Don't search DEBUG_INSNs for removable zero extends.
[official-gcc.git] / gcc / ada / gnat_rm.texi
blobe4a39e1671b9a5b15f68f5fba9fcadc9b5e2f00f
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  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
35 @syncodeindex fn cp
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
52 @insertcopying
54 @end titlepage
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
60 @noindent
61 GNAT Reference Manual
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
67 @noindent
68 AdaCore
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Obsolescent Features::
85 * GNU Free Documentation License::
86 * Index::
88  --- The Detailed Node Listing ---
90 About This Guide
92 * What This Reference Manual Contains::
93 * Related Information::
95 Implementation Defined Pragmas
97 * Pragma Abort_Defer::
98 * Pragma Ada_83::
99 * Pragma Ada_95::
100 * Pragma Ada_05::
101 * Pragma Ada_2005::
102 * Pragma Ada_12::
103 * Pragma Ada_2012::
104 * Pragma Annotate::
105 * Pragma Assert::
106 * Pragma Assume_No_Invalid_Values::
107 * Pragma Ast_Entry::
108 * Pragma C_Pass_By_Copy::
109 * Pragma Check::
110 * Pragma Check_Name::
111 * Pragma Check_Policy::
112 * Pragma Comment::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Compiler_Unit::
117 * Pragma Complete_Representation::
118 * Pragma Complex_Representation::
119 * Pragma Component_Alignment::
120 * Pragma Convention_Identifier::
121 * Pragma CPP_Class::
122 * Pragma CPP_Constructor::
123 * Pragma CPP_Virtual::
124 * Pragma CPP_Vtable::
125 * Pragma Debug::
126 * Pragma Debug_Policy::
127 * Pragma Detect_Blocking::
128 * Pragma Elaboration_Checks::
129 * Pragma Eliminate::
130 * Pragma Export_Exception::
131 * Pragma Export_Function::
132 * Pragma Export_Object::
133 * Pragma Export_Procedure::
134 * Pragma Export_Value::
135 * Pragma Export_Valued_Procedure::
136 * Pragma Extend_System::
137 * Pragma Extensions_Allowed::
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 Short_Circuit_And_Or::
188 * Pragma Source_File_Name::
189 * Pragma Source_File_Name_Project::
190 * Pragma Source_Reference::
191 * Pragma Stream_Convert::
192 * Pragma Style_Checks::
193 * Pragma Subtitle::
194 * Pragma Suppress::
195 * Pragma Suppress_All::
196 * Pragma Suppress_Exception_Locations::
197 * Pragma Suppress_Initialization::
198 * Pragma Task_Info::
199 * Pragma Task_Name::
200 * Pragma Task_Storage::
201 * Pragma Thread_Local_Storage::
202 * Pragma Time_Slice::
203 * Pragma Title::
204 * Pragma Unchecked_Union::
205 * Pragma Unimplemented_Unit::
206 * Pragma Universal_Aliasing ::
207 * Pragma Universal_Data::
208 * Pragma Unmodified::
209 * Pragma Unreferenced::
210 * Pragma Unreferenced_Objects::
211 * Pragma Unreserve_All_Interrupts::
212 * Pragma Unsuppress::
213 * Pragma Use_VADS_Size::
214 * Pragma Validity_Checks::
215 * Pragma Volatile::
216 * Pragma Warnings::
217 * Pragma Weak_External::
218 * Pragma Wide_Character_Encoding::
220 Implementation Defined Attributes
222 * Abort_Signal::
223 * Address_Size::
224 * Asm_Input::
225 * Asm_Output::
226 * AST_Entry::
227 * Bit::
228 * Bit_Position::
229 * Compiler_Version::
230 * Code_Address::
231 * Default_Bit_Order::
232 * Elaborated::
233 * Elab_Body::
234 * Elab_Spec::
235 * Emax::
236 * Enabled::
237 * Enum_Rep::
238 * Enum_Val::
239 * Epsilon::
240 * Fixed_Value::
241 * Has_Access_Values::
242 * Has_Discriminants::
243 * Img::
244 * Integer_Value::
245 * Invalid_Value::
246 * Large::
247 * Machine_Size::
248 * Mantissa::
249 * Max_Interrupt_Priority::
250 * Max_Priority::
251 * Maximum_Alignment::
252 * Mechanism_Code::
253 * Null_Parameter::
254 * Object_Size::
255 * Old::
256 * Passed_By_Reference::
257 * Pool_Address::
258 * Range_Length::
259 * Result::
260 * Safe_Emax::
261 * Safe_Large::
262 * Small::
263 * Storage_Unit::
264 * Stub_Type::
265 * Target_Name::
266 * Tick::
267 * To_Address::
268 * Type_Class::
269 * UET_Address::
270 * Unconstrained_Array::
271 * Universal_Literal_String::
272 * Unrestricted_Access::
273 * VADS_Size::
274 * Value_Size::
275 * Wchar_T_Size::
276 * Word_Size::
278 The Implementation of Standard I/O
280 * Standard I/O Packages::
281 * FORM Strings::
282 * Direct_IO::
283 * Sequential_IO::
284 * Text_IO::
285 * Wide_Text_IO::
286 * Wide_Wide_Text_IO::
287 * Stream_IO::
288 * Text Translation::
289 * Shared Files::
290 * Filenames encoding::
291 * Open Modes::
292 * Operations on C Streams::
293 * Interfacing to C Streams::
295 The GNAT Library
297 * Ada.Characters.Latin_9 (a-chlat9.ads)::
298 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
299 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
300 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
301 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
302 * Ada.Command_Line.Environment (a-colien.ads)::
303 * Ada.Command_Line.Remove (a-colire.ads)::
304 * Ada.Command_Line.Response_File (a-clrefi.ads)::
305 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
306 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
307 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
308 * Ada.Exceptions.Traceback (a-exctra.ads)::
309 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
310 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
311 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
312 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
313 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
314 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
315 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
316 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
317 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
318 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
319 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
320 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
321 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
322 * GNAT.Altivec (g-altive.ads)::
323 * GNAT.Altivec.Conversions (g-altcon.ads)::
324 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
325 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
326 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
327 * GNAT.Array_Split (g-arrspl.ads)::
328 * GNAT.AWK (g-awk.ads)::
329 * GNAT.Bounded_Buffers (g-boubuf.ads)::
330 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
331 * GNAT.Bubble_Sort (g-bubsor.ads)::
332 * GNAT.Bubble_Sort_A (g-busora.ads)::
333 * GNAT.Bubble_Sort_G (g-busorg.ads)::
334 * GNAT.Byte_Order_Mark (g-byorma.ads)::
335 * GNAT.Byte_Swapping (g-bytswa.ads)::
336 * GNAT.Calendar (g-calend.ads)::
337 * GNAT.Calendar.Time_IO (g-catiio.ads)::
338 * GNAT.Case_Util (g-casuti.ads)::
339 * GNAT.CGI (g-cgi.ads)::
340 * GNAT.CGI.Cookie (g-cgicoo.ads)::
341 * GNAT.CGI.Debug (g-cgideb.ads)::
342 * GNAT.Command_Line (g-comlin.ads)::
343 * GNAT.Compiler_Version (g-comver.ads)::
344 * GNAT.Ctrl_C (g-ctrl_c.ads)::
345 * GNAT.CRC32 (g-crc32.ads)::
346 * GNAT.Current_Exception (g-curexc.ads)::
347 * GNAT.Debug_Pools (g-debpoo.ads)::
348 * GNAT.Debug_Utilities (g-debuti.ads)::
349 * GNAT.Decode_String (g-decstr.ads)::
350 * GNAT.Decode_UTF8_String (g-deutst.ads)::
351 * GNAT.Directory_Operations (g-dirope.ads)::
352 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
353 * GNAT.Dynamic_HTables (g-dynhta.ads)::
354 * GNAT.Dynamic_Tables (g-dyntab.ads)::
355 * GNAT.Encode_String (g-encstr.ads)::
356 * GNAT.Encode_UTF8_String (g-enutst.ads)::
357 * GNAT.Exception_Actions (g-excact.ads)::
358 * GNAT.Exception_Traces (g-exctra.ads)::
359 * GNAT.Exceptions (g-except.ads)::
360 * GNAT.Expect (g-expect.ads)::
361 * GNAT.Float_Control (g-flocon.ads)::
362 * GNAT.Heap_Sort (g-heasor.ads)::
363 * GNAT.Heap_Sort_A (g-hesora.ads)::
364 * GNAT.Heap_Sort_G (g-hesorg.ads)::
365 * GNAT.HTable (g-htable.ads)::
366 * GNAT.IO (g-io.ads)::
367 * GNAT.IO_Aux (g-io_aux.ads)::
368 * GNAT.Lock_Files (g-locfil.ads)::
369 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
370 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
371 * GNAT.MD5 (g-md5.ads)::
372 * GNAT.Memory_Dump (g-memdum.ads)::
373 * GNAT.Most_Recent_Exception (g-moreex.ads)::
374 * GNAT.OS_Lib (g-os_lib.ads)::
375 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
376 * GNAT.Random_Numbers (g-rannum.ads)::
377 * GNAT.Regexp (g-regexp.ads)::
378 * GNAT.Registry (g-regist.ads)::
379 * GNAT.Regpat (g-regpat.ads)::
380 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
381 * GNAT.Semaphores (g-semaph.ads)::
382 * GNAT.Serial_Communications (g-sercom.ads)::
383 * GNAT.SHA1 (g-sha1.ads)::
384 * GNAT.SHA224 (g-sha224.ads)::
385 * GNAT.SHA256 (g-sha256.ads)::
386 * GNAT.SHA384 (g-sha384.ads)::
387 * GNAT.SHA512 (g-sha512.ads)::
388 * GNAT.Signals (g-signal.ads)::
389 * GNAT.Sockets (g-socket.ads)::
390 * GNAT.Source_Info (g-souinf.ads)::
391 * GNAT.Spelling_Checker (g-speche.ads)::
392 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
393 * GNAT.Spitbol.Patterns (g-spipat.ads)::
394 * GNAT.Spitbol (g-spitbo.ads)::
395 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
396 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
397 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
398 * GNAT.SSE (g-sse.ads)::
399 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
400 * GNAT.Strings (g-string.ads)::
401 * GNAT.String_Split (g-strspl.ads)::
402 * GNAT.Table (g-table.ads)::
403 * GNAT.Task_Lock (g-tasloc.ads)::
404 * GNAT.Threads (g-thread.ads)::
405 * GNAT.Time_Stamp (g-timsta.ads)::
406 * GNAT.Traceback (g-traceb.ads)::
407 * GNAT.Traceback.Symbolic (g-trasym.ads)::
408 * GNAT.UTF_32 (g-utf_32.ads)::
409 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
410 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
411 * GNAT.Wide_String_Split (g-wistsp.ads)::
412 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
413 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
414 * Interfaces.C.Extensions (i-cexten.ads)::
415 * Interfaces.C.Streams (i-cstrea.ads)::
416 * Interfaces.CPP (i-cpp.ads)::
417 * Interfaces.Packed_Decimal (i-pacdec.ads)::
418 * Interfaces.VxWorks (i-vxwork.ads)::
419 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
420 * System.Address_Image (s-addima.ads)::
421 * System.Assertions (s-assert.ads)::
422 * System.Memory (s-memory.ads)::
423 * System.Partition_Interface (s-parint.ads)::
424 * System.Pool_Global (s-pooglo.ads)::
425 * System.Pool_Local (s-pooloc.ads)::
426 * System.Restrictions (s-restri.ads)::
427 * System.Rident (s-rident.ads)::
428 * System.Strings.Stream_Ops (s-ststop.ads)::
429 * System.Task_Info (s-tasinf.ads)::
430 * System.Wch_Cnv (s-wchcnv.ads)::
431 * System.Wch_Con (s-wchcon.ads)::
433 Text_IO
435 * Text_IO Stream Pointer Positioning::
436 * Text_IO Reading and Writing Non-Regular Files::
437 * Get_Immediate::
438 * Treating Text_IO Files as Streams::
439 * Text_IO Extensions::
440 * Text_IO Facilities for Unbounded Strings::
442 Wide_Text_IO
444 * Wide_Text_IO Stream Pointer Positioning::
445 * Wide_Text_IO Reading and Writing Non-Regular Files::
447 Wide_Wide_Text_IO
449 * Wide_Wide_Text_IO Stream Pointer Positioning::
450 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
452 Interfacing to Other Languages
454 * Interfacing to C::
455 * Interfacing to C++::
456 * Interfacing to COBOL::
457 * Interfacing to Fortran::
458 * Interfacing to non-GNAT Ada code::
460 Specialized Needs Annexes
462 Implementation of Specific Ada Features
463 * Machine Code Insertions::
464 * GNAT Implementation of Tasking::
465 * GNAT Implementation of Shared Passive Packages::
466 * Code Generation for Array Aggregates::
467 * The Size of Discriminated Records with Default Discriminants::
468 * Strict Conformance to the Ada Reference Manual::
470 Obsolescent Features
472 GNU Free Documentation License
474 Index
475 @end menu
477 @end ifnottex
479 @node About This Guide
480 @unnumbered About This Guide
482 @noindent
483 This manual contains useful information in writing programs using the
484 @value{EDITION} compiler.  It includes information on implementation dependent
485 characteristics of @value{EDITION}, including all the information required by
486 Annex M of the Ada language standard.
488 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
489 Ada 83 compatibility mode.
490 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
491 but you can override with a compiler switch
492 to explicitly specify the language version.
493 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
494 @value{EDITION} User's Guide}, for details on these switches.)
495 Throughout this manual, references to ``Ada'' without a year suffix
496 apply to both the Ada 95 and Ada 2005 versions of the language.
498 Ada is designed to be highly portable.
499 In general, a program will have the same effect even when compiled by
500 different compilers on different platforms.
501 However, since Ada is designed to be used in a
502 wide variety of applications, it also contains a number of system
503 dependent features to be used in interfacing to the external world.
504 @cindex Implementation-dependent features
505 @cindex Portability
507 Note: Any program that makes use of implementation-dependent features
508 may be non-portable.  You should follow good programming practice and
509 isolate and clearly document any sections of your program that make use
510 of these features in a non-portable manner.
512 @ifset PROEDITION
513 For ease of exposition, ``GNAT Pro'' will be referred to simply as
514 ``GNAT'' in the remainder of this document.
515 @end ifset
517 @menu
518 * What This Reference Manual Contains::
519 * Conventions::
520 * Related Information::
521 @end menu
523 @node What This Reference Manual Contains
524 @unnumberedsec What This Reference Manual Contains
526 @noindent
527 This reference manual contains the following chapters:
529 @itemize @bullet
530 @item
531 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
532 pragmas, which can be used to extend and enhance the functionality of the
533 compiler.
535 @item
536 @ref{Implementation Defined Attributes}, lists GNAT
537 implementation-dependent attributes which can be used to extend and
538 enhance the functionality of the compiler.
540 @item
541 @ref{Implementation Advice}, provides information on generally
542 desirable behavior which are not requirements that all compilers must
543 follow since it cannot be provided on all systems, or which may be
544 undesirable on some systems.
546 @item
547 @ref{Implementation Defined Characteristics}, provides a guide to
548 minimizing implementation dependent features.
550 @item
551 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
552 implemented by GNAT, and how they can be imported into user
553 application programs.
555 @item
556 @ref{Representation Clauses and Pragmas}, describes in detail the
557 way that GNAT represents data, and in particular the exact set
558 of representation clauses and pragmas that is accepted.
560 @item
561 @ref{Standard Library Routines}, provides a listing of packages and a
562 brief description of the functionality that is provided by Ada's
563 extensive set of standard library routines as implemented by GNAT@.
565 @item
566 @ref{The Implementation of Standard I/O}, details how the GNAT
567 implementation of the input-output facilities.
569 @item
570 @ref{The GNAT Library}, is a catalog of packages that complement
571 the Ada predefined library.
573 @item
574 @ref{Interfacing to Other Languages}, describes how programs
575 written in Ada using GNAT can be interfaced to other programming
576 languages.
578 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
579 of the specialized needs annexes.
581 @item
582 @ref{Implementation of Specific Ada Features}, discusses issues related
583 to GNAT's implementation of machine code insertions, tasking, and several
584 other features.
586 @item
587 @ref{Obsolescent Features} documents implementation dependent features,
588 including pragmas and attributes, which are considered obsolescent, since
589 there are other preferred ways of achieving the same results. These
590 obsolescent forms are retained for backwards compatibility.
592 @end itemize
594 @cindex Ada 95 Language Reference Manual
595 @cindex Ada 2005 Language Reference Manual
596 @noindent
597 This reference manual assumes a basic familiarity with the Ada 95 language, as
598 described in the International Standard ANSI/ISO/IEC-8652:1995,
599 January 1995.
600 It does not require knowledge of the new features introduced by Ada 2005,
601 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
602 and Amendment 1).
603 Both reference manuals are included in the GNAT documentation
604 package.
606 @node Conventions
607 @unnumberedsec Conventions
608 @cindex Conventions, typographical
609 @cindex Typographical conventions
611 @noindent
612 Following are examples of the typographical and graphic conventions used
613 in this guide:
615 @itemize @bullet
616 @item
617 @code{Functions}, @code{utility program names}, @code{standard names},
618 and @code{classes}.
620 @item
621 @code{Option flags}
623 @item
624 @file{File names}, @samp{button names}, and @samp{field names}.
626 @item
627 @code{Variables}, @env{environment variables}, and @var{metasyntactic
628 variables}.
630 @item
631 @emph{Emphasis}.
633 @item
634 [optional information or parameters]
636 @item
637 Examples are described by text
638 @smallexample
639 and then shown this way.
640 @end smallexample
641 @end itemize
643 @noindent
644 Commands that are entered by the user are preceded in this manual by the
645 characters @samp{$ } (dollar sign followed by space).  If your system uses this
646 sequence as a prompt, then the commands will appear exactly as you see them
647 in the manual.  If your system uses some other prompt, then the command will
648 appear with the @samp{$} replaced by whatever prompt character you are using.
650 @node Related Information
651 @unnumberedsec Related Information
652 @noindent
653 See the following documents for further information on GNAT:
655 @itemize @bullet
656 @item
657 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
658 @value{EDITION} User's Guide}, which provides information on how to use the
659 GNAT compiler system.
661 @item
662 @cite{Ada 95 Reference Manual}, which contains all reference
663 material for the Ada 95 programming language.
665 @item
666 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
667 of the Ada 95 standard.  The annotations describe
668 detailed aspects of the design decision, and in particular contain useful
669 sections on Ada 83 compatibility.
671 @item
672 @cite{Ada 2005 Reference Manual}, which contains all reference
673 material for the Ada 2005 programming language.
675 @item
676 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
677 of the Ada 2005 standard.  The annotations describe
678 detailed aspects of the design decision, and in particular contain useful
679 sections on Ada 83 and Ada 95 compatibility.
681 @item
682 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
683 which contains specific information on compatibility between GNAT and
684 DEC Ada 83 systems.
686 @item
687 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
688 describes in detail the pragmas and attributes provided by the DEC Ada 83
689 compiler system.
691 @end itemize
693 @node Implementation Defined Pragmas
694 @chapter Implementation Defined Pragmas
696 @noindent
697 Ada defines a set of pragmas that can be used to supply additional
698 information to the compiler.  These language defined pragmas are
699 implemented in GNAT and work as described in the Ada Reference Manual.
701 In addition, Ada allows implementations to define additional pragmas
702 whose meaning is defined by the implementation.  GNAT provides a number
703 of these implementation-defined pragmas, which can be used to extend
704 and enhance the functionality of the compiler.  This section of the GNAT
705 Reference Manual describes these additional pragmas.
707 Note that any program using these pragmas might not be portable to other
708 compilers (although GNAT implements this set of pragmas on all
709 platforms).  Therefore if portability to other compilers is an important
710 consideration, the use of these pragmas should be minimized.
712 @menu
713 * Pragma Abort_Defer::
714 * Pragma Ada_83::
715 * Pragma Ada_95::
716 * Pragma Ada_05::
717 * Pragma Ada_2005::
718 * Pragma Ada_12::
719 * Pragma Ada_2012::
720 * Pragma Annotate::
721 * Pragma Assert::
722 * Pragma Assume_No_Invalid_Values::
723 * Pragma Ast_Entry::
724 * Pragma C_Pass_By_Copy::
725 * Pragma Check::
726 * Pragma Check_Name::
727 * Pragma Check_Policy::
728 * Pragma Comment::
729 * Pragma Common_Object::
730 * Pragma Compile_Time_Error::
731 * Pragma Compile_Time_Warning::
732 * Pragma Compiler_Unit::
733 * Pragma Complete_Representation::
734 * Pragma Complex_Representation::
735 * Pragma Component_Alignment::
736 * Pragma Convention_Identifier::
737 * Pragma CPP_Class::
738 * Pragma CPP_Constructor::
739 * Pragma CPP_Virtual::
740 * Pragma CPP_Vtable::
741 * Pragma Debug::
742 * Pragma Debug_Policy::
743 * Pragma Detect_Blocking::
744 * Pragma Elaboration_Checks::
745 * Pragma Eliminate::
746 * Pragma Export_Exception::
747 * Pragma Export_Function::
748 * Pragma Export_Object::
749 * Pragma Export_Procedure::
750 * Pragma Export_Value::
751 * Pragma Export_Valued_Procedure::
752 * Pragma Extend_System::
753 * Pragma Extensions_Allowed::
754 * Pragma External::
755 * Pragma External_Name_Casing::
756 * Pragma Fast_Math::
757 * Pragma Favor_Top_Level::
758 * Pragma Finalize_Storage_Only::
759 * Pragma Float_Representation::
760 * Pragma Ident::
761 * Pragma Implemented_By_Entry::
762 * Pragma Implicit_Packing::
763 * Pragma Import_Exception::
764 * Pragma Import_Function::
765 * Pragma Import_Object::
766 * Pragma Import_Procedure::
767 * Pragma Import_Valued_Procedure::
768 * Pragma Initialize_Scalars::
769 * Pragma Inline_Always::
770 * Pragma Inline_Generic::
771 * Pragma Interface::
772 * Pragma Interface_Name::
773 * Pragma Interrupt_Handler::
774 * Pragma Interrupt_State::
775 * Pragma Keep_Names::
776 * Pragma License::
777 * Pragma Link_With::
778 * Pragma Linker_Alias::
779 * Pragma Linker_Constructor::
780 * Pragma Linker_Destructor::
781 * Pragma Linker_Section::
782 * Pragma Long_Float::
783 * Pragma Machine_Attribute::
784 * Pragma Main::
785 * Pragma Main_Storage::
786 * Pragma No_Body::
787 * Pragma No_Return::
788 * Pragma No_Strict_Aliasing::
789 * Pragma Normalize_Scalars::
790 * Pragma Obsolescent::
791 * Pragma Optimize_Alignment::
792 * Pragma Passive::
793 * Pragma Persistent_BSS::
794 * Pragma Polling::
795 * Pragma Postcondition::
796 * Pragma Precondition::
797 * Pragma Profile (Ravenscar)::
798 * Pragma Profile (Restricted)::
799 * Pragma Psect_Object::
800 * Pragma Pure_Function::
801 * Pragma Restriction_Warnings::
802 * Pragma Shared::
803 * Pragma Short_Circuit_And_Or::
804 * Pragma Source_File_Name::
805 * Pragma Source_File_Name_Project::
806 * Pragma Source_Reference::
807 * Pragma Stream_Convert::
808 * Pragma Style_Checks::
809 * Pragma Subtitle::
810 * Pragma Suppress::
811 * Pragma Suppress_All::
812 * Pragma Suppress_Exception_Locations::
813 * Pragma Suppress_Initialization::
814 * Pragma Task_Info::
815 * Pragma Task_Name::
816 * Pragma Task_Storage::
817 * Pragma Thread_Local_Storage::
818 * Pragma Time_Slice::
819 * Pragma Title::
820 * Pragma Unchecked_Union::
821 * Pragma Unimplemented_Unit::
822 * Pragma Universal_Aliasing ::
823 * Pragma Universal_Data::
824 * Pragma Unmodified::
825 * Pragma Unreferenced::
826 * Pragma Unreferenced_Objects::
827 * Pragma Unreserve_All_Interrupts::
828 * Pragma Unsuppress::
829 * Pragma Use_VADS_Size::
830 * Pragma Validity_Checks::
831 * Pragma Volatile::
832 * Pragma Warnings::
833 * Pragma Weak_External::
834 * Pragma Wide_Character_Encoding::
835 @end menu
837 @node Pragma Abort_Defer
838 @unnumberedsec Pragma Abort_Defer
839 @findex Abort_Defer
840 @cindex Deferring aborts
841 @noindent
842 Syntax:
843 @smallexample
844 pragma Abort_Defer;
845 @end smallexample
847 @noindent
848 This pragma must appear at the start of the statement sequence of a
849 handled sequence of statements (right after the @code{begin}).  It has
850 the effect of deferring aborts for the sequence of statements (but not
851 for the declarations or handlers, if any, associated with this statement
852 sequence).
854 @node Pragma Ada_83
855 @unnumberedsec Pragma Ada_83
856 @findex Ada_83
857 @noindent
858 Syntax:
859 @smallexample @c ada
860 pragma Ada_83;
861 @end smallexample
863 @noindent
864 A configuration pragma that establishes Ada 83 mode for the unit to
865 which it applies, regardless of the mode set by the command line
866 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
867 the syntax and semantics of Ada 83, as defined in the original Ada
868 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
869 and Ada 2005 are not recognized, optional package bodies are allowed,
870 and generics may name types with unknown discriminants without using
871 the @code{(<>)} notation.  In addition, some but not all of the additional
872 restrictions of Ada 83 are enforced.
874 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
875 Ada 83 code to be compiled and adapted to GNAT with less effort.
876 Secondly, it aids in keeping code backwards compatible with Ada 83.
877 However, there is no guarantee that code that is processed correctly
878 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
879 83 compiler, since GNAT does not enforce all the additional checks
880 required by Ada 83.
882 @node Pragma Ada_95
883 @unnumberedsec Pragma Ada_95
884 @findex Ada_95
885 @noindent
886 Syntax:
887 @smallexample @c ada
888 pragma Ada_95;
889 @end smallexample
891 @noindent
892 A configuration pragma that establishes Ada 95 mode for the unit to which
893 it applies, regardless of the mode set by the command line switches.
894 This mode is set automatically for the @code{Ada} and @code{System}
895 packages and their children, so you need not specify it in these
896 contexts.  This pragma is useful when writing a reusable component that
897 itself uses Ada 95 features, but which is intended to be usable from
898 either Ada 83 or Ada 95 programs.
900 @node Pragma Ada_05
901 @unnumberedsec Pragma Ada_05
902 @findex Ada_05
903 @noindent
904 Syntax:
905 @smallexample @c ada
906 pragma Ada_05;
907 @end smallexample
909 @noindent
910 A configuration pragma that establishes Ada 2005 mode for the unit to which
911 it applies, regardless of the mode set by the command line switches.
912 This pragma is useful when writing a reusable component that
913 itself uses Ada 2005 features, but which is intended to be usable from
914 either Ada 83 or Ada 95 programs.
916 @node Pragma Ada_2005
917 @unnumberedsec Pragma Ada_2005
918 @findex Ada_2005
919 @noindent
920 Syntax:
921 @smallexample @c ada
922 pragma Ada_2005;
923 @end smallexample
925 @noindent
926 This configuration pragma is a synonym for pragma Ada_05 and has the
927 same syntax and effect.
929 @node Pragma Ada_12
930 @unnumberedsec Pragma Ada_12
931 @findex Ada_12
932 @noindent
933 Syntax:
934 @smallexample @c ada
935 pragma Ada_12;
936 @end smallexample
938 @noindent
939 A configuration pragma that establishes Ada 2012 mode for the unit to which
940 it applies, regardless of the mode set by the command line switches.
941 This mode is set automatically for the @code{Ada} and @code{System}
942 packages and their children, so you need not specify it in these
943 contexts.  This pragma is useful when writing a reusable component that
944 itself uses Ada 2012 features, but which is intended to be usable from
945 Ada 83, Ada 95, or Ada 2005 programs.
947 @node Pragma Ada_2012
948 @unnumberedsec Pragma Ada_2012
949 @findex Ada_2005
950 @noindent
951 Syntax:
952 @smallexample @c ada
953 pragma Ada_2012;
954 @end smallexample
956 @noindent
957 This configuration pragma is a synonym for pragma Ada_12 and has the
958 same syntax and effect.
960 @node Pragma Annotate
961 @unnumberedsec Pragma Annotate
962 @findex Annotate
963 @noindent
964 Syntax:
965 @smallexample @c ada
966 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
968 ARG ::= NAME | EXPRESSION
969 @end smallexample
971 @noindent
972 This pragma is used to annotate programs.  @var{identifier} identifies
973 the type of annotation.  GNAT verifies that it is an identifier, but does
974 not otherwise analyze it. The second optional identifier is also left
975 unanalyzed, and by convention is used to control the action of the tool to
976 which the annotation is addressed.  The remaining @var{arg} arguments
977 can be either string literals or more generally expressions.
978 String literals are assumed to be either of type
979 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
980 depending on the character literals they contain.
981 All other kinds of arguments are analyzed as expressions, and must be
982 unambiguous.
984 The analyzed pragma is retained in the tree, but not otherwise processed
985 by any part of the GNAT compiler.  This pragma is intended for use by
986 external tools, including ASIS@.
988 @node Pragma Assert
989 @unnumberedsec Pragma Assert
990 @findex Assert
991 @noindent
992 Syntax:
993 @smallexample @c ada
994 pragma Assert (
995   boolean_EXPRESSION
996   [, string_EXPRESSION]);
997 @end smallexample
999 @noindent
1000 The effect of this pragma depends on whether the corresponding command
1001 line switch is set to activate assertions.  The pragma expands into code
1002 equivalent to the following:
1004 @smallexample @c ada
1005 if assertions-enabled then
1006    if not boolean_EXPRESSION then
1007       System.Assertions.Raise_Assert_Failure
1008         (string_EXPRESSION);
1009    end if;
1010 end if;
1011 @end smallexample
1013 @noindent
1014 The string argument, if given, is the message that will be associated
1015 with the exception occurrence if the exception is raised.  If no second
1016 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1017 where @var{file} is the name of the source file containing the assert,
1018 and @var{nnn} is the line number of the assert.  A pragma is not a
1019 statement, so if a statement sequence contains nothing but a pragma
1020 assert, then a null statement is required in addition, as in:
1022 @smallexample @c ada
1023 @dots{}
1024 if J > 3 then
1025    pragma Assert (K > 3, "Bad value for K");
1026    null;
1027 end if;
1028 @end smallexample
1030 @noindent
1031 Note that, as with the @code{if} statement to which it is equivalent, the
1032 type of the expression is either @code{Standard.Boolean}, or any type derived
1033 from this standard type.
1035 If assertions are disabled (switch @option{-gnata} not used), then there
1036 is no run-time effect (and in particular, any side effects from the
1037 expression will not occur at run time).  (The expression is still
1038 analyzed at compile time, and may cause types to be frozen if they are
1039 mentioned here for the first time).
1041 If assertions are enabled, then the given expression is tested, and if
1042 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1043 which results in the raising of @code{Assert_Failure} with the given message.
1045 You should generally avoid side effects in the expression arguments of
1046 this pragma, because these side effects will turn on and off with the
1047 setting of the assertions mode, resulting in assertions that have an
1048 effect on the program.  However, the expressions are analyzed for
1049 semantic correctness whether or not assertions are enabled, so turning
1050 assertions on and off cannot affect the legality of a program.
1052 @node Pragma Assume_No_Invalid_Values
1053 @unnumberedsec Pragma Assume_No_Invalid_Values
1054 @findex Assume_No_Invalid_Values
1055 @cindex Invalid representations
1056 @cindex Invalid values
1057 @noindent
1058 Syntax:
1059 @smallexample @c ada
1060 pragma Assume_No_Invalid_Values (On | Off);
1061 @end smallexample
1063 @noindent
1064 This is a configuration pragma that controls the assumptions made by the
1065 compiler about the occurrence of invalid representations (invalid values)
1066 in the code.
1068 The default behavior (corresponding to an Off argument for this pragma), is
1069 to assume that values may in general be invalid unless the compiler can
1070 prove they are valid. Consider the following example:
1072 @smallexample @c ada
1073 V1 : Integer range 1 .. 10;
1074 V2 : Integer range 11 .. 20;
1076 for J in V2 .. V1 loop
1077    ...
1078 end loop;
1079 @end smallexample
1081 @noindent
1082 if V1 and V2 have valid values, then the loop is known at compile
1083 time not to execute since the lower bound must be greater than the
1084 upper bound. However in default mode, no such assumption is made,
1085 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1086 is given, the compiler will assume that any occurrence of a variable
1087 other than in an explicit @code{'Valid} test always has a valid
1088 value, and the loop above will be optimized away.
1090 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1091 you know your code is free of uninitialized variables and other
1092 possible sources of invalid representations, and may result in
1093 more efficient code. A program that accesses an invalid representation
1094 with this pragma in effect is erroneous, so no guarantees can be made
1095 about its behavior.
1097 It is peculiar though permissible to use this pragma in conjunction
1098 with validity checking (-gnatVa). In such cases, accessing invalid
1099 values will generally give an exception, though formally the program
1100 is erroneous so there are no guarantees that this will always be the
1101 case, and it is recommended that these two options not be used together.
1103 @node Pragma Ast_Entry
1104 @unnumberedsec Pragma Ast_Entry
1105 @cindex OpenVMS
1106 @findex Ast_Entry
1107 @noindent
1108 Syntax:
1109 @smallexample @c ada
1110 pragma AST_Entry (entry_IDENTIFIER);
1111 @end smallexample
1113 @noindent
1114 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1115 argument is the simple name of a single entry; at most one @code{AST_Entry}
1116 pragma is allowed for any given entry.  This pragma must be used in
1117 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1118 the entry declaration and in the same task type specification or single task
1119 as the entry to which it applies.  This pragma specifies that the given entry
1120 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1121 resulting from an OpenVMS system service call.  The pragma does not affect
1122 normal use of the entry.  For further details on this pragma, see the
1123 DEC Ada Language Reference Manual, section 9.12a.
1125 @node Pragma C_Pass_By_Copy
1126 @unnumberedsec Pragma C_Pass_By_Copy
1127 @cindex Passing by copy
1128 @findex C_Pass_By_Copy
1129 @noindent
1130 Syntax:
1131 @smallexample @c ada
1132 pragma C_Pass_By_Copy
1133   ([Max_Size =>] static_integer_EXPRESSION);
1134 @end smallexample
1136 @noindent
1137 Normally the default mechanism for passing C convention records to C
1138 convention subprograms is to pass them by reference, as suggested by RM
1139 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1140 this default, by requiring that record formal parameters be passed by
1141 copy if all of the following conditions are met:
1143 @itemize @bullet
1144 @item
1145 The size of the record type does not exceed the value specified for
1146 @code{Max_Size}.
1147 @item
1148 The record type has @code{Convention C}.
1149 @item
1150 The formal parameter has this record type, and the subprogram has a
1151 foreign (non-Ada) convention.
1152 @end itemize
1154 @noindent
1155 If these conditions are met the argument is passed by copy, i.e.@: in a
1156 manner consistent with what C expects if the corresponding formal in the
1157 C prototype is a struct (rather than a pointer to a struct).
1159 You can also pass records by copy by specifying the convention
1160 @code{C_Pass_By_Copy} for the record type, or by using the extended
1161 @code{Import} and @code{Export} pragmas, which allow specification of
1162 passing mechanisms on a parameter by parameter basis.
1164 @node Pragma Check
1165 @unnumberedsec Pragma Check
1166 @cindex Assertions
1167 @cindex Named assertions
1168 @findex Check
1169 @noindent
1170 Syntax:
1171 @smallexample @c ada
1172 pragma Check (
1173      [Name    =>] Identifier,
1174      [Check   =>] Boolean_EXPRESSION
1175   [, [Message =>] string_EXPRESSION] );
1176 @end smallexample
1178 @noindent
1179 This pragma is similar to the predefined pragma @code{Assert} except that an
1180 extra identifier argument is present. In conjunction with pragma
1181 @code{Check_Policy}, this can be used to define groups of assertions that can
1182 be independently controlled. The identifier @code{Assertion} is special, it
1183 refers to the normal set of pragma @code{Assert} statements. The identifiers
1184 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1185 names, so these three names would normally not be used directly in a pragma
1186 @code{Check}.
1188 Checks introduced by this pragma are normally deactivated by default. They can
1189 be activated either by the command line option @option{-gnata}, which turns on
1190 all checks, or individually controlled using pragma @code{Check_Policy}.
1192 @node Pragma Check_Name
1193 @unnumberedsec Pragma Check_Name
1194 @cindex Defining check names
1195 @cindex Check names, defining
1196 @findex Check_Name
1197 @noindent
1198 Syntax:
1199 @smallexample @c ada
1200 pragma Check_Name (check_name_IDENTIFIER);
1201 @end smallexample
1203 @noindent
1204 This is a configuration pragma that defines a new implementation
1205 defined check name (unless IDENTIFIER matches one of the predefined
1206 check names, in which case the pragma has no effect). Check names
1207 are global to a partition, so if two or more configuration pragmas
1208 are present in a partition mentioning the same name, only one new
1209 check name is introduced.
1211 An implementation defined check name introduced with this pragma may
1212 be used in only three contexts: @code{pragma Suppress},
1213 @code{pragma Unsuppress},
1214 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1215 any of these three cases, the check name must be visible. A check
1216 name is visible if it is in the configuration pragmas applying to
1217 the current unit, or if it appears at the start of any unit that
1218 is part of the dependency set of the current unit (e.g., units that
1219 are mentioned in @code{with} clauses).
1221 @node Pragma Check_Policy
1222 @unnumberedsec Pragma Check_Policy
1223 @cindex Controlling assertions
1224 @cindex Assertions, control
1225 @cindex Check pragma control
1226 @cindex Named assertions
1227 @findex Check
1228 @noindent
1229 Syntax:
1230 @smallexample @c ada
1231 pragma Check_Policy
1232  ([Name   =>] Identifier,
1233   [Policy =>] POLICY_IDENTIFIER);
1235 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1236 @end smallexample
1238 @noindent
1239 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1240 except that it controls sets of named assertions introduced using the
1241 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1242 @code{Assertion_Policy}) can be used within a declarative part, in which case
1243 it controls the status to the end of the corresponding construct (in a manner
1244 identical to pragma @code{Suppress)}.
1246 The identifier given as the first argument corresponds to a name used in
1247 associated @code{Check} pragmas. For example, if the pragma:
1249 @smallexample @c ada
1250 pragma Check_Policy (Critical_Error, Off);
1251 @end smallexample
1253 @noindent
1254 is given, then subsequent @code{Check} pragmas whose first argument is also
1255 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1256 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1257 @code{Check_Policy} with this identifier is similar to the normal
1258 @code{Assertion_Policy} pragma except that it can appear within a
1259 declarative part).
1261 The special identifiers @code{Precondition} and @code{Postcondition} control
1262 the status of preconditions and postconditions. If a @code{Precondition} pragma
1263 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1264 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1265 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1266 are recognized.
1268 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1269 to turn on corresponding checks. The default for a set of checks for which no
1270 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1271 @option{-gnata} is given, which turns on all checks by default.
1273 The check policy settings @code{Check} and @code{Ignore} are also recognized
1274 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1275 compatibility with the standard @code{Assertion_Policy} pragma.
1277 @node Pragma Comment
1278 @unnumberedsec Pragma Comment
1279 @findex Comment
1280 @noindent
1281 Syntax:
1283 @smallexample @c ada
1284 pragma Comment (static_string_EXPRESSION);
1285 @end smallexample
1287 @noindent
1288 This is almost identical in effect to pragma @code{Ident}.  It allows the
1289 placement of a comment into the object file and hence into the
1290 executable file if the operating system permits such usage.  The
1291 difference is that @code{Comment}, unlike @code{Ident}, has
1292 no limitations on placement of the pragma (it can be placed
1293 anywhere in the main source unit), and if more than one pragma
1294 is used, all comments are retained.
1296 @node Pragma Common_Object
1297 @unnumberedsec Pragma Common_Object
1298 @findex Common_Object
1299 @noindent
1300 Syntax:
1302 @smallexample @c ada
1303 pragma Common_Object (
1304      [Internal =>] LOCAL_NAME
1305   [, [External =>] EXTERNAL_SYMBOL]
1306   [, [Size     =>] EXTERNAL_SYMBOL] );
1308 EXTERNAL_SYMBOL ::=
1309   IDENTIFIER
1310 | static_string_EXPRESSION
1311 @end smallexample
1313 @noindent
1314 This pragma enables the shared use of variables stored in overlaid
1315 linker areas corresponding to the use of @code{COMMON}
1316 in Fortran.  The single
1317 object @var{LOCAL_NAME} is assigned to the area designated by
1318 the @var{External} argument.
1319 You may define a record to correspond to a series
1320 of fields.  The @var{Size} argument
1321 is syntax checked in GNAT, but otherwise ignored.
1323 @code{Common_Object} is not supported on all platforms.  If no
1324 support is available, then the code generator will issue a message
1325 indicating that the necessary attribute for implementation of this
1326 pragma is not available.
1328 @node Pragma Compile_Time_Error
1329 @unnumberedsec Pragma Compile_Time_Error
1330 @findex Compile_Time_Error
1331 @noindent
1332 Syntax:
1334 @smallexample @c ada
1335 pragma Compile_Time_Error
1336          (boolean_EXPRESSION, static_string_EXPRESSION);
1337 @end smallexample
1339 @noindent
1340 This pragma can be used to generate additional compile time
1341 error messages. It
1342 is particularly useful in generics, where errors can be issued for
1343 specific problematic instantiations. The first parameter is a boolean
1344 expression. The pragma is effective only if the value of this expression
1345 is known at compile time, and has the value True. The set of expressions
1346 whose values are known at compile time includes all static boolean
1347 expressions, and also other values which the compiler can determine
1348 at compile time (e.g., the size of a record type set by an explicit
1349 size representation clause, or the value of a variable which was
1350 initialized to a constant and is known not to have been modified).
1351 If these conditions are met, an error message is generated using
1352 the value given as the second argument. This string value may contain
1353 embedded ASCII.LF characters to break the message into multiple lines.
1355 @node Pragma Compile_Time_Warning
1356 @unnumberedsec Pragma Compile_Time_Warning
1357 @findex Compile_Time_Warning
1358 @noindent
1359 Syntax:
1361 @smallexample @c ada
1362 pragma Compile_Time_Warning
1363          (boolean_EXPRESSION, static_string_EXPRESSION);
1364 @end smallexample
1366 @noindent
1367 Same as pragma Compile_Time_Error, except a warning is issued instead
1368 of an error message. Note that if this pragma is used in a package that
1369 is with'ed by a client, the client will get the warning even though it
1370 is issued by a with'ed package (normally warnings in with'ed units are
1371 suppressed, but this is a special exception to that rule).
1373 One typical use is within a generic where compile time known characteristics
1374 of formal parameters are tested, and warnings given appropriately. Another use
1375 with a first parameter of True is to warn a client about use of a package,
1376 for example that it is not fully implemented.
1378 @node Pragma Compiler_Unit
1379 @unnumberedsec Pragma Compiler_Unit
1380 @findex Compiler_Unit
1381 @noindent
1382 Syntax:
1384 @smallexample @c ada
1385 pragma Compiler_Unit;
1386 @end smallexample
1388 @noindent
1389 This pragma is intended only for internal use in the GNAT run-time library.
1390 It indicates that the unit is used as part of the compiler build. The effect
1391 is to disallow constructs (raise with message, conditional expressions etc)
1392 that would cause trouble when bootstrapping using an older version of GNAT.
1393 For the exact list of restrictions, see the compiler sources and references
1394 to Is_Compiler_Unit.
1396 @node Pragma Complete_Representation
1397 @unnumberedsec Pragma Complete_Representation
1398 @findex Complete_Representation
1399 @noindent
1400 Syntax:
1402 @smallexample @c ada
1403 pragma Complete_Representation;
1404 @end smallexample
1406 @noindent
1407 This pragma must appear immediately within a record representation
1408 clause. Typical placements are before the first component clause
1409 or after the last component clause. The effect is to give an error
1410 message if any component is missing a component clause. This pragma
1411 may be used to ensure that a record representation clause is
1412 complete, and that this invariant is maintained if fields are
1413 added to the record in the future.
1415 @node Pragma Complex_Representation
1416 @unnumberedsec Pragma Complex_Representation
1417 @findex Complex_Representation
1418 @noindent
1419 Syntax:
1421 @smallexample @c ada
1422 pragma Complex_Representation
1423         ([Entity =>] LOCAL_NAME);
1424 @end smallexample
1426 @noindent
1427 The @var{Entity} argument must be the name of a record type which has
1428 two fields of the same floating-point type.  The effect of this pragma is
1429 to force gcc to use the special internal complex representation form for
1430 this record, which may be more efficient.  Note that this may result in
1431 the code for this type not conforming to standard ABI (application
1432 binary interface) requirements for the handling of record types.  For
1433 example, in some environments, there is a requirement for passing
1434 records by pointer, and the use of this pragma may result in passing
1435 this type in floating-point registers.
1437 @node Pragma Component_Alignment
1438 @unnumberedsec Pragma Component_Alignment
1439 @cindex Alignments of components
1440 @findex Component_Alignment
1441 @noindent
1442 Syntax:
1444 @smallexample @c ada
1445 pragma Component_Alignment (
1446      [Form =>] ALIGNMENT_CHOICE
1447   [, [Name =>] type_LOCAL_NAME]);
1449 ALIGNMENT_CHOICE ::=
1450   Component_Size
1451 | Component_Size_4
1452 | Storage_Unit
1453 | Default
1454 @end smallexample
1456 @noindent
1457 Specifies the alignment of components in array or record types.
1458 The meaning of the @var{Form} argument is as follows:
1460 @table @code
1461 @findex Component_Size
1462 @item Component_Size
1463 Aligns scalar components and subcomponents of the array or record type
1464 on boundaries appropriate to their inherent size (naturally
1465 aligned).  For example, 1-byte components are aligned on byte boundaries,
1466 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1467 integer components are aligned on 4-byte boundaries and so on.  These
1468 alignment rules correspond to the normal rules for C compilers on all
1469 machines except the VAX@.
1471 @findex Component_Size_4
1472 @item Component_Size_4
1473 Naturally aligns components with a size of four or fewer
1474 bytes.  Components that are larger than 4 bytes are placed on the next
1475 4-byte boundary.
1477 @findex Storage_Unit
1478 @item Storage_Unit
1479 Specifies that array or record components are byte aligned, i.e.@:
1480 aligned on boundaries determined by the value of the constant
1481 @code{System.Storage_Unit}.
1483 @cindex OpenVMS
1484 @item Default
1485 Specifies that array or record components are aligned on default
1486 boundaries, appropriate to the underlying hardware or operating system or
1487 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1488 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1489 the @code{Default} choice is the same as @code{Component_Size} (natural
1490 alignment).
1491 @end table
1493 @noindent
1494 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1495 refer to a local record or array type, and the specified alignment
1496 choice applies to the specified type.  The use of
1497 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1498 @code{Component_Alignment} pragma to be ignored.  The use of
1499 @code{Component_Alignment} together with a record representation clause
1500 is only effective for fields not specified by the representation clause.
1502 If the @code{Name} parameter is absent, the pragma can be used as either
1503 a configuration pragma, in which case it applies to one or more units in
1504 accordance with the normal rules for configuration pragmas, or it can be
1505 used within a declarative part, in which case it applies to types that
1506 are declared within this declarative part, or within any nested scope
1507 within this declarative part.  In either case it specifies the alignment
1508 to be applied to any record or array type which has otherwise standard
1509 representation.
1511 If the alignment for a record or array type is not specified (using
1512 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1513 clause), the GNAT uses the default alignment as described previously.
1515 @node Pragma Convention_Identifier
1516 @unnumberedsec Pragma Convention_Identifier
1517 @findex Convention_Identifier
1518 @cindex Conventions, synonyms
1519 @noindent
1520 Syntax:
1522 @smallexample @c ada
1523 pragma Convention_Identifier (
1524          [Name =>]       IDENTIFIER,
1525          [Convention =>] convention_IDENTIFIER);
1526 @end smallexample
1528 @noindent
1529 This pragma provides a mechanism for supplying synonyms for existing
1530 convention identifiers. The @code{Name} identifier can subsequently
1531 be used as a synonym for the given convention in other pragmas (including
1532 for example pragma @code{Import} or another @code{Convention_Identifier}
1533 pragma). As an example of the use of this, suppose you had legacy code
1534 which used Fortran77 as the identifier for Fortran. Then the pragma:
1536 @smallexample @c ada
1537 pragma Convention_Identifier (Fortran77, Fortran);
1538 @end smallexample
1540 @noindent
1541 would allow the use of the convention identifier @code{Fortran77} in
1542 subsequent code, avoiding the need to modify the sources. As another
1543 example, you could use this to parametrize convention requirements
1544 according to systems. Suppose you needed to use @code{Stdcall} on
1545 windows systems, and @code{C} on some other system, then you could
1546 define a convention identifier @code{Library} and use a single
1547 @code{Convention_Identifier} pragma to specify which convention
1548 would be used system-wide.
1550 @node Pragma CPP_Class
1551 @unnumberedsec Pragma CPP_Class
1552 @findex CPP_Class
1553 @cindex Interfacing with C++
1554 @noindent
1555 Syntax:
1557 @smallexample @c ada
1558 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1559 @end smallexample
1561 @noindent
1562 The argument denotes an entity in the current declarative region that is
1563 declared as a record type. It indicates that the type corresponds to an
1564 externally declared C++ class type, and is to be laid out the same way
1565 that C++ would lay out the type. If the C++ class has virtual primitives
1566 then the record must be declared as a tagged record type.
1568 Types for which @code{CPP_Class} is specified do not have assignment or
1569 equality operators defined (such operations can be imported or declared
1570 as subprograms as required). Initialization is allowed only by constructor
1571 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1572 limited if not explicitly declared as limited or derived from a limited
1573 type, and an error is issued in that case.
1575 Pragma @code{CPP_Class} is intended primarily for automatic generation
1576 using an automatic binding generator tool.
1577 See @ref{Interfacing to C++} for related information.
1579 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1580 for backward compatibility but its functionality is available
1581 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1583 @node Pragma CPP_Constructor
1584 @unnumberedsec Pragma CPP_Constructor
1585 @cindex Interfacing with C++
1586 @findex CPP_Constructor
1587 @noindent
1588 Syntax:
1590 @smallexample @c ada
1591 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1592   [, [External_Name =>] static_string_EXPRESSION ]
1593   [, [Link_Name     =>] static_string_EXPRESSION ]);
1594 @end smallexample
1596 @noindent
1597 This pragma identifies an imported function (imported in the usual way
1598 with pragma @code{Import}) as corresponding to a C++ constructor. If
1599 @code{External_Name} and @code{Link_Name} are not specified then the
1600 @code{Entity} argument is a name that must have been previously mentioned
1601 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1602 must be of one of the following forms:
1604 @itemize @bullet
1605 @item
1606 @code{function @var{Fname} return @var{T}}
1608 @itemize @bullet
1609 @item
1610 @code{function @var{Fname} return @var{T}'Class}
1612 @item
1613 @code{function @var{Fname} (@dots{}) return @var{T}}
1614 @end itemize
1616 @item
1617 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1618 @end itemize
1620 @noindent
1621 where @var{T} is a limited record type imported from C++ with pragma
1622 @code{Import} and @code{Convention} = @code{CPP}.
1624 The first two forms import the default constructor, used when an object
1625 of type @var{T} is created on the Ada side with no explicit constructor.
1626 The latter two forms cover all the non-default constructors of the type.
1627 See the GNAT users guide for details.
1629 If no constructors are imported, it is impossible to create any objects
1630 on the Ada side and the type is implicitly declared abstract.
1632 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1633 using an automatic binding generator tool.
1634 See @ref{Interfacing to C++} for more related information.
1636 Note: The use of functions returning class-wide types for constructors is
1637 currently obsolete. They are supported for backward compatibility. The
1638 use of functions returning the type T leave the Ada sources more clear
1639 because the imported C++ constructors always return an object of type T;
1640 that is, they never return an object whose type is a descendant of type T.
1642 @node Pragma CPP_Virtual
1643 @unnumberedsec Pragma CPP_Virtual
1644 @cindex Interfacing to C++
1645 @findex CPP_Virtual
1646 @noindent
1647 This pragma is now obsolete has has no effect because GNAT generates
1648 the same object layout than the G++ compiler.
1650 See @ref{Interfacing to C++} for related information.
1652 @node Pragma CPP_Vtable
1653 @unnumberedsec Pragma CPP_Vtable
1654 @cindex Interfacing with C++
1655 @findex CPP_Vtable
1656 @noindent
1657 This pragma is now obsolete has has no effect because GNAT generates
1658 the same object layout than the G++ compiler.
1660 See @ref{Interfacing to C++} for related information.
1662 @node Pragma Debug
1663 @unnumberedsec Pragma Debug
1664 @findex Debug
1665 @noindent
1666 Syntax:
1668 @smallexample @c ada
1669 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1671 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1672   PROCEDURE_NAME
1673 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1674 @end smallexample
1676 @noindent
1677 The procedure call argument has the syntactic form of an expression, meeting
1678 the syntactic requirements for pragmas.
1680 If debug pragmas are not enabled or if the condition is present and evaluates
1681 to False, this pragma has no effect. If debug pragmas are enabled, the
1682 semantics of the pragma is exactly equivalent to the procedure call statement
1683 corresponding to the argument with a terminating semicolon. Pragmas are
1684 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1685 intersperse calls to debug procedures in the middle of declarations. Debug
1686 pragmas can be enabled either by use of the command line switch @option{-gnata}
1687 or by use of the configuration pragma @code{Debug_Policy}.
1689 @node Pragma Debug_Policy
1690 @unnumberedsec Pragma Debug_Policy
1691 @findex Debug_Policy
1692 @noindent
1693 Syntax:
1695 @smallexample @c ada
1696 pragma Debug_Policy (CHECK | IGNORE);
1697 @end smallexample
1699 @noindent
1700 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1701 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1702 This pragma overrides the effect of the @option{-gnata} switch on the
1703 command line.
1705 @node Pragma Detect_Blocking
1706 @unnumberedsec Pragma Detect_Blocking
1707 @findex Detect_Blocking
1708 @noindent
1709 Syntax:
1711 @smallexample @c ada
1712 pragma Detect_Blocking;
1713 @end smallexample
1715 @noindent
1716 This is a configuration pragma that forces the detection of potentially
1717 blocking operations within a protected operation, and to raise Program_Error
1718 if that happens.
1720 @node Pragma Elaboration_Checks
1721 @unnumberedsec Pragma Elaboration_Checks
1722 @cindex Elaboration control
1723 @findex Elaboration_Checks
1724 @noindent
1725 Syntax:
1727 @smallexample @c ada
1728 pragma Elaboration_Checks (Dynamic | Static);
1729 @end smallexample
1731 @noindent
1732 This is a configuration pragma that provides control over the
1733 elaboration model used by the compilation affected by the
1734 pragma.  If the parameter is @code{Dynamic},
1735 then the dynamic elaboration
1736 model described in the Ada Reference Manual is used, as though
1737 the @option{-gnatE} switch had been specified on the command
1738 line.  If the parameter is @code{Static}, then the default GNAT static
1739 model is used.  This configuration pragma overrides the setting
1740 of the command line.  For full details on the elaboration models
1741 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1742 gnat_ugn, @value{EDITION} User's Guide}.
1744 @node Pragma Eliminate
1745 @unnumberedsec Pragma Eliminate
1746 @cindex Elimination of unused subprograms
1747 @findex Eliminate
1748 @noindent
1749 Syntax:
1751 @smallexample @c ada
1752 pragma Eliminate (
1753     [Unit_Name =>] IDENTIFIER |
1754                    SELECTED_COMPONENT);
1756 pragma Eliminate (
1757     [Unit_Name       =>]  IDENTIFIER |
1758                           SELECTED_COMPONENT,
1759     [Entity          =>]  IDENTIFIER |
1760                           SELECTED_COMPONENT |
1761                           STRING_LITERAL
1762     [,OVERLOADING_RESOLUTION]);
1764 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1765                            SOURCE_LOCATION
1767 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1768                                       FUNCTION_PROFILE
1770 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1772 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1773                       Result_Type => result_SUBTYPE_NAME]
1775 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1776 SUBTYPE_NAME    ::= STRING_VALUE
1778 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1779 SOURCE_TRACE    ::= STRING_VALUE
1781 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1782 @end smallexample
1784 @noindent
1785 This pragma indicates that the given entity is not used outside the
1786 compilation unit it is defined in. The entity must be an explicitly declared
1787 subprogram; this includes  generic subprogram instances and
1788 subprograms declared in generic package instances.
1790 If the entity to be eliminated is a library level subprogram, then
1791 the first form of pragma @code{Eliminate} is used with only a single argument.
1792 In this form, the @code{Unit_Name} argument specifies the name of the
1793 library  level unit to be eliminated.
1795 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1796 are required. If item is an entity of a library package, then the first
1797 argument specifies the unit name, and the second argument specifies
1798 the particular entity.  If the second argument is in string form, it must
1799 correspond to the internal manner in which GNAT stores entity names (see
1800 compilation unit Namet in the compiler sources for details).
1802 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1803 to distinguish between overloaded subprograms. If a pragma does not contain
1804 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1805 subprograms denoted by the first two parameters.
1807 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1808 to be eliminated in a manner similar to that used for the extended
1809 @code{Import} and @code{Export} pragmas, except that the subtype names are
1810 always given as strings. At the moment, this form of distinguishing
1811 overloaded subprograms is implemented only partially, so we do not recommend
1812 using it for practical subprogram elimination.
1814 Note that in case of a parameterless procedure its profile is represented
1815 as @code{Parameter_Types => ("")}
1817 Alternatively, the @code{Source_Location} parameter is used to specify
1818 which overloaded alternative is to be eliminated by pointing to the
1819 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1820 source text. The string literal (or concatenation of string literals)
1821 given as SOURCE_TRACE must have the following format:
1823 @smallexample @c ada
1824 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1826 LBRACKET ::= [
1827 RBRACKET ::= ]
1829 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1830 FILE_NAME       ::= STRING_LITERAL
1831 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1832 @end smallexample
1834 SOURCE_TRACE should be the short name of the source file (with no directory
1835 information), and LINE_NUMBER is supposed to point to the line where the
1836 defining name of the subprogram is located.
1838 For the subprograms that are not a part of generic instantiations, only one
1839 SOURCE_LOCATION is used. If a subprogram is declared in a package
1840 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1841 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1842 second one denotes the declaration of the corresponding subprogram in the
1843 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1844 in case of nested instantiations.
1846 The effect of the pragma is to allow the compiler to eliminate
1847 the code or data associated with the named entity.  Any reference to
1848 an eliminated entity outside the compilation unit it is defined in,
1849 causes a compile time or link time error.
1851 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1852 in a system independent manner, with unused entities eliminated, without
1853 the requirement of modifying the source text.  Normally the required set
1854 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1855 tool. Elimination of unused entities local to a compilation unit is
1856 automatic, without requiring the use of pragma @code{Eliminate}.
1858 Note that the reason this pragma takes string literals where names might
1859 be expected is that a pragma @code{Eliminate} can appear in a context where the
1860 relevant names are not visible.
1862 Note that any change in the source files that includes removing, splitting of
1863 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1864 parameter illegal.
1866 It is legal to use pragma Eliminate where the referenced entity is a
1867 dispatching operation, but it is not clear what this would mean, since
1868 in general the call does not know which entity is actually being called.
1869 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1871 @node Pragma Export_Exception
1872 @unnumberedsec Pragma Export_Exception
1873 @cindex OpenVMS
1874 @findex Export_Exception
1875 @noindent
1876 Syntax:
1878 @smallexample @c ada
1879 pragma Export_Exception (
1880      [Internal =>] LOCAL_NAME
1881   [, [External =>] EXTERNAL_SYMBOL]
1882   [, [Form     =>] Ada | VMS]
1883   [, [Code     =>] static_integer_EXPRESSION]);
1885 EXTERNAL_SYMBOL ::=
1886   IDENTIFIER
1887 | static_string_EXPRESSION
1888 @end smallexample
1890 @noindent
1891 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1892 causes the specified exception to be propagated outside of the Ada program,
1893 so that it can be handled by programs written in other OpenVMS languages.
1894 This pragma establishes an external name for an Ada exception and makes the
1895 name available to the OpenVMS Linker as a global symbol.  For further details
1896 on this pragma, see the
1897 DEC Ada Language Reference Manual, section 13.9a3.2.
1899 @node Pragma Export_Function
1900 @unnumberedsec Pragma Export_Function
1901 @cindex Argument passing mechanisms
1902 @findex Export_Function
1904 @noindent
1905 Syntax:
1907 @smallexample @c ada
1908 pragma Export_Function (
1909      [Internal         =>] LOCAL_NAME
1910   [, [External         =>] EXTERNAL_SYMBOL]
1911   [, [Parameter_Types  =>] PARAMETER_TYPES]
1912   [, [Result_Type      =>] result_SUBTYPE_MARK]
1913   [, [Mechanism        =>] MECHANISM]
1914   [, [Result_Mechanism =>] MECHANISM_NAME]);
1916 EXTERNAL_SYMBOL ::=
1917   IDENTIFIER
1918 | static_string_EXPRESSION
1919 | ""
1921 PARAMETER_TYPES ::=
1922   null
1923 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1925 TYPE_DESIGNATOR ::=
1926   subtype_NAME
1927 | subtype_Name ' Access
1929 MECHANISM ::=
1930   MECHANISM_NAME
1931 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1933 MECHANISM_ASSOCIATION ::=
1934   [formal_parameter_NAME =>] MECHANISM_NAME
1936 MECHANISM_NAME ::=
1937   Value
1938 | Reference
1939 | Descriptor [([Class =>] CLASS_NAME)]
1940 | Short_Descriptor [([Class =>] CLASS_NAME)]
1942 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1943 @end smallexample
1945 @noindent
1946 Use this pragma to make a function externally callable and optionally
1947 provide information on mechanisms to be used for passing parameter and
1948 result values.  We recommend, for the purposes of improving portability,
1949 this pragma always be used in conjunction with a separate pragma
1950 @code{Export}, which must precede the pragma @code{Export_Function}.
1951 GNAT does not require a separate pragma @code{Export}, but if none is
1952 present, @code{Convention Ada} is assumed, which is usually
1953 not what is wanted, so it is usually appropriate to use this
1954 pragma in conjunction with a @code{Export} or @code{Convention}
1955 pragma that specifies the desired foreign convention.
1956 Pragma @code{Export_Function}
1957 (and @code{Export}, if present) must appear in the same declarative
1958 region as the function to which they apply.
1960 @var{internal_name} must uniquely designate the function to which the
1961 pragma applies.  If more than one function name exists of this name in
1962 the declarative part you must use the @code{Parameter_Types} and
1963 @code{Result_Type} parameters is mandatory to achieve the required
1964 unique designation.  @var{subtype_mark}s in these parameters must
1965 exactly match the subtypes in the corresponding function specification,
1966 using positional notation to match parameters with subtype marks.
1967 The form with an @code{'Access} attribute can be used to match an
1968 anonymous access parameter.
1970 @cindex OpenVMS
1971 @cindex Passing by descriptor
1972 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1973 The default behavior for Export_Function is to accept either 64bit or
1974 32bit descriptors unless short_descriptor is specified, then only 32bit
1975 descriptors are accepted.
1977 @cindex Suppressing external name
1978 Special treatment is given if the EXTERNAL is an explicit null
1979 string or a static string expressions that evaluates to the null
1980 string. In this case, no external name is generated. This form
1981 still allows the specification of parameter mechanisms.
1983 @node Pragma Export_Object
1984 @unnumberedsec Pragma Export_Object
1985 @findex Export_Object
1986 @noindent
1987 Syntax:
1989 @smallexample @c ada
1990 pragma Export_Object
1991       [Internal =>] LOCAL_NAME
1992    [, [External =>] EXTERNAL_SYMBOL]
1993    [, [Size     =>] EXTERNAL_SYMBOL]
1995 EXTERNAL_SYMBOL ::=
1996   IDENTIFIER
1997 | static_string_EXPRESSION
1998 @end smallexample
2000 @noindent
2001 This pragma designates an object as exported, and apart from the
2002 extended rules for external symbols, is identical in effect to the use of
2003 the normal @code{Export} pragma applied to an object.  You may use a
2004 separate Export pragma (and you probably should from the point of view
2005 of portability), but it is not required.  @var{Size} is syntax checked,
2006 but otherwise ignored by GNAT@.
2008 @node Pragma Export_Procedure
2009 @unnumberedsec Pragma Export_Procedure
2010 @findex Export_Procedure
2011 @noindent
2012 Syntax:
2014 @smallexample @c ada
2015 pragma Export_Procedure (
2016      [Internal        =>] LOCAL_NAME
2017   [, [External        =>] EXTERNAL_SYMBOL]
2018   [, [Parameter_Types =>] PARAMETER_TYPES]
2019   [, [Mechanism       =>] MECHANISM]);
2021 EXTERNAL_SYMBOL ::=
2022   IDENTIFIER
2023 | static_string_EXPRESSION
2024 | ""
2026 PARAMETER_TYPES ::=
2027   null
2028 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2030 TYPE_DESIGNATOR ::=
2031   subtype_NAME
2032 | subtype_Name ' Access
2034 MECHANISM ::=
2035   MECHANISM_NAME
2036 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2038 MECHANISM_ASSOCIATION ::=
2039   [formal_parameter_NAME =>] MECHANISM_NAME
2041 MECHANISM_NAME ::=
2042   Value
2043 | Reference
2044 | Descriptor [([Class =>] CLASS_NAME)]
2045 | Short_Descriptor [([Class =>] CLASS_NAME)]
2047 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2048 @end smallexample
2050 @noindent
2051 This pragma is identical to @code{Export_Function} except that it
2052 applies to a procedure rather than a function and the parameters
2053 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2054 GNAT does not require a separate pragma @code{Export}, but if none is
2055 present, @code{Convention Ada} is assumed, which is usually
2056 not what is wanted, so it is usually appropriate to use this
2057 pragma in conjunction with a @code{Export} or @code{Convention}
2058 pragma that specifies the desired foreign convention.
2060 @cindex OpenVMS
2061 @cindex Passing by descriptor
2062 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2063 The default behavior for Export_Procedure is to accept either 64bit or
2064 32bit descriptors unless short_descriptor is specified, then only 32bit
2065 descriptors are accepted.
2067 @cindex Suppressing external name
2068 Special treatment is given if the EXTERNAL is an explicit null
2069 string or a static string expressions that evaluates to the null
2070 string. In this case, no external name is generated. This form
2071 still allows the specification of parameter mechanisms.
2073 @node Pragma Export_Value
2074 @unnumberedsec Pragma Export_Value
2075 @findex Export_Value
2076 @noindent
2077 Syntax:
2079 @smallexample @c ada
2080 pragma Export_Value (
2081   [Value     =>] static_integer_EXPRESSION,
2082   [Link_Name =>] static_string_EXPRESSION);
2083 @end smallexample
2085 @noindent
2086 This pragma serves to export a static integer value for external use.
2087 The first argument specifies the value to be exported. The Link_Name
2088 argument specifies the symbolic name to be associated with the integer
2089 value. This pragma is useful for defining a named static value in Ada
2090 that can be referenced in assembly language units to be linked with
2091 the application. This pragma is currently supported only for the
2092 AAMP target and is ignored for other targets.
2094 @node Pragma Export_Valued_Procedure
2095 @unnumberedsec Pragma Export_Valued_Procedure
2096 @findex Export_Valued_Procedure
2097 @noindent
2098 Syntax:
2100 @smallexample @c ada
2101 pragma Export_Valued_Procedure (
2102      [Internal        =>] LOCAL_NAME
2103   [, [External        =>] EXTERNAL_SYMBOL]
2104   [, [Parameter_Types =>] PARAMETER_TYPES]
2105   [, [Mechanism       =>] MECHANISM]);
2107 EXTERNAL_SYMBOL ::=
2108   IDENTIFIER
2109 | static_string_EXPRESSION
2110 | ""
2112 PARAMETER_TYPES ::=
2113   null
2114 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2116 TYPE_DESIGNATOR ::=
2117   subtype_NAME
2118 | subtype_Name ' Access
2120 MECHANISM ::=
2121   MECHANISM_NAME
2122 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2124 MECHANISM_ASSOCIATION ::=
2125   [formal_parameter_NAME =>] MECHANISM_NAME
2127 MECHANISM_NAME ::=
2128   Value
2129 | Reference
2130 | Descriptor [([Class =>] CLASS_NAME)]
2131 | Short_Descriptor [([Class =>] CLASS_NAME)]
2133 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2134 @end smallexample
2136 @noindent
2137 This pragma is identical to @code{Export_Procedure} except that the
2138 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2139 mode @code{OUT}, and externally the subprogram is treated as a function
2140 with this parameter as the result of the function.  GNAT provides for
2141 this capability to allow the use of @code{OUT} and @code{IN OUT}
2142 parameters in interfacing to external functions (which are not permitted
2143 in Ada functions).
2144 GNAT does not require a separate pragma @code{Export}, but if none is
2145 present, @code{Convention Ada} is assumed, which is almost certainly
2146 not what is wanted since the whole point of this pragma is to interface
2147 with foreign language functions, so it is usually appropriate to use this
2148 pragma in conjunction with a @code{Export} or @code{Convention}
2149 pragma that specifies the desired foreign convention.
2151 @cindex OpenVMS
2152 @cindex Passing by descriptor
2153 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2154 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2155 32bit descriptors unless short_descriptor is specified, then only 32bit
2156 descriptors are accepted.
2158 @cindex Suppressing external name
2159 Special treatment is given if the EXTERNAL is an explicit null
2160 string or a static string expressions that evaluates to the null
2161 string. In this case, no external name is generated. This form
2162 still allows the specification of parameter mechanisms.
2164 @node Pragma Extend_System
2165 @unnumberedsec Pragma Extend_System
2166 @cindex @code{system}, extending
2167 @cindex Dec Ada 83
2168 @findex Extend_System
2169 @noindent
2170 Syntax:
2172 @smallexample @c ada
2173 pragma Extend_System ([Name =>] IDENTIFIER);
2174 @end smallexample
2176 @noindent
2177 This pragma is used to provide backwards compatibility with other
2178 implementations that extend the facilities of package @code{System}.  In
2179 GNAT, @code{System} contains only the definitions that are present in
2180 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2181 implementation, provide many extensions to package @code{System}.
2183 For each such implementation accommodated by this pragma, GNAT provides a
2184 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2185 implementation, which provides the required additional definitions.  You
2186 can use this package in two ways.  You can @code{with} it in the normal
2187 way and access entities either by selection or using a @code{use}
2188 clause.  In this case no special processing is required.
2190 However, if existing code contains references such as
2191 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2192 definitions provided in package @code{System}, you may use this pragma
2193 to extend visibility in @code{System} in a non-standard way that
2194 provides greater compatibility with the existing code.  Pragma
2195 @code{Extend_System} is a configuration pragma whose single argument is
2196 the name of the package containing the extended definition
2197 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2198 control of this pragma will be processed using special visibility
2199 processing that looks in package @code{System.Aux_@var{xxx}} where
2200 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2201 package @code{System}, but not found in package @code{System}.
2203 You can use this pragma either to access a predefined @code{System}
2204 extension supplied with the compiler, for example @code{Aux_DEC} or
2205 you can construct your own extension unit following the above
2206 definition.  Note that such a package is a child of @code{System}
2207 and thus is considered part of the implementation.  To compile
2208 it you will have to use the appropriate switch for compiling
2209 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2210 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2212 @node Pragma Extensions_Allowed
2213 @unnumberedsec Pragma Extensions_Allowed
2214 @cindex Ada Extensions
2215 @cindex GNAT Extensions
2216 @findex Extensions_Allowed
2217 @noindent
2218 Syntax:
2220 @smallexample @c ada
2221 pragma Extensions_Allowed (On | Off);
2222 @end smallexample
2224 @noindent
2225 This configuration pragma enables or disables the implementation
2226 extension mode (the use of Off as a parameter cancels the effect
2227 of the @option{-gnatX} command switch).
2229 In extension mode, the latest version of the Ada language is
2230 implemented (currently Ada 2012), and in addition a small number
2231 of GNAT specific extensions are recognized as follows:
2233 @table @asis
2234 @item Constrained attribute for generic objects
2235 The @code{Constrained} attribute is permitted for objects of
2236 generic types. The result indicates if the corresponding actual
2237 is constrained.
2239 @end table
2241 @node Pragma External
2242 @unnumberedsec Pragma External
2243 @findex External
2244 @noindent
2245 Syntax:
2247 @smallexample @c ada
2248 pragma External (
2249   [   Convention    =>] convention_IDENTIFIER,
2250   [   Entity        =>] LOCAL_NAME
2251   [, [External_Name =>] static_string_EXPRESSION ]
2252   [, [Link_Name     =>] static_string_EXPRESSION ]);
2253 @end smallexample
2255 @noindent
2256 This pragma is identical in syntax and semantics to pragma
2257 @code{Export} as defined in the Ada Reference Manual.  It is
2258 provided for compatibility with some Ada 83 compilers that
2259 used this pragma for exactly the same purposes as pragma
2260 @code{Export} before the latter was standardized.
2262 @node Pragma External_Name_Casing
2263 @unnumberedsec Pragma External_Name_Casing
2264 @cindex Dec Ada 83 casing compatibility
2265 @cindex External Names, casing
2266 @cindex Casing of External names
2267 @findex External_Name_Casing
2268 @noindent
2269 Syntax:
2271 @smallexample @c ada
2272 pragma External_Name_Casing (
2273   Uppercase | Lowercase
2274   [, Uppercase | Lowercase | As_Is]);
2275 @end smallexample
2277 @noindent
2278 This pragma provides control over the casing of external names associated
2279 with Import and Export pragmas.  There are two cases to consider:
2281 @table @asis
2282 @item Implicit external names
2283 Implicit external names are derived from identifiers.  The most common case
2284 arises when a standard Ada Import or Export pragma is used with only two
2285 arguments, as in:
2287 @smallexample @c ada
2288    pragma Import (C, C_Routine);
2289 @end smallexample
2291 @noindent
2292 Since Ada is a case-insensitive language, the spelling of the identifier in
2293 the Ada source program does not provide any information on the desired
2294 casing of the external name, and so a convention is needed.  In GNAT the
2295 default treatment is that such names are converted to all lower case
2296 letters.  This corresponds to the normal C style in many environments.
2297 The first argument of pragma @code{External_Name_Casing} can be used to
2298 control this treatment.  If @code{Uppercase} is specified, then the name
2299 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2300 then the normal default of all lower case letters will be used.
2302 This same implicit treatment is also used in the case of extended DEC Ada 83
2303 compatible Import and Export pragmas where an external name is explicitly
2304 specified using an identifier rather than a string.
2306 @item Explicit external names
2307 Explicit external names are given as string literals.  The most common case
2308 arises when a standard Ada Import or Export pragma is used with three
2309 arguments, as in:
2311 @smallexample @c ada
2312 pragma Import (C, C_Routine, "C_routine");
2313 @end smallexample
2315 @noindent
2316 In this case, the string literal normally provides the exact casing required
2317 for the external name.  The second argument of pragma
2318 @code{External_Name_Casing} may be used to modify this behavior.
2319 If @code{Uppercase} is specified, then the name
2320 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2321 then the name will be forced to all lowercase letters.  A specification of
2322 @code{As_Is} provides the normal default behavior in which the casing is
2323 taken from the string provided.
2324 @end table
2326 @noindent
2327 This pragma may appear anywhere that a pragma is valid.  In particular, it
2328 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2329 case it applies to all subsequent compilations, or it can be used as a program
2330 unit pragma, in which case it only applies to the current unit, or it can
2331 be used more locally to control individual Import/Export pragmas.
2333 It is primarily intended for use with OpenVMS systems, where many
2334 compilers convert all symbols to upper case by default.  For interfacing to
2335 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2336 the pragma:
2338 @smallexample @c ada
2339 pragma External_Name_Casing (Uppercase, Uppercase);
2340 @end smallexample
2342 @noindent
2343 to enforce the upper casing of all external symbols.
2345 @node Pragma Fast_Math
2346 @unnumberedsec Pragma Fast_Math
2347 @findex Fast_Math
2348 @noindent
2349 Syntax:
2351 @smallexample @c ada
2352 pragma Fast_Math;
2353 @end smallexample
2355 @noindent
2356 This is a configuration pragma which activates a mode in which speed is
2357 considered more important for floating-point operations than absolutely
2358 accurate adherence to the requirements of the standard. Currently the
2359 following operations are affected:
2361 @table @asis
2362 @item Complex Multiplication
2363 The normal simple formula for complex multiplication can result in intermediate
2364 overflows for numbers near the end of the range. The Ada standard requires that
2365 this situation be detected and corrected by scaling, but in Fast_Math mode such
2366 cases will simply result in overflow. Note that to take advantage of this you
2367 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2368 under control of the pragma, rather than use the preinstantiated versions.
2369 @end table
2371 @node Pragma Favor_Top_Level
2372 @unnumberedsec Pragma Favor_Top_Level
2373 @findex Favor_Top_Level
2374 @noindent
2375 Syntax:
2377 @smallexample @c ada
2378 pragma Favor_Top_Level (type_NAME);
2379 @end smallexample
2381 @noindent
2382 The named type must be an access-to-subprogram type. This pragma is an
2383 efficiency hint to the compiler, regarding the use of 'Access or
2384 'Unrestricted_Access on nested (non-library-level) subprograms. The
2385 pragma means that nested subprograms are not used with this type, or
2386 are rare, so that the generated code should be efficient in the
2387 top-level case. When this pragma is used, dynamically generated
2388 trampolines may be used on some targets for nested subprograms.
2389 See also the No_Implicit_Dynamic_Code restriction.
2391 @node Pragma Finalize_Storage_Only
2392 @unnumberedsec Pragma Finalize_Storage_Only
2393 @findex Finalize_Storage_Only
2394 @noindent
2395 Syntax:
2397 @smallexample @c ada
2398 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2399 @end smallexample
2401 @noindent
2402 This pragma allows the compiler not to emit a Finalize call for objects
2403 defined at the library level.  This is mostly useful for types where
2404 finalization is only used to deal with storage reclamation since in most
2405 environments it is not necessary to reclaim memory just before terminating
2406 execution, hence the name.
2408 @node Pragma Float_Representation
2409 @unnumberedsec Pragma Float_Representation
2410 @cindex OpenVMS
2411 @findex Float_Representation
2412 @noindent
2413 Syntax:
2415 @smallexample @c ada
2416 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2418 FLOAT_REP ::= VAX_Float | IEEE_Float
2419 @end smallexample
2421 @noindent
2422 In the one argument form, this pragma is a configuration pragma which
2423 allows control over the internal representation chosen for the predefined
2424 floating point types declared in the packages @code{Standard} and
2425 @code{System}. On all systems other than OpenVMS, the argument must
2426 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2427 argument may be @code{VAX_Float} to specify the use of the VAX float
2428 format for the floating-point types in Standard. This requires that
2429 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2430 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2431 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2433 The two argument form specifies the representation to be used for
2434 the specified floating-point type. On all systems other than OpenVMS,
2435 the argument must
2436 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2437 argument may be @code{VAX_Float} to specify the use of the VAX float
2438 format, as follows:
2440 @itemize @bullet
2441 @item
2442 For digits values up to 6, F float format will be used.
2443 @item
2444 For digits values from 7 to 9, G float format will be used.
2445 @item
2446 For digits values from 10 to 15, F float format will be used.
2447 @item
2448 Digits values above 15 are not allowed.
2449 @end itemize
2451 @node Pragma Ident
2452 @unnumberedsec Pragma Ident
2453 @findex Ident
2454 @noindent
2455 Syntax:
2457 @smallexample @c ada
2458 pragma Ident (static_string_EXPRESSION);
2459 @end smallexample
2461 @noindent
2462 This pragma provides a string identification in the generated object file,
2463 if the system supports the concept of this kind of identification string.
2464 This pragma is allowed only in the outermost declarative part or
2465 declarative items of a compilation unit. If more than one @code{Ident}
2466 pragma is given, only the last one processed is effective.
2467 @cindex OpenVMS
2468 On OpenVMS systems, the effect of the pragma is identical to the effect of
2469 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2470 maximum allowed length is 31 characters, so if it is important to
2471 maintain compatibility with this compiler, you should obey this length
2472 limit.
2474 @node Pragma Implemented_By_Entry
2475 @unnumberedsec Pragma Implemented_By_Entry
2476 @findex Implemented_By_Entry
2477 @noindent
2478 Syntax:
2480 @smallexample @c ada
2481 pragma Implemented_By_Entry (LOCAL_NAME);
2482 @end smallexample
2484 @noindent
2485 This is a representation pragma which applies to protected, synchronized and
2486 task interface primitives. If the pragma is applied to primitive operation Op
2487 of interface Iface, it is illegal to override Op in a type that implements
2488 Iface, with anything other than an entry.
2490 @smallexample @c ada
2491 type Iface is protected interface;
2492 procedure Do_Something (Object : in out Iface) is abstract;
2493 pragma Implemented_By_Entry (Do_Something);
2495 protected type P is new Iface with
2496    procedure Do_Something;  --  Illegal
2497 end P;
2499 task type T is new Iface with
2500    entry Do_Something;      --  Legal
2501 end T;
2502 @end smallexample
2504 @noindent
2505 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2506 is intended to be used in conjunction with dispatching requeue statements as
2507 described in AI05-0030. Should the ARG decide on an official name and syntax,
2508 this pragma will become language-defined rather than GNAT-specific.
2510 @node Pragma Implicit_Packing
2511 @unnumberedsec Pragma Implicit_Packing
2512 @findex Implicit_Packing
2513 @noindent
2514 Syntax:
2516 @smallexample @c ada
2517 pragma Implicit_Packing;
2518 @end smallexample
2520 @noindent
2521 This is a configuration pragma that requests implicit packing for packed
2522 arrays for which a size clause is given but no explicit pragma Pack or
2523 specification of Component_Size is present. It also applies to records
2524 where no record representation clause is present. Consider this example:
2526 @smallexample @c ada
2527 type R is array (0 .. 7) of Boolean;
2528 for R'Size use 8;
2529 @end smallexample
2531 @noindent
2532 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2533 does not change the layout of a composite object. So the Size clause in the
2534 above example is normally rejected, since the default layout of the array uses
2535 8-bit components, and thus the array requires a minimum of 64 bits.
2537 If this declaration is compiled in a region of code covered by an occurrence
2538 of the configuration pragma Implicit_Packing, then the Size clause in this
2539 and similar examples will cause implicit packing and thus be accepted. For
2540 this implicit packing to occur, the type in question must be an array of small
2541 components whose size is known at compile time, and the Size clause must
2542 specify the exact size that corresponds to the length of the array multiplied
2543 by the size in bits of the component type.
2544 @cindex Array packing
2546 Similarly, the following example shows the use in the record case
2548 @smallexample @c ada
2549 type r is record
2550    a, b, c, d, e, f, g, h : boolean;
2551    chr                    : character;
2552 end record;
2553 for r'size use 16;
2554 @end smallexample
2556 @noindent
2557 Without a pragma Pack, each Boolean field requires 8 bits, so the
2558 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2559 sufficient. The use of pragma Implciit_Packing allows this record
2560 declaration to compile without an explicit pragma Pack.
2561 @node Pragma Import_Exception
2562 @unnumberedsec Pragma Import_Exception
2563 @cindex OpenVMS
2564 @findex Import_Exception
2565 @noindent
2566 Syntax:
2568 @smallexample @c ada
2569 pragma Import_Exception (
2570      [Internal =>] LOCAL_NAME
2571   [, [External =>] EXTERNAL_SYMBOL]
2572   [, [Form     =>] Ada | VMS]
2573   [, [Code     =>] static_integer_EXPRESSION]);
2575 EXTERNAL_SYMBOL ::=
2576   IDENTIFIER
2577 | static_string_EXPRESSION
2578 @end smallexample
2580 @noindent
2581 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2582 It allows OpenVMS conditions (for example, from OpenVMS system services or
2583 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2584 The pragma specifies that the exception associated with an exception
2585 declaration in an Ada program be defined externally (in non-Ada code).
2586 For further details on this pragma, see the
2587 DEC Ada Language Reference Manual, section 13.9a.3.1.
2589 @node Pragma Import_Function
2590 @unnumberedsec Pragma Import_Function
2591 @findex Import_Function
2592 @noindent
2593 Syntax:
2595 @smallexample @c ada
2596 pragma Import_Function (
2597      [Internal                 =>] LOCAL_NAME,
2598   [, [External                 =>] EXTERNAL_SYMBOL]
2599   [, [Parameter_Types          =>] PARAMETER_TYPES]
2600   [, [Result_Type              =>] SUBTYPE_MARK]
2601   [, [Mechanism                =>] MECHANISM]
2602   [, [Result_Mechanism         =>] MECHANISM_NAME]
2603   [, [First_Optional_Parameter =>] IDENTIFIER]);
2605 EXTERNAL_SYMBOL ::=
2606   IDENTIFIER
2607 | static_string_EXPRESSION
2609 PARAMETER_TYPES ::=
2610   null
2611 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2613 TYPE_DESIGNATOR ::=
2614   subtype_NAME
2615 | subtype_Name ' Access
2617 MECHANISM ::=
2618   MECHANISM_NAME
2619 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2621 MECHANISM_ASSOCIATION ::=
2622   [formal_parameter_NAME =>] MECHANISM_NAME
2624 MECHANISM_NAME ::=
2625   Value
2626 | Reference
2627 | Descriptor [([Class =>] CLASS_NAME)]
2628 | Short_Descriptor [([Class =>] CLASS_NAME)]
2630 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2631 @end smallexample
2633 @noindent
2634 This pragma is used in conjunction with a pragma @code{Import} to
2635 specify additional information for an imported function.  The pragma
2636 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2637 @code{Import_Function} pragma and both must appear in the same
2638 declarative part as the function specification.
2640 The @var{Internal} argument must uniquely designate
2641 the function to which the
2642 pragma applies.  If more than one function name exists of this name in
2643 the declarative part you must use the @code{Parameter_Types} and
2644 @var{Result_Type} parameters to achieve the required unique
2645 designation.  Subtype marks in these parameters must exactly match the
2646 subtypes in the corresponding function specification, using positional
2647 notation to match parameters with subtype marks.
2648 The form with an @code{'Access} attribute can be used to match an
2649 anonymous access parameter.
2651 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2652 parameters to specify passing mechanisms for the
2653 parameters and result.  If you specify a single mechanism name, it
2654 applies to all parameters.  Otherwise you may specify a mechanism on a
2655 parameter by parameter basis using either positional or named
2656 notation.  If the mechanism is not specified, the default mechanism
2657 is used.
2659 @cindex OpenVMS
2660 @cindex Passing by descriptor
2661 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2662 The default behavior for Import_Function is to pass a 64bit descriptor
2663 unless short_descriptor is specified, then a 32bit descriptor is passed.
2665 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2666 It specifies that the designated parameter and all following parameters
2667 are optional, meaning that they are not passed at the generated code
2668 level (this is distinct from the notion of optional parameters in Ada
2669 where the parameters are passed anyway with the designated optional
2670 parameters).  All optional parameters must be of mode @code{IN} and have
2671 default parameter values that are either known at compile time
2672 expressions, or uses of the @code{'Null_Parameter} attribute.
2674 @node Pragma Import_Object
2675 @unnumberedsec Pragma Import_Object
2676 @findex Import_Object
2677 @noindent
2678 Syntax:
2680 @smallexample @c ada
2681 pragma Import_Object
2682      [Internal =>] LOCAL_NAME
2683   [, [External =>] EXTERNAL_SYMBOL]
2684   [, [Size     =>] EXTERNAL_SYMBOL]);
2686 EXTERNAL_SYMBOL ::=
2687   IDENTIFIER
2688 | static_string_EXPRESSION
2689 @end smallexample
2691 @noindent
2692 This pragma designates an object as imported, and apart from the
2693 extended rules for external symbols, is identical in effect to the use of
2694 the normal @code{Import} pragma applied to an object.  Unlike the
2695 subprogram case, you need not use a separate @code{Import} pragma,
2696 although you may do so (and probably should do so from a portability
2697 point of view).  @var{size} is syntax checked, but otherwise ignored by
2698 GNAT@.
2700 @node Pragma Import_Procedure
2701 @unnumberedsec Pragma Import_Procedure
2702 @findex Import_Procedure
2703 @noindent
2704 Syntax:
2706 @smallexample @c ada
2707 pragma Import_Procedure (
2708      [Internal                 =>] LOCAL_NAME
2709   [, [External                 =>] EXTERNAL_SYMBOL]
2710   [, [Parameter_Types          =>] PARAMETER_TYPES]
2711   [, [Mechanism                =>] MECHANISM]
2712   [, [First_Optional_Parameter =>] IDENTIFIER]);
2714 EXTERNAL_SYMBOL ::=
2715   IDENTIFIER
2716 | static_string_EXPRESSION
2718 PARAMETER_TYPES ::=
2719   null
2720 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2722 TYPE_DESIGNATOR ::=
2723   subtype_NAME
2724 | subtype_Name ' Access
2726 MECHANISM ::=
2727   MECHANISM_NAME
2728 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2730 MECHANISM_ASSOCIATION ::=
2731   [formal_parameter_NAME =>] MECHANISM_NAME
2733 MECHANISM_NAME ::=
2734   Value
2735 | Reference
2736 | Descriptor [([Class =>] CLASS_NAME)]
2737 | Short_Descriptor [([Class =>] CLASS_NAME)]
2739 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2740 @end smallexample
2742 @noindent
2743 This pragma is identical to @code{Import_Function} except that it
2744 applies to a procedure rather than a function and the parameters
2745 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2747 @node Pragma Import_Valued_Procedure
2748 @unnumberedsec Pragma Import_Valued_Procedure
2749 @findex Import_Valued_Procedure
2750 @noindent
2751 Syntax:
2753 @smallexample @c ada
2754 pragma Import_Valued_Procedure (
2755      [Internal                 =>] LOCAL_NAME
2756   [, [External                 =>] EXTERNAL_SYMBOL]
2757   [, [Parameter_Types          =>] PARAMETER_TYPES]
2758   [, [Mechanism                =>] MECHANISM]
2759   [, [First_Optional_Parameter =>] IDENTIFIER]);
2761 EXTERNAL_SYMBOL ::=
2762   IDENTIFIER
2763 | static_string_EXPRESSION
2765 PARAMETER_TYPES ::=
2766   null
2767 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2769 TYPE_DESIGNATOR ::=
2770   subtype_NAME
2771 | subtype_Name ' Access
2773 MECHANISM ::=
2774   MECHANISM_NAME
2775 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2777 MECHANISM_ASSOCIATION ::=
2778   [formal_parameter_NAME =>] MECHANISM_NAME
2780 MECHANISM_NAME ::=
2781   Value
2782 | Reference
2783 | Descriptor [([Class =>] CLASS_NAME)]
2784 | Short_Descriptor [([Class =>] CLASS_NAME)]
2786 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2787 @end smallexample
2789 @noindent
2790 This pragma is identical to @code{Import_Procedure} except that the
2791 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2792 mode @code{OUT}, and externally the subprogram is treated as a function
2793 with this parameter as the result of the function.  The purpose of this
2794 capability is to allow the use of @code{OUT} and @code{IN OUT}
2795 parameters in interfacing to external functions (which are not permitted
2796 in Ada functions).  You may optionally use the @code{Mechanism}
2797 parameters to specify passing mechanisms for the parameters.
2798 If you specify a single mechanism name, it applies to all parameters.
2799 Otherwise you may specify a mechanism on a parameter by parameter
2800 basis using either positional or named notation.  If the mechanism is not
2801 specified, the default mechanism is used.
2803 Note that it is important to use this pragma in conjunction with a separate
2804 pragma Import that specifies the desired convention, since otherwise the
2805 default convention is Ada, which is almost certainly not what is required.
2807 @node Pragma Initialize_Scalars
2808 @unnumberedsec Pragma Initialize_Scalars
2809 @findex Initialize_Scalars
2810 @cindex debugging with Initialize_Scalars
2811 @noindent
2812 Syntax:
2814 @smallexample @c ada
2815 pragma Initialize_Scalars;
2816 @end smallexample
2818 @noindent
2819 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2820 two important differences.  First, there is no requirement for the pragma
2821 to be used uniformly in all units of a partition, in particular, it is fine
2822 to use this just for some or all of the application units of a partition,
2823 without needing to recompile the run-time library.
2825 In the case where some units are compiled with the pragma, and some without,
2826 then a declaration of a variable where the type is defined in package
2827 Standard or is locally declared will always be subject to initialization,
2828 as will any declaration of a scalar variable.  For composite variables,
2829 whether the variable is initialized may also depend on whether the package
2830 in which the type of the variable is declared is compiled with the pragma.
2832 The other important difference is that you can control the value used
2833 for initializing scalar objects.  At bind time, you can select several
2834 options for initialization. You can
2835 initialize with invalid values (similar to Normalize_Scalars, though for
2836 Initialize_Scalars it is not always possible to determine the invalid
2837 values in complex cases like signed component fields with non-standard
2838 sizes). You can also initialize with high or
2839 low values, or with a specified bit pattern.  See the users guide for binder
2840 options for specifying these cases.
2842 This means that you can compile a program, and then without having to
2843 recompile the program, you can run it with different values being used
2844 for initializing otherwise uninitialized values, to test if your program
2845 behavior depends on the choice.  Of course the behavior should not change,
2846 and if it does, then most likely you have an erroneous reference to an
2847 uninitialized value.
2849 It is even possible to change the value at execution time eliminating even
2850 the need to rebind with a different switch using an environment variable.
2851 See the GNAT users guide for details.
2853 Note that pragma @code{Initialize_Scalars} is particularly useful in
2854 conjunction with the enhanced validity checking that is now provided
2855 in GNAT, which checks for invalid values under more conditions.
2856 Using this feature (see description of the @option{-gnatV} flag in the
2857 users guide) in conjunction with pragma @code{Initialize_Scalars}
2858 provides a powerful new tool to assist in the detection of problems
2859 caused by uninitialized variables.
2861 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2862 effect on the generated code. This may cause your code to be
2863 substantially larger. It may also cause an increase in the amount
2864 of stack required, so it is probably a good idea to turn on stack
2865 checking (see description of stack checking in the GNAT users guide)
2866 when using this pragma.
2868 @node Pragma Inline_Always
2869 @unnumberedsec Pragma Inline_Always
2870 @findex Inline_Always
2871 @noindent
2872 Syntax:
2874 @smallexample @c ada
2875 pragma Inline_Always (NAME [, NAME]);
2876 @end smallexample
2878 @noindent
2879 Similar to pragma @code{Inline} except that inlining is not subject to
2880 the use of option @option{-gnatn} and the inlining happens regardless of
2881 whether this option is used.
2883 @node Pragma Inline_Generic
2884 @unnumberedsec Pragma Inline_Generic
2885 @findex Inline_Generic
2886 @noindent
2887 Syntax:
2889 @smallexample @c ada
2890 pragma Inline_Generic (generic_package_NAME);
2891 @end smallexample
2893 @noindent
2894 This is implemented for compatibility with DEC Ada 83 and is recognized,
2895 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2896 by default when using GNAT@.
2898 @node Pragma Interface
2899 @unnumberedsec Pragma Interface
2900 @findex Interface
2901 @noindent
2902 Syntax:
2904 @smallexample @c ada
2905 pragma Interface (
2906      [Convention    =>] convention_identifier,
2907      [Entity        =>] local_NAME
2908   [, [External_Name =>] static_string_expression]
2909   [, [Link_Name     =>] static_string_expression]);
2910 @end smallexample
2912 @noindent
2913 This pragma is identical in syntax and semantics to
2914 the standard Ada pragma @code{Import}.  It is provided for compatibility
2915 with Ada 83.  The definition is upwards compatible both with pragma
2916 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2917 with some extended implementations of this pragma in certain Ada 83
2918 implementations.  The only difference between pragma @code{Interface}
2919 and pragma @code{Import} is that there is special circuitry to allow
2920 both pragmas to appear for the same subprogram entity (normally it
2921 is illegal to have multiple @code{Import} pragmas. This is useful in
2922 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2923 Ada 83 compilers.
2925 @node Pragma Interface_Name
2926 @unnumberedsec Pragma Interface_Name
2927 @findex Interface_Name
2928 @noindent
2929 Syntax:
2931 @smallexample @c ada
2932 pragma Interface_Name (
2933      [Entity        =>] LOCAL_NAME
2934   [, [External_Name =>] static_string_EXPRESSION]
2935   [, [Link_Name     =>] static_string_EXPRESSION]);
2936 @end smallexample
2938 @noindent
2939 This pragma provides an alternative way of specifying the interface name
2940 for an interfaced subprogram, and is provided for compatibility with Ada
2941 83 compilers that use the pragma for this purpose.  You must provide at
2942 least one of @var{External_Name} or @var{Link_Name}.
2944 @node Pragma Interrupt_Handler
2945 @unnumberedsec Pragma Interrupt_Handler
2946 @findex Interrupt_Handler
2947 @noindent
2948 Syntax:
2950 @smallexample @c ada
2951 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2952 @end smallexample
2954 @noindent
2955 This program unit pragma is supported for parameterless protected procedures
2956 as described in Annex C of the Ada Reference Manual. On the AAMP target
2957 the pragma can also be specified for nonprotected parameterless procedures
2958 that are declared at the library level (which includes procedures
2959 declared at the top level of a library package). In the case of AAMP,
2960 when this pragma is applied to a nonprotected procedure, the instruction
2961 @code{IERET} is generated for returns from the procedure, enabling
2962 maskable interrupts, in place of the normal return instruction.
2964 @node Pragma Interrupt_State
2965 @unnumberedsec Pragma Interrupt_State
2966 @findex Interrupt_State
2967 @noindent
2968 Syntax:
2970 @smallexample @c ada
2971 pragma Interrupt_State
2972  ([Name  =>] value,
2973   [State =>] SYSTEM | RUNTIME | USER);
2974 @end smallexample
2976 @noindent
2977 Normally certain interrupts are reserved to the implementation.  Any attempt
2978 to attach an interrupt causes Program_Error to be raised, as described in
2979 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2980 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2981 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2982 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2983 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2984 Ada exceptions, or used to implement run-time functions such as the
2985 @code{abort} statement and stack overflow checking.
2987 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2988 such uses of interrupts.  It subsumes the functionality of pragma
2989 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2990 available on Windows or VMS.  On all other platforms than VxWorks,
2991 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2992 and may be used to mark interrupts required by the board support package
2993 as reserved.
2995 Interrupts can be in one of three states:
2996 @itemize @bullet
2997 @item System
2999 The interrupt is reserved (no Ada handler can be installed), and the
3000 Ada run-time may not install a handler. As a result you are guaranteed
3001 standard system default action if this interrupt is raised.
3003 @item Runtime
3005 The interrupt is reserved (no Ada handler can be installed). The run time
3006 is allowed to install a handler for internal control purposes, but is
3007 not required to do so.
3009 @item User
3011 The interrupt is unreserved.  The user may install a handler to provide
3012 some other action.
3013 @end itemize
3015 @noindent
3016 These states are the allowed values of the @code{State} parameter of the
3017 pragma.  The @code{Name} parameter is a value of the type
3018 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3019 @code{Ada.Interrupts.Names}.
3021 This is a configuration pragma, and the binder will check that there
3022 are no inconsistencies between different units in a partition in how a
3023 given interrupt is specified. It may appear anywhere a pragma is legal.
3025 The effect is to move the interrupt to the specified state.
3027 By declaring interrupts to be SYSTEM, you guarantee the standard system
3028 action, such as a core dump.
3030 By declaring interrupts to be USER, you guarantee that you can install
3031 a handler.
3033 Note that certain signals on many operating systems cannot be caught and
3034 handled by applications.  In such cases, the pragma is ignored.  See the
3035 operating system documentation, or the value of the array @code{Reserved}
3036 declared in the spec of package @code{System.OS_Interface}.
3038 Overriding the default state of signals used by the Ada runtime may interfere
3039 with an application's runtime behavior in the cases of the synchronous signals,
3040 and in the case of the signal used to implement the @code{abort} statement.
3042 @node Pragma Keep_Names
3043 @unnumberedsec Pragma Keep_Names
3044 @findex Keep_Names
3045 @noindent
3046 Syntax:
3048 @smallexample @c ada
3049 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3050 @end smallexample
3052 @noindent
3053 The @var{LOCAL_NAME} argument
3054 must refer to an enumeration first subtype
3055 in the current declarative part. The effect is to retain the enumeration
3056 literal names for use by @code{Image} and @code{Value} even if a global
3057 @code{Discard_Names} pragma applies. This is useful when you want to
3058 generally suppress enumeration literal names and for example you therefore
3059 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3060 want to retain the names for specific enumeration types.
3062 @node Pragma License
3063 @unnumberedsec Pragma License
3064 @findex License
3065 @cindex License checking
3066 @noindent
3067 Syntax:
3069 @smallexample @c ada
3070 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3071 @end smallexample
3073 @noindent
3074 This pragma is provided to allow automated checking for appropriate license
3075 conditions with respect to the standard and modified GPL@.  A pragma
3076 @code{License}, which is a configuration pragma that typically appears at
3077 the start of a source file or in a separate @file{gnat.adc} file, specifies
3078 the licensing conditions of a unit as follows:
3080 @itemize @bullet
3081 @item Unrestricted
3082 This is used for a unit that can be freely used with no license restrictions.
3083 Examples of such units are public domain units, and units from the Ada
3084 Reference Manual.
3086 @item GPL
3087 This is used for a unit that is licensed under the unmodified GPL, and which
3088 therefore cannot be @code{with}'ed by a restricted unit.
3090 @item Modified_GPL
3091 This is used for a unit licensed under the GNAT modified GPL that includes
3092 a special exception paragraph that specifically permits the inclusion of
3093 the unit in programs without requiring the entire program to be released
3094 under the GPL@.
3096 @item Restricted
3097 This is used for a unit that is restricted in that it is not permitted to
3098 depend on units that are licensed under the GPL@.  Typical examples are
3099 proprietary code that is to be released under more restrictive license
3100 conditions.  Note that restricted units are permitted to @code{with} units
3101 which are licensed under the modified GPL (this is the whole point of the
3102 modified GPL).
3104 @end itemize
3106 @noindent
3107 Normally a unit with no @code{License} pragma is considered to have an
3108 unknown license, and no checking is done.  However, standard GNAT headers
3109 are recognized, and license information is derived from them as follows.
3111 @itemize @bullet
3113 A GNAT license header starts with a line containing 78 hyphens.  The following
3114 comment text is searched for the appearance of any of the following strings.
3116 If the string ``GNU General Public License'' is found, then the unit is assumed
3117 to have GPL license, unless the string ``As a special exception'' follows, in
3118 which case the license is assumed to be modified GPL@.
3120 If one of the strings
3121 ``This specification is adapted from the Ada Semantic Interface'' or
3122 ``This specification is derived from the Ada Reference Manual'' is found
3123 then the unit is assumed to be unrestricted.
3124 @end itemize
3126 @noindent
3127 These default actions means that a program with a restricted license pragma
3128 will automatically get warnings if a GPL unit is inappropriately
3129 @code{with}'ed.  For example, the program:
3131 @smallexample @c ada
3132 with Sem_Ch3;
3133 with GNAT.Sockets;
3134 procedure Secret_Stuff is
3135   @dots{}
3136 end Secret_Stuff
3137 @end smallexample
3139 @noindent
3140 if compiled with pragma @code{License} (@code{Restricted}) in a
3141 @file{gnat.adc} file will generate the warning:
3143 @smallexample
3144 1.  with Sem_Ch3;
3145         |
3146    >>> license of withed unit "Sem_Ch3" is incompatible
3148 2.  with GNAT.Sockets;
3149 3.  procedure Secret_Stuff is
3150 @end smallexample
3152 @noindent
3153 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3154 compiler and is licensed under the
3155 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3156 run time, and is therefore licensed under the modified GPL@.
3158 @node Pragma Link_With
3159 @unnumberedsec Pragma Link_With
3160 @findex Link_With
3161 @noindent
3162 Syntax:
3164 @smallexample @c ada
3165 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3166 @end smallexample
3168 @noindent
3169 This pragma is provided for compatibility with certain Ada 83 compilers.
3170 It has exactly the same effect as pragma @code{Linker_Options} except
3171 that spaces occurring within one of the string expressions are treated
3172 as separators. For example, in the following case:
3174 @smallexample @c ada
3175 pragma Link_With ("-labc -ldef");
3176 @end smallexample
3178 @noindent
3179 results in passing the strings @code{-labc} and @code{-ldef} as two
3180 separate arguments to the linker. In addition pragma Link_With allows
3181 multiple arguments, with the same effect as successive pragmas.
3183 @node Pragma Linker_Alias
3184 @unnumberedsec Pragma Linker_Alias
3185 @findex Linker_Alias
3186 @noindent
3187 Syntax:
3189 @smallexample @c ada
3190 pragma Linker_Alias (
3191   [Entity =>] LOCAL_NAME,
3192   [Target =>] static_string_EXPRESSION);
3193 @end smallexample
3195 @noindent
3196 @var{LOCAL_NAME} must refer to an object that is declared at the library
3197 level. This pragma establishes the given entity as a linker alias for the
3198 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3199 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3200 @var{static_string_EXPRESSION} in the object file, that is to say no space
3201 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3202 to the same address as @var{static_string_EXPRESSION} by the linker.
3204 The actual linker name for the target must be used (e.g.@: the fully
3205 encoded name with qualification in Ada, or the mangled name in C++),
3206 or it must be declared using the C convention with @code{pragma Import}
3207 or @code{pragma Export}.
3209 Not all target machines support this pragma. On some of them it is accepted
3210 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3212 @smallexample @c ada
3213 --  Example of the use of pragma Linker_Alias
3215 package p is
3216   i : Integer := 1;
3217   pragma Export (C, i);
3219   new_name_for_i : Integer;
3220   pragma Linker_Alias (new_name_for_i, "i");
3221 end p;
3222 @end smallexample
3224 @node Pragma Linker_Constructor
3225 @unnumberedsec Pragma Linker_Constructor
3226 @findex Linker_Constructor
3227 @noindent
3228 Syntax:
3230 @smallexample @c ada
3231 pragma Linker_Constructor (procedure_LOCAL_NAME);
3232 @end smallexample
3234 @noindent
3235 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3236 is declared at the library level. A procedure to which this pragma is
3237 applied will be treated as an initialization routine by the linker.
3238 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3239 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3240 of the executable is called (or immediately after the shared library is
3241 loaded if the procedure is linked in a shared library), in particular
3242 before the Ada run-time environment is set up.
3244 Because of these specific contexts, the set of operations such a procedure
3245 can perform is very limited and the type of objects it can manipulate is
3246 essentially restricted to the elementary types. In particular, it must only
3247 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3249 This pragma is used by GNAT to implement auto-initialization of shared Stand
3250 Alone Libraries, which provides a related capability without the restrictions
3251 listed above. Where possible, the use of Stand Alone Libraries is preferable
3252 to the use of this pragma.
3254 @node Pragma Linker_Destructor
3255 @unnumberedsec Pragma Linker_Destructor
3256 @findex Linker_Destructor
3257 @noindent
3258 Syntax:
3260 @smallexample @c ada
3261 pragma Linker_Destructor (procedure_LOCAL_NAME);
3262 @end smallexample
3264 @noindent
3265 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3266 is declared at the library level. A procedure to which this pragma is
3267 applied will be treated as a finalization routine by the linker.
3268 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3269 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3270 of the executable has exited (or immediately before the shared library
3271 is unloaded if the procedure is linked in a shared library), in particular
3272 after the Ada run-time environment is shut down.
3274 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3275 because of these specific contexts.
3277 @node Pragma Linker_Section
3278 @unnumberedsec Pragma Linker_Section
3279 @findex Linker_Section
3280 @noindent
3281 Syntax:
3283 @smallexample @c ada
3284 pragma Linker_Section (
3285   [Entity  =>] LOCAL_NAME,
3286   [Section =>] static_string_EXPRESSION);
3287 @end smallexample
3289 @noindent
3290 @var{LOCAL_NAME} must refer to an object that is declared at the library
3291 level. This pragma specifies the name of the linker section for the given
3292 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3293 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3294 section of the executable (assuming the linker doesn't rename the section).
3296 The compiler normally places library-level objects in standard sections
3297 depending on their type: procedures and functions generally go in the
3298 @code{.text} section, initialized variables in the @code{.data} section
3299 and uninitialized variables in the @code{.bss} section.
3301 Other, special sections may exist on given target machines to map special
3302 hardware, for example I/O ports or flash memory. This pragma is a means to
3303 defer the final layout of the executable to the linker, thus fully working
3304 at the symbolic level with the compiler.
3306 Some file formats do not support arbitrary sections so not all target
3307 machines support this pragma. The use of this pragma may cause a program
3308 execution to be erroneous if it is used to place an entity into an
3309 inappropriate section (e.g.@: a modified variable into the @code{.text}
3310 section). See also @code{pragma Persistent_BSS}.
3312 @smallexample @c ada
3313 --  Example of the use of pragma Linker_Section
3315 package IO_Card is
3316   Port_A : Integer;
3317   pragma Volatile (Port_A);
3318   pragma Linker_Section (Port_A, ".bss.port_a");
3320   Port_B : Integer;
3321   pragma Volatile (Port_B);
3322   pragma Linker_Section (Port_B, ".bss.port_b");
3323 end IO_Card;
3324 @end smallexample
3326 @node Pragma Long_Float
3327 @unnumberedsec Pragma Long_Float
3328 @cindex OpenVMS
3329 @findex Long_Float
3330 @noindent
3331 Syntax:
3333 @smallexample @c ada
3334 pragma Long_Float (FLOAT_FORMAT);
3336 FLOAT_FORMAT ::= D_Float | G_Float
3337 @end smallexample
3339 @noindent
3340 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3341 It allows control over the internal representation chosen for the predefined
3342 type @code{Long_Float} and for floating point type representations with
3343 @code{digits} specified in the range 7 through 15.
3344 For further details on this pragma, see the
3345 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3346 this pragma, the standard runtime libraries must be recompiled.
3347 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3348 @value{EDITION} User's Guide OpenVMS}, for a description of the
3349 @code{GNAT LIBRARY} command.
3351 @node Pragma Machine_Attribute
3352 @unnumberedsec Pragma Machine_Attribute
3353 @findex Machine_Attribute
3354 @noindent
3355 Syntax:
3357 @smallexample @c ada
3358 pragma Machine_Attribute (
3359      [Entity         =>] LOCAL_NAME,
3360      [Attribute_Name =>] static_string_EXPRESSION
3361   [, [Info           =>] static_EXPRESSION] );
3362 @end smallexample
3364 @noindent
3365 Machine-dependent attributes can be specified for types and/or
3366 declarations.  This pragma is semantically equivalent to
3367 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3368 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3369 in GNU C, where @code{@var{attribute_name}} is recognized by the
3370 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3371 specific macro.  A string literal for the optional parameter @var{info}
3372 is transformed into an identifier, which may make this pragma unusable
3373 for some attributes.  @xref{Target Attributes,, Defining target-specific
3374 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3375 Internals}, further information.
3377 @node Pragma Main
3378 @unnumberedsec Pragma Main
3379 @cindex OpenVMS
3380 @findex Main
3381 @noindent
3382 Syntax:
3384 @smallexample @c ada
3385 pragma Main
3386  (MAIN_OPTION [, MAIN_OPTION]);
3388 MAIN_OPTION ::=
3389   [Stack_Size              =>] static_integer_EXPRESSION
3390 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3391 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3392 @end smallexample
3394 @noindent
3395 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3396 no effect in GNAT, other than being syntax checked.
3398 @node Pragma Main_Storage
3399 @unnumberedsec Pragma Main_Storage
3400 @cindex OpenVMS
3401 @findex Main_Storage
3402 @noindent
3403 Syntax:
3405 @smallexample @c ada
3406 pragma Main_Storage
3407   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3409 MAIN_STORAGE_OPTION ::=
3410   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3411 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3412 @end smallexample
3414 @noindent
3415 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3416 no effect in GNAT, other than being syntax checked.  Note that the pragma
3417 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3419 @node Pragma No_Body
3420 @unnumberedsec Pragma No_Body
3421 @findex No_Body
3422 @noindent
3423 Syntax:
3425 @smallexample @c ada
3426 pragma No_Body;
3427 @end smallexample
3429 @noindent
3430 There are a number of cases in which a package spec does not require a body,
3431 and in fact a body is not permitted. GNAT will not permit the spec to be
3432 compiled if there is a body around. The pragma No_Body allows you to provide
3433 a body file, even in a case where no body is allowed. The body file must
3434 contain only comments and a single No_Body pragma. This is recognized by
3435 the compiler as indicating that no body is logically present.
3437 This is particularly useful during maintenance when a package is modified in
3438 such a way that a body needed before is no longer needed. The provision of a
3439 dummy body with a No_Body pragma ensures that there is no interference from
3440 earlier versions of the package body.
3442 @node Pragma No_Return
3443 @unnumberedsec Pragma No_Return
3444 @findex No_Return
3445 @noindent
3446 Syntax:
3448 @smallexample @c ada
3449 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3450 @end smallexample
3452 @noindent
3453 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3454 declarations in the current declarative part.  A procedure to which this
3455 pragma is applied may not contain any explicit @code{return} statements.
3456 In addition, if the procedure contains any implicit returns from falling
3457 off the end of a statement sequence, then execution of that implicit
3458 return will cause Program_Error to be raised.
3460 One use of this pragma is to identify procedures whose only purpose is to raise
3461 an exception. Another use of this pragma is to suppress incorrect warnings
3462 about missing returns in functions, where the last statement of a function
3463 statement sequence is a call to such a procedure.
3465 Note that in Ada 2005 mode, this pragma is part of the language, and is
3466 identical in effect to the pragma as implemented in Ada 95 mode.
3468 @node Pragma No_Strict_Aliasing
3469 @unnumberedsec Pragma No_Strict_Aliasing
3470 @findex No_Strict_Aliasing
3471 @noindent
3472 Syntax:
3474 @smallexample @c ada
3475 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3476 @end smallexample
3478 @noindent
3479 @var{type_LOCAL_NAME} must refer to an access type
3480 declaration in the current declarative part.  The effect is to inhibit
3481 strict aliasing optimization for the given type.  The form with no
3482 arguments is a configuration pragma which applies to all access types
3483 declared in units to which the pragma applies. For a detailed
3484 description of the strict aliasing optimization, and the situations
3485 in which it must be suppressed, see @ref{Optimization and Strict
3486 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3488 @node Pragma Normalize_Scalars
3489 @unnumberedsec Pragma Normalize_Scalars
3490 @findex Normalize_Scalars
3491 @noindent
3492 Syntax:
3494 @smallexample @c ada
3495 pragma Normalize_Scalars;
3496 @end smallexample
3498 @noindent
3499 This is a language defined pragma which is fully implemented in GNAT@.  The
3500 effect is to cause all scalar objects that are not otherwise initialized
3501 to be initialized.  The initial values are implementation dependent and
3502 are as follows:
3504 @table @code
3505 @item Standard.Character
3506 @noindent
3507 Objects whose root type is Standard.Character are initialized to
3508 Character'Last unless the subtype range excludes NUL (in which case
3509 NUL is used). This choice will always generate an invalid value if
3510 one exists.
3512 @item Standard.Wide_Character
3513 @noindent
3514 Objects whose root type is Standard.Wide_Character are initialized to
3515 Wide_Character'Last unless the subtype range excludes NUL (in which case
3516 NUL is used). This choice will always generate an invalid value if
3517 one exists.
3519 @item Standard.Wide_Wide_Character
3520 @noindent
3521 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3522 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3523 which case NUL is used). This choice will always generate an invalid value if
3524 one exists.
3526 @item Integer types
3527 @noindent
3528 Objects of an integer type are treated differently depending on whether
3529 negative values are present in the subtype. If no negative values are
3530 present, then all one bits is used as the initial value except in the
3531 special case where zero is excluded from the subtype, in which case
3532 all zero bits are used. This choice will always generate an invalid
3533 value if one exists.
3535 For subtypes with negative values present, the largest negative number
3536 is used, except in the unusual case where this largest negative number
3537 is in the subtype, and the largest positive number is not, in which case
3538 the largest positive value is used. This choice will always generate
3539 an invalid value if one exists.
3541 @item Floating-Point Types
3542 Objects of all floating-point types are initialized to all 1-bits. For
3543 standard IEEE format, this corresponds to a NaN (not a number) which is
3544 indeed an invalid value.
3546 @item Fixed-Point Types
3547 Objects of all fixed-point types are treated as described above for integers,
3548 with the rules applying to the underlying integer value used to represent
3549 the fixed-point value.
3551 @item Modular types
3552 Objects of a modular type are initialized to all one bits, except in
3553 the special case where zero is excluded from the subtype, in which
3554 case all zero bits are used. This choice will always generate an
3555 invalid value if one exists.
3557 @item Enumeration types
3558 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3559 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3560 whose Pos value is zero, in which case a code of zero is used. This choice
3561 will always generate an invalid value if one exists.
3563 @end table
3565 @node Pragma Obsolescent
3566 @unnumberedsec Pragma Obsolescent
3567 @findex Obsolescent
3568 @noindent
3569 Syntax:
3571 @smallexample @c ada
3572 pragma Obsolescent;
3574 pragma Obsolescent (
3575   [Message =>] static_string_EXPRESSION
3576 [,[Version =>] Ada_05]]);
3578 pragma Obsolescent (
3579   [Entity  =>] NAME
3580 [,[Message =>] static_string_EXPRESSION
3581 [,[Version =>] Ada_05]] );
3582 @end smallexample
3584 @noindent
3585 This pragma can occur immediately following a declaration of an entity,
3586 including the case of a record component. If no Entity argument is present,
3587 then this declaration is the one to which the pragma applies. If an Entity
3588 parameter is present, it must either match the name of the entity in this
3589 declaration, or alternatively, the pragma can immediately follow an enumeration
3590 type declaration, where the Entity argument names one of the enumeration
3591 literals.
3593 This pragma is used to indicate that the named entity
3594 is considered obsolescent and should not be used. Typically this is
3595 used when an API must be modified by eventually removing or modifying
3596 existing subprograms or other entities. The pragma can be used at an
3597 intermediate stage when the entity is still present, but will be
3598 removed later.
3600 The effect of this pragma is to output a warning message on a reference to
3601 an entity thus marked that the subprogram is obsolescent if the appropriate
3602 warning option in the compiler is activated. If the Message parameter is
3603 present, then a second warning message is given containing this text. In
3604 addition, a reference to the eneity is considered to be a violation of pragma
3605 Restrictions (No_Obsolescent_Features).
3607 This pragma can also be used as a program unit pragma for a package,
3608 in which case the entity name is the name of the package, and the
3609 pragma indicates that the entire package is considered
3610 obsolescent. In this case a client @code{with}'ing such a package
3611 violates the restriction, and the @code{with} statement is
3612 flagged with warnings if the warning option is set.
3614 If the Version parameter is present (which must be exactly
3615 the identifier Ada_05, no other argument is allowed), then the
3616 indication of obsolescence applies only when compiling in Ada 2005
3617 mode. This is primarily intended for dealing with the situations
3618 in the predefined library where subprograms or packages
3619 have become defined as obsolescent in Ada 2005
3620 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3622 The following examples show typical uses of this pragma:
3624 @smallexample @c ada
3625 package p is
3626    pragma Obsolescent (p, Message => "use pp instead of p");
3627 end p;
3629 package q is
3630    procedure q2;
3631    pragma Obsolescent ("use q2new instead");
3633    type R is new integer;
3634    pragma Obsolescent
3635      (Entity  => R,
3636       Message => "use RR in Ada 2005",
3637       Version => Ada_05);
3639    type M is record
3640       F1 : Integer;
3641       F2 : Integer;
3642       pragma Obsolescent;
3643       F3 : Integer;
3644    end record;
3646    type E is (a, bc, 'd', quack);
3647    pragma Obsolescent (Entity => bc)
3648    pragma Obsolescent (Entity => 'd')
3650    function "+"
3651      (a, b : character) return character;
3652    pragma Obsolescent (Entity => "+");
3653 end;
3654 @end smallexample
3656 @noindent
3657 Note that, as for all pragmas, if you use a pragma argument identifier,
3658 then all subsequent parameters must also use a pragma argument identifier.
3659 So if you specify "Entity =>" for the Entity argument, and a Message
3660 argument is present, it must be preceded by "Message =>".
3662 @node Pragma Optimize_Alignment
3663 @unnumberedsec Pragma Optimize_Alignment
3664 @findex Optimize_Alignment
3665 @cindex Alignment, default settings
3666 @noindent
3667 Syntax:
3669 @smallexample @c ada
3670 pragma Optimize_Alignment (TIME | SPACE | OFF);
3671 @end smallexample
3673 @noindent
3674 This is a configuration pragma which affects the choice of default alignments
3675 for types where no alignment is explicitly specified. There is a time/space
3676 trade-off in the selection of these values. Large alignments result in more
3677 efficient code, at the expense of larger data space, since sizes have to be
3678 increased to match these alignments. Smaller alignments save space, but the
3679 access code is slower. The normal choice of default alignments (which is what
3680 you get if you do not use this pragma, or if you use an argument of OFF),
3681 tries to balance these two requirements.
3683 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3684 First any packed record is given an alignment of 1. Second, if a size is given
3685 for the type, then the alignment is chosen to avoid increasing this size. For
3686 example, consider:
3688 @smallexample @c ada
3689    type R is record
3690       X : Integer;
3691       Y : Character;
3692    end record;
3694    for R'Size use 5*8;
3695 @end smallexample
3697 @noindent
3698 In the default mode, this type gets an alignment of 4, so that access to the
3699 Integer field X are efficient. But this means that objects of the type end up
3700 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3701 allowed to be bigger than the size of the type, but it can waste space if for
3702 example fields of type R appear in an enclosing record. If the above type is
3703 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3705 Specifying TIME causes larger default alignments to be chosen in the case of
3706 small types with sizes that are not a power of 2. For example, consider:
3708 @smallexample @c ada
3709    type R is record
3710       A : Character;
3711       B : Character;
3712       C : Boolean;
3713    end record;
3715    pragma Pack (R);
3716    for R'Size use 17;
3717 @end smallexample
3719 @noindent
3720 The default alignment for this record is normally 1, but if this type is
3721 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3722 to 4, which wastes space for objects of the type, since they are now 4 bytes
3723 long, but results in more efficient access when the whole record is referenced.
3725 As noted above, this is a configuration pragma, and there is a requirement
3726 that all units in a partition be compiled with a consistent setting of the
3727 optimization setting. This would normally be achieved by use of a configuration
3728 pragma file containing the appropriate setting. The exception to this rule is
3729 that units with an explicit configuration pragma in the same file as the source
3730 unit are excluded from the consistency check, as are all predefined units. The
3731 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3732 pragma appears at the start of the file.
3734 @node Pragma Passive
3735 @unnumberedsec Pragma Passive
3736 @findex Passive
3737 @noindent
3738 Syntax:
3740 @smallexample @c ada
3741 pragma Passive [(Semaphore | No)];
3742 @end smallexample
3744 @noindent
3745 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3746 compatibility with DEC Ada 83 implementations, where it is used within a
3747 task definition to request that a task be made passive.  If the argument
3748 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3749 treats the pragma as an assertion that the containing task is passive
3750 and that optimization of context switch with this task is permitted and
3751 desired.  If the argument @code{No} is present, the task must not be
3752 optimized.  GNAT does not attempt to optimize any tasks in this manner
3753 (since protected objects are available in place of passive tasks).
3755 @node Pragma Persistent_BSS
3756 @unnumberedsec Pragma Persistent_BSS
3757 @findex Persistent_BSS
3758 @noindent
3759 Syntax:
3761 @smallexample @c ada
3762 pragma Persistent_BSS [(LOCAL_NAME)]
3763 @end smallexample
3765 @noindent
3766 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3767 section. On some targets the linker and loader provide for special
3768 treatment of this section, allowing a program to be reloaded without
3769 affecting the contents of this data (hence the name persistent).
3771 There are two forms of usage. If an argument is given, it must be the
3772 local name of a library level object, with no explicit initialization
3773 and whose type is potentially persistent. If no argument is given, then
3774 the pragma is a configuration pragma, and applies to all library level
3775 objects with no explicit initialization of potentially persistent types.
3777 A potentially persistent type is a scalar type, or a non-tagged,
3778 non-discriminated record, all of whose components have no explicit
3779 initialization and are themselves of a potentially persistent type,
3780 or an array, all of whose constraints are static, and whose component
3781 type is potentially persistent.
3783 If this pragma is used on a target where this feature is not supported,
3784 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3786 @node Pragma Polling
3787 @unnumberedsec Pragma Polling
3788 @findex Polling
3789 @noindent
3790 Syntax:
3792 @smallexample @c ada
3793 pragma Polling (ON | OFF);
3794 @end smallexample
3796 @noindent
3797 This pragma controls the generation of polling code.  This is normally off.
3798 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3799 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3800 runtime library, and can be found in file @file{a-excpol.adb}.
3802 Pragma @code{Polling} can appear as a configuration pragma (for example it
3803 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3804 can be used in the statement or declaration sequence to control polling
3805 more locally.
3807 A call to the polling routine is generated at the start of every loop and
3808 at the start of every subprogram call.  This guarantees that the @code{Poll}
3809 routine is called frequently, and places an upper bound (determined by
3810 the complexity of the code) on the period between two @code{Poll} calls.
3812 The primary purpose of the polling interface is to enable asynchronous
3813 aborts on targets that cannot otherwise support it (for example Windows
3814 NT), but it may be used for any other purpose requiring periodic polling.
3815 The standard version is null, and can be replaced by a user program.  This
3816 will require re-compilation of the @code{Ada.Exceptions} package that can
3817 be found in files @file{a-except.ads} and @file{a-except.adb}.
3819 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3820 distribution) is used to enable the asynchronous abort capability on
3821 targets that do not normally support the capability.  The version of
3822 @code{Poll} in this file makes a call to the appropriate runtime routine
3823 to test for an abort condition.
3825 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3826 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3827 details.
3829 @node Pragma Postcondition
3830 @unnumberedsec Pragma Postcondition
3831 @cindex Postconditions
3832 @cindex Checks, postconditions
3833 @findex Postconditions
3834 @noindent
3835 Syntax:
3837 @smallexample @c ada
3838 pragma Postcondition (
3839    [Check   =>] Boolean_Expression
3840  [,[Message =>] String_Expression]);
3841 @end smallexample
3843 @noindent
3844 The @code{Postcondition} pragma allows specification of automatic
3845 postcondition checks for subprograms. These checks are similar to
3846 assertions, but are automatically inserted just prior to the return
3847 statements of the subprogram with which they are associated (including
3848 implicit returns at the end of procedure bodies and associated
3849 exception handlers).
3851 In addition, the boolean expression which is the condition which
3852 must be true may contain references to function'Result in the case
3853 of a function to refer to the returned value.
3855 @code{Postcondition} pragmas may appear either immediate following the
3856 (separate) declaration of a subprogram, or at the start of the
3857 declarations of a subprogram body. Only other pragmas may intervene
3858 (that is appear between the subprogram declaration and its
3859 postconditions, or appear before the postcondition in the
3860 declaration sequence in a subprogram body). In the case of a
3861 postcondition appearing after a subprogram declaration, the
3862 formal arguments of the subprogram are visible, and can be
3863 referenced in the postcondition expressions.
3865 The postconditions are collected and automatically tested just
3866 before any return (implicit or explicit) in the subprogram body.
3867 A postcondition is only recognized if postconditions are active
3868 at the time the pragma is encountered. The compiler switch @option{gnata}
3869 turns on all postconditions by default, and pragma @code{Check_Policy}
3870 with an identifier of @code{Postcondition} can also be used to
3871 control whether postconditions are active.
3873 The general approach is that postconditions are placed in the spec
3874 if they represent functional aspects which make sense to the client.
3875 For example we might have:
3877 @smallexample @c ada
3878    function Direction return Integer;
3879    pragma Postcondition
3880     (Direction'Result = +1
3881        or else
3882      Direction'Result = -1);
3883 @end smallexample
3885 @noindent
3886 which serves to document that the result must be +1 or -1, and
3887 will test that this is the case at run time if postcondition
3888 checking is active.
3890 Postconditions within the subprogram body can be used to
3891 check that some internal aspect of the implementation,
3892 not visible to the client, is operating as expected.
3893 For instance if a square root routine keeps an internal
3894 counter of the number of times it is called, then we
3895 might have the following postcondition:
3897 @smallexample @c ada
3898    Sqrt_Calls : Natural := 0;
3900    function Sqrt (Arg : Float) return Float is
3901      pragma Postcondition
3902        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3903      ...
3904    end Sqrt
3905 @end smallexample
3907 @noindent
3908 As this example, shows, the use of the @code{Old} attribute
3909 is often useful in postconditions to refer to the state on
3910 entry to the subprogram.
3912 Note that postconditions are only checked on normal returns
3913 from the subprogram. If an abnormal return results from
3914 raising an exception, then the postconditions are not checked.
3916 If a postcondition fails, then the exception
3917 @code{System.Assertions.Assert_Failure} is raised. If
3918 a message argument was supplied, then the given string
3919 will be used as the exception message. If no message
3920 argument was supplied, then the default message has
3921 the form "Postcondition failed at file:line". The
3922 exception is raised in the context of the subprogram
3923 body, so it is possible to catch postcondition failures
3924 within the subprogram body itself.
3926 Within a package spec, normal visibility rules
3927 in Ada would prevent forward references within a
3928 postcondition pragma to functions defined later in
3929 the same package. This would introduce undesirable
3930 ordering constraints. To avoid this problem, all
3931 postcondition pragmas are analyzed at the end of
3932 the package spec, allowing forward references.
3934 The following example shows that this even allows
3935 mutually recursive postconditions as in:
3937 @smallexample @c ada
3938 package Parity_Functions is
3939    function Odd  (X : Natural) return Boolean;
3940    pragma Postcondition
3941      (Odd'Result =
3942         (x = 1
3943           or else
3944         (x /= 0 and then Even (X - 1))));
3946    function Even (X : Natural) return Boolean;
3947    pragma Postcondition
3948      (Even'Result =
3949         (x = 0
3950           or else
3951         (x /= 1 and then Odd (X - 1))));
3953 end Parity_Functions;
3954 @end smallexample
3956 @noindent
3957 There are no restrictions on the complexity or form of
3958 conditions used within @code{Postcondition} pragmas.
3959 The following example shows that it is even possible
3960 to verify performance behavior.
3962 @smallexample @c ada
3963 package Sort is
3965    Performance : constant Float;
3966    --  Performance constant set by implementation
3967    --  to match target architecture behavior.
3969    procedure Treesort (Arg : String);
3970    --  Sorts characters of argument using N*logN sort
3971    pragma Postcondition
3972      (Float (Clock - Clock'Old) <=
3973         Float (Arg'Length) *
3974         log (Float (Arg'Length)) *
3975         Performance);
3976 end Sort;
3977 @end smallexample
3979 @noindent
3980 Note: postcondition pragmas associated with subprograms that are
3981 marked as Inline_Always, or those marked as Inline with front-end
3982 inlining (-gnatN option set) are accepted and legality-checked
3983 by the compiler, but are ignored at run-time even if postcondition
3984 checking is enabled.
3986 @node Pragma Precondition
3987 @unnumberedsec Pragma Precondition
3988 @cindex Preconditions
3989 @cindex Checks, preconditions
3990 @findex Preconditions
3991 @noindent
3992 Syntax:
3994 @smallexample @c ada
3995 pragma Precondition (
3996    [Check   =>] Boolean_Expression
3997  [,[Message =>] String_Expression]);
3998 @end smallexample
4000 @noindent
4001 The @code{Precondition} pragma is similar to @code{Postcondition}
4002 except that the corresponding checks take place immediately upon
4003 entry to the subprogram, and if a precondition fails, the exception
4004 is raised in the context of the caller, and the attribute 'Result
4005 cannot be used within the precondition expression.
4007 Otherwise, the placement and visibility rules are identical to those
4008 described for postconditions. The following is an example of use
4009 within a package spec:
4011 @smallexample @c ada
4012 package Math_Functions is
4013    ...
4014    function Sqrt (Arg : Float) return Float;
4015    pragma Precondition (Arg >= 0.0)
4016    ...
4017 end Math_Functions;
4018 @end smallexample
4020 @noindent
4021 @code{Precondition} pragmas may appear either immediate following the
4022 (separate) declaration of a subprogram, or at the start of the
4023 declarations of a subprogram body. Only other pragmas may intervene
4024 (that is appear between the subprogram declaration and its
4025 postconditions, or appear before the postcondition in the
4026 declaration sequence in a subprogram body).
4028 Note: postcondition pragmas associated with subprograms that are
4029 marked as Inline_Always, or those marked as Inline with front-end
4030 inlining (-gnatN option set) are accepted and legality-checked
4031 by the compiler, but are ignored at run-time even if postcondition
4032 checking is enabled.
4034 @node Pragma Profile (Ravenscar)
4035 @unnumberedsec Pragma Profile (Ravenscar)
4036 @findex Ravenscar
4037 @noindent
4038 Syntax:
4040 @smallexample @c ada
4041 pragma Profile (Ravenscar);
4042 @end smallexample
4044 @noindent
4045 A configuration pragma that establishes the following set of configuration
4046 pragmas:
4048 @table @code
4049 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4050 [RM D.2.2] Tasks are dispatched following a preemptive
4051 priority-ordered scheduling policy.
4053 @item Locking_Policy (Ceiling_Locking)
4054 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4055 the ceiling priority of the corresponding protected object.
4057 @c @item Detect_Blocking
4058 @c This pragma forces the detection of potentially blocking operations within a
4059 @c protected operation, and to raise Program_Error if that happens.
4060 @end table
4061 @noindent
4063 plus the following set of restrictions:
4065 @table @code
4066 @item Max_Entry_Queue_Length = 1
4067 Defines the maximum number of calls that are queued on a (protected) entry.
4068 Note that this restrictions is checked at run time. Violation of this
4069 restriction results in the raising of Program_Error exception at the point of
4070 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4071 always 1 and hence no task can be queued on a protected entry.
4073 @item Max_Protected_Entries = 1
4074 [RM D.7] Specifies the maximum number of entries per protected type. The
4075 bounds of every entry family of a protected unit shall be static, or shall be
4076 defined by a discriminant of a subtype whose corresponding bound is static.
4077 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4079 @item Max_Task_Entries = 0
4080 [RM D.7] Specifies the maximum number of entries
4081 per task.  The bounds of every entry family
4082 of a task unit shall be static, or shall be
4083 defined by a discriminant of a subtype whose
4084 corresponding bound is static.  A value of zero
4085 indicates that no rendezvous are possible.  For
4086 the Profile (Ravenscar), the value of Max_Task_Entries is always
4087 0 (zero).
4089 @item No_Abort_Statements
4090 [RM D.7] There are no abort_statements, and there are
4091 no calls to Task_Identification.Abort_Task.
4093 @item No_Asynchronous_Control
4094 There are no semantic dependences on the package
4095 Asynchronous_Task_Control.
4097 @item No_Calendar
4098 There are no semantic dependencies on the package Ada.Calendar.
4100 @item No_Dynamic_Attachment
4101 There is no call to any of the operations defined in package Ada.Interrupts
4102 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4103 Detach_Handler, and Reference).
4105 @item No_Dynamic_Priorities
4106 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4108 @item No_Implicit_Heap_Allocations
4109 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4111 @item No_Local_Protected_Objects
4112 Protected objects and access types that designate
4113 such objects shall be declared only at library level.
4115 @item No_Local_Timing_Events
4116 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4117 declared at the library level.
4119 @item No_Protected_Type_Allocators
4120 There are no allocators for protected types or
4121 types containing protected subcomponents.
4123 @item No_Relative_Delay
4124 There are no delay_relative statements.
4126 @item No_Requeue_Statements
4127 Requeue statements are not allowed.
4129 @item No_Select_Statements
4130 There are no select_statements.
4132 @item No_Specific_Termination_Handlers
4133 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4134 or to Ada.Task_Termination.Specific_Handler.
4136 @item No_Task_Allocators
4137 [RM D.7] There are no allocators for task types
4138 or types containing task subcomponents.
4140 @item No_Task_Attributes_Package
4141 There are no semantic dependencies on the Ada.Task_Attributes package.
4143 @item No_Task_Hierarchy
4144 [RM D.7] All (non-environment) tasks depend
4145 directly on the environment task of the partition.
4147 @item No_Task_Termination
4148 Tasks which terminate are erroneous.
4150 @item No_Unchecked_Conversion
4151 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4153 @item No_Unchecked_Deallocation
4154 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4156 @item Simple_Barriers
4157 Entry barrier condition expressions shall be either static
4158 boolean expressions or boolean objects which are declared in
4159 the protected type which contains the entry.
4160 @end table
4162 @noindent
4163 This set of configuration pragmas and restrictions correspond to the
4164 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4165 published by the @cite{International Real-Time Ada Workshop}, 1997,
4166 and whose most recent description is available at
4167 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4169 The original definition of the profile was revised at subsequent IRTAW
4170 meetings. It has been included in the ISO
4171 @cite{Guide for the Use of the Ada Programming Language in High
4172 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4173 the next revision of the standard. The formal definition given by
4174 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4175 AI-305) available at
4176 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4177 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4178 respectively.
4180 The above set is a superset of the restrictions provided by pragma
4181 @code{Profile (Restricted)}, it includes six additional restrictions
4182 (@code{Simple_Barriers}, @code{No_Select_Statements},
4183 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4184 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4185 that pragma @code{Profile (Ravenscar)}, like the pragma
4186 @code{Profile (Restricted)},
4187 automatically causes the use of a simplified,
4188 more efficient version of the tasking run-time system.
4190 @node Pragma Profile (Restricted)
4191 @unnumberedsec Pragma Profile (Restricted)
4192 @findex Restricted Run Time
4193 @noindent
4194 Syntax:
4196 @smallexample @c ada
4197 pragma Profile (Restricted);
4198 @end smallexample
4200 @noindent
4201 A configuration pragma that establishes the following set of restrictions:
4203 @itemize @bullet
4204 @item No_Abort_Statements
4205 @item No_Entry_Queue
4206 @item No_Task_Hierarchy
4207 @item No_Task_Allocators
4208 @item No_Dynamic_Priorities
4209 @item No_Terminate_Alternatives
4210 @item No_Dynamic_Attachment
4211 @item No_Protected_Type_Allocators
4212 @item No_Local_Protected_Objects
4213 @item No_Requeue_Statements
4214 @item No_Task_Attributes_Package
4215 @item Max_Asynchronous_Select_Nesting =  0
4216 @item Max_Task_Entries =  0
4217 @item Max_Protected_Entries = 1
4218 @item Max_Select_Alternatives = 0
4219 @end itemize
4221 @noindent
4222 This set of restrictions causes the automatic selection of a simplified
4223 version of the run time that provides improved performance for the
4224 limited set of tasking functionality permitted by this set of restrictions.
4226 @node Pragma Psect_Object
4227 @unnumberedsec Pragma Psect_Object
4228 @findex Psect_Object
4229 @noindent
4230 Syntax:
4232 @smallexample @c ada
4233 pragma Psect_Object (
4234      [Internal =>] LOCAL_NAME,
4235   [, [External =>] EXTERNAL_SYMBOL]
4236   [, [Size     =>] EXTERNAL_SYMBOL]);
4238 EXTERNAL_SYMBOL ::=
4239   IDENTIFIER
4240 | static_string_EXPRESSION
4241 @end smallexample
4243 @noindent
4244 This pragma is identical in effect to pragma @code{Common_Object}.
4246 @node Pragma Pure_Function
4247 @unnumberedsec Pragma Pure_Function
4248 @findex Pure_Function
4249 @noindent
4250 Syntax:
4252 @smallexample @c ada
4253 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4254 @end smallexample
4256 @noindent
4257 This pragma appears in the same declarative part as a function
4258 declaration (or a set of function declarations if more than one
4259 overloaded declaration exists, in which case the pragma applies
4260 to all entities).  It specifies that the function @code{Entity} is
4261 to be considered pure for the purposes of code generation.  This means
4262 that the compiler can assume that there are no side effects, and
4263 in particular that two calls with identical arguments produce the
4264 same result.  It also means that the function can be used in an
4265 address clause.
4267 Note that, quite deliberately, there are no static checks to try
4268 to ensure that this promise is met, so @code{Pure_Function} can be used
4269 with functions that are conceptually pure, even if they do modify
4270 global variables.  For example, a square root function that is
4271 instrumented to count the number of times it is called is still
4272 conceptually pure, and can still be optimized, even though it
4273 modifies a global variable (the count).  Memo functions are another
4274 example (where a table of previous calls is kept and consulted to
4275 avoid re-computation).
4277 @findex Pure
4278 Note: Most functions in a @code{Pure} package are automatically pure, and
4279 there is no need to use pragma @code{Pure_Function} for such functions.  One
4280 exception is any function that has at least one formal of type
4281 @code{System.Address} or a type derived from it.  Such functions are not
4282 considered pure by default, since the compiler assumes that the
4283 @code{Address} parameter may be functioning as a pointer and that the
4284 referenced data may change even if the address value does not.
4285 Similarly, imported functions are not considered to be pure by default,
4286 since there is no way of checking that they are in fact pure.  The use
4287 of pragma @code{Pure_Function} for such a function will override these default
4288 assumption, and cause the compiler to treat a designated subprogram as pure
4289 in these cases.
4291 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4292 applies to the underlying renamed function.  This can be used to
4293 disambiguate cases of overloading where some but not all functions
4294 in a set of overloaded functions are to be designated as pure.
4296 If pragma @code{Pure_Function} is applied to a library level function, the
4297 function is also considered pure from an optimization point of view, but the
4298 unit is not a Pure unit in the categorization sense. So for example, a function
4299 thus marked is free to @code{with} non-pure units.
4301 @node Pragma Restriction_Warnings
4302 @unnumberedsec Pragma Restriction_Warnings
4303 @findex Restriction_Warnings
4304 @noindent
4305 Syntax:
4307 @smallexample @c ada
4308 pragma Restriction_Warnings
4309   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4310 @end smallexample
4312 @noindent
4313 This pragma allows a series of restriction identifiers to be
4314 specified (the list of allowed identifiers is the same as for
4315 pragma @code{Restrictions}). For each of these identifiers
4316 the compiler checks for violations of the restriction, but
4317 generates a warning message rather than an error message
4318 if the restriction is violated.
4320 @node Pragma Shared
4321 @unnumberedsec Pragma Shared
4322 @findex Shared
4324 @noindent
4325 This pragma is provided for compatibility with Ada 83. The syntax and
4326 semantics are identical to pragma Atomic.
4328 @node Pragma Short_Circuit_And_Or
4329 @unnumberedsec Pragma Short_Circuit_And_Or
4330 @findex Short_Circuit_And_Or
4332 @noindent
4333 This configuration pragma causes any occurrence of the AND operator applied to
4334 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4335 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4336 may be useful in the context of certification protocols requiring the use of
4337 short-circuited logical operators. If this configuration pragma occurs locally
4338 within the file being compiled, it applies only to the file being compiled.
4339 There is no requirement that all units in a partition use this option.
4341 semantics are identical to pragma Atomic.
4342 @node Pragma Source_File_Name
4343 @unnumberedsec Pragma Source_File_Name
4344 @findex Source_File_Name
4345 @noindent
4346 Syntax:
4348 @smallexample @c ada
4349 pragma Source_File_Name (
4350   [Unit_Name   =>] unit_NAME,
4351   Spec_File_Name =>  STRING_LITERAL,
4352   [Index => INTEGER_LITERAL]);
4354 pragma Source_File_Name (
4355   [Unit_Name   =>] unit_NAME,
4356   Body_File_Name =>  STRING_LITERAL,
4357   [Index => INTEGER_LITERAL]);
4358 @end smallexample
4360 @noindent
4361 Use this to override the normal naming convention.  It is a configuration
4362 pragma, and so has the usual applicability of configuration pragmas
4363 (i.e.@: it applies to either an entire partition, or to all units in a
4364 compilation, or to a single unit, depending on how it is used.
4365 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4366 the second argument is required, and indicates whether this is the file
4367 name for the spec or for the body.
4369 The optional Index argument should be used when a file contains multiple
4370 units, and when you do not want to use @code{gnatchop} to separate then
4371 into multiple files (which is the recommended procedure to limit the
4372 number of recompilations that are needed when some sources change).
4373 For instance, if the source file @file{source.ada} contains
4375 @smallexample @c ada
4376 package B is
4378 end B;
4380 with B;
4381 procedure A is
4382 begin
4383    ..
4384 end A;
4385 @end smallexample
4387 you could use the following configuration pragmas:
4389 @smallexample @c ada
4390 pragma Source_File_Name
4391   (B, Spec_File_Name => "source.ada", Index => 1);
4392 pragma Source_File_Name
4393   (A, Body_File_Name => "source.ada", Index => 2);
4394 @end smallexample
4396 Note that the @code{gnatname} utility can also be used to generate those
4397 configuration pragmas.
4399 Another form of the @code{Source_File_Name} pragma allows
4400 the specification of patterns defining alternative file naming schemes
4401 to apply to all files.
4403 @smallexample @c ada
4404 pragma Source_File_Name
4405   (  [Spec_File_Name  =>] STRING_LITERAL
4406    [,[Casing          =>] CASING_SPEC]
4407    [,[Dot_Replacement =>] STRING_LITERAL]);
4409 pragma Source_File_Name
4410   (  [Body_File_Name  =>] STRING_LITERAL
4411    [,[Casing          =>] CASING_SPEC]
4412    [,[Dot_Replacement =>] STRING_LITERAL]);
4414 pragma Source_File_Name
4415   (  [Subunit_File_Name =>] STRING_LITERAL
4416    [,[Casing            =>] CASING_SPEC]
4417    [,[Dot_Replacement   =>] STRING_LITERAL]);
4419 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4420 @end smallexample
4422 @noindent
4423 The first argument is a pattern that contains a single asterisk indicating
4424 the point at which the unit name is to be inserted in the pattern string
4425 to form the file name.  The second argument is optional.  If present it
4426 specifies the casing of the unit name in the resulting file name string.
4427 The default is lower case.  Finally the third argument allows for systematic
4428 replacement of any dots in the unit name by the specified string literal.
4430 A pragma Source_File_Name cannot appear after a
4431 @ref{Pragma Source_File_Name_Project}.
4433 For more details on the use of the @code{Source_File_Name} pragma,
4434 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4435 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4436 User's Guide}.
4438 @node Pragma Source_File_Name_Project
4439 @unnumberedsec Pragma Source_File_Name_Project
4440 @findex Source_File_Name_Project
4441 @noindent
4443 This pragma has the same syntax and semantics as pragma Source_File_Name.
4444 It is only allowed as a stand alone configuration pragma.
4445 It cannot appear after a @ref{Pragma Source_File_Name}, and
4446 most importantly, once pragma Source_File_Name_Project appears,
4447 no further Source_File_Name pragmas are allowed.
4449 The intention is that Source_File_Name_Project pragmas are always
4450 generated by the Project Manager in a manner consistent with the naming
4451 specified in a project file, and when naming is controlled in this manner,
4452 it is not permissible to attempt to modify this naming scheme using
4453 Source_File_Name pragmas (which would not be known to the project manager).
4455 @node Pragma Source_Reference
4456 @unnumberedsec Pragma Source_Reference
4457 @findex Source_Reference
4458 @noindent
4459 Syntax:
4461 @smallexample @c ada
4462 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4463 @end smallexample
4465 @noindent
4466 This pragma must appear as the first line of a source file.
4467 @var{integer_literal} is the logical line number of the line following
4468 the pragma line (for use in error messages and debugging
4469 information).  @var{string_literal} is a static string constant that
4470 specifies the file name to be used in error messages and debugging
4471 information.  This is most notably used for the output of @code{gnatchop}
4472 with the @option{-r} switch, to make sure that the original unchopped
4473 source file is the one referred to.
4475 The second argument must be a string literal, it cannot be a static
4476 string expression other than a string literal.  This is because its value
4477 is needed for error messages issued by all phases of the compiler.
4479 @node Pragma Stream_Convert
4480 @unnumberedsec Pragma Stream_Convert
4481 @findex Stream_Convert
4482 @noindent
4483 Syntax:
4485 @smallexample @c ada
4486 pragma Stream_Convert (
4487   [Entity =>] type_LOCAL_NAME,
4488   [Read   =>] function_NAME,
4489   [Write  =>] function_NAME);
4490 @end smallexample
4492 @noindent
4493 This pragma provides an efficient way of providing stream functions for
4494 types defined in packages.  Not only is it simpler to use than declaring
4495 the necessary functions with attribute representation clauses, but more
4496 significantly, it allows the declaration to made in such a way that the
4497 stream packages are not loaded unless they are needed.  The use of
4498 the Stream_Convert pragma adds no overhead at all, unless the stream
4499 attributes are actually used on the designated type.
4501 The first argument specifies the type for which stream functions are
4502 provided.  The second parameter provides a function used to read values
4503 of this type.  It must name a function whose argument type may be any
4504 subtype, and whose returned type must be the type given as the first
4505 argument to the pragma.
4507 The meaning of the @var{Read}
4508 parameter is that if a stream attribute directly
4509 or indirectly specifies reading of the type given as the first parameter,
4510 then a value of the type given as the argument to the Read function is
4511 read from the stream, and then the Read function is used to convert this
4512 to the required target type.
4514 Similarly the @var{Write} parameter specifies how to treat write attributes
4515 that directly or indirectly apply to the type given as the first parameter.
4516 It must have an input parameter of the type specified by the first parameter,
4517 and the return type must be the same as the input type of the Read function.
4518 The effect is to first call the Write function to convert to the given stream
4519 type, and then write the result type to the stream.
4521 The Read and Write functions must not be overloaded subprograms.  If necessary
4522 renamings can be supplied to meet this requirement.
4523 The usage of this attribute is best illustrated by a simple example, taken
4524 from the GNAT implementation of package Ada.Strings.Unbounded:
4526 @smallexample @c ada
4527 function To_Unbounded (S : String)
4528            return Unbounded_String
4529   renames To_Unbounded_String;
4531 pragma Stream_Convert
4532   (Unbounded_String, To_Unbounded, To_String);
4533 @end smallexample
4535 @noindent
4536 The specifications of the referenced functions, as given in the Ada
4537 Reference Manual are:
4539 @smallexample @c ada
4540 function To_Unbounded_String (Source : String)
4541   return Unbounded_String;
4543 function To_String (Source : Unbounded_String)
4544   return String;
4545 @end smallexample
4547 @noindent
4548 The effect is that if the value of an unbounded string is written to a stream,
4549 then the representation of the item in the stream is in the same format that
4550 would be used for @code{Standard.String'Output}, and this same representation
4551 is expected when a value of this type is read from the stream. Note that the
4552 value written always includes the bounds, even for Unbounded_String'Write,
4553 since Unbounded_String is not an array type.
4555 @node Pragma Style_Checks
4556 @unnumberedsec Pragma Style_Checks
4557 @findex Style_Checks
4558 @noindent
4559 Syntax:
4561 @smallexample @c ada
4562 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4563                      On | Off [, LOCAL_NAME]);
4564 @end smallexample
4566 @noindent
4567 This pragma is used in conjunction with compiler switches to control the
4568 built in style checking provided by GNAT@.  The compiler switches, if set,
4569 provide an initial setting for the switches, and this pragma may be used
4570 to modify these settings, or the settings may be provided entirely by
4571 the use of the pragma.  This pragma can be used anywhere that a pragma
4572 is legal, including use as a configuration pragma (including use in
4573 the @file{gnat.adc} file).
4575 The form with a string literal specifies which style options are to be
4576 activated.  These are additive, so they apply in addition to any previously
4577 set style check options.  The codes for the options are the same as those
4578 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4579 For example the following two methods can be used to enable
4580 layout checking:
4582 @itemize @bullet
4583 @item
4584 @smallexample @c ada
4585 pragma Style_Checks ("l");
4586 @end smallexample
4588 @item
4589 @smallexample
4590 gcc -c -gnatyl @dots{}
4591 @end smallexample
4592 @end itemize
4594 @noindent
4595 The form ALL_CHECKS activates all standard checks (its use is equivalent
4596 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4597 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4598 @value{EDITION} User's Guide}, for details.)
4600 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4601 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4602 options (i.e. equivalent to -gnatyg).
4604 The forms with @code{Off} and @code{On}
4605 can be used to temporarily disable style checks
4606 as shown in the following example:
4608 @smallexample @c ada
4609 @iftex
4610 @leftskip=0cm
4611 @end iftex
4612 pragma Style_Checks ("k"); -- requires keywords in lower case
4613 pragma Style_Checks (Off); -- turn off style checks
4614 NULL;                      -- this will not generate an error message
4615 pragma Style_Checks (On);  -- turn style checks back on
4616 NULL;                      -- this will generate an error message
4617 @end smallexample
4619 @noindent
4620 Finally the two argument form is allowed only if the first argument is
4621 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4622 for the specified entity, as shown in the following example:
4624 @smallexample @c ada
4625 @iftex
4626 @leftskip=0cm
4627 @end iftex
4628 pragma Style_Checks ("r"); -- require consistency of identifier casing
4629 Arg : Integer;
4630 Rf1 : Integer := ARG;      -- incorrect, wrong case
4631 pragma Style_Checks (Off, Arg);
4632 Rf2 : Integer := ARG;      -- OK, no error
4633 @end smallexample
4635 @node Pragma Subtitle
4636 @unnumberedsec Pragma Subtitle
4637 @findex Subtitle
4638 @noindent
4639 Syntax:
4641 @smallexample @c ada
4642 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4643 @end smallexample
4645 @noindent
4646 This pragma is recognized for compatibility with other Ada compilers
4647 but is ignored by GNAT@.
4649 @node Pragma Suppress
4650 @unnumberedsec Pragma Suppress
4651 @findex Suppress
4652 @noindent
4653 Syntax:
4655 @smallexample @c ada
4656 pragma Suppress (Identifier [, [On =>] Name]);
4657 @end smallexample
4659 @noindent
4660 This is a standard pragma, and supports all the check names required in
4661 the RM. It is included here because GNAT recognizes one additional check
4662 name: @code{Alignment_Check} which can be used to suppress alignment checks
4663 on addresses used in address clauses. Such checks can also be suppressed
4664 by suppressing range checks, but the specific use of @code{Alignment_Check}
4665 allows suppression of alignment checks without suppressing other range checks.
4667 Note that pragma Suppress gives the compiler permission to omit
4668 checks, but does not require the compiler to omit checks. The compiler
4669 will generate checks if they are essentially free, even when they are
4670 suppressed. In particular, if the compiler can prove that a certain
4671 check will necessarily fail, it will generate code to do an
4672 unconditional ``raise'', even if checks are suppressed. The compiler
4673 warns in this case.
4675 Of course, run-time checks are omitted whenever the compiler can prove
4676 that they will not fail, whether or not checks are suppressed.
4678 @node Pragma Suppress_All
4679 @unnumberedsec Pragma Suppress_All
4680 @findex Suppress_All
4681 @noindent
4682 Syntax:
4684 @smallexample @c ada
4685 pragma Suppress_All;
4686 @end smallexample
4688 @noindent
4689 This pragma can only appear immediately following a compilation
4690 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4691 which it follows.  This pragma is implemented for compatibility with DEC
4692 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4693 configuration pragma is the preferred usage in GNAT@.
4695 @node Pragma Suppress_Exception_Locations
4696 @unnumberedsec Pragma Suppress_Exception_Locations
4697 @findex Suppress_Exception_Locations
4698 @noindent
4699 Syntax:
4701 @smallexample @c ada
4702 pragma Suppress_Exception_Locations;
4703 @end smallexample
4705 @noindent
4706 In normal mode, a raise statement for an exception by default generates
4707 an exception message giving the file name and line number for the location
4708 of the raise. This is useful for debugging and logging purposes, but this
4709 entails extra space for the strings for the messages. The configuration
4710 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4711 generation of these strings, with the result that space is saved, but the
4712 exception message for such raises is null. This configuration pragma may
4713 appear in a global configuration pragma file, or in a specific unit as
4714 usual. It is not required that this pragma be used consistently within
4715 a partition, so it is fine to have some units within a partition compiled
4716 with this pragma and others compiled in normal mode without it.
4718 @node Pragma Suppress_Initialization
4719 @unnumberedsec Pragma Suppress_Initialization
4720 @findex Suppress_Initialization
4721 @cindex Suppressing initialization
4722 @cindex Initialization, suppression of
4723 @noindent
4724 Syntax:
4726 @smallexample @c ada
4727 pragma Suppress_Initialization ([Entity =>] type_Name);
4728 @end smallexample
4730 @noindent
4731 This pragma suppresses any implicit or explicit initialization
4732 associated with the given type name for all variables of this type.
4734 @node Pragma Task_Info
4735 @unnumberedsec Pragma Task_Info
4736 @findex Task_Info
4737 @noindent
4738 Syntax
4740 @smallexample @c ada
4741 pragma Task_Info (EXPRESSION);
4742 @end smallexample
4744 @noindent
4745 This pragma appears within a task definition (like pragma
4746 @code{Priority}) and applies to the task in which it appears.  The
4747 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4748 The @code{Task_Info} pragma provides system dependent control over
4749 aspects of tasking implementation, for example, the ability to map
4750 tasks to specific processors.  For details on the facilities available
4751 for the version of GNAT that you are using, see the documentation
4752 in the spec of package System.Task_Info in the runtime
4753 library.
4755 @node Pragma Task_Name
4756 @unnumberedsec Pragma Task_Name
4757 @findex Task_Name
4758 @noindent
4759 Syntax
4761 @smallexample @c ada
4762 pragma Task_Name (string_EXPRESSION);
4763 @end smallexample
4765 @noindent
4766 This pragma appears within a task definition (like pragma
4767 @code{Priority}) and applies to the task in which it appears.  The
4768 argument must be of type String, and provides a name to be used for
4769 the task instance when the task is created.  Note that this expression
4770 is not required to be static, and in particular, it can contain
4771 references to task discriminants.  This facility can be used to
4772 provide different names for different tasks as they are created,
4773 as illustrated in the example below.
4775 The task name is recorded internally in the run-time structures
4776 and is accessible to tools like the debugger.  In addition the
4777 routine @code{Ada.Task_Identification.Image} will return this
4778 string, with a unique task address appended.
4780 @smallexample @c ada
4781 --  Example of the use of pragma Task_Name
4783 with Ada.Task_Identification;
4784 use Ada.Task_Identification;
4785 with Text_IO; use Text_IO;
4786 procedure t3 is
4788    type Astring is access String;
4790    task type Task_Typ (Name : access String) is
4791       pragma Task_Name (Name.all);
4792    end Task_Typ;
4794    task body Task_Typ is
4795       Nam : constant String := Image (Current_Task);
4796    begin
4797       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4798    end Task_Typ;
4800    type Ptr_Task is access Task_Typ;
4801    Task_Var : Ptr_Task;
4803 begin
4804    Task_Var :=
4805      new Task_Typ (new String'("This is task 1"));
4806    Task_Var :=
4807      new Task_Typ (new String'("This is task 2"));
4808 end;
4809 @end smallexample
4811 @node Pragma Task_Storage
4812 @unnumberedsec Pragma Task_Storage
4813 @findex Task_Storage
4814 Syntax:
4816 @smallexample @c ada
4817 pragma Task_Storage (
4818   [Task_Type =>] LOCAL_NAME,
4819   [Top_Guard =>] static_integer_EXPRESSION);
4820 @end smallexample
4822 @noindent
4823 This pragma specifies the length of the guard area for tasks.  The guard
4824 area is an additional storage area allocated to a task.  A value of zero
4825 means that either no guard area is created or a minimal guard area is
4826 created, depending on the target.  This pragma can appear anywhere a
4827 @code{Storage_Size} attribute definition clause is allowed for a task
4828 type.
4830 @node Pragma Thread_Local_Storage
4831 @unnumberedsec Pragma Thread_Local_Storage
4832 @findex Thread_Local_Storage
4833 @cindex Task specific storage
4834 @cindex TLS (Thread Local Storage)
4835 Syntax:
4837 @smallexample @c ada
4838 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4839 @end smallexample
4841 @noindent
4842 This pragma specifies that the specified entity, which must be
4843 a variable declared in a library level package, is to be marked as
4844 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4845 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4846 (and hence each Ada task) to see a distinct copy of the variable.
4848 The variable may not have default initialization, and if there is
4849 an explicit initialization, it must be either @code{null} for an
4850 access variable, or a static expression for a scalar variable.
4851 This provides a low level mechanism similar to that provided by
4852 the @code{Ada.Task_Attributes} package, but much more efficient
4853 and is also useful in writing interface code that will interact
4854 with foreign threads.
4856 If this pragma is used on a system where @code{TLS} is not supported,
4857 then an error message will be generated and the program will be rejected.
4859 @node Pragma Time_Slice
4860 @unnumberedsec Pragma Time_Slice
4861 @findex Time_Slice
4862 @noindent
4863 Syntax:
4865 @smallexample @c ada
4866 pragma Time_Slice (static_duration_EXPRESSION);
4867 @end smallexample
4869 @noindent
4870 For implementations of GNAT on operating systems where it is possible
4871 to supply a time slice value, this pragma may be used for this purpose.
4872 It is ignored if it is used in a system that does not allow this control,
4873 or if it appears in other than the main program unit.
4874 @cindex OpenVMS
4875 Note that the effect of this pragma is identical to the effect of the
4876 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4878 @node Pragma Title
4879 @unnumberedsec Pragma Title
4880 @findex Title
4881 @noindent
4882 Syntax:
4884 @smallexample @c ada
4885 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4887 TITLING_OPTION ::=
4888   [Title    =>] STRING_LITERAL,
4889 | [Subtitle =>] STRING_LITERAL
4890 @end smallexample
4892 @noindent
4893 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4894 pragma used in DEC Ada 83 implementations to provide a title and/or
4895 subtitle for the program listing.  The program listing generated by GNAT
4896 does not have titles or subtitles.
4898 Unlike other pragmas, the full flexibility of named notation is allowed
4899 for this pragma, i.e.@: the parameters may be given in any order if named
4900 notation is used, and named and positional notation can be mixed
4901 following the normal rules for procedure calls in Ada.
4903 @node Pragma Unchecked_Union
4904 @unnumberedsec Pragma Unchecked_Union
4905 @cindex Unions in C
4906 @findex Unchecked_Union
4907 @noindent
4908 Syntax:
4910 @smallexample @c ada
4911 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4912 @end smallexample
4914 @noindent
4915 This pragma is used to specify a representation of a record type that is
4916 equivalent to a C union. It was introduced as a GNAT implementation defined
4917 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4918 pragma, making it language defined, and GNAT fully implements this extended
4919 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4920 details, consult the Ada 2005 Reference Manual, section B.3.3.
4922 @node Pragma Unimplemented_Unit
4923 @unnumberedsec Pragma Unimplemented_Unit
4924 @findex Unimplemented_Unit
4925 @noindent
4926 Syntax:
4928 @smallexample @c ada
4929 pragma Unimplemented_Unit;
4930 @end smallexample
4932 @noindent
4933 If this pragma occurs in a unit that is processed by the compiler, GNAT
4934 aborts with the message @samp{@var{xxx} not implemented}, where
4935 @var{xxx} is the name of the current compilation unit.  This pragma is
4936 intended to allow the compiler to handle unimplemented library units in
4937 a clean manner.
4939 The abort only happens if code is being generated.  Thus you can use
4940 specs of unimplemented packages in syntax or semantic checking mode.
4942 @node Pragma Universal_Aliasing
4943 @unnumberedsec Pragma Universal_Aliasing
4944 @findex Universal_Aliasing
4945 @noindent
4946 Syntax:
4948 @smallexample @c ada
4949 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4950 @end smallexample
4952 @noindent
4953 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4954 declarative part.  The effect is to inhibit strict type-based aliasing
4955 optimization for the given type.  In other words, the effect is as though
4956 access types designating this type were subject to pragma No_Strict_Aliasing.
4957 For a detailed description of the strict aliasing optimization, and the
4958 situations in which it must be suppressed, @xref{Optimization and Strict
4959 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4961 @node Pragma Universal_Data
4962 @unnumberedsec Pragma Universal_Data
4963 @findex Universal_Data
4964 @noindent
4965 Syntax:
4967 @smallexample @c ada
4968 pragma Universal_Data [(library_unit_Name)];
4969 @end smallexample
4971 @noindent
4972 This pragma is supported only for the AAMP target and is ignored for
4973 other targets. The pragma specifies that all library-level objects
4974 (Counter 0 data) associated with the library unit are to be accessed
4975 and updated using universal addressing (24-bit addresses for AAMP5)
4976 rather than the default of 16-bit Data Environment (DENV) addressing.
4977 Use of this pragma will generally result in less efficient code for
4978 references to global data associated with the library unit, but
4979 allows such data to be located anywhere in memory. This pragma is
4980 a library unit pragma, but can also be used as a configuration pragma
4981 (including use in the @file{gnat.adc} file). The functionality
4982 of this pragma is also available by applying the -univ switch on the
4983 compilations of units where universal addressing of the data is desired.
4985 @node Pragma Unmodified
4986 @unnumberedsec Pragma Unmodified
4987 @findex Unmodified
4988 @cindex Warnings, unmodified
4989 @noindent
4990 Syntax:
4992 @smallexample @c ada
4993 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4994 @end smallexample
4996 @noindent
4997 This pragma signals that the assignable entities (variables,
4998 @code{out} parameters, @code{in out} parameters) whose names are listed are
4999 deliberately not assigned in the current source unit. This
5000 suppresses warnings about the
5001 entities being referenced but not assigned, and in addition a warning will be
5002 generated if one of these entities is in fact assigned in the
5003 same unit as the pragma (or in the corresponding body, or one
5004 of its subunits).
5006 This is particularly useful for clearly signaling that a particular
5007 parameter is not modified, even though the spec suggests that it might
5010 @node Pragma Unreferenced
5011 @unnumberedsec Pragma Unreferenced
5012 @findex Unreferenced
5013 @cindex Warnings, unreferenced
5014 @noindent
5015 Syntax:
5017 @smallexample @c ada
5018 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5019 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5020 @end smallexample
5022 @noindent
5023 This pragma signals that the entities whose names are listed are
5024 deliberately not referenced in the current source unit. This
5025 suppresses warnings about the
5026 entities being unreferenced, and in addition a warning will be
5027 generated if one of these entities is in fact referenced in the
5028 same unit as the pragma (or in the corresponding body, or one
5029 of its subunits).
5031 This is particularly useful for clearly signaling that a particular
5032 parameter is not referenced in some particular subprogram implementation
5033 and that this is deliberate. It can also be useful in the case of
5034 objects declared only for their initialization or finalization side
5035 effects.
5037 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5038 current scope, then the entity most recently declared is the one to which
5039 the pragma applies. Note that in the case of accept formals, the pragma
5040 Unreferenced may appear immediately after the keyword @code{do} which
5041 allows the indication of whether or not accept formals are referenced
5042 or not to be given individually for each accept statement.
5044 The left hand side of an assignment does not count as a reference for the
5045 purpose of this pragma. Thus it is fine to assign to an entity for which
5046 pragma Unreferenced is given.
5048 Note that if a warning is desired for all calls to a given subprogram,
5049 regardless of whether they occur in the same unit as the subprogram
5050 declaration, then this pragma should not be used (calls from another
5051 unit would not be flagged); pragma Obsolescent can be used instead
5052 for this purpose, see @xref{Pragma Obsolescent}.
5054 The second form of pragma @code{Unreferenced} is used within a context
5055 clause. In this case the arguments must be unit names of units previously
5056 mentioned in @code{with} clauses (similar to the usage of pragma
5057 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5058 units and unreferenced entities within these units.
5060 @node Pragma Unreferenced_Objects
5061 @unnumberedsec Pragma Unreferenced_Objects
5062 @findex Unreferenced_Objects
5063 @cindex Warnings, unreferenced
5064 @noindent
5065 Syntax:
5067 @smallexample @c ada
5068 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5069 @end smallexample
5071 @noindent
5072 This pragma signals that for the types or subtypes whose names are
5073 listed, objects which are declared with one of these types or subtypes may
5074 not be referenced, and if no references appear, no warnings are given.
5076 This is particularly useful for objects which are declared solely for their
5077 initialization and finalization effect. Such variables are sometimes referred
5078 to as RAII variables (Resource Acquisition Is Initialization). Using this
5079 pragma on the relevant type (most typically a limited controlled type), the
5080 compiler will automatically suppress unwanted warnings about these variables
5081 not being referenced.
5083 @node Pragma Unreserve_All_Interrupts
5084 @unnumberedsec Pragma Unreserve_All_Interrupts
5085 @findex Unreserve_All_Interrupts
5086 @noindent
5087 Syntax:
5089 @smallexample @c ada
5090 pragma Unreserve_All_Interrupts;
5091 @end smallexample
5093 @noindent
5094 Normally certain interrupts are reserved to the implementation.  Any attempt
5095 to attach an interrupt causes Program_Error to be raised, as described in
5096 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5097 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5098 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5099 interrupt execution.
5101 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5102 a program, then all such interrupts are unreserved.  This allows the
5103 program to handle these interrupts, but disables their standard
5104 functions.  For example, if this pragma is used, then pressing
5105 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
5106 a program can then handle the @code{SIGINT} interrupt as it chooses.
5108 For a full list of the interrupts handled in a specific implementation,
5109 see the source code for the spec of @code{Ada.Interrupts.Names} in
5110 file @file{a-intnam.ads}.  This is a target dependent file that contains the
5111 list of interrupts recognized for a given target.  The documentation in
5112 this file also specifies what interrupts are affected by the use of
5113 the @code{Unreserve_All_Interrupts} pragma.
5115 For a more general facility for controlling what interrupts can be
5116 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5117 of the @code{Unreserve_All_Interrupts} pragma.
5119 @node Pragma Unsuppress
5120 @unnumberedsec Pragma Unsuppress
5121 @findex Unsuppress
5122 @noindent
5123 Syntax:
5125 @smallexample @c ada
5126 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5127 @end smallexample
5129 @noindent
5130 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5131 there is no corresponding pragma @code{Suppress} in effect, it has no
5132 effect.  The range of the effect is the same as for pragma
5133 @code{Suppress}.  The meaning of the arguments is identical to that used
5134 in pragma @code{Suppress}.
5136 One important application is to ensure that checks are on in cases where
5137 code depends on the checks for its correct functioning, so that the code
5138 will compile correctly even if the compiler switches are set to suppress
5139 checks.
5141 @node Pragma Use_VADS_Size
5142 @unnumberedsec Pragma Use_VADS_Size
5143 @cindex @code{Size}, VADS compatibility
5144 @findex Use_VADS_Size
5145 @noindent
5146 Syntax:
5148 @smallexample @c ada
5149 pragma Use_VADS_Size;
5150 @end smallexample
5152 @noindent
5153 This is a configuration pragma.  In a unit to which it applies, any use
5154 of the 'Size attribute is automatically interpreted as a use of the
5155 'VADS_Size attribute.  Note that this may result in incorrect semantic
5156 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5157 the handling of existing code which depends on the interpretation of Size
5158 as implemented in the VADS compiler.  See description of the VADS_Size
5159 attribute for further details.
5161 @node Pragma Validity_Checks
5162 @unnumberedsec Pragma Validity_Checks
5163 @findex Validity_Checks
5164 @noindent
5165 Syntax:
5167 @smallexample @c ada
5168 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5169 @end smallexample
5171 @noindent
5172 This pragma is used in conjunction with compiler switches to control the
5173 built-in validity checking provided by GNAT@.  The compiler switches, if set
5174 provide an initial setting for the switches, and this pragma may be used
5175 to modify these settings, or the settings may be provided entirely by
5176 the use of the pragma.  This pragma can be used anywhere that a pragma
5177 is legal, including use as a configuration pragma (including use in
5178 the @file{gnat.adc} file).
5180 The form with a string literal specifies which validity options are to be
5181 activated.  The validity checks are first set to include only the default
5182 reference manual settings, and then a string of letters in the string
5183 specifies the exact set of options required.  The form of this string
5184 is exactly as described for the @option{-gnatVx} compiler switch (see the
5185 GNAT users guide for details).  For example the following two methods
5186 can be used to enable validity checking for mode @code{in} and
5187 @code{in out} subprogram parameters:
5189 @itemize @bullet
5190 @item
5191 @smallexample @c ada
5192 pragma Validity_Checks ("im");
5193 @end smallexample
5195 @item
5196 @smallexample
5197 gcc -c -gnatVim @dots{}
5198 @end smallexample
5199 @end itemize
5201 @noindent
5202 The form ALL_CHECKS activates all standard checks (its use is equivalent
5203 to the use of the @code{gnatva} switch.
5205 The forms with @code{Off} and @code{On}
5206 can be used to temporarily disable validity checks
5207 as shown in the following example:
5209 @smallexample @c ada
5210 @iftex
5211 @leftskip=0cm
5212 @end iftex
5213 pragma Validity_Checks ("c"); -- validity checks for copies
5214 pragma Validity_Checks (Off); -- turn off validity checks
5215 A := B;                       -- B will not be validity checked
5216 pragma Validity_Checks (On);  -- turn validity checks back on
5217 A := C;                       -- C will be validity checked
5218 @end smallexample
5220 @node Pragma Volatile
5221 @unnumberedsec Pragma Volatile
5222 @findex Volatile
5223 @noindent
5224 Syntax:
5226 @smallexample @c ada
5227 pragma Volatile (LOCAL_NAME);
5228 @end smallexample
5230 @noindent
5231 This pragma is defined by the Ada Reference Manual, and the GNAT
5232 implementation is fully conformant with this definition.  The reason it
5233 is mentioned in this section is that a pragma of the same name was supplied
5234 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5235 implementation of pragma Volatile is upwards compatible with the
5236 implementation in DEC Ada 83.
5238 @node Pragma Warnings
5239 @unnumberedsec Pragma Warnings
5240 @findex Warnings
5241 @noindent
5242 Syntax:
5244 @smallexample @c ada
5245 pragma Warnings (On | Off);
5246 pragma Warnings (On | Off, LOCAL_NAME);
5247 pragma Warnings (static_string_EXPRESSION);
5248 pragma Warnings (On | Off, static_string_EXPRESSION);
5249 @end smallexample
5251 @noindent
5252 Normally warnings are enabled, with the output being controlled by
5253 the command line switch.  Warnings (@code{Off}) turns off generation of
5254 warnings until a Warnings (@code{On}) is encountered or the end of the
5255 current unit.  If generation of warnings is turned off using this
5256 pragma, then no warning messages are output, regardless of the
5257 setting of the command line switches.
5259 The form with a single argument may be used as a configuration pragma.
5261 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5262 the specified entity.  This suppression is effective from the point where
5263 it occurs till the end of the extended scope of the variable (similar to
5264 the scope of @code{Suppress}).
5266 The form with a single static_string_EXPRESSION argument provides more precise
5267 control over which warnings are active. The string is a list of letters
5268 specifying which warnings are to be activated and which deactivated. The
5269 code for these letters is the same as the string used in the command
5270 line switch controlling warnings. For a brief summary, use the gnatmake
5271 command with no arguments, which will generate usage information containing
5272 the list of warnings switches supported. For
5273 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5274 User's Guide}.
5276 @noindent
5277 The specified warnings will be in effect until the end of the program
5278 or another pragma Warnings is encountered. The effect of the pragma is
5279 cumulative. Initially the set of warnings is the standard default set
5280 as possibly modified by compiler switches. Then each pragma Warning
5281 modifies this set of warnings as specified. This form of the pragma may
5282 also be used as a configuration pragma.
5284 The fourth form, with an On|Off parameter and a string, is used to
5285 control individual messages, based on their text. The string argument
5286 is a pattern that is used to match against the text of individual
5287 warning messages (not including the initial "warning: " tag).
5289 The pattern may contain asterisks, which match zero or more characters in
5290 the message. For example, you can use
5291 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5292 message @code{warning: 960 bits of "a" unused}. No other regular
5293 expression notations are permitted. All characters other than asterisk in
5294 these three specific cases are treated as literal characters in the match.
5296 There are two ways to use this pragma. The OFF form can be used as a
5297 configuration pragma. The effect is to suppress all warnings (if any)
5298 that match the pattern string throughout the compilation.
5300 The second usage is to suppress a warning locally, and in this case, two
5301 pragmas must appear in sequence:
5303 @smallexample @c ada
5304 pragma Warnings (Off, Pattern);
5305 @dots{} code where given warning is to be suppressed
5306 pragma Warnings (On, Pattern);
5307 @end smallexample
5309 @noindent
5310 In this usage, the pattern string must match in the Off and On pragmas,
5311 and at least one matching warning must be suppressed.
5313 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5314 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5315 be useful in checking whether obsolete pragmas in existing programs are hiding
5316 real problems.
5318 Note: pragma Warnings does not affect the processing of style messages. See
5319 separate entry for pragma Style_Checks for control of style messages.
5321 @node Pragma Weak_External
5322 @unnumberedsec Pragma Weak_External
5323 @findex Weak_External
5324 @noindent
5325 Syntax:
5327 @smallexample @c ada
5328 pragma Weak_External ([Entity =>] LOCAL_NAME);
5329 @end smallexample
5331 @noindent
5332 @var{LOCAL_NAME} must refer to an object that is declared at the library
5333 level. This pragma specifies that the given entity should be marked as a
5334 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5335 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5336 of a regular symbol, that is to say a symbol that does not have to be
5337 resolved by the linker if used in conjunction with a pragma Import.
5339 When a weak symbol is not resolved by the linker, its address is set to
5340 zero. This is useful in writing interfaces to external modules that may
5341 or may not be linked in the final executable, for example depending on
5342 configuration settings.
5344 If a program references at run time an entity to which this pragma has been
5345 applied, and the corresponding symbol was not resolved at link time, then
5346 the execution of the program is erroneous. It is not erroneous to take the
5347 Address of such an entity, for example to guard potential references,
5348 as shown in the example below.
5350 Some file formats do not support weak symbols so not all target machines
5351 support this pragma.
5353 @smallexample @c ada
5354 --  Example of the use of pragma Weak_External
5356 package External_Module is
5357   key : Integer;
5358   pragma Import (C, key);
5359   pragma Weak_External (key);
5360   function Present return boolean;
5361 end External_Module;
5363 with System; use System;
5364 package body External_Module is
5365   function Present return boolean is
5366   begin
5367     return key'Address /= System.Null_Address;
5368   end Present;
5369 end External_Module;
5370 @end smallexample
5372 @node Pragma Wide_Character_Encoding
5373 @unnumberedsec Pragma Wide_Character_Encoding
5374 @findex Wide_Character_Encoding
5375 @noindent
5376 Syntax:
5378 @smallexample @c ada
5379 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5380 @end smallexample
5382 @noindent
5383 This pragma specifies the wide character encoding to be used in program
5384 source text appearing subsequently. It is a configuration pragma, but may
5385 also be used at any point that a pragma is allowed, and it is permissible
5386 to have more than one such pragma in a file, allowing multiple encodings
5387 to appear within the same file.
5389 The argument can be an identifier or a character literal. In the identifier
5390 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5391 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5392 case it is correspondingly one of the characters @samp{h}, @samp{u},
5393 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5395 Note that when the pragma is used within a file, it affects only the
5396 encoding within that file, and does not affect withed units, specs,
5397 or subunits.
5399 @node Implementation Defined Attributes
5400 @chapter Implementation Defined Attributes
5401 Ada defines (throughout the Ada reference manual,
5402 summarized in Annex K),
5403 a set of attributes that provide useful additional functionality in all
5404 areas of the language.  These language defined attributes are implemented
5405 in GNAT and work as described in the Ada Reference Manual.
5407 In addition, Ada allows implementations to define additional
5408 attributes whose meaning is defined by the implementation.  GNAT provides
5409 a number of these implementation-dependent attributes which can be used
5410 to extend and enhance the functionality of the compiler.  This section of
5411 the GNAT reference manual describes these additional attributes.
5413 Note that any program using these attributes may not be portable to
5414 other compilers (although GNAT implements this set of attributes on all
5415 platforms).  Therefore if portability to other compilers is an important
5416 consideration, you should minimize the use of these attributes.
5418 @menu
5419 * Abort_Signal::
5420 * Address_Size::
5421 * Asm_Input::
5422 * Asm_Output::
5423 * AST_Entry::
5424 * Bit::
5425 * Bit_Position::
5426 * Compiler_Version::
5427 * Code_Address::
5428 * Default_Bit_Order::
5429 * Elaborated::
5430 * Elab_Body::
5431 * Elab_Spec::
5432 * Emax::
5433 * Enabled::
5434 * Enum_Rep::
5435 * Enum_Val::
5436 * Epsilon::
5437 * Fixed_Value::
5438 * Has_Access_Values::
5439 * Has_Discriminants::
5440 * Img::
5441 * Integer_Value::
5442 * Invalid_Value::
5443 * Large::
5444 * Machine_Size::
5445 * Mantissa::
5446 * Max_Interrupt_Priority::
5447 * Max_Priority::
5448 * Maximum_Alignment::
5449 * Mechanism_Code::
5450 * Null_Parameter::
5451 * Object_Size::
5452 * Old::
5453 * Passed_By_Reference::
5454 * Pool_Address::
5455 * Range_Length::
5456 * Result::
5457 * Safe_Emax::
5458 * Safe_Large::
5459 * Small::
5460 * Storage_Unit::
5461 * Stub_Type::
5462 * Target_Name::
5463 * Tick::
5464 * To_Address::
5465 * Type_Class::
5466 * UET_Address::
5467 * Unconstrained_Array::
5468 * Universal_Literal_String::
5469 * Unrestricted_Access::
5470 * VADS_Size::
5471 * Value_Size::
5472 * Wchar_T_Size::
5473 * Word_Size::
5474 @end menu
5476 @node Abort_Signal
5477 @unnumberedsec Abort_Signal
5478 @findex Abort_Signal
5479 @noindent
5480 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5481 prefix) provides the entity for the special exception used to signal
5482 task abort or asynchronous transfer of control.  Normally this attribute
5483 should only be used in the tasking runtime (it is highly peculiar, and
5484 completely outside the normal semantics of Ada, for a user program to
5485 intercept the abort exception).
5487 @node Address_Size
5488 @unnumberedsec Address_Size
5489 @cindex Size of @code{Address}
5490 @findex Address_Size
5491 @noindent
5492 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5493 prefix) is a static constant giving the number of bits in an
5494 @code{Address}. It is the same value as System.Address'Size,
5495 but has the advantage of being static, while a direct
5496 reference to System.Address'Size is non-static because Address
5497 is a private type.
5499 @node Asm_Input
5500 @unnumberedsec Asm_Input
5501 @findex Asm_Input
5502 @noindent
5503 The @code{Asm_Input} attribute denotes a function that takes two
5504 parameters.  The first is a string, the second is an expression of the
5505 type designated by the prefix.  The first (string) argument is required
5506 to be a static expression, and is the constraint for the parameter,
5507 (e.g.@: what kind of register is required).  The second argument is the
5508 value to be used as the input argument.  The possible values for the
5509 constant are the same as those used in the RTL, and are dependent on
5510 the configuration file used to built the GCC back end.
5511 @ref{Machine Code Insertions}
5513 @node Asm_Output
5514 @unnumberedsec Asm_Output
5515 @findex Asm_Output
5516 @noindent
5517 The @code{Asm_Output} attribute denotes a function that takes two
5518 parameters.  The first is a string, the second is the name of a variable
5519 of the type designated by the attribute prefix.  The first (string)
5520 argument is required to be a static expression and designates the
5521 constraint for the parameter (e.g.@: what kind of register is
5522 required).  The second argument is the variable to be updated with the
5523 result.  The possible values for constraint are the same as those used in
5524 the RTL, and are dependent on the configuration file used to build the
5525 GCC back end.  If there are no output operands, then this argument may
5526 either be omitted, or explicitly given as @code{No_Output_Operands}.
5527 @ref{Machine Code Insertions}
5529 @node AST_Entry
5530 @unnumberedsec AST_Entry
5531 @cindex OpenVMS
5532 @findex AST_Entry
5533 @noindent
5534 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5535 the name of an entry, it yields a value of the predefined type AST_Handler
5536 (declared in the predefined package System, as extended by the use of
5537 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5538 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5539 Language Reference Manual}, section 9.12a.
5541 @node Bit
5542 @unnumberedsec Bit
5543 @findex Bit
5544 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5545 offset within the storage unit (byte) that contains the first bit of
5546 storage allocated for the object.  The value of this attribute is of the
5547 type @code{Universal_Integer}, and is always a non-negative number not
5548 exceeding the value of @code{System.Storage_Unit}.
5550 For an object that is a variable or a constant allocated in a register,
5551 the value is zero.  (The use of this attribute does not force the
5552 allocation of a variable to memory).
5554 For an object that is a formal parameter, this attribute applies
5555 to either the matching actual parameter or to a copy of the
5556 matching actual parameter.
5558 For an access object the value is zero.  Note that
5559 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5560 designated object.  Similarly for a record component
5561 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5562 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5563 are subject to index checks.
5565 This attribute is designed to be compatible with the DEC Ada 83 definition
5566 and implementation of the @code{Bit} attribute.
5568 @node Bit_Position
5569 @unnumberedsec Bit_Position
5570 @findex Bit_Position
5571 @noindent
5572 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5573 of the fields of the record type, yields the bit
5574 offset within the record contains the first bit of
5575 storage allocated for the object.  The value of this attribute is of the
5576 type @code{Universal_Integer}.  The value depends only on the field
5577 @var{C} and is independent of the alignment of
5578 the containing record @var{R}.
5580 @node Compiler_Version
5581 @unnumberedsec Compiler_Version
5582 @findex Compiler_Version
5583 @noindent
5584 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5585 prefix) yields a static string identifying the version of the compiler
5586 being used to compile the unit containing the attribute reference. A
5587 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5589 @node Code_Address
5590 @unnumberedsec Code_Address
5591 @findex Code_Address
5592 @cindex Subprogram address
5593 @cindex Address of subprogram code
5594 @noindent
5595 The @code{'Address}
5596 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5597 intended effect seems to be to provide
5598 an address value which can be used to call the subprogram by means of
5599 an address clause as in the following example:
5601 @smallexample @c ada
5602 procedure K is @dots{}
5604 procedure L;
5605 for L'Address use K'Address;
5606 pragma Import (Ada, L);
5607 @end smallexample
5609 @noindent
5610 A call to @code{L} is then expected to result in a call to @code{K}@.
5611 In Ada 83, where there were no access-to-subprogram values, this was
5612 a common work-around for getting the effect of an indirect call.
5613 GNAT implements the above use of @code{Address} and the technique
5614 illustrated by the example code works correctly.
5616 However, for some purposes, it is useful to have the address of the start
5617 of the generated code for the subprogram.  On some architectures, this is
5618 not necessarily the same as the @code{Address} value described above.
5619 For example, the @code{Address} value may reference a subprogram
5620 descriptor rather than the subprogram itself.
5622 The @code{'Code_Address} attribute, which can only be applied to
5623 subprogram entities, always returns the address of the start of the
5624 generated code of the specified subprogram, which may or may not be
5625 the same value as is returned by the corresponding @code{'Address}
5626 attribute.
5628 @node Default_Bit_Order
5629 @unnumberedsec Default_Bit_Order
5630 @cindex Big endian
5631 @cindex Little endian
5632 @findex Default_Bit_Order
5633 @noindent
5634 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5635 permissible prefix), provides the value @code{System.Default_Bit_Order}
5636 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5637 @code{Low_Order_First}).  This is used to construct the definition of
5638 @code{Default_Bit_Order} in package @code{System}.
5640 @node Elaborated
5641 @unnumberedsec Elaborated
5642 @findex Elaborated
5643 @noindent
5644 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5645 value is a Boolean which indicates whether or not the given unit has been
5646 elaborated.  This attribute is primarily intended for internal use by the
5647 generated code for dynamic elaboration checking, but it can also be used
5648 in user programs.  The value will always be True once elaboration of all
5649 units has been completed.  An exception is for units which need no
5650 elaboration, the value is always False for such units.
5652 @node Elab_Body
5653 @unnumberedsec Elab_Body
5654 @findex Elab_Body
5655 @noindent
5656 This attribute can only be applied to a program unit name.  It returns
5657 the entity for the corresponding elaboration procedure for elaborating
5658 the body of the referenced unit.  This is used in the main generated
5659 elaboration procedure by the binder and is not normally used in any
5660 other context.  However, there may be specialized situations in which it
5661 is useful to be able to call this elaboration procedure from Ada code,
5662 e.g.@: if it is necessary to do selective re-elaboration to fix some
5663 error.
5665 @node Elab_Spec
5666 @unnumberedsec Elab_Spec
5667 @findex Elab_Spec
5668 @noindent
5669 This attribute can only be applied to a program unit name.  It returns
5670 the entity for the corresponding elaboration procedure for elaborating
5671 the spec of the referenced unit.  This is used in the main
5672 generated elaboration procedure by the binder and is not normally used
5673 in any other context.  However, there may be specialized situations in
5674 which it is useful to be able to call this elaboration procedure from
5675 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5676 some error.
5678 @node Emax
5679 @unnumberedsec Emax
5680 @cindex Ada 83 attributes
5681 @findex Emax
5682 @noindent
5683 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5684 the Ada 83 reference manual for an exact description of the semantics of
5685 this attribute.
5687 @node Enabled
5688 @unnumberedsec Enabled
5689 @findex Enabled
5690 @noindent
5691 The @code{Enabled} attribute allows an application program to check at compile
5692 time to see if the designated check is currently enabled. The prefix is a
5693 simple identifier, referencing any predefined check name (other than
5694 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5695 no argument is given for the attribute, the check is for the general state
5696 of the check, if an argument is given, then it is an entity name, and the
5697 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5698 given naming the entity (if not, then the argument is ignored).
5700 Note that instantiations inherit the check status at the point of the
5701 instantiation, so a useful idiom is to have a library package that
5702 introduces a check name with @code{pragma Check_Name}, and then contains
5703 generic packages or subprograms which use the @code{Enabled} attribute
5704 to see if the check is enabled. A user of this package can then issue
5705 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5706 the package or subprogram, controlling whether the check will be present.
5708 @node Enum_Rep
5709 @unnumberedsec Enum_Rep
5710 @cindex Representation of enums
5711 @findex Enum_Rep
5712 @noindent
5713 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5714 function with the following spec:
5716 @smallexample @c ada
5717 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5718   return @i{Universal_Integer};
5719 @end smallexample
5721 @noindent
5722 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5723 enumeration type or to a non-overloaded enumeration
5724 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5725 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5726 enumeration literal or object.
5728 The function returns the representation value for the given enumeration
5729 value.  This will be equal to value of the @code{Pos} attribute in the
5730 absence of an enumeration representation clause.  This is a static
5731 attribute (i.e.@: the result is static if the argument is static).
5733 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5734 in which case it simply returns the integer value.  The reason for this
5735 is to allow it to be used for @code{(<>)} discrete formal arguments in
5736 a generic unit that can be instantiated with either enumeration types
5737 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5738 type whose upper bound exceeds the upper bound of the largest signed
5739 integer type, and the argument is a variable, so that the universal
5740 integer calculation is done at run time, then the call to @code{Enum_Rep}
5741 may raise @code{Constraint_Error}.
5743 @node Enum_Val
5744 @unnumberedsec Enum_Val
5745 @cindex Representation of enums
5746 @findex Enum_Val
5747 @noindent
5748 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5749 function with the following spec:
5751 @smallexample @c ada
5752 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5753   return @var{S}'Base};
5754 @end smallexample
5756 @noindent
5757 The function returns the enumeration value whose representation matches the
5758 argument, or raises Constraint_Error if no enumeration literal of the type
5759 has the matching value.
5760 This will be equal to value of the @code{Val} attribute in the
5761 absence of an enumeration representation clause.  This is a static
5762 attribute (i.e.@: the result is static if the argument is static).
5764 @node Epsilon
5765 @unnumberedsec Epsilon
5766 @cindex Ada 83 attributes
5767 @findex Epsilon
5768 @noindent
5769 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5770 the Ada 83 reference manual for an exact description of the semantics of
5771 this attribute.
5773 @node Fixed_Value
5774 @unnumberedsec Fixed_Value
5775 @findex Fixed_Value
5776 @noindent
5777 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5778 function with the following specification:
5780 @smallexample @c ada
5781 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5782   return @var{S};
5783 @end smallexample
5785 @noindent
5786 The value returned is the fixed-point value @var{V} such that
5788 @smallexample @c ada
5789 @var{V} = Arg * @var{S}'Small
5790 @end smallexample
5792 @noindent
5793 The effect is thus similar to first converting the argument to the
5794 integer type used to represent @var{S}, and then doing an unchecked
5795 conversion to the fixed-point type.  The difference is
5796 that there are full range checks, to ensure that the result is in range.
5797 This attribute is primarily intended for use in implementation of the
5798 input-output functions for fixed-point values.
5800 @node Has_Access_Values
5801 @unnumberedsec Has_Access_Values
5802 @cindex Access values, testing for
5803 @findex Has_Access_Values
5804 @noindent
5805 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5806 is a Boolean value which is True if the is an access type, or is a composite
5807 type with a component (at any nesting depth) that is an access type, and is
5808 False otherwise.
5809 The intended use of this attribute is in conjunction with generic
5810 definitions.  If the attribute is applied to a generic private type, it
5811 indicates whether or not the corresponding actual type has access values.
5813 @node Has_Discriminants
5814 @unnumberedsec Has_Discriminants
5815 @cindex Discriminants, testing for
5816 @findex Has_Discriminants
5817 @noindent
5818 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5819 is a Boolean value which is True if the type has discriminants, and False
5820 otherwise.  The intended use of this attribute is in conjunction with generic
5821 definitions.  If the attribute is applied to a generic private type, it
5822 indicates whether or not the corresponding actual type has discriminants.
5824 @node Img
5825 @unnumberedsec Img
5826 @findex Img
5827 @noindent
5828 The @code{Img} attribute differs from @code{Image} in that it may be
5829 applied to objects as well as types, in which case it gives the
5830 @code{Image} for the subtype of the object.  This is convenient for
5831 debugging:
5833 @smallexample @c ada
5834 Put_Line ("X = " & X'Img);
5835 @end smallexample
5837 @noindent
5838 has the same meaning as the more verbose:
5840 @smallexample @c ada
5841 Put_Line ("X = " & @var{T}'Image (X));
5842 @end smallexample
5844 @noindent
5845 where @var{T} is the (sub)type of the object @code{X}.
5847 @node Integer_Value
5848 @unnumberedsec Integer_Value
5849 @findex Integer_Value
5850 @noindent
5851 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5852 function with the following spec:
5854 @smallexample @c ada
5855 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5856   return @var{S};
5857 @end smallexample
5859 @noindent
5860 The value returned is the integer value @var{V}, such that
5862 @smallexample @c ada
5863 Arg = @var{V} * @var{T}'Small
5864 @end smallexample
5866 @noindent
5867 where @var{T} is the type of @code{Arg}.
5868 The effect is thus similar to first doing an unchecked conversion from
5869 the fixed-point type to its corresponding implementation type, and then
5870 converting the result to the target integer type.  The difference is
5871 that there are full range checks, to ensure that the result is in range.
5872 This attribute is primarily intended for use in implementation of the
5873 standard input-output functions for fixed-point values.
5875 @node Invalid_Value
5876 @unnumberedsec Invalid_Value
5877 @findex Invalid_Value
5878 @noindent
5879 For every scalar type S, S'Invalid_Value returns an undefined value of the
5880 type. If possible this value is an invalid representation for the type. The
5881 value returned is identical to the value used to initialize an otherwise
5882 uninitialized value of the type if pragma Initialize_Scalars is used,
5883 including the ability to modify the value with the binder -Sxx flag and
5884 relevant environment variables at run time.
5886 @node Large
5887 @unnumberedsec Large
5888 @cindex Ada 83 attributes
5889 @findex Large
5890 @noindent
5891 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5892 the Ada 83 reference manual for an exact description of the semantics of
5893 this attribute.
5895 @node Machine_Size
5896 @unnumberedsec Machine_Size
5897 @findex Machine_Size
5898 @noindent
5899 This attribute is identical to the @code{Object_Size} attribute.  It is
5900 provided for compatibility with the DEC Ada 83 attribute of this name.
5902 @node Mantissa
5903 @unnumberedsec Mantissa
5904 @cindex Ada 83 attributes
5905 @findex Mantissa
5906 @noindent
5907 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5908 the Ada 83 reference manual for an exact description of the semantics of
5909 this attribute.
5911 @node Max_Interrupt_Priority
5912 @unnumberedsec Max_Interrupt_Priority
5913 @cindex Interrupt priority, maximum
5914 @findex Max_Interrupt_Priority
5915 @noindent
5916 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5917 permissible prefix), provides the same value as
5918 @code{System.Max_Interrupt_Priority}.
5920 @node Max_Priority
5921 @unnumberedsec Max_Priority
5922 @cindex Priority, maximum
5923 @findex Max_Priority
5924 @noindent
5925 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5926 prefix) provides the same value as @code{System.Max_Priority}.
5928 @node Maximum_Alignment
5929 @unnumberedsec Maximum_Alignment
5930 @cindex Alignment, maximum
5931 @findex Maximum_Alignment
5932 @noindent
5933 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5934 permissible prefix) provides the maximum useful alignment value for the
5935 target.  This is a static value that can be used to specify the alignment
5936 for an object, guaranteeing that it is properly aligned in all
5937 cases.
5939 @node Mechanism_Code
5940 @unnumberedsec Mechanism_Code
5941 @cindex Return values, passing mechanism
5942 @cindex Parameters, passing mechanism
5943 @findex Mechanism_Code
5944 @noindent
5945 @code{@var{function}'Mechanism_Code} yields an integer code for the
5946 mechanism used for the result of function, and
5947 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5948 used for formal parameter number @var{n} (a static integer value with 1
5949 meaning the first parameter) of @var{subprogram}.  The code returned is:
5951 @table @asis
5952 @item 1
5953 by copy (value)
5954 @item 2
5955 by reference
5956 @item 3
5957 by descriptor (default descriptor class)
5958 @item 4
5959 by descriptor (UBS: unaligned bit string)
5960 @item 5
5961 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5962 @item 6
5963 by descriptor (UBA: unaligned bit array)
5964 @item 7
5965 by descriptor (S: string, also scalar access type parameter)
5966 @item 8
5967 by descriptor (SB: string with arbitrary bounds)
5968 @item 9
5969 by descriptor (A: contiguous array)
5970 @item 10
5971 by descriptor (NCA: non-contiguous array)
5972 @end table
5974 @noindent
5975 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5976 @cindex OpenVMS
5978 @node Null_Parameter
5979 @unnumberedsec Null_Parameter
5980 @cindex Zero address, passing
5981 @findex Null_Parameter
5982 @noindent
5983 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5984 type or subtype @var{T} allocated at machine address zero.  The attribute
5985 is allowed only as the default expression of a formal parameter, or as
5986 an actual expression of a subprogram call.  In either case, the
5987 subprogram must be imported.
5989 The identity of the object is represented by the address zero in the
5990 argument list, independent of the passing mechanism (explicit or
5991 default).
5993 This capability is needed to specify that a zero address should be
5994 passed for a record or other composite object passed by reference.
5995 There is no way of indicating this without the @code{Null_Parameter}
5996 attribute.
5998 @node Object_Size
5999 @unnumberedsec Object_Size
6000 @cindex Size, used for objects
6001 @findex Object_Size
6002 @noindent
6003 The size of an object is not necessarily the same as the size of the type
6004 of an object.  This is because by default object sizes are increased to be
6005 a multiple of the alignment of the object.  For example,
6006 @code{Natural'Size} is
6007 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6008 Similarly, a record containing an integer and a character:
6010 @smallexample @c ada
6011 type Rec is record
6012    I : Integer;
6013    C : Character;
6014 end record;
6015 @end smallexample
6017 @noindent
6018 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
6019 alignment will be 4, because of the
6020 integer field, and so the default size of record objects for this type
6021 will be 64 (8 bytes).
6023 @node Old
6024 @unnumberedsec Old
6025 @cindex Capturing Old values
6026 @cindex Postconditions
6027 @noindent
6028 The attribute Prefix'Old can be used within a
6029 subprogram to refer to the value of the prefix on entry. So for
6030 example if you have an argument of a record type X called Arg1,
6031 you can refer to Arg1.Field'Old which yields the value of
6032 Arg1.Field on entry. The implementation simply involves generating
6033 an object declaration which captures the value on entry. Any
6034 prefix is allowed except one of a limited type (since limited
6035 types cannot be copied to capture their values) or a local variable
6036 (since it does not exist at subprogram entry time).
6038 The following example shows the use of 'Old to implement
6039 a test of a postcondition:
6041 @smallexample @c ada
6042 with Old_Pkg;
6043 procedure Old is
6044 begin
6045    Old_Pkg.Incr;
6046 end Old;
6048 package Old_Pkg is
6049    procedure Incr;
6050 end Old_Pkg;
6052 package body Old_Pkg is
6053    Count : Natural := 0;
6055    procedure Incr is
6056    begin
6057       ... code manipulating the value of Count
6059       pragma Assert (Count = Count'Old + 1);
6060    end Incr;
6061 end Old_Pkg;
6062 @end smallexample
6064 @noindent
6065 Note that it is allowed to apply 'Old to a constant entity, but this will
6066 result in a warning, since the old and new values will always be the same.
6068 @node Passed_By_Reference
6069 @unnumberedsec Passed_By_Reference
6070 @cindex Parameters, when passed by reference
6071 @findex Passed_By_Reference
6072 @noindent
6073 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6074 a value of type @code{Boolean} value that is @code{True} if the type is
6075 normally passed by reference and @code{False} if the type is normally
6076 passed by copy in calls.  For scalar types, the result is always @code{False}
6077 and is static.  For non-scalar types, the result is non-static.
6079 @node Pool_Address
6080 @unnumberedsec Pool_Address
6081 @cindex Parameters, when passed by reference
6082 @findex Pool_Address
6083 @noindent
6084 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6085 of X within its storage pool. This is the same as
6086 @code{@var{X}'Address}, except that for an unconstrained array whose
6087 bounds are allocated just before the first component,
6088 @code{@var{X}'Pool_Address} returns the address of those bounds,
6089 whereas @code{@var{X}'Address} returns the address of the first
6090 component.
6092 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6093 the object is allocated'', which could be a user-defined storage pool,
6094 the global heap, on the stack, or in a static memory area. For an
6095 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6096 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6098 @node Range_Length
6099 @unnumberedsec Range_Length
6100 @findex Range_Length
6101 @noindent
6102 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6103 the number of values represented by the subtype (zero for a null
6104 range).  The result is static for static subtypes.  @code{Range_Length}
6105 applied to the index subtype of a one dimensional array always gives the
6106 same result as @code{Range} applied to the array itself.
6108 @node Result
6109 @unnumberedsec Result
6110 @findex Result
6111 @noindent
6112 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6113 for a function. The prefix must be the name of the corresponding function. This
6114 is used to refer to the result of the function in the postcondition expression.
6115 For a further discussion of the use of this attribute and examples of its use,
6116 see the description of pragma Postcondition.
6118 @node Safe_Emax
6119 @unnumberedsec Safe_Emax
6120 @cindex Ada 83 attributes
6121 @findex Safe_Emax
6122 @noindent
6123 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6124 the Ada 83 reference manual for an exact description of the semantics of
6125 this attribute.
6127 @node Safe_Large
6128 @unnumberedsec Safe_Large
6129 @cindex Ada 83 attributes
6130 @findex Safe_Large
6131 @noindent
6132 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6133 the Ada 83 reference manual for an exact description of the semantics of
6134 this attribute.
6136 @node Small
6137 @unnumberedsec Small
6138 @cindex Ada 83 attributes
6139 @findex Small
6140 @noindent
6141 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6142 fixed-point types.
6143 GNAT also allows this attribute to be applied to floating-point types
6144 for compatibility with Ada 83.  See
6145 the Ada 83 reference manual for an exact description of the semantics of
6146 this attribute when applied to floating-point types.
6148 @node Storage_Unit
6149 @unnumberedsec Storage_Unit
6150 @findex Storage_Unit
6151 @noindent
6152 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6153 prefix) provides the same value as @code{System.Storage_Unit}.
6155 @node Stub_Type
6156 @unnumberedsec Stub_Type
6157 @findex Stub_Type
6158 @noindent
6159 The GNAT implementation of remote access-to-classwide types is
6160 organized as described in AARM section E.4 (20.t): a value of an RACW type
6161 (designating a remote object) is represented as a normal access
6162 value, pointing to a "stub" object which in turn contains the
6163 necessary information to contact the designated remote object. A
6164 call on any dispatching operation of such a stub object does the
6165 remote call, if necessary, using the information in the stub object
6166 to locate the target partition, etc.
6168 For a prefix @code{T} that denotes a remote access-to-classwide type,
6169 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6171 By construction, the layout of @code{T'Stub_Type} is identical to that of
6172 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6173 unit @code{System.Partition_Interface}. Use of this attribute will create
6174 an implicit dependency on this unit.
6176 @node Target_Name
6177 @unnumberedsec Target_Name
6178 @findex Target_Name
6179 @noindent
6180 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6181 prefix) provides a static string value that identifies the target
6182 for the current compilation. For GCC implementations, this is the
6183 standard gcc target name without the terminating slash (for
6184 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6186 @node Tick
6187 @unnumberedsec Tick
6188 @findex Tick
6189 @noindent
6190 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6191 provides the same value as @code{System.Tick},
6193 @node To_Address
6194 @unnumberedsec To_Address
6195 @findex To_Address
6196 @noindent
6197 The @code{System'To_Address}
6198 (@code{System} is the only permissible prefix)
6199 denotes a function identical to
6200 @code{System.Storage_Elements.To_Address} except that
6201 it is a static attribute.  This means that if its argument is
6202 a static expression, then the result of the attribute is a
6203 static expression.  The result is that such an expression can be
6204 used in contexts (e.g.@: preelaborable packages) which require a
6205 static expression and where the function call could not be used
6206 (since the function call is always non-static, even if its
6207 argument is static).
6209 @node Type_Class
6210 @unnumberedsec Type_Class
6211 @findex Type_Class
6212 @noindent
6213 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6214 the value of the type class for the full type of @var{type}.  If
6215 @var{type} is a generic formal type, the value is the value for the
6216 corresponding actual subtype.  The value of this attribute is of type
6217 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6219 @smallexample @c ada
6220   type Type_Class is
6221     (Type_Class_Enumeration,
6222      Type_Class_Integer,
6223      Type_Class_Fixed_Point,
6224      Type_Class_Floating_Point,
6225      Type_Class_Array,
6226      Type_Class_Record,
6227      Type_Class_Access,
6228      Type_Class_Task,
6229      Type_Class_Address);
6230 @end smallexample
6232 @noindent
6233 Protected types yield the value @code{Type_Class_Task}, which thus
6234 applies to all concurrent types.  This attribute is designed to
6235 be compatible with the DEC Ada 83 attribute of the same name.
6237 @node UET_Address
6238 @unnumberedsec UET_Address
6239 @findex UET_Address
6240 @noindent
6241 The @code{UET_Address} attribute can only be used for a prefix which
6242 denotes a library package.  It yields the address of the unit exception
6243 table when zero cost exception handling is used.  This attribute is
6244 intended only for use within the GNAT implementation.  See the unit
6245 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6246 for details on how this attribute is used in the implementation.
6248 @node Unconstrained_Array
6249 @unnumberedsec Unconstrained_Array
6250 @findex Unconstrained_Array
6251 @noindent
6252 The @code{Unconstrained_Array} attribute can be used with a prefix that
6253 denotes any type or subtype. It is a static attribute that yields
6254 @code{True} if the prefix designates an unconstrained array,
6255 and @code{False} otherwise. In a generic instance, the result is
6256 still static, and yields the result of applying this test to the
6257 generic actual.
6259 @node Universal_Literal_String
6260 @unnumberedsec Universal_Literal_String
6261 @cindex Named numbers, representation of
6262 @findex Universal_Literal_String
6263 @noindent
6264 The prefix of @code{Universal_Literal_String} must be a named
6265 number.  The static result is the string consisting of the characters of
6266 the number as defined in the original source.  This allows the user
6267 program to access the actual text of named numbers without intermediate
6268 conversions and without the need to enclose the strings in quotes (which
6269 would preclude their use as numbers).  This is used internally for the
6270 construction of values of the floating-point attributes from the file
6271 @file{ttypef.ads}, but may also be used by user programs.
6273 For example, the following program prints the first 50 digits of pi:
6275 @smallexample @c ada
6276 with Text_IO; use Text_IO;
6277 with Ada.Numerics;
6278 procedure Pi is
6279 begin
6280    Put (Ada.Numerics.Pi'Universal_Literal_String);
6281 end;
6282 @end smallexample
6284 @node Unrestricted_Access
6285 @unnumberedsec Unrestricted_Access
6286 @cindex @code{Access}, unrestricted
6287 @findex Unrestricted_Access
6288 @noindent
6289 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6290 except that all accessibility and aliased view checks are omitted.  This
6291 is a user-beware attribute.  It is similar to
6292 @code{Address}, for which it is a desirable replacement where the value
6293 desired is an access type.  In other words, its effect is identical to
6294 first applying the @code{Address} attribute and then doing an unchecked
6295 conversion to a desired access type.  In GNAT, but not necessarily in
6296 other implementations, the use of static chains for inner level
6297 subprograms means that @code{Unrestricted_Access} applied to a
6298 subprogram yields a value that can be called as long as the subprogram
6299 is in scope (normal Ada accessibility rules restrict this usage).
6301 It is possible to use @code{Unrestricted_Access} for any type, but care
6302 must be exercised if it is used to create pointers to unconstrained
6303 objects. In this case, the resulting pointer has the same scope as the
6304 context of the attribute, and may not be returned to some enclosing
6305 scope. For instance, a function cannot use @code{Unrestricted_Access}
6306 to create a unconstrained pointer and then return that value to the
6307 caller.
6309 @node VADS_Size
6310 @unnumberedsec VADS_Size
6311 @cindex @code{Size}, VADS compatibility
6312 @findex VADS_Size
6313 @noindent
6314 The @code{'VADS_Size} attribute is intended to make it easier to port
6315 legacy code which relies on the semantics of @code{'Size} as implemented
6316 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6317 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6318 to a predefined or other primitive type with no Size clause yields the
6319 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6320 typical machines).  In addition @code{'VADS_Size} applied to an object
6321 gives the result that would be obtained by applying the attribute to
6322 the corresponding type.
6324 @node Value_Size
6325 @unnumberedsec Value_Size
6326 @cindex @code{Size}, setting for not-first subtype
6327 @findex Value_Size
6328 @code{@var{type}'Value_Size} is the number of bits required to represent
6329 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6330 but, unlike @code{Size}, may be set for non-first subtypes.
6332 @node Wchar_T_Size
6333 @unnumberedsec Wchar_T_Size
6334 @findex Wchar_T_Size
6335 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6336 prefix) provides the size in bits of the C @code{wchar_t} type
6337 primarily for constructing the definition of this type in
6338 package @code{Interfaces.C}.
6340 @node Word_Size
6341 @unnumberedsec Word_Size
6342 @findex Word_Size
6343 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6344 prefix) provides the value @code{System.Word_Size}.
6346 @c ------------------------
6347 @node Implementation Advice
6348 @chapter Implementation Advice
6349 @noindent
6350 The main text of the Ada Reference Manual describes the required
6351 behavior of all Ada compilers, and the GNAT compiler conforms to
6352 these requirements.
6354 In addition, there are sections throughout the Ada Reference Manual headed
6355 by the phrase ``Implementation advice''.  These sections are not normative,
6356 i.e., they do not specify requirements that all compilers must
6357 follow.  Rather they provide advice on generally desirable behavior.  You
6358 may wonder why they are not requirements.  The most typical answer is
6359 that they describe behavior that seems generally desirable, but cannot
6360 be provided on all systems, or which may be undesirable on some systems.
6362 As far as practical, GNAT follows the implementation advice sections in
6363 the Ada Reference Manual.  This chapter contains a table giving the
6364 reference manual section number, paragraph number and several keywords
6365 for each advice.  Each entry consists of the text of the advice followed
6366 by the GNAT interpretation of this advice.  Most often, this simply says
6367 ``followed'', which means that GNAT follows the advice.  However, in a
6368 number of cases, GNAT deliberately deviates from this advice, in which
6369 case the text describes what GNAT does and why.
6371 @cindex Error detection
6372 @unnumberedsec 1.1.3(20): Error Detection
6373 @sp 1
6374 @cartouche
6375 If an implementation detects the use of an unsupported Specialized Needs
6376 Annex feature at run time, it should raise @code{Program_Error} if
6377 feasible.
6378 @end cartouche
6379 Not relevant.  All specialized needs annex features are either supported,
6380 or diagnosed at compile time.
6382 @cindex Child Units
6383 @unnumberedsec 1.1.3(31): Child Units
6384 @sp 1
6385 @cartouche
6386 If an implementation wishes to provide implementation-defined
6387 extensions to the functionality of a language-defined library unit, it
6388 should normally do so by adding children to the library unit.
6389 @end cartouche
6390 Followed.
6392 @cindex Bounded errors
6393 @unnumberedsec 1.1.5(12): Bounded Errors
6394 @sp 1
6395 @cartouche
6396 If an implementation detects a bounded error or erroneous
6397 execution, it should raise @code{Program_Error}.
6398 @end cartouche
6399 Followed in all cases in which the implementation detects a bounded
6400 error or erroneous execution.  Not all such situations are detected at
6401 runtime.
6403 @cindex Pragmas
6404 @unnumberedsec 2.8(16): Pragmas
6405 @sp 1
6406 @cartouche
6407 Normally, implementation-defined pragmas should have no semantic effect
6408 for error-free programs; that is, if the implementation-defined pragmas
6409 are removed from a working program, the program should still be legal,
6410 and should still have the same semantics.
6411 @end cartouche
6412 The following implementation defined pragmas are exceptions to this
6413 rule:
6415 @table @code
6416 @item Abort_Defer
6417 Affects semantics
6418 @item Ada_83
6419 Affects legality
6420 @item Assert
6421 Affects semantics
6422 @item CPP_Class
6423 Affects semantics
6424 @item CPP_Constructor
6425 Affects semantics
6426 @item Debug
6427 Affects semantics
6428 @item Interface_Name
6429 Affects semantics
6430 @item Machine_Attribute
6431 Affects semantics
6432 @item Unimplemented_Unit
6433 Affects legality
6434 @item Unchecked_Union
6435 Affects semantics
6436 @end table
6438 @noindent
6439 In each of the above cases, it is essential to the purpose of the pragma
6440 that this advice not be followed.  For details see the separate section
6441 on implementation defined pragmas.
6443 @unnumberedsec 2.8(17-19): Pragmas
6444 @sp 1
6445 @cartouche
6446 Normally, an implementation should not define pragmas that can
6447 make an illegal program legal, except as follows:
6448 @end cartouche
6449 @sp 1
6450 @cartouche
6451 A pragma used to complete a declaration, such as a pragma @code{Import};
6452 @end cartouche
6453 @sp 1
6454 @cartouche
6455 A pragma used to configure the environment by adding, removing, or
6456 replacing @code{library_items}.
6457 @end cartouche
6458 See response to paragraph 16 of this same section.
6460 @cindex Character Sets
6461 @cindex Alternative Character Sets
6462 @unnumberedsec 3.5.2(5): Alternative Character Sets
6463 @sp 1
6464 @cartouche
6465 If an implementation supports a mode with alternative interpretations
6466 for @code{Character} and @code{Wide_Character}, the set of graphic
6467 characters of @code{Character} should nevertheless remain a proper
6468 subset of the set of graphic characters of @code{Wide_Character}.  Any
6469 character set ``localizations'' should be reflected in the results of
6470 the subprograms defined in the language-defined package
6471 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6472 an alternative interpretation of @code{Character}, the implementation should
6473 also support a corresponding change in what is a legal
6474 @code{identifier_letter}.
6475 @end cartouche
6476 Not all wide character modes follow this advice, in particular the JIS
6477 and IEC modes reflect standard usage in Japan, and in these encoding,
6478 the upper half of the Latin-1 set is not part of the wide-character
6479 subset, since the most significant bit is used for wide character
6480 encoding.  However, this only applies to the external forms.  Internally
6481 there is no such restriction.
6483 @cindex Integer types
6484 @unnumberedsec 3.5.4(28): Integer Types
6486 @sp 1
6487 @cartouche
6488 An implementation should support @code{Long_Integer} in addition to
6489 @code{Integer} if the target machine supports 32-bit (or longer)
6490 arithmetic.  No other named integer subtypes are recommended for package
6491 @code{Standard}.  Instead, appropriate named integer subtypes should be
6492 provided in the library package @code{Interfaces} (see B.2).
6493 @end cartouche
6494 @code{Long_Integer} is supported.  Other standard integer types are supported
6495 so this advice is not fully followed.  These types
6496 are supported for convenient interface to C, and so that all hardware
6497 types of the machine are easily available.
6498 @unnumberedsec 3.5.4(29): Integer Types
6500 @sp 1
6501 @cartouche
6502 An implementation for a two's complement machine should support
6503 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6504 implementation should support a non-binary modules up to @code{Integer'Last}.
6505 @end cartouche
6506 Followed.
6508 @cindex Enumeration values
6509 @unnumberedsec 3.5.5(8): Enumeration Values
6510 @sp 1
6511 @cartouche
6512 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6513 subtype, if the value of the operand does not correspond to the internal
6514 code for any enumeration literal of its type (perhaps due to an
6515 un-initialized variable), then the implementation should raise
6516 @code{Program_Error}.  This is particularly important for enumeration
6517 types with noncontiguous internal codes specified by an
6518 enumeration_representation_clause.
6519 @end cartouche
6520 Followed.
6522 @cindex Float types
6523 @unnumberedsec 3.5.7(17): Float Types
6524 @sp 1
6525 @cartouche
6526 An implementation should support @code{Long_Float} in addition to
6527 @code{Float} if the target machine supports 11 or more digits of
6528 precision.  No other named floating point subtypes are recommended for
6529 package @code{Standard}.  Instead, appropriate named floating point subtypes
6530 should be provided in the library package @code{Interfaces} (see B.2).
6531 @end cartouche
6532 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6533 former provides improved compatibility with other implementations
6534 supporting this type.  The latter corresponds to the highest precision
6535 floating-point type supported by the hardware.  On most machines, this
6536 will be the same as @code{Long_Float}, but on some machines, it will
6537 correspond to the IEEE extended form.  The notable case is all ia32
6538 (x86) implementations, where @code{Long_Long_Float} corresponds to
6539 the 80-bit extended precision format supported in hardware on this
6540 processor.  Note that the 128-bit format on SPARC is not supported,
6541 since this is a software rather than a hardware format.
6543 @cindex Multidimensional arrays
6544 @cindex Arrays, multidimensional
6545 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6546 @sp 1
6547 @cartouche
6548 An implementation should normally represent multidimensional arrays in
6549 row-major order, consistent with the notation used for multidimensional
6550 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6551 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6552 column-major order should be used instead (see B.5, ``Interfacing with
6553 Fortran'').
6554 @end cartouche
6555 Followed.
6557 @findex Duration'Small
6558 @unnumberedsec 9.6(30-31): Duration'Small
6559 @sp 1
6560 @cartouche
6561 Whenever possible in an implementation, the value of @code{Duration'Small}
6562 should be no greater than 100 microseconds.
6563 @end cartouche
6564 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6566 @sp 1
6567 @cartouche
6568 The time base for @code{delay_relative_statements} should be monotonic;
6569 it need not be the same time base as used for @code{Calendar.Clock}.
6570 @end cartouche
6571 Followed.
6573 @unnumberedsec 10.2.1(12): Consistent Representation
6574 @sp 1
6575 @cartouche
6576 In an implementation, a type declared in a pre-elaborated package should
6577 have the same representation in every elaboration of a given version of
6578 the package, whether the elaborations occur in distinct executions of
6579 the same program, or in executions of distinct programs or partitions
6580 that include the given version.
6581 @end cartouche
6582 Followed, except in the case of tagged types.  Tagged types involve
6583 implicit pointers to a local copy of a dispatch table, and these pointers
6584 have representations which thus depend on a particular elaboration of the
6585 package.  It is not easy to see how it would be possible to follow this
6586 advice without severely impacting efficiency of execution.
6588 @cindex Exception information
6589 @unnumberedsec 11.4.1(19): Exception Information
6590 @sp 1
6591 @cartouche
6592 @code{Exception_Message} by default and @code{Exception_Information}
6593 should produce information useful for
6594 debugging.  @code{Exception_Message} should be short, about one
6595 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6596 should not include the
6597 @code{Exception_Name}.  @code{Exception_Information} should include both
6598 the @code{Exception_Name} and the @code{Exception_Message}.
6599 @end cartouche
6600 Followed.  For each exception that doesn't have a specified
6601 @code{Exception_Message}, the compiler generates one containing the location
6602 of the raise statement.  This location has the form ``file:line'', where
6603 file is the short file name (without path information) and line is the line
6604 number in the file.  Note that in the case of the Zero Cost Exception
6605 mechanism, these messages become redundant with the Exception_Information that
6606 contains a full backtrace of the calling sequence, so they are disabled.
6607 To disable explicitly the generation of the source location message, use the
6608 Pragma @code{Discard_Names}.
6610 @cindex Suppression of checks
6611 @cindex Checks, suppression of
6612 @unnumberedsec 11.5(28): Suppression of Checks
6613 @sp 1
6614 @cartouche
6615 The implementation should minimize the code executed for checks that
6616 have been suppressed.
6617 @end cartouche
6618 Followed.
6620 @cindex Representation clauses
6621 @unnumberedsec 13.1 (21-24): Representation Clauses
6622 @sp 1
6623 @cartouche
6624 The recommended level of support for all representation items is
6625 qualified as follows:
6626 @end cartouche
6627 @sp 1
6628 @cartouche
6629 An implementation need not support representation items containing
6630 non-static expressions, except that an implementation should support a
6631 representation item for a given entity if each non-static expression in
6632 the representation item is a name that statically denotes a constant
6633 declared before the entity.
6634 @end cartouche
6635 Followed.  In fact, GNAT goes beyond the recommended level of support
6636 by allowing nonstatic expressions in some representation clauses even
6637 without the need to declare constants initialized with the values of
6638 such expressions.
6639 For example:
6641 @smallexample @c ada
6642   X : Integer;
6643   Y : Float;
6644   for Y'Address use X'Address;>>
6645 @end smallexample
6647 @sp 1
6648 @cartouche
6649 An implementation need not support a specification for the @code{Size}
6650 for a given composite subtype, nor the size or storage place for an
6651 object (including a component) of a given composite subtype, unless the
6652 constraints on the subtype and its composite subcomponents (if any) are
6653 all static constraints.
6654 @end cartouche
6655 Followed.  Size Clauses are not permitted on non-static components, as
6656 described above.
6658 @sp 1
6659 @cartouche
6660 An aliased component, or a component whose type is by-reference, should
6661 always be allocated at an addressable location.
6662 @end cartouche
6663 Followed.
6665 @cindex Packed types
6666 @unnumberedsec 13.2(6-8): Packed Types
6667 @sp 1
6668 @cartouche
6669 If a type is packed, then the implementation should try to minimize
6670 storage allocated to objects of the type, possibly at the expense of
6671 speed of accessing components, subject to reasonable complexity in
6672 addressing calculations.
6673 @end cartouche
6674 @sp 1
6675 @cartouche
6676 The recommended level of support pragma @code{Pack} is:
6678 For a packed record type, the components should be packed as tightly as
6679 possible subject to the Sizes of the component subtypes, and subject to
6680 any @code{record_representation_clause} that applies to the type; the
6681 implementation may, but need not, reorder components or cross aligned
6682 word boundaries to improve the packing.  A component whose @code{Size} is
6683 greater than the word size may be allocated an integral number of words.
6684 @end cartouche
6685 Followed.  Tight packing of arrays is supported for all component sizes
6686 up to 64-bits. If the array component size is 1 (that is to say, if
6687 the component is a boolean type or an enumeration type with two values)
6688 then values of the type are implicitly initialized to zero. This
6689 happens both for objects of the packed type, and for objects that have a
6690 subcomponent of the packed type.
6692 @sp 1
6693 @cartouche
6694 An implementation should support Address clauses for imported
6695 subprograms.
6696 @end cartouche
6697 Followed.
6698 @cindex @code{Address} clauses
6699 @unnumberedsec 13.3(14-19): Address Clauses
6701 @sp 1
6702 @cartouche
6703 For an array @var{X}, @code{@var{X}'Address} should point at the first
6704 component of the array, and not at the array bounds.
6705 @end cartouche
6706 Followed.
6708 @sp 1
6709 @cartouche
6710 The recommended level of support for the @code{Address} attribute is:
6712 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6713 object that is aliased or of a by-reference type, or is an entity whose
6714 @code{Address} has been specified.
6715 @end cartouche
6716 Followed.  A valid address will be produced even if none of those
6717 conditions have been met.  If necessary, the object is forced into
6718 memory to ensure the address is valid.
6720 @sp 1
6721 @cartouche
6722 An implementation should support @code{Address} clauses for imported
6723 subprograms.
6724 @end cartouche
6725 Followed.
6727 @sp 1
6728 @cartouche
6729 Objects (including subcomponents) that are aliased or of a by-reference
6730 type should be allocated on storage element boundaries.
6731 @end cartouche
6732 Followed.
6734 @sp 1
6735 @cartouche
6736 If the @code{Address} of an object is specified, or it is imported or exported,
6737 then the implementation should not perform optimizations based on
6738 assumptions of no aliases.
6739 @end cartouche
6740 Followed.
6742 @cindex @code{Alignment} clauses
6743 @unnumberedsec 13.3(29-35): Alignment Clauses
6744 @sp 1
6745 @cartouche
6746 The recommended level of support for the @code{Alignment} attribute for
6747 subtypes is:
6749 An implementation should support specified Alignments that are factors
6750 and multiples of the number of storage elements per word, subject to the
6751 following:
6752 @end cartouche
6753 Followed.
6755 @sp 1
6756 @cartouche
6757 An implementation need not support specified @code{Alignment}s for
6758 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6759 loaded and stored by available machine instructions.
6760 @end cartouche
6761 Followed.
6763 @sp 1
6764 @cartouche
6765 An implementation need not support specified @code{Alignment}s that are
6766 greater than the maximum @code{Alignment} the implementation ever returns by
6767 default.
6768 @end cartouche
6769 Followed.
6771 @sp 1
6772 @cartouche
6773 The recommended level of support for the @code{Alignment} attribute for
6774 objects is:
6776 Same as above, for subtypes, but in addition:
6777 @end cartouche
6778 Followed.
6780 @sp 1
6781 @cartouche
6782 For stand-alone library-level objects of statically constrained
6783 subtypes, the implementation should support all @code{Alignment}s
6784 supported by the target linker.  For example, page alignment is likely to
6785 be supported for such objects, but not for subtypes.
6786 @end cartouche
6787 Followed.
6789 @cindex @code{Size} clauses
6790 @unnumberedsec 13.3(42-43): Size Clauses
6791 @sp 1
6792 @cartouche
6793 The recommended level of support for the @code{Size} attribute of
6794 objects is:
6796 A @code{Size} clause should be supported for an object if the specified
6797 @code{Size} is at least as large as its subtype's @code{Size}, and
6798 corresponds to a size in storage elements that is a multiple of the
6799 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6800 @end cartouche
6801 Followed.
6803 @unnumberedsec 13.3(50-56): Size Clauses
6804 @sp 1
6805 @cartouche
6806 If the @code{Size} of a subtype is specified, and allows for efficient
6807 independent addressability (see 9.10) on the target architecture, then
6808 the @code{Size} of the following objects of the subtype should equal the
6809 @code{Size} of the subtype:
6811 Aliased objects (including components).
6812 @end cartouche
6813 Followed.
6815 @sp 1
6816 @cartouche
6817 @code{Size} clause on a composite subtype should not affect the
6818 internal layout of components.
6819 @end cartouche
6820 Followed. But note that this can be overridden by use of the implementation
6821 pragma Implicit_Packing in the case of packed arrays.
6823 @sp 1
6824 @cartouche
6825 The recommended level of support for the @code{Size} attribute of subtypes is:
6826 @end cartouche
6827 @sp 1
6828 @cartouche
6829 The @code{Size} (if not specified) of a static discrete or fixed point
6830 subtype should be the number of bits needed to represent each value
6831 belonging to the subtype using an unbiased representation, leaving space
6832 for a sign bit only if the subtype contains negative values.  If such a
6833 subtype is a first subtype, then an implementation should support a
6834 specified @code{Size} for it that reflects this representation.
6835 @end cartouche
6836 Followed.
6838 @sp 1
6839 @cartouche
6840 For a subtype implemented with levels of indirection, the @code{Size}
6841 should include the size of the pointers, but not the size of what they
6842 point at.
6843 @end cartouche
6844 Followed.
6846 @cindex @code{Component_Size} clauses
6847 @unnumberedsec 13.3(71-73): Component Size Clauses
6848 @sp 1
6849 @cartouche
6850 The recommended level of support for the @code{Component_Size}
6851 attribute is:
6852 @end cartouche
6853 @sp 1
6854 @cartouche
6855 An implementation need not support specified @code{Component_Sizes} that are
6856 less than the @code{Size} of the component subtype.
6857 @end cartouche
6858 Followed.
6860 @sp 1
6861 @cartouche
6862 An implementation should support specified @code{Component_Size}s that
6863 are factors and multiples of the word size.  For such
6864 @code{Component_Size}s, the array should contain no gaps between
6865 components.  For other @code{Component_Size}s (if supported), the array
6866 should contain no gaps between components when packing is also
6867 specified; the implementation should forbid this combination in cases
6868 where it cannot support a no-gaps representation.
6869 @end cartouche
6870 Followed.
6872 @cindex Enumeration representation clauses
6873 @cindex Representation clauses, enumeration
6874 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6875 @sp 1
6876 @cartouche
6877 The recommended level of support for enumeration representation clauses
6880 An implementation need not support enumeration representation clauses
6881 for boolean types, but should at minimum support the internal codes in
6882 the range @code{System.Min_Int.System.Max_Int}.
6883 @end cartouche
6884 Followed.
6886 @cindex Record representation clauses
6887 @cindex Representation clauses, records
6888 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6889 @sp 1
6890 @cartouche
6891 The recommended level of support for
6892 @*@code{record_representation_clauses} is:
6894 An implementation should support storage places that can be extracted
6895 with a load, mask, shift sequence of machine code, and set with a load,
6896 shift, mask, store sequence, given the available machine instructions
6897 and run-time model.
6898 @end cartouche
6899 Followed.
6901 @sp 1
6902 @cartouche
6903 A storage place should be supported if its size is equal to the
6904 @code{Size} of the component subtype, and it starts and ends on a
6905 boundary that obeys the @code{Alignment} of the component subtype.
6906 @end cartouche
6907 Followed.
6909 @sp 1
6910 @cartouche
6911 If the default bit ordering applies to the declaration of a given type,
6912 then for a component whose subtype's @code{Size} is less than the word
6913 size, any storage place that does not cross an aligned word boundary
6914 should be supported.
6915 @end cartouche
6916 Followed.
6918 @sp 1
6919 @cartouche
6920 An implementation may reserve a storage place for the tag field of a
6921 tagged type, and disallow other components from overlapping that place.
6922 @end cartouche
6923 Followed.  The storage place for the tag field is the beginning of the tagged
6924 record, and its size is Address'Size.  GNAT will reject an explicit component
6925 clause for the tag field.
6927 @sp 1
6928 @cartouche
6929 An implementation need not support a @code{component_clause} for a
6930 component of an extension part if the storage place is not after the
6931 storage places of all components of the parent type, whether or not
6932 those storage places had been specified.
6933 @end cartouche
6934 Followed.  The above advice on record representation clauses is followed,
6935 and all mentioned features are implemented.
6937 @cindex Storage place attributes
6938 @unnumberedsec 13.5.2(5): Storage Place Attributes
6939 @sp 1
6940 @cartouche
6941 If a component is represented using some form of pointer (such as an
6942 offset) to the actual data of the component, and this data is contiguous
6943 with the rest of the object, then the storage place attributes should
6944 reflect the place of the actual data, not the pointer.  If a component is
6945 allocated discontinuously from the rest of the object, then a warning
6946 should be generated upon reference to one of its storage place
6947 attributes.
6948 @end cartouche
6949 Followed.  There are no such components in GNAT@.
6951 @cindex Bit ordering
6952 @unnumberedsec 13.5.3(7-8): Bit Ordering
6953 @sp 1
6954 @cartouche
6955 The recommended level of support for the non-default bit ordering is:
6956 @end cartouche
6957 @sp 1
6958 @cartouche
6959 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6960 should support the non-default bit ordering in addition to the default
6961 bit ordering.
6962 @end cartouche
6963 Followed.  Word size does not equal storage size in this implementation.
6964 Thus non-default bit ordering is not supported.
6966 @cindex @code{Address}, as private type
6967 @unnumberedsec 13.7(37): Address as Private
6968 @sp 1
6969 @cartouche
6970 @code{Address} should be of a private type.
6971 @end cartouche
6972 Followed.
6974 @cindex Operations, on @code{Address}
6975 @cindex @code{Address}, operations of
6976 @unnumberedsec 13.7.1(16): Address Operations
6977 @sp 1
6978 @cartouche
6979 Operations in @code{System} and its children should reflect the target
6980 environment semantics as closely as is reasonable.  For example, on most
6981 machines, it makes sense for address arithmetic to ``wrap around''.
6982 Operations that do not make sense should raise @code{Program_Error}.
6983 @end cartouche
6984 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6985 operation raises @code{Program_Error}, since all operations make sense.
6987 @cindex Unchecked conversion
6988 @unnumberedsec 13.9(14-17): Unchecked Conversion
6989 @sp 1
6990 @cartouche
6991 The @code{Size} of an array object should not include its bounds; hence,
6992 the bounds should not be part of the converted data.
6993 @end cartouche
6994 Followed.
6996 @sp 1
6997 @cartouche
6998 The implementation should not generate unnecessary run-time checks to
6999 ensure that the representation of @var{S} is a representation of the
7000 target type.  It should take advantage of the permission to return by
7001 reference when possible.  Restrictions on unchecked conversions should be
7002 avoided unless required by the target environment.
7003 @end cartouche
7004 Followed.  There are no restrictions on unchecked conversion.  A warning is
7005 generated if the source and target types do not have the same size since
7006 the semantics in this case may be target dependent.
7008 @sp 1
7009 @cartouche
7010 The recommended level of support for unchecked conversions is:
7011 @end cartouche
7012 @sp 1
7013 @cartouche
7014 Unchecked conversions should be supported and should be reversible in
7015 the cases where this clause defines the result.  To enable meaningful use
7016 of unchecked conversion, a contiguous representation should be used for
7017 elementary subtypes, for statically constrained array subtypes whose
7018 component subtype is one of the subtypes described in this paragraph,
7019 and for record subtypes without discriminants whose component subtypes
7020 are described in this paragraph.
7021 @end cartouche
7022 Followed.
7024 @cindex Heap usage, implicit
7025 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7026 @sp 1
7027 @cartouche
7028 An implementation should document any cases in which it dynamically
7029 allocates heap storage for a purpose other than the evaluation of an
7030 allocator.
7031 @end cartouche
7032 Followed, the only other points at which heap storage is dynamically
7033 allocated are as follows:
7035 @itemize @bullet
7036 @item
7037 At initial elaboration time, to allocate dynamically sized global
7038 objects.
7040 @item
7041 To allocate space for a task when a task is created.
7043 @item
7044 To extend the secondary stack dynamically when needed.  The secondary
7045 stack is used for returning variable length results.
7046 @end itemize
7048 @sp 1
7049 @cartouche
7050 A default (implementation-provided) storage pool for an
7051 access-to-constant type should not have overhead to support deallocation of
7052 individual objects.
7053 @end cartouche
7054 Followed.
7056 @sp 1
7057 @cartouche
7058 A storage pool for an anonymous access type should be created at the
7059 point of an allocator for the type, and be reclaimed when the designated
7060 object becomes inaccessible.
7061 @end cartouche
7062 Followed.
7064 @cindex Unchecked deallocation
7065 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7066 @sp 1
7067 @cartouche
7068 For a standard storage pool, @code{Free} should actually reclaim the
7069 storage.
7070 @end cartouche
7071 Followed.
7073 @cindex Stream oriented attributes
7074 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7075 @sp 1
7076 @cartouche
7077 If a stream element is the same size as a storage element, then the
7078 normal in-memory representation should be used by @code{Read} and
7079 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
7080 should use the smallest number of stream elements needed to represent
7081 all values in the base range of the scalar type.
7082 @end cartouche
7084 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7085 which specifies using the size of the first subtype.
7086 However, such an implementation is based on direct binary
7087 representations and is therefore target- and endianness-dependent.
7088 To address this issue, GNAT also supplies an alternate implementation
7089 of the stream attributes @code{Read} and @code{Write},
7090 which uses the target-independent XDR standard representation
7091 for scalar types.
7092 @cindex XDR representation
7093 @cindex @code{Read} attribute
7094 @cindex @code{Write} attribute
7095 @cindex Stream oriented attributes
7096 The XDR implementation is provided as an alternative body of the
7097 @code{System.Stream_Attributes} package, in the file
7098 @file{s-strxdr.adb} in the GNAT library.
7099 There is no @file{s-strxdr.ads} file.
7100 In order to install the XDR implementation, do the following:
7101 @enumerate
7102 @item Replace the default implementation of the
7103 @code{System.Stream_Attributes} package with the XDR implementation.
7104 For example on a Unix platform issue the commands:
7105 @smallexample
7106 $ mv s-stratt.adb s-strold.adb
7107 $ mv s-strxdr.adb s-stratt.adb
7108 @end smallexample
7110 @item
7111 Rebuild the GNAT run-time library as documented in
7112 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7113 @end enumerate
7115 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7116 @sp 1
7117 @cartouche
7118 If an implementation provides additional named predefined integer types,
7119 then the names should end with @samp{Integer} as in
7120 @samp{Long_Integer}.  If an implementation provides additional named
7121 predefined floating point types, then the names should end with
7122 @samp{Float} as in @samp{Long_Float}.
7123 @end cartouche
7124 Followed.
7126 @findex Ada.Characters.Handling
7127 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7128 @sp 1
7129 @cartouche
7130 If an implementation provides a localized definition of @code{Character}
7131 or @code{Wide_Character}, then the effects of the subprograms in
7132 @code{Characters.Handling} should reflect the localizations.  See also
7133 3.5.2.
7134 @end cartouche
7135 Followed.  GNAT provides no such localized definitions.
7137 @cindex Bounded-length strings
7138 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7139 @sp 1
7140 @cartouche
7141 Bounded string objects should not be implemented by implicit pointers
7142 and dynamic allocation.
7143 @end cartouche
7144 Followed.  No implicit pointers or dynamic allocation are used.
7146 @cindex Random number generation
7147 @unnumberedsec A.5.2(46-47): Random Number Generation
7148 @sp 1
7149 @cartouche
7150 Any storage associated with an object of type @code{Generator} should be
7151 reclaimed on exit from the scope of the object.
7152 @end cartouche
7153 Followed.
7155 @sp 1
7156 @cartouche
7157 If the generator period is sufficiently long in relation to the number
7158 of distinct initiator values, then each possible value of
7159 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7160 random numbers that does not, in a practical sense, overlap the sequence
7161 initiated by any other value.  If this is not possible, then the mapping
7162 between initiator values and generator states should be a rapidly
7163 varying function of the initiator value.
7164 @end cartouche
7165 Followed.  The generator period is sufficiently long for the first
7166 condition here to hold true.
7168 @findex Get_Immediate
7169 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7170 @sp 1
7171 @cartouche
7172 The @code{Get_Immediate} procedures should be implemented with
7173 unbuffered input.  For a device such as a keyboard, input should be
7174 @dfn{available} if a key has already been typed, whereas for a disk
7175 file, input should always be available except at end of file.  For a file
7176 associated with a keyboard-like device, any line-editing features of the
7177 underlying operating system should be disabled during the execution of
7178 @code{Get_Immediate}.
7179 @end cartouche
7180 Followed on all targets except VxWorks. For VxWorks, there is no way to
7181 provide this functionality that does not result in the input buffer being
7182 flushed before the @code{Get_Immediate} call. A special unit
7183 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7184 this functionality.
7186 @findex Export
7187 @unnumberedsec B.1(39-41): Pragma @code{Export}
7188 @sp 1
7189 @cartouche
7190 If an implementation supports pragma @code{Export} to a given language,
7191 then it should also allow the main subprogram to be written in that
7192 language.  It should support some mechanism for invoking the elaboration
7193 of the Ada library units included in the system, and for invoking the
7194 finalization of the environment task.  On typical systems, the
7195 recommended mechanism is to provide two subprograms whose link names are
7196 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7197 elaboration code for library units.  @code{adafinal} should contain the
7198 finalization code.  These subprograms should have no effect the second
7199 and subsequent time they are called.
7200 @end cartouche
7201 Followed.
7203 @sp 1
7204 @cartouche
7205 Automatic elaboration of pre-elaborated packages should be
7206 provided when pragma @code{Export} is supported.
7207 @end cartouche
7208 Followed when the main program is in Ada.  If the main program is in a
7209 foreign language, then
7210 @code{adainit} must be called to elaborate pre-elaborated
7211 packages.
7213 @sp 1
7214 @cartouche
7215 For each supported convention @var{L} other than @code{Intrinsic}, an
7216 implementation should support @code{Import} and @code{Export} pragmas
7217 for objects of @var{L}-compatible types and for subprograms, and pragma
7218 @code{Convention} for @var{L}-eligible types and for subprograms,
7219 presuming the other language has corresponding features.  Pragma
7220 @code{Convention} need not be supported for scalar types.
7221 @end cartouche
7222 Followed.
7224 @cindex Package @code{Interfaces}
7225 @findex Interfaces
7226 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7227 @sp 1
7228 @cartouche
7229 For each implementation-defined convention identifier, there should be a
7230 child package of package Interfaces with the corresponding name.  This
7231 package should contain any declarations that would be useful for
7232 interfacing to the language (implementation) represented by the
7233 convention.  Any declarations useful for interfacing to any language on
7234 the given hardware architecture should be provided directly in
7235 @code{Interfaces}.
7236 @end cartouche
7237 Followed. An additional package not defined
7238 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7239 for interfacing to C++.
7241 @sp 1
7242 @cartouche
7243 An implementation supporting an interface to C, COBOL, or Fortran should
7244 provide the corresponding package or packages described in the following
7245 clauses.
7246 @end cartouche
7247 Followed.  GNAT provides all the packages described in this section.
7249 @cindex C, interfacing with
7250 @unnumberedsec B.3(63-71): Interfacing with C
7251 @sp 1
7252 @cartouche
7253 An implementation should support the following interface correspondences
7254 between Ada and C@.
7255 @end cartouche
7256 Followed.
7258 @sp 1
7259 @cartouche
7260 An Ada procedure corresponds to a void-returning C function.
7261 @end cartouche
7262 Followed.
7264 @sp 1
7265 @cartouche
7266 An Ada function corresponds to a non-void C function.
7267 @end cartouche
7268 Followed.
7270 @sp 1
7271 @cartouche
7272 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7273 function.
7274 @end cartouche
7275 Followed.
7277 @sp 1
7278 @cartouche
7279 An Ada @code{in} parameter of an access-to-object type with designated
7280 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7281 where @var{t} is the C type corresponding to the Ada type @var{T}.
7282 @end cartouche
7283 Followed.
7285 @sp 1
7286 @cartouche
7287 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7288 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7289 argument to a C function, where @var{t} is the C type corresponding to
7290 the Ada type @var{T}.  In the case of an elementary @code{out} or
7291 @code{in out} parameter, a pointer to a temporary copy is used to
7292 preserve by-copy semantics.
7293 @end cartouche
7294 Followed.
7296 @sp 1
7297 @cartouche
7298 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7299 @code{@var{t}*} argument to a C function, where @var{t} is the C
7300 structure corresponding to the Ada type @var{T}.
7301 @end cartouche
7302 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7303 pragma, or Convention, or by explicitly specifying the mechanism for a given
7304 call using an extended import or export pragma.
7306 @sp 1
7307 @cartouche
7308 An Ada parameter of an array type with component type @var{T}, of any
7309 mode, is passed as a @code{@var{t}*} argument to a C function, where
7310 @var{t} is the C type corresponding to the Ada type @var{T}.
7311 @end cartouche
7312 Followed.
7314 @sp 1
7315 @cartouche
7316 An Ada parameter of an access-to-subprogram type is passed as a pointer
7317 to a C function whose prototype corresponds to the designated
7318 subprogram's specification.
7319 @end cartouche
7320 Followed.
7322 @cindex COBOL, interfacing with
7323 @unnumberedsec B.4(95-98): Interfacing with COBOL
7324 @sp 1
7325 @cartouche
7326 An Ada implementation should support the following interface
7327 correspondences between Ada and COBOL@.
7328 @end cartouche
7329 Followed.
7331 @sp 1
7332 @cartouche
7333 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7334 the COBOL type corresponding to @var{T}.
7335 @end cartouche
7336 Followed.
7338 @sp 1
7339 @cartouche
7340 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7341 the corresponding COBOL type.
7342 @end cartouche
7343 Followed.
7345 @sp 1
7346 @cartouche
7347 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7348 COBOL type corresponding to the Ada parameter type; for scalars, a local
7349 copy is used if necessary to ensure by-copy semantics.
7350 @end cartouche
7351 Followed.
7353 @cindex Fortran, interfacing with
7354 @unnumberedsec B.5(22-26): Interfacing with Fortran
7355 @sp 1
7356 @cartouche
7357 An Ada implementation should support the following interface
7358 correspondences between Ada and Fortran:
7359 @end cartouche
7360 Followed.
7362 @sp 1
7363 @cartouche
7364 An Ada procedure corresponds to a Fortran subroutine.
7365 @end cartouche
7366 Followed.
7368 @sp 1
7369 @cartouche
7370 An Ada function corresponds to a Fortran function.
7371 @end cartouche
7372 Followed.
7374 @sp 1
7375 @cartouche
7376 An Ada parameter of an elementary, array, or record type @var{T} is
7377 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7378 the Fortran type corresponding to the Ada type @var{T}, and where the
7379 INTENT attribute of the corresponding dummy argument matches the Ada
7380 formal parameter mode; the Fortran implementation's parameter passing
7381 conventions are used.  For elementary types, a local copy is used if
7382 necessary to ensure by-copy semantics.
7383 @end cartouche
7384 Followed.
7386 @sp 1
7387 @cartouche
7388 An Ada parameter of an access-to-subprogram type is passed as a
7389 reference to a Fortran procedure whose interface corresponds to the
7390 designated subprogram's specification.
7391 @end cartouche
7392 Followed.
7394 @cindex Machine operations
7395 @unnumberedsec C.1(3-5): Access to Machine Operations
7396 @sp 1
7397 @cartouche
7398 The machine code or intrinsic support should allow access to all
7399 operations normally available to assembly language programmers for the
7400 target environment, including privileged instructions, if any.
7401 @end cartouche
7402 Followed.
7404 @sp 1
7405 @cartouche
7406 The interfacing pragmas (see Annex B) should support interface to
7407 assembler; the default assembler should be associated with the
7408 convention identifier @code{Assembler}.
7409 @end cartouche
7410 Followed.
7412 @sp 1
7413 @cartouche
7414 If an entity is exported to assembly language, then the implementation
7415 should allocate it at an addressable location, and should ensure that it
7416 is retained by the linking process, even if not otherwise referenced
7417 from the Ada code.  The implementation should assume that any call to a
7418 machine code or assembler subprogram is allowed to read or update every
7419 object that is specified as exported.
7420 @end cartouche
7421 Followed.
7423 @unnumberedsec C.1(10-16): Access to Machine Operations
7424 @sp 1
7425 @cartouche
7426 The implementation should ensure that little or no overhead is
7427 associated with calling intrinsic and machine-code subprograms.
7428 @end cartouche
7429 Followed for both intrinsics and machine-code subprograms.
7431 @sp 1
7432 @cartouche
7433 It is recommended that intrinsic subprograms be provided for convenient
7434 access to any machine operations that provide special capabilities or
7435 efficiency and that are not otherwise available through the language
7436 constructs.
7437 @end cartouche
7438 Followed.  A full set of machine operation intrinsic subprograms is provided.
7440 @sp 1
7441 @cartouche
7442 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7443 swap, decrement and test, enqueue/dequeue.
7444 @end cartouche
7445 Followed on any target supporting such operations.
7447 @sp 1
7448 @cartouche
7449 Standard numeric functions---e.g.@:, sin, log.
7450 @end cartouche
7451 Followed on any target supporting such operations.
7453 @sp 1
7454 @cartouche
7455 String manipulation operations---e.g.@:, translate and test.
7456 @end cartouche
7457 Followed on any target supporting such operations.
7459 @sp 1
7460 @cartouche
7461 Vector operations---e.g.@:, compare vector against thresholds.
7462 @end cartouche
7463 Followed on any target supporting such operations.
7465 @sp 1
7466 @cartouche
7467 Direct operations on I/O ports.
7468 @end cartouche
7469 Followed on any target supporting such operations.
7471 @cindex Interrupt support
7472 @unnumberedsec C.3(28): Interrupt Support
7473 @sp 1
7474 @cartouche
7475 If the @code{Ceiling_Locking} policy is not in effect, the
7476 implementation should provide means for the application to specify which
7477 interrupts are to be blocked during protected actions, if the underlying
7478 system allows for a finer-grain control of interrupt blocking.
7479 @end cartouche
7480 Followed.  The underlying system does not allow for finer-grain control
7481 of interrupt blocking.
7483 @cindex Protected procedure handlers
7484 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7485 @sp 1
7486 @cartouche
7487 Whenever possible, the implementation should allow interrupt handlers to
7488 be called directly by the hardware.
7489 @end cartouche
7490 @c SGI info:
7491 @ignore
7492 This is never possible under IRIX, so this is followed by default.
7493 @end ignore
7494 Followed on any target where the underlying operating system permits
7495 such direct calls.
7497 @sp 1
7498 @cartouche
7499 Whenever practical, violations of any
7500 implementation-defined restrictions should be detected before run time.
7501 @end cartouche
7502 Followed.  Compile time warnings are given when possible.
7504 @cindex Package @code{Interrupts}
7505 @findex Interrupts
7506 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7508 @sp 1
7509 @cartouche
7510 If implementation-defined forms of interrupt handler procedures are
7511 supported, such as protected procedures with parameters, then for each
7512 such form of a handler, a type analogous to @code{Parameterless_Handler}
7513 should be specified in a child package of @code{Interrupts}, with the
7514 same operations as in the predefined package Interrupts.
7515 @end cartouche
7516 Followed.
7518 @cindex Pre-elaboration requirements
7519 @unnumberedsec C.4(14): Pre-elaboration Requirements
7520 @sp 1
7521 @cartouche
7522 It is recommended that pre-elaborated packages be implemented in such a
7523 way that there should be little or no code executed at run time for the
7524 elaboration of entities not already covered by the Implementation
7525 Requirements.
7526 @end cartouche
7527 Followed.  Executable code is generated in some cases, e.g.@: loops
7528 to initialize large arrays.
7530 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7532 @sp 1
7533 @cartouche
7534 If the pragma applies to an entity, then the implementation should
7535 reduce the amount of storage used for storing names associated with that
7536 entity.
7537 @end cartouche
7538 Followed.
7540 @cindex Package @code{Task_Attributes}
7541 @findex Task_Attributes
7542 @unnumberedsec C.7.2(30): The Package Task_Attributes
7543 @sp 1
7544 @cartouche
7545 Some implementations are targeted to domains in which memory use at run
7546 time must be completely deterministic.  For such implementations, it is
7547 recommended that the storage for task attributes will be pre-allocated
7548 statically and not from the heap.  This can be accomplished by either
7549 placing restrictions on the number and the size of the task's
7550 attributes, or by using the pre-allocated storage for the first @var{N}
7551 attribute objects, and the heap for the others.  In the latter case,
7552 @var{N} should be documented.
7553 @end cartouche
7554 Not followed.  This implementation is not targeted to such a domain.
7556 @cindex Locking Policies
7557 @unnumberedsec D.3(17): Locking Policies
7559 @sp 1
7560 @cartouche
7561 The implementation should use names that end with @samp{_Locking} for
7562 locking policies defined by the implementation.
7563 @end cartouche
7564 Followed.  A single implementation-defined locking policy is defined,
7565 whose name (@code{Inheritance_Locking}) follows this suggestion.
7567 @cindex Entry queuing policies
7568 @unnumberedsec D.4(16): Entry Queuing Policies
7569 @sp 1
7570 @cartouche
7571 Names that end with @samp{_Queuing} should be used
7572 for all implementation-defined queuing policies.
7573 @end cartouche
7574 Followed.  No such implementation-defined queuing policies exist.
7576 @cindex Preemptive abort
7577 @unnumberedsec D.6(9-10): Preemptive Abort
7578 @sp 1
7579 @cartouche
7580 Even though the @code{abort_statement} is included in the list of
7581 potentially blocking operations (see 9.5.1), it is recommended that this
7582 statement be implemented in a way that never requires the task executing
7583 the @code{abort_statement} to block.
7584 @end cartouche
7585 Followed.
7587 @sp 1
7588 @cartouche
7589 On a multi-processor, the delay associated with aborting a task on
7590 another processor should be bounded; the implementation should use
7591 periodic polling, if necessary, to achieve this.
7592 @end cartouche
7593 Followed.
7595 @cindex Tasking restrictions
7596 @unnumberedsec D.7(21): Tasking Restrictions
7597 @sp 1
7598 @cartouche
7599 When feasible, the implementation should take advantage of the specified
7600 restrictions to produce a more efficient implementation.
7601 @end cartouche
7602 GNAT currently takes advantage of these restrictions by providing an optimized
7603 run time when the Ravenscar profile and the GNAT restricted run time set
7604 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7605 pragma @code{Profile (Restricted)} for more details.
7607 @cindex Time, monotonic
7608 @unnumberedsec D.8(47-49): Monotonic Time
7609 @sp 1
7610 @cartouche
7611 When appropriate, implementations should provide configuration
7612 mechanisms to change the value of @code{Tick}.
7613 @end cartouche
7614 Such configuration mechanisms are not appropriate to this implementation
7615 and are thus not supported.
7617 @sp 1
7618 @cartouche
7619 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7620 be implemented as transformations of the same time base.
7621 @end cartouche
7622 Followed.
7624 @sp 1
7625 @cartouche
7626 It is recommended that the @dfn{best} time base which exists in
7627 the underlying system be available to the application through
7628 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7629 @end cartouche
7630 Followed.
7632 @cindex Partition communication subsystem
7633 @cindex PCS
7634 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7635 @sp 1
7636 @cartouche
7637 Whenever possible, the PCS on the called partition should allow for
7638 multiple tasks to call the RPC-receiver with different messages and
7639 should allow them to block until the corresponding subprogram body
7640 returns.
7641 @end cartouche
7642 Followed by GLADE, a separately supplied PCS that can be used with
7643 GNAT.
7645 @sp 1
7646 @cartouche
7647 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7648 should raise @code{Storage_Error} if it runs out of space trying to
7649 write the @code{Item} into the stream.
7650 @end cartouche
7651 Followed by GLADE, a separately supplied PCS that can be used with
7652 GNAT@.
7654 @cindex COBOL support
7655 @unnumberedsec F(7): COBOL Support
7656 @sp 1
7657 @cartouche
7658 If COBOL (respectively, C) is widely supported in the target
7659 environment, implementations supporting the Information Systems Annex
7660 should provide the child package @code{Interfaces.COBOL} (respectively,
7661 @code{Interfaces.C}) specified in Annex B and should support a
7662 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7663 pragmas (see Annex B), thus allowing Ada programs to interface with
7664 programs written in that language.
7665 @end cartouche
7666 Followed.
7668 @cindex Decimal radix support
7669 @unnumberedsec F.1(2): Decimal Radix Support
7670 @sp 1
7671 @cartouche
7672 Packed decimal should be used as the internal representation for objects
7673 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7674 @end cartouche
7675 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7676 representations.
7678 @cindex Numerics
7679 @unnumberedsec G: Numerics
7680 @sp 2
7681 @cartouche
7682 If Fortran (respectively, C) is widely supported in the target
7683 environment, implementations supporting the Numerics Annex
7684 should provide the child package @code{Interfaces.Fortran} (respectively,
7685 @code{Interfaces.C}) specified in Annex B and should support a
7686 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7687 pragmas (see Annex B), thus allowing Ada programs to interface with
7688 programs written in that language.
7689 @end cartouche
7690 Followed.
7692 @cindex Complex types
7693 @unnumberedsec G.1.1(56-58): Complex Types
7694 @sp 2
7695 @cartouche
7696 Because the usual mathematical meaning of multiplication of a complex
7697 operand and a real operand is that of the scaling of both components of
7698 the former by the latter, an implementation should not perform this
7699 operation by first promoting the real operand to complex type and then
7700 performing a full complex multiplication.  In systems that, in the
7701 future, support an Ada binding to IEC 559:1989, the latter technique
7702 will not generate the required result when one of the components of the
7703 complex operand is infinite.  (Explicit multiplication of the infinite
7704 component by the zero component obtained during promotion yields a NaN
7705 that propagates into the final result.) Analogous advice applies in the
7706 case of multiplication of a complex operand and a pure-imaginary
7707 operand, and in the case of division of a complex operand by a real or
7708 pure-imaginary operand.
7709 @end cartouche
7710 Not followed.
7712 @sp 1
7713 @cartouche
7714 Similarly, because the usual mathematical meaning of addition of a
7715 complex operand and a real operand is that the imaginary operand remains
7716 unchanged, an implementation should not perform this operation by first
7717 promoting the real operand to complex type and then performing a full
7718 complex addition.  In implementations in which the @code{Signed_Zeros}
7719 attribute of the component type is @code{True} (and which therefore
7720 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7721 predefined arithmetic operations), the latter technique will not
7722 generate the required result when the imaginary component of the complex
7723 operand is a negatively signed zero.  (Explicit addition of the negative
7724 zero to the zero obtained during promotion yields a positive zero.)
7725 Analogous advice applies in the case of addition of a complex operand
7726 and a pure-imaginary operand, and in the case of subtraction of a
7727 complex operand and a real or pure-imaginary operand.
7728 @end cartouche
7729 Not followed.
7731 @sp 1
7732 @cartouche
7733 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7734 attempt to provide a rational treatment of the signs of zero results and
7735 result components.  As one example, the result of the @code{Argument}
7736 function should have the sign of the imaginary component of the
7737 parameter @code{X} when the point represented by that parameter lies on
7738 the positive real axis; as another, the sign of the imaginary component
7739 of the @code{Compose_From_Polar} function should be the same as
7740 (respectively, the opposite of) that of the @code{Argument} parameter when that
7741 parameter has a value of zero and the @code{Modulus} parameter has a
7742 nonnegative (respectively, negative) value.
7743 @end cartouche
7744 Followed.
7746 @cindex Complex elementary functions
7747 @unnumberedsec G.1.2(49): Complex Elementary Functions
7748 @sp 1
7749 @cartouche
7750 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7751 @code{True} should attempt to provide a rational treatment of the signs
7752 of zero results and result components.  For example, many of the complex
7753 elementary functions have components that are odd functions of one of
7754 the parameter components; in these cases, the result component should
7755 have the sign of the parameter component at the origin.  Other complex
7756 elementary functions have zero components whose sign is opposite that of
7757 a parameter component at the origin, or is always positive or always
7758 negative.
7759 @end cartouche
7760 Followed.
7762 @cindex Accuracy requirements
7763 @unnumberedsec G.2.4(19): Accuracy Requirements
7764 @sp 1
7765 @cartouche
7766 The versions of the forward trigonometric functions without a
7767 @code{Cycle} parameter should not be implemented by calling the
7768 corresponding version with a @code{Cycle} parameter of
7769 @code{2.0*Numerics.Pi}, since this will not provide the required
7770 accuracy in some portions of the domain.  For the same reason, the
7771 version of @code{Log} without a @code{Base} parameter should not be
7772 implemented by calling the corresponding version with a @code{Base}
7773 parameter of @code{Numerics.e}.
7774 @end cartouche
7775 Followed.
7777 @cindex Complex arithmetic accuracy
7778 @cindex Accuracy, complex arithmetic
7779 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7781 @sp 1
7782 @cartouche
7783 The version of the @code{Compose_From_Polar} function without a
7784 @code{Cycle} parameter should not be implemented by calling the
7785 corresponding version with a @code{Cycle} parameter of
7786 @code{2.0*Numerics.Pi}, since this will not provide the required
7787 accuracy in some portions of the domain.
7788 @end cartouche
7789 Followed.
7791 @c -----------------------------------------
7792 @node Implementation Defined Characteristics
7793 @chapter Implementation Defined Characteristics
7795 @noindent
7796 In addition to the implementation dependent pragmas and attributes, and
7797 the implementation advice, there are a number of other Ada features
7798 that are potentially implementation dependent.  These are mentioned
7799 throughout the Ada Reference Manual, and are summarized in Annex M@.
7801 A requirement for conforming Ada compilers is that they provide
7802 documentation describing how the implementation deals with each of these
7803 issues.  In this chapter, you will find each point in Annex M listed
7804 followed by a description in italic font of how GNAT
7805 @c SGI info:
7806 @ignore
7807 in the ProDev Ada
7808 implementation on IRIX 5.3 operating system or greater
7809 @end ignore
7810 handles the implementation dependence.
7812 You can use this chapter as a guide to minimizing implementation
7813 dependent features in your programs if portability to other compilers
7814 and other operating systems is an important consideration.  The numbers
7815 in each section below correspond to the paragraph number in the Ada
7816 Reference Manual.
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{2}.  Whether or not each recommendation given in Implementation
7822 Advice is followed.  See 1.1.2(37).
7823 @end cartouche
7824 @noindent
7825 @xref{Implementation Advice}.
7827 @sp 1
7828 @cartouche
7829 @noindent
7830 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7831 @end cartouche
7832 @noindent
7833 The complexity of programs that can be processed is limited only by the
7834 total amount of available virtual memory, and disk space for the
7835 generated object files.
7837 @sp 1
7838 @cartouche
7839 @noindent
7840 @strong{4}.  Variations from the standard that are impractical to avoid
7841 given the implementation's execution environment.  See 1.1.3(6).
7842 @end cartouche
7843 @noindent
7844 There are no variations from the standard.
7846 @sp 1
7847 @cartouche
7848 @noindent
7849 @strong{5}.  Which @code{code_statement}s cause external
7850 interactions.  See 1.1.3(10).
7851 @end cartouche
7852 @noindent
7853 Any @code{code_statement} can potentially cause external interactions.
7855 @sp 1
7856 @cartouche
7857 @noindent
7858 @strong{6}.  The coded representation for the text of an Ada
7859 program.  See 2.1(4).
7860 @end cartouche
7861 @noindent
7862 See separate section on source representation.
7864 @sp 1
7865 @cartouche
7866 @noindent
7867 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7868 @end cartouche
7869 @noindent
7870 See separate section on source representation.
7872 @sp 1
7873 @cartouche
7874 @noindent
7875 @strong{8}.  The representation for an end of line.  See 2.2(2).
7876 @end cartouche
7877 @noindent
7878 See separate section on source representation.
7880 @sp 1
7881 @cartouche
7882 @noindent
7883 @strong{9}.  Maximum supported line length and lexical element
7884 length.  See 2.2(15).
7885 @end cartouche
7886 @noindent
7887 The maximum line length is 255 characters and the maximum length of a
7888 lexical element is also 255 characters.
7890 @sp 1
7891 @cartouche
7892 @noindent
7893 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7894 @end cartouche
7895 @noindent
7897 @xref{Implementation Defined Pragmas}.
7899 @sp 1
7900 @cartouche
7901 @noindent
7902 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7903 @end cartouche
7904 @noindent
7905 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7906 parameter, checks that the optimization flag is set, and aborts if it is
7907 not.
7909 @sp 1
7910 @cartouche
7911 @noindent
7912 @strong{12}.  The sequence of characters of the value returned by
7913 @code{@var{S}'Image} when some of the graphic characters of
7914 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7915 3.5(37).
7916 @end cartouche
7917 @noindent
7918 The sequence of characters is as defined by the wide character encoding
7919 method used for the source.  See section on source representation for
7920 further details.
7922 @sp 1
7923 @cartouche
7924 @noindent
7925 @strong{13}.  The predefined integer types declared in
7926 @code{Standard}.  See 3.5.4(25).
7927 @end cartouche
7928 @noindent
7929 @table @code
7930 @item Short_Short_Integer
7931 8 bit signed
7932 @item Short_Integer
7933 (Short) 16 bit signed
7934 @item Integer
7935 32 bit signed
7936 @item Long_Integer
7937 64 bit signed (Alpha OpenVMS only)
7938 32 bit signed (all other targets)
7939 @item Long_Long_Integer
7940 64 bit signed
7941 @end table
7943 @sp 1
7944 @cartouche
7945 @noindent
7946 @strong{14}.  Any nonstandard integer types and the operators defined
7947 for them.  See 3.5.4(26).
7948 @end cartouche
7949 @noindent
7950 There are no nonstandard integer types.
7952 @sp 1
7953 @cartouche
7954 @noindent
7955 @strong{15}.  Any nonstandard real types and the operators defined for
7956 them.  See 3.5.6(8).
7957 @end cartouche
7958 @noindent
7959 There are no nonstandard real types.
7961 @sp 1
7962 @cartouche
7963 @noindent
7964 @strong{16}.  What combinations of requested decimal precision and range
7965 are supported for floating point types.  See 3.5.7(7).
7966 @end cartouche
7967 @noindent
7968 The precision and range is as defined by the IEEE standard.
7970 @sp 1
7971 @cartouche
7972 @noindent
7973 @strong{17}.  The predefined floating point types declared in
7974 @code{Standard}.  See 3.5.7(16).
7975 @end cartouche
7976 @noindent
7977 @table @code
7978 @item Short_Float
7979 32 bit IEEE short
7980 @item Float
7981 (Short) 32 bit IEEE short
7982 @item Long_Float
7983 64 bit IEEE long
7984 @item Long_Long_Float
7985 64 bit IEEE long (80 bit IEEE long on x86 processors)
7986 @end table
7988 @sp 1
7989 @cartouche
7990 @noindent
7991 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7992 @end cartouche
7993 @noindent
7994 @code{Fine_Delta} is 2**(@minus{}63)
7996 @sp 1
7997 @cartouche
7998 @noindent
7999 @strong{19}.  What combinations of small, range, and digits are
8000 supported for fixed point types.  See 3.5.9(10).
8001 @end cartouche
8002 @noindent
8003 Any combinations are permitted that do not result in a small less than
8004 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8005 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8006 is 64 bits (true of all architectures except ia32), then the output from
8007 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
8008 is because floating-point conversions are used to convert fixed point.
8010 @sp 1
8011 @cartouche
8012 @noindent
8013 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
8014 within an unnamed @code{block_statement}.  See 3.9(10).
8015 @end cartouche
8016 @noindent
8017 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8018 decimal integer are allocated.
8020 @sp 1
8021 @cartouche
8022 @noindent
8023 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
8024 @end cartouche
8025 @noindent
8026 @xref{Implementation Defined Attributes}.
8028 @sp 1
8029 @cartouche
8030 @noindent
8031 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
8032 @end cartouche
8033 @noindent
8034 There are no implementation-defined time types.
8036 @sp 1
8037 @cartouche
8038 @noindent
8039 @strong{23}.  The time base associated with relative delays.
8040 @end cartouche
8041 @noindent
8042 See 9.6(20).  The time base used is that provided by the C library
8043 function @code{gettimeofday}.
8045 @sp 1
8046 @cartouche
8047 @noindent
8048 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
8049 9.6(23).
8050 @end cartouche
8051 @noindent
8052 The time base used is that provided by the C library function
8053 @code{gettimeofday}.
8055 @sp 1
8056 @cartouche
8057 @noindent
8058 @strong{25}.  The time zone used for package @code{Calendar}
8059 operations.  See 9.6(24).
8060 @end cartouche
8061 @noindent
8062 The time zone used by package @code{Calendar} is the current system time zone
8063 setting for local time, as accessed by the C library function
8064 @code{localtime}.
8066 @sp 1
8067 @cartouche
8068 @noindent
8069 @strong{26}.  Any limit on @code{delay_until_statements} of
8070 @code{select_statements}.  See 9.6(29).
8071 @end cartouche
8072 @noindent
8073 There are no such limits.
8075 @sp 1
8076 @cartouche
8077 @noindent
8078 @strong{27}.  Whether or not two non-overlapping parts of a composite
8079 object are independently addressable, in the case where packing, record
8080 layout, or @code{Component_Size} is specified for the object.  See
8081 9.10(1).
8082 @end cartouche
8083 @noindent
8084 Separate components are independently addressable if they do not share
8085 overlapping storage units.
8087 @sp 1
8088 @cartouche
8089 @noindent
8090 @strong{28}.  The representation for a compilation.  See 10.1(2).
8091 @end cartouche
8092 @noindent
8093 A compilation is represented by a sequence of files presented to the
8094 compiler in a single invocation of the @command{gcc} command.
8096 @sp 1
8097 @cartouche
8098 @noindent
8099 @strong{29}.  Any restrictions on compilations that contain multiple
8100 compilation_units.  See 10.1(4).
8101 @end cartouche
8102 @noindent
8103 No single file can contain more than one compilation unit, but any
8104 sequence of files can be presented to the compiler as a single
8105 compilation.
8107 @sp 1
8108 @cartouche
8109 @noindent
8110 @strong{30}.  The mechanisms for creating an environment and for adding
8111 and replacing compilation units.  See 10.1.4(3).
8112 @end cartouche
8113 @noindent
8114 See separate section on compilation model.
8116 @sp 1
8117 @cartouche
8118 @noindent
8119 @strong{31}.  The manner of explicitly assigning library units to a
8120 partition.  See 10.2(2).
8121 @end cartouche
8122 @noindent
8123 If a unit contains an Ada main program, then the Ada units for the partition
8124 are determined by recursive application of the rules in the Ada Reference
8125 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8126 are needed by the main program, and then this definition of need is applied
8127 recursively to those units, and the partition contains the transitive
8128 closure determined by this relationship.  In short, all the necessary units
8129 are included, with no need to explicitly specify the list.  If additional
8130 units are required, e.g.@: by foreign language units, then all units must be
8131 mentioned in the context clause of one of the needed Ada units.
8133 If the partition contains no main program, or if the main program is in
8134 a language other than Ada, then GNAT
8135 provides the binder options @option{-z} and @option{-n} respectively, and in
8136 this case a list of units can be explicitly supplied to the binder for
8137 inclusion in the partition (all units needed by these units will also
8138 be included automatically).  For full details on the use of these
8139 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8140 @value{EDITION} User's Guide}.
8142 @sp 1
8143 @cartouche
8144 @noindent
8145 @strong{32}.  The implementation-defined means, if any, of specifying
8146 which compilation units are needed by a given compilation unit.  See
8147 10.2(2).
8148 @end cartouche
8149 @noindent
8150 The units needed by a given compilation unit are as defined in
8151 the Ada Reference Manual section 10.2(2-6).  There are no
8152 implementation-defined pragmas or other implementation-defined
8153 means for specifying needed units.
8155 @sp 1
8156 @cartouche
8157 @noindent
8158 @strong{33}.  The manner of designating the main subprogram of a
8159 partition.  See 10.2(7).
8160 @end cartouche
8161 @noindent
8162 The main program is designated by providing the name of the
8163 corresponding @file{ALI} file as the input parameter to the binder.
8165 @sp 1
8166 @cartouche
8167 @noindent
8168 @strong{34}.  The order of elaboration of @code{library_items}.  See
8169 10.2(18).
8170 @end cartouche
8171 @noindent
8172 The first constraint on ordering is that it meets the requirements of
8173 Chapter 10 of the Ada Reference Manual.  This still leaves some
8174 implementation dependent choices, which are resolved by first
8175 elaborating bodies as early as possible (i.e., in preference to specs
8176 where there is a choice), and second by evaluating the immediate with
8177 clauses of a unit to determine the probably best choice, and
8178 third by elaborating in alphabetical order of unit names
8179 where a choice still remains.
8181 @sp 1
8182 @cartouche
8183 @noindent
8184 @strong{35}.  Parameter passing and function return for the main
8185 subprogram.  See 10.2(21).
8186 @end cartouche
8187 @noindent
8188 The main program has no parameters.  It may be a procedure, or a function
8189 returning an integer type.  In the latter case, the returned integer
8190 value is the return code of the program (overriding any value that
8191 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8193 @sp 1
8194 @cartouche
8195 @noindent
8196 @strong{36}.  The mechanisms for building and running partitions.  See
8197 10.2(24).
8198 @end cartouche
8199 @noindent
8200 GNAT itself supports programs with only a single partition.  The GNATDIST
8201 tool provided with the GLADE package (which also includes an implementation
8202 of the PCS) provides a completely flexible method for building and running
8203 programs consisting of multiple partitions.  See the separate GLADE manual
8204 for details.
8206 @sp 1
8207 @cartouche
8208 @noindent
8209 @strong{37}.  The details of program execution, including program
8210 termination.  See 10.2(25).
8211 @end cartouche
8212 @noindent
8213 See separate section on compilation model.
8215 @sp 1
8216 @cartouche
8217 @noindent
8218 @strong{38}.  The semantics of any non-active partitions supported by the
8219 implementation.  See 10.2(28).
8220 @end cartouche
8221 @noindent
8222 Passive partitions are supported on targets where shared memory is
8223 provided by the operating system.  See the GLADE reference manual for
8224 further details.
8226 @sp 1
8227 @cartouche
8228 @noindent
8229 @strong{39}.  The information returned by @code{Exception_Message}.  See
8230 11.4.1(10).
8231 @end cartouche
8232 @noindent
8233 Exception message returns the null string unless a specific message has
8234 been passed by the program.
8236 @sp 1
8237 @cartouche
8238 @noindent
8239 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8240 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8241 @end cartouche
8242 @noindent
8243 Blocks have implementation defined names of the form @code{B@var{nnn}}
8244 where @var{nnn} is an integer.
8246 @sp 1
8247 @cartouche
8248 @noindent
8249 @strong{41}.  The information returned by
8250 @code{Exception_Information}.  See 11.4.1(13).
8251 @end cartouche
8252 @noindent
8253 @code{Exception_Information} returns a string in the following format:
8255 @smallexample
8256 @emph{Exception_Name:} nnnnn
8257 @emph{Message:} mmmmm
8258 @emph{PID:} ppp
8259 @emph{Call stack traceback locations:}
8260 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8261 @end smallexample
8263 @noindent
8264 where
8266 @itemize @bullet
8267 @item
8268 @code{nnnn} is the fully qualified name of the exception in all upper
8269 case letters. This line is always present.
8271 @item
8272 @code{mmmm} is the message (this line present only if message is non-null)
8274 @item
8275 @code{ppp} is the Process Id value as a decimal integer (this line is
8276 present only if the Process Id is nonzero). Currently we are
8277 not making use of this field.
8279 @item
8280 The Call stack traceback locations line and the following values
8281 are present only if at least one traceback location was recorded.
8282 The values are given in C style format, with lower case letters
8283 for a-f, and only as many digits present as are necessary.
8284 @end itemize
8286 @noindent
8287 The line terminator sequence at the end of each line, including
8288 the last line is a single @code{LF} character (@code{16#0A#}).
8290 @sp 1
8291 @cartouche
8292 @noindent
8293 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8294 @end cartouche
8295 @noindent
8296 The implementation defined check name Alignment_Check controls checking of
8297 address clause values for proper alignment (that is, the address supplied
8298 must be consistent with the alignment of the type).
8300 In addition, a user program can add implementation-defined check names
8301 by means of the pragma Check_Name.
8303 @sp 1
8304 @cartouche
8305 @noindent
8306 @strong{43}.  The interpretation of each aspect of representation.  See
8307 13.1(20).
8308 @end cartouche
8309 @noindent
8310 See separate section on data representations.
8312 @sp 1
8313 @cartouche
8314 @noindent
8315 @strong{44}.  Any restrictions placed upon representation items.  See
8316 13.1(20).
8317 @end cartouche
8318 @noindent
8319 See separate section on data representations.
8321 @sp 1
8322 @cartouche
8323 @noindent
8324 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8325 13.3(48).
8326 @end cartouche
8327 @noindent
8328 Size for an indefinite subtype is the maximum possible size, except that
8329 for the case of a subprogram parameter, the size of the parameter object
8330 is the actual size.
8332 @sp 1
8333 @cartouche
8334 @noindent
8335 @strong{46}.  The default external representation for a type tag.  See
8336 13.3(75).
8337 @end cartouche
8338 @noindent
8339 The default external representation for a type tag is the fully expanded
8340 name of the type in upper case letters.
8342 @sp 1
8343 @cartouche
8344 @noindent
8345 @strong{47}.  What determines whether a compilation unit is the same in
8346 two different partitions.  See 13.3(76).
8347 @end cartouche
8348 @noindent
8349 A compilation unit is the same in two different partitions if and only
8350 if it derives from the same source file.
8352 @sp 1
8353 @cartouche
8354 @noindent
8355 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8356 @end cartouche
8357 @noindent
8358 The only implementation defined component is the tag for a tagged type,
8359 which contains a pointer to the dispatching table.
8361 @sp 1
8362 @cartouche
8363 @noindent
8364 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8365 ordering.  See 13.5.3(5).
8366 @end cartouche
8367 @noindent
8368 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8369 implementation, so no non-default bit ordering is supported.  The default
8370 bit ordering corresponds to the natural endianness of the target architecture.
8372 @sp 1
8373 @cartouche
8374 @noindent
8375 @strong{50}.  The contents of the visible part of package @code{System}
8376 and its language-defined children.  See 13.7(2).
8377 @end cartouche
8378 @noindent
8379 See the definition of these packages in files @file{system.ads} and
8380 @file{s-stoele.ads}.
8382 @sp 1
8383 @cartouche
8384 @noindent
8385 @strong{51}.  The contents of the visible part of package
8386 @code{System.Machine_Code}, and the meaning of
8387 @code{code_statements}.  See 13.8(7).
8388 @end cartouche
8389 @noindent
8390 See the definition and documentation in file @file{s-maccod.ads}.
8392 @sp 1
8393 @cartouche
8394 @noindent
8395 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8396 @end cartouche
8397 @noindent
8398 Unchecked conversion between types of the same size
8399 results in an uninterpreted transmission of the bits from one type
8400 to the other.  If the types are of unequal sizes, then in the case of
8401 discrete types, a shorter source is first zero or sign extended as
8402 necessary, and a shorter target is simply truncated on the left.
8403 For all non-discrete types, the source is first copied if necessary
8404 to ensure that the alignment requirements of the target are met, then
8405 a pointer is constructed to the source value, and the result is obtained
8406 by dereferencing this pointer after converting it to be a pointer to the
8407 target type. Unchecked conversions where the target subtype is an
8408 unconstrained array are not permitted. If the target alignment is
8409 greater than the source alignment, then a copy of the result is
8410 made with appropriate alignment
8412 @sp 1
8413 @cartouche
8414 @noindent
8415 @strong{53}.  The manner of choosing a storage pool for an access type
8416 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8417 @end cartouche
8418 @noindent
8419 There are 3 different standard pools used by the compiler when
8420 @code{Storage_Pool} is not specified depending whether the type is local
8421 to a subprogram or defined at the library level and whether
8422 @code{Storage_Size}is specified or not.  See documentation in the runtime
8423 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8424 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8425 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8426 default pools used.
8428 @sp 1
8429 @cartouche
8430 @noindent
8431 @strong{54}.  Whether or not the implementation provides user-accessible
8432 names for the standard pool type(s).  See 13.11(17).
8433 @end cartouche
8434 @noindent
8436 See documentation in the sources of the run time mentioned in paragraph
8437 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8438 these units.
8440 @sp 1
8441 @cartouche
8442 @noindent
8443 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8444 @end cartouche
8445 @noindent
8446 @code{Storage_Size} is measured in storage units, and refers to the
8447 total space available for an access type collection, or to the primary
8448 stack space for a task.
8450 @sp 1
8451 @cartouche
8452 @noindent
8453 @strong{56}.  Implementation-defined aspects of storage pools.  See
8454 13.11(22).
8455 @end cartouche
8456 @noindent
8457 See documentation in the sources of the run time mentioned in paragraph
8458 @strong{53} for details on GNAT-defined aspects of storage pools.
8460 @sp 1
8461 @cartouche
8462 @noindent
8463 @strong{57}.  The set of restrictions allowed in a pragma
8464 @code{Restrictions}.  See 13.12(7).
8465 @end cartouche
8466 @noindent
8467 All RM defined Restriction identifiers are implemented.  The following
8468 additional restriction identifiers are provided.  There are two separate
8469 lists of implementation dependent restriction identifiers.  The first
8470 set requires consistency throughout a partition (in other words, if the
8471 restriction identifier is used for any compilation unit in the partition,
8472 then all compilation units in the partition must obey the restriction.
8474 @table @code
8476 @item Simple_Barriers
8477 @findex Simple_Barriers
8478 This restriction ensures at compile time that barriers in entry declarations
8479 for protected types are restricted to either static boolean expressions or
8480 references to simple boolean variables defined in the private part of the
8481 protected type.  No other form of entry barriers is permitted.  This is one
8482 of the restrictions of the Ravenscar profile for limited tasking (see also
8483 pragma @code{Profile (Ravenscar)}).
8485 @item Max_Entry_Queue_Length => Expr
8486 @findex Max_Entry_Queue_Length
8487 This restriction is a declaration that any protected entry compiled in
8488 the scope of the restriction has at most the specified number of
8489 tasks waiting on the entry
8490 at any one time, and so no queue is required.  This restriction is not
8491 checked at compile time.  A program execution is erroneous if an attempt
8492 is made to queue more than the specified number of tasks on such an entry.
8494 @item No_Calendar
8495 @findex No_Calendar
8496 This restriction ensures at compile time that there is no implicit or
8497 explicit dependence on the package @code{Ada.Calendar}.
8499 @item No_Default_Initialization
8500 @findex No_Default_Initialization
8502 This restriction prohibits any instance of default initialization of variables.
8503 The binder implements a consistency rule which prevents any unit compiled
8504 without the restriction from with'ing a unit with the restriction (this allows
8505 the generation of initialization procedures to be skipped, since you can be
8506 sure that no call is ever generated to an initialization procedure in a unit
8507 with the restriction active). If used in conjunction with Initialize_Scalars or
8508 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8509 without a specific initializer (including the case of OUT scalar parameters).
8511 @item No_Direct_Boolean_Operators
8512 @findex No_Direct_Boolean_Operators
8513 This restriction ensures that no logical (and/or/xor) are used on
8514 operands of type Boolean (or any type derived
8515 from Boolean). This is intended for use in safety critical programs
8516 where the certification protocol requires the use of short-circuit
8517 (and then, or else) forms for all composite boolean operations.
8519 @item No_Dispatching_Calls
8520 @findex No_Dispatching_Calls
8521 This restriction ensures at compile time that the code generated by the
8522 compiler involves no dispatching calls. The use of this restriction allows the
8523 safe use of record extensions, classwide membership tests and other classwide
8524 features not involving implicit dispatching. This restriction ensures that
8525 the code contains no indirect calls through a dispatching mechanism. Note that
8526 this includes internally-generated calls created by the compiler, for example
8527 in the implementation of class-wide objects assignments. The
8528 membership test is allowed in the presence of this restriction, because its
8529 implementation requires no dispatching.
8530 This restriction is comparable to the official Ada restriction
8531 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8532 all classwide constructs that do not imply dispatching.
8533 The following example indicates constructs that violate this restriction.
8535 @smallexample
8536 package Pkg is
8537   type T is tagged record
8538     Data : Natural;
8539   end record;
8540   procedure P (X : T);
8542   type DT is new T with record
8543     More_Data : Natural;
8544   end record;
8545   procedure Q (X : DT);
8546 end Pkg;
8548 with Pkg; use Pkg;
8549 procedure Example is
8550   procedure Test (O : T'Class) is
8551     N : Natural  := O'Size;--  Error: Dispatching call
8552     C : T'Class := O;      --  Error: implicit Dispatching Call
8553   begin
8554     if O in DT'Class then  --  OK   : Membership test
8555        Q (DT (O));         --  OK   : Type conversion plus direct call
8556     else
8557        P (O);              --  Error: Dispatching call
8558     end if;
8559   end Test;
8561   Obj : DT;
8562 begin
8563   P (Obj);                 --  OK   : Direct call
8564   P (T (Obj));             --  OK   : Type conversion plus direct call
8565   P (T'Class (Obj));       --  Error: Dispatching call
8567   Test (Obj);              --  OK   : Type conversion
8569   if Obj in T'Class then   --  OK   : Membership test
8570      null;
8571   end if;
8572 end Example;
8573 @end smallexample
8575 @item No_Dynamic_Attachment
8576 @findex No_Dynamic_Attachment
8577 This restriction ensures that there is no call to any of the operations
8578 defined in package Ada.Interrupts.
8580 @item No_Enumeration_Maps
8581 @findex No_Enumeration_Maps
8582 This restriction ensures at compile time that no operations requiring
8583 enumeration maps are used (that is Image and Value attributes applied
8584 to enumeration types).
8586 @item No_Entry_Calls_In_Elaboration_Code
8587 @findex No_Entry_Calls_In_Elaboration_Code
8588 This restriction ensures at compile time that no task or protected entry
8589 calls are made during elaboration code.  As a result of the use of this
8590 restriction, the compiler can assume that no code past an accept statement
8591 in a task can be executed at elaboration time.
8593 @item No_Exception_Handlers
8594 @findex No_Exception_Handlers
8595 This restriction ensures at compile time that there are no explicit
8596 exception handlers. It also indicates that no exception propagation will
8597 be provided. In this mode, exceptions may be raised but will result in
8598 an immediate call to the last chance handler, a routine that the user
8599 must define with the following profile:
8601 @smallexample @c ada
8602 procedure Last_Chance_Handler
8603   (Source_Location : System.Address; Line : Integer);
8604 pragma Export (C, Last_Chance_Handler,
8605                "__gnat_last_chance_handler");
8606 @end smallexample
8608 The parameter is a C null-terminated string representing a message to be
8609 associated with the exception (typically the source location of the raise
8610 statement generated by the compiler). The Line parameter when nonzero
8611 represents the line number in the source program where the raise occurs.
8613 @item No_Exception_Propagation
8614 @findex No_Exception_Propagation
8615 This restriction guarantees that exceptions are never propagated to an outer
8616 subprogram scope). The only case in which an exception may be raised is when
8617 the handler is statically in the same subprogram, so that the effect of a raise
8618 is essentially like a goto statement. Any other raise statement (implicit or
8619 explicit) will be considered unhandled. Exception handlers are allowed, but may
8620 not contain an exception occurrence identifier (exception choice). In addition
8621 use of the package GNAT.Current_Exception is not permitted, and reraise
8622 statements (raise with no operand) are not permitted.
8624 @item No_Exception_Registration
8625 @findex No_Exception_Registration
8626 This restriction ensures at compile time that no stream operations for
8627 types Exception_Id or Exception_Occurrence are used. This also makes it
8628 impossible to pass exceptions to or from a partition with this restriction
8629 in a distributed environment. If this exception is active, then the generated
8630 code is simplified by omitting the otherwise-required global registration
8631 of exceptions when they are declared.
8633 @item No_Implicit_Conditionals
8634 @findex No_Implicit_Conditionals
8635 This restriction ensures that the generated code does not contain any
8636 implicit conditionals, either by modifying the generated code where possible,
8637 or by rejecting any construct that would otherwise generate an implicit
8638 conditional. Note that this check does not include run time constraint
8639 checks, which on some targets may generate implicit conditionals as
8640 well. To control the latter, constraint checks can be suppressed in the
8641 normal manner. Constructs generating implicit conditionals include comparisons
8642 of composite objects and the Max/Min attributes.
8644 @item No_Implicit_Dynamic_Code
8645 @findex No_Implicit_Dynamic_Code
8646 @cindex trampoline
8647 This restriction prevents the compiler from building ``trampolines''.
8648 This is a structure that is built on the stack and contains dynamic
8649 code to be executed at run time. On some targets, a trampoline is
8650 built for the following features: @code{Access},
8651 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8652 nested task bodies; primitive operations of nested tagged types.
8653 Trampolines do not work on machines that prevent execution of stack
8654 data. For example, on windows systems, enabling DEP (data execution
8655 protection) will cause trampolines to raise an exception.
8656 Trampolines are also quite slow at run time.
8658 On many targets, trampolines have been largely eliminated. Look at the
8659 version of system.ads for your target --- if it has
8660 Always_Compatible_Rep equal to False, then trampolines are largely
8661 eliminated. In particular, a trampoline is built for the following
8662 features: @code{Address} of a nested subprogram;
8663 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8664 but only if pragma Favor_Top_Level applies, or the access type has a
8665 foreign-language convention; primitive operations of nested tagged
8666 types.
8668 @item No_Implicit_Loops
8669 @findex No_Implicit_Loops
8670 This restriction ensures that the generated code does not contain any
8671 implicit @code{for} loops, either by modifying
8672 the generated code where possible,
8673 or by rejecting any construct that would otherwise generate an implicit
8674 @code{for} loop. If this restriction is active, it is possible to build
8675 large array aggregates with all static components without generating an
8676 intermediate temporary, and without generating a loop to initialize individual
8677 components. Otherwise, a loop is created for arrays larger than about 5000
8678 scalar components.
8680 @item No_Initialize_Scalars
8681 @findex No_Initialize_Scalars
8682 This restriction ensures that no unit in the partition is compiled with
8683 pragma Initialize_Scalars. This allows the generation of more efficient
8684 code, and in particular eliminates dummy null initialization routines that
8685 are otherwise generated for some record and array types.
8687 @item No_Local_Protected_Objects
8688 @findex No_Local_Protected_Objects
8689 This restriction ensures at compile time that protected objects are
8690 only declared at the library level.
8692 @item No_Protected_Type_Allocators
8693 @findex No_Protected_Type_Allocators
8694 This restriction ensures at compile time that there are no allocator
8695 expressions that attempt to allocate protected objects.
8697 @item No_Secondary_Stack
8698 @findex No_Secondary_Stack
8699 This restriction ensures at compile time that the generated code does not
8700 contain any reference to the secondary stack.  The secondary stack is used
8701 to implement functions returning unconstrained objects (arrays or records)
8702 on some targets.
8704 @item No_Select_Statements
8705 @findex No_Select_Statements
8706 This restriction ensures at compile time no select statements of any kind
8707 are permitted, that is the keyword @code{select} may not appear.
8708 This is one of the restrictions of the Ravenscar
8709 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8711 @item No_Standard_Storage_Pools
8712 @findex No_Standard_Storage_Pools
8713 This restriction ensures at compile time that no access types
8714 use the standard default storage pool.  Any access type declared must
8715 have an explicit Storage_Pool attribute defined specifying a
8716 user-defined storage pool.
8718 @item No_Streams
8719 @findex No_Streams
8720 This restriction ensures at compile/bind time that there are no
8721 stream objects created and no use of stream attributes.
8722 This restriction does not forbid dependences on the package
8723 @code{Ada.Streams}. So it is permissible to with
8724 @code{Ada.Streams} (or another package that does so itself)
8725 as long as no actual stream objects are created and no
8726 stream attributes are used.
8728 Note that the use of restriction allows optimization of tagged types,
8729 since they do not need to worry about dispatching stream operations.
8730 To take maximum advantage of this space-saving optimization, any
8731 unit declaring a tagged type should be compiled with the restriction,
8732 though this is not required.
8734 @item No_Task_Attributes_Package
8735 @findex No_Task_Attributes_Package
8736 This restriction ensures at compile time that there are no implicit or
8737 explicit dependencies on the package @code{Ada.Task_Attributes}.
8739 @item No_Task_Termination
8740 @findex No_Task_Termination
8741 This restriction ensures at compile time that no terminate alternatives
8742 appear in any task body.
8744 @item No_Tasking
8745 @findex No_Tasking
8746 This restriction prevents the declaration of tasks or task types throughout
8747 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8748 except that violations are caught at compile time and cause an error message
8749 to be output either by the compiler or binder.
8751 @item Static_Priorities
8752 @findex Static_Priorities
8753 This restriction ensures at compile time that all priority expressions
8754 are static, and that there are no dependencies on the package
8755 @code{Ada.Dynamic_Priorities}.
8757 @item Static_Storage_Size
8758 @findex Static_Storage_Size
8759 This restriction ensures at compile time that any expression appearing
8760 in a Storage_Size pragma or attribute definition clause is static.
8762 @end table
8764 @noindent
8765 The second set of implementation dependent restriction identifiers
8766 does not require partition-wide consistency.
8767 The restriction may be enforced for a single
8768 compilation unit without any effect on any of the
8769 other compilation units in the partition.
8771 @table @code
8773 @item No_Elaboration_Code
8774 @findex No_Elaboration_Code
8775 This restriction ensures at compile time that no elaboration code is
8776 generated.  Note that this is not the same condition as is enforced
8777 by pragma @code{Preelaborate}.  There are cases in which pragma
8778 @code{Preelaborate} still permits code to be generated (e.g.@: code
8779 to initialize a large array to all zeroes), and there are cases of units
8780 which do not meet the requirements for pragma @code{Preelaborate},
8781 but for which no elaboration code is generated.  Generally, it is
8782 the case that preelaborable units will meet the restrictions, with
8783 the exception of large aggregates initialized with an others_clause,
8784 and exception declarations (which generate calls to a run-time
8785 registry procedure).  This restriction is enforced on
8786 a unit by unit basis, it need not be obeyed consistently
8787 throughout a partition.
8789 In the case of aggregates with others, if the aggregate has a dynamic
8790 size, there is no way to eliminate the elaboration code (such dynamic
8791 bounds would be incompatible with @code{Preelaborate} in any case). If
8792 the bounds are static, then use of this restriction actually modifies
8793 the code choice of the compiler to avoid generating a loop, and instead
8794 generate the aggregate statically if possible, no matter how many times
8795 the data for the others clause must be repeatedly generated.
8797 It is not possible to precisely document
8798 the constructs which are compatible with this restriction, since,
8799 unlike most other restrictions, this is not a restriction on the
8800 source code, but a restriction on the generated object code. For
8801 example, if the source contains a declaration:
8803 @smallexample
8804    Val : constant Integer := X;
8805 @end smallexample
8807 @noindent
8808 where X is not a static constant, it may be possible, depending
8809 on complex optimization circuitry, for the compiler to figure
8810 out the value of X at compile time, in which case this initialization
8811 can be done by the loader, and requires no initialization code. It
8812 is not possible to document the precise conditions under which the
8813 optimizer can figure this out.
8815 Note that this the implementation of this restriction requires full
8816 code generation. If it is used in conjunction with "semantics only"
8817 checking, then some cases of violations may be missed.
8819 @item No_Entry_Queue
8820 @findex No_Entry_Queue
8821 This restriction is a declaration that any protected entry compiled in
8822 the scope of the restriction has at most one task waiting on the entry
8823 at any one time, and so no queue is required.  This restriction is not
8824 checked at compile time.  A program execution is erroneous if an attempt
8825 is made to queue a second task on such an entry.
8827 @item No_Implementation_Attributes
8828 @findex No_Implementation_Attributes
8829 This restriction checks at compile time that no GNAT-defined attributes
8830 are present.  With this restriction, the only attributes that can be used
8831 are those defined in the Ada Reference Manual.
8833 @item No_Implementation_Pragmas
8834 @findex No_Implementation_Pragmas
8835 This restriction checks at compile time that no GNAT-defined pragmas
8836 are present.  With this restriction, the only pragmas that can be used
8837 are those defined in the Ada Reference Manual.
8839 @item No_Implementation_Restrictions
8840 @findex No_Implementation_Restrictions
8841 This restriction checks at compile time that no GNAT-defined restriction
8842 identifiers (other than @code{No_Implementation_Restrictions} itself)
8843 are present.  With this restriction, the only other restriction identifiers
8844 that can be used are those defined in the Ada Reference Manual.
8846 @item No_Wide_Characters
8847 @findex No_Wide_Characters
8848 This restriction ensures at compile time that no uses of the types
8849 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8850 wide types
8851 appear, and that no wide or wide wide string or character literals
8852 appear in the program (that is literals representing characters not in
8853 type @code{Character}.
8855 @end table
8857 @sp 1
8858 @cartouche
8859 @noindent
8860 @strong{58}.  The consequences of violating limitations on
8861 @code{Restrictions} pragmas.  See 13.12(9).
8862 @end cartouche
8863 @noindent
8864 Restrictions that can be checked at compile time result in illegalities
8865 if violated.  Currently there are no other consequences of violating
8866 restrictions.
8868 @sp 1
8869 @cartouche
8870 @noindent
8871 @strong{59}.  The representation used by the @code{Read} and
8872 @code{Write} attributes of elementary types in terms of stream
8873 elements.  See 13.13.2(9).
8874 @end cartouche
8875 @noindent
8876 The representation is the in-memory representation of the base type of
8877 the type, using the number of bits corresponding to the
8878 @code{@var{type}'Size} value, and the natural ordering of the machine.
8880 @sp 1
8881 @cartouche
8882 @noindent
8883 @strong{60}.  The names and characteristics of the numeric subtypes
8884 declared in the visible part of package @code{Standard}.  See A.1(3).
8885 @end cartouche
8886 @noindent
8887 See items describing the integer and floating-point types supported.
8889 @sp 1
8890 @cartouche
8891 @noindent
8892 @strong{61}.  The accuracy actually achieved by the elementary
8893 functions.  See A.5.1(1).
8894 @end cartouche
8895 @noindent
8896 The elementary functions correspond to the functions available in the C
8897 library.  Only fast math mode is implemented.
8899 @sp 1
8900 @cartouche
8901 @noindent
8902 @strong{62}.  The sign of a zero result from some of the operators or
8903 functions in @code{Numerics.Generic_Elementary_Functions}, when
8904 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8905 @end cartouche
8906 @noindent
8907 The sign of zeroes follows the requirements of the IEEE 754 standard on
8908 floating-point.
8910 @sp 1
8911 @cartouche
8912 @noindent
8913 @strong{63}.  The value of
8914 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8915 @end cartouche
8916 @noindent
8917 Maximum image width is 6864, see library file @file{s-rannum.ads}.
8919 @sp 1
8920 @cartouche
8921 @noindent
8922 @strong{64}.  The value of
8923 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8924 @end cartouche
8925 @noindent
8926 Maximum image width is 6864, see library file @file{s-rannum.ads}.
8928 @sp 1
8929 @cartouche
8930 @noindent
8931 @strong{65}.  The algorithms for random number generation.  See
8932 A.5.2(32).
8933 @end cartouche
8934 @noindent
8935 The algorithm is the Mersenne Twister, as documented in the source file
8936 @file{s-rannum.adb}. This version of the algorithm has a period of
8937 2**19937-1.
8939 @sp 1
8940 @cartouche
8941 @noindent
8942 @strong{66}.  The string representation of a random number generator's
8943 state.  See A.5.2(38).
8944 @end cartouche
8945 @noindent
8946 The value returned by the Image function is the concatenation of
8947 the fixed-width decimal representations of the 624 32-bit integers
8948 of the state vector.
8950 @sp 1
8951 @cartouche
8952 @noindent
8953 @strong{67}.  The minimum time interval between calls to the
8954 time-dependent Reset procedure that are guaranteed to initiate different
8955 random number sequences.  See A.5.2(45).
8956 @end cartouche
8957 @noindent
8958 The minimum period between reset calls to guarantee distinct series of
8959 random numbers is one microsecond.
8961 @sp 1
8962 @cartouche
8963 @noindent
8964 @strong{68}.  The values of the @code{Model_Mantissa},
8965 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8966 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8967 Annex is not supported.  See A.5.3(72).
8968 @end cartouche
8969 @noindent
8970 See the source file @file{ttypef.ads} for the values of all numeric
8971 attributes.
8973 @sp 1
8974 @cartouche
8975 @noindent
8976 @strong{69}.  Any implementation-defined characteristics of the
8977 input-output packages.  See A.7(14).
8978 @end cartouche
8979 @noindent
8980 There are no special implementation defined characteristics for these
8981 packages.
8983 @sp 1
8984 @cartouche
8985 @noindent
8986 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8987 A.9(10).
8988 @end cartouche
8989 @noindent
8990 All type representations are contiguous, and the @code{Buffer_Size} is
8991 the value of @code{@var{type}'Size} rounded up to the next storage unit
8992 boundary.
8994 @sp 1
8995 @cartouche
8996 @noindent
8997 @strong{71}.  External files for standard input, standard output, and
8998 standard error See A.10(5).
8999 @end cartouche
9000 @noindent
9001 These files are mapped onto the files provided by the C streams
9002 libraries.  See source file @file{i-cstrea.ads} for further details.
9004 @sp 1
9005 @cartouche
9006 @noindent
9007 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
9008 A.10.9(36).
9009 @end cartouche
9010 @noindent
9011 If more digits are requested in the output than are represented by the
9012 precision of the value, zeroes are output in the corresponding least
9013 significant digit positions.
9015 @sp 1
9016 @cartouche
9017 @noindent
9018 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
9019 @code{Command_Name}.  See A.15(1).
9020 @end cartouche
9021 @noindent
9022 These are mapped onto the @code{argv} and @code{argc} parameters of the
9023 main program in the natural manner.
9025 @sp 1
9026 @cartouche
9027 @noindent
9028 @strong{74}.  Implementation-defined convention names.  See B.1(11).
9029 @end cartouche
9030 @noindent
9031 The following convention names are supported
9033 @table @code
9034 @item  Ada
9036 @item Assembler
9037 Assembly language
9038 @item Asm
9039 Synonym for Assembler
9040 @item Assembly
9041 Synonym for Assembler
9042 @item C
9044 @item C_Pass_By_Copy
9045 Allowed only for record types, like C, but also notes that record
9046 is to be passed by copy rather than reference.
9047 @item COBOL
9048 COBOL
9049 @item C_Plus_Plus (or CPP)
9051 @item Default
9052 Treated the same as C
9053 @item External
9054 Treated the same as C
9055 @item Fortran
9056 Fortran
9057 @item Intrinsic
9058 For support of pragma @code{Import} with convention Intrinsic, see
9059 separate section on Intrinsic Subprograms.
9060 @item Stdcall
9061 Stdcall (used for Windows implementations only).  This convention correspond
9062 to the WINAPI (previously called Pascal convention) C/C++ convention under
9063 Windows.  A function with this convention cleans the stack before exit.
9064 @item DLL
9065 Synonym for Stdcall
9066 @item Win32
9067 Synonym for Stdcall
9068 @item Stubbed
9069 Stubbed is a special convention used to indicate that the body of the
9070 subprogram will be entirely ignored.  Any call to the subprogram
9071 is converted into a raise of the @code{Program_Error} exception.  If a
9072 pragma @code{Import} specifies convention @code{stubbed} then no body need
9073 be present at all.  This convention is useful during development for the
9074 inclusion of subprograms whose body has not yet been written.
9076 @end table
9077 @noindent
9078 In addition, all otherwise unrecognized convention names are also
9079 treated as being synonymous with convention C@.  In all implementations
9080 except for VMS, use of such other names results in a warning.  In VMS
9081 implementations, these names are accepted silently.
9083 @sp 1
9084 @cartouche
9085 @noindent
9086 @strong{75}.  The meaning of link names.  See B.1(36).
9087 @end cartouche
9088 @noindent
9089 Link names are the actual names used by the linker.
9091 @sp 1
9092 @cartouche
9093 @noindent
9094 @strong{76}.  The manner of choosing link names when neither the link
9095 name nor the address of an imported or exported entity is specified.  See
9096 B.1(36).
9097 @end cartouche
9098 @noindent
9099 The default linker name is that which would be assigned by the relevant
9100 external language, interpreting the Ada name as being in all lower case
9101 letters.
9103 @sp 1
9104 @cartouche
9105 @noindent
9106 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9107 @end cartouche
9108 @noindent
9109 The string passed to @code{Linker_Options} is presented uninterpreted as
9110 an argument to the link command, unless it contains ASCII.NUL characters.
9111 NUL characters if they appear act as argument separators, so for example
9113 @smallexample @c ada
9114 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9115 @end smallexample
9117 @noindent
9118 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9119 linker. The order of linker options is preserved for a given unit. The final
9120 list of options passed to the linker is in reverse order of the elaboration
9121 order. For example, linker options for a body always appear before the options
9122 from the corresponding package spec.
9124 @sp 1
9125 @cartouche
9126 @noindent
9127 @strong{78}.  The contents of the visible part of package
9128 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9129 @end cartouche
9130 @noindent
9131 See files with prefix @file{i-} in the distributed library.
9133 @sp 1
9134 @cartouche
9135 @noindent
9136 @strong{79}.  Implementation-defined children of package
9137 @code{Interfaces}.  The contents of the visible part of package
9138 @code{Interfaces}.  See B.2(11).
9139 @end cartouche
9140 @noindent
9141 See files with prefix @file{i-} in the distributed library.
9143 @sp 1
9144 @cartouche
9145 @noindent
9146 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
9147 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9148 @code{COBOL_Character}; and the initialization of the variables
9149 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9150 @code{Interfaces.COBOL}.  See B.4(50).
9151 @end cartouche
9152 @noindent
9153 @table @code
9154 @item Floating
9155 Float
9156 @item Long_Floating
9157 (Floating) Long_Float
9158 @item Binary
9159 Integer
9160 @item Long_Binary
9161 Long_Long_Integer
9162 @item Decimal_Element
9163 Character
9164 @item COBOL_Character
9165 Character
9166 @end table
9168 @noindent
9169 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9171 @sp 1
9172 @cartouche
9173 @noindent
9174 @strong{81}.  Support for access to machine instructions.  See C.1(1).
9175 @end cartouche
9176 @noindent
9177 See documentation in file @file{s-maccod.ads} in the distributed library.
9179 @sp 1
9180 @cartouche
9181 @noindent
9182 @strong{82}.  Implementation-defined aspects of access to machine
9183 operations.  See C.1(9).
9184 @end cartouche
9185 @noindent
9186 See documentation in file @file{s-maccod.ads} in the distributed library.
9188 @sp 1
9189 @cartouche
9190 @noindent
9191 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9192 @end cartouche
9193 @noindent
9194 Interrupts are mapped to signals or conditions as appropriate.  See
9195 definition of unit
9196 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9197 on the interrupts supported on a particular target.
9199 @sp 1
9200 @cartouche
9201 @noindent
9202 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9203 C.4(13).
9204 @end cartouche
9205 @noindent
9206 GNAT does not permit a partition to be restarted without reloading,
9207 except under control of the debugger.
9209 @sp 1
9210 @cartouche
9211 @noindent
9212 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9213 @end cartouche
9214 @noindent
9215 Pragma @code{Discard_Names} causes names of enumeration literals to
9216 be suppressed.  In the presence of this pragma, the Image attribute
9217 provides the image of the Pos of the literal, and Value accepts
9218 Pos values.
9220 @sp 1
9221 @cartouche
9222 @noindent
9223 @strong{86}.  The result of the @code{Task_Identification.Image}
9224 attribute.  See C.7.1(7).
9225 @end cartouche
9226 @noindent
9227 The result of this attribute is a string that identifies
9228 the object or component that denotes a given task. If a variable @code{Var}
9229 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9230 where the suffix
9231 is the hexadecimal representation of the virtual address of the corresponding
9232 task control block. If the variable is an array of tasks, the image of each
9233 task will have the form of an indexed component indicating the position of a
9234 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9235 component of a record, the image of the task will have the form of a selected
9236 component. These rules are fully recursive, so that the image of a task that
9237 is a subcomponent of a composite object corresponds to the expression that
9238 designates this task.
9239 @noindent
9240 If a task is created by an allocator, its image depends on the context. If the
9241 allocator is part of an object declaration, the rules described above are used
9242 to construct its image, and this image is not affected by subsequent
9243 assignments. If the allocator appears within an expression, the image
9244 includes only the name of the task type.
9245 @noindent
9246 If the configuration pragma Discard_Names is present, or if the restriction
9247 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9248 the numeric suffix, that is to say the hexadecimal representation of the
9249 virtual address of the control block of the task.
9250 @sp 1
9251 @cartouche
9252 @noindent
9253 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9254 or interrupt handler.  See C.7.1(17).
9255 @end cartouche
9256 @noindent
9257 Protected entries or interrupt handlers can be executed by any
9258 convenient thread, so the value of @code{Current_Task} is undefined.
9260 @sp 1
9261 @cartouche
9262 @noindent
9263 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9264 body or interrupt handler.  See C.7.1(19).
9265 @end cartouche
9266 @noindent
9267 The effect of calling @code{Current_Task} from an entry body or
9268 interrupt handler is to return the identification of the task currently
9269 executing the code.
9271 @sp 1
9272 @cartouche
9273 @noindent
9274 @strong{89}.  Implementation-defined aspects of
9275 @code{Task_Attributes}.  See C.7.2(19).
9276 @end cartouche
9277 @noindent
9278 There are no implementation-defined aspects of @code{Task_Attributes}.
9280 @sp 1
9281 @cartouche
9282 @noindent
9283 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9284 @end cartouche
9285 @noindent
9286 The metrics information for GNAT depends on the performance of the
9287 underlying operating system.  The sources of the run-time for tasking
9288 implementation, together with the output from @option{-gnatG} can be
9289 used to determine the exact sequence of operating systems calls made
9290 to implement various tasking constructs.  Together with appropriate
9291 information on the performance of the underlying operating system,
9292 on the exact target in use, this information can be used to determine
9293 the required metrics.
9295 @sp 1
9296 @cartouche
9297 @noindent
9298 @strong{91}.  The declarations of @code{Any_Priority} and
9299 @code{Priority}.  See D.1(11).
9300 @end cartouche
9301 @noindent
9302 See declarations in file @file{system.ads}.
9304 @sp 1
9305 @cartouche
9306 @noindent
9307 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9308 @end cartouche
9309 @noindent
9310 There are no implementation-defined execution resources.
9312 @sp 1
9313 @cartouche
9314 @noindent
9315 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9316 access to a protected object keeps its processor busy.  See D.2.1(3).
9317 @end cartouche
9318 @noindent
9319 On a multi-processor, a task that is waiting for access to a protected
9320 object does not keep its processor busy.
9322 @sp 1
9323 @cartouche
9324 @noindent
9325 @strong{94}.  The affect of implementation defined execution resources
9326 on task dispatching.  See D.2.1(9).
9327 @end cartouche
9328 @noindent
9329 @c SGI info
9330 @ignore
9331 Tasks map to IRIX threads, and the dispatching policy is as defined by
9332 the IRIX implementation of threads.
9333 @end ignore
9334 Tasks map to threads in the threads package used by GNAT@.  Where possible
9335 and appropriate, these threads correspond to native threads of the
9336 underlying operating system.
9338 @sp 1
9339 @cartouche
9340 @noindent
9341 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9342 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9343 @end cartouche
9344 @noindent
9345 There are no implementation-defined policy-identifiers allowed in this
9346 pragma.
9348 @sp 1
9349 @cartouche
9350 @noindent
9351 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9352 D.2.2(16).
9353 @end cartouche
9354 @noindent
9355 Execution of a task cannot be preempted by the implementation processing
9356 of delay expirations for lower priority tasks.
9358 @sp 1
9359 @cartouche
9360 @noindent
9361 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9362 @end cartouche
9363 @noindent
9364 @c SGI info:
9365 @ignore
9366 Tasks map to IRIX threads, and the dispatching policy is as defined by
9367 the IRIX implementation of threads.
9368 @end ignore
9369 The policy is the same as that of the underlying threads implementation.
9371 @sp 1
9372 @cartouche
9373 @noindent
9374 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9375 in a pragma @code{Locking_Policy}.  See D.3(4).
9376 @end cartouche
9377 @noindent
9378 The only implementation defined policy permitted in GNAT is
9379 @code{Inheritance_Locking}.  On targets that support this policy, locking
9380 is implemented by inheritance, i.e.@: the task owning the lock operates
9381 at a priority equal to the highest priority of any task currently
9382 requesting the lock.
9384 @sp 1
9385 @cartouche
9386 @noindent
9387 @strong{99}.  Default ceiling priorities.  See D.3(10).
9388 @end cartouche
9389 @noindent
9390 The ceiling priority of protected objects of the type
9391 @code{System.Interrupt_Priority'Last} as described in the Ada
9392 Reference Manual D.3(10),
9394 @sp 1
9395 @cartouche
9396 @noindent
9397 @strong{100}.  The ceiling of any protected object used internally by
9398 the implementation.  See D.3(16).
9399 @end cartouche
9400 @noindent
9401 The ceiling priority of internal protected objects is
9402 @code{System.Priority'Last}.
9404 @sp 1
9405 @cartouche
9406 @noindent
9407 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9408 @end cartouche
9409 @noindent
9410 There are no implementation-defined queuing policies.
9412 @sp 1
9413 @cartouche
9414 @noindent
9415 @strong{102}.  On a multiprocessor, any conditions that cause the
9416 completion of an aborted construct to be delayed later than what is
9417 specified for a single processor.  See D.6(3).
9418 @end cartouche
9419 @noindent
9420 The semantics for abort on a multi-processor is the same as on a single
9421 processor, there are no further delays.
9423 @sp 1
9424 @cartouche
9425 @noindent
9426 @strong{103}.  Any operations that implicitly require heap storage
9427 allocation.  See D.7(8).
9428 @end cartouche
9429 @noindent
9430 The only operation that implicitly requires heap storage allocation is
9431 task creation.
9433 @sp 1
9434 @cartouche
9435 @noindent
9436 @strong{104}.  Implementation-defined aspects of pragma
9437 @code{Restrictions}.  See D.7(20).
9438 @end cartouche
9439 @noindent
9440 There are no such implementation-defined aspects.
9442 @sp 1
9443 @cartouche
9444 @noindent
9445 @strong{105}.  Implementation-defined aspects of package
9446 @code{Real_Time}.  See D.8(17).
9447 @end cartouche
9448 @noindent
9449 There are no implementation defined aspects of package @code{Real_Time}.
9451 @sp 1
9452 @cartouche
9453 @noindent
9454 @strong{106}.  Implementation-defined aspects of
9455 @code{delay_statements}.  See D.9(8).
9456 @end cartouche
9457 @noindent
9458 Any difference greater than one microsecond will cause the task to be
9459 delayed (see D.9(7)).
9461 @sp 1
9462 @cartouche
9463 @noindent
9464 @strong{107}.  The upper bound on the duration of interrupt blocking
9465 caused by the implementation.  See D.12(5).
9466 @end cartouche
9467 @noindent
9468 The upper bound is determined by the underlying operating system.  In
9469 no cases is it more than 10 milliseconds.
9471 @sp 1
9472 @cartouche
9473 @noindent
9474 @strong{108}.  The means for creating and executing distributed
9475 programs.  See E(5).
9476 @end cartouche
9477 @noindent
9478 The GLADE package provides a utility GNATDIST for creating and executing
9479 distributed programs.  See the GLADE reference manual for further details.
9481 @sp 1
9482 @cartouche
9483 @noindent
9484 @strong{109}.  Any events that can result in a partition becoming
9485 inaccessible.  See E.1(7).
9486 @end cartouche
9487 @noindent
9488 See the GLADE reference manual for full details on such events.
9490 @sp 1
9491 @cartouche
9492 @noindent
9493 @strong{110}.  The scheduling policies, treatment of priorities, and
9494 management of shared resources between partitions in certain cases.  See
9495 E.1(11).
9496 @end cartouche
9497 @noindent
9498 See the GLADE reference manual for full details on these aspects of
9499 multi-partition execution.
9501 @sp 1
9502 @cartouche
9503 @noindent
9504 @strong{111}.  Events that cause the version of a compilation unit to
9505 change.  See E.3(5).
9506 @end cartouche
9507 @noindent
9508 Editing the source file of a compilation unit, or the source files of
9509 any units on which it is dependent in a significant way cause the version
9510 to change.  No other actions cause the version number to change.  All changes
9511 are significant except those which affect only layout, capitalization or
9512 comments.
9514 @sp 1
9515 @cartouche
9516 @noindent
9517 @strong{112}.  Whether the execution of the remote subprogram is
9518 immediately aborted as a result of cancellation.  See E.4(13).
9519 @end cartouche
9520 @noindent
9521 See the GLADE reference manual for details on the effect of abort in
9522 a distributed application.
9524 @sp 1
9525 @cartouche
9526 @noindent
9527 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9528 @end cartouche
9529 @noindent
9530 See the GLADE reference manual for a full description of all implementation
9531 defined aspects of the PCS@.
9533 @sp 1
9534 @cartouche
9535 @noindent
9536 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9537 E.5(26).
9538 @end cartouche
9539 @noindent
9540 See the GLADE reference manual for a full description of all
9541 implementation defined interfaces.
9543 @sp 1
9544 @cartouche
9545 @noindent
9546 @strong{115}.  The values of named numbers in the package
9547 @code{Decimal}.  See F.2(7).
9548 @end cartouche
9549 @noindent
9550 @table @code
9551 @item Max_Scale
9553 @item Min_Scale
9555 @item Min_Delta
9556 1.0E-18
9557 @item Max_Delta
9558 1.0E+18
9559 @item Max_Decimal_Digits
9561 @end table
9563 @sp 1
9564 @cartouche
9565 @noindent
9566 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9567 @code{Text_IO.Editing}.  See F.3.3(16).
9568 @end cartouche
9569 @noindent
9572 @sp 1
9573 @cartouche
9574 @noindent
9575 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9576 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9577 @end cartouche
9578 @noindent
9581 @sp 1
9582 @cartouche
9583 @noindent
9584 @strong{118}.  The accuracy actually achieved by the complex elementary
9585 functions and by other complex arithmetic operations.  See G.1(1).
9586 @end cartouche
9587 @noindent
9588 Standard library functions are used for the complex arithmetic
9589 operations.  Only fast math mode is currently supported.
9591 @sp 1
9592 @cartouche
9593 @noindent
9594 @strong{119}.  The sign of a zero result (or a component thereof) from
9595 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9596 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9597 @end cartouche
9598 @noindent
9599 The signs of zero values are as recommended by the relevant
9600 implementation advice.
9602 @sp 1
9603 @cartouche
9604 @noindent
9605 @strong{120}.  The sign of a zero result (or a component thereof) from
9606 any operator or function in
9607 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9608 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9609 @end cartouche
9610 @noindent
9611 The signs of zero values are as recommended by the relevant
9612 implementation advice.
9614 @sp 1
9615 @cartouche
9616 @noindent
9617 @strong{121}.  Whether the strict mode or the relaxed mode is the
9618 default.  See G.2(2).
9619 @end cartouche
9620 @noindent
9621 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9622 provides a highly efficient implementation of strict mode.
9624 @sp 1
9625 @cartouche
9626 @noindent
9627 @strong{122}.  The result interval in certain cases of fixed-to-float
9628 conversion.  See G.2.1(10).
9629 @end cartouche
9630 @noindent
9631 For cases where the result interval is implementation dependent, the
9632 accuracy is that provided by performing all operations in 64-bit IEEE
9633 floating-point format.
9635 @sp 1
9636 @cartouche
9637 @noindent
9638 @strong{123}.  The result of a floating point arithmetic operation in
9639 overflow situations, when the @code{Machine_Overflows} attribute of the
9640 result type is @code{False}.  See G.2.1(13).
9641 @end cartouche
9642 @noindent
9643 Infinite and NaN values are produced as dictated by the IEEE
9644 floating-point standard.
9646 Note that on machines that are not fully compliant with the IEEE
9647 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9648 must be used for achieving IEEE confirming behavior (although at the cost
9649 of a significant performance penalty), so infinite and NaN values are
9650 properly generated.
9652 @sp 1
9653 @cartouche
9654 @noindent
9655 @strong{124}.  The result interval for division (or exponentiation by a
9656 negative exponent), when the floating point hardware implements division
9657 as multiplication by a reciprocal.  See G.2.1(16).
9658 @end cartouche
9659 @noindent
9660 Not relevant, division is IEEE exact.
9662 @sp 1
9663 @cartouche
9664 @noindent
9665 @strong{125}.  The definition of close result set, which determines the
9666 accuracy of certain fixed point multiplications and divisions.  See
9667 G.2.3(5).
9668 @end cartouche
9669 @noindent
9670 Operations in the close result set are performed using IEEE long format
9671 floating-point arithmetic.  The input operands are converted to
9672 floating-point, the operation is done in floating-point, and the result
9673 is converted to the target type.
9675 @sp 1
9676 @cartouche
9677 @noindent
9678 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9679 point multiplication or division for which the result shall be in the
9680 perfect result set.  See G.2.3(22).
9681 @end cartouche
9682 @noindent
9683 The result is only defined to be in the perfect result set if the result
9684 can be computed by a single scaling operation involving a scale factor
9685 representable in 64-bits.
9687 @sp 1
9688 @cartouche
9689 @noindent
9690 @strong{127}.  The result of a fixed point arithmetic operation in
9691 overflow situations, when the @code{Machine_Overflows} attribute of the
9692 result type is @code{False}.  See G.2.3(27).
9693 @end cartouche
9694 @noindent
9695 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9696 types.
9698 @sp 1
9699 @cartouche
9700 @noindent
9701 @strong{128}.  The result of an elementary function reference in
9702 overflow situations, when the @code{Machine_Overflows} attribute of the
9703 result type is @code{False}.  See G.2.4(4).
9704 @end cartouche
9705 @noindent
9706 IEEE infinite and Nan values are produced as appropriate.
9708 @sp 1
9709 @cartouche
9710 @noindent
9711 @strong{129}.  The value of the angle threshold, within which certain
9712 elementary functions, complex arithmetic operations, and complex
9713 elementary functions yield results conforming to a maximum relative
9714 error bound.  See G.2.4(10).
9715 @end cartouche
9716 @noindent
9717 Information on this subject is not yet available.
9719 @sp 1
9720 @cartouche
9721 @noindent
9722 @strong{130}.  The accuracy of certain elementary functions for
9723 parameters beyond the angle threshold.  See G.2.4(10).
9724 @end cartouche
9725 @noindent
9726 Information on this subject is not yet available.
9728 @sp 1
9729 @cartouche
9730 @noindent
9731 @strong{131}.  The result of a complex arithmetic operation or complex
9732 elementary function reference in overflow situations, when the
9733 @code{Machine_Overflows} attribute of the corresponding real type is
9734 @code{False}.  See G.2.6(5).
9735 @end cartouche
9736 @noindent
9737 IEEE infinite and Nan values are produced as appropriate.
9739 @sp 1
9740 @cartouche
9741 @noindent
9742 @strong{132}.  The accuracy of certain complex arithmetic operations and
9743 certain complex elementary functions for parameters (or components
9744 thereof) beyond the angle threshold.  See G.2.6(8).
9745 @end cartouche
9746 @noindent
9747 Information on those subjects is not yet available.
9749 @sp 1
9750 @cartouche
9751 @noindent
9752 @strong{133}.  Information regarding bounded errors and erroneous
9753 execution.  See H.2(1).
9754 @end cartouche
9755 @noindent
9756 Information on this subject is not yet available.
9758 @sp 1
9759 @cartouche
9760 @noindent
9761 @strong{134}.  Implementation-defined aspects of pragma
9762 @code{Inspection_Point}.  See H.3.2(8).
9763 @end cartouche
9764 @noindent
9765 Pragma @code{Inspection_Point} ensures that the variable is live and can
9766 be examined by the debugger at the inspection point.
9768 @sp 1
9769 @cartouche
9770 @noindent
9771 @strong{135}.  Implementation-defined aspects of pragma
9772 @code{Restrictions}.  See H.4(25).
9773 @end cartouche
9774 @noindent
9775 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9776 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9777 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9779 @sp 1
9780 @cartouche
9781 @noindent
9782 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9783 H.4(27).
9784 @end cartouche
9785 @noindent
9786 There are no restrictions on pragma @code{Restrictions}.
9788 @node Intrinsic Subprograms
9789 @chapter Intrinsic Subprograms
9790 @cindex Intrinsic Subprograms
9792 @menu
9793 * Intrinsic Operators::
9794 * Enclosing_Entity::
9795 * Exception_Information::
9796 * Exception_Message::
9797 * Exception_Name::
9798 * File::
9799 * Line::
9800 * Rotate_Left::
9801 * Rotate_Right::
9802 * Shift_Left::
9803 * Shift_Right::
9804 * Shift_Right_Arithmetic::
9805 * Source_Location::
9806 @end menu
9808 @noindent
9809 GNAT allows a user application program to write the declaration:
9811 @smallexample @c ada
9812    pragma Import (Intrinsic, name);
9813 @end smallexample
9815 @noindent
9816 providing that the name corresponds to one of the implemented intrinsic
9817 subprograms in GNAT, and that the parameter profile of the referenced
9818 subprogram meets the requirements.  This chapter describes the set of
9819 implemented intrinsic subprograms, and the requirements on parameter profiles.
9820 Note that no body is supplied; as with other uses of pragma Import, the
9821 body is supplied elsewhere (in this case by the compiler itself).  Note
9822 that any use of this feature is potentially non-portable, since the
9823 Ada standard does not require Ada compilers to implement this feature.
9825 @node Intrinsic Operators
9826 @section Intrinsic Operators
9827 @cindex Intrinsic operator
9829 @noindent
9830 All the predefined numeric operators in package Standard
9831 in @code{pragma Import (Intrinsic,..)}
9832 declarations.  In the binary operator case, the operands must have the same
9833 size.  The operand or operands must also be appropriate for
9834 the operator.  For example, for addition, the operands must
9835 both be floating-point or both be fixed-point, and the
9836 right operand for @code{"**"} must have a root type of
9837 @code{Standard.Integer'Base}.
9838 You can use an intrinsic operator declaration as in the following example:
9840 @smallexample @c ada
9841    type Int1 is new Integer;
9842    type Int2 is new Integer;
9844    function "+" (X1 : Int1; X2 : Int2) return Int1;
9845    function "+" (X1 : Int1; X2 : Int2) return Int2;
9846    pragma Import (Intrinsic, "+");
9847 @end smallexample
9849 @noindent
9850 This declaration would permit ``mixed mode'' arithmetic on items
9851 of the differing types @code{Int1} and @code{Int2}.
9852 It is also possible to specify such operators for private types, if the
9853 full views are appropriate arithmetic types.
9855 @node Enclosing_Entity
9856 @section Enclosing_Entity
9857 @cindex Enclosing_Entity
9858 @noindent
9859 This intrinsic subprogram is used in the implementation of the
9860 library routine @code{GNAT.Source_Info}.  The only useful use of the
9861 intrinsic import in this case is the one in this unit, so an
9862 application program should simply call the function
9863 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9864 the current subprogram, package, task, entry, or protected subprogram.
9866 @node Exception_Information
9867 @section Exception_Information
9868 @cindex Exception_Information'
9869 @noindent
9870 This intrinsic subprogram is used in the implementation of the
9871 library routine @code{GNAT.Current_Exception}.  The only useful
9872 use of the intrinsic import in this case is the one in this unit,
9873 so an application program should simply call the function
9874 @code{GNAT.Current_Exception.Exception_Information} to obtain
9875 the exception information associated with the current exception.
9877 @node Exception_Message
9878 @section Exception_Message
9879 @cindex Exception_Message
9880 @noindent
9881 This intrinsic subprogram is used in the implementation of the
9882 library routine @code{GNAT.Current_Exception}.  The only useful
9883 use of the intrinsic import in this case is the one in this unit,
9884 so an application program should simply call the function
9885 @code{GNAT.Current_Exception.Exception_Message} to obtain
9886 the message associated with the current exception.
9888 @node Exception_Name
9889 @section Exception_Name
9890 @cindex Exception_Name
9891 @noindent
9892 This intrinsic subprogram is used in the implementation of the
9893 library routine @code{GNAT.Current_Exception}.  The only useful
9894 use of the intrinsic import in this case is the one in this unit,
9895 so an application program should simply call the function
9896 @code{GNAT.Current_Exception.Exception_Name} to obtain
9897 the name of the current exception.
9899 @node File
9900 @section File
9901 @cindex File
9902 @noindent
9903 This intrinsic subprogram is used in the implementation of the
9904 library routine @code{GNAT.Source_Info}.  The only useful use of the
9905 intrinsic import in this case is the one in this unit, so an
9906 application program should simply call the function
9907 @code{GNAT.Source_Info.File} to obtain the name of the current
9908 file.
9910 @node Line
9911 @section Line
9912 @cindex Line
9913 @noindent
9914 This intrinsic subprogram is used in the implementation of the
9915 library routine @code{GNAT.Source_Info}.  The only useful use of the
9916 intrinsic import in this case is the one in this unit, so an
9917 application program should simply call the function
9918 @code{GNAT.Source_Info.Line} to obtain the number of the current
9919 source line.
9921 @node Rotate_Left
9922 @section Rotate_Left
9923 @cindex Rotate_Left
9924 @noindent
9925 In standard Ada, the @code{Rotate_Left} function is available only
9926 for the predefined modular types in package @code{Interfaces}.  However, in
9927 GNAT it is possible to define a Rotate_Left function for a user
9928 defined modular type or any signed integer type as in this example:
9930 @smallexample @c ada
9931    function Shift_Left
9932      (Value  : My_Modular_Type;
9933       Amount : Natural)
9934       return   My_Modular_Type;
9935 @end smallexample
9937 @noindent
9938 The requirements are that the profile be exactly as in the example
9939 above.  The only modifications allowed are in the formal parameter
9940 names, and in the type of @code{Value} and the return type, which
9941 must be the same, and must be either a signed integer type, or
9942 a modular integer type with a binary modulus, and the size must
9943 be 8.  16, 32 or 64 bits.
9945 @node Rotate_Right
9946 @section Rotate_Right
9947 @cindex Rotate_Right
9948 @noindent
9949 A @code{Rotate_Right} function can be defined for any user defined
9950 binary modular integer type, or signed integer type, as described
9951 above for @code{Rotate_Left}.
9953 @node Shift_Left
9954 @section Shift_Left
9955 @cindex Shift_Left
9956 @noindent
9957 A @code{Shift_Left} function can be defined for any user defined
9958 binary modular integer type, or signed integer type, as described
9959 above for @code{Rotate_Left}.
9961 @node Shift_Right
9962 @section Shift_Right
9963 @cindex Shift_Right
9964 @noindent
9965 A @code{Shift_Right} function can be defined for any user defined
9966 binary modular integer type, or signed integer type, as described
9967 above for @code{Rotate_Left}.
9969 @node Shift_Right_Arithmetic
9970 @section Shift_Right_Arithmetic
9971 @cindex Shift_Right_Arithmetic
9972 @noindent
9973 A @code{Shift_Right_Arithmetic} function can be defined for any user
9974 defined binary modular integer type, or signed integer type, as described
9975 above for @code{Rotate_Left}.
9977 @node Source_Location
9978 @section Source_Location
9979 @cindex Source_Location
9980 @noindent
9981 This intrinsic subprogram is used in the implementation of the
9982 library routine @code{GNAT.Source_Info}.  The only useful use of the
9983 intrinsic import in this case is the one in this unit, so an
9984 application program should simply call the function
9985 @code{GNAT.Source_Info.Source_Location} to obtain the current
9986 source file location.
9988 @node Representation Clauses and Pragmas
9989 @chapter Representation Clauses and Pragmas
9990 @cindex Representation Clauses
9992 @menu
9993 * Alignment Clauses::
9994 * Size Clauses::
9995 * Storage_Size Clauses::
9996 * Size of Variant Record Objects::
9997 * Biased Representation ::
9998 * Value_Size and Object_Size Clauses::
9999 * Component_Size Clauses::
10000 * Bit_Order Clauses::
10001 * Effect of Bit_Order on Byte Ordering::
10002 * Pragma Pack for Arrays::
10003 * Pragma Pack for Records::
10004 * Record Representation Clauses::
10005 * Enumeration Clauses::
10006 * Address Clauses::
10007 * Effect of Convention on Representation::
10008 * Determining the Representations chosen by GNAT::
10009 @end menu
10011 @noindent
10012 @cindex Representation Clause
10013 @cindex Representation Pragma
10014 @cindex Pragma, representation
10015 This section describes the representation clauses accepted by GNAT, and
10016 their effect on the representation of corresponding data objects.
10018 GNAT fully implements Annex C (Systems Programming).  This means that all
10019 the implementation advice sections in chapter 13 are fully implemented.
10020 However, these sections only require a minimal level of support for
10021 representation clauses.  GNAT provides much more extensive capabilities,
10022 and this section describes the additional capabilities provided.
10024 @node Alignment Clauses
10025 @section Alignment Clauses
10026 @cindex Alignment Clause
10028 @noindent
10029 GNAT requires that all alignment clauses specify a power of 2, and all
10030 default alignments are always a power of 2.  The default alignment
10031 values are as follows:
10033 @itemize @bullet
10034 @item @emph{Primitive Types}.
10035 For primitive types, the alignment is the minimum of the actual size of
10036 objects of the type divided by @code{Storage_Unit},
10037 and the maximum alignment supported by the target.
10038 (This maximum alignment is given by the GNAT-specific attribute
10039 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10040 @cindex @code{Maximum_Alignment} attribute
10041 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10042 default alignment will be 8 on any target that supports alignments
10043 this large, but on some targets, the maximum alignment may be smaller
10044 than 8, in which case objects of type @code{Long_Float} will be maximally
10045 aligned.
10047 @item @emph{Arrays}.
10048 For arrays, the alignment is equal to the alignment of the component type
10049 for the normal case where no packing or component size is given.  If the
10050 array is packed, and the packing is effective (see separate section on
10051 packed arrays), then the alignment will be one for long packed arrays,
10052 or arrays whose length is not known at compile time.  For short packed
10053 arrays, which are handled internally as modular types, the alignment
10054 will be as described for primitive types, e.g.@: a packed array of length
10055 31 bits will have an object size of four bytes, and an alignment of 4.
10057 @item @emph{Records}.
10058 For the normal non-packed case, the alignment of a record is equal to
10059 the maximum alignment of any of its components.  For tagged records, this
10060 includes the implicit access type used for the tag.  If a pragma @code{Pack}
10061 is used and all components are packable (see separate section on pragma
10062 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10063 record makes it profitable to increase it.
10065 A special case is when:
10066 @itemize @bullet
10067 @item
10068 the size of the record is given explicitly, or a
10069 full record representation clause is given, and
10070 @item
10071 the size of the record is 2, 4, or 8 bytes.
10072 @end itemize
10073 @noindent
10074 In this case, an alignment is chosen to match the
10075 size of the record. For example, if we have:
10077 @smallexample @c ada
10078    type Small is record
10079       A, B : Character;
10080    end record;
10081    for Small'Size use 16;
10082 @end smallexample
10084 @noindent
10085 then the default alignment of the record type @code{Small} is 2, not 1. This
10086 leads to more efficient code when the record is treated as a unit, and also
10087 allows the type to specified as @code{Atomic} on architectures requiring
10088 strict alignment.
10090 @end itemize
10092 @noindent
10093 An alignment clause may specify a larger alignment than the default value
10094 up to some maximum value dependent on the target (obtainable by using the
10095 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10096 a smaller alignment than the default value for enumeration, integer and
10097 fixed point types, as well as for record types, for example
10099 @smallexample @c ada
10100   type V is record
10101      A : Integer;
10102   end record;
10104   for V'alignment use 1;
10105 @end smallexample
10107 @noindent
10108 @cindex Alignment, default
10109 The default alignment for the type @code{V} is 4, as a result of the
10110 Integer field in the record, but it is permissible, as shown, to
10111 override the default alignment of the record with a smaller value.
10113 @node Size Clauses
10114 @section Size Clauses
10115 @cindex Size Clause
10117 @noindent
10118 The default size for a type @code{T} is obtainable through the
10119 language-defined attribute @code{T'Size} and also through the
10120 equivalent GNAT-defined attribute @code{T'Value_Size}.
10121 For objects of type @code{T}, GNAT will generally increase the type size
10122 so that the object size (obtainable through the GNAT-defined attribute
10123 @code{T'Object_Size})
10124 is a multiple of @code{T'Alignment * Storage_Unit}.
10125 For example
10127 @smallexample @c ada
10128    type Smallint is range 1 .. 6;
10130    type Rec is record
10131       Y1 : integer;
10132       Y2 : boolean;
10133    end record;
10134 @end smallexample
10136 @noindent
10137 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10138 as specified by the RM rules,
10139 but objects of this type will have a size of 8
10140 (@code{Smallint'Object_Size} = 8),
10141 since objects by default occupy an integral number
10142 of storage units.  On some targets, notably older
10143 versions of the Digital Alpha, the size of stand
10144 alone objects of this type may be 32, reflecting
10145 the inability of the hardware to do byte load/stores.
10147 Similarly, the size of type @code{Rec} is 40 bits
10148 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10149 the alignment is 4, so objects of this type will have
10150 their size increased to 64 bits so that it is a multiple
10151 of the alignment (in bits).  This decision is
10152 in accordance with the specific Implementation Advice in RM 13.3(43):
10154 @quotation
10155 A @code{Size} clause should be supported for an object if the specified
10156 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10157 to a size in storage elements that is a multiple of the object's
10158 @code{Alignment} (if the @code{Alignment} is nonzero).
10159 @end quotation
10161 @noindent
10162 An explicit size clause may be used to override the default size by
10163 increasing it.  For example, if we have:
10165 @smallexample @c ada
10166    type My_Boolean is new Boolean;
10167    for My_Boolean'Size use 32;
10168 @end smallexample
10170 @noindent
10171 then values of this type will always be 32 bits long.  In the case of
10172 discrete types, the size can be increased up to 64 bits, with the effect
10173 that the entire specified field is used to hold the value, sign- or
10174 zero-extended as appropriate.  If more than 64 bits is specified, then
10175 padding space is allocated after the value, and a warning is issued that
10176 there are unused bits.
10178 Similarly the size of records and arrays may be increased, and the effect
10179 is to add padding bits after the value.  This also causes a warning message
10180 to be generated.
10182 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10183 Size in bits, this corresponds to an object of size 256 megabytes (minus
10184 one).  This limitation is true on all targets.  The reason for this
10185 limitation is that it improves the quality of the code in many cases
10186 if it is known that a Size value can be accommodated in an object of
10187 type Integer.
10189 @node Storage_Size Clauses
10190 @section Storage_Size Clauses
10191 @cindex Storage_Size Clause
10193 @noindent
10194 For tasks, the @code{Storage_Size} clause specifies the amount of space
10195 to be allocated for the task stack.  This cannot be extended, and if the
10196 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10197 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10198 or a @code{Storage_Size} pragma in the task definition to set the
10199 appropriate required size.  A useful technique is to include in every
10200 task definition a pragma of the form:
10202 @smallexample @c ada
10203    pragma Storage_Size (Default_Stack_Size);
10204 @end smallexample
10206 @noindent
10207 Then @code{Default_Stack_Size} can be defined in a global package, and
10208 modified as required. Any tasks requiring stack sizes different from the
10209 default can have an appropriate alternative reference in the pragma.
10211 You can also use the @option{-d} binder switch to modify the default stack
10212 size.
10214 For access types, the @code{Storage_Size} clause specifies the maximum
10215 space available for allocation of objects of the type.  If this space is
10216 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10217 In the case where the access type is declared local to a subprogram, the
10218 use of a @code{Storage_Size} clause triggers automatic use of a special
10219 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10220 space for the pool is automatically reclaimed on exit from the scope in
10221 which the type is declared.
10223 A special case recognized by the compiler is the specification of a
10224 @code{Storage_Size} of zero for an access type.  This means that no
10225 items can be allocated from the pool, and this is recognized at compile
10226 time, and all the overhead normally associated with maintaining a fixed
10227 size storage pool is eliminated.  Consider the following example:
10229 @smallexample @c ada
10230    procedure p is
10231       type R is array (Natural) of Character;
10232       type P is access all R;
10233       for P'Storage_Size use 0;
10234       --  Above access type intended only for interfacing purposes
10236       y : P;
10238       procedure g (m : P);
10239       pragma Import (C, g);
10241       --  @dots{}
10243    begin
10244       --  @dots{}
10245       y := new R;
10246    end;
10247 @end smallexample
10249 @noindent
10250 As indicated in this example, these dummy storage pools are often useful in
10251 connection with interfacing where no object will ever be allocated.  If you
10252 compile the above example, you get the warning:
10254 @smallexample
10255    p.adb:16:09: warning: allocation from empty storage pool
10256    p.adb:16:09: warning: Storage_Error will be raised at run time
10257 @end smallexample
10259 @noindent
10260 Of course in practice, there will not be any explicit allocators in the
10261 case of such an access declaration.
10263 @node Size of Variant Record Objects
10264 @section Size of Variant Record Objects
10265 @cindex Size, variant record objects
10266 @cindex Variant record objects, size
10268 @noindent
10269 In the case of variant record objects, there is a question whether Size gives
10270 information about a particular variant, or the maximum size required
10271 for any variant.  Consider the following program
10273 @smallexample @c ada
10274 with Text_IO; use Text_IO;
10275 procedure q is
10276    type R1 (A : Boolean := False) is record
10277      case A is
10278        when True  => X : Character;
10279        when False => null;
10280      end case;
10281    end record;
10283    V1 : R1 (False);
10284    V2 : R1;
10286 begin
10287    Put_Line (Integer'Image (V1'Size));
10288    Put_Line (Integer'Image (V2'Size));
10289 end q;
10290 @end smallexample
10292 @noindent
10293 Here we are dealing with a variant record, where the True variant
10294 requires 16 bits, and the False variant requires 8 bits.
10295 In the above example, both V1 and V2 contain the False variant,
10296 which is only 8 bits long.  However, the result of running the
10297 program is:
10299 @smallexample
10302 @end smallexample
10304 @noindent
10305 The reason for the difference here is that the discriminant value of
10306 V1 is fixed, and will always be False.  It is not possible to assign
10307 a True variant value to V1, therefore 8 bits is sufficient.  On the
10308 other hand, in the case of V2, the initial discriminant value is
10309 False (from the default), but it is possible to assign a True
10310 variant value to V2, therefore 16 bits must be allocated for V2
10311 in the general case, even fewer bits may be needed at any particular
10312 point during the program execution.
10314 As can be seen from the output of this program, the @code{'Size}
10315 attribute applied to such an object in GNAT gives the actual allocated
10316 size of the variable, which is the largest size of any of the variants.
10317 The Ada Reference Manual is not completely clear on what choice should
10318 be made here, but the GNAT behavior seems most consistent with the
10319 language in the RM@.
10321 In some cases, it may be desirable to obtain the size of the current
10322 variant, rather than the size of the largest variant.  This can be
10323 achieved in GNAT by making use of the fact that in the case of a
10324 subprogram parameter, GNAT does indeed return the size of the current
10325 variant (because a subprogram has no way of knowing how much space
10326 is actually allocated for the actual).
10328 Consider the following modified version of the above program:
10330 @smallexample @c ada
10331 with Text_IO; use Text_IO;
10332 procedure q is
10333    type R1 (A : Boolean := False) is record
10334      case A is
10335        when True  => X : Character;
10336        when False => null;
10337      end case;
10338    end record;
10340    V2 : R1;
10342    function Size (V : R1) return Integer is
10343    begin
10344       return V'Size;
10345    end Size;
10347 begin
10348    Put_Line (Integer'Image (V2'Size));
10349    Put_Line (Integer'IMage (Size (V2)));
10350    V2 := (True, 'x');
10351    Put_Line (Integer'Image (V2'Size));
10352    Put_Line (Integer'IMage (Size (V2)));
10353 end q;
10354 @end smallexample
10356 @noindent
10357 The output from this program is
10359 @smallexample
10364 @end smallexample
10366 @noindent
10367 Here we see that while the @code{'Size} attribute always returns
10368 the maximum size, regardless of the current variant value, the
10369 @code{Size} function does indeed return the size of the current
10370 variant value.
10372 @node Biased Representation
10373 @section Biased Representation
10374 @cindex Size for biased representation
10375 @cindex Biased representation
10377 @noindent
10378 In the case of scalars with a range starting at other than zero, it is
10379 possible in some cases to specify a size smaller than the default minimum
10380 value, and in such cases, GNAT uses an unsigned biased representation,
10381 in which zero is used to represent the lower bound, and successive values
10382 represent successive values of the type.
10384 For example, suppose we have the declaration:
10386 @smallexample @c ada
10387    type Small is range -7 .. -4;
10388    for Small'Size use 2;
10389 @end smallexample
10391 @noindent
10392 Although the default size of type @code{Small} is 4, the @code{Size}
10393 clause is accepted by GNAT and results in the following representation
10394 scheme:
10396 @smallexample
10397   -7 is represented as 2#00#
10398   -6 is represented as 2#01#
10399   -5 is represented as 2#10#
10400   -4 is represented as 2#11#
10401 @end smallexample
10403 @noindent
10404 Biased representation is only used if the specified @code{Size} clause
10405 cannot be accepted in any other manner.  These reduced sizes that force
10406 biased representation can be used for all discrete types except for
10407 enumeration types for which a representation clause is given.
10409 @node Value_Size and Object_Size Clauses
10410 @section Value_Size and Object_Size Clauses
10411 @findex Value_Size
10412 @findex Object_Size
10413 @cindex Size, of objects
10415 @noindent
10416 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10417 number of bits required to hold values of type @code{T}.
10418 Although this interpretation was allowed in Ada 83, it was not required,
10419 and this requirement in practice can cause some significant difficulties.
10420 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10421 However, in Ada 95 and Ada 2005,
10422 @code{Natural'Size} is
10423 typically 31.  This means that code may change in behavior when moving
10424 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10426 @smallexample @c ada
10427    type Rec is record;
10428       A : Natural;
10429       B : Natural;
10430    end record;
10432    for Rec use record
10433       at 0  range 0 .. Natural'Size - 1;
10434       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10435    end record;
10436 @end smallexample
10438 @noindent
10439 In the above code, since the typical size of @code{Natural} objects
10440 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10441 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10442 there are cases where the fact that the object size can exceed the
10443 size of the type causes surprises.
10445 To help get around this problem GNAT provides two implementation
10446 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10447 applied to a type, these attributes yield the size of the type
10448 (corresponding to the RM defined size attribute), and the size of
10449 objects of the type respectively.
10451 The @code{Object_Size} is used for determining the default size of
10452 objects and components.  This size value can be referred to using the
10453 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10454 the basis of the determination of the size.  The backend is free to
10455 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10456 character might be stored in 32 bits on a machine with no efficient
10457 byte access instructions such as the Alpha.
10459 The default rules for the value of @code{Object_Size} for
10460 discrete types are as follows:
10462 @itemize @bullet
10463 @item
10464 The @code{Object_Size} for base subtypes reflect the natural hardware
10465 size in bits (run the compiler with @option{-gnatS} to find those values
10466 for numeric types). Enumeration types and fixed-point base subtypes have
10467 8, 16, 32 or 64 bits for this size, depending on the range of values
10468 to be stored.
10470 @item
10471 The @code{Object_Size} of a subtype is the same as the
10472 @code{Object_Size} of
10473 the type from which it is obtained.
10475 @item
10476 The @code{Object_Size} of a derived base type is copied from the parent
10477 base type, and the @code{Object_Size} of a derived first subtype is copied
10478 from the parent first subtype.
10479 @end itemize
10481 @noindent
10482 The @code{Value_Size} attribute
10483 is the (minimum) number of bits required to store a value
10484 of the type.
10485 This value is used to determine how tightly to pack
10486 records or arrays with components of this type, and also affects
10487 the semantics of unchecked conversion (unchecked conversions where
10488 the @code{Value_Size} values differ generate a warning, and are potentially
10489 target dependent).
10491 The default rules for the value of @code{Value_Size} are as follows:
10493 @itemize @bullet
10494 @item
10495 The @code{Value_Size} for a base subtype is the minimum number of bits
10496 required to store all values of the type (including the sign bit
10497 only if negative values are possible).
10499 @item
10500 If a subtype statically matches the first subtype of a given type, then it has
10501 by default the same @code{Value_Size} as the first subtype.  This is a
10502 consequence of RM 13.1(14) (``if two subtypes statically match,
10503 then their subtype-specific aspects are the same''.)
10505 @item
10506 All other subtypes have a @code{Value_Size} corresponding to the minimum
10507 number of bits required to store all values of the subtype.  For
10508 dynamic bounds, it is assumed that the value can range down or up
10509 to the corresponding bound of the ancestor
10510 @end itemize
10512 @noindent
10513 The RM defined attribute @code{Size} corresponds to the
10514 @code{Value_Size} attribute.
10516 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10517 the @code{Value_Size} of
10518 the first-named subtype to the given value, and the
10519 @code{Object_Size} of this first-named subtype to the given value padded up
10520 to an appropriate boundary.  It is a consequence of the default rules
10521 above that this @code{Object_Size} will apply to all further subtypes.  On the
10522 other hand, @code{Value_Size} is affected only for the first subtype, any
10523 dynamic subtypes obtained from it directly, and any statically matching
10524 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10526 @code{Value_Size} and
10527 @code{Object_Size} may be explicitly set for any subtype using
10528 an attribute definition clause.  Note that the use of these attributes
10529 can cause the RM 13.1(14) rule to be violated.  If two access types
10530 reference aliased objects whose subtypes have differing @code{Object_Size}
10531 values as a result of explicit attribute definition clauses, then it
10532 is erroneous to convert from one access subtype to the other.
10534 At the implementation level, Esize stores the Object_Size and the
10535 RM_Size field stores the @code{Value_Size} (and hence the value of the
10536 @code{Size} attribute,
10537 which, as noted above, is equivalent to @code{Value_Size}).
10539 To get a feel for the difference, consider the following examples (note
10540 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10542 @smallexample
10543                                        Object_Size     Value_Size
10545 type x1 is range 0 .. 5;                    8               3
10547 type x2 is range 0 .. 5;
10548 for x2'size use 12;                        16              12
10550 subtype x3 is x2 range 0 .. 3;             16               2
10552 subtype x4 is x2'base range 0 .. 10;        8               4
10554 subtype x5 is x2 range 0 .. dynamic;       16               3*
10556 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10558 @end smallexample
10560 @noindent
10561 Note: the entries marked ``3*'' are not actually specified by the Ada
10562 Reference Manual, but it seems in the spirit of the RM rules to allocate
10563 the minimum number of bits (here 3, given the range for @code{x2})
10564 known to be large enough to hold the given range of values.
10566 So far, so good, but GNAT has to obey the RM rules, so the question is
10567 under what conditions must the RM @code{Size} be used.
10568 The following is a list
10569 of the occasions on which the RM @code{Size} must be used:
10571 @itemize @bullet
10572 @item
10573 Component size for packed arrays or records
10575 @item
10576 Value of the attribute @code{Size} for a type
10578 @item
10579 Warning about sizes not matching for unchecked conversion
10580 @end itemize
10582 @noindent
10583 For record types, the @code{Object_Size} is always a multiple of the
10584 alignment of the type (this is true for all types). In some cases the
10585 @code{Value_Size} can be smaller. Consider:
10587 @smallexample
10588    type R is record
10589      X : Integer;
10590      Y : Character;
10591    end record;
10592 @end smallexample
10594 @noindent
10595 On a typical 32-bit architecture, the X component will be four bytes, and
10596 require four-byte alignment, and the Y component will be one byte. In this
10597 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10598 required to store a value of this type, and for example, it is permissible
10599 to have a component of type R in an outer array whose component size is
10600 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10601 since it must be rounded up so that this value is a multiple of the
10602 alignment (4 bytes = 32 bits).
10604 @noindent
10605 For all other types, the @code{Object_Size}
10606 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10607 Only @code{Size} may be specified for such types.
10609 @node Component_Size Clauses
10610 @section Component_Size Clauses
10611 @cindex Component_Size Clause
10613 @noindent
10614 Normally, the value specified in a component size clause must be consistent
10615 with the subtype of the array component with regard to size and alignment.
10616 In other words, the value specified must be at least equal to the size
10617 of this subtype, and must be a multiple of the alignment value.
10619 In addition, component size clauses are allowed which cause the array
10620 to be packed, by specifying a smaller value.  A first case is for
10621 component size values in the range 1 through 63.  The value specified
10622 must not be smaller than the Size of the subtype.  GNAT will accurately
10623 honor all packing requests in this range.  For example, if we have:
10625 @smallexample @c ada
10626 type r is array (1 .. 8) of Natural;
10627 for r'Component_Size use 31;
10628 @end smallexample
10630 @noindent
10631 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10632 Of course access to the components of such an array is considerably
10633 less efficient than if the natural component size of 32 is used.
10634 A second case is when the subtype of the component is a record type
10635 padded because of its default alignment.  For example, if we have:
10637 @smallexample @c ada
10638 type r is record
10639   i : Integer;
10640   j : Integer;
10641   b : Boolean;
10642 end record;
10644 type a is array (1 .. 8) of r;
10645 for a'Component_Size use 72;
10646 @end smallexample
10648 @noindent
10649 then the resulting array has a length of 72 bytes, instead of 96 bytes
10650 if the alignment of the record (4) was obeyed.
10652 Note that there is no point in giving both a component size clause
10653 and a pragma Pack for the same array type. if such duplicate
10654 clauses are given, the pragma Pack will be ignored.
10656 @node Bit_Order Clauses
10657 @section Bit_Order Clauses
10658 @cindex Bit_Order Clause
10659 @cindex bit ordering
10660 @cindex ordering, of bits
10662 @noindent
10663 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10664 attribute.  The specification may either correspond to the default bit
10665 order for the target, in which case the specification has no effect and
10666 places no additional restrictions, or it may be for the non-standard
10667 setting (that is the opposite of the default).
10669 In the case where the non-standard value is specified, the effect is
10670 to renumber bits within each byte, but the ordering of bytes is not
10671 affected.  There are certain
10672 restrictions placed on component clauses as follows:
10674 @itemize @bullet
10676 @item Components fitting within a single storage unit.
10677 @noindent
10678 These are unrestricted, and the effect is merely to renumber bits.  For
10679 example if we are on a little-endian machine with @code{Low_Order_First}
10680 being the default, then the following two declarations have exactly
10681 the same effect:
10683 @smallexample @c ada
10684    type R1 is record
10685       A : Boolean;
10686       B : Integer range 1 .. 120;
10687    end record;
10689    for R1 use record
10690       A at 0 range 0 .. 0;
10691       B at 0 range 1 .. 7;
10692    end record;
10694    type R2 is record
10695       A : Boolean;
10696       B : Integer range 1 .. 120;
10697    end record;
10699    for R2'Bit_Order use High_Order_First;
10701    for R2 use record
10702       A at 0 range 7 .. 7;
10703       B at 0 range 0 .. 6;
10704    end record;
10705 @end smallexample
10707 @noindent
10708 The useful application here is to write the second declaration with the
10709 @code{Bit_Order} attribute definition clause, and know that it will be treated
10710 the same, regardless of whether the target is little-endian or big-endian.
10712 @item Components occupying an integral number of bytes.
10713 @noindent
10714 These are components that exactly fit in two or more bytes.  Such component
10715 declarations are allowed, but have no effect, since it is important to realize
10716 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10717 In particular, the following attempt at getting an endian-independent integer
10718 does not work:
10720 @smallexample @c ada
10721    type R2 is record
10722       A : Integer;
10723    end record;
10725    for R2'Bit_Order use High_Order_First;
10727    for R2 use record
10728       A at 0 range 0 .. 31;
10729    end record;
10730 @end smallexample
10732 @noindent
10733 This declaration will result in a little-endian integer on a
10734 little-endian machine, and a big-endian integer on a big-endian machine.
10735 If byte flipping is required for interoperability between big- and
10736 little-endian machines, this must be explicitly programmed.  This capability
10737 is not provided by @code{Bit_Order}.
10739 @item Components that are positioned across byte boundaries
10740 @noindent
10741 but do not occupy an integral number of bytes.  Given that bytes are not
10742 reordered, such fields would occupy a non-contiguous sequence of bits
10743 in memory, requiring non-trivial code to reassemble.  They are for this
10744 reason not permitted, and any component clause specifying such a layout
10745 will be flagged as illegal by GNAT@.
10747 @end itemize
10749 @noindent
10750 Since the misconception that Bit_Order automatically deals with all
10751 endian-related incompatibilities is a common one, the specification of
10752 a component field that is an integral number of bytes will always
10753 generate a warning.  This warning may be suppressed using @code{pragma
10754 Warnings (Off)} if desired.  The following section contains additional
10755 details regarding the issue of byte ordering.
10757 @node Effect of Bit_Order on Byte Ordering
10758 @section Effect of Bit_Order on Byte Ordering
10759 @cindex byte ordering
10760 @cindex ordering, of bytes
10762 @noindent
10763 In this section we will review the effect of the @code{Bit_Order} attribute
10764 definition clause on byte ordering.  Briefly, it has no effect at all, but
10765 a detailed example will be helpful.  Before giving this
10766 example, let us review the precise
10767 definition of the effect of defining @code{Bit_Order}.  The effect of a
10768 non-standard bit order is described in section 15.5.3 of the Ada
10769 Reference Manual:
10771 @quotation
10772 2   A bit ordering is a method of interpreting the meaning of
10773 the storage place attributes.
10774 @end quotation
10776 @noindent
10777 To understand the precise definition of storage place attributes in
10778 this context, we visit section 13.5.1 of the manual:
10780 @quotation
10781 13   A record_representation_clause (without the mod_clause)
10782 specifies the layout.  The storage place attributes (see 13.5.2)
10783 are taken from the values of the position, first_bit, and last_bit
10784 expressions after normalizing those values so that first_bit is
10785 less than Storage_Unit.
10786 @end quotation
10788 @noindent
10789 The critical point here is that storage places are taken from
10790 the values after normalization, not before.  So the @code{Bit_Order}
10791 interpretation applies to normalized values.  The interpretation
10792 is described in the later part of the 15.5.3 paragraph:
10794 @quotation
10795 2   A bit ordering is a method of interpreting the meaning of
10796 the storage place attributes.  High_Order_First (known in the
10797 vernacular as ``big endian'') means that the first bit of a
10798 storage element (bit 0) is the most significant bit (interpreting
10799 the sequence of bits that represent a component as an unsigned
10800 integer value).  Low_Order_First (known in the vernacular as
10801 ``little endian'') means the opposite: the first bit is the
10802 least significant.
10803 @end quotation
10805 @noindent
10806 Note that the numbering is with respect to the bits of a storage
10807 unit.  In other words, the specification affects only the numbering
10808 of bits within a single storage unit.
10810 We can make the effect clearer by giving an example.
10812 Suppose that we have an external device which presents two bytes, the first
10813 byte presented, which is the first (low addressed byte) of the two byte
10814 record is called Master, and the second byte is called Slave.
10816 The left most (most significant bit is called Control for each byte, and
10817 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10818 (least significant) bit.
10820 On a big-endian machine, we can write the following representation clause
10822 @smallexample @c ada
10823    type Data is record
10824       Master_Control : Bit;
10825       Master_V1      : Bit;
10826       Master_V2      : Bit;
10827       Master_V3      : Bit;
10828       Master_V4      : Bit;
10829       Master_V5      : Bit;
10830       Master_V6      : Bit;
10831       Master_V7      : Bit;
10832       Slave_Control  : Bit;
10833       Slave_V1       : Bit;
10834       Slave_V2       : Bit;
10835       Slave_V3       : Bit;
10836       Slave_V4       : Bit;
10837       Slave_V5       : Bit;
10838       Slave_V6       : Bit;
10839       Slave_V7       : Bit;
10840    end record;
10842    for Data use record
10843       Master_Control at 0 range 0 .. 0;
10844       Master_V1      at 0 range 1 .. 1;
10845       Master_V2      at 0 range 2 .. 2;
10846       Master_V3      at 0 range 3 .. 3;
10847       Master_V4      at 0 range 4 .. 4;
10848       Master_V5      at 0 range 5 .. 5;
10849       Master_V6      at 0 range 6 .. 6;
10850       Master_V7      at 0 range 7 .. 7;
10851       Slave_Control  at 1 range 0 .. 0;
10852       Slave_V1       at 1 range 1 .. 1;
10853       Slave_V2       at 1 range 2 .. 2;
10854       Slave_V3       at 1 range 3 .. 3;
10855       Slave_V4       at 1 range 4 .. 4;
10856       Slave_V5       at 1 range 5 .. 5;
10857       Slave_V6       at 1 range 6 .. 6;
10858       Slave_V7       at 1 range 7 .. 7;
10859    end record;
10860 @end smallexample
10862 @noindent
10863 Now if we move this to a little endian machine, then the bit ordering within
10864 the byte is backwards, so we have to rewrite the record rep clause as:
10866 @smallexample @c ada
10867    for Data use record
10868       Master_Control at 0 range 7 .. 7;
10869       Master_V1      at 0 range 6 .. 6;
10870       Master_V2      at 0 range 5 .. 5;
10871       Master_V3      at 0 range 4 .. 4;
10872       Master_V4      at 0 range 3 .. 3;
10873       Master_V5      at 0 range 2 .. 2;
10874       Master_V6      at 0 range 1 .. 1;
10875       Master_V7      at 0 range 0 .. 0;
10876       Slave_Control  at 1 range 7 .. 7;
10877       Slave_V1       at 1 range 6 .. 6;
10878       Slave_V2       at 1 range 5 .. 5;
10879       Slave_V3       at 1 range 4 .. 4;
10880       Slave_V4       at 1 range 3 .. 3;
10881       Slave_V5       at 1 range 2 .. 2;
10882       Slave_V6       at 1 range 1 .. 1;
10883       Slave_V7       at 1 range 0 .. 0;
10884    end record;
10885 @end smallexample
10887 @noindent
10888 It is a nuisance to have to rewrite the clause, especially if
10889 the code has to be maintained on both machines.  However,
10890 this is a case that we can handle with the
10891 @code{Bit_Order} attribute if it is implemented.
10892 Note that the implementation is not required on byte addressed
10893 machines, but it is indeed implemented in GNAT.
10894 This means that we can simply use the
10895 first record clause, together with the declaration
10897 @smallexample @c ada
10898    for Data'Bit_Order use High_Order_First;
10899 @end smallexample
10901 @noindent
10902 and the effect is what is desired, namely the layout is exactly the same,
10903 independent of whether the code is compiled on a big-endian or little-endian
10904 machine.
10906 The important point to understand is that byte ordering is not affected.
10907 A @code{Bit_Order} attribute definition never affects which byte a field
10908 ends up in, only where it ends up in that byte.
10909 To make this clear, let us rewrite the record rep clause of the previous
10910 example as:
10912 @smallexample @c ada
10913    for Data'Bit_Order use High_Order_First;
10914    for Data use record
10915       Master_Control at 0 range  0 .. 0;
10916       Master_V1      at 0 range  1 .. 1;
10917       Master_V2      at 0 range  2 .. 2;
10918       Master_V3      at 0 range  3 .. 3;
10919       Master_V4      at 0 range  4 .. 4;
10920       Master_V5      at 0 range  5 .. 5;
10921       Master_V6      at 0 range  6 .. 6;
10922       Master_V7      at 0 range  7 .. 7;
10923       Slave_Control  at 0 range  8 .. 8;
10924       Slave_V1       at 0 range  9 .. 9;
10925       Slave_V2       at 0 range 10 .. 10;
10926       Slave_V3       at 0 range 11 .. 11;
10927       Slave_V4       at 0 range 12 .. 12;
10928       Slave_V5       at 0 range 13 .. 13;
10929       Slave_V6       at 0 range 14 .. 14;
10930       Slave_V7       at 0 range 15 .. 15;
10931    end record;
10932 @end smallexample
10934 @noindent
10935 This is exactly equivalent to saying (a repeat of the first example):
10937 @smallexample @c ada
10938    for Data'Bit_Order use High_Order_First;
10939    for Data use record
10940       Master_Control at 0 range 0 .. 0;
10941       Master_V1      at 0 range 1 .. 1;
10942       Master_V2      at 0 range 2 .. 2;
10943       Master_V3      at 0 range 3 .. 3;
10944       Master_V4      at 0 range 4 .. 4;
10945       Master_V5      at 0 range 5 .. 5;
10946       Master_V6      at 0 range 6 .. 6;
10947       Master_V7      at 0 range 7 .. 7;
10948       Slave_Control  at 1 range 0 .. 0;
10949       Slave_V1       at 1 range 1 .. 1;
10950       Slave_V2       at 1 range 2 .. 2;
10951       Slave_V3       at 1 range 3 .. 3;
10952       Slave_V4       at 1 range 4 .. 4;
10953       Slave_V5       at 1 range 5 .. 5;
10954       Slave_V6       at 1 range 6 .. 6;
10955       Slave_V7       at 1 range 7 .. 7;
10956    end record;
10957 @end smallexample
10959 @noindent
10960 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10961 field.  The storage place attributes are obtained by normalizing the
10962 values given so that the @code{First_Bit} value is less than 8.  After
10963 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10964 we specified in the other case.
10966 Now one might expect that the @code{Bit_Order} attribute might affect
10967 bit numbering within the entire record component (two bytes in this
10968 case, thus affecting which byte fields end up in), but that is not
10969 the way this feature is defined, it only affects numbering of bits,
10970 not which byte they end up in.
10972 Consequently it never makes sense to specify a starting bit number
10973 greater than 7 (for a byte addressable field) if an attribute
10974 definition for @code{Bit_Order} has been given, and indeed it
10975 may be actively confusing to specify such a value, so the compiler
10976 generates a warning for such usage.
10978 If you do need to control byte ordering then appropriate conditional
10979 values must be used.  If in our example, the slave byte came first on
10980 some machines we might write:
10982 @smallexample @c ada
10983    Master_Byte_First constant Boolean := @dots{};
10985    Master_Byte : constant Natural :=
10986                    1 - Boolean'Pos (Master_Byte_First);
10987    Slave_Byte  : constant Natural :=
10988                    Boolean'Pos (Master_Byte_First);
10990    for Data'Bit_Order use High_Order_First;
10991    for Data use record
10992       Master_Control at Master_Byte range 0 .. 0;
10993       Master_V1      at Master_Byte range 1 .. 1;
10994       Master_V2      at Master_Byte range 2 .. 2;
10995       Master_V3      at Master_Byte range 3 .. 3;
10996       Master_V4      at Master_Byte range 4 .. 4;
10997       Master_V5      at Master_Byte range 5 .. 5;
10998       Master_V6      at Master_Byte range 6 .. 6;
10999       Master_V7      at Master_Byte range 7 .. 7;
11000       Slave_Control  at Slave_Byte  range 0 .. 0;
11001       Slave_V1       at Slave_Byte  range 1 .. 1;
11002       Slave_V2       at Slave_Byte  range 2 .. 2;
11003       Slave_V3       at Slave_Byte  range 3 .. 3;
11004       Slave_V4       at Slave_Byte  range 4 .. 4;
11005       Slave_V5       at Slave_Byte  range 5 .. 5;
11006       Slave_V6       at Slave_Byte  range 6 .. 6;
11007       Slave_V7       at Slave_Byte  range 7 .. 7;
11008    end record;
11009 @end smallexample
11011 @noindent
11012 Now to switch between machines, all that is necessary is
11013 to set the boolean constant @code{Master_Byte_First} in
11014 an appropriate manner.
11016 @node Pragma Pack for Arrays
11017 @section Pragma Pack for Arrays
11018 @cindex Pragma Pack (for arrays)
11020 @noindent
11021 Pragma @code{Pack} applied to an array has no effect unless the component type
11022 is packable.  For a component type to be packable, it must be one of the
11023 following cases:
11025 @itemize @bullet
11026 @item
11027 Any scalar type
11028 @item
11029 Any type whose size is specified with a size clause
11030 @item
11031 Any packed array type with a static size
11032 @item
11033 Any record type padded because of its default alignment
11034 @end itemize
11036 @noindent
11037 For all these cases, if the component subtype size is in the range
11038 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11039 component size were specified giving the component subtype size.
11040 For example if we have:
11042 @smallexample @c ada
11043    type r is range 0 .. 17;
11045    type ar is array (1 .. 8) of r;
11046    pragma Pack (ar);
11047 @end smallexample
11049 @noindent
11050 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11051 and the size of the array @code{ar} will be exactly 40 bits.
11053 Note that in some cases this rather fierce approach to packing can produce
11054 unexpected effects.  For example, in Ada 95 and Ada 2005,
11055 subtype @code{Natural} typically has a size of 31, meaning that if you
11056 pack an array of @code{Natural}, you get 31-bit
11057 close packing, which saves a few bits, but results in far less efficient
11058 access.  Since many other Ada compilers will ignore such a packing request,
11059 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11060 might not be what is intended.  You can easily remove this warning by
11061 using an explicit @code{Component_Size} setting instead, which never generates
11062 a warning, since the intention of the programmer is clear in this case.
11064 GNAT treats packed arrays in one of two ways.  If the size of the array is
11065 known at compile time and is less than 64 bits, then internally the array
11066 is represented as a single modular type, of exactly the appropriate number
11067 of bits.  If the length is greater than 63 bits, or is not known at compile
11068 time, then the packed array is represented as an array of bytes, and the
11069 length is always a multiple of 8 bits.
11071 Note that to represent a packed array as a modular type, the alignment must
11072 be suitable for the modular type involved. For example, on typical machines
11073 a 32-bit packed array will be represented by a 32-bit modular integer with
11074 an alignment of four bytes. If you explicitly override the default alignment
11075 with an alignment clause that is too small, the modular representation
11076 cannot be used. For example, consider the following set of declarations:
11078 @smallexample @c ada
11079    type R is range 1 .. 3;
11080    type S is array (1 .. 31) of R;
11081    for S'Component_Size use 2;
11082    for S'Size use 62;
11083    for S'Alignment use 1;
11084 @end smallexample
11086 @noindent
11087 If the alignment clause were not present, then a 62-bit modular
11088 representation would be chosen (typically with an alignment of 4 or 8
11089 bytes depending on the target). But the default alignment is overridden
11090 with the explicit alignment clause. This means that the modular
11091 representation cannot be used, and instead the array of bytes
11092 representation must be used, meaning that the length must be a multiple
11093 of 8. Thus the above set of declarations will result in a diagnostic
11094 rejecting the size clause and noting that the minimum size allowed is 64.
11096 @cindex Pragma Pack (for type Natural)
11097 @cindex Pragma Pack warning
11099 One special case that is worth noting occurs when the base type of the
11100 component size is 8/16/32 and the subtype is one bit less. Notably this
11101 occurs with subtype @code{Natural}. Consider:
11103 @smallexample @c ada
11104    type Arr is array (1 .. 32) of Natural;
11105    pragma Pack (Arr);
11106 @end smallexample
11108 @noindent
11109 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11110 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11111 Ada 83 compilers did not attempt 31 bit packing.
11113 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11114 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11115 substantial unintended performance penalty when porting legacy Ada 83 code.
11116 To help prevent this, GNAT generates a warning in such cases. If you really
11117 want 31 bit packing in a case like this, you can set the component size
11118 explicitly:
11120 @smallexample @c ada
11121    type Arr is array (1 .. 32) of Natural;
11122    for Arr'Component_Size use 31;
11123 @end smallexample
11125 @noindent
11126 Here 31-bit packing is achieved as required, and no warning is generated,
11127 since in this case the programmer intention is clear.
11129 @node Pragma Pack for Records
11130 @section Pragma Pack for Records
11131 @cindex Pragma Pack (for records)
11133 @noindent
11134 Pragma @code{Pack} applied to a record will pack the components to reduce
11135 wasted space from alignment gaps and by reducing the amount of space
11136 taken by components.  We distinguish between @emph{packable} components and
11137 @emph{non-packable} components.
11138 Components of the following types are considered packable:
11139 @itemize @bullet
11140 @item
11141 All primitive types are packable.
11143 @item
11144 Small packed arrays, whose size does not exceed 64 bits, and where the
11145 size is statically known at compile time, are represented internally
11146 as modular integers, and so they are also packable.
11148 @end itemize
11150 @noindent
11151 All packable components occupy the exact number of bits corresponding to
11152 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11153 can start on an arbitrary bit boundary.
11155 All other types are non-packable, they occupy an integral number of
11156 storage units, and
11157 are placed at a boundary corresponding to their alignment requirements.
11159 For example, consider the record
11161 @smallexample @c ada
11162    type Rb1 is array (1 .. 13) of Boolean;
11163    pragma Pack (rb1);
11165    type Rb2 is array (1 .. 65) of Boolean;
11166    pragma Pack (rb2);
11168    type x2 is record
11169       l1 : Boolean;
11170       l2 : Duration;
11171       l3 : Float;
11172       l4 : Boolean;
11173       l5 : Rb1;
11174       l6 : Rb2;
11175    end record;
11176    pragma Pack (x2);
11177 @end smallexample
11179 @noindent
11180 The representation for the record x2 is as follows:
11182 @smallexample @c ada
11183 for x2'Size use 224;
11184 for x2 use record
11185    l1 at  0 range  0 .. 0;
11186    l2 at  0 range  1 .. 64;
11187    l3 at 12 range  0 .. 31;
11188    l4 at 16 range  0 .. 0;
11189    l5 at 16 range  1 .. 13;
11190    l6 at 18 range  0 .. 71;
11191 end record;
11192 @end smallexample
11194 @noindent
11195 Studying this example, we see that the packable fields @code{l1}
11196 and @code{l2} are
11197 of length equal to their sizes, and placed at specific bit boundaries (and
11198 not byte boundaries) to
11199 eliminate padding.  But @code{l3} is of a non-packable float type, so
11200 it is on the next appropriate alignment boundary.
11202 The next two fields are fully packable, so @code{l4} and @code{l5} are
11203 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11204 array that is longer than 64 bits, so it is itself non-packable.  Thus
11205 the @code{l6} field is aligned to the next byte boundary, and takes an
11206 integral number of bytes, i.e.@: 72 bits.
11208 @node Record Representation Clauses
11209 @section Record Representation Clauses
11210 @cindex Record Representation Clause
11212 @noindent
11213 Record representation clauses may be given for all record types, including
11214 types obtained by record extension.  Component clauses are allowed for any
11215 static component.  The restrictions on component clauses depend on the type
11216 of the component.
11218 @cindex Component Clause
11219 For all components of an elementary type, the only restriction on component
11220 clauses is that the size must be at least the 'Size value of the type
11221 (actually the Value_Size).  There are no restrictions due to alignment,
11222 and such components may freely cross storage boundaries.
11224 Packed arrays with a size up to and including 64 bits are represented
11225 internally using a modular type with the appropriate number of bits, and
11226 thus the same lack of restriction applies.  For example, if you declare:
11228 @smallexample @c ada
11229    type R is array (1 .. 49) of Boolean;
11230    pragma Pack (R);
11231    for R'Size use 49;
11232 @end smallexample
11234 @noindent
11235 then a component clause for a component of type R may start on any
11236 specified bit boundary, and may specify a value of 49 bits or greater.
11238 For packed bit arrays that are longer than 64 bits, there are two
11239 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11240 including the important case of single bits or boolean values, then
11241 there are no limitations on placement of such components, and they
11242 may start and end at arbitrary bit boundaries.
11244 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11245 an array of this type longer than 64 bits must always be placed on
11246 on a storage unit (byte) boundary and occupy an integral number
11247 of storage units (bytes). Any component clause that does not
11248 meet this requirement will be rejected.
11250 Any aliased component, or component of an aliased type, must
11251 have its normal alignment and size. A component clause that
11252 does not meet this requirement will be rejected.
11254 The tag field of a tagged type always occupies an address sized field at
11255 the start of the record.  No component clause may attempt to overlay this
11256 tag. When a tagged type appears as a component, the tag field must have
11257 proper alignment
11259 In the case of a record extension T1, of a type T, no component clause applied
11260 to the type T1 can specify a storage location that would overlap the first
11261 T'Size bytes of the record.
11263 For all other component types, including non-bit-packed arrays,
11264 the component can be placed at an arbitrary bit boundary,
11265 so for example, the following is permitted:
11267 @smallexample @c ada
11268    type R is array (1 .. 10) of Boolean;
11269    for R'Size use 80;
11271    type Q is record
11272       G, H : Boolean;
11273       L, M : R;
11274    end record;
11276    for Q use record
11277       G at 0 range  0 ..   0;
11278       H at 0 range  1 ..   1;
11279       L at 0 range  2 ..  81;
11280       R at 0 range 82 .. 161;
11281    end record;
11282 @end smallexample
11284 @noindent
11285 Note: the above rules apply to recent releases of GNAT 5.
11286 In GNAT 3, there are more severe restrictions on larger components.
11287 For non-primitive types, including packed arrays with a size greater than
11288 64 bits, component clauses must respect the alignment requirement of the
11289 type, in particular, always starting on a byte boundary, and the length
11290 must be a multiple of the storage unit.
11292 @node Enumeration Clauses
11293 @section Enumeration Clauses
11295 The only restriction on enumeration clauses is that the range of values
11296 must be representable.  For the signed case, if one or more of the
11297 representation values are negative, all values must be in the range:
11299 @smallexample @c ada
11300    System.Min_Int .. System.Max_Int
11301 @end smallexample
11303 @noindent
11304 For the unsigned case, where all values are nonnegative, the values must
11305 be in the range:
11307 @smallexample @c ada
11308    0 .. System.Max_Binary_Modulus;
11309 @end smallexample
11311 @noindent
11312 A @emph{confirming} representation clause is one in which the values range
11313 from 0 in sequence, i.e.@: a clause that confirms the default representation
11314 for an enumeration type.
11315 Such a confirming representation
11316 is permitted by these rules, and is specially recognized by the compiler so
11317 that no extra overhead results from the use of such a clause.
11319 If an array has an index type which is an enumeration type to which an
11320 enumeration clause has been applied, then the array is stored in a compact
11321 manner.  Consider the declarations:
11323 @smallexample @c ada
11324    type r is (A, B, C);
11325    for r use (A => 1, B => 5, C => 10);
11326    type t is array (r) of Character;
11327 @end smallexample
11329 @noindent
11330 The array type t corresponds to a vector with exactly three elements and
11331 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11332 use of space, but means that accesses to elements of the array will incur
11333 the overhead of converting representation values to the corresponding
11334 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11336 @node Address Clauses
11337 @section Address Clauses
11338 @cindex Address Clause
11340 The reference manual allows a general restriction on representation clauses,
11341 as found in RM 13.1(22):
11343 @quotation
11344 An implementation need not support representation
11345 items containing nonstatic expressions, except that
11346 an implementation should support a representation item
11347 for a given entity if each nonstatic expression in the
11348 representation item is a name that statically denotes
11349 a constant declared before the entity.
11350 @end quotation
11352 @noindent
11353 In practice this is applicable only to address clauses, since this is the
11354 only case in which a non-static expression is permitted by the syntax.  As
11355 the AARM notes in sections 13.1 (22.a-22.h):
11357 @display
11358   22.a   Reason: This is to avoid the following sort of thing:
11360   22.b        X : Integer := F(@dots{});
11361               Y : Address := G(@dots{});
11362               for X'Address use Y;
11364   22.c   In the above, we have to evaluate the
11365          initialization expression for X before we
11366          know where to put the result.  This seems
11367          like an unreasonable implementation burden.
11369   22.d   The above code should instead be written
11370          like this:
11372   22.e        Y : constant Address := G(@dots{});
11373               X : Integer := F(@dots{});
11374               for X'Address use Y;
11376   22.f   This allows the expression ``Y'' to be safely
11377          evaluated before X is created.
11379   22.g   The constant could be a formal parameter of mode in.
11381   22.h   An implementation can support other nonstatic
11382          expressions if it wants to.  Expressions of type
11383          Address are hardly ever static, but their value
11384          might be known at compile time anyway in many
11385          cases.
11386 @end display
11388 @noindent
11389 GNAT does indeed permit many additional cases of non-static expressions.  In
11390 particular, if the type involved is elementary there are no restrictions
11391 (since in this case, holding a temporary copy of the initialization value,
11392 if one is present, is inexpensive).  In addition, if there is no implicit or
11393 explicit initialization, then there are no restrictions.  GNAT will reject
11394 only the case where all three of these conditions hold:
11396 @itemize @bullet
11398 @item
11399 The type of the item is non-elementary (e.g.@: a record or array).
11401 @item
11402 There is explicit or implicit initialization required for the object.
11403 Note that access values are always implicitly initialized, and also
11404 in GNAT, certain bit-packed arrays (those having a dynamic length or
11405 a length greater than 64) will also be implicitly initialized to zero.
11407 @item
11408 The address value is non-static.  Here GNAT is more permissive than the
11409 RM, and allows the address value to be the address of a previously declared
11410 stand-alone variable, as long as it does not itself have an address clause.
11412 @smallexample @c ada
11413            Anchor  : Some_Initialized_Type;
11414            Overlay : Some_Initialized_Type;
11415            for Overlay'Address use Anchor'Address;
11416 @end smallexample
11418 @noindent
11419 However, the prefix of the address clause cannot be an array component, or
11420 a component of a discriminated record.
11422 @end itemize
11424 @noindent
11425 As noted above in section 22.h, address values are typically non-static.  In
11426 particular the To_Address function, even if applied to a literal value, is
11427 a non-static function call.  To avoid this minor annoyance, GNAT provides
11428 the implementation defined attribute 'To_Address.  The following two
11429 expressions have identical values:
11431 @findex Attribute
11432 @findex To_Address
11433 @smallexample @c ada
11434    To_Address (16#1234_0000#)
11435    System'To_Address (16#1234_0000#);
11436 @end smallexample
11438 @noindent
11439 except that the second form is considered to be a static expression, and
11440 thus when used as an address clause value is always permitted.
11442 @noindent
11443 Additionally, GNAT treats as static an address clause that is an
11444 unchecked_conversion of a static integer value.  This simplifies the porting
11445 of legacy code, and provides a portable equivalent to the GNAT attribute
11446 @code{To_Address}.
11448 Another issue with address clauses is the interaction with alignment
11449 requirements.  When an address clause is given for an object, the address
11450 value must be consistent with the alignment of the object (which is usually
11451 the same as the alignment of the type of the object).  If an address clause
11452 is given that specifies an inappropriately aligned address value, then the
11453 program execution is erroneous.
11455 Since this source of erroneous behavior can have unfortunate effects, GNAT
11456 checks (at compile time if possible, generating a warning, or at execution
11457 time with a run-time check) that the alignment is appropriate.  If the
11458 run-time check fails, then @code{Program_Error} is raised.  This run-time
11459 check is suppressed if range checks are suppressed, or if the special GNAT
11460 check Alignment_Check is suppressed, or if
11461 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11463 Finally, GNAT does not permit overlaying of objects of controlled types or
11464 composite types containing a controlled component. In most cases, the compiler
11465 can detect an attempt at such overlays and will generate a warning at compile
11466 time and a Program_Error exception at run time.
11468 @findex Export
11469 An address clause cannot be given for an exported object.  More
11470 understandably the real restriction is that objects with an address
11471 clause cannot be exported.  This is because such variables are not
11472 defined by the Ada program, so there is no external object to export.
11474 @findex Import
11475 It is permissible to give an address clause and a pragma Import for the
11476 same object.  In this case, the variable is not really defined by the
11477 Ada program, so there is no external symbol to be linked.  The link name
11478 and the external name are ignored in this case.  The reason that we allow this
11479 combination is that it provides a useful idiom to avoid unwanted
11480 initializations on objects with address clauses.
11482 When an address clause is given for an object that has implicit or
11483 explicit initialization, then by default initialization takes place.  This
11484 means that the effect of the object declaration is to overwrite the
11485 memory at the specified address.  This is almost always not what the
11486 programmer wants, so GNAT will output a warning:
11488 @smallexample
11489   with System;
11490   package G is
11491      type R is record
11492         M : Integer := 0;
11493      end record;
11495      Ext : R;
11496      for Ext'Address use System'To_Address (16#1234_1234#);
11497          |
11498   >>> warning: implicit initialization of "Ext" may
11499       modify overlaid storage
11500   >>> warning: use pragma Import for "Ext" to suppress
11501       initialization (RM B(24))
11503   end G;
11504 @end smallexample
11506 @noindent
11507 As indicated by the warning message, the solution is to use a (dummy) pragma
11508 Import to suppress this initialization.  The pragma tell the compiler that the
11509 object is declared and initialized elsewhere.  The following package compiles
11510 without warnings (and the initialization is suppressed):
11512 @smallexample @c ada
11513    with System;
11514    package G is
11515       type R is record
11516          M : Integer := 0;
11517       end record;
11519       Ext : R;
11520       for Ext'Address use System'To_Address (16#1234_1234#);
11521       pragma Import (Ada, Ext);
11522    end G;
11523 @end smallexample
11525 @noindent
11526 A final issue with address clauses involves their use for overlaying
11527 variables, as in the following example:
11528 @cindex Overlaying of objects
11530 @smallexample @c ada
11531   A : Integer;
11532   B : Integer;
11533   for B'Address use A'Address;
11534 @end smallexample
11536 @noindent
11537 or alternatively, using the form recommended by the RM:
11539 @smallexample @c ada
11540   A    : Integer;
11541   Addr : constant Address := A'Address;
11542   B    : Integer;
11543   for B'Address use Addr;
11544 @end smallexample
11546 @noindent
11547 In both of these cases, @code{A}
11548 and @code{B} become aliased to one another via the
11549 address clause. This use of address clauses to overlay
11550 variables, achieving an effect similar to unchecked
11551 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11552 the effect is implementation defined. Furthermore, the
11553 Ada RM specifically recommends that in a situation
11554 like this, @code{B} should be subject to the following
11555 implementation advice (RM 13.3(19)):
11557 @quotation
11558 19  If the Address of an object is specified, or it is imported
11559     or exported, then the implementation should not perform
11560     optimizations based on assumptions of no aliases.
11561 @end quotation
11563 @noindent
11564 GNAT follows this recommendation, and goes further by also applying
11565 this recommendation to the overlaid variable (@code{A}
11566 in the above example) in this case. This means that the overlay
11567 works "as expected", in that a modification to one of the variables
11568 will affect the value of the other.
11570 @node Effect of Convention on Representation
11571 @section Effect of Convention on Representation
11572 @cindex Convention, effect on representation
11574 @noindent
11575 Normally the specification of a foreign language convention for a type or
11576 an object has no effect on the chosen representation.  In particular, the
11577 representation chosen for data in GNAT generally meets the standard system
11578 conventions, and for example records are laid out in a manner that is
11579 consistent with C@.  This means that specifying convention C (for example)
11580 has no effect.
11582 There are four exceptions to this general rule:
11584 @itemize @bullet
11586 @item Convention Fortran and array subtypes
11587 If pragma Convention Fortran is specified for an array subtype, then in
11588 accordance with the implementation advice in section 3.6.2(11) of the
11589 Ada Reference Manual, the array will be stored in a Fortran-compatible
11590 column-major manner, instead of the normal default row-major order.
11592 @item Convention C and enumeration types
11593 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11594 to accommodate all values of the type.  For example, for the enumeration
11595 type declared by:
11597 @smallexample @c ada
11598    type Color is (Red, Green, Blue);
11599 @end smallexample
11601 @noindent
11602 8 bits is sufficient to store all values of the type, so by default, objects
11603 of type @code{Color} will be represented using 8 bits.  However, normal C
11604 convention is to use 32 bits for all enum values in C, since enum values
11605 are essentially of type int.  If pragma @code{Convention C} is specified for an
11606 Ada enumeration type, then the size is modified as necessary (usually to
11607 32 bits) to be consistent with the C convention for enum values.
11609 Note that this treatment applies only to types. If Convention C is given for
11610 an enumeration object, where the enumeration type is not Convention C, then
11611 Object_Size bits are allocated. For example, for a normal enumeration type,
11612 with less than 256 elements, only 8 bits will be allocated for the object.
11613 Since this may be a surprise in terms of what C expects, GNAT will issue a
11614 warning in this situation. The warning can be suppressed by giving an explicit
11615 size clause specifying the desired size.
11617 @item Convention C/Fortran and Boolean types
11618 In C, the usual convention for boolean values, that is values used for
11619 conditions, is that zero represents false, and nonzero values represent
11620 true.  In Ada, the normal convention is that two specific values, typically
11621 0/1, are used to represent false/true respectively.
11623 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11624 value represents true).
11626 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11627 C or Fortran convention for a derived Boolean, as in the following example:
11629 @smallexample @c ada
11630    type C_Switch is new Boolean;
11631    pragma Convention (C, C_Switch);
11632 @end smallexample
11634 @noindent
11635 then the GNAT generated code will treat any nonzero value as true.  For truth
11636 values generated by GNAT, the conventional value 1 will be used for True, but
11637 when one of these values is read, any nonzero value is treated as True.
11639 @item Access types on OpenVMS
11640 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11641 arrays) are 64-bits long. An exception to this rule is for the case of
11642 C-convention access types where there is no explicit size clause present (or
11643 inherited for derived types). In this case, GNAT chooses to make these
11644 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11645 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11647 @end itemize
11649 @node Determining the Representations chosen by GNAT
11650 @section Determining the Representations chosen by GNAT
11651 @cindex Representation, determination of
11652 @cindex @option{-gnatR} switch
11654 @noindent
11655 Although the descriptions in this section are intended to be complete, it is
11656 often easier to simply experiment to see what GNAT accepts and what the
11657 effect is on the layout of types and objects.
11659 As required by the Ada RM, if a representation clause is not accepted, then
11660 it must be rejected as illegal by the compiler.  However, when a
11661 representation clause or pragma is accepted, there can still be questions
11662 of what the compiler actually does.  For example, if a partial record
11663 representation clause specifies the location of some components and not
11664 others, then where are the non-specified components placed? Or if pragma
11665 @code{Pack} is used on a record, then exactly where are the resulting
11666 fields placed? The section on pragma @code{Pack} in this chapter can be
11667 used to answer the second question, but it is often easier to just see
11668 what the compiler does.
11670 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11671 with this option, then the compiler will output information on the actual
11672 representations chosen, in a format similar to source representation
11673 clauses.  For example, if we compile the package:
11675 @smallexample @c ada
11676 package q is
11677    type r (x : boolean) is tagged record
11678       case x is
11679          when True => S : String (1 .. 100);
11680          when False => null;
11681       end case;
11682    end record;
11684    type r2 is new r (false) with record
11685       y2 : integer;
11686    end record;
11688    for r2 use record
11689       y2 at 16 range 0 .. 31;
11690    end record;
11692    type x is record
11693       y : character;
11694    end record;
11696    type x1 is array (1 .. 10) of x;
11697    for x1'component_size use 11;
11699    type ia is access integer;
11701    type Rb1 is array (1 .. 13) of Boolean;
11702    pragma Pack (rb1);
11704    type Rb2 is array (1 .. 65) of Boolean;
11705    pragma Pack (rb2);
11707    type x2 is record
11708       l1 : Boolean;
11709       l2 : Duration;
11710       l3 : Float;
11711       l4 : Boolean;
11712       l5 : Rb1;
11713       l6 : Rb2;
11714    end record;
11715    pragma Pack (x2);
11716 end q;
11717 @end smallexample
11719 @noindent
11720 using the switch @option{-gnatR} we obtain the following output:
11722 @smallexample
11723 Representation information for unit q
11724 -------------------------------------
11726 for r'Size use ??;
11727 for r'Alignment use 4;
11728 for r use record
11729    x    at 4 range  0 .. 7;
11730    _tag at 0 range  0 .. 31;
11731    s    at 5 range  0 .. 799;
11732 end record;
11734 for r2'Size use 160;
11735 for r2'Alignment use 4;
11736 for r2 use record
11737    x       at  4 range  0 .. 7;
11738    _tag    at  0 range  0 .. 31;
11739    _parent at  0 range  0 .. 63;
11740    y2      at 16 range  0 .. 31;
11741 end record;
11743 for x'Size use 8;
11744 for x'Alignment use 1;
11745 for x use record
11746    y at 0 range  0 .. 7;
11747 end record;
11749 for x1'Size use 112;
11750 for x1'Alignment use 1;
11751 for x1'Component_Size use 11;
11753 for rb1'Size use 13;
11754 for rb1'Alignment use 2;
11755 for rb1'Component_Size use 1;
11757 for rb2'Size use 72;
11758 for rb2'Alignment use 1;
11759 for rb2'Component_Size use 1;
11761 for x2'Size use 224;
11762 for x2'Alignment use 4;
11763 for x2 use record
11764    l1 at  0 range  0 .. 0;
11765    l2 at  0 range  1 .. 64;
11766    l3 at 12 range  0 .. 31;
11767    l4 at 16 range  0 .. 0;
11768    l5 at 16 range  1 .. 13;
11769    l6 at 18 range  0 .. 71;
11770 end record;
11771 @end smallexample
11773 @noindent
11774 The Size values are actually the Object_Size, i.e.@: the default size that
11775 will be allocated for objects of the type.
11776 The ?? size for type r indicates that we have a variant record, and the
11777 actual size of objects will depend on the discriminant value.
11779 The Alignment values show the actual alignment chosen by the compiler
11780 for each record or array type.
11782 The record representation clause for type r shows where all fields
11783 are placed, including the compiler generated tag field (whose location
11784 cannot be controlled by the programmer).
11786 The record representation clause for the type extension r2 shows all the
11787 fields present, including the parent field, which is a copy of the fields
11788 of the parent type of r2, i.e.@: r1.
11790 The component size and size clauses for types rb1 and rb2 show
11791 the exact effect of pragma @code{Pack} on these arrays, and the record
11792 representation clause for type x2 shows how pragma @code{Pack} affects
11793 this record type.
11795 In some cases, it may be useful to cut and paste the representation clauses
11796 generated by the compiler into the original source to fix and guarantee
11797 the actual representation to be used.
11799 @node Standard Library Routines
11800 @chapter Standard Library Routines
11802 @noindent
11803 The Ada Reference Manual contains in Annex A a full description of an
11804 extensive set of standard library routines that can be used in any Ada
11805 program, and which must be provided by all Ada compilers.  They are
11806 analogous to the standard C library used by C programs.
11808 GNAT implements all of the facilities described in annex A, and for most
11809 purposes the description in the Ada Reference Manual, or appropriate Ada
11810 text book, will be sufficient for making use of these facilities.
11812 In the case of the input-output facilities,
11813 @xref{The Implementation of Standard I/O},
11814 gives details on exactly how GNAT interfaces to the
11815 file system.  For the remaining packages, the Ada Reference Manual
11816 should be sufficient.  The following is a list of the packages included,
11817 together with a brief description of the functionality that is provided.
11819 For completeness, references are included to other predefined library
11820 routines defined in other sections of the Ada Reference Manual (these are
11821 cross-indexed from Annex A).
11823 @table @code
11824 @item Ada (A.2)
11825 This is a parent package for all the standard library packages.  It is
11826 usually included implicitly in your program, and itself contains no
11827 useful data or routines.
11829 @item Ada.Calendar (9.6)
11830 @code{Calendar} provides time of day access, and routines for
11831 manipulating times and durations.
11833 @item Ada.Characters (A.3.1)
11834 This is a dummy parent package that contains no useful entities
11836 @item Ada.Characters.Handling (A.3.2)
11837 This package provides some basic character handling capabilities,
11838 including classification functions for classes of characters (e.g.@: test
11839 for letters, or digits).
11841 @item Ada.Characters.Latin_1 (A.3.3)
11842 This package includes a complete set of definitions of the characters
11843 that appear in type CHARACTER@.  It is useful for writing programs that
11844 will run in international environments.  For example, if you want an
11845 upper case E with an acute accent in a string, it is often better to use
11846 the definition of @code{UC_E_Acute} in this package.  Then your program
11847 will print in an understandable manner even if your environment does not
11848 support these extended characters.
11850 @item Ada.Command_Line (A.15)
11851 This package provides access to the command line parameters and the name
11852 of the current program (analogous to the use of @code{argc} and @code{argv}
11853 in C), and also allows the exit status for the program to be set in a
11854 system-independent manner.
11856 @item Ada.Decimal (F.2)
11857 This package provides constants describing the range of decimal numbers
11858 implemented, and also a decimal divide routine (analogous to the COBOL
11859 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11861 @item Ada.Direct_IO (A.8.4)
11862 This package provides input-output using a model of a set of records of
11863 fixed-length, containing an arbitrary definite Ada type, indexed by an
11864 integer record number.
11866 @item Ada.Dynamic_Priorities (D.5)
11867 This package allows the priorities of a task to be adjusted dynamically
11868 as the task is running.
11870 @item Ada.Exceptions (11.4.1)
11871 This package provides additional information on exceptions, and also
11872 contains facilities for treating exceptions as data objects, and raising
11873 exceptions with associated messages.
11875 @item Ada.Finalization (7.6)
11876 This package contains the declarations and subprograms to support the
11877 use of controlled types, providing for automatic initialization and
11878 finalization (analogous to the constructors and destructors of C++)
11880 @item Ada.Interrupts (C.3.2)
11881 This package provides facilities for interfacing to interrupts, which
11882 includes the set of signals or conditions that can be raised and
11883 recognized as interrupts.
11885 @item Ada.Interrupts.Names (C.3.2)
11886 This package provides the set of interrupt names (actually signal
11887 or condition names) that can be handled by GNAT@.
11889 @item Ada.IO_Exceptions (A.13)
11890 This package defines the set of exceptions that can be raised by use of
11891 the standard IO packages.
11893 @item Ada.Numerics
11894 This package contains some standard constants and exceptions used
11895 throughout the numerics packages.  Note that the constants pi and e are
11896 defined here, and it is better to use these definitions than rolling
11897 your own.
11899 @item Ada.Numerics.Complex_Elementary_Functions
11900 Provides the implementation of standard elementary functions (such as
11901 log and trigonometric functions) operating on complex numbers using the
11902 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11903 created by the package @code{Numerics.Complex_Types}.
11905 @item Ada.Numerics.Complex_Types
11906 This is a predefined instantiation of
11907 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11908 build the type @code{Complex} and @code{Imaginary}.
11910 @item Ada.Numerics.Discrete_Random
11911 This generic package provides a random number generator suitable for generating
11912 uniformly distributed values of a specified discrete subtype.
11914 @item Ada.Numerics.Float_Random
11915 This package provides a random number generator suitable for generating
11916 uniformly distributed floating point values in the unit interval.
11918 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11919 This is a generic version of the package that provides the
11920 implementation of standard elementary functions (such as log and
11921 trigonometric functions) for an arbitrary complex type.
11923 The following predefined instantiations of this package are provided:
11925 @table @code
11926 @item Short_Float
11927 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11928 @item Float
11929 @code{Ada.Numerics.Complex_Elementary_Functions}
11930 @item Long_Float
11931 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11932 @end table
11934 @item Ada.Numerics.Generic_Complex_Types
11935 This is a generic package that allows the creation of complex types,
11936 with associated complex arithmetic operations.
11938 The following predefined instantiations of this package exist
11939 @table @code
11940 @item Short_Float
11941 @code{Ada.Numerics.Short_Complex_Complex_Types}
11942 @item Float
11943 @code{Ada.Numerics.Complex_Complex_Types}
11944 @item Long_Float
11945 @code{Ada.Numerics.Long_Complex_Complex_Types}
11946 @end table
11948 @item Ada.Numerics.Generic_Elementary_Functions
11949 This is a generic package that provides the implementation of standard
11950 elementary functions (such as log an trigonometric functions) for an
11951 arbitrary float type.
11953 The following predefined instantiations of this package exist
11955 @table @code
11956 @item Short_Float
11957 @code{Ada.Numerics.Short_Elementary_Functions}
11958 @item Float
11959 @code{Ada.Numerics.Elementary_Functions}
11960 @item Long_Float
11961 @code{Ada.Numerics.Long_Elementary_Functions}
11962 @end table
11964 @item Ada.Real_Time (D.8)
11965 This package provides facilities similar to those of @code{Calendar}, but
11966 operating with a finer clock suitable for real time control. Note that
11967 annex D requires that there be no backward clock jumps, and GNAT generally
11968 guarantees this behavior, but of course if the external clock on which
11969 the GNAT runtime depends is deliberately reset by some external event,
11970 then such a backward jump may occur.
11972 @item Ada.Sequential_IO (A.8.1)
11973 This package provides input-output facilities for sequential files,
11974 which can contain a sequence of values of a single type, which can be
11975 any Ada type, including indefinite (unconstrained) types.
11977 @item Ada.Storage_IO (A.9)
11978 This package provides a facility for mapping arbitrary Ada types to and
11979 from a storage buffer.  It is primarily intended for the creation of new
11980 IO packages.
11982 @item Ada.Streams (13.13.1)
11983 This is a generic package that provides the basic support for the
11984 concept of streams as used by the stream attributes (@code{Input},
11985 @code{Output}, @code{Read} and @code{Write}).
11987 @item Ada.Streams.Stream_IO (A.12.1)
11988 This package is a specialization of the type @code{Streams} defined in
11989 package @code{Streams} together with a set of operations providing
11990 Stream_IO capability.  The Stream_IO model permits both random and
11991 sequential access to a file which can contain an arbitrary set of values
11992 of one or more Ada types.
11994 @item Ada.Strings (A.4.1)
11995 This package provides some basic constants used by the string handling
11996 packages.
11998 @item Ada.Strings.Bounded (A.4.4)
11999 This package provides facilities for handling variable length
12000 strings.  The bounded model requires a maximum length.  It is thus
12001 somewhat more limited than the unbounded model, but avoids the use of
12002 dynamic allocation or finalization.
12004 @item Ada.Strings.Fixed (A.4.3)
12005 This package provides facilities for handling fixed length strings.
12007 @item Ada.Strings.Maps (A.4.2)
12008 This package provides facilities for handling character mappings and
12009 arbitrarily defined subsets of characters.  For instance it is useful in
12010 defining specialized translation tables.
12012 @item Ada.Strings.Maps.Constants (A.4.6)
12013 This package provides a standard set of predefined mappings and
12014 predefined character sets.  For example, the standard upper to lower case
12015 conversion table is found in this package.  Note that upper to lower case
12016 conversion is non-trivial if you want to take the entire set of
12017 characters, including extended characters like E with an acute accent,
12018 into account.  You should use the mappings in this package (rather than
12019 adding 32 yourself) to do case mappings.
12021 @item Ada.Strings.Unbounded (A.4.5)
12022 This package provides facilities for handling variable length
12023 strings.  The unbounded model allows arbitrary length strings, but
12024 requires the use of dynamic allocation and finalization.
12026 @item Ada.Strings.Wide_Bounded (A.4.7)
12027 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12028 @itemx Ada.Strings.Wide_Maps (A.4.7)
12029 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12030 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12031 These packages provide analogous capabilities to the corresponding
12032 packages without @samp{Wide_} in the name, but operate with the types
12033 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12034 and @code{Character}.
12036 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12037 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12038 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12039 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12040 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12041 These packages provide analogous capabilities to the corresponding
12042 packages without @samp{Wide_} in the name, but operate with the types
12043 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12044 of @code{String} and @code{Character}.
12046 @item Ada.Synchronous_Task_Control (D.10)
12047 This package provides some standard facilities for controlling task
12048 communication in a synchronous manner.
12050 @item Ada.Tags
12051 This package contains definitions for manipulation of the tags of tagged
12052 values.
12054 @item Ada.Task_Attributes
12055 This package provides the capability of associating arbitrary
12056 task-specific data with separate tasks.
12058 @item Ada.Text_IO
12059 This package provides basic text input-output capabilities for
12060 character, string and numeric data.  The subpackages of this
12061 package are listed next.
12063 @item Ada.Text_IO.Decimal_IO
12064 Provides input-output facilities for decimal fixed-point types
12066 @item Ada.Text_IO.Enumeration_IO
12067 Provides input-output facilities for enumeration types.
12069 @item Ada.Text_IO.Fixed_IO
12070 Provides input-output facilities for ordinary fixed-point types.
12072 @item Ada.Text_IO.Float_IO
12073 Provides input-output facilities for float types.  The following
12074 predefined instantiations of this generic package are available:
12076 @table @code
12077 @item Short_Float
12078 @code{Short_Float_Text_IO}
12079 @item Float
12080 @code{Float_Text_IO}
12081 @item Long_Float
12082 @code{Long_Float_Text_IO}
12083 @end table
12085 @item Ada.Text_IO.Integer_IO
12086 Provides input-output facilities for integer types.  The following
12087 predefined instantiations of this generic package are available:
12089 @table @code
12090 @item Short_Short_Integer
12091 @code{Ada.Short_Short_Integer_Text_IO}
12092 @item Short_Integer
12093 @code{Ada.Short_Integer_Text_IO}
12094 @item Integer
12095 @code{Ada.Integer_Text_IO}
12096 @item Long_Integer
12097 @code{Ada.Long_Integer_Text_IO}
12098 @item Long_Long_Integer
12099 @code{Ada.Long_Long_Integer_Text_IO}
12100 @end table
12102 @item Ada.Text_IO.Modular_IO
12103 Provides input-output facilities for modular (unsigned) types
12105 @item Ada.Text_IO.Complex_IO (G.1.3)
12106 This package provides basic text input-output capabilities for complex
12107 data.
12109 @item Ada.Text_IO.Editing (F.3.3)
12110 This package contains routines for edited output, analogous to the use
12111 of pictures in COBOL@.  The picture formats used by this package are a
12112 close copy of the facility in COBOL@.
12114 @item Ada.Text_IO.Text_Streams (A.12.2)
12115 This package provides a facility that allows Text_IO files to be treated
12116 as streams, so that the stream attributes can be used for writing
12117 arbitrary data, including binary data, to Text_IO files.
12119 @item Ada.Unchecked_Conversion (13.9)
12120 This generic package allows arbitrary conversion from one type to
12121 another of the same size, providing for breaking the type safety in
12122 special circumstances.
12124 If the types have the same Size (more accurately the same Value_Size),
12125 then the effect is simply to transfer the bits from the source to the
12126 target type without any modification.  This usage is well defined, and
12127 for simple types whose representation is typically the same across
12128 all implementations, gives a portable method of performing such
12129 conversions.
12131 If the types do not have the same size, then the result is implementation
12132 defined, and thus may be non-portable.  The following describes how GNAT
12133 handles such unchecked conversion cases.
12135 If the types are of different sizes, and are both discrete types, then
12136 the effect is of a normal type conversion without any constraint checking.
12137 In particular if the result type has a larger size, the result will be
12138 zero or sign extended.  If the result type has a smaller size, the result
12139 will be truncated by ignoring high order bits.
12141 If the types are of different sizes, and are not both discrete types,
12142 then the conversion works as though pointers were created to the source
12143 and target, and the pointer value is converted.  The effect is that bits
12144 are copied from successive low order storage units and bits of the source
12145 up to the length of the target type.
12147 A warning is issued if the lengths differ, since the effect in this
12148 case is implementation dependent, and the above behavior may not match
12149 that of some other compiler.
12151 A pointer to one type may be converted to a pointer to another type using
12152 unchecked conversion.  The only case in which the effect is undefined is
12153 when one or both pointers are pointers to unconstrained array types.  In
12154 this case, the bounds information may get incorrectly transferred, and in
12155 particular, GNAT uses double size pointers for such types, and it is
12156 meaningless to convert between such pointer types.  GNAT will issue a
12157 warning if the alignment of the target designated type is more strict
12158 than the alignment of the source designated type (since the result may
12159 be unaligned in this case).
12161 A pointer other than a pointer to an unconstrained array type may be
12162 converted to and from System.Address.  Such usage is common in Ada 83
12163 programs, but note that Ada.Address_To_Access_Conversions is the
12164 preferred method of performing such conversions in Ada 95 and Ada 2005.
12165 Neither
12166 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12167 used in conjunction with pointers to unconstrained objects, since
12168 the bounds information cannot be handled correctly in this case.
12170 @item Ada.Unchecked_Deallocation (13.11.2)
12171 This generic package allows explicit freeing of storage previously
12172 allocated by use of an allocator.
12174 @item Ada.Wide_Text_IO (A.11)
12175 This package is similar to @code{Ada.Text_IO}, except that the external
12176 file supports wide character representations, and the internal types are
12177 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12178 and @code{String}.  It contains generic subpackages listed next.
12180 @item Ada.Wide_Text_IO.Decimal_IO
12181 Provides input-output facilities for decimal fixed-point types
12183 @item Ada.Wide_Text_IO.Enumeration_IO
12184 Provides input-output facilities for enumeration types.
12186 @item Ada.Wide_Text_IO.Fixed_IO
12187 Provides input-output facilities for ordinary fixed-point types.
12189 @item Ada.Wide_Text_IO.Float_IO
12190 Provides input-output facilities for float types.  The following
12191 predefined instantiations of this generic package are available:
12193 @table @code
12194 @item Short_Float
12195 @code{Short_Float_Wide_Text_IO}
12196 @item Float
12197 @code{Float_Wide_Text_IO}
12198 @item Long_Float
12199 @code{Long_Float_Wide_Text_IO}
12200 @end table
12202 @item Ada.Wide_Text_IO.Integer_IO
12203 Provides input-output facilities for integer types.  The following
12204 predefined instantiations of this generic package are available:
12206 @table @code
12207 @item Short_Short_Integer
12208 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12209 @item Short_Integer
12210 @code{Ada.Short_Integer_Wide_Text_IO}
12211 @item Integer
12212 @code{Ada.Integer_Wide_Text_IO}
12213 @item Long_Integer
12214 @code{Ada.Long_Integer_Wide_Text_IO}
12215 @item Long_Long_Integer
12216 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12217 @end table
12219 @item Ada.Wide_Text_IO.Modular_IO
12220 Provides input-output facilities for modular (unsigned) types
12222 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12223 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12224 external file supports wide character representations.
12226 @item Ada.Wide_Text_IO.Editing (F.3.4)
12227 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12228 types are @code{Wide_Character} and @code{Wide_String} instead of
12229 @code{Character} and @code{String}.
12231 @item Ada.Wide_Text_IO.Streams (A.12.3)
12232 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12233 types are @code{Wide_Character} and @code{Wide_String} instead of
12234 @code{Character} and @code{String}.
12236 @item Ada.Wide_Wide_Text_IO (A.11)
12237 This package is similar to @code{Ada.Text_IO}, except that the external
12238 file supports wide character representations, and the internal types are
12239 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12240 and @code{String}.  It contains generic subpackages listed next.
12242 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12243 Provides input-output facilities for decimal fixed-point types
12245 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12246 Provides input-output facilities for enumeration types.
12248 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12249 Provides input-output facilities for ordinary fixed-point types.
12251 @item Ada.Wide_Wide_Text_IO.Float_IO
12252 Provides input-output facilities for float types.  The following
12253 predefined instantiations of this generic package are available:
12255 @table @code
12256 @item Short_Float
12257 @code{Short_Float_Wide_Wide_Text_IO}
12258 @item Float
12259 @code{Float_Wide_Wide_Text_IO}
12260 @item Long_Float
12261 @code{Long_Float_Wide_Wide_Text_IO}
12262 @end table
12264 @item Ada.Wide_Wide_Text_IO.Integer_IO
12265 Provides input-output facilities for integer types.  The following
12266 predefined instantiations of this generic package are available:
12268 @table @code
12269 @item Short_Short_Integer
12270 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12271 @item Short_Integer
12272 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12273 @item Integer
12274 @code{Ada.Integer_Wide_Wide_Text_IO}
12275 @item Long_Integer
12276 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12277 @item Long_Long_Integer
12278 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12279 @end table
12281 @item Ada.Wide_Wide_Text_IO.Modular_IO
12282 Provides input-output facilities for modular (unsigned) types
12284 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12285 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12286 external file supports wide character representations.
12288 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12289 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12290 types are @code{Wide_Character} and @code{Wide_String} instead of
12291 @code{Character} and @code{String}.
12293 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12294 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12295 types are @code{Wide_Character} and @code{Wide_String} instead of
12296 @code{Character} and @code{String}.
12297 @end table
12299 @node The Implementation of Standard I/O
12300 @chapter The Implementation of Standard I/O
12302 @noindent
12303 GNAT implements all the required input-output facilities described in
12304 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12305 required behavior of these packages from the Ada point of view, and if
12306 you are writing a portable Ada program that does not need to know the
12307 exact manner in which Ada maps to the outside world when it comes to
12308 reading or writing external files, then you do not need to read this
12309 chapter.  As long as your files are all regular files (not pipes or
12310 devices), and as long as you write and read the files only from Ada, the
12311 description in the Ada Reference Manual is sufficient.
12313 However, if you want to do input-output to pipes or other devices, such
12314 as the keyboard or screen, or if the files you are dealing with are
12315 either generated by some other language, or to be read by some other
12316 language, then you need to know more about the details of how the GNAT
12317 implementation of these input-output facilities behaves.
12319 In this chapter we give a detailed description of exactly how GNAT
12320 interfaces to the file system.  As always, the sources of the system are
12321 available to you for answering questions at an even more detailed level,
12322 but for most purposes the information in this chapter will suffice.
12324 Another reason that you may need to know more about how input-output is
12325 implemented arises when you have a program written in mixed languages
12326 where, for example, files are shared between the C and Ada sections of
12327 the same program.  GNAT provides some additional facilities, in the form
12328 of additional child library packages, that facilitate this sharing, and
12329 these additional facilities are also described in this chapter.
12331 @menu
12332 * Standard I/O Packages::
12333 * FORM Strings::
12334 * Direct_IO::
12335 * Sequential_IO::
12336 * Text_IO::
12337 * Wide_Text_IO::
12338 * Wide_Wide_Text_IO::
12339 * Stream_IO::
12340 * Text Translation::
12341 * Shared Files::
12342 * Filenames encoding::
12343 * Open Modes::
12344 * Operations on C Streams::
12345 * Interfacing to C Streams::
12346 @end menu
12348 @node Standard I/O Packages
12349 @section Standard I/O Packages
12351 @noindent
12352 The Standard I/O packages described in Annex A for
12354 @itemize @bullet
12355 @item
12356 Ada.Text_IO
12357 @item
12358 Ada.Text_IO.Complex_IO
12359 @item
12360 Ada.Text_IO.Text_Streams
12361 @item
12362 Ada.Wide_Text_IO
12363 @item
12364 Ada.Wide_Text_IO.Complex_IO
12365 @item
12366 Ada.Wide_Text_IO.Text_Streams
12367 @item
12368 Ada.Wide_Wide_Text_IO
12369 @item
12370 Ada.Wide_Wide_Text_IO.Complex_IO
12371 @item
12372 Ada.Wide_Wide_Text_IO.Text_Streams
12373 @item
12374 Ada.Stream_IO
12375 @item
12376 Ada.Sequential_IO
12377 @item
12378 Ada.Direct_IO
12379 @end itemize
12381 @noindent
12382 are implemented using the C
12383 library streams facility; where
12385 @itemize @bullet
12386 @item
12387 All files are opened using @code{fopen}.
12388 @item
12389 All input/output operations use @code{fread}/@code{fwrite}.
12390 @end itemize
12392 @noindent
12393 There is no internal buffering of any kind at the Ada library level. The only
12394 buffering is that provided at the system level in the implementation of the
12395 library routines that support streams. This facilitates shared use of these
12396 streams by mixed language programs. Note though that system level buffering is
12397 explicitly enabled at elaboration of the standard I/O packages and that can
12398 have an impact on mixed language programs, in particular those using I/O before
12399 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12400 the Ada elaboration routine before performing any I/O or when impractical,
12401 flush the common I/O streams and in particular Standard_Output before
12402 elaborating the Ada code.
12404 @node FORM Strings
12405 @section FORM Strings
12407 @noindent
12408 The format of a FORM string in GNAT is:
12410 @smallexample
12411 "keyword=value,keyword=value,@dots{},keyword=value"
12412 @end smallexample
12414 @noindent
12415 where letters may be in upper or lower case, and there are no spaces
12416 between values.  The order of the entries is not important.  Currently
12417 the following keywords defined.
12419 @smallexample
12420 TEXT_TRANSLATION=[YES|NO]
12421 SHARED=[YES|NO]
12422 WCEM=[n|h|u|s|e|8|b]
12423 ENCODING=[UTF8|8BITS]
12424 @end smallexample
12426 @noindent
12427 The use of these parameters is described later in this section.
12429 @node Direct_IO
12430 @section Direct_IO
12432 @noindent
12433 Direct_IO can only be instantiated for definite types.  This is a
12434 restriction of the Ada language, which means that the records are fixed
12435 length (the length being determined by @code{@var{type}'Size}, rounded
12436 up to the next storage unit boundary if necessary).
12438 The records of a Direct_IO file are simply written to the file in index
12439 sequence, with the first record starting at offset zero, and subsequent
12440 records following.  There is no control information of any kind.  For
12441 example, if 32-bit integers are being written, each record takes
12442 4-bytes, so the record at index @var{K} starts at offset
12443 (@var{K}@minus{}1)*4.
12445 There is no limit on the size of Direct_IO files, they are expanded as
12446 necessary to accommodate whatever records are written to the file.
12448 @node Sequential_IO
12449 @section Sequential_IO
12451 @noindent
12452 Sequential_IO may be instantiated with either a definite (constrained)
12453 or indefinite (unconstrained) type.
12455 For the definite type case, the elements written to the file are simply
12456 the memory images of the data values with no control information of any
12457 kind.  The resulting file should be read using the same type, no validity
12458 checking is performed on input.
12460 For the indefinite type case, the elements written consist of two
12461 parts.  First is the size of the data item, written as the memory image
12462 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12463 the data value.  The resulting file can only be read using the same
12464 (unconstrained) type.  Normal assignment checks are performed on these
12465 read operations, and if these checks fail, @code{Data_Error} is
12466 raised.  In particular, in the array case, the lengths must match, and in
12467 the variant record case, if the variable for a particular read operation
12468 is constrained, the discriminants must match.
12470 Note that it is not possible to use Sequential_IO to write variable
12471 length array items, and then read the data back into different length
12472 arrays.  For example, the following will raise @code{Data_Error}:
12474 @smallexample @c ada
12475  package IO is new Sequential_IO (String);
12476  F : IO.File_Type;
12477  S : String (1..4);
12478  @dots{}
12479  IO.Create (F)
12480  IO.Write (F, "hello!")
12481  IO.Reset (F, Mode=>In_File);
12482  IO.Read (F, S);
12483  Put_Line (S);
12485 @end smallexample
12487 @noindent
12488 On some Ada implementations, this will print @code{hell}, but the program is
12489 clearly incorrect, since there is only one element in the file, and that
12490 element is the string @code{hello!}.
12492 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12493 using Stream_IO, and this is the preferred mechanism.  In particular, the
12494 above program fragment rewritten to use Stream_IO will work correctly.
12496 @node Text_IO
12497 @section Text_IO
12499 @noindent
12500 Text_IO files consist of a stream of characters containing the following
12501 special control characters:
12503 @smallexample
12504 LF (line feed, 16#0A#) Line Mark
12505 FF (form feed, 16#0C#) Page Mark
12506 @end smallexample
12508 @noindent
12509 A canonical Text_IO file is defined as one in which the following
12510 conditions are met:
12512 @itemize @bullet
12513 @item
12514 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12515 of the line.
12517 @item
12518 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12519 end of a page and consequently can appear only immediately following a
12520 @code{LF} (line mark) character.
12522 @item
12523 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12524 (line mark, page mark).  In the former case, the page mark is implicitly
12525 assumed to be present.
12526 @end itemize
12528 @noindent
12529 A file written using Text_IO will be in canonical form provided that no
12530 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12531 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12532 the file unless an explicit @code{New_Page} operation was performed
12533 before closing the file.
12535 A canonical Text_IO file that is a regular file (i.e., not a device or a
12536 pipe) can be read using any of the routines in Text_IO@.  The
12537 semantics in this case will be exactly as defined in the Ada Reference
12538 Manual, and all the routines in Text_IO are fully implemented.
12540 A text file that does not meet the requirements for a canonical Text_IO
12541 file has one of the following:
12543 @itemize @bullet
12544 @item
12545 The file contains @code{FF} characters not immediately following a
12546 @code{LF} character.
12548 @item
12549 The file contains @code{LF} or @code{FF} characters written by
12550 @code{Put} or @code{Put_Line}, which are not logically considered to be
12551 line marks or page marks.
12553 @item
12554 The file ends in a character other than @code{LF} or @code{FF},
12555 i.e.@: there is no explicit line mark or page mark at the end of the file.
12556 @end itemize
12558 @noindent
12559 Text_IO can be used to read such non-standard text files but subprograms
12560 to do with line or page numbers do not have defined meanings.  In
12561 particular, a @code{FF} character that does not follow a @code{LF}
12562 character may or may not be treated as a page mark from the point of
12563 view of page and line numbering.  Every @code{LF} character is considered
12564 to end a line, and there is an implied @code{LF} character at the end of
12565 the file.
12567 @menu
12568 * Text_IO Stream Pointer Positioning::
12569 * Text_IO Reading and Writing Non-Regular Files::
12570 * Get_Immediate::
12571 * Treating Text_IO Files as Streams::
12572 * Text_IO Extensions::
12573 * Text_IO Facilities for Unbounded Strings::
12574 @end menu
12576 @node Text_IO Stream Pointer Positioning
12577 @subsection Stream Pointer Positioning
12579 @noindent
12580 @code{Ada.Text_IO} has a definition of current position for a file that
12581 is being read.  No internal buffering occurs in Text_IO, and usually the
12582 physical position in the stream used to implement the file corresponds
12583 to this logical position defined by Text_IO@.  There are two exceptions:
12585 @itemize @bullet
12586 @item
12587 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12588 is positioned past the @code{LF} (line mark) that precedes the page
12589 mark.  Text_IO maintains an internal flag so that subsequent read
12590 operations properly handle the logical position which is unchanged by
12591 the @code{End_Of_Page} call.
12593 @item
12594 After a call to @code{End_Of_File} that returns @code{True}, if the
12595 Text_IO file was positioned before the line mark at the end of file
12596 before the call, then the logical position is unchanged, but the stream
12597 is physically positioned right at the end of file (past the line mark,
12598 and past a possible page mark following the line mark.  Again Text_IO
12599 maintains internal flags so that subsequent read operations properly
12600 handle the logical position.
12601 @end itemize
12603 @noindent
12604 These discrepancies have no effect on the observable behavior of
12605 Text_IO, but if a single Ada stream is shared between a C program and
12606 Ada program, or shared (using @samp{shared=yes} in the form string)
12607 between two Ada files, then the difference may be observable in some
12608 situations.
12610 @node Text_IO Reading and Writing Non-Regular Files
12611 @subsection Reading and Writing Non-Regular Files
12613 @noindent
12614 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12615 can be used for reading and writing.  Writing is not affected and the
12616 sequence of characters output is identical to the normal file case, but
12617 for reading, the behavior of Text_IO is modified to avoid undesirable
12618 look-ahead as follows:
12620 An input file that is not a regular file is considered to have no page
12621 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12622 page mark) appearing in the file are considered to be data
12623 characters.  In particular:
12625 @itemize @bullet
12626 @item
12627 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12628 following a line mark.  If a page mark appears, it will be treated as a
12629 data character.
12631 @item
12632 This avoids the need to wait for an extra character to be typed or
12633 entered from the pipe to complete one of these operations.
12635 @item
12636 @code{End_Of_Page} always returns @code{False}
12638 @item
12639 @code{End_Of_File} will return @code{False} if there is a page mark at
12640 the end of the file.
12641 @end itemize
12643 @noindent
12644 Output to non-regular files is the same as for regular files.  Page marks
12645 may be written to non-regular files using @code{New_Page}, but as noted
12646 above they will not be treated as page marks on input if the output is
12647 piped to another Ada program.
12649 Another important discrepancy when reading non-regular files is that the end
12650 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12651 pressing the @key{EOT} key,
12652 then end of file
12653 is signaled once (i.e.@: the test @code{End_Of_File}
12654 will yield @code{True}, or a read will
12655 raise @code{End_Error}), but then reading can resume
12656 to read data past that end of
12657 file indication, until another end of file indication is entered.
12659 @node Get_Immediate
12660 @subsection Get_Immediate
12661 @cindex Get_Immediate
12663 @noindent
12664 Get_Immediate returns the next character (including control characters)
12665 from the input file.  In particular, Get_Immediate will return LF or FF
12666 characters used as line marks or page marks.  Such operations leave the
12667 file positioned past the control character, and it is thus not treated
12668 as having its normal function.  This means that page, line and column
12669 counts after this kind of Get_Immediate call are set as though the mark
12670 did not occur.  In the case where a Get_Immediate leaves the file
12671 positioned between the line mark and page mark (which is not normally
12672 possible), it is undefined whether the FF character will be treated as a
12673 page mark.
12675 @node Treating Text_IO Files as Streams
12676 @subsection Treating Text_IO Files as Streams
12677 @cindex Stream files
12679 @noindent
12680 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12681 as a stream.  Data written to a Text_IO file in this stream mode is
12682 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12683 16#0C# (@code{FF}), the resulting file may have non-standard
12684 format.  Similarly if read operations are used to read from a Text_IO
12685 file treated as a stream, then @code{LF} and @code{FF} characters may be
12686 skipped and the effect is similar to that described above for
12687 @code{Get_Immediate}.
12689 @node Text_IO Extensions
12690 @subsection Text_IO Extensions
12691 @cindex Text_IO extensions
12693 @noindent
12694 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12695 to the standard @code{Text_IO} package:
12697 @itemize @bullet
12698 @item function File_Exists (Name : String) return Boolean;
12699 Determines if a file of the given name exists.
12701 @item function Get_Line return String;
12702 Reads a string from the standard input file.  The value returned is exactly
12703 the length of the line that was read.
12705 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12706 Similar, except that the parameter File specifies the file from which
12707 the string is to be read.
12709 @end itemize
12711 @node Text_IO Facilities for Unbounded Strings
12712 @subsection Text_IO Facilities for Unbounded Strings
12713 @cindex Text_IO for unbounded strings
12714 @cindex Unbounded_String, Text_IO operations
12716 @noindent
12717 The package @code{Ada.Strings.Unbounded.Text_IO}
12718 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12719 subprograms useful for Text_IO operations on unbounded strings:
12721 @itemize @bullet
12723 @item function Get_Line (File : File_Type) return Unbounded_String;
12724 Reads a line from the specified file
12725 and returns the result as an unbounded string.
12727 @item procedure Put (File : File_Type; U : Unbounded_String);
12728 Writes the value of the given unbounded string to the specified file
12729 Similar to the effect of
12730 @code{Put (To_String (U))} except that an extra copy is avoided.
12732 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12733 Writes the value of the given unbounded string to the specified file,
12734 followed by a @code{New_Line}.
12735 Similar to the effect of @code{Put_Line (To_String (U))} except
12736 that an extra copy is avoided.
12737 @end itemize
12739 @noindent
12740 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12741 and is optional.  If the parameter is omitted, then the standard input or
12742 output file is referenced as appropriate.
12744 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12745 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12746 @code{Wide_Text_IO} functionality for unbounded wide strings.
12748 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12749 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12750 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12752 @node Wide_Text_IO
12753 @section Wide_Text_IO
12755 @noindent
12756 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12757 both input and output files may contain special sequences that represent
12758 wide character values.  The encoding scheme for a given file may be
12759 specified using a FORM parameter:
12761 @smallexample
12762 WCEM=@var{x}
12763 @end smallexample
12765 @noindent
12766 as part of the FORM string (WCEM = wide character encoding method),
12767 where @var{x} is one of the following characters
12769 @table @samp
12770 @item h
12771 Hex ESC encoding
12772 @item u
12773 Upper half encoding
12774 @item s
12775 Shift-JIS encoding
12776 @item e
12777 EUC Encoding
12778 @item 8
12779 UTF-8 encoding
12780 @item b
12781 Brackets encoding
12782 @end table
12784 @noindent
12785 The encoding methods match those that
12786 can be used in a source
12787 program, but there is no requirement that the encoding method used for
12788 the source program be the same as the encoding method used for files,
12789 and different files may use different encoding methods.
12791 The default encoding method for the standard files, and for opened files
12792 for which no WCEM parameter is given in the FORM string matches the
12793 wide character encoding specified for the main program (the default
12794 being brackets encoding if no coding method was specified with -gnatW).
12796 @table @asis
12797 @item Hex Coding
12798 In this encoding, a wide character is represented by a five character
12799 sequence:
12801 @smallexample
12802 ESC a b c d
12803 @end smallexample
12805 @noindent
12806 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12807 characters (using upper case letters) of the wide character code.  For
12808 example, ESC A345 is used to represent the wide character with code
12809 16#A345#.  This scheme is compatible with use of the full
12810 @code{Wide_Character} set.
12812 @item Upper Half Coding
12813 The wide character with encoding 16#abcd#, where the upper bit is on
12814 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12815 16#cd#.  The second byte may never be a format control character, but is
12816 not required to be in the upper half.  This method can be also used for
12817 shift-JIS or EUC where the internal coding matches the external coding.
12819 @item Shift JIS Coding
12820 A wide character is represented by a two character sequence 16#ab# and
12821 16#cd#, with the restrictions described for upper half encoding as
12822 described above.  The internal character code is the corresponding JIS
12823 character according to the standard algorithm for Shift-JIS
12824 conversion.  Only characters defined in the JIS code set table can be
12825 used with this encoding method.
12827 @item EUC Coding
12828 A wide character is represented by a two character sequence 16#ab# and
12829 16#cd#, with both characters being in the upper half.  The internal
12830 character code is the corresponding JIS character according to the EUC
12831 encoding algorithm.  Only characters defined in the JIS code set table
12832 can be used with this encoding method.
12834 @item UTF-8 Coding
12835 A wide character is represented using
12836 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12837 10646-1/Am.2.  Depending on the character value, the representation
12838 is a one, two, or three byte sequence:
12840 @smallexample
12841 16#0000#-16#007f#: 2#0xxxxxxx#
12842 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12843 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12844 @end smallexample
12846 @noindent
12847 where the @var{xxx} bits correspond to the left-padded bits of the
12848 16-bit character value.  Note that all lower half ASCII characters
12849 are represented as ASCII bytes and all upper half characters and
12850 other wide characters are represented as sequences of upper-half
12851 (The full UTF-8 scheme allows for encoding 31-bit characters as
12852 6-byte sequences, but in this implementation, all UTF-8 sequences
12853 of four or more bytes length will raise a Constraint_Error, as
12854 will all invalid UTF-8 sequences.)
12856 @item Brackets Coding
12857 In this encoding, a wide character is represented by the following eight
12858 character sequence:
12860 @smallexample
12861 [ " a b c d " ]
12862 @end smallexample
12864 @noindent
12865 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12866 characters (using uppercase letters) of the wide character code.  For
12867 example, @code{["A345"]} is used to represent the wide character with code
12868 @code{16#A345#}.
12869 This scheme is compatible with use of the full Wide_Character set.
12870 On input, brackets coding can also be used for upper half characters,
12871 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12872 is only used for wide characters with a code greater than @code{16#FF#}.
12874 Note that brackets coding is not normally used in the context of
12875 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12876 a portable way of encoding source files. In the context of Wide_Text_IO
12877 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12878 any instance of the left bracket character other than to encode wide
12879 character values using the brackets encoding method. In practice it is
12880 expected that some standard wide character encoding method such
12881 as UTF-8 will be used for text input output.
12883 If brackets notation is used, then any occurrence of a left bracket
12884 in the input file which is not the start of a valid wide character
12885 sequence will cause Constraint_Error to be raised. It is possible to
12886 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12887 input will interpret this as a left bracket.
12889 However, when a left bracket is output, it will be output as a left bracket
12890 and not as ["5B"]. We make this decision because for normal use of
12891 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12892 brackets. For example, if we write:
12894 @smallexample
12895    Put_Line ("Start of output [first run]");
12896 @end smallexample
12898 @noindent
12899 we really do not want to have the left bracket in this message clobbered so
12900 that the output reads:
12902 @smallexample
12903    Start of output ["5B"]first run]
12904 @end smallexample
12906 @noindent
12907 In practice brackets encoding is reasonably useful for normal Put_Line use
12908 since we won't get confused between left brackets and wide character
12909 sequences in the output. But for input, or when files are written out
12910 and read back in, it really makes better sense to use one of the standard
12911 encoding methods such as UTF-8.
12913 @end table
12915 @noindent
12916 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12917 not all wide character
12918 values can be represented.  An attempt to output a character that cannot
12919 be represented using the encoding scheme for the file causes
12920 Constraint_Error to be raised.  An invalid wide character sequence on
12921 input also causes Constraint_Error to be raised.
12923 @menu
12924 * Wide_Text_IO Stream Pointer Positioning::
12925 * Wide_Text_IO Reading and Writing Non-Regular Files::
12926 @end menu
12928 @node Wide_Text_IO Stream Pointer Positioning
12929 @subsection Stream Pointer Positioning
12931 @noindent
12932 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12933 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12934 case:
12936 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12937 normal lower ASCII set (i.e.@: a character in the range:
12939 @smallexample @c ada
12940 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12941 @end smallexample
12943 @noindent
12944 then although the logical position of the file pointer is unchanged by
12945 the @code{Look_Ahead} call, the stream is physically positioned past the
12946 wide character sequence.  Again this is to avoid the need for buffering
12947 or backup, and all @code{Wide_Text_IO} routines check the internal
12948 indication that this situation has occurred so that this is not visible
12949 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12950 can be observed if the wide text file shares a stream with another file.
12952 @node Wide_Text_IO Reading and Writing Non-Regular Files
12953 @subsection Reading and Writing Non-Regular Files
12955 @noindent
12956 As in the case of Text_IO, when a non-regular file is read, it is
12957 assumed that the file contains no page marks (any form characters are
12958 treated as data characters), and @code{End_Of_Page} always returns
12959 @code{False}.  Similarly, the end of file indication is not sticky, so
12960 it is possible to read beyond an end of file.
12962 @node Wide_Wide_Text_IO
12963 @section Wide_Wide_Text_IO
12965 @noindent
12966 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12967 both input and output files may contain special sequences that represent
12968 wide wide character values.  The encoding scheme for a given file may be
12969 specified using a FORM parameter:
12971 @smallexample
12972 WCEM=@var{x}
12973 @end smallexample
12975 @noindent
12976 as part of the FORM string (WCEM = wide character encoding method),
12977 where @var{x} is one of the following characters
12979 @table @samp
12980 @item h
12981 Hex ESC encoding
12982 @item u
12983 Upper half encoding
12984 @item s
12985 Shift-JIS encoding
12986 @item e
12987 EUC Encoding
12988 @item 8
12989 UTF-8 encoding
12990 @item b
12991 Brackets encoding
12992 @end table
12994 @noindent
12995 The encoding methods match those that
12996 can be used in a source
12997 program, but there is no requirement that the encoding method used for
12998 the source program be the same as the encoding method used for files,
12999 and different files may use different encoding methods.
13001 The default encoding method for the standard files, and for opened files
13002 for which no WCEM parameter is given in the FORM string matches the
13003 wide character encoding specified for the main program (the default
13004 being brackets encoding if no coding method was specified with -gnatW).
13006 @table @asis
13008 @item UTF-8 Coding
13009 A wide character is represented using
13010 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13011 10646-1/Am.2.  Depending on the character value, the representation
13012 is a one, two, three, or four byte sequence:
13014 @smallexample
13015 16#000000#-16#00007f#: 2#0xxxxxxx#
13016 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13017 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13018 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13019 @end smallexample
13021 @noindent
13022 where the @var{xxx} bits correspond to the left-padded bits of the
13023 21-bit character value.  Note that all lower half ASCII characters
13024 are represented as ASCII bytes and all upper half characters and
13025 other wide characters are represented as sequences of upper-half
13026 characters.
13028 @item Brackets Coding
13029 In this encoding, a wide wide character is represented by the following eight
13030 character sequence if is in wide character range
13032 @smallexample
13033 [ " a b c d " ]
13034 @end smallexample
13036 and by the following ten character sequence if not
13038 @smallexample
13039 [ " a b c d e f " ]
13040 @end smallexample
13042 @noindent
13043 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13044 are the four or six hexadecimal
13045 characters (using uppercase letters) of the wide wide character code.  For
13046 example, @code{["01A345"]} is used to represent the wide wide character
13047 with code @code{16#01A345#}.
13049 This scheme is compatible with use of the full Wide_Wide_Character set.
13050 On input, brackets coding can also be used for upper half characters,
13051 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
13052 is only used for wide characters with a code greater than @code{16#FF#}.
13054 @end table
13056 @noindent
13057 If is also possible to use the other Wide_Character encoding methods,
13058 such as Shift-JIS, but the other schemes cannot support the full range
13059 of wide wide characters.
13060 An attempt to output a character that cannot
13061 be represented using the encoding scheme for the file causes
13062 Constraint_Error to be raised.  An invalid wide character sequence on
13063 input also causes Constraint_Error to be raised.
13065 @menu
13066 * Wide_Wide_Text_IO Stream Pointer Positioning::
13067 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13068 @end menu
13070 @node Wide_Wide_Text_IO Stream Pointer Positioning
13071 @subsection Stream Pointer Positioning
13073 @noindent
13074 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13075 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13076 case:
13078 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13079 normal lower ASCII set (i.e.@: a character in the range:
13081 @smallexample @c ada
13082 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13083 @end smallexample
13085 @noindent
13086 then although the logical position of the file pointer is unchanged by
13087 the @code{Look_Ahead} call, the stream is physically positioned past the
13088 wide character sequence.  Again this is to avoid the need for buffering
13089 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13090 indication that this situation has occurred so that this is not visible
13091 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13092 can be observed if the wide text file shares a stream with another file.
13094 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13095 @subsection Reading and Writing Non-Regular Files
13097 @noindent
13098 As in the case of Text_IO, when a non-regular file is read, it is
13099 assumed that the file contains no page marks (any form characters are
13100 treated as data characters), and @code{End_Of_Page} always returns
13101 @code{False}.  Similarly, the end of file indication is not sticky, so
13102 it is possible to read beyond an end of file.
13104 @node Stream_IO
13105 @section Stream_IO
13107 @noindent
13108 A stream file is a sequence of bytes, where individual elements are
13109 written to the file as described in the Ada Reference Manual.  The type
13110 @code{Stream_Element} is simply a byte.  There are two ways to read or
13111 write a stream file.
13113 @itemize @bullet
13114 @item
13115 The operations @code{Read} and @code{Write} directly read or write a
13116 sequence of stream elements with no control information.
13118 @item
13119 The stream attributes applied to a stream file transfer data in the
13120 manner described for stream attributes.
13121 @end itemize
13123 @node Text Translation
13124 @section Text Translation
13126 @noindent
13127 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13128 passed to Text_IO.Create and Text_IO.Open:
13129 @samp{Text_Translation=@var{Yes}} is the default, which means to
13130 translate LF to/from CR/LF on Windows systems.
13131 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13132 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13133 may be used to create Unix-style files on
13134 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13135 systems.
13137 @node Shared Files
13138 @section Shared Files
13140 @noindent
13141 Section A.14 of the Ada Reference Manual allows implementations to
13142 provide a wide variety of behavior if an attempt is made to access the
13143 same external file with two or more internal files.
13145 To provide a full range of functionality, while at the same time
13146 minimizing the problems of portability caused by this implementation
13147 dependence, GNAT handles file sharing as follows:
13149 @itemize @bullet
13150 @item
13151 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13152 to open two or more files with the same full name is considered an error
13153 and is not supported.  The exception @code{Use_Error} will be
13154 raised.  Note that a file that is not explicitly closed by the program
13155 remains open until the program terminates.
13157 @item
13158 If the form parameter @samp{shared=no} appears in the form string, the
13159 file can be opened or created with its own separate stream identifier,
13160 regardless of whether other files sharing the same external file are
13161 opened.  The exact effect depends on how the C stream routines handle
13162 multiple accesses to the same external files using separate streams.
13164 @item
13165 If the form parameter @samp{shared=yes} appears in the form string for
13166 each of two or more files opened using the same full name, the same
13167 stream is shared between these files, and the semantics are as described
13168 in Ada Reference Manual, Section A.14.
13169 @end itemize
13171 @noindent
13172 When a program that opens multiple files with the same name is ported
13173 from another Ada compiler to GNAT, the effect will be that
13174 @code{Use_Error} is raised.
13176 The documentation of the original compiler and the documentation of the
13177 program should then be examined to determine if file sharing was
13178 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13179 and @code{Create} calls as required.
13181 When a program is ported from GNAT to some other Ada compiler, no
13182 special attention is required unless the @samp{shared=@var{xxx}} form
13183 parameter is used in the program.  In this case, you must examine the
13184 documentation of the new compiler to see if it supports the required
13185 file sharing semantics, and form strings modified appropriately.  Of
13186 course it may be the case that the program cannot be ported if the
13187 target compiler does not support the required functionality.  The best
13188 approach in writing portable code is to avoid file sharing (and hence
13189 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13190 completely.
13192 One common use of file sharing in Ada 83 is the use of instantiations of
13193 Sequential_IO on the same file with different types, to achieve
13194 heterogeneous input-output.  Although this approach will work in GNAT if
13195 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13196 for this purpose (using the stream attributes)
13198 @node Filenames encoding
13199 @section Filenames encoding
13201 @noindent
13202 An encoding form parameter can be used to specify the filename
13203 encoding @samp{encoding=@var{xxx}}.
13205 @itemize @bullet
13206 @item
13207 If the form parameter @samp{encoding=utf8} appears in the form string, the
13208 filename must be encoded in UTF-8.
13210 @item
13211 If the form parameter @samp{encoding=8bits} appears in the form
13212 string, the filename must be a standard 8bits string.
13213 @end itemize
13215 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13216 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13217 variable. And if not set @samp{utf8} is assumed.
13219 @table @samp
13220 @item CP_ACP
13221 The current system Windows ANSI code page.
13222 @item CP_UTF8
13223 UTF-8 encoding
13224 @end table
13226 This encoding form parameter is only supported on the Windows
13227 platform. On the other Operating Systems the run-time is supporting
13228 UTF-8 natively.
13230 @node Open Modes
13231 @section Open Modes
13233 @noindent
13234 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13235 using the mode shown in the following table:
13237 @sp 2
13238 @center @code{Open} and @code{Create} Call Modes
13239 @smallexample
13240                                @b{OPEN }           @b{CREATE}
13241 Append_File                    "r+"             "w+"
13242 In_File                        "r"              "w+"
13243 Out_File (Direct_IO)           "r+"             "w"
13244 Out_File (all other cases)     "w"              "w"
13245 Inout_File                     "r+"             "w+"
13246 @end smallexample
13248 @noindent
13249 If text file translation is required, then either @samp{b} or @samp{t}
13250 is added to the mode, depending on the setting of Text.  Text file
13251 translation refers to the mapping of CR/LF sequences in an external file
13252 to LF characters internally.  This mapping only occurs in DOS and
13253 DOS-like systems, and is not relevant to other systems.
13255 A special case occurs with Stream_IO@.  As shown in the above table, the
13256 file is initially opened in @samp{r} or @samp{w} mode for the
13257 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13258 subsequently requires switching from reading to writing or vice-versa,
13259 then the file is reopened in @samp{r+} mode to permit the required operation.
13261 @node Operations on C Streams
13262 @section Operations on C Streams
13263 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13264 access to the C library functions for operations on C streams:
13266 @smallexample @c adanocomment
13267 package Interfaces.C_Streams is
13268   -- Note: the reason we do not use the types that are in
13269   -- Interfaces.C is that we want to avoid dragging in the
13270   -- code in this unit if possible.
13271   subtype chars is System.Address;
13272   -- Pointer to null-terminated array of characters
13273   subtype FILEs is System.Address;
13274   -- Corresponds to the C type FILE*
13275   subtype voids is System.Address;
13276   -- Corresponds to the C type void*
13277   subtype int is Integer;
13278   subtype long is Long_Integer;
13279   -- Note: the above types are subtypes deliberately, and it
13280   -- is part of this spec that the above correspondences are
13281   -- guaranteed.  This means that it is legitimate to, for
13282   -- example, use Integer instead of int.  We provide these
13283   -- synonyms for clarity, but in some cases it may be
13284   -- convenient to use the underlying types (for example to
13285   -- avoid an unnecessary dependency of a spec on the spec
13286   -- of this unit).
13287   type size_t is mod 2 ** Standard'Address_Size;
13288   NULL_Stream : constant FILEs;
13289   -- Value returned (NULL in C) to indicate an
13290   -- fdopen/fopen/tmpfile error
13291   ----------------------------------
13292   -- Constants Defined in stdio.h --
13293   ----------------------------------
13294   EOF : constant int;
13295   -- Used by a number of routines to indicate error or
13296   -- end of file
13297   IOFBF : constant int;
13298   IOLBF : constant int;
13299   IONBF : constant int;
13300   -- Used to indicate buffering mode for setvbuf call
13301   SEEK_CUR : constant int;
13302   SEEK_END : constant int;
13303   SEEK_SET : constant int;
13304   -- Used to indicate origin for fseek call
13305   function stdin return FILEs;
13306   function stdout return FILEs;
13307   function stderr return FILEs;
13308   -- Streams associated with standard files
13309   --------------------------
13310   -- Standard C functions --
13311   --------------------------
13312   -- The functions selected below are ones that are
13313   -- available in UNIX (but not necessarily in ANSI C).
13314   -- These are very thin interfaces
13315   -- which copy exactly the C headers.  For more
13316   -- documentation on these functions, see the Microsoft C
13317   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13318   -- ISBN 1-55615-225-6), which includes useful information
13319   -- on system compatibility.
13320   procedure clearerr (stream : FILEs);
13321   function fclose (stream : FILEs) return int;
13322   function fdopen (handle : int; mode : chars) return FILEs;
13323   function feof (stream : FILEs) return int;
13324   function ferror (stream : FILEs) return int;
13325   function fflush (stream : FILEs) return int;
13326   function fgetc (stream : FILEs) return int;
13327   function fgets (strng : chars; n : int; stream : FILEs)
13328       return chars;
13329   function fileno (stream : FILEs) return int;
13330   function fopen (filename : chars; Mode : chars)
13331       return FILEs;
13332   -- Note: to maintain target independence, use
13333   -- text_translation_required, a boolean variable defined in
13334   -- a-sysdep.c to deal with the target dependent text
13335   -- translation requirement.  If this variable is set,
13336   -- then  b/t should be appended to the standard mode
13337   -- argument to set the text translation mode off or on
13338   -- as required.
13339   function fputc (C : int; stream : FILEs) return int;
13340   function fputs (Strng : chars; Stream : FILEs) return int;
13341   function fread
13342      (buffer : voids;
13343       size : size_t;
13344       count : size_t;
13345       stream : FILEs)
13346       return size_t;
13347   function freopen
13348      (filename : chars;
13349       mode : chars;
13350       stream : FILEs)
13351       return FILEs;
13352   function fseek
13353      (stream : FILEs;
13354       offset : long;
13355       origin : int)
13356       return int;
13357   function ftell (stream : FILEs) return long;
13358   function fwrite
13359      (buffer : voids;
13360       size : size_t;
13361       count : size_t;
13362       stream : FILEs)
13363       return size_t;
13364   function isatty (handle : int) return int;
13365   procedure mktemp (template : chars);
13366   -- The return value (which is just a pointer to template)
13367   -- is discarded
13368   procedure rewind (stream : FILEs);
13369   function rmtmp return int;
13370   function setvbuf
13371      (stream : FILEs;
13372       buffer : chars;
13373       mode : int;
13374       size : size_t)
13375       return int;
13377   function tmpfile return FILEs;
13378   function ungetc (c : int; stream : FILEs) return int;
13379   function unlink (filename : chars) return int;
13380   ---------------------
13381   -- Extra functions --
13382   ---------------------
13383   -- These functions supply slightly thicker bindings than
13384   -- those above.  They are derived from functions in the
13385   -- C Run-Time Library, but may do a bit more work than
13386   -- just directly calling one of the Library functions.
13387   function is_regular_file (handle : int) return int;
13388   -- Tests if given handle is for a regular file (result 1)
13389   -- or for a non-regular file (pipe or device, result 0).
13390   ---------------------------------
13391   -- Control of Text/Binary Mode --
13392   ---------------------------------
13393   -- If text_translation_required is true, then the following
13394   -- functions may be used to dynamically switch a file from
13395   -- binary to text mode or vice versa.  These functions have
13396   -- no effect if text_translation_required is false (i.e.@: in
13397   -- normal UNIX mode).  Use fileno to get a stream handle.
13398   procedure set_binary_mode (handle : int);
13399   procedure set_text_mode (handle : int);
13400   ----------------------------
13401   -- Full Path Name support --
13402   ----------------------------
13403   procedure full_name (nam : chars; buffer : chars);
13404   -- Given a NUL terminated string representing a file
13405   -- name, returns in buffer a NUL terminated string
13406   -- representing the full path name for the file name.
13407   -- On systems where it is relevant the   drive is also
13408   -- part of the full path name.  It is the responsibility
13409   -- of the caller to pass an actual parameter for buffer
13410   -- that is big enough for any full path name.  Use
13411   -- max_path_len given below as the size of buffer.
13412   max_path_len : integer;
13413   -- Maximum length of an allowable full path name on the
13414   -- system, including a terminating NUL character.
13415 end Interfaces.C_Streams;
13416 @end smallexample
13418 @node Interfacing to C Streams
13419 @section Interfacing to C Streams
13421 @noindent
13422 The packages in this section permit interfacing Ada files to C Stream
13423 operations.
13425 @smallexample @c ada
13426  with Interfaces.C_Streams;
13427  package Ada.Sequential_IO.C_Streams is
13428     function C_Stream (F : File_Type)
13429        return Interfaces.C_Streams.FILEs;
13430     procedure Open
13431       (File : in out File_Type;
13432        Mode : in File_Mode;
13433        C_Stream : in Interfaces.C_Streams.FILEs;
13434        Form : in String := "");
13435  end Ada.Sequential_IO.C_Streams;
13437   with Interfaces.C_Streams;
13438   package Ada.Direct_IO.C_Streams is
13439      function C_Stream (F : File_Type)
13440         return Interfaces.C_Streams.FILEs;
13441      procedure Open
13442        (File : in out File_Type;
13443         Mode : in File_Mode;
13444         C_Stream : in Interfaces.C_Streams.FILEs;
13445         Form : in String := "");
13446   end Ada.Direct_IO.C_Streams;
13448   with Interfaces.C_Streams;
13449   package Ada.Text_IO.C_Streams is
13450      function C_Stream (F : File_Type)
13451         return Interfaces.C_Streams.FILEs;
13452      procedure Open
13453        (File : in out File_Type;
13454         Mode : in File_Mode;
13455         C_Stream : in Interfaces.C_Streams.FILEs;
13456         Form : in String := "");
13457   end Ada.Text_IO.C_Streams;
13459   with Interfaces.C_Streams;
13460   package Ada.Wide_Text_IO.C_Streams is
13461      function C_Stream (F : File_Type)
13462         return Interfaces.C_Streams.FILEs;
13463      procedure Open
13464        (File : in out File_Type;
13465         Mode : in File_Mode;
13466         C_Stream : in Interfaces.C_Streams.FILEs;
13467         Form : in String := "");
13468  end Ada.Wide_Text_IO.C_Streams;
13470   with Interfaces.C_Streams;
13471   package Ada.Wide_Wide_Text_IO.C_Streams is
13472      function C_Stream (F : File_Type)
13473         return Interfaces.C_Streams.FILEs;
13474      procedure Open
13475        (File : in out File_Type;
13476         Mode : in File_Mode;
13477         C_Stream : in Interfaces.C_Streams.FILEs;
13478         Form : in String := "");
13479  end Ada.Wide_Wide_Text_IO.C_Streams;
13481  with Interfaces.C_Streams;
13482  package Ada.Stream_IO.C_Streams is
13483     function C_Stream (F : File_Type)
13484        return Interfaces.C_Streams.FILEs;
13485     procedure Open
13486       (File : in out File_Type;
13487        Mode : in File_Mode;
13488        C_Stream : in Interfaces.C_Streams.FILEs;
13489        Form : in String := "");
13490  end Ada.Stream_IO.C_Streams;
13491 @end smallexample
13493 @noindent
13494 In each of these six packages, the @code{C_Stream} function obtains the
13495 @code{FILE} pointer from a currently opened Ada file.  It is then
13496 possible to use the @code{Interfaces.C_Streams} package to operate on
13497 this stream, or the stream can be passed to a C program which can
13498 operate on it directly.  Of course the program is responsible for
13499 ensuring that only appropriate sequences of operations are executed.
13501 One particular use of relevance to an Ada program is that the
13502 @code{setvbuf} function can be used to control the buffering of the
13503 stream used by an Ada file.  In the absence of such a call the standard
13504 default buffering is used.
13506 The @code{Open} procedures in these packages open a file giving an
13507 existing C Stream instead of a file name.  Typically this stream is
13508 imported from a C program, allowing an Ada file to operate on an
13509 existing C file.
13511 @node The GNAT Library
13512 @chapter The GNAT Library
13514 @noindent
13515 The GNAT library contains a number of general and special purpose packages.
13516 It represents functionality that the GNAT developers have found useful, and
13517 which is made available to GNAT users.  The packages described here are fully
13518 supported, and upwards compatibility will be maintained in future releases,
13519 so you can use these facilities with the confidence that the same functionality
13520 will be available in future releases.
13522 The chapter here simply gives a brief summary of the facilities available.
13523 The full documentation is found in the spec file for the package.  The full
13524 sources of these library packages, including both spec and body, are provided
13525 with all GNAT releases.  For example, to find out the full specifications of
13526 the SPITBOL pattern matching capability, including a full tutorial and
13527 extensive examples, look in the @file{g-spipat.ads} file in the library.
13529 For each entry here, the package name (as it would appear in a @code{with}
13530 clause) is given, followed by the name of the corresponding spec file in
13531 parentheses.  The packages are children in four hierarchies, @code{Ada},
13532 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13533 GNAT-specific hierarchy.
13535 Note that an application program should only use packages in one of these
13536 four hierarchies if the package is defined in the Ada Reference Manual,
13537 or is listed in this section of the GNAT Programmers Reference Manual.
13538 All other units should be considered internal implementation units and
13539 should not be directly @code{with}'ed by application code.  The use of
13540 a @code{with} statement that references one of these internal implementation
13541 units makes an application potentially dependent on changes in versions
13542 of GNAT, and will generate a warning message.
13544 @menu
13545 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13546 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13547 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13548 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13549 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13550 * Ada.Command_Line.Environment (a-colien.ads)::
13551 * Ada.Command_Line.Remove (a-colire.ads)::
13552 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13553 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13554 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13555 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13556 * Ada.Exceptions.Traceback (a-exctra.ads)::
13557 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13558 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13559 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13560 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13561 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13562 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13563 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13564 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13565 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13566 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13567 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13568 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13569 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13570 * GNAT.Altivec (g-altive.ads)::
13571 * GNAT.Altivec.Conversions (g-altcon.ads)::
13572 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13573 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13574 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13575 * GNAT.Array_Split (g-arrspl.ads)::
13576 * GNAT.AWK (g-awk.ads)::
13577 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13578 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13579 * GNAT.Bubble_Sort (g-bubsor.ads)::
13580 * GNAT.Bubble_Sort_A (g-busora.ads)::
13581 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13582 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13583 * GNAT.Byte_Swapping (g-bytswa.ads)::
13584 * GNAT.Calendar (g-calend.ads)::
13585 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13586 * GNAT.Case_Util (g-casuti.ads)::
13587 * GNAT.CGI (g-cgi.ads)::
13588 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13589 * GNAT.CGI.Debug (g-cgideb.ads)::
13590 * GNAT.Command_Line (g-comlin.ads)::
13591 * GNAT.Compiler_Version (g-comver.ads)::
13592 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13593 * GNAT.CRC32 (g-crc32.ads)::
13594 * GNAT.Current_Exception (g-curexc.ads)::
13595 * GNAT.Debug_Pools (g-debpoo.ads)::
13596 * GNAT.Debug_Utilities (g-debuti.ads)::
13597 * GNAT.Decode_String (g-decstr.ads)::
13598 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13599 * GNAT.Directory_Operations (g-dirope.ads)::
13600 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13601 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13602 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13603 * GNAT.Encode_String (g-encstr.ads)::
13604 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13605 * GNAT.Exception_Actions (g-excact.ads)::
13606 * GNAT.Exception_Traces (g-exctra.ads)::
13607 * GNAT.Exceptions (g-except.ads)::
13608 * GNAT.Expect (g-expect.ads)::
13609 * GNAT.Float_Control (g-flocon.ads)::
13610 * GNAT.Heap_Sort (g-heasor.ads)::
13611 * GNAT.Heap_Sort_A (g-hesora.ads)::
13612 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13613 * GNAT.HTable (g-htable.ads)::
13614 * GNAT.IO (g-io.ads)::
13615 * GNAT.IO_Aux (g-io_aux.ads)::
13616 * GNAT.Lock_Files (g-locfil.ads)::
13617 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
13618 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
13619 * GNAT.MD5 (g-md5.ads)::
13620 * GNAT.Memory_Dump (g-memdum.ads)::
13621 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13622 * GNAT.OS_Lib (g-os_lib.ads)::
13623 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13624 * GNAT.Random_Numbers (g-rannum.ads)::
13625 * GNAT.Regexp (g-regexp.ads)::
13626 * GNAT.Registry (g-regist.ads)::
13627 * GNAT.Regpat (g-regpat.ads)::
13628 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13629 * GNAT.Semaphores (g-semaph.ads)::
13630 * GNAT.Serial_Communications (g-sercom.ads)::
13631 * GNAT.SHA1 (g-sha1.ads)::
13632 * GNAT.SHA224 (g-sha224.ads)::
13633 * GNAT.SHA256 (g-sha256.ads)::
13634 * GNAT.SHA384 (g-sha384.ads)::
13635 * GNAT.SHA512 (g-sha512.ads)::
13636 * GNAT.Signals (g-signal.ads)::
13637 * GNAT.Sockets (g-socket.ads)::
13638 * GNAT.Source_Info (g-souinf.ads)::
13639 * GNAT.Spelling_Checker (g-speche.ads)::
13640 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13641 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13642 * GNAT.Spitbol (g-spitbo.ads)::
13643 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13644 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13645 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13646 * GNAT.SSE (g-sse.ads)::
13647 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13648 * GNAT.Strings (g-string.ads)::
13649 * GNAT.String_Split (g-strspl.ads)::
13650 * GNAT.Table (g-table.ads)::
13651 * GNAT.Task_Lock (g-tasloc.ads)::
13652 * GNAT.Threads (g-thread.ads)::
13653 * GNAT.Time_Stamp (g-timsta.ads)::
13654 * GNAT.Traceback (g-traceb.ads)::
13655 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13656 * GNAT.UTF_32 (g-utf_32.ads)::
13657 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13658 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13659 * GNAT.Wide_String_Split (g-wistsp.ads)::
13660 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13661 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13662 * Interfaces.C.Extensions (i-cexten.ads)::
13663 * Interfaces.C.Streams (i-cstrea.ads)::
13664 * Interfaces.CPP (i-cpp.ads)::
13665 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13666 * Interfaces.VxWorks (i-vxwork.ads)::
13667 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13668 * System.Address_Image (s-addima.ads)::
13669 * System.Assertions (s-assert.ads)::
13670 * System.Memory (s-memory.ads)::
13671 * System.Partition_Interface (s-parint.ads)::
13672 * System.Pool_Global (s-pooglo.ads)::
13673 * System.Pool_Local (s-pooloc.ads)::
13674 * System.Restrictions (s-restri.ads)::
13675 * System.Rident (s-rident.ads)::
13676 * System.Strings.Stream_Ops (s-ststop.ads)::
13677 * System.Task_Info (s-tasinf.ads)::
13678 * System.Wch_Cnv (s-wchcnv.ads)::
13679 * System.Wch_Con (s-wchcon.ads)::
13680 @end menu
13682 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13683 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13684 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13685 @cindex Latin_9 constants for Character
13687 @noindent
13688 This child of @code{Ada.Characters}
13689 provides a set of definitions corresponding to those in the
13690 RM-defined package @code{Ada.Characters.Latin_1} but with the
13691 few modifications required for @code{Latin-9}
13692 The provision of such a package
13693 is specifically authorized by the Ada Reference Manual
13694 (RM A.3.3(27)).
13696 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13697 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13698 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13699 @cindex Latin_1 constants for Wide_Character
13701 @noindent
13702 This child of @code{Ada.Characters}
13703 provides a set of definitions corresponding to those in the
13704 RM-defined package @code{Ada.Characters.Latin_1} but with the
13705 types of the constants being @code{Wide_Character}
13706 instead of @code{Character}.  The provision of such a package
13707 is specifically authorized by the Ada Reference Manual
13708 (RM A.3.3(27)).
13710 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13711 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13712 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13713 @cindex Latin_9 constants for Wide_Character
13715 @noindent
13716 This child of @code{Ada.Characters}
13717 provides a set of definitions corresponding to those in the
13718 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13719 types of the constants being @code{Wide_Character}
13720 instead of @code{Character}.  The provision of such a package
13721 is specifically authorized by the Ada Reference Manual
13722 (RM A.3.3(27)).
13724 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13725 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13726 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13727 @cindex Latin_1 constants for Wide_Wide_Character
13729 @noindent
13730 This child of @code{Ada.Characters}
13731 provides a set of definitions corresponding to those in the
13732 RM-defined package @code{Ada.Characters.Latin_1} but with the
13733 types of the constants being @code{Wide_Wide_Character}
13734 instead of @code{Character}.  The provision of such a package
13735 is specifically authorized by the Ada Reference Manual
13736 (RM A.3.3(27)).
13738 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13739 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13740 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13741 @cindex Latin_9 constants for Wide_Wide_Character
13743 @noindent
13744 This child of @code{Ada.Characters}
13745 provides a set of definitions corresponding to those in the
13746 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13747 types of the constants being @code{Wide_Wide_Character}
13748 instead of @code{Character}.  The provision of such a package
13749 is specifically authorized by the Ada Reference Manual
13750 (RM A.3.3(27)).
13752 @node Ada.Command_Line.Environment (a-colien.ads)
13753 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13754 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13755 @cindex Environment entries
13757 @noindent
13758 This child of @code{Ada.Command_Line}
13759 provides a mechanism for obtaining environment values on systems
13760 where this concept makes sense.
13762 @node Ada.Command_Line.Remove (a-colire.ads)
13763 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13764 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13765 @cindex Removing command line arguments
13766 @cindex Command line, argument removal
13768 @noindent
13769 This child of @code{Ada.Command_Line}
13770 provides a mechanism for logically removing
13771 arguments from the argument list.  Once removed, an argument is not visible
13772 to further calls on the subprograms in @code{Ada.Command_Line} will not
13773 see the removed argument.
13775 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13776 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13777 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13778 @cindex Response file for command line
13779 @cindex Command line, response file
13780 @cindex Command line, handling long command lines
13782 @noindent
13783 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13784 getting command line arguments from a text file, called a "response file".
13785 Using a response file allow passing a set of arguments to an executable longer
13786 than the maximum allowed by the system on the command line.
13788 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13789 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13790 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13791 @cindex C Streams, Interfacing with Direct_IO
13793 @noindent
13794 This package provides subprograms that allow interfacing between
13795 C streams and @code{Direct_IO}.  The stream identifier can be
13796 extracted from a file opened on the Ada side, and an Ada file
13797 can be constructed from a stream opened on the C side.
13799 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13800 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13801 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13802 @cindex Null_Occurrence, testing for
13804 @noindent
13805 This child subprogram provides a way of testing for the null
13806 exception occurrence (@code{Null_Occurrence}) without raising
13807 an exception.
13809 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13810 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13811 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13812 @cindex Null_Occurrence, testing for
13814 @noindent
13815 This child subprogram is used for handling otherwise unhandled
13816 exceptions (hence the name last chance), and perform clean ups before
13817 terminating the program. Note that this subprogram never returns.
13819 @node Ada.Exceptions.Traceback (a-exctra.ads)
13820 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13821 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13822 @cindex Traceback for Exception Occurrence
13824 @noindent
13825 This child package provides the subprogram (@code{Tracebacks}) to
13826 give a traceback array of addresses based on an exception
13827 occurrence.
13829 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13830 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13831 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13832 @cindex C Streams, Interfacing with Sequential_IO
13834 @noindent
13835 This package provides subprograms that allow interfacing between
13836 C streams and @code{Sequential_IO}.  The stream identifier can be
13837 extracted from a file opened on the Ada side, and an Ada file
13838 can be constructed from a stream opened on the C side.
13840 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13841 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13842 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13843 @cindex C Streams, Interfacing with Stream_IO
13845 @noindent
13846 This package provides subprograms that allow interfacing between
13847 C streams and @code{Stream_IO}.  The stream identifier can be
13848 extracted from a file opened on the Ada side, and an Ada file
13849 can be constructed from a stream opened on the C side.
13851 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13852 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13853 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13854 @cindex @code{Unbounded_String}, IO support
13855 @cindex @code{Text_IO}, extensions for unbounded strings
13857 @noindent
13858 This package provides subprograms for Text_IO for unbounded
13859 strings, avoiding the necessity for an intermediate operation
13860 with ordinary strings.
13862 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13863 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13864 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13865 @cindex @code{Unbounded_Wide_String}, IO support
13866 @cindex @code{Text_IO}, extensions for unbounded wide strings
13868 @noindent
13869 This package provides subprograms for Text_IO for unbounded
13870 wide strings, avoiding the necessity for an intermediate operation
13871 with ordinary wide strings.
13873 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13874 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13875 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13876 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13877 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13879 @noindent
13880 This package provides subprograms for Text_IO for unbounded
13881 wide wide strings, avoiding the necessity for an intermediate operation
13882 with ordinary wide wide strings.
13884 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13885 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13886 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13887 @cindex C Streams, Interfacing with @code{Text_IO}
13889 @noindent
13890 This package provides subprograms that allow interfacing between
13891 C streams and @code{Text_IO}.  The stream identifier can be
13892 extracted from a file opened on the Ada side, and an Ada file
13893 can be constructed from a stream opened on the C side.
13895 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
13896 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13897 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13898 @cindex @code{Text_IO} resetting standard files
13900 @noindent
13901 This procedure is used to reset the status of the standard files used
13902 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
13903 embedded application) where the status of the files may change during
13904 execution (for example a standard input file may be redefined to be
13905 interactive).
13907 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13908 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13909 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13910 @cindex Unicode categorization, Wide_Character
13912 @noindent
13913 This package provides subprograms that allow categorization of
13914 Wide_Character values according to Unicode categories.
13916 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13917 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13918 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13919 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13921 @noindent
13922 This package provides subprograms that allow interfacing between
13923 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13924 extracted from a file opened on the Ada side, and an Ada file
13925 can be constructed from a stream opened on the C side.
13927 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
13928 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13929 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13930 @cindex @code{Wide_Text_IO} resetting standard files
13932 @noindent
13933 This procedure is used to reset the status of the standard files used
13934 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
13935 embedded application) where the status of the files may change during
13936 execution (for example a standard input file may be redefined to be
13937 interactive).
13939 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13940 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13941 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13942 @cindex Unicode categorization, Wide_Wide_Character
13944 @noindent
13945 This package provides subprograms that allow categorization of
13946 Wide_Wide_Character values according to Unicode categories.
13948 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13949 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13950 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13951 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13953 @noindent
13954 This package provides subprograms that allow interfacing between
13955 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13956 extracted from a file opened on the Ada side, and an Ada file
13957 can be constructed from a stream opened on the C side.
13959 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
13960 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13961 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13962 @cindex @code{Wide_Wide_Text_IO} resetting standard files
13964 @noindent
13965 This procedure is used to reset the status of the standard files used
13966 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
13967 restart in an embedded application) where the status of the files may
13968 change during execution (for example a standard input file may be
13969 redefined to be interactive).
13971 @node GNAT.Altivec (g-altive.ads)
13972 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13973 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13974 @cindex AltiVec
13976 @noindent
13977 This is the root package of the GNAT AltiVec binding. It provides
13978 definitions of constants and types common to all the versions of the
13979 binding.
13981 @node GNAT.Altivec.Conversions (g-altcon.ads)
13982 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13983 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13984 @cindex AltiVec
13986 @noindent
13987 This package provides the Vector/View conversion routines.
13989 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13990 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13991 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13992 @cindex AltiVec
13994 @noindent
13995 This package exposes the Ada interface to the AltiVec operations on
13996 vector objects. A soft emulation is included by default in the GNAT
13997 library. The hard binding is provided as a separate package. This unit
13998 is common to both bindings.
14000 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14001 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14002 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14003 @cindex AltiVec
14005 @noindent
14006 This package exposes the various vector types part of the Ada binding
14007 to AltiVec facilities.
14009 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14010 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14011 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14012 @cindex AltiVec
14014 @noindent
14015 This package provides public 'View' data types from/to which private
14016 vector representations can be converted via
14017 GNAT.Altivec.Conversions. This allows convenient access to individual
14018 vector elements and provides a simple way to initialize vector
14019 objects.
14021 @node GNAT.Array_Split (g-arrspl.ads)
14022 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14023 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14024 @cindex Array splitter
14026 @noindent
14027 Useful array-manipulation routines: given a set of separators, split
14028 an array wherever the separators appear, and provide direct access
14029 to the resulting slices.
14031 @node GNAT.AWK (g-awk.ads)
14032 @section @code{GNAT.AWK} (@file{g-awk.ads})
14033 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14034 @cindex Parsing
14035 @cindex AWK
14037 @noindent
14038 Provides AWK-like parsing functions, with an easy interface for parsing one
14039 or more files containing formatted data.  The file is viewed as a database
14040 where each record is a line and a field is a data element in this line.
14042 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14043 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14044 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14045 @cindex Parsing
14046 @cindex Bounded Buffers
14048 @noindent
14049 Provides a concurrent generic bounded buffer abstraction.  Instances are
14050 useful directly or as parts of the implementations of other abstractions,
14051 such as mailboxes.
14053 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14054 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14055 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14056 @cindex Parsing
14057 @cindex Mailboxes
14059 @noindent
14060 Provides a thread-safe asynchronous intertask mailbox communication facility.
14062 @node GNAT.Bubble_Sort (g-bubsor.ads)
14063 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14064 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14065 @cindex Sorting
14066 @cindex Bubble sort
14068 @noindent
14069 Provides a general implementation of bubble sort usable for sorting arbitrary
14070 data items.  Exchange and comparison procedures are provided by passing
14071 access-to-procedure values.
14073 @node GNAT.Bubble_Sort_A (g-busora.ads)
14074 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14075 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14076 @cindex Sorting
14077 @cindex Bubble sort
14079 @noindent
14080 Provides a general implementation of bubble sort usable for sorting arbitrary
14081 data items.  Move and comparison procedures are provided by passing
14082 access-to-procedure values. This is an older version, retained for
14083 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14085 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14086 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14087 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14088 @cindex Sorting
14089 @cindex Bubble sort
14091 @noindent
14092 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14093 are provided as generic parameters, this improves efficiency, especially
14094 if the procedures can be inlined, at the expense of duplicating code for
14095 multiple instantiations.
14097 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14098 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14099 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14100 @cindex UTF-8 representation
14101 @cindex Wide characte representations
14103 @noindent
14104 Provides a routine which given a string, reads the start of the string to
14105 see whether it is one of the standard byte order marks (BOM's) which signal
14106 the encoding of the string. The routine includes detection of special XML
14107 sequences for various UCS input formats.
14109 @node GNAT.Byte_Swapping (g-bytswa.ads)
14110 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14111 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14112 @cindex Byte swapping
14113 @cindex Endian
14115 @noindent
14116 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14117 Machine-specific implementations are available in some cases.
14119 @node GNAT.Calendar (g-calend.ads)
14120 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14121 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14122 @cindex @code{Calendar}
14124 @noindent
14125 Extends the facilities provided by @code{Ada.Calendar} to include handling
14126 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14127 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14128 C @code{timeval} format.
14130 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14131 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14132 @cindex @code{Calendar}
14133 @cindex Time
14134 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14136 @node GNAT.CRC32 (g-crc32.ads)
14137 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14138 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14139 @cindex CRC32
14140 @cindex Cyclic Redundancy Check
14142 @noindent
14143 This package implements the CRC-32 algorithm.  For a full description
14144 of this algorithm see
14145 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14146 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14147 Aug.@: 1988.  Sarwate, D.V@.
14149 @node GNAT.Case_Util (g-casuti.ads)
14150 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14151 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14152 @cindex Casing utilities
14153 @cindex Character handling (@code{GNAT.Case_Util})
14155 @noindent
14156 A set of simple routines for handling upper and lower casing of strings
14157 without the overhead of the full casing tables
14158 in @code{Ada.Characters.Handling}.
14160 @node GNAT.CGI (g-cgi.ads)
14161 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14162 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14163 @cindex CGI (Common Gateway Interface)
14165 @noindent
14166 This is a package for interfacing a GNAT program with a Web server via the
14167 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14168 parameters, which are a set of key/value pairs sent by the Web server.  It
14169 builds a table whose index is the key and provides some services to deal
14170 with this table.
14172 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14173 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14174 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14175 @cindex CGI (Common Gateway Interface) cookie support
14176 @cindex Cookie support in CGI
14178 @noindent
14179 This is a package to interface a GNAT program with a Web server via the
14180 Common Gateway Interface (CGI).  It exports services to deal with Web
14181 cookies (piece of information kept in the Web client software).
14183 @node GNAT.CGI.Debug (g-cgideb.ads)
14184 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14185 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14186 @cindex CGI (Common Gateway Interface) debugging
14188 @noindent
14189 This is a package to help debugging CGI (Common Gateway Interface)
14190 programs written in Ada.
14192 @node GNAT.Command_Line (g-comlin.ads)
14193 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14194 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14195 @cindex Command line
14197 @noindent
14198 Provides a high level interface to @code{Ada.Command_Line} facilities,
14199 including the ability to scan for named switches with optional parameters
14200 and expand file names using wild card notations.
14202 @node GNAT.Compiler_Version (g-comver.ads)
14203 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14204 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14205 @cindex Compiler Version
14206 @cindex Version, of compiler
14208 @noindent
14209 Provides a routine for obtaining the version of the compiler used to
14210 compile the program. More accurately this is the version of the binder
14211 used to bind the program (this will normally be the same as the version
14212 of the compiler if a consistent tool set is used to compile all units
14213 of a partition).
14215 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14216 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14217 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14218 @cindex Interrupt
14220 @noindent
14221 Provides a simple interface to handle Ctrl-C keyboard events.
14223 @node GNAT.Current_Exception (g-curexc.ads)
14224 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14225 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14226 @cindex Current exception
14227 @cindex Exception retrieval
14229 @noindent
14230 Provides access to information on the current exception that has been raised
14231 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14232 specification syntax.
14233 This is particularly useful in simulating typical facilities for
14234 obtaining information about exceptions provided by Ada 83 compilers.
14236 @node GNAT.Debug_Pools (g-debpoo.ads)
14237 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14238 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14239 @cindex Debugging
14240 @cindex Debug pools
14241 @cindex Memory corruption debugging
14243 @noindent
14244 Provide a debugging storage pools that helps tracking memory corruption
14245 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14246 @value{EDITION} User's Guide}.
14248 @node GNAT.Debug_Utilities (g-debuti.ads)
14249 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14250 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14251 @cindex Debugging
14253 @noindent
14254 Provides a few useful utilities for debugging purposes, including conversion
14255 to and from string images of address values. Supports both C and Ada formats
14256 for hexadecimal literals.
14258 @node GNAT.Decode_String (g-decstr.ads)
14259 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14260 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14261 @cindex Decoding strings
14262 @cindex String decoding
14263 @cindex Wide character encoding
14264 @cindex UTF-8
14265 @cindex Unicode
14267 @noindent
14268 A generic package providing routines for decoding wide character and wide wide
14269 character strings encoded as sequences of 8-bit characters using a specified
14270 encoding method. Includes validation routines, and also routines for stepping
14271 to next or previous encoded character in an encoded string.
14272 Useful in conjunction with Unicode character coding. Note there is a
14273 preinstantiation for UTF-8. See next entry.
14275 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14276 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14277 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14278 @cindex Decoding strings
14279 @cindex Decoding UTF-8 strings
14280 @cindex UTF-8 string decoding
14281 @cindex Wide character decoding
14282 @cindex UTF-8
14283 @cindex Unicode
14285 @noindent
14286 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14288 @node GNAT.Directory_Operations (g-dirope.ads)
14289 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14290 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14291 @cindex Directory operations
14293 @noindent
14294 Provides a set of routines for manipulating directories, including changing
14295 the current directory, making new directories, and scanning the files in a
14296 directory.
14298 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14299 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14300 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14301 @cindex Directory operations iteration
14303 @noindent
14304 A child unit of GNAT.Directory_Operations providing additional operations
14305 for iterating through directories.
14307 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14308 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14309 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14310 @cindex Hash tables
14312 @noindent
14313 A generic implementation of hash tables that can be used to hash arbitrary
14314 data.  Provided in two forms, a simple form with built in hash functions,
14315 and a more complex form in which the hash function is supplied.
14317 @noindent
14318 This package provides a facility similar to that of @code{GNAT.HTable},
14319 except that this package declares a type that can be used to define
14320 dynamic instances of the hash table, while an instantiation of
14321 @code{GNAT.HTable} creates a single instance of the hash table.
14323 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14324 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14325 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14326 @cindex Table implementation
14327 @cindex Arrays, extendable
14329 @noindent
14330 A generic package providing a single dimension array abstraction where the
14331 length of the array can be dynamically modified.
14333 @noindent
14334 This package provides a facility similar to that of @code{GNAT.Table},
14335 except that this package declares a type that can be used to define
14336 dynamic instances of the table, while an instantiation of
14337 @code{GNAT.Table} creates a single instance of the table type.
14339 @node GNAT.Encode_String (g-encstr.ads)
14340 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14341 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14342 @cindex Encoding strings
14343 @cindex String encoding
14344 @cindex Wide character encoding
14345 @cindex UTF-8
14346 @cindex Unicode
14348 @noindent
14349 A generic package providing routines for encoding wide character and wide
14350 wide character strings as sequences of 8-bit characters using a specified
14351 encoding method. Useful in conjunction with Unicode character coding.
14352 Note there is a preinstantiation for UTF-8. See next entry.
14354 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14355 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14356 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14357 @cindex Encoding strings
14358 @cindex Encoding UTF-8 strings
14359 @cindex UTF-8 string encoding
14360 @cindex Wide character encoding
14361 @cindex UTF-8
14362 @cindex Unicode
14364 @noindent
14365 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14367 @node GNAT.Exception_Actions (g-excact.ads)
14368 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14369 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14370 @cindex Exception actions
14372 @noindent
14373 Provides callbacks when an exception is raised. Callbacks can be registered
14374 for specific exceptions, or when any exception is raised. This
14375 can be used for instance to force a core dump to ease debugging.
14377 @node GNAT.Exception_Traces (g-exctra.ads)
14378 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14379 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14380 @cindex Exception traces
14381 @cindex Debugging
14383 @noindent
14384 Provides an interface allowing to control automatic output upon exception
14385 occurrences.
14387 @node GNAT.Exceptions (g-except.ads)
14388 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14389 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14390 @cindex Exceptions, Pure
14391 @cindex Pure packages, exceptions
14393 @noindent
14394 Normally it is not possible to raise an exception with
14395 a message from a subprogram in a pure package, since the
14396 necessary types and subprograms are in @code{Ada.Exceptions}
14397 which is not a pure unit. @code{GNAT.Exceptions} provides a
14398 facility for getting around this limitation for a few
14399 predefined exceptions, and for example allow raising
14400 @code{Constraint_Error} with a message from a pure subprogram.
14402 @node GNAT.Expect (g-expect.ads)
14403 @section @code{GNAT.Expect} (@file{g-expect.ads})
14404 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14406 @noindent
14407 Provides a set of subprograms similar to what is available
14408 with the standard Tcl Expect tool.
14409 It allows you to easily spawn and communicate with an external process.
14410 You can send commands or inputs to the process, and compare the output
14411 with some expected regular expression. Currently @code{GNAT.Expect}
14412 is implemented on all native GNAT ports except for OpenVMS@.
14413 It is not implemented for cross ports, and in particular is not
14414 implemented for VxWorks or LynxOS@.
14416 @node GNAT.Float_Control (g-flocon.ads)
14417 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14418 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14419 @cindex Floating-Point Processor
14421 @noindent
14422 Provides an interface for resetting the floating-point processor into the
14423 mode required for correct semantic operation in Ada.  Some third party
14424 library calls may cause this mode to be modified, and the Reset procedure
14425 in this package can be used to reestablish the required mode.
14427 @node GNAT.Heap_Sort (g-heasor.ads)
14428 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14429 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14430 @cindex Sorting
14432 @noindent
14433 Provides a general implementation of heap sort usable for sorting arbitrary
14434 data items. Exchange and comparison procedures are provided by passing
14435 access-to-procedure values.  The algorithm used is a modified heap sort
14436 that performs approximately N*log(N) comparisons in the worst case.
14438 @node GNAT.Heap_Sort_A (g-hesora.ads)
14439 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14440 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14441 @cindex Sorting
14443 @noindent
14444 Provides a general implementation of heap sort usable for sorting arbitrary
14445 data items. Move and comparison procedures are provided by passing
14446 access-to-procedure values.  The algorithm used is a modified heap sort
14447 that performs approximately N*log(N) comparisons in the worst case.
14448 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14449 interface, but may be slightly more efficient.
14451 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14452 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14453 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14454 @cindex Sorting
14456 @noindent
14457 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14458 are provided as generic parameters, this improves efficiency, especially
14459 if the procedures can be inlined, at the expense of duplicating code for
14460 multiple instantiations.
14462 @node GNAT.HTable (g-htable.ads)
14463 @section @code{GNAT.HTable} (@file{g-htable.ads})
14464 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14465 @cindex Hash tables
14467 @noindent
14468 A generic implementation of hash tables that can be used to hash arbitrary
14469 data.  Provides two approaches, one a simple static approach, and the other
14470 allowing arbitrary dynamic hash tables.
14472 @node GNAT.IO (g-io.ads)
14473 @section @code{GNAT.IO} (@file{g-io.ads})
14474 @cindex @code{GNAT.IO} (@file{g-io.ads})
14475 @cindex Simple I/O
14476 @cindex Input/Output facilities
14478 @noindent
14479 A simple preelaborable input-output package that provides a subset of
14480 simple Text_IO functions for reading characters and strings from
14481 Standard_Input, and writing characters, strings and integers to either
14482 Standard_Output or Standard_Error.
14484 @node GNAT.IO_Aux (g-io_aux.ads)
14485 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14486 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14487 @cindex Text_IO
14488 @cindex Input/Output facilities
14490 Provides some auxiliary functions for use with Text_IO, including a test
14491 for whether a file exists, and functions for reading a line of text.
14493 @node GNAT.Lock_Files (g-locfil.ads)
14494 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14495 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14496 @cindex File locking
14497 @cindex Locking using files
14499 @noindent
14500 Provides a general interface for using files as locks.  Can be used for
14501 providing program level synchronization.
14503 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
14504 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14505 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14506 @cindex Random number generation
14508 @noindent
14509 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
14510 a modified version of the Blum-Blum-Shub generator.
14512 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
14513 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14514 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14515 @cindex Random number generation
14517 @noindent
14518 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
14519 a modified version of the Blum-Blum-Shub generator.
14521 @node GNAT.MD5 (g-md5.ads)
14522 @section @code{GNAT.MD5} (@file{g-md5.ads})
14523 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14524 @cindex Message Digest MD5
14526 @noindent
14527 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14529 @node GNAT.Memory_Dump (g-memdum.ads)
14530 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14531 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14532 @cindex Dump Memory
14534 @noindent
14535 Provides a convenient routine for dumping raw memory to either the
14536 standard output or standard error files. Uses GNAT.IO for actual
14537 output.
14539 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14540 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14541 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14542 @cindex Exception, obtaining most recent
14544 @noindent
14545 Provides access to the most recently raised exception.  Can be used for
14546 various logging purposes, including duplicating functionality of some
14547 Ada 83 implementation dependent extensions.
14549 @node GNAT.OS_Lib (g-os_lib.ads)
14550 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14551 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14552 @cindex Operating System interface
14553 @cindex Spawn capability
14555 @noindent
14556 Provides a range of target independent operating system interface functions,
14557 including time/date management, file operations, subprocess management,
14558 including a portable spawn procedure, and access to environment variables
14559 and error return codes.
14561 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14562 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14563 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14564 @cindex Hash functions
14566 @noindent
14567 Provides a generator of static minimal perfect hash functions. No
14568 collisions occur and each item can be retrieved from the table in one
14569 probe (perfect property). The hash table size corresponds to the exact
14570 size of the key set and no larger (minimal property). The key set has to
14571 be know in advance (static property). The hash functions are also order
14572 preserving. If w2 is inserted after w1 in the generator, their
14573 hashcode are in the same order. These hashing functions are very
14574 convenient for use with realtime applications.
14576 @node GNAT.Random_Numbers (g-rannum.ads)
14577 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14578 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14579 @cindex Random number generation
14581 @noindent
14582 Provides random number capabilities which extend those available in the
14583 standard Ada library and are more convenient to use.
14585 @node GNAT.Regexp (g-regexp.ads)
14586 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14587 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14588 @cindex Regular expressions
14589 @cindex Pattern matching
14591 @noindent
14592 A simple implementation of regular expressions, using a subset of regular
14593 expression syntax copied from familiar Unix style utilities.  This is the
14594 simples of the three pattern matching packages provided, and is particularly
14595 suitable for ``file globbing'' applications.
14597 @node GNAT.Registry (g-regist.ads)
14598 @section @code{GNAT.Registry} (@file{g-regist.ads})
14599 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14600 @cindex Windows Registry
14602 @noindent
14603 This is a high level binding to the Windows registry.  It is possible to
14604 do simple things like reading a key value, creating a new key.  For full
14605 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14606 package provided with the Win32Ada binding
14608 @node GNAT.Regpat (g-regpat.ads)
14609 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14610 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14611 @cindex Regular expressions
14612 @cindex Pattern matching
14614 @noindent
14615 A complete implementation of Unix-style regular expression matching, copied
14616 from the original V7 style regular expression library written in C by
14617 Henry Spencer (and binary compatible with this C library).
14619 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14620 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14621 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14622 @cindex Secondary Stack Info
14624 @noindent
14625 Provide the capability to query the high water mark of the current task's
14626 secondary stack.
14628 @node GNAT.Semaphores (g-semaph.ads)
14629 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14630 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14631 @cindex Semaphores
14633 @noindent
14634 Provides classic counting and binary semaphores using protected types.
14636 @node GNAT.Serial_Communications (g-sercom.ads)
14637 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14638 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14639 @cindex Serial_Communications
14641 @noindent
14642 Provides a simple interface to send and receive data over a serial
14643 port. This is only supported on GNU/Linux and Windows.
14645 @node GNAT.SHA1 (g-sha1.ads)
14646 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14647 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14648 @cindex Secure Hash Algorithm SHA-1
14650 @noindent
14651 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14652 and RFC 3174.
14654 @node GNAT.SHA224 (g-sha224.ads)
14655 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
14656 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14657 @cindex Secure Hash Algorithm SHA-224
14659 @noindent
14660 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14662 @node GNAT.SHA256 (g-sha256.ads)
14663 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
14664 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14665 @cindex Secure Hash Algorithm SHA-256
14667 @noindent
14668 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14670 @node GNAT.SHA384 (g-sha384.ads)
14671 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
14672 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14673 @cindex Secure Hash Algorithm SHA-384
14675 @noindent
14676 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14678 @node GNAT.SHA512 (g-sha512.ads)
14679 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
14680 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14681 @cindex Secure Hash Algorithm SHA-512
14683 @noindent
14684 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14686 @node GNAT.Signals (g-signal.ads)
14687 @section @code{GNAT.Signals} (@file{g-signal.ads})
14688 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14689 @cindex Signals
14691 @noindent
14692 Provides the ability to manipulate the blocked status of signals on supported
14693 targets.
14695 @node GNAT.Sockets (g-socket.ads)
14696 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14697 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14698 @cindex Sockets
14700 @noindent
14701 A high level and portable interface to develop sockets based applications.
14702 This package is based on the sockets thin binding found in
14703 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14704 on all native GNAT ports except for OpenVMS@.  It is not implemented
14705 for the LynxOS@ cross port.
14707 @node GNAT.Source_Info (g-souinf.ads)
14708 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14709 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14710 @cindex Source Information
14712 @noindent
14713 Provides subprograms that give access to source code information known at
14714 compile time, such as the current file name and line number.
14716 @node GNAT.Spelling_Checker (g-speche.ads)
14717 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14718 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14719 @cindex Spell checking
14721 @noindent
14722 Provides a function for determining whether one string is a plausible
14723 near misspelling of another string.
14725 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14726 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14727 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14728 @cindex Spell checking
14730 @noindent
14731 Provides a generic function that can be instantiated with a string type for
14732 determining whether one string is a plausible near misspelling of another
14733 string.
14735 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14736 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14737 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14738 @cindex SPITBOL pattern matching
14739 @cindex Pattern matching
14741 @noindent
14742 A complete implementation of SNOBOL4 style pattern matching.  This is the
14743 most elaborate of the pattern matching packages provided.  It fully duplicates
14744 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14745 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14747 @node GNAT.Spitbol (g-spitbo.ads)
14748 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14749 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14750 @cindex SPITBOL interface
14752 @noindent
14753 The top level package of the collection of SPITBOL-style functionality, this
14754 package provides basic SNOBOL4 string manipulation functions, such as
14755 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14756 useful for constructing arbitrary mappings from strings in the style of
14757 the SNOBOL4 TABLE function.
14759 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14760 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14761 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14762 @cindex Sets of strings
14763 @cindex SPITBOL Tables
14765 @noindent
14766 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14767 for type @code{Standard.Boolean}, giving an implementation of sets of
14768 string values.
14770 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14771 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14772 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14773 @cindex Integer maps
14774 @cindex Maps
14775 @cindex SPITBOL Tables
14777 @noindent
14778 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14779 for type @code{Standard.Integer}, giving an implementation of maps
14780 from string to integer values.
14782 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14783 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14784 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14785 @cindex String maps
14786 @cindex Maps
14787 @cindex SPITBOL Tables
14789 @noindent
14790 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14791 a variable length string type, giving an implementation of general
14792 maps from strings to strings.
14794 @node GNAT.SSE (g-sse.ads)
14795 @section @code{GNAT.SSE} (@file{g-sse.ads})
14796 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14798 @noindent
14799 Root of a set of units aimed at offering Ada bindings to a subset of
14800 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14801 targets.  It exposes vector component types together with a general
14802 introduction to the binding contents and use.
14804 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14805 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14806 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14808 @noindent
14809 SSE vector types for use with SSE related intrinsics.
14811 @node GNAT.Strings (g-string.ads)
14812 @section @code{GNAT.Strings} (@file{g-string.ads})
14813 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14815 @noindent
14816 Common String access types and related subprograms. Basically it
14817 defines a string access and an array of string access types.
14819 @node GNAT.String_Split (g-strspl.ads)
14820 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14821 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14822 @cindex String splitter
14824 @noindent
14825 Useful string manipulation routines: given a set of separators, split
14826 a string wherever the separators appear, and provide direct access
14827 to the resulting slices. This package is instantiated from
14828 @code{GNAT.Array_Split}.
14830 @node GNAT.Table (g-table.ads)
14831 @section @code{GNAT.Table} (@file{g-table.ads})
14832 @cindex @code{GNAT.Table} (@file{g-table.ads})
14833 @cindex Table implementation
14834 @cindex Arrays, extendable
14836 @noindent
14837 A generic package providing a single dimension array abstraction where the
14838 length of the array can be dynamically modified.
14840 @noindent
14841 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14842 except that this package declares a single instance of the table type,
14843 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14844 used to define dynamic instances of the table.
14846 @node GNAT.Task_Lock (g-tasloc.ads)
14847 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14848 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14849 @cindex Task synchronization
14850 @cindex Task locking
14851 @cindex Locking
14853 @noindent
14854 A very simple facility for locking and unlocking sections of code using a
14855 single global task lock.  Appropriate for use in situations where contention
14856 between tasks is very rarely expected.
14858 @node GNAT.Time_Stamp (g-timsta.ads)
14859 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14860 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14861 @cindex Time stamp
14862 @cindex Current time
14864 @noindent
14865 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14866 represents the current date and time in ISO 8601 format. This is a very simple
14867 routine with minimal code and there are no dependencies on any other unit.
14869 @node GNAT.Threads (g-thread.ads)
14870 @section @code{GNAT.Threads} (@file{g-thread.ads})
14871 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14872 @cindex Foreign threads
14873 @cindex Threads, foreign
14875 @noindent
14876 Provides facilities for dealing with foreign threads which need to be known
14877 by the GNAT run-time system. Consult the documentation of this package for
14878 further details if your program has threads that are created by a non-Ada
14879 environment which then accesses Ada code.
14881 @node GNAT.Traceback (g-traceb.ads)
14882 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14883 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14884 @cindex Trace back facilities
14886 @noindent
14887 Provides a facility for obtaining non-symbolic traceback information, useful
14888 in various debugging situations.
14890 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14891 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14892 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14893 @cindex Trace back facilities
14895 @node GNAT.UTF_32 (g-utf_32.ads)
14896 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14897 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14898 @cindex Wide character codes
14900 @noindent
14901 This is a package intended to be used in conjunction with the
14902 @code{Wide_Character} type in Ada 95 and the
14903 @code{Wide_Wide_Character} type in Ada 2005 (available
14904 in @code{GNAT} in Ada 2005 mode). This package contains
14905 Unicode categorization routines, as well as lexical
14906 categorization routines corresponding to the Ada 2005
14907 lexical rules for identifiers and strings, and also a
14908 lower case to upper case fold routine corresponding to
14909 the Ada 2005 rules for identifier equivalence.
14911 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14912 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14913 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14914 @cindex Spell checking
14916 @noindent
14917 Provides a function for determining whether one wide wide string is a plausible
14918 near misspelling of another wide wide string, where the strings are represented
14919 using the UTF_32_String type defined in System.Wch_Cnv.
14921 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14922 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14923 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14924 @cindex Spell checking
14926 @noindent
14927 Provides a function for determining whether one wide string is a plausible
14928 near misspelling of another wide string.
14930 @node GNAT.Wide_String_Split (g-wistsp.ads)
14931 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14932 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14933 @cindex Wide_String splitter
14935 @noindent
14936 Useful wide string manipulation routines: given a set of separators, split
14937 a wide string wherever the separators appear, and provide direct access
14938 to the resulting slices. This package is instantiated from
14939 @code{GNAT.Array_Split}.
14941 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14942 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14943 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14944 @cindex Spell checking
14946 @noindent
14947 Provides a function for determining whether one wide wide string is a plausible
14948 near misspelling of another wide wide string.
14950 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14951 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14952 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14953 @cindex Wide_Wide_String splitter
14955 @noindent
14956 Useful wide wide string manipulation routines: given a set of separators, split
14957 a wide wide string wherever the separators appear, and provide direct access
14958 to the resulting slices. This package is instantiated from
14959 @code{GNAT.Array_Split}.
14961 @node Interfaces.C.Extensions (i-cexten.ads)
14962 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14963 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14965 @noindent
14966 This package contains additional C-related definitions, intended
14967 for use with either manually or automatically generated bindings
14968 to C libraries.
14970 @node Interfaces.C.Streams (i-cstrea.ads)
14971 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14972 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14973 @cindex  C streams, interfacing
14975 @noindent
14976 This package is a binding for the most commonly used operations
14977 on C streams.
14979 @node Interfaces.CPP (i-cpp.ads)
14980 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14981 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14982 @cindex  C++ interfacing
14983 @cindex  Interfacing, to C++
14985 @noindent
14986 This package provides facilities for use in interfacing to C++.  It
14987 is primarily intended to be used in connection with automated tools
14988 for the generation of C++ interfaces.
14990 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14991 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14992 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14993 @cindex  IBM Packed Format
14994 @cindex  Packed Decimal
14996 @noindent
14997 This package provides a set of routines for conversions to and
14998 from a packed decimal format compatible with that used on IBM
14999 mainframes.
15001 @node Interfaces.VxWorks (i-vxwork.ads)
15002 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15003 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15004 @cindex Interfacing to VxWorks
15005 @cindex VxWorks, interfacing
15007 @noindent
15008 This package provides a limited binding to the VxWorks API.
15009 In particular, it interfaces with the
15010 VxWorks hardware interrupt facilities.
15012 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15013 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15014 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15015 @cindex Interfacing to VxWorks' I/O
15016 @cindex VxWorks, I/O interfacing
15017 @cindex VxWorks, Get_Immediate
15018 @cindex Get_Immediate, VxWorks
15020 @noindent
15021 This package provides a binding to the ioctl (IO/Control)
15022 function of VxWorks, defining a set of option values and
15023 function codes. A particular use of this package is
15024 to enable the use of Get_Immediate under VxWorks.
15026 @node System.Address_Image (s-addima.ads)
15027 @section @code{System.Address_Image} (@file{s-addima.ads})
15028 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15029 @cindex Address image
15030 @cindex Image, of an address
15032 @noindent
15033 This function provides a useful debugging
15034 function that gives an (implementation dependent)
15035 string which identifies an address.
15037 @node System.Assertions (s-assert.ads)
15038 @section @code{System.Assertions} (@file{s-assert.ads})
15039 @cindex @code{System.Assertions} (@file{s-assert.ads})
15040 @cindex Assertions
15041 @cindex Assert_Failure, exception
15043 @noindent
15044 This package provides the declaration of the exception raised
15045 by an run-time assertion failure, as well as the routine that
15046 is used internally to raise this assertion.
15048 @node System.Memory (s-memory.ads)
15049 @section @code{System.Memory} (@file{s-memory.ads})
15050 @cindex @code{System.Memory} (@file{s-memory.ads})
15051 @cindex Memory allocation
15053 @noindent
15054 This package provides the interface to the low level routines used
15055 by the generated code for allocation and freeing storage for the
15056 default storage pool (analogous to the C routines malloc and free.
15057 It also provides a reallocation interface analogous to the C routine
15058 realloc. The body of this unit may be modified to provide alternative
15059 allocation mechanisms for the default pool, and in addition, direct
15060 calls to this unit may be made for low level allocation uses (for
15061 example see the body of @code{GNAT.Tables}).
15063 @node System.Partition_Interface (s-parint.ads)
15064 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15065 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15066 @cindex Partition interfacing functions
15068 @noindent
15069 This package provides facilities for partition interfacing.  It
15070 is used primarily in a distribution context when using Annex E
15071 with @code{GLADE}.
15073 @node System.Pool_Global (s-pooglo.ads)
15074 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15075 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15076 @cindex Storage pool, global
15077 @cindex Global storage pool
15079 @noindent
15080 This package provides a storage pool that is equivalent to the default
15081 storage pool used for access types for which no pool is specifically
15082 declared. It uses malloc/free to allocate/free and does not attempt to
15083 do any automatic reclamation.
15085 @node System.Pool_Local (s-pooloc.ads)
15086 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15087 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15088 @cindex Storage pool, local
15089 @cindex Local storage pool
15091 @noindent
15092 This package provides a storage pool that is intended for use with locally
15093 defined access types. It uses malloc/free for allocate/free, and maintains
15094 a list of allocated blocks, so that all storage allocated for the pool can
15095 be freed automatically when the pool is finalized.
15097 @node System.Restrictions (s-restri.ads)
15098 @section @code{System.Restrictions} (@file{s-restri.ads})
15099 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15100 @cindex Run-time restrictions access
15102 @noindent
15103 This package provides facilities for accessing at run time
15104 the status of restrictions specified at compile time for
15105 the partition. Information is available both with regard
15106 to actual restrictions specified, and with regard to
15107 compiler determined information on which restrictions
15108 are violated by one or more packages in the partition.
15110 @node System.Rident (s-rident.ads)
15111 @section @code{System.Rident} (@file{s-rident.ads})
15112 @cindex @code{System.Rident} (@file{s-rident.ads})
15113 @cindex Restrictions definitions
15115 @noindent
15116 This package provides definitions of the restrictions
15117 identifiers supported by GNAT, and also the format of
15118 the restrictions provided in package System.Restrictions.
15119 It is not normally necessary to @code{with} this generic package
15120 since the necessary instantiation is included in
15121 package System.Restrictions.
15123 @node System.Strings.Stream_Ops (s-ststop.ads)
15124 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15125 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15126 @cindex Stream operations
15127 @cindex String stream operations
15129 @noindent
15130 This package provides a set of stream subprograms for standard string types.
15131 It is intended primarily to support implicit use of such subprograms when
15132 stream attributes are applied to string types, but the subprograms in this
15133 package can be used directly by application programs.
15135 @node System.Task_Info (s-tasinf.ads)
15136 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15137 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15138 @cindex Task_Info pragma
15140 @noindent
15141 This package provides target dependent functionality that is used
15142 to support the @code{Task_Info} pragma
15144 @node System.Wch_Cnv (s-wchcnv.ads)
15145 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15146 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15147 @cindex Wide Character, Representation
15148 @cindex Wide String, Conversion
15149 @cindex Representation of wide characters
15151 @noindent
15152 This package provides routines for converting between
15153 wide and wide wide characters and a representation as a value of type
15154 @code{Standard.String}, using a specified wide character
15155 encoding method.  It uses definitions in
15156 package @code{System.Wch_Con}.
15158 @node System.Wch_Con (s-wchcon.ads)
15159 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15160 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15162 @noindent
15163 This package provides definitions and descriptions of
15164 the various methods used for encoding wide characters
15165 in ordinary strings.  These definitions are used by
15166 the package @code{System.Wch_Cnv}.
15168 @node Interfacing to Other Languages
15169 @chapter Interfacing to Other Languages
15170 @noindent
15171 The facilities in annex B of the Ada Reference Manual are fully
15172 implemented in GNAT, and in addition, a full interface to C++ is
15173 provided.
15175 @menu
15176 * Interfacing to C::
15177 * Interfacing to C++::
15178 * Interfacing to COBOL::
15179 * Interfacing to Fortran::
15180 * Interfacing to non-GNAT Ada code::
15181 @end menu
15183 @node Interfacing to C
15184 @section Interfacing to C
15186 @noindent
15187 Interfacing to C with GNAT can use one of two approaches:
15189 @itemize @bullet
15190 @item
15191 The types in the package @code{Interfaces.C} may be used.
15192 @item
15193 Standard Ada types may be used directly.  This may be less portable to
15194 other compilers, but will work on all GNAT compilers, which guarantee
15195 correspondence between the C and Ada types.
15196 @end itemize
15198 @noindent
15199 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15200 effect, since this is the default.  The following table shows the
15201 correspondence between Ada scalar types and the corresponding C types.
15203 @table @code
15204 @item Integer
15205 @code{int}
15206 @item Short_Integer
15207 @code{short}
15208 @item Short_Short_Integer
15209 @code{signed char}
15210 @item Long_Integer
15211 @code{long}
15212 @item Long_Long_Integer
15213 @code{long long}
15214 @item Short_Float
15215 @code{float}
15216 @item Float
15217 @code{float}
15218 @item Long_Float
15219 @code{double}
15220 @item Long_Long_Float
15221 This is the longest floating-point type supported by the hardware.
15222 @end table
15224 @noindent
15225 Additionally, there are the following general correspondences between Ada
15226 and C types:
15227 @itemize @bullet
15228 @item
15229 Ada enumeration types map to C enumeration types directly if pragma
15230 @code{Convention C} is specified, which causes them to have int
15231 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15232 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15233 @code{int}, respectively) depending on the number of values passed.
15234 This is the only case in which pragma @code{Convention C} affects the
15235 representation of an Ada type.
15237 @item
15238 Ada access types map to C pointers, except for the case of pointers to
15239 unconstrained types in Ada, which have no direct C equivalent.
15241 @item
15242 Ada arrays map directly to C arrays.
15244 @item
15245 Ada records map directly to C structures.
15247 @item
15248 Packed Ada records map to C structures where all members are bit fields
15249 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15250 @end itemize
15252 @node Interfacing to C++
15253 @section Interfacing to C++
15255 @noindent
15256 The interface to C++ makes use of the following pragmas, which are
15257 primarily intended to be constructed automatically using a binding generator
15258 tool, although it is possible to construct them by hand.  No suitable binding
15259 generator tool is supplied with GNAT though.
15261 Using these pragmas it is possible to achieve complete
15262 inter-operability between Ada tagged types and C++ class definitions.
15263 See @ref{Implementation Defined Pragmas}, for more details.
15265 @table @code
15266 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15267 The argument denotes an entity in the current declarative region that is
15268 declared as a tagged or untagged record type. It indicates that the type
15269 corresponds to an externally declared C++ class type, and is to be laid
15270 out the same way that C++ would lay out the type.
15272 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15273 for backward compatibility but its functionality is available
15274 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15276 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15277 This pragma identifies an imported function (imported in the usual way
15278 with pragma @code{Import}) as corresponding to a C++ constructor.
15279 @end table
15281 @node Interfacing to COBOL
15282 @section Interfacing to COBOL
15284 @noindent
15285 Interfacing to COBOL is achieved as described in section B.4 of
15286 the Ada Reference Manual.
15288 @node Interfacing to Fortran
15289 @section Interfacing to Fortran
15291 @noindent
15292 Interfacing to Fortran is achieved as described in section B.5 of the
15293 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15294 multi-dimensional array causes the array to be stored in column-major
15295 order as required for convenient interface to Fortran.
15297 @node Interfacing to non-GNAT Ada code
15298 @section Interfacing to non-GNAT Ada code
15300 It is possible to specify the convention @code{Ada} in a pragma
15301 @code{Import} or pragma @code{Export}.  However this refers to
15302 the calling conventions used by GNAT, which may or may not be
15303 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15304 compiler to allow interoperation.
15306 If arguments types are kept simple, and if the foreign compiler generally
15307 follows system calling conventions, then it may be possible to integrate
15308 files compiled by other Ada compilers, provided that the elaboration
15309 issues are adequately addressed (for example by eliminating the
15310 need for any load time elaboration).
15312 In particular, GNAT running on VMS is designed to
15313 be highly compatible with the DEC Ada 83 compiler, so this is one
15314 case in which it is possible to import foreign units of this type,
15315 provided that the data items passed are restricted to simple scalar
15316 values or simple record types without variants, or simple array
15317 types with fixed bounds.
15319 @node Specialized Needs Annexes
15320 @chapter Specialized Needs Annexes
15322 @noindent
15323 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15324 required in all implementations.  However, as described in this chapter,
15325 GNAT implements all of these annexes:
15327 @table @asis
15328 @item Systems Programming (Annex C)
15329 The Systems Programming Annex is fully implemented.
15331 @item Real-Time Systems (Annex D)
15332 The Real-Time Systems Annex is fully implemented.
15334 @item Distributed Systems (Annex E)
15335 Stub generation is fully implemented in the GNAT compiler.  In addition,
15336 a complete compatible PCS is available as part of the GLADE system,
15337 a separate product.  When the two
15338 products are used in conjunction, this annex is fully implemented.
15340 @item Information Systems (Annex F)
15341 The Information Systems annex is fully implemented.
15343 @item Numerics (Annex G)
15344 The Numerics Annex is fully implemented.
15346 @item Safety and Security / High-Integrity Systems (Annex H)
15347 The Safety and Security Annex (termed the High-Integrity Systems Annex
15348 in Ada 2005) is fully implemented.
15349 @end table
15351 @node Implementation of Specific Ada Features
15352 @chapter Implementation of Specific Ada Features
15354 @noindent
15355 This chapter describes the GNAT implementation of several Ada language
15356 facilities.
15358 @menu
15359 * Machine Code Insertions::
15360 * GNAT Implementation of Tasking::
15361 * GNAT Implementation of Shared Passive Packages::
15362 * Code Generation for Array Aggregates::
15363 * The Size of Discriminated Records with Default Discriminants::
15364 * Strict Conformance to the Ada Reference Manual::
15365 @end menu
15367 @node Machine Code Insertions
15368 @section Machine Code Insertions
15369 @cindex Machine Code insertions
15371 @noindent
15372 Package @code{Machine_Code} provides machine code support as described
15373 in the Ada Reference Manual in two separate forms:
15374 @itemize @bullet
15375 @item
15376 Machine code statements, consisting of qualified expressions that
15377 fit the requirements of RM section 13.8.
15378 @item
15379 An intrinsic callable procedure, providing an alternative mechanism of
15380 including machine instructions in a subprogram.
15381 @end itemize
15383 @noindent
15384 The two features are similar, and both are closely related to the mechanism
15385 provided by the asm instruction in the GNU C compiler.  Full understanding
15386 and use of the facilities in this package requires understanding the asm
15387 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15388 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15390 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15391 semantic restrictions and effects as described below.  Both are provided so
15392 that the procedure call can be used as a statement, and the function call
15393 can be used to form a code_statement.
15395 The first example given in the GCC documentation is the C @code{asm}
15396 instruction:
15397 @smallexample
15398    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15399 @end smallexample
15401 @noindent
15402 The equivalent can be written for GNAT as:
15404 @smallexample @c ada
15405 Asm ("fsinx %1 %0",
15406      My_Float'Asm_Output ("=f", result),
15407      My_Float'Asm_Input  ("f",  angle));
15408 @end smallexample
15410 @noindent
15411 The first argument to @code{Asm} is the assembler template, and is
15412 identical to what is used in GNU C@.  This string must be a static
15413 expression.  The second argument is the output operand list.  It is
15414 either a single @code{Asm_Output} attribute reference, or a list of such
15415 references enclosed in parentheses (technically an array aggregate of
15416 such references).
15418 The @code{Asm_Output} attribute denotes a function that takes two
15419 parameters.  The first is a string, the second is the name of a variable
15420 of the type designated by the attribute prefix.  The first (string)
15421 argument is required to be a static expression and designates the
15422 constraint for the parameter (e.g.@: what kind of register is
15423 required).  The second argument is the variable to be updated with the
15424 result.  The possible values for constraint are the same as those used in
15425 the RTL, and are dependent on the configuration file used to build the
15426 GCC back end.  If there are no output operands, then this argument may
15427 either be omitted, or explicitly given as @code{No_Output_Operands}.
15429 The second argument of @code{@var{my_float}'Asm_Output} functions as
15430 though it were an @code{out} parameter, which is a little curious, but
15431 all names have the form of expressions, so there is no syntactic
15432 irregularity, even though normally functions would not be permitted
15433 @code{out} parameters.  The third argument is the list of input
15434 operands.  It is either a single @code{Asm_Input} attribute reference, or
15435 a list of such references enclosed in parentheses (technically an array
15436 aggregate of such references).
15438 The @code{Asm_Input} attribute denotes a function that takes two
15439 parameters.  The first is a string, the second is an expression of the
15440 type designated by the prefix.  The first (string) argument is required
15441 to be a static expression, and is the constraint for the parameter,
15442 (e.g.@: what kind of register is required).  The second argument is the
15443 value to be used as the input argument.  The possible values for the
15444 constant are the same as those used in the RTL, and are dependent on
15445 the configuration file used to built the GCC back end.
15447 If there are no input operands, this argument may either be omitted, or
15448 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15449 present in the above example, is a list of register names, called the
15450 @dfn{clobber} argument.  This argument, if given, must be a static string
15451 expression, and is a space or comma separated list of names of registers
15452 that must be considered destroyed as a result of the @code{Asm} call.  If
15453 this argument is the null string (the default value), then the code
15454 generator assumes that no additional registers are destroyed.
15456 The fifth argument, not present in the above example, called the
15457 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15458 the literal value @code{True} to indicate to the code generator that all
15459 optimizations with respect to the instruction specified should be
15460 suppressed, and that in particular, for an instruction that has outputs,
15461 the instruction will still be generated, even if none of the outputs are
15462 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15463 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15464 Generally it is strongly advisable to use Volatile for any ASM statement
15465 that is missing either input or output operands, or when two or more ASM
15466 statements appear in sequence, to avoid unwanted optimizations. A warning
15467 is generated if this advice is not followed.
15469 The @code{Asm} subprograms may be used in two ways.  First the procedure
15470 forms can be used anywhere a procedure call would be valid, and
15471 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15472 be used to intersperse machine instructions with other Ada statements.
15473 Second, the function forms, which return a dummy value of the limited
15474 private type @code{Asm_Insn}, can be used in code statements, and indeed
15475 this is the only context where such calls are allowed.  Code statements
15476 appear as aggregates of the form:
15478 @smallexample @c ada
15479 Asm_Insn'(Asm (@dots{}));
15480 Asm_Insn'(Asm_Volatile (@dots{}));
15481 @end smallexample
15483 @noindent
15484 In accordance with RM rules, such code statements are allowed only
15485 within subprograms whose entire body consists of such statements.  It is
15486 not permissible to intermix such statements with other Ada statements.
15488 Typically the form using intrinsic procedure calls is more convenient
15489 and more flexible.  The code statement form is provided to meet the RM
15490 suggestion that such a facility should be made available.  The following
15491 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15492 is used, the arguments may be given in arbitrary order, following the
15493 normal rules for use of positional and named arguments)
15495 @smallexample
15496 ASM_CALL ::= Asm (
15497                  [Template =>] static_string_EXPRESSION
15498                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15499                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15500                [,[Clobber  =>] static_string_EXPRESSION ]
15501                [,[Volatile =>] static_boolean_EXPRESSION] )
15503 OUTPUT_OPERAND_LIST ::=
15504   [PREFIX.]No_Output_Operands
15505 | OUTPUT_OPERAND_ATTRIBUTE
15506 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15508 OUTPUT_OPERAND_ATTRIBUTE ::=
15509   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15511 INPUT_OPERAND_LIST ::=
15512   [PREFIX.]No_Input_Operands
15513 | INPUT_OPERAND_ATTRIBUTE
15514 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15516 INPUT_OPERAND_ATTRIBUTE ::=
15517   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15518 @end smallexample
15520 @noindent
15521 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15522 are declared in the package @code{Machine_Code} and must be referenced
15523 according to normal visibility rules. In particular if there is no
15524 @code{use} clause for this package, then appropriate package name
15525 qualification is required.
15527 @node GNAT Implementation of Tasking
15528 @section GNAT Implementation of Tasking
15530 @noindent
15531 This chapter outlines the basic GNAT approach to tasking (in particular,
15532 a multi-layered library for portability) and discusses issues related
15533 to compliance with the Real-Time Systems Annex.
15535 @menu
15536 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15537 * Ensuring Compliance with the Real-Time Annex::
15538 @end menu
15540 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15541 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15543 @noindent
15544 GNAT's run-time support comprises two layers:
15546 @itemize @bullet
15547 @item GNARL (GNAT Run-time Layer)
15548 @item GNULL (GNAT Low-level Library)
15549 @end itemize
15551 @noindent
15552 In GNAT, Ada's tasking services rely on a platform and OS independent
15553 layer known as GNARL@.  This code is responsible for implementing the
15554 correct semantics of Ada's task creation, rendezvous, protected
15555 operations etc.
15557 GNARL decomposes Ada's tasking semantics into simpler lower level
15558 operations such as create a thread, set the priority of a thread,
15559 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15560 operations constitutes GNULLI, the GNULL Interface.  This interface is
15561 directly inspired from the POSIX real-time API@.
15563 If the underlying executive or OS implements the POSIX standard
15564 faithfully, the GNULL Interface maps as is to the services offered by
15565 the underlying kernel.  Otherwise, some target dependent glue code maps
15566 the services offered by the underlying kernel to the semantics expected
15567 by GNARL@.
15569 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
15570 key point is that each Ada task is mapped on a thread in the underlying
15571 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15573 In addition Ada task priorities map onto the underlying thread priorities.
15574 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15576 @itemize @bullet
15577 @item
15578 The underlying scheduler is used to schedule the Ada tasks.  This
15579 makes Ada tasks as efficient as kernel threads from a scheduling
15580 standpoint.
15582 @item
15583 Interaction with code written in C containing threads is eased
15584 since at the lowest level Ada tasks and C threads map onto the same
15585 underlying kernel concept.
15587 @item
15588 When an Ada task is blocked during I/O the remaining Ada tasks are
15589 able to proceed.
15591 @item
15592 On multiprocessor systems Ada tasks can execute in parallel.
15593 @end itemize
15595 @noindent
15596 Some threads libraries offer a mechanism to fork a new process, with the
15597 child process duplicating the threads from the parent.
15598 GNAT does not
15599 support this functionality when the parent contains more than one task.
15600 @cindex Forking a new process
15602 @node Ensuring Compliance with the Real-Time Annex
15603 @subsection Ensuring Compliance with the Real-Time Annex
15604 @cindex Real-Time Systems Annex compliance
15606 @noindent
15607 Although mapping Ada tasks onto
15608 the underlying threads has significant advantages, it does create some
15609 complications when it comes to respecting the scheduling semantics
15610 specified in the real-time annex (Annex D).
15612 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15613 scheduling policy states:
15615 @quotation
15616 @emph{When the active priority of a ready task that is not running
15617 changes, or the setting of its base priority takes effect, the
15618 task is removed from the ready queue for its old active priority
15619 and is added at the tail of the ready queue for its new active
15620 priority, except in the case where the active priority is lowered
15621 due to the loss of inherited priority, in which case the task is
15622 added at the head of the ready queue for its new active priority.}
15623 @end quotation
15625 @noindent
15626 While most kernels do put tasks at the end of the priority queue when
15627 a task changes its priority, (which respects the main
15628 FIFO_Within_Priorities requirement), almost none keep a thread at the
15629 beginning of its priority queue when its priority drops from the loss
15630 of inherited priority.
15632 As a result most vendors have provided incomplete Annex D implementations.
15634 The GNAT run-time, has a nice cooperative solution to this problem
15635 which ensures that accurate FIFO_Within_Priorities semantics are
15636 respected.
15638 The principle is as follows.  When an Ada task T is about to start
15639 running, it checks whether some other Ada task R with the same
15640 priority as T has been suspended due to the loss of priority
15641 inheritance.  If this is the case, T yields and is placed at the end of
15642 its priority queue.  When R arrives at the front of the queue it
15643 executes.
15645 Note that this simple scheme preserves the relative order of the tasks
15646 that were ready to execute in the priority queue where R has been
15647 placed at the end.
15649 @node GNAT Implementation of Shared Passive Packages
15650 @section GNAT Implementation of Shared Passive Packages
15651 @cindex Shared passive packages
15653 @noindent
15654 GNAT fully implements the pragma @code{Shared_Passive} for
15655 @cindex pragma @code{Shared_Passive}
15656 the purpose of designating shared passive packages.
15657 This allows the use of passive partitions in the
15658 context described in the Ada Reference Manual; i.e., for communication
15659 between separate partitions of a distributed application using the
15660 features in Annex E.
15661 @cindex Annex E
15662 @cindex Distribution Systems Annex
15664 However, the implementation approach used by GNAT provides for more
15665 extensive usage as follows:
15667 @table @emph
15668 @item Communication between separate programs
15670 This allows separate programs to access the data in passive
15671 partitions, using protected objects for synchronization where
15672 needed. The only requirement is that the two programs have a
15673 common shared file system. It is even possible for programs
15674 running on different machines with different architectures
15675 (e.g.@: different endianness) to communicate via the data in
15676 a passive partition.
15678 @item Persistence between program runs
15680 The data in a passive package can persist from one run of a
15681 program to another, so that a later program sees the final
15682 values stored by a previous run of the same program.
15684 @end table
15686 @noindent
15687 The implementation approach used is to store the data in files. A
15688 separate stream file is created for each object in the package, and
15689 an access to an object causes the corresponding file to be read or
15690 written.
15692 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15693 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15694 set to the directory to be used for these files.
15695 The files in this directory
15696 have names that correspond to their fully qualified names. For
15697 example, if we have the package
15699 @smallexample @c ada
15700 package X is
15701   pragma Shared_Passive (X);
15702   Y : Integer;
15703   Z : Float;
15704 end X;
15705 @end smallexample
15707 @noindent
15708 and the environment variable is set to @code{/stemp/}, then the files created
15709 will have the names:
15711 @smallexample
15712 /stemp/x.y
15713 /stemp/x.z
15714 @end smallexample
15716 @noindent
15717 These files are created when a value is initially written to the object, and
15718 the files are retained until manually deleted. This provides the persistence
15719 semantics. If no file exists, it means that no partition has assigned a value
15720 to the variable; in this case the initial value declared in the package
15721 will be used. This model ensures that there are no issues in synchronizing
15722 the elaboration process, since elaboration of passive packages elaborates the
15723 initial values, but does not create the files.
15725 The files are written using normal @code{Stream_IO} access.
15726 If you want to be able
15727 to communicate between programs or partitions running on different
15728 architectures, then you should use the XDR versions of the stream attribute
15729 routines, since these are architecture independent.
15731 If active synchronization is required for access to the variables in the
15732 shared passive package, then as described in the Ada Reference Manual, the
15733 package may contain protected objects used for this purpose. In this case
15734 a lock file (whose name is @file{___lock} (three underscores)
15735 is created in the shared memory directory.
15736 @cindex @file{___lock} file (for shared passive packages)
15737 This is used to provide the required locking
15738 semantics for proper protected object synchronization.
15740 As of January 2003, GNAT supports shared passive packages on all platforms
15741 except for OpenVMS.
15743 @node Code Generation for Array Aggregates
15744 @section Code Generation for Array Aggregates
15746 @menu
15747 * Static constant aggregates with static bounds::
15748 * Constant aggregates with unconstrained nominal types::
15749 * Aggregates with static bounds::
15750 * Aggregates with non-static bounds::
15751 * Aggregates in assignment statements::
15752 @end menu
15754 @noindent
15755 Aggregates have a rich syntax and allow the user to specify the values of
15756 complex data structures by means of a single construct.  As a result, the
15757 code generated for aggregates can be quite complex and involve loops, case
15758 statements and multiple assignments.  In the simplest cases, however, the
15759 compiler will recognize aggregates whose components and constraints are
15760 fully static, and in those cases the compiler will generate little or no
15761 executable code.  The following is an outline of the code that GNAT generates
15762 for various aggregate constructs.  For further details, you will find it
15763 useful to examine the output produced by the -gnatG flag to see the expanded
15764 source that is input to the code generator.  You may also want to examine
15765 the assembly code generated at various levels of optimization.
15767 The code generated for aggregates depends on the context, the component values,
15768 and the type.  In the context of an object declaration the code generated is
15769 generally simpler than in the case of an assignment.  As a general rule, static
15770 component values and static subtypes also lead to simpler code.
15772 @node Static constant aggregates with static bounds
15773 @subsection Static constant aggregates with static bounds
15775 @noindent
15776 For the declarations:
15777 @smallexample @c ada
15778     type One_Dim is array (1..10) of integer;
15779     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15780 @end smallexample
15782 @noindent
15783 GNAT generates no executable code: the constant ar0 is placed in static memory.
15784 The same is true for constant aggregates with named associations:
15786 @smallexample @c ada
15787     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15788     Cr3 : constant One_Dim := (others => 7777);
15789 @end smallexample
15791 @noindent
15792 The same is true for multidimensional constant arrays such as:
15794 @smallexample @c ada
15795     type two_dim is array (1..3, 1..3) of integer;
15796     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15797 @end smallexample
15799 @noindent
15800 The same is true for arrays of one-dimensional arrays: the following are
15801 static:
15803 @smallexample @c ada
15804 type ar1b  is array (1..3) of boolean;
15805 type ar_ar is array (1..3) of ar1b;
15806 None  : constant ar1b := (others => false);     --  fully static
15807 None2 : constant ar_ar := (1..3 => None);       --  fully static
15808 @end smallexample
15810 @noindent
15811 However, for multidimensional aggregates with named associations, GNAT will
15812 generate assignments and loops, even if all associations are static.  The
15813 following two declarations generate a loop for the first dimension, and
15814 individual component assignments for the second dimension:
15816 @smallexample @c ada
15817 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15818 Zero2: constant two_dim := (others => (others => 0));
15819 @end smallexample
15821 @node Constant aggregates with unconstrained nominal types
15822 @subsection Constant aggregates with unconstrained nominal types
15824 @noindent
15825 In such cases the aggregate itself establishes the subtype, so that
15826 associations with @code{others} cannot be used.  GNAT determines the
15827 bounds for the actual subtype of the aggregate, and allocates the
15828 aggregate statically as well.  No code is generated for the following:
15830 @smallexample @c ada
15831     type One_Unc is array (natural range <>) of integer;
15832     Cr_Unc : constant One_Unc := (12,24,36);
15833 @end smallexample
15835 @node Aggregates with static bounds
15836 @subsection Aggregates with static bounds
15838 @noindent
15839 In all previous examples the aggregate was the initial (and immutable) value
15840 of a constant.  If the aggregate initializes a variable, then code is generated
15841 for it as a combination of individual assignments and loops over the target
15842 object.  The declarations
15844 @smallexample @c ada
15845        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15846        Cr_Var2 : One_Dim := (others > -1);
15847 @end smallexample
15849 @noindent
15850 generate the equivalent of
15852 @smallexample @c ada
15853        Cr_Var1 (1) := 2;
15854        Cr_Var1 (2) := 3;
15855        Cr_Var1 (3) := 5;
15856        Cr_Var1 (4) := 11;
15858        for I in Cr_Var2'range loop
15859           Cr_Var2 (I) := -1;
15860        end loop;
15861 @end smallexample
15863 @node Aggregates with non-static bounds
15864 @subsection Aggregates with non-static bounds
15866 @noindent
15867 If the bounds of the aggregate are not statically compatible with the bounds
15868 of the nominal subtype  of the target, then constraint checks have to be
15869 generated on the bounds.  For a multidimensional array, constraint checks may
15870 have to be applied to sub-arrays individually, if they do not have statically
15871 compatible subtypes.
15873 @node Aggregates in assignment statements
15874 @subsection Aggregates in assignment statements
15876 @noindent
15877 In general, aggregate assignment requires the construction of a temporary,
15878 and a copy from the temporary to the target of the assignment.  This is because
15879 it is not always possible to convert the assignment into a series of individual
15880 component assignments.  For example, consider the simple case:
15882 @smallexample @c ada
15883         A := (A(2), A(1));
15884 @end smallexample
15886 @noindent
15887 This cannot be converted into:
15889 @smallexample @c ada
15890         A(1) := A(2);
15891         A(2) := A(1);
15892 @end smallexample
15894 @noindent
15895 So the aggregate has to be built first in a separate location, and then
15896 copied into the target.  GNAT recognizes simple cases where this intermediate
15897 step is not required, and the assignments can be performed in place, directly
15898 into the target.  The following sufficient criteria are applied:
15900 @itemize @bullet
15901 @item
15902 The bounds of the aggregate are static, and the associations are static.
15903 @item
15904 The components of the aggregate are static constants, names of
15905 simple variables that are not renamings, or expressions not involving
15906 indexed components whose operands obey these rules.
15907 @end itemize
15909 @noindent
15910 If any of these conditions are violated, the aggregate will be built in
15911 a temporary (created either by the front-end or the code generator) and then
15912 that temporary will be copied onto the target.
15914 @node The Size of Discriminated Records with Default Discriminants
15915 @section The Size of Discriminated Records with Default Discriminants
15917 @noindent
15918 If a discriminated type @code{T} has discriminants with default values, it is
15919 possible to declare an object of this type without providing an explicit
15920 constraint:
15922 @smallexample @c ada
15923 @group
15924 type Size is range 1..100;
15926 type Rec (D : Size := 15) is record
15927    Name : String (1..D);
15928 end T;
15930 Word : Rec;
15931 @end group
15932 @end smallexample
15934 @noindent
15935 Such an object is said to be @emph{unconstrained}.
15936 The discriminant of the object
15937 can be modified by a full assignment to the object, as long as it preserves the
15938 relation between the value of the discriminant, and the value of the components
15939 that depend on it:
15941 @smallexample @c ada
15942 @group
15943 Word := (3, "yes");
15945 Word := (5, "maybe");
15947 Word := (5, "no"); -- raises Constraint_Error
15948 @end group
15949 @end smallexample
15951 @noindent
15952 In order to support this behavior efficiently, an unconstrained object is
15953 given the maximum size that any value of the type requires. In the case
15954 above, @code{Word} has storage for the discriminant and for
15955 a @code{String} of length 100.
15956 It is important to note that unconstrained objects do not require dynamic
15957 allocation. It would be an improper implementation to place on the heap those
15958 components whose size depends on discriminants. (This improper implementation
15959 was used by some Ada83 compilers, where the @code{Name} component above
15960 would have
15961 been stored as a pointer to a dynamic string). Following the principle that
15962 dynamic storage management should never be introduced implicitly,
15963 an Ada compiler should reserve the full size for an unconstrained declared
15964 object, and place it on the stack.
15966 This maximum size approach
15967 has been a source of surprise to some users, who expect the default
15968 values of the discriminants to determine the size reserved for an
15969 unconstrained object: ``If the default is 15, why should the object occupy
15970 a larger size?''
15971 The answer, of course, is that the discriminant may be later modified,
15972 and its full range of values must be taken into account. This is why the
15973 declaration:
15975 @smallexample
15976 @group
15977 type Rec (D : Positive := 15) is record
15978    Name : String (1..D);
15979 end record;
15981 Too_Large : Rec;
15982 @end group
15983 @end smallexample
15985 @noindent
15986 is flagged by the compiler with a warning:
15987 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15988 because the required size includes @code{Positive'Last}
15989 bytes. As the first example indicates, the proper approach is to declare an
15990 index type of ``reasonable'' range so that unconstrained objects are not too
15991 large.
15993 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15994 created in the heap by means of an allocator, then it is @emph{not}
15995 unconstrained:
15996 it is constrained by the default values of the discriminants, and those values
15997 cannot be modified by full assignment. This is because in the presence of
15998 aliasing all views of the object (which may be manipulated by different tasks,
15999 say) must be consistent, so it is imperative that the object, once created,
16000 remain invariant.
16002 @node Strict Conformance to the Ada Reference Manual
16003 @section Strict Conformance to the Ada Reference Manual
16005 @noindent
16006 The dynamic semantics defined by the Ada Reference Manual impose a set of
16007 run-time checks to be generated. By default, the GNAT compiler will insert many
16008 run-time checks into the compiled code, including most of those required by the
16009 Ada Reference Manual. However, there are three checks that are not enabled
16010 in the default mode for efficiency reasons: arithmetic overflow checking for
16011 integer operations (including division by zero), checks for access before
16012 elaboration on subprogram calls, and stack overflow checking (most operating
16013 systems do not perform this check by default).
16015 Strict conformance to the Ada Reference Manual can be achieved by adding
16016 three compiler options for overflow checking for integer operations
16017 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16018 calls and generic instantiations (@option{-gnatE}), and stack overflow
16019 checking (@option{-fstack-check}).
16021 Note that the result of a floating point arithmetic operation in overflow and
16022 invalid situations, when the @code{Machine_Overflows} attribute of the result
16023 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16024 case for machines compliant with the IEEE floating-point standard, but on
16025 machines that are not fully compliant with this standard, such as Alpha, the
16026 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16027 behavior (although at the cost of a significant performance penalty), so
16028 infinite and and NaN values are properly generated.
16030 @node Obsolescent Features
16031 @chapter Obsolescent Features
16033 @noindent
16034 This chapter describes features that are provided by GNAT, but are
16035 considered obsolescent since there are preferred ways of achieving
16036 the same effect. These features are provided solely for historical
16037 compatibility purposes.
16039 @menu
16040 * pragma No_Run_Time::
16041 * pragma Ravenscar::
16042 * pragma Restricted_Run_Time::
16043 @end menu
16045 @node pragma No_Run_Time
16046 @section pragma No_Run_Time
16048 The pragma @code{No_Run_Time} is used to achieve an affect similar
16049 to the use of the "Zero Foot Print" configurable run time, but without
16050 requiring a specially configured run time. The result of using this
16051 pragma, which must be used for all units in a partition, is to restrict
16052 the use of any language features requiring run-time support code. The
16053 preferred usage is to use an appropriately configured run-time that
16054 includes just those features that are to be made accessible.
16056 @node pragma Ravenscar
16057 @section pragma Ravenscar
16059 The pragma @code{Ravenscar} has exactly the same effect as pragma
16060 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16061 is part of the new Ada 2005 standard.
16063 @node pragma Restricted_Run_Time
16064 @section pragma Restricted_Run_Time
16066 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16067 pragma @code{Profile (Restricted)}. The latter usage is
16068 preferred since the Ada 2005 pragma @code{Profile} is intended for
16069 this kind of implementation dependent addition.
16071 @include fdl.texi
16072 @c GNU Free Documentation License
16074 @node Index,,GNU Free Documentation License, Top
16075 @unnumbered Index
16077 @printindex cp
16079 @contents
16081 @bye