1 \input texinfo @c -*-texinfo-*-
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
7 @c GNAT DOCUMENTATION o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
15 @setfilename gnat_rm.info
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''.
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
32 @settitle GNAT Reference Manual
34 @setchapternewpage odd
37 @include gcc-common.texi
39 @dircategory GNU Ada tools
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
50 @vskip 0pt plus 1filll
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
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::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Obsolescent Features::
85 * GNU Free Documentation License::
88 --- The Detailed Node Listing ---
92 * What This Reference Manual Contains::
93 * Related Information::
95 Implementation Defined Pragmas
97 * Pragma Abort_Defer::
104 * Pragma Assume_No_Invalid_Values::
106 * Pragma C_Pass_By_Copy::
108 * Pragma Check_Name::
109 * Pragma Check_Policy::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Error::
113 * Pragma Compile_Time_Warning::
114 * Pragma Compiler_Unit::
115 * Pragma Complete_Representation::
116 * Pragma Complex_Representation::
117 * Pragma Component_Alignment::
118 * Pragma Convention_Identifier::
120 * Pragma CPP_Constructor::
121 * Pragma CPP_Virtual::
122 * Pragma CPP_Vtable::
124 * Pragma Debug_Policy::
125 * Pragma Detect_Blocking::
126 * Pragma Elaboration_Checks::
128 * Pragma Export_Exception::
129 * Pragma Export_Function::
130 * Pragma Export_Object::
131 * Pragma Export_Procedure::
132 * Pragma Export_Value::
133 * Pragma Export_Valued_Procedure::
134 * Pragma Extend_System::
136 * Pragma External_Name_Casing::
138 * Pragma Favor_Top_Level::
139 * Pragma Finalize_Storage_Only::
140 * Pragma Float_Representation::
142 * Pragma Implemented_By_Entry::
143 * Pragma Implicit_Packing::
144 * Pragma Import_Exception::
145 * Pragma Import_Function::
146 * Pragma Import_Object::
147 * Pragma Import_Procedure::
148 * Pragma Import_Valued_Procedure::
149 * Pragma Initialize_Scalars::
150 * Pragma Inline_Always::
151 * Pragma Inline_Generic::
153 * Pragma Interface_Name::
154 * Pragma Interrupt_Handler::
155 * Pragma Interrupt_State::
156 * Pragma Keep_Names::
159 * Pragma Linker_Alias::
160 * Pragma Linker_Constructor::
161 * Pragma Linker_Destructor::
162 * Pragma Linker_Section::
163 * Pragma Long_Float::
164 * Pragma Machine_Attribute::
166 * Pragma Main_Storage::
169 * Pragma No_Strict_Aliasing ::
170 * Pragma Normalize_Scalars::
171 * Pragma Obsolescent::
172 * Pragma Optimize_Alignment::
174 * Pragma Persistent_BSS::
176 * Pragma Postcondition::
177 * Pragma Precondition::
178 * Pragma Profile (Ravenscar)::
179 * Pragma Profile (Restricted)::
180 * Pragma Psect_Object::
181 * Pragma Pure_Function::
182 * Pragma Restriction_Warnings::
184 * Pragma Short_Circuit_And_Or::
185 * Pragma Source_File_Name::
186 * Pragma Source_File_Name_Project::
187 * Pragma Source_Reference::
188 * Pragma Stream_Convert::
189 * Pragma Style_Checks::
192 * Pragma Suppress_All::
193 * Pragma Suppress_Exception_Locations::
194 * Pragma Suppress_Initialization::
197 * Pragma Task_Storage::
198 * Pragma Thread_Local_Storage::
199 * Pragma Time_Slice::
201 * Pragma Unchecked_Union::
202 * Pragma Unimplemented_Unit::
203 * Pragma Universal_Aliasing ::
204 * Pragma Universal_Data::
205 * Pragma Unmodified::
206 * Pragma Unreferenced::
207 * Pragma Unreferenced_Objects::
208 * Pragma Unreserve_All_Interrupts::
209 * Pragma Unsuppress::
210 * Pragma Use_VADS_Size::
211 * Pragma Validity_Checks::
214 * Pragma Weak_External::
215 * Pragma Wide_Character_Encoding::
217 Implementation Defined Attributes
228 * Default_Bit_Order::
238 * Has_Access_Values::
239 * Has_Discriminants::
246 * Max_Interrupt_Priority::
248 * Maximum_Alignment::
253 * Passed_By_Reference::
267 * Unconstrained_Array::
268 * Universal_Literal_String::
269 * Unrestricted_Access::
275 The Implementation of Standard I/O
277 * Standard I/O Packages::
283 * Wide_Wide_Text_IO::
287 * Filenames encoding::
289 * Operations on C Streams::
290 * Interfacing to C Streams::
294 * Ada.Characters.Latin_9 (a-chlat9.ads)::
295 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
296 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
297 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
298 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
299 * Ada.Command_Line.Environment (a-colien.ads)::
300 * Ada.Command_Line.Remove (a-colire.ads)::
301 * Ada.Command_Line.Response_File (a-clrefi.ads)::
302 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
303 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
304 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
305 * Ada.Exceptions.Traceback (a-exctra.ads)::
306 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
307 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
308 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
309 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
310 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
311 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
312 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
313 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
314 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
315 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
316 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
317 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
318 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
319 * GNAT.Altivec (g-altive.ads)::
320 * GNAT.Altivec.Conversions (g-altcon.ads)::
321 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
322 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
323 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
324 * GNAT.Array_Split (g-arrspl.ads)::
325 * GNAT.AWK (g-awk.ads)::
326 * GNAT.Bounded_Buffers (g-boubuf.ads)::
327 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
328 * GNAT.Bubble_Sort (g-bubsor.ads)::
329 * GNAT.Bubble_Sort_A (g-busora.ads)::
330 * GNAT.Bubble_Sort_G (g-busorg.ads)::
331 * GNAT.Byte_Order_Mark (g-byorma.ads)::
332 * GNAT.Byte_Swapping (g-bytswa.ads)::
333 * GNAT.Calendar (g-calend.ads)::
334 * GNAT.Calendar.Time_IO (g-catiio.ads)::
335 * GNAT.Case_Util (g-casuti.ads)::
336 * GNAT.CGI (g-cgi.ads)::
337 * GNAT.CGI.Cookie (g-cgicoo.ads)::
338 * GNAT.CGI.Debug (g-cgideb.ads)::
339 * GNAT.Command_Line (g-comlin.ads)::
340 * GNAT.Compiler_Version (g-comver.ads)::
341 * GNAT.Ctrl_C (g-ctrl_c.ads)::
342 * GNAT.CRC32 (g-crc32.ads)::
343 * GNAT.Current_Exception (g-curexc.ads)::
344 * GNAT.Debug_Pools (g-debpoo.ads)::
345 * GNAT.Debug_Utilities (g-debuti.ads)::
346 * GNAT.Decode_String (g-decstr.ads)::
347 * GNAT.Decode_UTF8_String (g-deutst.ads)::
348 * GNAT.Directory_Operations (g-dirope.ads)::
349 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
350 * GNAT.Dynamic_HTables (g-dynhta.ads)::
351 * GNAT.Dynamic_Tables (g-dyntab.ads)::
352 * GNAT.Encode_String (g-encstr.ads)::
353 * GNAT.Encode_UTF8_String (g-enutst.ads)::
354 * GNAT.Exception_Actions (g-excact.ads)::
355 * GNAT.Exception_Traces (g-exctra.ads)::
356 * GNAT.Exceptions (g-except.ads)::
357 * GNAT.Expect (g-expect.ads)::
358 * GNAT.Float_Control (g-flocon.ads)::
359 * GNAT.Heap_Sort (g-heasor.ads)::
360 * GNAT.Heap_Sort_A (g-hesora.ads)::
361 * GNAT.Heap_Sort_G (g-hesorg.ads)::
362 * GNAT.HTable (g-htable.ads)::
363 * GNAT.IO (g-io.ads)::
364 * GNAT.IO_Aux (g-io_aux.ads)::
365 * GNAT.Lock_Files (g-locfil.ads)::
366 * GNAT.MD5 (g-md5.ads)::
367 * GNAT.Memory_Dump (g-memdum.ads)::
368 * GNAT.Most_Recent_Exception (g-moreex.ads)::
369 * GNAT.OS_Lib (g-os_lib.ads)::
370 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
371 * GNAT.Random_Numbers (g-rannum.ads)::
372 * GNAT.Regexp (g-regexp.ads)::
373 * GNAT.Registry (g-regist.ads)::
374 * GNAT.Regpat (g-regpat.ads)::
375 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
376 * GNAT.Semaphores (g-semaph.ads)::
377 * GNAT.Serial_Communications (g-sercom.ads)::
378 * GNAT.SHA1 (g-sha1.ads)::
379 * GNAT.SHA224 (g-sha224.ads)::
380 * GNAT.SHA256 (g-sha256.ads)::
381 * GNAT.SHA384 (g-sha384.ads)::
382 * GNAT.SHA512 (g-sha512.ads)::
383 * GNAT.Signals (g-signal.ads)::
384 * GNAT.Sockets (g-socket.ads)::
385 * GNAT.Source_Info (g-souinf.ads)::
386 * GNAT.Spelling_Checker (g-speche.ads)::
387 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
388 * GNAT.Spitbol.Patterns (g-spipat.ads)::
389 * GNAT.Spitbol (g-spitbo.ads)::
390 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
391 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
392 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
393 * GNAT.SSE (g-sse.ads)::
394 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
395 * GNAT.Strings (g-string.ads)::
396 * GNAT.String_Split (g-strspl.ads)::
397 * GNAT.Table (g-table.ads)::
398 * GNAT.Task_Lock (g-tasloc.ads)::
399 * GNAT.Threads (g-thread.ads)::
400 * GNAT.Time_Stamp (g-timsta.ads)::
401 * GNAT.Traceback (g-traceb.ads)::
402 * GNAT.Traceback.Symbolic (g-trasym.ads)::
403 * GNAT.UTF_32 (g-utf_32.ads)::
404 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
405 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
406 * GNAT.Wide_String_Split (g-wistsp.ads)::
407 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
408 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
409 * Interfaces.C.Extensions (i-cexten.ads)::
410 * Interfaces.C.Streams (i-cstrea.ads)::
411 * Interfaces.CPP (i-cpp.ads)::
412 * Interfaces.Packed_Decimal (i-pacdec.ads)::
413 * Interfaces.VxWorks (i-vxwork.ads)::
414 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
415 * System.Address_Image (s-addima.ads)::
416 * System.Assertions (s-assert.ads)::
417 * System.Memory (s-memory.ads)::
418 * System.Partition_Interface (s-parint.ads)::
419 * System.Pool_Global (s-pooglo.ads)::
420 * System.Pool_Local (s-pooloc.ads)::
421 * System.Restrictions (s-restri.ads)::
422 * System.Rident (s-rident.ads)::
423 * System.Strings.Stream_Ops (s-ststop.ads)::
424 * System.Task_Info (s-tasinf.ads)::
425 * System.Wch_Cnv (s-wchcnv.ads)::
426 * System.Wch_Con (s-wchcon.ads)::
430 * Text_IO Stream Pointer Positioning::
431 * Text_IO Reading and Writing Non-Regular Files::
433 * Treating Text_IO Files as Streams::
434 * Text_IO Extensions::
435 * Text_IO Facilities for Unbounded Strings::
439 * Wide_Text_IO Stream Pointer Positioning::
440 * Wide_Text_IO Reading and Writing Non-Regular Files::
444 * Wide_Wide_Text_IO Stream Pointer Positioning::
445 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
447 Interfacing to Other Languages
450 * Interfacing to C++::
451 * Interfacing to COBOL::
452 * Interfacing to Fortran::
453 * Interfacing to non-GNAT Ada code::
455 Specialized Needs Annexes
457 Implementation of Specific Ada Features
458 * Machine Code Insertions::
459 * GNAT Implementation of Tasking::
460 * GNAT Implementation of Shared Passive Packages::
461 * Code Generation for Array Aggregates::
462 * The Size of Discriminated Records with Default Discriminants::
463 * Strict Conformance to the Ada Reference Manual::
467 GNU Free Documentation License
474 @node About This Guide
475 @unnumbered About This Guide
478 This manual contains useful information in writing programs using the
479 @value{EDITION} compiler. It includes information on implementation dependent
480 characteristics of @value{EDITION}, including all the information required by
481 Annex M of the Ada language standard.
483 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
484 Ada 83 compatibility mode.
485 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
486 but you can override with a compiler switch
487 to explicitly specify the language version.
488 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
489 @value{EDITION} User's Guide}, for details on these switches.)
490 Throughout this manual, references to ``Ada'' without a year suffix
491 apply to both the Ada 95 and Ada 2005 versions of the language.
493 Ada is designed to be highly portable.
494 In general, a program will have the same effect even when compiled by
495 different compilers on different platforms.
496 However, since Ada is designed to be used in a
497 wide variety of applications, it also contains a number of system
498 dependent features to be used in interfacing to the external world.
499 @cindex Implementation-dependent features
502 Note: Any program that makes use of implementation-dependent features
503 may be non-portable. You should follow good programming practice and
504 isolate and clearly document any sections of your program that make use
505 of these features in a non-portable manner.
508 For ease of exposition, ``GNAT Pro'' will be referred to simply as
509 ``GNAT'' in the remainder of this document.
513 * What This Reference Manual Contains::
515 * Related Information::
518 @node What This Reference Manual Contains
519 @unnumberedsec What This Reference Manual Contains
522 This reference manual contains the following chapters:
526 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
527 pragmas, which can be used to extend and enhance the functionality of the
531 @ref{Implementation Defined Attributes}, lists GNAT
532 implementation-dependent attributes which can be used to extend and
533 enhance the functionality of the compiler.
536 @ref{Implementation Advice}, provides information on generally
537 desirable behavior which are not requirements that all compilers must
538 follow since it cannot be provided on all systems, or which may be
539 undesirable on some systems.
542 @ref{Implementation Defined Characteristics}, provides a guide to
543 minimizing implementation dependent features.
546 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
547 implemented by GNAT, and how they can be imported into user
548 application programs.
551 @ref{Representation Clauses and Pragmas}, describes in detail the
552 way that GNAT represents data, and in particular the exact set
553 of representation clauses and pragmas that is accepted.
556 @ref{Standard Library Routines}, provides a listing of packages and a
557 brief description of the functionality that is provided by Ada's
558 extensive set of standard library routines as implemented by GNAT@.
561 @ref{The Implementation of Standard I/O}, details how the GNAT
562 implementation of the input-output facilities.
565 @ref{The GNAT Library}, is a catalog of packages that complement
566 the Ada predefined library.
569 @ref{Interfacing to Other Languages}, describes how programs
570 written in Ada using GNAT can be interfaced to other programming
573 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
574 of the specialized needs annexes.
577 @ref{Implementation of Specific Ada Features}, discusses issues related
578 to GNAT's implementation of machine code insertions, tasking, and several
582 @ref{Obsolescent Features} documents implementation dependent features,
583 including pragmas and attributes, which are considered obsolescent, since
584 there are other preferred ways of achieving the same results. These
585 obsolescent forms are retained for backwards compatibility.
589 @cindex Ada 95 Language Reference Manual
590 @cindex Ada 2005 Language Reference Manual
592 This reference manual assumes a basic familiarity with the Ada 95 language, as
593 described in the International Standard ANSI/ISO/IEC-8652:1995,
595 It does not require knowledge of the new features introduced by Ada 2005,
596 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
598 Both reference manuals are included in the GNAT documentation
602 @unnumberedsec Conventions
603 @cindex Conventions, typographical
604 @cindex Typographical conventions
607 Following are examples of the typographical and graphic conventions used
612 @code{Functions}, @code{utility program names}, @code{standard names},
619 @file{File names}, @samp{button names}, and @samp{field names}.
622 @code{Variables}, @env{environment variables}, and @var{metasyntactic
629 [optional information or parameters]
632 Examples are described by text
634 and then shown this way.
639 Commands that are entered by the user are preceded in this manual by the
640 characters @samp{$ } (dollar sign followed by space). If your system uses this
641 sequence as a prompt, then the commands will appear exactly as you see them
642 in the manual. If your system uses some other prompt, then the command will
643 appear with the @samp{$} replaced by whatever prompt character you are using.
645 @node Related Information
646 @unnumberedsec Related Information
648 See the following documents for further information on GNAT:
652 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
653 @value{EDITION} User's Guide}, which provides information on how to use the
654 GNAT compiler system.
657 @cite{Ada 95 Reference Manual}, which contains all reference
658 material for the Ada 95 programming language.
661 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
662 of the Ada 95 standard. The annotations describe
663 detailed aspects of the design decision, and in particular contain useful
664 sections on Ada 83 compatibility.
667 @cite{Ada 2005 Reference Manual}, which contains all reference
668 material for the Ada 2005 programming language.
671 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
672 of the Ada 2005 standard. The annotations describe
673 detailed aspects of the design decision, and in particular contain useful
674 sections on Ada 83 and Ada 95 compatibility.
677 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
678 which contains specific information on compatibility between GNAT and
682 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
683 describes in detail the pragmas and attributes provided by the DEC Ada 83
688 @node Implementation Defined Pragmas
689 @chapter Implementation Defined Pragmas
692 Ada defines a set of pragmas that can be used to supply additional
693 information to the compiler. These language defined pragmas are
694 implemented in GNAT and work as described in the Ada Reference Manual.
696 In addition, Ada allows implementations to define additional pragmas
697 whose meaning is defined by the implementation. GNAT provides a number
698 of these implementation-defined pragmas, which can be used to extend
699 and enhance the functionality of the compiler. This section of the GNAT
700 Reference Manual describes these additional pragmas.
702 Note that any program using these pragmas might not be portable to other
703 compilers (although GNAT implements this set of pragmas on all
704 platforms). Therefore if portability to other compilers is an important
705 consideration, the use of these pragmas should be minimized.
708 * Pragma Abort_Defer::
715 * Pragma Assume_No_Invalid_Values::
717 * Pragma C_Pass_By_Copy::
719 * Pragma Check_Name::
720 * Pragma Check_Policy::
722 * Pragma Common_Object::
723 * Pragma Compile_Time_Error::
724 * Pragma Compile_Time_Warning::
725 * Pragma Compiler_Unit::
726 * Pragma Complete_Representation::
727 * Pragma Complex_Representation::
728 * Pragma Component_Alignment::
729 * Pragma Convention_Identifier::
731 * Pragma CPP_Constructor::
732 * Pragma CPP_Virtual::
733 * Pragma CPP_Vtable::
735 * Pragma Debug_Policy::
736 * Pragma Detect_Blocking::
737 * Pragma Elaboration_Checks::
739 * Pragma Export_Exception::
740 * Pragma Export_Function::
741 * Pragma Export_Object::
742 * Pragma Export_Procedure::
743 * Pragma Export_Value::
744 * Pragma Export_Valued_Procedure::
745 * Pragma Extend_System::
747 * Pragma External_Name_Casing::
749 * Pragma Favor_Top_Level::
750 * Pragma Finalize_Storage_Only::
751 * Pragma Float_Representation::
753 * Pragma Implemented_By_Entry::
754 * Pragma Implicit_Packing::
755 * Pragma Import_Exception::
756 * Pragma Import_Function::
757 * Pragma Import_Object::
758 * Pragma Import_Procedure::
759 * Pragma Import_Valued_Procedure::
760 * Pragma Initialize_Scalars::
761 * Pragma Inline_Always::
762 * Pragma Inline_Generic::
764 * Pragma Interface_Name::
765 * Pragma Interrupt_Handler::
766 * Pragma Interrupt_State::
767 * Pragma Keep_Names::
770 * Pragma Linker_Alias::
771 * Pragma Linker_Constructor::
772 * Pragma Linker_Destructor::
773 * Pragma Linker_Section::
774 * Pragma Long_Float::
775 * Pragma Machine_Attribute::
777 * Pragma Main_Storage::
780 * Pragma No_Strict_Aliasing::
781 * Pragma Normalize_Scalars::
782 * Pragma Obsolescent::
783 * Pragma Optimize_Alignment::
785 * Pragma Persistent_BSS::
787 * Pragma Postcondition::
788 * Pragma Precondition::
789 * Pragma Profile (Ravenscar)::
790 * Pragma Profile (Restricted)::
791 * Pragma Psect_Object::
792 * Pragma Pure_Function::
793 * Pragma Restriction_Warnings::
795 * Pragma Short_Circuit_And_Or::
796 * Pragma Source_File_Name::
797 * Pragma Source_File_Name_Project::
798 * Pragma Source_Reference::
799 * Pragma Stream_Convert::
800 * Pragma Style_Checks::
803 * Pragma Suppress_All::
804 * Pragma Suppress_Exception_Locations::
805 * Pragma Suppress_Initialization::
808 * Pragma Task_Storage::
809 * Pragma Thread_Local_Storage::
810 * Pragma Time_Slice::
812 * Pragma Unchecked_Union::
813 * Pragma Unimplemented_Unit::
814 * Pragma Universal_Aliasing ::
815 * Pragma Universal_Data::
816 * Pragma Unmodified::
817 * Pragma Unreferenced::
818 * Pragma Unreferenced_Objects::
819 * Pragma Unreserve_All_Interrupts::
820 * Pragma Unsuppress::
821 * Pragma Use_VADS_Size::
822 * Pragma Validity_Checks::
825 * Pragma Weak_External::
826 * Pragma Wide_Character_Encoding::
829 @node Pragma Abort_Defer
830 @unnumberedsec Pragma Abort_Defer
832 @cindex Deferring aborts
840 This pragma must appear at the start of the statement sequence of a
841 handled sequence of statements (right after the @code{begin}). It has
842 the effect of deferring aborts for the sequence of statements (but not
843 for the declarations or handlers, if any, associated with this statement
847 @unnumberedsec Pragma Ada_83
856 A configuration pragma that establishes Ada 83 mode for the unit to
857 which it applies, regardless of the mode set by the command line
858 switches. In Ada 83 mode, GNAT attempts to be as compatible with
859 the syntax and semantics of Ada 83, as defined in the original Ada
860 83 Reference Manual as possible. In particular, the keywords added by Ada 95
861 and Ada 2005 are not recognized, optional package bodies are allowed,
862 and generics may name types with unknown discriminants without using
863 the @code{(<>)} notation. In addition, some but not all of the additional
864 restrictions of Ada 83 are enforced.
866 Ada 83 mode is intended for two purposes. Firstly, it allows existing
867 Ada 83 code to be compiled and adapted to GNAT with less effort.
868 Secondly, it aids in keeping code backwards compatible with Ada 83.
869 However, there is no guarantee that code that is processed correctly
870 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
871 83 compiler, since GNAT does not enforce all the additional checks
875 @unnumberedsec Pragma Ada_95
884 A configuration pragma that establishes Ada 95 mode for the unit to which
885 it applies, regardless of the mode set by the command line switches.
886 This mode is set automatically for the @code{Ada} and @code{System}
887 packages and their children, so you need not specify it in these
888 contexts. This pragma is useful when writing a reusable component that
889 itself uses Ada 95 features, but which is intended to be usable from
890 either Ada 83 or Ada 95 programs.
893 @unnumberedsec Pragma Ada_05
902 A configuration pragma that establishes Ada 2005 mode for the unit to which
903 it applies, regardless of the mode set by the command line switches.
904 This mode is set automatically for the @code{Ada} and @code{System}
905 packages and their children, so you need not specify it in these
906 contexts. This pragma is useful when writing a reusable component that
907 itself uses Ada 2005 features, but which is intended to be usable from
908 either Ada 83 or Ada 95 programs.
910 @node Pragma Ada_2005
911 @unnumberedsec Pragma Ada_2005
920 This configuration pragma is a synonym for pragma Ada_05 and has the
921 same syntax and effect.
923 @node Pragma Annotate
924 @unnumberedsec Pragma Annotate
929 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
931 ARG ::= NAME | EXPRESSION
935 This pragma is used to annotate programs. @var{identifier} identifies
936 the type of annotation. GNAT verifies that it is an identifier, but does
937 not otherwise analyze it. The second optional identifier is also left
938 unanalyzed, and by convention is used to control the action of the tool to
939 which the annotation is addressed. The remaining @var{arg} arguments
940 can be either string literals or more generally expressions.
941 String literals are assumed to be either of type
942 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
943 depending on the character literals they contain.
944 All other kinds of arguments are analyzed as expressions, and must be
947 The analyzed pragma is retained in the tree, but not otherwise processed
948 by any part of the GNAT compiler. This pragma is intended for use by
949 external tools, including ASIS@.
952 @unnumberedsec Pragma Assert
959 [, string_EXPRESSION]);
963 The effect of this pragma depends on whether the corresponding command
964 line switch is set to activate assertions. The pragma expands into code
965 equivalent to the following:
968 if assertions-enabled then
969 if not boolean_EXPRESSION then
970 System.Assertions.Raise_Assert_Failure
977 The string argument, if given, is the message that will be associated
978 with the exception occurrence if the exception is raised. If no second
979 argument is given, the default message is @samp{@var{file}:@var{nnn}},
980 where @var{file} is the name of the source file containing the assert,
981 and @var{nnn} is the line number of the assert. A pragma is not a
982 statement, so if a statement sequence contains nothing but a pragma
983 assert, then a null statement is required in addition, as in:
988 pragma Assert (K > 3, "Bad value for K");
994 Note that, as with the @code{if} statement to which it is equivalent, the
995 type of the expression is either @code{Standard.Boolean}, or any type derived
996 from this standard type.
998 If assertions are disabled (switch @option{-gnata} not used), then there
999 is no run-time effect (and in particular, any side effects from the
1000 expression will not occur at run time). (The expression is still
1001 analyzed at compile time, and may cause types to be frozen if they are
1002 mentioned here for the first time).
1004 If assertions are enabled, then the given expression is tested, and if
1005 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1006 which results in the raising of @code{Assert_Failure} with the given message.
1008 You should generally avoid side effects in the expression arguments of
1009 this pragma, because these side effects will turn on and off with the
1010 setting of the assertions mode, resulting in assertions that have an
1011 effect on the program. However, the expressions are analyzed for
1012 semantic correctness whether or not assertions are enabled, so turning
1013 assertions on and off cannot affect the legality of a program.
1015 @node Pragma Assume_No_Invalid_Values
1016 @unnumberedsec Pragma Assume_No_Invalid_Values
1017 @findex Assume_No_Invalid_Values
1018 @cindex Invalid representations
1019 @cindex Invalid values
1022 @smallexample @c ada
1023 pragma Assume_No_Invalid_Values (On | Off);
1027 This is a configuration pragma that controls the assumptions made by the
1028 compiler about the occurrence of invalid representations (invalid values)
1031 The default behavior (corresponding to an Off argument for this pragma), is
1032 to assume that values may in general be invalid unless the compiler can
1033 prove they are valid. Consider the following example:
1035 @smallexample @c ada
1036 V1 : Integer range 1 .. 10;
1037 V2 : Integer range 11 .. 20;
1039 for J in V2 .. V1 loop
1045 if V1 and V2 have valid values, then the loop is known at compile
1046 time not to execute since the lower bound must be greater than the
1047 upper bound. However in default mode, no such assumption is made,
1048 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1049 is given, the compiler will assume that any occurrence of a variable
1050 other than in an explicit @code{'Valid} test always has a valid
1051 value, and the loop above will be optimized away.
1053 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1054 you know your code is free of uninitialized variables and other
1055 possible sources of invalid representations, and may result in
1056 more efficient code. A program that accesses an invalid representation
1057 with this pragma in effect is erroneous, so no guarantees can be made
1060 It is peculiar though permissible to use this pragma in conjunction
1061 with validity checking (-gnatVa). In such cases, accessing invalid
1062 values will generally give an exception, though formally the program
1063 is erroneous so there are no guarantees that this will always be the
1064 case, and it is recommended that these two options not be used together.
1066 @node Pragma Ast_Entry
1067 @unnumberedsec Pragma Ast_Entry
1072 @smallexample @c ada
1073 pragma AST_Entry (entry_IDENTIFIER);
1077 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1078 argument is the simple name of a single entry; at most one @code{AST_Entry}
1079 pragma is allowed for any given entry. This pragma must be used in
1080 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1081 the entry declaration and in the same task type specification or single task
1082 as the entry to which it applies. This pragma specifies that the given entry
1083 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1084 resulting from an OpenVMS system service call. The pragma does not affect
1085 normal use of the entry. For further details on this pragma, see the
1086 DEC Ada Language Reference Manual, section 9.12a.
1088 @node Pragma C_Pass_By_Copy
1089 @unnumberedsec Pragma C_Pass_By_Copy
1090 @cindex Passing by copy
1091 @findex C_Pass_By_Copy
1094 @smallexample @c ada
1095 pragma C_Pass_By_Copy
1096 ([Max_Size =>] static_integer_EXPRESSION);
1100 Normally the default mechanism for passing C convention records to C
1101 convention subprograms is to pass them by reference, as suggested by RM
1102 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1103 this default, by requiring that record formal parameters be passed by
1104 copy if all of the following conditions are met:
1108 The size of the record type does not exceed the value specified for
1111 The record type has @code{Convention C}.
1113 The formal parameter has this record type, and the subprogram has a
1114 foreign (non-Ada) convention.
1118 If these conditions are met the argument is passed by copy, i.e.@: in a
1119 manner consistent with what C expects if the corresponding formal in the
1120 C prototype is a struct (rather than a pointer to a struct).
1122 You can also pass records by copy by specifying the convention
1123 @code{C_Pass_By_Copy} for the record type, or by using the extended
1124 @code{Import} and @code{Export} pragmas, which allow specification of
1125 passing mechanisms on a parameter by parameter basis.
1128 @unnumberedsec Pragma Check
1130 @cindex Named assertions
1134 @smallexample @c ada
1136 [Name =>] Identifier,
1137 [Check =>] Boolean_EXPRESSION
1138 [, [Message =>] string_EXPRESSION] );
1142 This pragma is similar to the predefined pragma @code{Assert} except that an
1143 extra identifier argument is present. In conjunction with pragma
1144 @code{Check_Policy}, this can be used to define groups of assertions that can
1145 be independently controlled. The identifier @code{Assertion} is special, it
1146 refers to the normal set of pragma @code{Assert} statements. The identifiers
1147 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1148 names, so these three names would normally not be used directly in a pragma
1151 Checks introduced by this pragma are normally deactivated by default. They can
1152 be activated either by the command line option @option{-gnata}, which turns on
1153 all checks, or individually controlled using pragma @code{Check_Policy}.
1155 @node Pragma Check_Name
1156 @unnumberedsec Pragma Check_Name
1157 @cindex Defining check names
1158 @cindex Check names, defining
1162 @smallexample @c ada
1163 pragma Check_Name (check_name_IDENTIFIER);
1167 This is a configuration pragma that defines a new implementation
1168 defined check name (unless IDENTIFIER matches one of the predefined
1169 check names, in which case the pragma has no effect). Check names
1170 are global to a partition, so if two or more configuration pragmas
1171 are present in a partition mentioning the same name, only one new
1172 check name is introduced.
1174 An implementation defined check name introduced with this pragma may
1175 be used in only three contexts: @code{pragma Suppress},
1176 @code{pragma Unsuppress},
1177 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1178 any of these three cases, the check name must be visible. A check
1179 name is visible if it is in the configuration pragmas applying to
1180 the current unit, or if it appears at the start of any unit that
1181 is part of the dependency set of the current unit (e.g., units that
1182 are mentioned in @code{with} clauses).
1184 @node Pragma Check_Policy
1185 @unnumberedsec Pragma Check_Policy
1186 @cindex Controlling assertions
1187 @cindex Assertions, control
1188 @cindex Check pragma control
1189 @cindex Named assertions
1193 @smallexample @c ada
1195 ([Name =>] Identifier,
1196 [Policy =>] POLICY_IDENTIFIER);
1198 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1202 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1203 except that it controls sets of named assertions introduced using the
1204 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1205 @code{Assertion_Policy}) can be used within a declarative part, in which case
1206 it controls the status to the end of the corresponding construct (in a manner
1207 identical to pragma @code{Suppress)}.
1209 The identifier given as the first argument corresponds to a name used in
1210 associated @code{Check} pragmas. For example, if the pragma:
1212 @smallexample @c ada
1213 pragma Check_Policy (Critical_Error, Off);
1217 is given, then subsequent @code{Check} pragmas whose first argument is also
1218 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1219 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1220 @code{Check_Policy} with this identifier is similar to the normal
1221 @code{Assertion_Policy} pragma except that it can appear within a
1224 The special identifiers @code{Precondition} and @code{Postcondition} control
1225 the status of preconditions and postconditions. If a @code{Precondition} pragma
1226 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1227 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1228 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1231 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1232 to turn on corresponding checks. The default for a set of checks for which no
1233 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1234 @option{-gnata} is given, which turns on all checks by default.
1236 The check policy settings @code{Check} and @code{Ignore} are also recognized
1237 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1238 compatibility with the standard @code{Assertion_Policy} pragma.
1240 @node Pragma Comment
1241 @unnumberedsec Pragma Comment
1246 @smallexample @c ada
1247 pragma Comment (static_string_EXPRESSION);
1251 This is almost identical in effect to pragma @code{Ident}. It allows the
1252 placement of a comment into the object file and hence into the
1253 executable file if the operating system permits such usage. The
1254 difference is that @code{Comment}, unlike @code{Ident}, has
1255 no limitations on placement of the pragma (it can be placed
1256 anywhere in the main source unit), and if more than one pragma
1257 is used, all comments are retained.
1259 @node Pragma Common_Object
1260 @unnumberedsec Pragma Common_Object
1261 @findex Common_Object
1265 @smallexample @c ada
1266 pragma Common_Object (
1267 [Internal =>] LOCAL_NAME
1268 [, [External =>] EXTERNAL_SYMBOL]
1269 [, [Size =>] EXTERNAL_SYMBOL] );
1273 | static_string_EXPRESSION
1277 This pragma enables the shared use of variables stored in overlaid
1278 linker areas corresponding to the use of @code{COMMON}
1279 in Fortran. The single
1280 object @var{LOCAL_NAME} is assigned to the area designated by
1281 the @var{External} argument.
1282 You may define a record to correspond to a series
1283 of fields. The @var{Size} argument
1284 is syntax checked in GNAT, but otherwise ignored.
1286 @code{Common_Object} is not supported on all platforms. If no
1287 support is available, then the code generator will issue a message
1288 indicating that the necessary attribute for implementation of this
1289 pragma is not available.
1291 @node Pragma Compile_Time_Error
1292 @unnumberedsec Pragma Compile_Time_Error
1293 @findex Compile_Time_Error
1297 @smallexample @c ada
1298 pragma Compile_Time_Error
1299 (boolean_EXPRESSION, static_string_EXPRESSION);
1303 This pragma can be used to generate additional compile time
1305 is particularly useful in generics, where errors can be issued for
1306 specific problematic instantiations. The first parameter is a boolean
1307 expression. The pragma is effective only if the value of this expression
1308 is known at compile time, and has the value True. The set of expressions
1309 whose values are known at compile time includes all static boolean
1310 expressions, and also other values which the compiler can determine
1311 at compile time (e.g., the size of a record type set by an explicit
1312 size representation clause, or the value of a variable which was
1313 initialized to a constant and is known not to have been modified).
1314 If these conditions are met, an error message is generated using
1315 the value given as the second argument. This string value may contain
1316 embedded ASCII.LF characters to break the message into multiple lines.
1318 @node Pragma Compile_Time_Warning
1319 @unnumberedsec Pragma Compile_Time_Warning
1320 @findex Compile_Time_Warning
1324 @smallexample @c ada
1325 pragma Compile_Time_Warning
1326 (boolean_EXPRESSION, static_string_EXPRESSION);
1330 Same as pragma Compile_Time_Error, except a warning is issued instead
1331 of an error message. Note that if this pragma is used in a package that
1332 is with'ed by a client, the client will get the warning even though it
1333 is issued by a with'ed package (normally warnings in with'ed units are
1334 suppressed, but this is a special exception to that rule).
1336 One typical use is within a generic where compile time known characteristics
1337 of formal parameters are tested, and warnings given appropriately. Another use
1338 with a first parameter of True is to warn a client about use of a package,
1339 for example that it is not fully implemented.
1341 @node Pragma Compiler_Unit
1342 @unnumberedsec Pragma Compiler_Unit
1343 @findex Compiler_Unit
1347 @smallexample @c ada
1348 pragma Compiler_Unit;
1352 This pragma is intended only for internal use in the GNAT run-time library.
1353 It indicates that the unit is used as part of the compiler build. The effect
1354 is to disallow constructs (raise with message, conditional expressions etc)
1355 that would cause trouble when bootstrapping using an older version of GNAT.
1356 For the exact list of restrictions, see the compiler sources and references
1357 to Is_Compiler_Unit.
1359 @node Pragma Complete_Representation
1360 @unnumberedsec Pragma Complete_Representation
1361 @findex Complete_Representation
1365 @smallexample @c ada
1366 pragma Complete_Representation;
1370 This pragma must appear immediately within a record representation
1371 clause. Typical placements are before the first component clause
1372 or after the last component clause. The effect is to give an error
1373 message if any component is missing a component clause. This pragma
1374 may be used to ensure that a record representation clause is
1375 complete, and that this invariant is maintained if fields are
1376 added to the record in the future.
1378 @node Pragma Complex_Representation
1379 @unnumberedsec Pragma Complex_Representation
1380 @findex Complex_Representation
1384 @smallexample @c ada
1385 pragma Complex_Representation
1386 ([Entity =>] LOCAL_NAME);
1390 The @var{Entity} argument must be the name of a record type which has
1391 two fields of the same floating-point type. The effect of this pragma is
1392 to force gcc to use the special internal complex representation form for
1393 this record, which may be more efficient. Note that this may result in
1394 the code for this type not conforming to standard ABI (application
1395 binary interface) requirements for the handling of record types. For
1396 example, in some environments, there is a requirement for passing
1397 records by pointer, and the use of this pragma may result in passing
1398 this type in floating-point registers.
1400 @node Pragma Component_Alignment
1401 @unnumberedsec Pragma Component_Alignment
1402 @cindex Alignments of components
1403 @findex Component_Alignment
1407 @smallexample @c ada
1408 pragma Component_Alignment (
1409 [Form =>] ALIGNMENT_CHOICE
1410 [, [Name =>] type_LOCAL_NAME]);
1412 ALIGNMENT_CHOICE ::=
1420 Specifies the alignment of components in array or record types.
1421 The meaning of the @var{Form} argument is as follows:
1424 @findex Component_Size
1425 @item Component_Size
1426 Aligns scalar components and subcomponents of the array or record type
1427 on boundaries appropriate to their inherent size (naturally
1428 aligned). For example, 1-byte components are aligned on byte boundaries,
1429 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1430 integer components are aligned on 4-byte boundaries and so on. These
1431 alignment rules correspond to the normal rules for C compilers on all
1432 machines except the VAX@.
1434 @findex Component_Size_4
1435 @item Component_Size_4
1436 Naturally aligns components with a size of four or fewer
1437 bytes. Components that are larger than 4 bytes are placed on the next
1440 @findex Storage_Unit
1442 Specifies that array or record components are byte aligned, i.e.@:
1443 aligned on boundaries determined by the value of the constant
1444 @code{System.Storage_Unit}.
1448 Specifies that array or record components are aligned on default
1449 boundaries, appropriate to the underlying hardware or operating system or
1450 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1451 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1452 the @code{Default} choice is the same as @code{Component_Size} (natural
1457 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1458 refer to a local record or array type, and the specified alignment
1459 choice applies to the specified type. The use of
1460 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1461 @code{Component_Alignment} pragma to be ignored. The use of
1462 @code{Component_Alignment} together with a record representation clause
1463 is only effective for fields not specified by the representation clause.
1465 If the @code{Name} parameter is absent, the pragma can be used as either
1466 a configuration pragma, in which case it applies to one or more units in
1467 accordance with the normal rules for configuration pragmas, or it can be
1468 used within a declarative part, in which case it applies to types that
1469 are declared within this declarative part, or within any nested scope
1470 within this declarative part. In either case it specifies the alignment
1471 to be applied to any record or array type which has otherwise standard
1474 If the alignment for a record or array type is not specified (using
1475 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1476 clause), the GNAT uses the default alignment as described previously.
1478 @node Pragma Convention_Identifier
1479 @unnumberedsec Pragma Convention_Identifier
1480 @findex Convention_Identifier
1481 @cindex Conventions, synonyms
1485 @smallexample @c ada
1486 pragma Convention_Identifier (
1487 [Name =>] IDENTIFIER,
1488 [Convention =>] convention_IDENTIFIER);
1492 This pragma provides a mechanism for supplying synonyms for existing
1493 convention identifiers. The @code{Name} identifier can subsequently
1494 be used as a synonym for the given convention in other pragmas (including
1495 for example pragma @code{Import} or another @code{Convention_Identifier}
1496 pragma). As an example of the use of this, suppose you had legacy code
1497 which used Fortran77 as the identifier for Fortran. Then the pragma:
1499 @smallexample @c ada
1500 pragma Convention_Identifier (Fortran77, Fortran);
1504 would allow the use of the convention identifier @code{Fortran77} in
1505 subsequent code, avoiding the need to modify the sources. As another
1506 example, you could use this to parametrize convention requirements
1507 according to systems. Suppose you needed to use @code{Stdcall} on
1508 windows systems, and @code{C} on some other system, then you could
1509 define a convention identifier @code{Library} and use a single
1510 @code{Convention_Identifier} pragma to specify which convention
1511 would be used system-wide.
1513 @node Pragma CPP_Class
1514 @unnumberedsec Pragma CPP_Class
1516 @cindex Interfacing with C++
1520 @smallexample @c ada
1521 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1525 The argument denotes an entity in the current declarative region that is
1526 declared as a record type. It indicates that the type corresponds to an
1527 externally declared C++ class type, and is to be laid out the same way
1528 that C++ would lay out the type. If the C++ class has virtual primitives
1529 then the record must be declared as a tagged record type.
1531 Types for which @code{CPP_Class} is specified do not have assignment or
1532 equality operators defined (such operations can be imported or declared
1533 as subprograms as required). Initialization is allowed only by constructor
1534 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1535 limited if not explicitly declared as limited or derived from a limited
1536 type, and an error is issued in that case.
1538 Pragma @code{CPP_Class} is intended primarily for automatic generation
1539 using an automatic binding generator tool.
1540 See @ref{Interfacing to C++} for related information.
1542 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1543 for backward compatibility but its functionality is available
1544 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1546 @node Pragma CPP_Constructor
1547 @unnumberedsec Pragma CPP_Constructor
1548 @cindex Interfacing with C++
1549 @findex CPP_Constructor
1553 @smallexample @c ada
1554 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1555 [, [External_Name =>] static_string_EXPRESSION ]
1556 [, [Link_Name =>] static_string_EXPRESSION ]);
1560 This pragma identifies an imported function (imported in the usual way
1561 with pragma @code{Import}) as corresponding to a C++ constructor. If
1562 @code{External_Name} and @code{Link_Name} are not specified then the
1563 @code{Entity} argument is a name that must have been previously mentioned
1564 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1565 must be of one of the following forms:
1569 @code{function @var{Fname} return @var{T}}
1573 @code{function @var{Fname} return @var{T}'Class}
1576 @code{function @var{Fname} (@dots{}) return @var{T}}
1580 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1584 where @var{T} is a limited record type imported from C++ with pragma
1585 @code{Import} and @code{Convention} = @code{CPP}.
1587 The first two forms import the default constructor, used when an object
1588 of type @var{T} is created on the Ada side with no explicit constructor.
1589 The latter two forms cover all the non-default constructors of the type.
1590 See the GNAT users guide for details.
1592 If no constructors are imported, it is impossible to create any objects
1593 on the Ada side and the type is implicitly declared abstract.
1595 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1596 using an automatic binding generator tool.
1597 See @ref{Interfacing to C++} for more related information.
1599 Note: The use of functions returning class-wide types for constructors is
1600 currently obsolete. They are supported for backward compatibility. The
1601 use of functions returning the type T leave the Ada sources more clear
1602 because the imported C++ constructors always return an object of type T;
1603 that is, they never return an object whose type is a descendant of type T.
1605 @node Pragma CPP_Virtual
1606 @unnumberedsec Pragma CPP_Virtual
1607 @cindex Interfacing to C++
1610 This pragma is now obsolete has has no effect because GNAT generates
1611 the same object layout than the G++ compiler.
1613 See @ref{Interfacing to C++} for related information.
1615 @node Pragma CPP_Vtable
1616 @unnumberedsec Pragma CPP_Vtable
1617 @cindex Interfacing with C++
1620 This pragma is now obsolete has has no effect because GNAT generates
1621 the same object layout than the G++ compiler.
1623 See @ref{Interfacing to C++} for related information.
1626 @unnumberedsec Pragma Debug
1631 @smallexample @c ada
1632 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1634 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1636 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1640 The procedure call argument has the syntactic form of an expression, meeting
1641 the syntactic requirements for pragmas.
1643 If debug pragmas are not enabled or if the condition is present and evaluates
1644 to False, this pragma has no effect. If debug pragmas are enabled, the
1645 semantics of the pragma is exactly equivalent to the procedure call statement
1646 corresponding to the argument with a terminating semicolon. Pragmas are
1647 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1648 intersperse calls to debug procedures in the middle of declarations. Debug
1649 pragmas can be enabled either by use of the command line switch @option{-gnata}
1650 or by use of the configuration pragma @code{Debug_Policy}.
1652 @node Pragma Debug_Policy
1653 @unnumberedsec Pragma Debug_Policy
1654 @findex Debug_Policy
1658 @smallexample @c ada
1659 pragma Debug_Policy (CHECK | IGNORE);
1663 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1664 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1665 This pragma overrides the effect of the @option{-gnata} switch on the
1668 @node Pragma Detect_Blocking
1669 @unnumberedsec Pragma Detect_Blocking
1670 @findex Detect_Blocking
1674 @smallexample @c ada
1675 pragma Detect_Blocking;
1679 This is a configuration pragma that forces the detection of potentially
1680 blocking operations within a protected operation, and to raise Program_Error
1683 @node Pragma Elaboration_Checks
1684 @unnumberedsec Pragma Elaboration_Checks
1685 @cindex Elaboration control
1686 @findex Elaboration_Checks
1690 @smallexample @c ada
1691 pragma Elaboration_Checks (Dynamic | Static);
1695 This is a configuration pragma that provides control over the
1696 elaboration model used by the compilation affected by the
1697 pragma. If the parameter is @code{Dynamic},
1698 then the dynamic elaboration
1699 model described in the Ada Reference Manual is used, as though
1700 the @option{-gnatE} switch had been specified on the command
1701 line. If the parameter is @code{Static}, then the default GNAT static
1702 model is used. This configuration pragma overrides the setting
1703 of the command line. For full details on the elaboration models
1704 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1705 gnat_ugn, @value{EDITION} User's Guide}.
1707 @node Pragma Eliminate
1708 @unnumberedsec Pragma Eliminate
1709 @cindex Elimination of unused subprograms
1714 @smallexample @c ada
1716 [Unit_Name =>] IDENTIFIER |
1717 SELECTED_COMPONENT);
1720 [Unit_Name =>] IDENTIFIER |
1722 [Entity =>] IDENTIFIER |
1723 SELECTED_COMPONENT |
1725 [,OVERLOADING_RESOLUTION]);
1727 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1730 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1733 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1735 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1736 Result_Type => result_SUBTYPE_NAME]
1738 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1739 SUBTYPE_NAME ::= STRING_VALUE
1741 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1742 SOURCE_TRACE ::= STRING_VALUE
1744 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1748 This pragma indicates that the given entity is not used outside the
1749 compilation unit it is defined in. The entity must be an explicitly declared
1750 subprogram; this includes generic subprogram instances and
1751 subprograms declared in generic package instances.
1753 If the entity to be eliminated is a library level subprogram, then
1754 the first form of pragma @code{Eliminate} is used with only a single argument.
1755 In this form, the @code{Unit_Name} argument specifies the name of the
1756 library level unit to be eliminated.
1758 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1759 are required. If item is an entity of a library package, then the first
1760 argument specifies the unit name, and the second argument specifies
1761 the particular entity. If the second argument is in string form, it must
1762 correspond to the internal manner in which GNAT stores entity names (see
1763 compilation unit Namet in the compiler sources for details).
1765 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1766 to distinguish between overloaded subprograms. If a pragma does not contain
1767 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1768 subprograms denoted by the first two parameters.
1770 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1771 to be eliminated in a manner similar to that used for the extended
1772 @code{Import} and @code{Export} pragmas, except that the subtype names are
1773 always given as strings. At the moment, this form of distinguishing
1774 overloaded subprograms is implemented only partially, so we do not recommend
1775 using it for practical subprogram elimination.
1777 Note that in case of a parameterless procedure its profile is represented
1778 as @code{Parameter_Types => ("")}
1780 Alternatively, the @code{Source_Location} parameter is used to specify
1781 which overloaded alternative is to be eliminated by pointing to the
1782 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1783 source text. The string literal (or concatenation of string literals)
1784 given as SOURCE_TRACE must have the following format:
1786 @smallexample @c ada
1787 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1792 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1793 FILE_NAME ::= STRING_LITERAL
1794 LINE_NUMBER ::= DIGIT @{DIGIT@}
1797 SOURCE_TRACE should be the short name of the source file (with no directory
1798 information), and LINE_NUMBER is supposed to point to the line where the
1799 defining name of the subprogram is located.
1801 For the subprograms that are not a part of generic instantiations, only one
1802 SOURCE_LOCATION is used. If a subprogram is declared in a package
1803 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1804 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1805 second one denotes the declaration of the corresponding subprogram in the
1806 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1807 in case of nested instantiations.
1809 The effect of the pragma is to allow the compiler to eliminate
1810 the code or data associated with the named entity. Any reference to
1811 an eliminated entity outside the compilation unit it is defined in,
1812 causes a compile time or link time error.
1814 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1815 in a system independent manner, with unused entities eliminated, without
1816 the requirement of modifying the source text. Normally the required set
1817 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1818 tool. Elimination of unused entities local to a compilation unit is
1819 automatic, without requiring the use of pragma @code{Eliminate}.
1821 Note that the reason this pragma takes string literals where names might
1822 be expected is that a pragma @code{Eliminate} can appear in a context where the
1823 relevant names are not visible.
1825 Note that any change in the source files that includes removing, splitting of
1826 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1829 It is legal to use pragma Eliminate where the referenced entity is a
1830 dispatching operation, but it is not clear what this would mean, since
1831 in general the call does not know which entity is actually being called.
1832 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1834 @node Pragma Export_Exception
1835 @unnumberedsec Pragma Export_Exception
1837 @findex Export_Exception
1841 @smallexample @c ada
1842 pragma Export_Exception (
1843 [Internal =>] LOCAL_NAME
1844 [, [External =>] EXTERNAL_SYMBOL]
1845 [, [Form =>] Ada | VMS]
1846 [, [Code =>] static_integer_EXPRESSION]);
1850 | static_string_EXPRESSION
1854 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1855 causes the specified exception to be propagated outside of the Ada program,
1856 so that it can be handled by programs written in other OpenVMS languages.
1857 This pragma establishes an external name for an Ada exception and makes the
1858 name available to the OpenVMS Linker as a global symbol. For further details
1859 on this pragma, see the
1860 DEC Ada Language Reference Manual, section 13.9a3.2.
1862 @node Pragma Export_Function
1863 @unnumberedsec Pragma Export_Function
1864 @cindex Argument passing mechanisms
1865 @findex Export_Function
1870 @smallexample @c ada
1871 pragma Export_Function (
1872 [Internal =>] LOCAL_NAME
1873 [, [External =>] EXTERNAL_SYMBOL]
1874 [, [Parameter_Types =>] PARAMETER_TYPES]
1875 [, [Result_Type =>] result_SUBTYPE_MARK]
1876 [, [Mechanism =>] MECHANISM]
1877 [, [Result_Mechanism =>] MECHANISM_NAME]);
1881 | static_string_EXPRESSION
1886 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1890 | subtype_Name ' Access
1894 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1896 MECHANISM_ASSOCIATION ::=
1897 [formal_parameter_NAME =>] MECHANISM_NAME
1902 | Descriptor [([Class =>] CLASS_NAME)]
1903 | Short_Descriptor [([Class =>] CLASS_NAME)]
1905 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1909 Use this pragma to make a function externally callable and optionally
1910 provide information on mechanisms to be used for passing parameter and
1911 result values. We recommend, for the purposes of improving portability,
1912 this pragma always be used in conjunction with a separate pragma
1913 @code{Export}, which must precede the pragma @code{Export_Function}.
1914 GNAT does not require a separate pragma @code{Export}, but if none is
1915 present, @code{Convention Ada} is assumed, which is usually
1916 not what is wanted, so it is usually appropriate to use this
1917 pragma in conjunction with a @code{Export} or @code{Convention}
1918 pragma that specifies the desired foreign convention.
1919 Pragma @code{Export_Function}
1920 (and @code{Export}, if present) must appear in the same declarative
1921 region as the function to which they apply.
1923 @var{internal_name} must uniquely designate the function to which the
1924 pragma applies. If more than one function name exists of this name in
1925 the declarative part you must use the @code{Parameter_Types} and
1926 @code{Result_Type} parameters is mandatory to achieve the required
1927 unique designation. @var{subtype_mark}s in these parameters must
1928 exactly match the subtypes in the corresponding function specification,
1929 using positional notation to match parameters with subtype marks.
1930 The form with an @code{'Access} attribute can be used to match an
1931 anonymous access parameter.
1934 @cindex Passing by descriptor
1935 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1936 The default behavior for Export_Function is to accept either 64bit or
1937 32bit descriptors unless short_descriptor is specified, then only 32bit
1938 descriptors are accepted.
1940 @cindex Suppressing external name
1941 Special treatment is given if the EXTERNAL is an explicit null
1942 string or a static string expressions that evaluates to the null
1943 string. In this case, no external name is generated. This form
1944 still allows the specification of parameter mechanisms.
1946 @node Pragma Export_Object
1947 @unnumberedsec Pragma Export_Object
1948 @findex Export_Object
1952 @smallexample @c ada
1953 pragma Export_Object
1954 [Internal =>] LOCAL_NAME
1955 [, [External =>] EXTERNAL_SYMBOL]
1956 [, [Size =>] EXTERNAL_SYMBOL]
1960 | static_string_EXPRESSION
1964 This pragma designates an object as exported, and apart from the
1965 extended rules for external symbols, is identical in effect to the use of
1966 the normal @code{Export} pragma applied to an object. You may use a
1967 separate Export pragma (and you probably should from the point of view
1968 of portability), but it is not required. @var{Size} is syntax checked,
1969 but otherwise ignored by GNAT@.
1971 @node Pragma Export_Procedure
1972 @unnumberedsec Pragma Export_Procedure
1973 @findex Export_Procedure
1977 @smallexample @c ada
1978 pragma Export_Procedure (
1979 [Internal =>] LOCAL_NAME
1980 [, [External =>] EXTERNAL_SYMBOL]
1981 [, [Parameter_Types =>] PARAMETER_TYPES]
1982 [, [Mechanism =>] MECHANISM]);
1986 | static_string_EXPRESSION
1991 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1995 | subtype_Name ' Access
1999 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2001 MECHANISM_ASSOCIATION ::=
2002 [formal_parameter_NAME =>] MECHANISM_NAME
2007 | Descriptor [([Class =>] CLASS_NAME)]
2008 | Short_Descriptor [([Class =>] CLASS_NAME)]
2010 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2014 This pragma is identical to @code{Export_Function} except that it
2015 applies to a procedure rather than a function and the parameters
2016 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2017 GNAT does not require a separate pragma @code{Export}, but if none is
2018 present, @code{Convention Ada} is assumed, which is usually
2019 not what is wanted, so it is usually appropriate to use this
2020 pragma in conjunction with a @code{Export} or @code{Convention}
2021 pragma that specifies the desired foreign convention.
2024 @cindex Passing by descriptor
2025 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2026 The default behavior for Export_Procedure is to accept either 64bit or
2027 32bit descriptors unless short_descriptor is specified, then only 32bit
2028 descriptors are accepted.
2030 @cindex Suppressing external name
2031 Special treatment is given if the EXTERNAL is an explicit null
2032 string or a static string expressions that evaluates to the null
2033 string. In this case, no external name is generated. This form
2034 still allows the specification of parameter mechanisms.
2036 @node Pragma Export_Value
2037 @unnumberedsec Pragma Export_Value
2038 @findex Export_Value
2042 @smallexample @c ada
2043 pragma Export_Value (
2044 [Value =>] static_integer_EXPRESSION,
2045 [Link_Name =>] static_string_EXPRESSION);
2049 This pragma serves to export a static integer value for external use.
2050 The first argument specifies the value to be exported. The Link_Name
2051 argument specifies the symbolic name to be associated with the integer
2052 value. This pragma is useful for defining a named static value in Ada
2053 that can be referenced in assembly language units to be linked with
2054 the application. This pragma is currently supported only for the
2055 AAMP target and is ignored for other targets.
2057 @node Pragma Export_Valued_Procedure
2058 @unnumberedsec Pragma Export_Valued_Procedure
2059 @findex Export_Valued_Procedure
2063 @smallexample @c ada
2064 pragma Export_Valued_Procedure (
2065 [Internal =>] LOCAL_NAME
2066 [, [External =>] EXTERNAL_SYMBOL]
2067 [, [Parameter_Types =>] PARAMETER_TYPES]
2068 [, [Mechanism =>] MECHANISM]);
2072 | static_string_EXPRESSION
2077 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2081 | subtype_Name ' Access
2085 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2087 MECHANISM_ASSOCIATION ::=
2088 [formal_parameter_NAME =>] MECHANISM_NAME
2093 | Descriptor [([Class =>] CLASS_NAME)]
2094 | Short_Descriptor [([Class =>] CLASS_NAME)]
2096 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2100 This pragma is identical to @code{Export_Procedure} except that the
2101 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2102 mode @code{OUT}, and externally the subprogram is treated as a function
2103 with this parameter as the result of the function. GNAT provides for
2104 this capability to allow the use of @code{OUT} and @code{IN OUT}
2105 parameters in interfacing to external functions (which are not permitted
2107 GNAT does not require a separate pragma @code{Export}, but if none is
2108 present, @code{Convention Ada} is assumed, which is almost certainly
2109 not what is wanted since the whole point of this pragma is to interface
2110 with foreign language functions, so it is usually appropriate to use this
2111 pragma in conjunction with a @code{Export} or @code{Convention}
2112 pragma that specifies the desired foreign convention.
2115 @cindex Passing by descriptor
2116 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2117 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2118 32bit descriptors unless short_descriptor is specified, then only 32bit
2119 descriptors are accepted.
2121 @cindex Suppressing external name
2122 Special treatment is given if the EXTERNAL is an explicit null
2123 string or a static string expressions that evaluates to the null
2124 string. In this case, no external name is generated. This form
2125 still allows the specification of parameter mechanisms.
2127 @node Pragma Extend_System
2128 @unnumberedsec Pragma Extend_System
2129 @cindex @code{system}, extending
2131 @findex Extend_System
2135 @smallexample @c ada
2136 pragma Extend_System ([Name =>] IDENTIFIER);
2140 This pragma is used to provide backwards compatibility with other
2141 implementations that extend the facilities of package @code{System}. In
2142 GNAT, @code{System} contains only the definitions that are present in
2143 the Ada RM@. However, other implementations, notably the DEC Ada 83
2144 implementation, provide many extensions to package @code{System}.
2146 For each such implementation accommodated by this pragma, GNAT provides a
2147 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2148 implementation, which provides the required additional definitions. You
2149 can use this package in two ways. You can @code{with} it in the normal
2150 way and access entities either by selection or using a @code{use}
2151 clause. In this case no special processing is required.
2153 However, if existing code contains references such as
2154 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2155 definitions provided in package @code{System}, you may use this pragma
2156 to extend visibility in @code{System} in a non-standard way that
2157 provides greater compatibility with the existing code. Pragma
2158 @code{Extend_System} is a configuration pragma whose single argument is
2159 the name of the package containing the extended definition
2160 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2161 control of this pragma will be processed using special visibility
2162 processing that looks in package @code{System.Aux_@var{xxx}} where
2163 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2164 package @code{System}, but not found in package @code{System}.
2166 You can use this pragma either to access a predefined @code{System}
2167 extension supplied with the compiler, for example @code{Aux_DEC} or
2168 you can construct your own extension unit following the above
2169 definition. Note that such a package is a child of @code{System}
2170 and thus is considered part of the implementation. To compile
2171 it you will have to use the appropriate switch for compiling
2172 system units. @xref{Top, @value{EDITION} User's Guide, About This
2173 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2175 @node Pragma External
2176 @unnumberedsec Pragma External
2181 @smallexample @c ada
2183 [ Convention =>] convention_IDENTIFIER,
2184 [ Entity =>] LOCAL_NAME
2185 [, [External_Name =>] static_string_EXPRESSION ]
2186 [, [Link_Name =>] static_string_EXPRESSION ]);
2190 This pragma is identical in syntax and semantics to pragma
2191 @code{Export} as defined in the Ada Reference Manual. It is
2192 provided for compatibility with some Ada 83 compilers that
2193 used this pragma for exactly the same purposes as pragma
2194 @code{Export} before the latter was standardized.
2196 @node Pragma External_Name_Casing
2197 @unnumberedsec Pragma External_Name_Casing
2198 @cindex Dec Ada 83 casing compatibility
2199 @cindex External Names, casing
2200 @cindex Casing of External names
2201 @findex External_Name_Casing
2205 @smallexample @c ada
2206 pragma External_Name_Casing (
2207 Uppercase | Lowercase
2208 [, Uppercase | Lowercase | As_Is]);
2212 This pragma provides control over the casing of external names associated
2213 with Import and Export pragmas. There are two cases to consider:
2216 @item Implicit external names
2217 Implicit external names are derived from identifiers. The most common case
2218 arises when a standard Ada Import or Export pragma is used with only two
2221 @smallexample @c ada
2222 pragma Import (C, C_Routine);
2226 Since Ada is a case-insensitive language, the spelling of the identifier in
2227 the Ada source program does not provide any information on the desired
2228 casing of the external name, and so a convention is needed. In GNAT the
2229 default treatment is that such names are converted to all lower case
2230 letters. This corresponds to the normal C style in many environments.
2231 The first argument of pragma @code{External_Name_Casing} can be used to
2232 control this treatment. If @code{Uppercase} is specified, then the name
2233 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2234 then the normal default of all lower case letters will be used.
2236 This same implicit treatment is also used in the case of extended DEC Ada 83
2237 compatible Import and Export pragmas where an external name is explicitly
2238 specified using an identifier rather than a string.
2240 @item Explicit external names
2241 Explicit external names are given as string literals. The most common case
2242 arises when a standard Ada Import or Export pragma is used with three
2245 @smallexample @c ada
2246 pragma Import (C, C_Routine, "C_routine");
2250 In this case, the string literal normally provides the exact casing required
2251 for the external name. The second argument of pragma
2252 @code{External_Name_Casing} may be used to modify this behavior.
2253 If @code{Uppercase} is specified, then the name
2254 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2255 then the name will be forced to all lowercase letters. A specification of
2256 @code{As_Is} provides the normal default behavior in which the casing is
2257 taken from the string provided.
2261 This pragma may appear anywhere that a pragma is valid. In particular, it
2262 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2263 case it applies to all subsequent compilations, or it can be used as a program
2264 unit pragma, in which case it only applies to the current unit, or it can
2265 be used more locally to control individual Import/Export pragmas.
2267 It is primarily intended for use with OpenVMS systems, where many
2268 compilers convert all symbols to upper case by default. For interfacing to
2269 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2272 @smallexample @c ada
2273 pragma External_Name_Casing (Uppercase, Uppercase);
2277 to enforce the upper casing of all external symbols.
2279 @node Pragma Fast_Math
2280 @unnumberedsec Pragma Fast_Math
2285 @smallexample @c ada
2290 This is a configuration pragma which activates a mode in which speed is
2291 considered more important for floating-point operations than absolutely
2292 accurate adherence to the requirements of the standard. Currently the
2293 following operations are affected:
2296 @item Complex Multiplication
2297 The normal simple formula for complex multiplication can result in intermediate
2298 overflows for numbers near the end of the range. The Ada standard requires that
2299 this situation be detected and corrected by scaling, but in Fast_Math mode such
2300 cases will simply result in overflow. Note that to take advantage of this you
2301 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2302 under control of the pragma, rather than use the preinstantiated versions.
2305 @node Pragma Favor_Top_Level
2306 @unnumberedsec Pragma Favor_Top_Level
2307 @findex Favor_Top_Level
2311 @smallexample @c ada
2312 pragma Favor_Top_Level (type_NAME);
2316 The named type must be an access-to-subprogram type. This pragma is an
2317 efficiency hint to the compiler, regarding the use of 'Access or
2318 'Unrestricted_Access on nested (non-library-level) subprograms. The
2319 pragma means that nested subprograms are not used with this type, or
2320 are rare, so that the generated code should be efficient in the
2321 top-level case. When this pragma is used, dynamically generated
2322 trampolines may be used on some targets for nested subprograms.
2323 See also the No_Implicit_Dynamic_Code restriction.
2325 @node Pragma Finalize_Storage_Only
2326 @unnumberedsec Pragma Finalize_Storage_Only
2327 @findex Finalize_Storage_Only
2331 @smallexample @c ada
2332 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2336 This pragma allows the compiler not to emit a Finalize call for objects
2337 defined at the library level. This is mostly useful for types where
2338 finalization is only used to deal with storage reclamation since in most
2339 environments it is not necessary to reclaim memory just before terminating
2340 execution, hence the name.
2342 @node Pragma Float_Representation
2343 @unnumberedsec Pragma Float_Representation
2345 @findex Float_Representation
2349 @smallexample @c ada
2350 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2352 FLOAT_REP ::= VAX_Float | IEEE_Float
2356 In the one argument form, this pragma is a configuration pragma which
2357 allows control over the internal representation chosen for the predefined
2358 floating point types declared in the packages @code{Standard} and
2359 @code{System}. On all systems other than OpenVMS, the argument must
2360 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2361 argument may be @code{VAX_Float} to specify the use of the VAX float
2362 format for the floating-point types in Standard. This requires that
2363 the standard runtime libraries be recompiled. @xref{The GNAT Run-Time
2364 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2365 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2367 The two argument form specifies the representation to be used for
2368 the specified floating-point type. On all systems other than OpenVMS,
2370 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2371 argument may be @code{VAX_Float} to specify the use of the VAX float
2376 For digits values up to 6, F float format will be used.
2378 For digits values from 7 to 9, G float format will be used.
2380 For digits values from 10 to 15, F float format will be used.
2382 Digits values above 15 are not allowed.
2386 @unnumberedsec Pragma Ident
2391 @smallexample @c ada
2392 pragma Ident (static_string_EXPRESSION);
2396 This pragma provides a string identification in the generated object file,
2397 if the system supports the concept of this kind of identification string.
2398 This pragma is allowed only in the outermost declarative part or
2399 declarative items of a compilation unit. If more than one @code{Ident}
2400 pragma is given, only the last one processed is effective.
2402 On OpenVMS systems, the effect of the pragma is identical to the effect of
2403 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2404 maximum allowed length is 31 characters, so if it is important to
2405 maintain compatibility with this compiler, you should obey this length
2408 @node Pragma Implemented_By_Entry
2409 @unnumberedsec Pragma Implemented_By_Entry
2410 @findex Implemented_By_Entry
2414 @smallexample @c ada
2415 pragma Implemented_By_Entry (LOCAL_NAME);
2419 This is a representation pragma which applies to protected, synchronized and
2420 task interface primitives. If the pragma is applied to primitive operation Op
2421 of interface Iface, it is illegal to override Op in a type that implements
2422 Iface, with anything other than an entry.
2424 @smallexample @c ada
2425 type Iface is protected interface;
2426 procedure Do_Something (Object : in out Iface) is abstract;
2427 pragma Implemented_By_Entry (Do_Something);
2429 protected type P is new Iface with
2430 procedure Do_Something; -- Illegal
2433 task type T is new Iface with
2434 entry Do_Something; -- Legal
2439 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2440 is intended to be used in conjunction with dispatching requeue statements as
2441 described in AI05-0030. Should the ARG decide on an official name and syntax,
2442 this pragma will become language-defined rather than GNAT-specific.
2444 @node Pragma Implicit_Packing
2445 @unnumberedsec Pragma Implicit_Packing
2446 @findex Implicit_Packing
2450 @smallexample @c ada
2451 pragma Implicit_Packing;
2455 This is a configuration pragma that requests implicit packing for packed
2456 arrays for which a size clause is given but no explicit pragma Pack or
2457 specification of Component_Size is present. It also applies to records
2458 where no record representation clause is present. Consider this example:
2460 @smallexample @c ada
2461 type R is array (0 .. 7) of Boolean;
2466 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2467 does not change the layout of a composite object. So the Size clause in the
2468 above example is normally rejected, since the default layout of the array uses
2469 8-bit components, and thus the array requires a minimum of 64 bits.
2471 If this declaration is compiled in a region of code covered by an occurrence
2472 of the configuration pragma Implicit_Packing, then the Size clause in this
2473 and similar examples will cause implicit packing and thus be accepted. For
2474 this implicit packing to occur, the type in question must be an array of small
2475 components whose size is known at compile time, and the Size clause must
2476 specify the exact size that corresponds to the length of the array multiplied
2477 by the size in bits of the component type.
2478 @cindex Array packing
2480 Similarly, the following example shows the use in the record case
2482 @smallexample @c ada
2484 a, b, c, d, e, f, g, h : boolean;
2491 Without a pragma Pack, each Boolean field requires 8 bits, so the
2492 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2493 sufficient. The use of pragma Implciit_Packing allows this record
2494 declaration to compile without an explicit pragma Pack.
2495 @node Pragma Import_Exception
2496 @unnumberedsec Pragma Import_Exception
2498 @findex Import_Exception
2502 @smallexample @c ada
2503 pragma Import_Exception (
2504 [Internal =>] LOCAL_NAME
2505 [, [External =>] EXTERNAL_SYMBOL]
2506 [, [Form =>] Ada | VMS]
2507 [, [Code =>] static_integer_EXPRESSION]);
2511 | static_string_EXPRESSION
2515 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2516 It allows OpenVMS conditions (for example, from OpenVMS system services or
2517 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2518 The pragma specifies that the exception associated with an exception
2519 declaration in an Ada program be defined externally (in non-Ada code).
2520 For further details on this pragma, see the
2521 DEC Ada Language Reference Manual, section 13.9a.3.1.
2523 @node Pragma Import_Function
2524 @unnumberedsec Pragma Import_Function
2525 @findex Import_Function
2529 @smallexample @c ada
2530 pragma Import_Function (
2531 [Internal =>] LOCAL_NAME,
2532 [, [External =>] EXTERNAL_SYMBOL]
2533 [, [Parameter_Types =>] PARAMETER_TYPES]
2534 [, [Result_Type =>] SUBTYPE_MARK]
2535 [, [Mechanism =>] MECHANISM]
2536 [, [Result_Mechanism =>] MECHANISM_NAME]
2537 [, [First_Optional_Parameter =>] IDENTIFIER]);
2541 | static_string_EXPRESSION
2545 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2549 | subtype_Name ' Access
2553 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2555 MECHANISM_ASSOCIATION ::=
2556 [formal_parameter_NAME =>] MECHANISM_NAME
2561 | Descriptor [([Class =>] CLASS_NAME)]
2562 | Short_Descriptor [([Class =>] CLASS_NAME)]
2564 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2568 This pragma is used in conjunction with a pragma @code{Import} to
2569 specify additional information for an imported function. The pragma
2570 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2571 @code{Import_Function} pragma and both must appear in the same
2572 declarative part as the function specification.
2574 The @var{Internal} argument must uniquely designate
2575 the function to which the
2576 pragma applies. If more than one function name exists of this name in
2577 the declarative part you must use the @code{Parameter_Types} and
2578 @var{Result_Type} parameters to achieve the required unique
2579 designation. Subtype marks in these parameters must exactly match the
2580 subtypes in the corresponding function specification, using positional
2581 notation to match parameters with subtype marks.
2582 The form with an @code{'Access} attribute can be used to match an
2583 anonymous access parameter.
2585 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2586 parameters to specify passing mechanisms for the
2587 parameters and result. If you specify a single mechanism name, it
2588 applies to all parameters. Otherwise you may specify a mechanism on a
2589 parameter by parameter basis using either positional or named
2590 notation. If the mechanism is not specified, the default mechanism
2594 @cindex Passing by descriptor
2595 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2596 The default behavior for Import_Function is to pass a 64bit descriptor
2597 unless short_descriptor is specified, then a 32bit descriptor is passed.
2599 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2600 It specifies that the designated parameter and all following parameters
2601 are optional, meaning that they are not passed at the generated code
2602 level (this is distinct from the notion of optional parameters in Ada
2603 where the parameters are passed anyway with the designated optional
2604 parameters). All optional parameters must be of mode @code{IN} and have
2605 default parameter values that are either known at compile time
2606 expressions, or uses of the @code{'Null_Parameter} attribute.
2608 @node Pragma Import_Object
2609 @unnumberedsec Pragma Import_Object
2610 @findex Import_Object
2614 @smallexample @c ada
2615 pragma Import_Object
2616 [Internal =>] LOCAL_NAME
2617 [, [External =>] EXTERNAL_SYMBOL]
2618 [, [Size =>] EXTERNAL_SYMBOL]);
2622 | static_string_EXPRESSION
2626 This pragma designates an object as imported, and apart from the
2627 extended rules for external symbols, is identical in effect to the use of
2628 the normal @code{Import} pragma applied to an object. Unlike the
2629 subprogram case, you need not use a separate @code{Import} pragma,
2630 although you may do so (and probably should do so from a portability
2631 point of view). @var{size} is syntax checked, but otherwise ignored by
2634 @node Pragma Import_Procedure
2635 @unnumberedsec Pragma Import_Procedure
2636 @findex Import_Procedure
2640 @smallexample @c ada
2641 pragma Import_Procedure (
2642 [Internal =>] LOCAL_NAME
2643 [, [External =>] EXTERNAL_SYMBOL]
2644 [, [Parameter_Types =>] PARAMETER_TYPES]
2645 [, [Mechanism =>] MECHANISM]
2646 [, [First_Optional_Parameter =>] IDENTIFIER]);
2650 | static_string_EXPRESSION
2654 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2658 | subtype_Name ' Access
2662 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2664 MECHANISM_ASSOCIATION ::=
2665 [formal_parameter_NAME =>] MECHANISM_NAME
2670 | Descriptor [([Class =>] CLASS_NAME)]
2671 | Short_Descriptor [([Class =>] CLASS_NAME)]
2673 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2677 This pragma is identical to @code{Import_Function} except that it
2678 applies to a procedure rather than a function and the parameters
2679 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2681 @node Pragma Import_Valued_Procedure
2682 @unnumberedsec Pragma Import_Valued_Procedure
2683 @findex Import_Valued_Procedure
2687 @smallexample @c ada
2688 pragma Import_Valued_Procedure (
2689 [Internal =>] LOCAL_NAME
2690 [, [External =>] EXTERNAL_SYMBOL]
2691 [, [Parameter_Types =>] PARAMETER_TYPES]
2692 [, [Mechanism =>] MECHANISM]
2693 [, [First_Optional_Parameter =>] IDENTIFIER]);
2697 | static_string_EXPRESSION
2701 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2705 | subtype_Name ' Access
2709 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2711 MECHANISM_ASSOCIATION ::=
2712 [formal_parameter_NAME =>] MECHANISM_NAME
2717 | Descriptor [([Class =>] CLASS_NAME)]
2718 | Short_Descriptor [([Class =>] CLASS_NAME)]
2720 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2724 This pragma is identical to @code{Import_Procedure} except that the
2725 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2726 mode @code{OUT}, and externally the subprogram is treated as a function
2727 with this parameter as the result of the function. The purpose of this
2728 capability is to allow the use of @code{OUT} and @code{IN OUT}
2729 parameters in interfacing to external functions (which are not permitted
2730 in Ada functions). You may optionally use the @code{Mechanism}
2731 parameters to specify passing mechanisms for the parameters.
2732 If you specify a single mechanism name, it applies to all parameters.
2733 Otherwise you may specify a mechanism on a parameter by parameter
2734 basis using either positional or named notation. If the mechanism is not
2735 specified, the default mechanism is used.
2737 Note that it is important to use this pragma in conjunction with a separate
2738 pragma Import that specifies the desired convention, since otherwise the
2739 default convention is Ada, which is almost certainly not what is required.
2741 @node Pragma Initialize_Scalars
2742 @unnumberedsec Pragma Initialize_Scalars
2743 @findex Initialize_Scalars
2744 @cindex debugging with Initialize_Scalars
2748 @smallexample @c ada
2749 pragma Initialize_Scalars;
2753 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2754 two important differences. First, there is no requirement for the pragma
2755 to be used uniformly in all units of a partition, in particular, it is fine
2756 to use this just for some or all of the application units of a partition,
2757 without needing to recompile the run-time library.
2759 In the case where some units are compiled with the pragma, and some without,
2760 then a declaration of a variable where the type is defined in package
2761 Standard or is locally declared will always be subject to initialization,
2762 as will any declaration of a scalar variable. For composite variables,
2763 whether the variable is initialized may also depend on whether the package
2764 in which the type of the variable is declared is compiled with the pragma.
2766 The other important difference is that you can control the value used
2767 for initializing scalar objects. At bind time, you can select several
2768 options for initialization. You can
2769 initialize with invalid values (similar to Normalize_Scalars, though for
2770 Initialize_Scalars it is not always possible to determine the invalid
2771 values in complex cases like signed component fields with non-standard
2772 sizes). You can also initialize with high or
2773 low values, or with a specified bit pattern. See the users guide for binder
2774 options for specifying these cases.
2776 This means that you can compile a program, and then without having to
2777 recompile the program, you can run it with different values being used
2778 for initializing otherwise uninitialized values, to test if your program
2779 behavior depends on the choice. Of course the behavior should not change,
2780 and if it does, then most likely you have an erroneous reference to an
2781 uninitialized value.
2783 It is even possible to change the value at execution time eliminating even
2784 the need to rebind with a different switch using an environment variable.
2785 See the GNAT users guide for details.
2787 Note that pragma @code{Initialize_Scalars} is particularly useful in
2788 conjunction with the enhanced validity checking that is now provided
2789 in GNAT, which checks for invalid values under more conditions.
2790 Using this feature (see description of the @option{-gnatV} flag in the
2791 users guide) in conjunction with pragma @code{Initialize_Scalars}
2792 provides a powerful new tool to assist in the detection of problems
2793 caused by uninitialized variables.
2795 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2796 effect on the generated code. This may cause your code to be
2797 substantially larger. It may also cause an increase in the amount
2798 of stack required, so it is probably a good idea to turn on stack
2799 checking (see description of stack checking in the GNAT users guide)
2800 when using this pragma.
2802 @node Pragma Inline_Always
2803 @unnumberedsec Pragma Inline_Always
2804 @findex Inline_Always
2808 @smallexample @c ada
2809 pragma Inline_Always (NAME [, NAME]);
2813 Similar to pragma @code{Inline} except that inlining is not subject to
2814 the use of option @option{-gnatn} and the inlining happens regardless of
2815 whether this option is used.
2817 @node Pragma Inline_Generic
2818 @unnumberedsec Pragma Inline_Generic
2819 @findex Inline_Generic
2823 @smallexample @c ada
2824 pragma Inline_Generic (generic_package_NAME);
2828 This is implemented for compatibility with DEC Ada 83 and is recognized,
2829 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2830 by default when using GNAT@.
2832 @node Pragma Interface
2833 @unnumberedsec Pragma Interface
2838 @smallexample @c ada
2840 [Convention =>] convention_identifier,
2841 [Entity =>] local_NAME
2842 [, [External_Name =>] static_string_expression]
2843 [, [Link_Name =>] static_string_expression]);
2847 This pragma is identical in syntax and semantics to
2848 the standard Ada pragma @code{Import}. It is provided for compatibility
2849 with Ada 83. The definition is upwards compatible both with pragma
2850 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2851 with some extended implementations of this pragma in certain Ada 83
2852 implementations. The only difference between pragma @code{Interface}
2853 and pragma @code{Import} is that there is special circuitry to allow
2854 both pragmas to appear for the same subprogram entity (normally it
2855 is illegal to have multiple @code{Import} pragmas. This is useful in
2856 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2859 @node Pragma Interface_Name
2860 @unnumberedsec Pragma Interface_Name
2861 @findex Interface_Name
2865 @smallexample @c ada
2866 pragma Interface_Name (
2867 [Entity =>] LOCAL_NAME
2868 [, [External_Name =>] static_string_EXPRESSION]
2869 [, [Link_Name =>] static_string_EXPRESSION]);
2873 This pragma provides an alternative way of specifying the interface name
2874 for an interfaced subprogram, and is provided for compatibility with Ada
2875 83 compilers that use the pragma for this purpose. You must provide at
2876 least one of @var{External_Name} or @var{Link_Name}.
2878 @node Pragma Interrupt_Handler
2879 @unnumberedsec Pragma Interrupt_Handler
2880 @findex Interrupt_Handler
2884 @smallexample @c ada
2885 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2889 This program unit pragma is supported for parameterless protected procedures
2890 as described in Annex C of the Ada Reference Manual. On the AAMP target
2891 the pragma can also be specified for nonprotected parameterless procedures
2892 that are declared at the library level (which includes procedures
2893 declared at the top level of a library package). In the case of AAMP,
2894 when this pragma is applied to a nonprotected procedure, the instruction
2895 @code{IERET} is generated for returns from the procedure, enabling
2896 maskable interrupts, in place of the normal return instruction.
2898 @node Pragma Interrupt_State
2899 @unnumberedsec Pragma Interrupt_State
2900 @findex Interrupt_State
2904 @smallexample @c ada
2905 pragma Interrupt_State
2907 [State =>] SYSTEM | RUNTIME | USER);
2911 Normally certain interrupts are reserved to the implementation. Any attempt
2912 to attach an interrupt causes Program_Error to be raised, as described in
2913 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2914 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2915 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2916 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2917 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2918 Ada exceptions, or used to implement run-time functions such as the
2919 @code{abort} statement and stack overflow checking.
2921 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2922 such uses of interrupts. It subsumes the functionality of pragma
2923 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2924 available on OS/2, Windows or VMS. On all other platforms than VxWorks,
2925 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2926 and may be used to mark interrupts required by the board support package
2929 Interrupts can be in one of three states:
2933 The interrupt is reserved (no Ada handler can be installed), and the
2934 Ada run-time may not install a handler. As a result you are guaranteed
2935 standard system default action if this interrupt is raised.
2939 The interrupt is reserved (no Ada handler can be installed). The run time
2940 is allowed to install a handler for internal control purposes, but is
2941 not required to do so.
2945 The interrupt is unreserved. The user may install a handler to provide
2950 These states are the allowed values of the @code{State} parameter of the
2951 pragma. The @code{Name} parameter is a value of the type
2952 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
2953 @code{Ada.Interrupts.Names}.
2955 This is a configuration pragma, and the binder will check that there
2956 are no inconsistencies between different units in a partition in how a
2957 given interrupt is specified. It may appear anywhere a pragma is legal.
2959 The effect is to move the interrupt to the specified state.
2961 By declaring interrupts to be SYSTEM, you guarantee the standard system
2962 action, such as a core dump.
2964 By declaring interrupts to be USER, you guarantee that you can install
2967 Note that certain signals on many operating systems cannot be caught and
2968 handled by applications. In such cases, the pragma is ignored. See the
2969 operating system documentation, or the value of the array @code{Reserved}
2970 declared in the spec of package @code{System.OS_Interface}.
2972 Overriding the default state of signals used by the Ada runtime may interfere
2973 with an application's runtime behavior in the cases of the synchronous signals,
2974 and in the case of the signal used to implement the @code{abort} statement.
2976 @node Pragma Keep_Names
2977 @unnumberedsec Pragma Keep_Names
2982 @smallexample @c ada
2983 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2987 The @var{LOCAL_NAME} argument
2988 must refer to an enumeration first subtype
2989 in the current declarative part. The effect is to retain the enumeration
2990 literal names for use by @code{Image} and @code{Value} even if a global
2991 @code{Discard_Names} pragma applies. This is useful when you want to
2992 generally suppress enumeration literal names and for example you therefore
2993 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2994 want to retain the names for specific enumeration types.
2996 @node Pragma License
2997 @unnumberedsec Pragma License
2999 @cindex License checking
3003 @smallexample @c ada
3004 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3008 This pragma is provided to allow automated checking for appropriate license
3009 conditions with respect to the standard and modified GPL@. A pragma
3010 @code{License}, which is a configuration pragma that typically appears at
3011 the start of a source file or in a separate @file{gnat.adc} file, specifies
3012 the licensing conditions of a unit as follows:
3016 This is used for a unit that can be freely used with no license restrictions.
3017 Examples of such units are public domain units, and units from the Ada
3021 This is used for a unit that is licensed under the unmodified GPL, and which
3022 therefore cannot be @code{with}'ed by a restricted unit.
3025 This is used for a unit licensed under the GNAT modified GPL that includes
3026 a special exception paragraph that specifically permits the inclusion of
3027 the unit in programs without requiring the entire program to be released
3031 This is used for a unit that is restricted in that it is not permitted to
3032 depend on units that are licensed under the GPL@. Typical examples are
3033 proprietary code that is to be released under more restrictive license
3034 conditions. Note that restricted units are permitted to @code{with} units
3035 which are licensed under the modified GPL (this is the whole point of the
3041 Normally a unit with no @code{License} pragma is considered to have an
3042 unknown license, and no checking is done. However, standard GNAT headers
3043 are recognized, and license information is derived from them as follows.
3047 A GNAT license header starts with a line containing 78 hyphens. The following
3048 comment text is searched for the appearance of any of the following strings.
3050 If the string ``GNU General Public License'' is found, then the unit is assumed
3051 to have GPL license, unless the string ``As a special exception'' follows, in
3052 which case the license is assumed to be modified GPL@.
3054 If one of the strings
3055 ``This specification is adapted from the Ada Semantic Interface'' or
3056 ``This specification is derived from the Ada Reference Manual'' is found
3057 then the unit is assumed to be unrestricted.
3061 These default actions means that a program with a restricted license pragma
3062 will automatically get warnings if a GPL unit is inappropriately
3063 @code{with}'ed. For example, the program:
3065 @smallexample @c ada
3068 procedure Secret_Stuff is
3074 if compiled with pragma @code{License} (@code{Restricted}) in a
3075 @file{gnat.adc} file will generate the warning:
3080 >>> license of withed unit "Sem_Ch3" is incompatible
3082 2. with GNAT.Sockets;
3083 3. procedure Secret_Stuff is
3087 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3088 compiler and is licensed under the
3089 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3090 run time, and is therefore licensed under the modified GPL@.
3092 @node Pragma Link_With
3093 @unnumberedsec Pragma Link_With
3098 @smallexample @c ada
3099 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3103 This pragma is provided for compatibility with certain Ada 83 compilers.
3104 It has exactly the same effect as pragma @code{Linker_Options} except
3105 that spaces occurring within one of the string expressions are treated
3106 as separators. For example, in the following case:
3108 @smallexample @c ada
3109 pragma Link_With ("-labc -ldef");
3113 results in passing the strings @code{-labc} and @code{-ldef} as two
3114 separate arguments to the linker. In addition pragma Link_With allows
3115 multiple arguments, with the same effect as successive pragmas.
3117 @node Pragma Linker_Alias
3118 @unnumberedsec Pragma Linker_Alias
3119 @findex Linker_Alias
3123 @smallexample @c ada
3124 pragma Linker_Alias (
3125 [Entity =>] LOCAL_NAME,
3126 [Target =>] static_string_EXPRESSION);
3130 @var{LOCAL_NAME} must refer to an object that is declared at the library
3131 level. This pragma establishes the given entity as a linker alias for the
3132 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3133 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3134 @var{static_string_EXPRESSION} in the object file, that is to say no space
3135 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3136 to the same address as @var{static_string_EXPRESSION} by the linker.
3138 The actual linker name for the target must be used (e.g.@: the fully
3139 encoded name with qualification in Ada, or the mangled name in C++),
3140 or it must be declared using the C convention with @code{pragma Import}
3141 or @code{pragma Export}.
3143 Not all target machines support this pragma. On some of them it is accepted
3144 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3146 @smallexample @c ada
3147 -- Example of the use of pragma Linker_Alias
3151 pragma Export (C, i);
3153 new_name_for_i : Integer;
3154 pragma Linker_Alias (new_name_for_i, "i");
3158 @node Pragma Linker_Constructor
3159 @unnumberedsec Pragma Linker_Constructor
3160 @findex Linker_Constructor
3164 @smallexample @c ada
3165 pragma Linker_Constructor (procedure_LOCAL_NAME);
3169 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3170 is declared at the library level. A procedure to which this pragma is
3171 applied will be treated as an initialization routine by the linker.
3172 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3173 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3174 of the executable is called (or immediately after the shared library is
3175 loaded if the procedure is linked in a shared library), in particular
3176 before the Ada run-time environment is set up.
3178 Because of these specific contexts, the set of operations such a procedure
3179 can perform is very limited and the type of objects it can manipulate is
3180 essentially restricted to the elementary types. In particular, it must only
3181 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3183 This pragma is used by GNAT to implement auto-initialization of shared Stand
3184 Alone Libraries, which provides a related capability without the restrictions
3185 listed above. Where possible, the use of Stand Alone Libraries is preferable
3186 to the use of this pragma.
3188 @node Pragma Linker_Destructor
3189 @unnumberedsec Pragma Linker_Destructor
3190 @findex Linker_Destructor
3194 @smallexample @c ada
3195 pragma Linker_Destructor (procedure_LOCAL_NAME);
3199 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3200 is declared at the library level. A procedure to which this pragma is
3201 applied will be treated as a finalization routine by the linker.
3202 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3203 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3204 of the executable has exited (or immediately before the shared library
3205 is unloaded if the procedure is linked in a shared library), in particular
3206 after the Ada run-time environment is shut down.
3208 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3209 because of these specific contexts.
3211 @node Pragma Linker_Section
3212 @unnumberedsec Pragma Linker_Section
3213 @findex Linker_Section
3217 @smallexample @c ada
3218 pragma Linker_Section (
3219 [Entity =>] LOCAL_NAME,
3220 [Section =>] static_string_EXPRESSION);
3224 @var{LOCAL_NAME} must refer to an object that is declared at the library
3225 level. This pragma specifies the name of the linker section for the given
3226 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3227 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3228 section of the executable (assuming the linker doesn't rename the section).
3230 The compiler normally places library-level objects in standard sections
3231 depending on their type: procedures and functions generally go in the
3232 @code{.text} section, initialized variables in the @code{.data} section
3233 and uninitialized variables in the @code{.bss} section.
3235 Other, special sections may exist on given target machines to map special
3236 hardware, for example I/O ports or flash memory. This pragma is a means to
3237 defer the final layout of the executable to the linker, thus fully working
3238 at the symbolic level with the compiler.
3240 Some file formats do not support arbitrary sections so not all target
3241 machines support this pragma. The use of this pragma may cause a program
3242 execution to be erroneous if it is used to place an entity into an
3243 inappropriate section (e.g.@: a modified variable into the @code{.text}
3244 section). See also @code{pragma Persistent_BSS}.
3246 @smallexample @c ada
3247 -- Example of the use of pragma Linker_Section
3251 pragma Volatile (Port_A);
3252 pragma Linker_Section (Port_A, ".bss.port_a");
3255 pragma Volatile (Port_B);
3256 pragma Linker_Section (Port_B, ".bss.port_b");
3260 @node Pragma Long_Float
3261 @unnumberedsec Pragma Long_Float
3267 @smallexample @c ada
3268 pragma Long_Float (FLOAT_FORMAT);
3270 FLOAT_FORMAT ::= D_Float | G_Float
3274 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3275 It allows control over the internal representation chosen for the predefined
3276 type @code{Long_Float} and for floating point type representations with
3277 @code{digits} specified in the range 7 through 15.
3278 For further details on this pragma, see the
3279 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3280 this pragma, the standard runtime libraries must be recompiled.
3281 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3282 @value{EDITION} User's Guide OpenVMS}, for a description of the
3283 @code{GNAT LIBRARY} command.
3285 @node Pragma Machine_Attribute
3286 @unnumberedsec Pragma Machine_Attribute
3287 @findex Machine_Attribute
3291 @smallexample @c ada
3292 pragma Machine_Attribute (
3293 [Entity =>] LOCAL_NAME,
3294 [Attribute_Name =>] static_string_EXPRESSION
3295 [, [Info =>] static_EXPRESSION] );
3299 Machine-dependent attributes can be specified for types and/or
3300 declarations. This pragma is semantically equivalent to
3301 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3302 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3303 in GNU C, where @code{@var{attribute_name}} is recognized by the
3304 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3305 specific macro. A string literal for the optional parameter @var{info}
3306 is transformed into an identifier, which may make this pragma unusable
3307 for some attributes. @xref{Target Attributes,, Defining target-specific
3308 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3309 Internals}, further information.
3312 @unnumberedsec Pragma Main
3318 @smallexample @c ada
3320 (MAIN_OPTION [, MAIN_OPTION]);
3323 [Stack_Size =>] static_integer_EXPRESSION
3324 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3325 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3329 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3330 no effect in GNAT, other than being syntax checked.
3332 @node Pragma Main_Storage
3333 @unnumberedsec Pragma Main_Storage
3335 @findex Main_Storage
3339 @smallexample @c ada
3341 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3343 MAIN_STORAGE_OPTION ::=
3344 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3345 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3349 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3350 no effect in GNAT, other than being syntax checked. Note that the pragma
3351 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3353 @node Pragma No_Body
3354 @unnumberedsec Pragma No_Body
3359 @smallexample @c ada
3364 There are a number of cases in which a package spec does not require a body,
3365 and in fact a body is not permitted. GNAT will not permit the spec to be
3366 compiled if there is a body around. The pragma No_Body allows you to provide
3367 a body file, even in a case where no body is allowed. The body file must
3368 contain only comments and a single No_Body pragma. This is recognized by
3369 the compiler as indicating that no body is logically present.
3371 This is particularly useful during maintenance when a package is modified in
3372 such a way that a body needed before is no longer needed. The provision of a
3373 dummy body with a No_Body pragma ensures that there is no interference from
3374 earlier versions of the package body.
3376 @node Pragma No_Return
3377 @unnumberedsec Pragma No_Return
3382 @smallexample @c ada
3383 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3387 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3388 declarations in the current declarative part. A procedure to which this
3389 pragma is applied may not contain any explicit @code{return} statements.
3390 In addition, if the procedure contains any implicit returns from falling
3391 off the end of a statement sequence, then execution of that implicit
3392 return will cause Program_Error to be raised.
3394 One use of this pragma is to identify procedures whose only purpose is to raise
3395 an exception. Another use of this pragma is to suppress incorrect warnings
3396 about missing returns in functions, where the last statement of a function
3397 statement sequence is a call to such a procedure.
3399 Note that in Ada 2005 mode, this pragma is part of the language, and is
3400 identical in effect to the pragma as implemented in Ada 95 mode.
3402 @node Pragma No_Strict_Aliasing
3403 @unnumberedsec Pragma No_Strict_Aliasing
3404 @findex No_Strict_Aliasing
3408 @smallexample @c ada
3409 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3413 @var{type_LOCAL_NAME} must refer to an access type
3414 declaration in the current declarative part. The effect is to inhibit
3415 strict aliasing optimization for the given type. The form with no
3416 arguments is a configuration pragma which applies to all access types
3417 declared in units to which the pragma applies. For a detailed
3418 description of the strict aliasing optimization, and the situations
3419 in which it must be suppressed, see @ref{Optimization and Strict
3420 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3422 @node Pragma Normalize_Scalars
3423 @unnumberedsec Pragma Normalize_Scalars
3424 @findex Normalize_Scalars
3428 @smallexample @c ada
3429 pragma Normalize_Scalars;
3433 This is a language defined pragma which is fully implemented in GNAT@. The
3434 effect is to cause all scalar objects that are not otherwise initialized
3435 to be initialized. The initial values are implementation dependent and
3439 @item Standard.Character
3441 Objects whose root type is Standard.Character are initialized to
3442 Character'Last unless the subtype range excludes NUL (in which case
3443 NUL is used). This choice will always generate an invalid value if
3446 @item Standard.Wide_Character
3448 Objects whose root type is Standard.Wide_Character are initialized to
3449 Wide_Character'Last unless the subtype range excludes NUL (in which case
3450 NUL is used). This choice will always generate an invalid value if
3453 @item Standard.Wide_Wide_Character
3455 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3456 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3457 which case NUL is used). This choice will always generate an invalid value if
3462 Objects of an integer type are treated differently depending on whether
3463 negative values are present in the subtype. If no negative values are
3464 present, then all one bits is used as the initial value except in the
3465 special case where zero is excluded from the subtype, in which case
3466 all zero bits are used. This choice will always generate an invalid
3467 value if one exists.
3469 For subtypes with negative values present, the largest negative number
3470 is used, except in the unusual case where this largest negative number
3471 is in the subtype, and the largest positive number is not, in which case
3472 the largest positive value is used. This choice will always generate
3473 an invalid value if one exists.
3475 @item Floating-Point Types
3476 Objects of all floating-point types are initialized to all 1-bits. For
3477 standard IEEE format, this corresponds to a NaN (not a number) which is
3478 indeed an invalid value.
3480 @item Fixed-Point Types
3481 Objects of all fixed-point types are treated as described above for integers,
3482 with the rules applying to the underlying integer value used to represent
3483 the fixed-point value.
3486 Objects of a modular type are initialized to all one bits, except in
3487 the special case where zero is excluded from the subtype, in which
3488 case all zero bits are used. This choice will always generate an
3489 invalid value if one exists.
3491 @item Enumeration types
3492 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3493 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3494 whose Pos value is zero, in which case a code of zero is used. This choice
3495 will always generate an invalid value if one exists.
3499 @node Pragma Obsolescent
3500 @unnumberedsec Pragma Obsolescent
3505 @smallexample @c ada
3508 pragma Obsolescent (
3509 [Message =>] static_string_EXPRESSION
3510 [,[Version =>] Ada_05]]);
3512 pragma Obsolescent (
3514 [,[Message =>] static_string_EXPRESSION
3515 [,[Version =>] Ada_05]] );
3519 This pragma can occur immediately following a declaration of an entity,
3520 including the case of a record component. If no Entity argument is present,
3521 then this declaration is the one to which the pragma applies. If an Entity
3522 parameter is present, it must either match the name of the entity in this
3523 declaration, or alternatively, the pragma can immediately follow an enumeration
3524 type declaration, where the Entity argument names one of the enumeration
3527 This pragma is used to indicate that the named entity
3528 is considered obsolescent and should not be used. Typically this is
3529 used when an API must be modified by eventually removing or modifying
3530 existing subprograms or other entities. The pragma can be used at an
3531 intermediate stage when the entity is still present, but will be
3534 The effect of this pragma is to output a warning message on a reference to
3535 an entity thus marked that the subprogram is obsolescent if the appropriate
3536 warning option in the compiler is activated. If the Message parameter is
3537 present, then a second warning message is given containing this text. In
3538 addition, a reference to the eneity is considered to be a violation of pragma
3539 Restrictions (No_Obsolescent_Features).
3541 This pragma can also be used as a program unit pragma for a package,
3542 in which case the entity name is the name of the package, and the
3543 pragma indicates that the entire package is considered
3544 obsolescent. In this case a client @code{with}'ing such a package
3545 violates the restriction, and the @code{with} statement is
3546 flagged with warnings if the warning option is set.
3548 If the Version parameter is present (which must be exactly
3549 the identifier Ada_05, no other argument is allowed), then the
3550 indication of obsolescence applies only when compiling in Ada 2005
3551 mode. This is primarily intended for dealing with the situations
3552 in the predefined library where subprograms or packages
3553 have become defined as obsolescent in Ada 2005
3554 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3556 The following examples show typical uses of this pragma:
3558 @smallexample @c ada
3560 pragma Obsolescent (p, Message => "use pp instead of p");
3565 pragma Obsolescent ("use q2new instead");
3567 type R is new integer;
3570 Message => "use RR in Ada 2005",
3580 type E is (a, bc, 'd', quack);
3581 pragma Obsolescent (Entity => bc)
3582 pragma Obsolescent (Entity => 'd')
3585 (a, b : character) return character;
3586 pragma Obsolescent (Entity => "+");
3591 Note that, as for all pragmas, if you use a pragma argument identifier,
3592 then all subsequent parameters must also use a pragma argument identifier.
3593 So if you specify "Entity =>" for the Entity argument, and a Message
3594 argument is present, it must be preceded by "Message =>".
3596 @node Pragma Optimize_Alignment
3597 @unnumberedsec Pragma Optimize_Alignment
3598 @findex Optimize_Alignment
3599 @cindex Alignment, default settings
3603 @smallexample @c ada
3604 pragma Optimize_Alignment (TIME | SPACE | OFF);
3608 This is a configuration pragma which affects the choice of default alignments
3609 for types where no alignment is explicitly specified. There is a time/space
3610 trade-off in the selection of these values. Large alignments result in more
3611 efficient code, at the expense of larger data space, since sizes have to be
3612 increased to match these alignments. Smaller alignments save space, but the
3613 access code is slower. The normal choice of default alignments (which is what
3614 you get if you do not use this pragma, or if you use an argument of OFF),
3615 tries to balance these two requirements.
3617 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3618 First any packed record is given an alignment of 1. Second, if a size is given
3619 for the type, then the alignment is chosen to avoid increasing this size. For
3622 @smallexample @c ada
3632 In the default mode, this type gets an alignment of 4, so that access to the
3633 Integer field X are efficient. But this means that objects of the type end up
3634 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3635 allowed to be bigger than the size of the type, but it can waste space if for
3636 example fields of type R appear in an enclosing record. If the above type is
3637 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3639 Specifying TIME causes larger default alignments to be chosen in the case of
3640 small types with sizes that are not a power of 2. For example, consider:
3642 @smallexample @c ada
3654 The default alignment for this record is normally 1, but if this type is
3655 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3656 to 4, which wastes space for objects of the type, since they are now 4 bytes
3657 long, but results in more efficient access when the whole record is referenced.
3659 As noted above, this is a configuration pragma, and there is a requirement
3660 that all units in a partition be compiled with a consistent setting of the
3661 optimization setting. This would normally be achieved by use of a configuration
3662 pragma file containing the appropriate setting. The exception to this rule is
3663 that units with an explicit configuration pragma in the same file as the source
3664 unit are excluded from the consistency check, as are all predefined units. The
3665 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3666 pragma appears at the start of the file.
3668 @node Pragma Passive
3669 @unnumberedsec Pragma Passive
3674 @smallexample @c ada
3675 pragma Passive [(Semaphore | No)];
3679 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3680 compatibility with DEC Ada 83 implementations, where it is used within a
3681 task definition to request that a task be made passive. If the argument
3682 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3683 treats the pragma as an assertion that the containing task is passive
3684 and that optimization of context switch with this task is permitted and
3685 desired. If the argument @code{No} is present, the task must not be
3686 optimized. GNAT does not attempt to optimize any tasks in this manner
3687 (since protected objects are available in place of passive tasks).
3689 @node Pragma Persistent_BSS
3690 @unnumberedsec Pragma Persistent_BSS
3691 @findex Persistent_BSS
3695 @smallexample @c ada
3696 pragma Persistent_BSS [(LOCAL_NAME)]
3700 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3701 section. On some targets the linker and loader provide for special
3702 treatment of this section, allowing a program to be reloaded without
3703 affecting the contents of this data (hence the name persistent).
3705 There are two forms of usage. If an argument is given, it must be the
3706 local name of a library level object, with no explicit initialization
3707 and whose type is potentially persistent. If no argument is given, then
3708 the pragma is a configuration pragma, and applies to all library level
3709 objects with no explicit initialization of potentially persistent types.
3711 A potentially persistent type is a scalar type, or a non-tagged,
3712 non-discriminated record, all of whose components have no explicit
3713 initialization and are themselves of a potentially persistent type,
3714 or an array, all of whose constraints are static, and whose component
3715 type is potentially persistent.
3717 If this pragma is used on a target where this feature is not supported,
3718 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3720 @node Pragma Polling
3721 @unnumberedsec Pragma Polling
3726 @smallexample @c ada
3727 pragma Polling (ON | OFF);
3731 This pragma controls the generation of polling code. This is normally off.
3732 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3733 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3734 runtime library, and can be found in file @file{a-excpol.adb}.
3736 Pragma @code{Polling} can appear as a configuration pragma (for example it
3737 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3738 can be used in the statement or declaration sequence to control polling
3741 A call to the polling routine is generated at the start of every loop and
3742 at the start of every subprogram call. This guarantees that the @code{Poll}
3743 routine is called frequently, and places an upper bound (determined by
3744 the complexity of the code) on the period between two @code{Poll} calls.
3746 The primary purpose of the polling interface is to enable asynchronous
3747 aborts on targets that cannot otherwise support it (for example Windows
3748 NT), but it may be used for any other purpose requiring periodic polling.
3749 The standard version is null, and can be replaced by a user program. This
3750 will require re-compilation of the @code{Ada.Exceptions} package that can
3751 be found in files @file{a-except.ads} and @file{a-except.adb}.
3753 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3754 distribution) is used to enable the asynchronous abort capability on
3755 targets that do not normally support the capability. The version of
3756 @code{Poll} in this file makes a call to the appropriate runtime routine
3757 to test for an abort condition.
3759 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3760 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3763 @node Pragma Postcondition
3764 @unnumberedsec Pragma Postcondition
3765 @cindex Postconditions
3766 @cindex Checks, postconditions
3767 @findex Postconditions
3771 @smallexample @c ada
3772 pragma Postcondition (
3773 [Check =>] Boolean_Expression
3774 [,[Message =>] String_Expression]);
3778 The @code{Postcondition} pragma allows specification of automatic
3779 postcondition checks for subprograms. These checks are similar to
3780 assertions, but are automatically inserted just prior to the return
3781 statements of the subprogram with which they are associated (including
3782 implicit returns at the end of procedure bodies and associated
3783 exception handlers).
3785 In addition, the boolean expression which is the condition which
3786 must be true may contain references to function'Result in the case
3787 of a function to refer to the returned value.
3789 @code{Postcondition} pragmas may appear either immediate following the
3790 (separate) declaration of a subprogram, or at the start of the
3791 declarations of a subprogram body. Only other pragmas may intervene
3792 (that is appear between the subprogram declaration and its
3793 postconditions, or appear before the postcondition in the
3794 declaration sequence in a subprogram body). In the case of a
3795 postcondition appearing after a subprogram declaration, the
3796 formal arguments of the subprogram are visible, and can be
3797 referenced in the postcondition expressions.
3799 The postconditions are collected and automatically tested just
3800 before any return (implicit or explicit) in the subprogram body.
3801 A postcondition is only recognized if postconditions are active
3802 at the time the pragma is encountered. The compiler switch @option{gnata}
3803 turns on all postconditions by default, and pragma @code{Check_Policy}
3804 with an identifier of @code{Postcondition} can also be used to
3805 control whether postconditions are active.
3807 The general approach is that postconditions are placed in the spec
3808 if they represent functional aspects which make sense to the client.
3809 For example we might have:
3811 @smallexample @c ada
3812 function Direction return Integer;
3813 pragma Postcondition
3814 (Direction'Result = +1
3816 Direction'Result = -1);
3820 which serves to document that the result must be +1 or -1, and
3821 will test that this is the case at run time if postcondition
3824 Postconditions within the subprogram body can be used to
3825 check that some internal aspect of the implementation,
3826 not visible to the client, is operating as expected.
3827 For instance if a square root routine keeps an internal
3828 counter of the number of times it is called, then we
3829 might have the following postcondition:
3831 @smallexample @c ada
3832 Sqrt_Calls : Natural := 0;
3834 function Sqrt (Arg : Float) return Float is
3835 pragma Postcondition
3836 (Sqrt_Calls = Sqrt_Calls'Old + 1);
3842 As this example, shows, the use of the @code{Old} attribute
3843 is often useful in postconditions to refer to the state on
3844 entry to the subprogram.
3846 Note that postconditions are only checked on normal returns
3847 from the subprogram. If an abnormal return results from
3848 raising an exception, then the postconditions are not checked.
3850 If a postcondition fails, then the exception
3851 @code{System.Assertions.Assert_Failure} is raised. If
3852 a message argument was supplied, then the given string
3853 will be used as the exception message. If no message
3854 argument was supplied, then the default message has
3855 the form "Postcondition failed at file:line". The
3856 exception is raised in the context of the subprogram
3857 body, so it is possible to catch postcondition failures
3858 within the subprogram body itself.
3860 Within a package spec, normal visibility rules
3861 in Ada would prevent forward references within a
3862 postcondition pragma to functions defined later in
3863 the same package. This would introduce undesirable
3864 ordering constraints. To avoid this problem, all
3865 postcondition pragmas are analyzed at the end of
3866 the package spec, allowing forward references.
3868 The following example shows that this even allows
3869 mutually recursive postconditions as in:
3871 @smallexample @c ada
3872 package Parity_Functions is
3873 function Odd (X : Natural) return Boolean;
3874 pragma Postcondition
3878 (x /= 0 and then Even (X - 1))));
3880 function Even (X : Natural) return Boolean;
3881 pragma Postcondition
3885 (x /= 1 and then Odd (X - 1))));
3887 end Parity_Functions;
3891 There are no restrictions on the complexity or form of
3892 conditions used within @code{Postcondition} pragmas.
3893 The following example shows that it is even possible
3894 to verify performance behavior.
3896 @smallexample @c ada
3899 Performance : constant Float;
3900 -- Performance constant set by implementation
3901 -- to match target architecture behavior.
3903 procedure Treesort (Arg : String);
3904 -- Sorts characters of argument using N*logN sort
3905 pragma Postcondition
3906 (Float (Clock - Clock'Old) <=
3907 Float (Arg'Length) *
3908 log (Float (Arg'Length)) *
3914 Note: postcondition pragmas associated with subprograms that are
3915 marked as Inline_Always, or those marked as Inline with front-end
3916 inlining (-gnatN option set) are accepted and legality-checked
3917 by the compiler, but are ignored at run-time even if postcondition
3918 checking is enabled.
3920 @node Pragma Precondition
3921 @unnumberedsec Pragma Precondition
3922 @cindex Preconditions
3923 @cindex Checks, preconditions
3924 @findex Preconditions
3928 @smallexample @c ada
3929 pragma Precondition (
3930 [Check =>] Boolean_Expression
3931 [,[Message =>] String_Expression]);
3935 The @code{Precondition} pragma is similar to @code{Postcondition}
3936 except that the corresponding checks take place immediately upon
3937 entry to the subprogram, and if a precondition fails, the exception
3938 is raised in the context of the caller, and the attribute 'Result
3939 cannot be used within the precondition expression.
3941 Otherwise, the placement and visibility rules are identical to those
3942 described for postconditions. The following is an example of use
3943 within a package spec:
3945 @smallexample @c ada
3946 package Math_Functions is
3948 function Sqrt (Arg : Float) return Float;
3949 pragma Precondition (Arg >= 0.0)
3955 @code{Precondition} pragmas may appear either immediate following the
3956 (separate) declaration of a subprogram, or at the start of the
3957 declarations of a subprogram body. Only other pragmas may intervene
3958 (that is appear between the subprogram declaration and its
3959 postconditions, or appear before the postcondition in the
3960 declaration sequence in a subprogram body).
3962 Note: postcondition pragmas associated with subprograms that are
3963 marked as Inline_Always, or those marked as Inline with front-end
3964 inlining (-gnatN option set) are accepted and legality-checked
3965 by the compiler, but are ignored at run-time even if postcondition
3966 checking is enabled.
3968 @node Pragma Profile (Ravenscar)
3969 @unnumberedsec Pragma Profile (Ravenscar)
3974 @smallexample @c ada
3975 pragma Profile (Ravenscar);
3979 A configuration pragma that establishes the following set of configuration
3983 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3984 [RM D.2.2] Tasks are dispatched following a preemptive
3985 priority-ordered scheduling policy.
3987 @item Locking_Policy (Ceiling_Locking)
3988 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3989 the ceiling priority of the corresponding protected object.
3991 @c @item Detect_Blocking
3992 @c This pragma forces the detection of potentially blocking operations within a
3993 @c protected operation, and to raise Program_Error if that happens.
3997 plus the following set of restrictions:
4000 @item Max_Entry_Queue_Length = 1
4001 Defines the maximum number of calls that are queued on a (protected) entry.
4002 Note that this restrictions is checked at run time. Violation of this
4003 restriction results in the raising of Program_Error exception at the point of
4004 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4005 always 1 and hence no task can be queued on a protected entry.
4007 @item Max_Protected_Entries = 1
4008 [RM D.7] Specifies the maximum number of entries per protected type. The
4009 bounds of every entry family of a protected unit shall be static, or shall be
4010 defined by a discriminant of a subtype whose corresponding bound is static.
4011 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4013 @item Max_Task_Entries = 0
4014 [RM D.7] Specifies the maximum number of entries
4015 per task. The bounds of every entry family
4016 of a task unit shall be static, or shall be
4017 defined by a discriminant of a subtype whose
4018 corresponding bound is static. A value of zero
4019 indicates that no rendezvous are possible. For
4020 the Profile (Ravenscar), the value of Max_Task_Entries is always
4023 @item No_Abort_Statements
4024 [RM D.7] There are no abort_statements, and there are
4025 no calls to Task_Identification.Abort_Task.
4027 @item No_Asynchronous_Control
4028 There are no semantic dependences on the package
4029 Asynchronous_Task_Control.
4032 There are no semantic dependencies on the package Ada.Calendar.
4034 @item No_Dynamic_Attachment
4035 There is no call to any of the operations defined in package Ada.Interrupts
4036 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4037 Detach_Handler, and Reference).
4039 @item No_Dynamic_Priorities
4040 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4042 @item No_Implicit_Heap_Allocations
4043 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4045 @item No_Local_Protected_Objects
4046 Protected objects and access types that designate
4047 such objects shall be declared only at library level.
4049 @item No_Local_Timing_Events
4050 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4051 declared at the library level.
4053 @item No_Protected_Type_Allocators
4054 There are no allocators for protected types or
4055 types containing protected subcomponents.
4057 @item No_Relative_Delay
4058 There are no delay_relative statements.
4060 @item No_Requeue_Statements
4061 Requeue statements are not allowed.
4063 @item No_Select_Statements
4064 There are no select_statements.
4066 @item No_Specific_Termination_Handlers
4067 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4068 or to Ada.Task_Termination.Specific_Handler.
4070 @item No_Task_Allocators
4071 [RM D.7] There are no allocators for task types
4072 or types containing task subcomponents.
4074 @item No_Task_Attributes_Package
4075 There are no semantic dependencies on the Ada.Task_Attributes package.
4077 @item No_Task_Hierarchy
4078 [RM D.7] All (non-environment) tasks depend
4079 directly on the environment task of the partition.
4081 @item No_Task_Termination
4082 Tasks which terminate are erroneous.
4084 @item No_Unchecked_Conversion
4085 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4087 @item No_Unchecked_Deallocation
4088 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4090 @item Simple_Barriers
4091 Entry barrier condition expressions shall be either static
4092 boolean expressions or boolean objects which are declared in
4093 the protected type which contains the entry.
4097 This set of configuration pragmas and restrictions correspond to the
4098 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4099 published by the @cite{International Real-Time Ada Workshop}, 1997,
4100 and whose most recent description is available at
4101 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4103 The original definition of the profile was revised at subsequent IRTAW
4104 meetings. It has been included in the ISO
4105 @cite{Guide for the Use of the Ada Programming Language in High
4106 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4107 the next revision of the standard. The formal definition given by
4108 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4109 AI-305) available at
4110 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4111 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4114 The above set is a superset of the restrictions provided by pragma
4115 @code{Profile (Restricted)}, it includes six additional restrictions
4116 (@code{Simple_Barriers}, @code{No_Select_Statements},
4117 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4118 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4119 that pragma @code{Profile (Ravenscar)}, like the pragma
4120 @code{Profile (Restricted)},
4121 automatically causes the use of a simplified,
4122 more efficient version of the tasking run-time system.
4124 @node Pragma Profile (Restricted)
4125 @unnumberedsec Pragma Profile (Restricted)
4126 @findex Restricted Run Time
4130 @smallexample @c ada
4131 pragma Profile (Restricted);
4135 A configuration pragma that establishes the following set of restrictions:
4138 @item No_Abort_Statements
4139 @item No_Entry_Queue
4140 @item No_Task_Hierarchy
4141 @item No_Task_Allocators
4142 @item No_Dynamic_Priorities
4143 @item No_Terminate_Alternatives
4144 @item No_Dynamic_Attachment
4145 @item No_Protected_Type_Allocators
4146 @item No_Local_Protected_Objects
4147 @item No_Requeue_Statements
4148 @item No_Task_Attributes_Package
4149 @item Max_Asynchronous_Select_Nesting = 0
4150 @item Max_Task_Entries = 0
4151 @item Max_Protected_Entries = 1
4152 @item Max_Select_Alternatives = 0
4156 This set of restrictions causes the automatic selection of a simplified
4157 version of the run time that provides improved performance for the
4158 limited set of tasking functionality permitted by this set of restrictions.
4160 @node Pragma Psect_Object
4161 @unnumberedsec Pragma Psect_Object
4162 @findex Psect_Object
4166 @smallexample @c ada
4167 pragma Psect_Object (
4168 [Internal =>] LOCAL_NAME,
4169 [, [External =>] EXTERNAL_SYMBOL]
4170 [, [Size =>] EXTERNAL_SYMBOL]);
4174 | static_string_EXPRESSION
4178 This pragma is identical in effect to pragma @code{Common_Object}.
4180 @node Pragma Pure_Function
4181 @unnumberedsec Pragma Pure_Function
4182 @findex Pure_Function
4186 @smallexample @c ada
4187 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4191 This pragma appears in the same declarative part as a function
4192 declaration (or a set of function declarations if more than one
4193 overloaded declaration exists, in which case the pragma applies
4194 to all entities). It specifies that the function @code{Entity} is
4195 to be considered pure for the purposes of code generation. This means
4196 that the compiler can assume that there are no side effects, and
4197 in particular that two calls with identical arguments produce the
4198 same result. It also means that the function can be used in an
4201 Note that, quite deliberately, there are no static checks to try
4202 to ensure that this promise is met, so @code{Pure_Function} can be used
4203 with functions that are conceptually pure, even if they do modify
4204 global variables. For example, a square root function that is
4205 instrumented to count the number of times it is called is still
4206 conceptually pure, and can still be optimized, even though it
4207 modifies a global variable (the count). Memo functions are another
4208 example (where a table of previous calls is kept and consulted to
4209 avoid re-computation).
4212 Note: Most functions in a @code{Pure} package are automatically pure, and
4213 there is no need to use pragma @code{Pure_Function} for such functions. One
4214 exception is any function that has at least one formal of type
4215 @code{System.Address} or a type derived from it. Such functions are not
4216 considered pure by default, since the compiler assumes that the
4217 @code{Address} parameter may be functioning as a pointer and that the
4218 referenced data may change even if the address value does not.
4219 Similarly, imported functions are not considered to be pure by default,
4220 since there is no way of checking that they are in fact pure. The use
4221 of pragma @code{Pure_Function} for such a function will override these default
4222 assumption, and cause the compiler to treat a designated subprogram as pure
4225 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4226 applies to the underlying renamed function. This can be used to
4227 disambiguate cases of overloading where some but not all functions
4228 in a set of overloaded functions are to be designated as pure.
4230 If pragma @code{Pure_Function} is applied to a library level function, the
4231 function is also considered pure from an optimization point of view, but the
4232 unit is not a Pure unit in the categorization sense. So for example, a function
4233 thus marked is free to @code{with} non-pure units.
4235 @node Pragma Restriction_Warnings
4236 @unnumberedsec Pragma Restriction_Warnings
4237 @findex Restriction_Warnings
4241 @smallexample @c ada
4242 pragma Restriction_Warnings
4243 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4247 This pragma allows a series of restriction identifiers to be
4248 specified (the list of allowed identifiers is the same as for
4249 pragma @code{Restrictions}). For each of these identifiers
4250 the compiler checks for violations of the restriction, but
4251 generates a warning message rather than an error message
4252 if the restriction is violated.
4255 @unnumberedsec Pragma Shared
4259 This pragma is provided for compatibility with Ada 83. The syntax and
4260 semantics are identical to pragma Atomic.
4262 @node Pragma Short_Circuit_And_Or
4263 @unnumberedsec Pragma Short_Circuit_And_Or
4264 @findex Short_Circuit_And_Or
4267 This configuration pragma causes any occurrence of the AND operator applied to
4268 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4269 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4270 may be useful in the context of certification protocols requiring the use of
4271 short-circuited logical operators. If this configuration pragma occurs locally
4272 within the file being compiled, it applies only to the file being compiled.
4273 There is no requirement that all units in a partition use this option.
4275 semantics are identical to pragma Atomic.
4276 @node Pragma Source_File_Name
4277 @unnumberedsec Pragma Source_File_Name
4278 @findex Source_File_Name
4282 @smallexample @c ada
4283 pragma Source_File_Name (
4284 [Unit_Name =>] unit_NAME,
4285 Spec_File_Name => STRING_LITERAL,
4286 [Index => INTEGER_LITERAL]);
4288 pragma Source_File_Name (
4289 [Unit_Name =>] unit_NAME,
4290 Body_File_Name => STRING_LITERAL,
4291 [Index => INTEGER_LITERAL]);
4295 Use this to override the normal naming convention. It is a configuration
4296 pragma, and so has the usual applicability of configuration pragmas
4297 (i.e.@: it applies to either an entire partition, or to all units in a
4298 compilation, or to a single unit, depending on how it is used.
4299 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4300 the second argument is required, and indicates whether this is the file
4301 name for the spec or for the body.
4303 The optional Index argument should be used when a file contains multiple
4304 units, and when you do not want to use @code{gnatchop} to separate then
4305 into multiple files (which is the recommended procedure to limit the
4306 number of recompilations that are needed when some sources change).
4307 For instance, if the source file @file{source.ada} contains
4309 @smallexample @c ada
4321 you could use the following configuration pragmas:
4323 @smallexample @c ada
4324 pragma Source_File_Name
4325 (B, Spec_File_Name => "source.ada", Index => 1);
4326 pragma Source_File_Name
4327 (A, Body_File_Name => "source.ada", Index => 2);
4330 Note that the @code{gnatname} utility can also be used to generate those
4331 configuration pragmas.
4333 Another form of the @code{Source_File_Name} pragma allows
4334 the specification of patterns defining alternative file naming schemes
4335 to apply to all files.
4337 @smallexample @c ada
4338 pragma Source_File_Name
4339 ( [Spec_File_Name =>] STRING_LITERAL
4340 [,[Casing =>] CASING_SPEC]
4341 [,[Dot_Replacement =>] STRING_LITERAL]);
4343 pragma Source_File_Name
4344 ( [Body_File_Name =>] STRING_LITERAL
4345 [,[Casing =>] CASING_SPEC]
4346 [,[Dot_Replacement =>] STRING_LITERAL]);
4348 pragma Source_File_Name
4349 ( [Subunit_File_Name =>] STRING_LITERAL
4350 [,[Casing =>] CASING_SPEC]
4351 [,[Dot_Replacement =>] STRING_LITERAL]);
4353 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4357 The first argument is a pattern that contains a single asterisk indicating
4358 the point at which the unit name is to be inserted in the pattern string
4359 to form the file name. The second argument is optional. If present it
4360 specifies the casing of the unit name in the resulting file name string.
4361 The default is lower case. Finally the third argument allows for systematic
4362 replacement of any dots in the unit name by the specified string literal.
4364 A pragma Source_File_Name cannot appear after a
4365 @ref{Pragma Source_File_Name_Project}.
4367 For more details on the use of the @code{Source_File_Name} pragma,
4368 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4369 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4372 @node Pragma Source_File_Name_Project
4373 @unnumberedsec Pragma Source_File_Name_Project
4374 @findex Source_File_Name_Project
4377 This pragma has the same syntax and semantics as pragma Source_File_Name.
4378 It is only allowed as a stand alone configuration pragma.
4379 It cannot appear after a @ref{Pragma Source_File_Name}, and
4380 most importantly, once pragma Source_File_Name_Project appears,
4381 no further Source_File_Name pragmas are allowed.
4383 The intention is that Source_File_Name_Project pragmas are always
4384 generated by the Project Manager in a manner consistent with the naming
4385 specified in a project file, and when naming is controlled in this manner,
4386 it is not permissible to attempt to modify this naming scheme using
4387 Source_File_Name pragmas (which would not be known to the project manager).
4389 @node Pragma Source_Reference
4390 @unnumberedsec Pragma Source_Reference
4391 @findex Source_Reference
4395 @smallexample @c ada
4396 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4400 This pragma must appear as the first line of a source file.
4401 @var{integer_literal} is the logical line number of the line following
4402 the pragma line (for use in error messages and debugging
4403 information). @var{string_literal} is a static string constant that
4404 specifies the file name to be used in error messages and debugging
4405 information. This is most notably used for the output of @code{gnatchop}
4406 with the @option{-r} switch, to make sure that the original unchopped
4407 source file is the one referred to.
4409 The second argument must be a string literal, it cannot be a static
4410 string expression other than a string literal. This is because its value
4411 is needed for error messages issued by all phases of the compiler.
4413 @node Pragma Stream_Convert
4414 @unnumberedsec Pragma Stream_Convert
4415 @findex Stream_Convert
4419 @smallexample @c ada
4420 pragma Stream_Convert (
4421 [Entity =>] type_LOCAL_NAME,
4422 [Read =>] function_NAME,
4423 [Write =>] function_NAME);
4427 This pragma provides an efficient way of providing stream functions for
4428 types defined in packages. Not only is it simpler to use than declaring
4429 the necessary functions with attribute representation clauses, but more
4430 significantly, it allows the declaration to made in such a way that the
4431 stream packages are not loaded unless they are needed. The use of
4432 the Stream_Convert pragma adds no overhead at all, unless the stream
4433 attributes are actually used on the designated type.
4435 The first argument specifies the type for which stream functions are
4436 provided. The second parameter provides a function used to read values
4437 of this type. It must name a function whose argument type may be any
4438 subtype, and whose returned type must be the type given as the first
4439 argument to the pragma.
4441 The meaning of the @var{Read}
4442 parameter is that if a stream attribute directly
4443 or indirectly specifies reading of the type given as the first parameter,
4444 then a value of the type given as the argument to the Read function is
4445 read from the stream, and then the Read function is used to convert this
4446 to the required target type.
4448 Similarly the @var{Write} parameter specifies how to treat write attributes
4449 that directly or indirectly apply to the type given as the first parameter.
4450 It must have an input parameter of the type specified by the first parameter,
4451 and the return type must be the same as the input type of the Read function.
4452 The effect is to first call the Write function to convert to the given stream
4453 type, and then write the result type to the stream.
4455 The Read and Write functions must not be overloaded subprograms. If necessary
4456 renamings can be supplied to meet this requirement.
4457 The usage of this attribute is best illustrated by a simple example, taken
4458 from the GNAT implementation of package Ada.Strings.Unbounded:
4460 @smallexample @c ada
4461 function To_Unbounded (S : String)
4462 return Unbounded_String
4463 renames To_Unbounded_String;
4465 pragma Stream_Convert
4466 (Unbounded_String, To_Unbounded, To_String);
4470 The specifications of the referenced functions, as given in the Ada
4471 Reference Manual are:
4473 @smallexample @c ada
4474 function To_Unbounded_String (Source : String)
4475 return Unbounded_String;
4477 function To_String (Source : Unbounded_String)
4482 The effect is that if the value of an unbounded string is written to a stream,
4483 then the representation of the item in the stream is in the same format that
4484 would be used for @code{Standard.String'Output}, and this same representation
4485 is expected when a value of this type is read from the stream. Note that the
4486 value written always includes the bounds, even for Unbounded_String'Write,
4487 since Unbounded_String is not an array type.
4489 @node Pragma Style_Checks
4490 @unnumberedsec Pragma Style_Checks
4491 @findex Style_Checks
4495 @smallexample @c ada
4496 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4497 On | Off [, LOCAL_NAME]);
4501 This pragma is used in conjunction with compiler switches to control the
4502 built in style checking provided by GNAT@. The compiler switches, if set,
4503 provide an initial setting for the switches, and this pragma may be used
4504 to modify these settings, or the settings may be provided entirely by
4505 the use of the pragma. This pragma can be used anywhere that a pragma
4506 is legal, including use as a configuration pragma (including use in
4507 the @file{gnat.adc} file).
4509 The form with a string literal specifies which style options are to be
4510 activated. These are additive, so they apply in addition to any previously
4511 set style check options. The codes for the options are the same as those
4512 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4513 For example the following two methods can be used to enable
4518 @smallexample @c ada
4519 pragma Style_Checks ("l");
4524 gcc -c -gnatyl @dots{}
4529 The form ALL_CHECKS activates all standard checks (its use is equivalent
4530 to the use of the @code{gnaty} switch with no options. @xref{Top,
4531 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4532 @value{EDITION} User's Guide}, for details.)
4534 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4535 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4536 options (i.e. equivalent to -gnatyg).
4538 The forms with @code{Off} and @code{On}
4539 can be used to temporarily disable style checks
4540 as shown in the following example:
4542 @smallexample @c ada
4546 pragma Style_Checks ("k"); -- requires keywords in lower case
4547 pragma Style_Checks (Off); -- turn off style checks
4548 NULL; -- this will not generate an error message
4549 pragma Style_Checks (On); -- turn style checks back on
4550 NULL; -- this will generate an error message
4554 Finally the two argument form is allowed only if the first argument is
4555 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4556 for the specified entity, as shown in the following example:
4558 @smallexample @c ada
4562 pragma Style_Checks ("r"); -- require consistency of identifier casing
4564 Rf1 : Integer := ARG; -- incorrect, wrong case
4565 pragma Style_Checks (Off, Arg);
4566 Rf2 : Integer := ARG; -- OK, no error
4569 @node Pragma Subtitle
4570 @unnumberedsec Pragma Subtitle
4575 @smallexample @c ada
4576 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4580 This pragma is recognized for compatibility with other Ada compilers
4581 but is ignored by GNAT@.
4583 @node Pragma Suppress
4584 @unnumberedsec Pragma Suppress
4589 @smallexample @c ada
4590 pragma Suppress (Identifier [, [On =>] Name]);
4594 This is a standard pragma, and supports all the check names required in
4595 the RM. It is included here because GNAT recognizes one additional check
4596 name: @code{Alignment_Check} which can be used to suppress alignment checks
4597 on addresses used in address clauses. Such checks can also be suppressed
4598 by suppressing range checks, but the specific use of @code{Alignment_Check}
4599 allows suppression of alignment checks without suppressing other range checks.
4601 Note that pragma Suppress gives the compiler permission to omit
4602 checks, but does not require the compiler to omit checks. The compiler
4603 will generate checks if they are essentially free, even when they are
4604 suppressed. In particular, if the compiler can prove that a certain
4605 check will necessarily fail, it will generate code to do an
4606 unconditional ``raise'', even if checks are suppressed. The compiler
4609 Of course, run-time checks are omitted whenever the compiler can prove
4610 that they will not fail, whether or not checks are suppressed.
4612 @node Pragma Suppress_All
4613 @unnumberedsec Pragma Suppress_All
4614 @findex Suppress_All
4618 @smallexample @c ada
4619 pragma Suppress_All;
4623 This pragma can only appear immediately following a compilation
4624 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4625 which it follows. This pragma is implemented for compatibility with DEC
4626 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4627 configuration pragma is the preferred usage in GNAT@.
4629 @node Pragma Suppress_Exception_Locations
4630 @unnumberedsec Pragma Suppress_Exception_Locations
4631 @findex Suppress_Exception_Locations
4635 @smallexample @c ada
4636 pragma Suppress_Exception_Locations;
4640 In normal mode, a raise statement for an exception by default generates
4641 an exception message giving the file name and line number for the location
4642 of the raise. This is useful for debugging and logging purposes, but this
4643 entails extra space for the strings for the messages. The configuration
4644 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4645 generation of these strings, with the result that space is saved, but the
4646 exception message for such raises is null. This configuration pragma may
4647 appear in a global configuration pragma file, or in a specific unit as
4648 usual. It is not required that this pragma be used consistently within
4649 a partition, so it is fine to have some units within a partition compiled
4650 with this pragma and others compiled in normal mode without it.
4652 @node Pragma Suppress_Initialization
4653 @unnumberedsec Pragma Suppress_Initialization
4654 @findex Suppress_Initialization
4655 @cindex Suppressing initialization
4656 @cindex Initialization, suppression of
4660 @smallexample @c ada
4661 pragma Suppress_Initialization ([Entity =>] type_Name);
4665 This pragma suppresses any implicit or explicit initialization
4666 associated with the given type name for all variables of this type.
4668 @node Pragma Task_Info
4669 @unnumberedsec Pragma Task_Info
4674 @smallexample @c ada
4675 pragma Task_Info (EXPRESSION);
4679 This pragma appears within a task definition (like pragma
4680 @code{Priority}) and applies to the task in which it appears. The
4681 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4682 The @code{Task_Info} pragma provides system dependent control over
4683 aspects of tasking implementation, for example, the ability to map
4684 tasks to specific processors. For details on the facilities available
4685 for the version of GNAT that you are using, see the documentation
4686 in the spec of package System.Task_Info in the runtime
4689 @node Pragma Task_Name
4690 @unnumberedsec Pragma Task_Name
4695 @smallexample @c ada
4696 pragma Task_Name (string_EXPRESSION);
4700 This pragma appears within a task definition (like pragma
4701 @code{Priority}) and applies to the task in which it appears. The
4702 argument must be of type String, and provides a name to be used for
4703 the task instance when the task is created. Note that this expression
4704 is not required to be static, and in particular, it can contain
4705 references to task discriminants. This facility can be used to
4706 provide different names for different tasks as they are created,
4707 as illustrated in the example below.
4709 The task name is recorded internally in the run-time structures
4710 and is accessible to tools like the debugger. In addition the
4711 routine @code{Ada.Task_Identification.Image} will return this
4712 string, with a unique task address appended.
4714 @smallexample @c ada
4715 -- Example of the use of pragma Task_Name
4717 with Ada.Task_Identification;
4718 use Ada.Task_Identification;
4719 with Text_IO; use Text_IO;
4722 type Astring is access String;
4724 task type Task_Typ (Name : access String) is
4725 pragma Task_Name (Name.all);
4728 task body Task_Typ is
4729 Nam : constant String := Image (Current_Task);
4731 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4734 type Ptr_Task is access Task_Typ;
4735 Task_Var : Ptr_Task;
4739 new Task_Typ (new String'("This is task 1"));
4741 new Task_Typ (new String'("This is task 2"));
4745 @node Pragma Task_Storage
4746 @unnumberedsec Pragma Task_Storage
4747 @findex Task_Storage
4750 @smallexample @c ada
4751 pragma Task_Storage (
4752 [Task_Type =>] LOCAL_NAME,
4753 [Top_Guard =>] static_integer_EXPRESSION);
4757 This pragma specifies the length of the guard area for tasks. The guard
4758 area is an additional storage area allocated to a task. A value of zero
4759 means that either no guard area is created or a minimal guard area is
4760 created, depending on the target. This pragma can appear anywhere a
4761 @code{Storage_Size} attribute definition clause is allowed for a task
4764 @node Pragma Thread_Local_Storage
4765 @unnumberedsec Pragma Thread_Local_Storage
4766 @findex Thread_Local_Storage
4767 @cindex Task specific storage
4768 @cindex TLS (Thread Local Storage)
4771 @smallexample @c ada
4772 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4776 This pragma specifies that the specified entity, which must be
4777 a variable declared in a library level package, is to be marked as
4778 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4779 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4780 (and hence each Ada task) to see a distinct copy of the variable.
4782 The variable may not have default initialization, and if there is
4783 an explicit initialization, it must be either @code{null} for an
4784 access variable, or a static expression for a scalar variable.
4785 This provides a low level mechanism similar to that provided by
4786 the @code{Ada.Task_Attributes} package, but much more efficient
4787 and is also useful in writing interface code that will interact
4788 with foreign threads.
4790 If this pragma is used on a system where @code{TLS} is not supported,
4791 then an error message will be generated and the program will be rejected.
4793 @node Pragma Time_Slice
4794 @unnumberedsec Pragma Time_Slice
4799 @smallexample @c ada
4800 pragma Time_Slice (static_duration_EXPRESSION);
4804 For implementations of GNAT on operating systems where it is possible
4805 to supply a time slice value, this pragma may be used for this purpose.
4806 It is ignored if it is used in a system that does not allow this control,
4807 or if it appears in other than the main program unit.
4809 Note that the effect of this pragma is identical to the effect of the
4810 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4813 @unnumberedsec Pragma Title
4818 @smallexample @c ada
4819 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4822 [Title =>] STRING_LITERAL,
4823 | [Subtitle =>] STRING_LITERAL
4827 Syntax checked but otherwise ignored by GNAT@. This is a listing control
4828 pragma used in DEC Ada 83 implementations to provide a title and/or
4829 subtitle for the program listing. The program listing generated by GNAT
4830 does not have titles or subtitles.
4832 Unlike other pragmas, the full flexibility of named notation is allowed
4833 for this pragma, i.e.@: the parameters may be given in any order if named
4834 notation is used, and named and positional notation can be mixed
4835 following the normal rules for procedure calls in Ada.
4837 @node Pragma Unchecked_Union
4838 @unnumberedsec Pragma Unchecked_Union
4840 @findex Unchecked_Union
4844 @smallexample @c ada
4845 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4849 This pragma is used to specify a representation of a record type that is
4850 equivalent to a C union. It was introduced as a GNAT implementation defined
4851 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4852 pragma, making it language defined, and GNAT fully implements this extended
4853 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4854 details, consult the Ada 2005 Reference Manual, section B.3.3.
4856 @node Pragma Unimplemented_Unit
4857 @unnumberedsec Pragma Unimplemented_Unit
4858 @findex Unimplemented_Unit
4862 @smallexample @c ada
4863 pragma Unimplemented_Unit;
4867 If this pragma occurs in a unit that is processed by the compiler, GNAT
4868 aborts with the message @samp{@var{xxx} not implemented}, where
4869 @var{xxx} is the name of the current compilation unit. This pragma is
4870 intended to allow the compiler to handle unimplemented library units in
4873 The abort only happens if code is being generated. Thus you can use
4874 specs of unimplemented packages in syntax or semantic checking mode.
4876 @node Pragma Universal_Aliasing
4877 @unnumberedsec Pragma Universal_Aliasing
4878 @findex Universal_Aliasing
4882 @smallexample @c ada
4883 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4887 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4888 declarative part. The effect is to inhibit strict type-based aliasing
4889 optimization for the given type. In other words, the effect is as though
4890 access types designating this type were subject to pragma No_Strict_Aliasing.
4891 For a detailed description of the strict aliasing optimization, and the
4892 situations in which it must be suppressed, @xref{Optimization and Strict
4893 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4895 @node Pragma Universal_Data
4896 @unnumberedsec Pragma Universal_Data
4897 @findex Universal_Data
4901 @smallexample @c ada
4902 pragma Universal_Data [(library_unit_Name)];
4906 This pragma is supported only for the AAMP target and is ignored for
4907 other targets. The pragma specifies that all library-level objects
4908 (Counter 0 data) associated with the library unit are to be accessed
4909 and updated using universal addressing (24-bit addresses for AAMP5)
4910 rather than the default of 16-bit Data Environment (DENV) addressing.
4911 Use of this pragma will generally result in less efficient code for
4912 references to global data associated with the library unit, but
4913 allows such data to be located anywhere in memory. This pragma is
4914 a library unit pragma, but can also be used as a configuration pragma
4915 (including use in the @file{gnat.adc} file). The functionality
4916 of this pragma is also available by applying the -univ switch on the
4917 compilations of units where universal addressing of the data is desired.
4919 @node Pragma Unmodified
4920 @unnumberedsec Pragma Unmodified
4922 @cindex Warnings, unmodified
4926 @smallexample @c ada
4927 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4931 This pragma signals that the assignable entities (variables,
4932 @code{out} parameters, @code{in out} parameters) whose names are listed are
4933 deliberately not assigned in the current source unit. This
4934 suppresses warnings about the
4935 entities being referenced but not assigned, and in addition a warning will be
4936 generated if one of these entities is in fact assigned in the
4937 same unit as the pragma (or in the corresponding body, or one
4940 This is particularly useful for clearly signaling that a particular
4941 parameter is not modified, even though the spec suggests that it might
4944 @node Pragma Unreferenced
4945 @unnumberedsec Pragma Unreferenced
4946 @findex Unreferenced
4947 @cindex Warnings, unreferenced
4951 @smallexample @c ada
4952 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4953 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4957 This pragma signals that the entities whose names are listed are
4958 deliberately not referenced in the current source unit. This
4959 suppresses warnings about the
4960 entities being unreferenced, and in addition a warning will be
4961 generated if one of these entities is in fact referenced in the
4962 same unit as the pragma (or in the corresponding body, or one
4965 This is particularly useful for clearly signaling that a particular
4966 parameter is not referenced in some particular subprogram implementation
4967 and that this is deliberate. It can also be useful in the case of
4968 objects declared only for their initialization or finalization side
4971 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4972 current scope, then the entity most recently declared is the one to which
4973 the pragma applies. Note that in the case of accept formals, the pragma
4974 Unreferenced may appear immediately after the keyword @code{do} which
4975 allows the indication of whether or not accept formals are referenced
4976 or not to be given individually for each accept statement.
4978 The left hand side of an assignment does not count as a reference for the
4979 purpose of this pragma. Thus it is fine to assign to an entity for which
4980 pragma Unreferenced is given.
4982 Note that if a warning is desired for all calls to a given subprogram,
4983 regardless of whether they occur in the same unit as the subprogram
4984 declaration, then this pragma should not be used (calls from another
4985 unit would not be flagged); pragma Obsolescent can be used instead
4986 for this purpose, see @xref{Pragma Obsolescent}.
4988 The second form of pragma @code{Unreferenced} is used within a context
4989 clause. In this case the arguments must be unit names of units previously
4990 mentioned in @code{with} clauses (similar to the usage of pragma
4991 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4992 units and unreferenced entities within these units.
4994 @node Pragma Unreferenced_Objects
4995 @unnumberedsec Pragma Unreferenced_Objects
4996 @findex Unreferenced_Objects
4997 @cindex Warnings, unreferenced
5001 @smallexample @c ada
5002 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5006 This pragma signals that for the types or subtypes whose names are
5007 listed, objects which are declared with one of these types or subtypes may
5008 not be referenced, and if no references appear, no warnings are given.
5010 This is particularly useful for objects which are declared solely for their
5011 initialization and finalization effect. Such variables are sometimes referred
5012 to as RAII variables (Resource Acquisition Is Initialization). Using this
5013 pragma on the relevant type (most typically a limited controlled type), the
5014 compiler will automatically suppress unwanted warnings about these variables
5015 not being referenced.
5017 @node Pragma Unreserve_All_Interrupts
5018 @unnumberedsec Pragma Unreserve_All_Interrupts
5019 @findex Unreserve_All_Interrupts
5023 @smallexample @c ada
5024 pragma Unreserve_All_Interrupts;
5028 Normally certain interrupts are reserved to the implementation. Any attempt
5029 to attach an interrupt causes Program_Error to be raised, as described in
5030 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5031 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5032 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5033 interrupt execution.
5035 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5036 a program, then all such interrupts are unreserved. This allows the
5037 program to handle these interrupts, but disables their standard
5038 functions. For example, if this pragma is used, then pressing
5039 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5040 a program can then handle the @code{SIGINT} interrupt as it chooses.
5042 For a full list of the interrupts handled in a specific implementation,
5043 see the source code for the spec of @code{Ada.Interrupts.Names} in
5044 file @file{a-intnam.ads}. This is a target dependent file that contains the
5045 list of interrupts recognized for a given target. The documentation in
5046 this file also specifies what interrupts are affected by the use of
5047 the @code{Unreserve_All_Interrupts} pragma.
5049 For a more general facility for controlling what interrupts can be
5050 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5051 of the @code{Unreserve_All_Interrupts} pragma.
5053 @node Pragma Unsuppress
5054 @unnumberedsec Pragma Unsuppress
5059 @smallexample @c ada
5060 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5064 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5065 there is no corresponding pragma @code{Suppress} in effect, it has no
5066 effect. The range of the effect is the same as for pragma
5067 @code{Suppress}. The meaning of the arguments is identical to that used
5068 in pragma @code{Suppress}.
5070 One important application is to ensure that checks are on in cases where
5071 code depends on the checks for its correct functioning, so that the code
5072 will compile correctly even if the compiler switches are set to suppress
5075 @node Pragma Use_VADS_Size
5076 @unnumberedsec Pragma Use_VADS_Size
5077 @cindex @code{Size}, VADS compatibility
5078 @findex Use_VADS_Size
5082 @smallexample @c ada
5083 pragma Use_VADS_Size;
5087 This is a configuration pragma. In a unit to which it applies, any use
5088 of the 'Size attribute is automatically interpreted as a use of the
5089 'VADS_Size attribute. Note that this may result in incorrect semantic
5090 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5091 the handling of existing code which depends on the interpretation of Size
5092 as implemented in the VADS compiler. See description of the VADS_Size
5093 attribute for further details.
5095 @node Pragma Validity_Checks
5096 @unnumberedsec Pragma Validity_Checks
5097 @findex Validity_Checks
5101 @smallexample @c ada
5102 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5106 This pragma is used in conjunction with compiler switches to control the
5107 built-in validity checking provided by GNAT@. The compiler switches, if set
5108 provide an initial setting for the switches, and this pragma may be used
5109 to modify these settings, or the settings may be provided entirely by
5110 the use of the pragma. This pragma can be used anywhere that a pragma
5111 is legal, including use as a configuration pragma (including use in
5112 the @file{gnat.adc} file).
5114 The form with a string literal specifies which validity options are to be
5115 activated. The validity checks are first set to include only the default
5116 reference manual settings, and then a string of letters in the string
5117 specifies the exact set of options required. The form of this string
5118 is exactly as described for the @option{-gnatVx} compiler switch (see the
5119 GNAT users guide for details). For example the following two methods
5120 can be used to enable validity checking for mode @code{in} and
5121 @code{in out} subprogram parameters:
5125 @smallexample @c ada
5126 pragma Validity_Checks ("im");
5131 gcc -c -gnatVim @dots{}
5136 The form ALL_CHECKS activates all standard checks (its use is equivalent
5137 to the use of the @code{gnatva} switch.
5139 The forms with @code{Off} and @code{On}
5140 can be used to temporarily disable validity checks
5141 as shown in the following example:
5143 @smallexample @c ada
5147 pragma Validity_Checks ("c"); -- validity checks for copies
5148 pragma Validity_Checks (Off); -- turn off validity checks
5149 A := B; -- B will not be validity checked
5150 pragma Validity_Checks (On); -- turn validity checks back on
5151 A := C; -- C will be validity checked
5154 @node Pragma Volatile
5155 @unnumberedsec Pragma Volatile
5160 @smallexample @c ada
5161 pragma Volatile (LOCAL_NAME);
5165 This pragma is defined by the Ada Reference Manual, and the GNAT
5166 implementation is fully conformant with this definition. The reason it
5167 is mentioned in this section is that a pragma of the same name was supplied
5168 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5169 implementation of pragma Volatile is upwards compatible with the
5170 implementation in DEC Ada 83.
5172 @node Pragma Warnings
5173 @unnumberedsec Pragma Warnings
5178 @smallexample @c ada
5179 pragma Warnings (On | Off);
5180 pragma Warnings (On | Off, LOCAL_NAME);
5181 pragma Warnings (static_string_EXPRESSION);
5182 pragma Warnings (On | Off, static_string_EXPRESSION);
5186 Normally warnings are enabled, with the output being controlled by
5187 the command line switch. Warnings (@code{Off}) turns off generation of
5188 warnings until a Warnings (@code{On}) is encountered or the end of the
5189 current unit. If generation of warnings is turned off using this
5190 pragma, then no warning messages are output, regardless of the
5191 setting of the command line switches.
5193 The form with a single argument may be used as a configuration pragma.
5195 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5196 the specified entity. This suppression is effective from the point where
5197 it occurs till the end of the extended scope of the variable (similar to
5198 the scope of @code{Suppress}).
5200 The form with a single static_string_EXPRESSION argument provides more precise
5201 control over which warnings are active. The string is a list of letters
5202 specifying which warnings are to be activated and which deactivated. The
5203 code for these letters is the same as the string used in the command
5204 line switch controlling warnings. For a brief summary, use the gnatmake
5205 command with no arguments, which will generate usage information containing
5206 the list of warnings switches supported. For
5207 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5211 The specified warnings will be in effect until the end of the program
5212 or another pragma Warnings is encountered. The effect of the pragma is
5213 cumulative. Initially the set of warnings is the standard default set
5214 as possibly modified by compiler switches. Then each pragma Warning
5215 modifies this set of warnings as specified. This form of the pragma may
5216 also be used as a configuration pragma.
5218 The fourth form, with an On|Off parameter and a string, is used to
5219 control individual messages, based on their text. The string argument
5220 is a pattern that is used to match against the text of individual
5221 warning messages (not including the initial "warning: " tag).
5223 The pattern may contain asterisks, which match zero or more characters in
5224 the message. For example, you can use
5225 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5226 message @code{warning: 960 bits of "a" unused}. No other regular
5227 expression notations are permitted. All characters other than asterisk in
5228 these three specific cases are treated as literal characters in the match.
5230 There are two ways to use this pragma. The OFF form can be used as a
5231 configuration pragma. The effect is to suppress all warnings (if any)
5232 that match the pattern string throughout the compilation.
5234 The second usage is to suppress a warning locally, and in this case, two
5235 pragmas must appear in sequence:
5237 @smallexample @c ada
5238 pragma Warnings (Off, Pattern);
5239 @dots{} code where given warning is to be suppressed
5240 pragma Warnings (On, Pattern);
5244 In this usage, the pattern string must match in the Off and On pragmas,
5245 and at least one matching warning must be suppressed.
5247 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5248 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5249 be useful in checking whether obsolete pragmas in existing programs are hiding
5252 Note: pragma Warnings does not affect the processing of style messages. See
5253 separate entry for pragma Style_Checks for control of style messages.
5255 @node Pragma Weak_External
5256 @unnumberedsec Pragma Weak_External
5257 @findex Weak_External
5261 @smallexample @c ada
5262 pragma Weak_External ([Entity =>] LOCAL_NAME);
5266 @var{LOCAL_NAME} must refer to an object that is declared at the library
5267 level. This pragma specifies that the given entity should be marked as a
5268 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5269 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5270 of a regular symbol, that is to say a symbol that does not have to be
5271 resolved by the linker if used in conjunction with a pragma Import.
5273 When a weak symbol is not resolved by the linker, its address is set to
5274 zero. This is useful in writing interfaces to external modules that may
5275 or may not be linked in the final executable, for example depending on
5276 configuration settings.
5278 If a program references at run time an entity to which this pragma has been
5279 applied, and the corresponding symbol was not resolved at link time, then
5280 the execution of the program is erroneous. It is not erroneous to take the
5281 Address of such an entity, for example to guard potential references,
5282 as shown in the example below.
5284 Some file formats do not support weak symbols so not all target machines
5285 support this pragma.
5287 @smallexample @c ada
5288 -- Example of the use of pragma Weak_External
5290 package External_Module is
5292 pragma Import (C, key);
5293 pragma Weak_External (key);
5294 function Present return boolean;
5295 end External_Module;
5297 with System; use System;
5298 package body External_Module is
5299 function Present return boolean is
5301 return key'Address /= System.Null_Address;
5303 end External_Module;
5306 @node Pragma Wide_Character_Encoding
5307 @unnumberedsec Pragma Wide_Character_Encoding
5308 @findex Wide_Character_Encoding
5312 @smallexample @c ada
5313 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5317 This pragma specifies the wide character encoding to be used in program
5318 source text appearing subsequently. It is a configuration pragma, but may
5319 also be used at any point that a pragma is allowed, and it is permissible
5320 to have more than one such pragma in a file, allowing multiple encodings
5321 to appear within the same file.
5323 The argument can be an identifier or a character literal. In the identifier
5324 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5325 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5326 case it is correspondingly one of the characters @samp{h}, @samp{u},
5327 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5329 Note that when the pragma is used within a file, it affects only the
5330 encoding within that file, and does not affect withed units, specs,
5333 @node Implementation Defined Attributes
5334 @chapter Implementation Defined Attributes
5335 Ada defines (throughout the Ada reference manual,
5336 summarized in Annex K),
5337 a set of attributes that provide useful additional functionality in all
5338 areas of the language. These language defined attributes are implemented
5339 in GNAT and work as described in the Ada Reference Manual.
5341 In addition, Ada allows implementations to define additional
5342 attributes whose meaning is defined by the implementation. GNAT provides
5343 a number of these implementation-dependent attributes which can be used
5344 to extend and enhance the functionality of the compiler. This section of
5345 the GNAT reference manual describes these additional attributes.
5347 Note that any program using these attributes may not be portable to
5348 other compilers (although GNAT implements this set of attributes on all
5349 platforms). Therefore if portability to other compilers is an important
5350 consideration, you should minimize the use of these attributes.
5360 * Compiler_Version::
5362 * Default_Bit_Order::
5372 * Has_Access_Values::
5373 * Has_Discriminants::
5380 * Max_Interrupt_Priority::
5382 * Maximum_Alignment::
5387 * Passed_By_Reference::
5401 * Unconstrained_Array::
5402 * Universal_Literal_String::
5403 * Unrestricted_Access::
5411 @unnumberedsec Abort_Signal
5412 @findex Abort_Signal
5414 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5415 prefix) provides the entity for the special exception used to signal
5416 task abort or asynchronous transfer of control. Normally this attribute
5417 should only be used in the tasking runtime (it is highly peculiar, and
5418 completely outside the normal semantics of Ada, for a user program to
5419 intercept the abort exception).
5422 @unnumberedsec Address_Size
5423 @cindex Size of @code{Address}
5424 @findex Address_Size
5426 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5427 prefix) is a static constant giving the number of bits in an
5428 @code{Address}. It is the same value as System.Address'Size,
5429 but has the advantage of being static, while a direct
5430 reference to System.Address'Size is non-static because Address
5434 @unnumberedsec Asm_Input
5437 The @code{Asm_Input} attribute denotes a function that takes two
5438 parameters. The first is a string, the second is an expression of the
5439 type designated by the prefix. The first (string) argument is required
5440 to be a static expression, and is the constraint for the parameter,
5441 (e.g.@: what kind of register is required). The second argument is the
5442 value to be used as the input argument. The possible values for the
5443 constant are the same as those used in the RTL, and are dependent on
5444 the configuration file used to built the GCC back end.
5445 @ref{Machine Code Insertions}
5448 @unnumberedsec Asm_Output
5451 The @code{Asm_Output} attribute denotes a function that takes two
5452 parameters. The first is a string, the second is the name of a variable
5453 of the type designated by the attribute prefix. The first (string)
5454 argument is required to be a static expression and designates the
5455 constraint for the parameter (e.g.@: what kind of register is
5456 required). The second argument is the variable to be updated with the
5457 result. The possible values for constraint are the same as those used in
5458 the RTL, and are dependent on the configuration file used to build the
5459 GCC back end. If there are no output operands, then this argument may
5460 either be omitted, or explicitly given as @code{No_Output_Operands}.
5461 @ref{Machine Code Insertions}
5464 @unnumberedsec AST_Entry
5468 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5469 the name of an entry, it yields a value of the predefined type AST_Handler
5470 (declared in the predefined package System, as extended by the use of
5471 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5472 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5473 Language Reference Manual}, section 9.12a.
5478 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5479 offset within the storage unit (byte) that contains the first bit of
5480 storage allocated for the object. The value of this attribute is of the
5481 type @code{Universal_Integer}, and is always a non-negative number not
5482 exceeding the value of @code{System.Storage_Unit}.
5484 For an object that is a variable or a constant allocated in a register,
5485 the value is zero. (The use of this attribute does not force the
5486 allocation of a variable to memory).
5488 For an object that is a formal parameter, this attribute applies
5489 to either the matching actual parameter or to a copy of the
5490 matching actual parameter.
5492 For an access object the value is zero. Note that
5493 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5494 designated object. Similarly for a record component
5495 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5496 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5497 are subject to index checks.
5499 This attribute is designed to be compatible with the DEC Ada 83 definition
5500 and implementation of the @code{Bit} attribute.
5503 @unnumberedsec Bit_Position
5504 @findex Bit_Position
5506 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5507 of the fields of the record type, yields the bit
5508 offset within the record contains the first bit of
5509 storage allocated for the object. The value of this attribute is of the
5510 type @code{Universal_Integer}. The value depends only on the field
5511 @var{C} and is independent of the alignment of
5512 the containing record @var{R}.
5514 @node Compiler_Version
5515 @unnumberedsec Compiler_Version
5516 @findex Compiler_Version
5518 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5519 prefix) yields a static string identifying the version of the compiler
5520 being used to compile the unit containing the attribute reference. A
5521 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5524 @unnumberedsec Code_Address
5525 @findex Code_Address
5526 @cindex Subprogram address
5527 @cindex Address of subprogram code
5530 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5531 intended effect seems to be to provide
5532 an address value which can be used to call the subprogram by means of
5533 an address clause as in the following example:
5535 @smallexample @c ada
5536 procedure K is @dots{}
5539 for L'Address use K'Address;
5540 pragma Import (Ada, L);
5544 A call to @code{L} is then expected to result in a call to @code{K}@.
5545 In Ada 83, where there were no access-to-subprogram values, this was
5546 a common work-around for getting the effect of an indirect call.
5547 GNAT implements the above use of @code{Address} and the technique
5548 illustrated by the example code works correctly.
5550 However, for some purposes, it is useful to have the address of the start
5551 of the generated code for the subprogram. On some architectures, this is
5552 not necessarily the same as the @code{Address} value described above.
5553 For example, the @code{Address} value may reference a subprogram
5554 descriptor rather than the subprogram itself.
5556 The @code{'Code_Address} attribute, which can only be applied to
5557 subprogram entities, always returns the address of the start of the
5558 generated code of the specified subprogram, which may or may not be
5559 the same value as is returned by the corresponding @code{'Address}
5562 @node Default_Bit_Order
5563 @unnumberedsec Default_Bit_Order
5565 @cindex Little endian
5566 @findex Default_Bit_Order
5568 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5569 permissible prefix), provides the value @code{System.Default_Bit_Order}
5570 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5571 @code{Low_Order_First}). This is used to construct the definition of
5572 @code{Default_Bit_Order} in package @code{System}.
5575 @unnumberedsec Elaborated
5578 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5579 value is a Boolean which indicates whether or not the given unit has been
5580 elaborated. This attribute is primarily intended for internal use by the
5581 generated code for dynamic elaboration checking, but it can also be used
5582 in user programs. The value will always be True once elaboration of all
5583 units has been completed. An exception is for units which need no
5584 elaboration, the value is always False for such units.
5587 @unnumberedsec Elab_Body
5590 This attribute can only be applied to a program unit name. It returns
5591 the entity for the corresponding elaboration procedure for elaborating
5592 the body of the referenced unit. This is used in the main generated
5593 elaboration procedure by the binder and is not normally used in any
5594 other context. However, there may be specialized situations in which it
5595 is useful to be able to call this elaboration procedure from Ada code,
5596 e.g.@: if it is necessary to do selective re-elaboration to fix some
5600 @unnumberedsec Elab_Spec
5603 This attribute can only be applied to a program unit name. It returns
5604 the entity for the corresponding elaboration procedure for elaborating
5605 the spec of the referenced unit. This is used in the main
5606 generated elaboration procedure by the binder and is not normally used
5607 in any other context. However, there may be specialized situations in
5608 which it is useful to be able to call this elaboration procedure from
5609 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5614 @cindex Ada 83 attributes
5617 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5618 the Ada 83 reference manual for an exact description of the semantics of
5622 @unnumberedsec Enabled
5625 The @code{Enabled} attribute allows an application program to check at compile
5626 time to see if the designated check is currently enabled. The prefix is a
5627 simple identifier, referencing any predefined check name (other than
5628 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5629 no argument is given for the attribute, the check is for the general state
5630 of the check, if an argument is given, then it is an entity name, and the
5631 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5632 given naming the entity (if not, then the argument is ignored).
5634 Note that instantiations inherit the check status at the point of the
5635 instantiation, so a useful idiom is to have a library package that
5636 introduces a check name with @code{pragma Check_Name}, and then contains
5637 generic packages or subprograms which use the @code{Enabled} attribute
5638 to see if the check is enabled. A user of this package can then issue
5639 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5640 the package or subprogram, controlling whether the check will be present.
5643 @unnumberedsec Enum_Rep
5644 @cindex Representation of enums
5647 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5648 function with the following spec:
5650 @smallexample @c ada
5651 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5652 return @i{Universal_Integer};
5656 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5657 enumeration type or to a non-overloaded enumeration
5658 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5659 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5660 enumeration literal or object.
5662 The function returns the representation value for the given enumeration
5663 value. This will be equal to value of the @code{Pos} attribute in the
5664 absence of an enumeration representation clause. This is a static
5665 attribute (i.e.@: the result is static if the argument is static).
5667 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5668 in which case it simply returns the integer value. The reason for this
5669 is to allow it to be used for @code{(<>)} discrete formal arguments in
5670 a generic unit that can be instantiated with either enumeration types
5671 or integer types. Note that if @code{Enum_Rep} is used on a modular
5672 type whose upper bound exceeds the upper bound of the largest signed
5673 integer type, and the argument is a variable, so that the universal
5674 integer calculation is done at run time, then the call to @code{Enum_Rep}
5675 may raise @code{Constraint_Error}.
5678 @unnumberedsec Enum_Val
5679 @cindex Representation of enums
5682 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5683 function with the following spec:
5685 @smallexample @c ada
5686 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5687 return @var{S}'Base};
5691 The function returns the enumeration value whose representation matches the
5692 argument, or raises Constraint_Error if no enumeration literal of the type
5693 has the matching value.
5694 This will be equal to value of the @code{Val} attribute in the
5695 absence of an enumeration representation clause. This is a static
5696 attribute (i.e.@: the result is static if the argument is static).
5699 @unnumberedsec Epsilon
5700 @cindex Ada 83 attributes
5703 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5704 the Ada 83 reference manual for an exact description of the semantics of
5708 @unnumberedsec Fixed_Value
5711 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5712 function with the following specification:
5714 @smallexample @c ada
5715 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5720 The value returned is the fixed-point value @var{V} such that
5722 @smallexample @c ada
5723 @var{V} = Arg * @var{S}'Small
5727 The effect is thus similar to first converting the argument to the
5728 integer type used to represent @var{S}, and then doing an unchecked
5729 conversion to the fixed-point type. The difference is
5730 that there are full range checks, to ensure that the result is in range.
5731 This attribute is primarily intended for use in implementation of the
5732 input-output functions for fixed-point values.
5734 @node Has_Access_Values
5735 @unnumberedsec Has_Access_Values
5736 @cindex Access values, testing for
5737 @findex Has_Access_Values
5739 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5740 is a Boolean value which is True if the is an access type, or is a composite
5741 type with a component (at any nesting depth) that is an access type, and is
5743 The intended use of this attribute is in conjunction with generic
5744 definitions. If the attribute is applied to a generic private type, it
5745 indicates whether or not the corresponding actual type has access values.
5747 @node Has_Discriminants
5748 @unnumberedsec Has_Discriminants
5749 @cindex Discriminants, testing for
5750 @findex Has_Discriminants
5752 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5753 is a Boolean value which is True if the type has discriminants, and False
5754 otherwise. The intended use of this attribute is in conjunction with generic
5755 definitions. If the attribute is applied to a generic private type, it
5756 indicates whether or not the corresponding actual type has discriminants.
5762 The @code{Img} attribute differs from @code{Image} in that it may be
5763 applied to objects as well as types, in which case it gives the
5764 @code{Image} for the subtype of the object. This is convenient for
5767 @smallexample @c ada
5768 Put_Line ("X = " & X'Img);
5772 has the same meaning as the more verbose:
5774 @smallexample @c ada
5775 Put_Line ("X = " & @var{T}'Image (X));
5779 where @var{T} is the (sub)type of the object @code{X}.
5782 @unnumberedsec Integer_Value
5783 @findex Integer_Value
5785 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5786 function with the following spec:
5788 @smallexample @c ada
5789 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5794 The value returned is the integer value @var{V}, such that
5796 @smallexample @c ada
5797 Arg = @var{V} * @var{T}'Small
5801 where @var{T} is the type of @code{Arg}.
5802 The effect is thus similar to first doing an unchecked conversion from
5803 the fixed-point type to its corresponding implementation type, and then
5804 converting the result to the target integer type. The difference is
5805 that there are full range checks, to ensure that the result is in range.
5806 This attribute is primarily intended for use in implementation of the
5807 standard input-output functions for fixed-point values.
5810 @unnumberedsec Invalid_Value
5811 @findex Invalid_Value
5813 For every scalar type S, S'Invalid_Value returns an undefined value of the
5814 type. If possible this value is an invalid representation for the type. The
5815 value returned is identical to the value used to initialize an otherwise
5816 uninitialized value of the type if pragma Initialize_Scalars is used,
5817 including the ability to modify the value with the binder -Sxx flag and
5818 relevant environment variables at run time.
5821 @unnumberedsec Large
5822 @cindex Ada 83 attributes
5825 The @code{Large} attribute is provided for compatibility with Ada 83. See
5826 the Ada 83 reference manual for an exact description of the semantics of
5830 @unnumberedsec Machine_Size
5831 @findex Machine_Size
5833 This attribute is identical to the @code{Object_Size} attribute. It is
5834 provided for compatibility with the DEC Ada 83 attribute of this name.
5837 @unnumberedsec Mantissa
5838 @cindex Ada 83 attributes
5841 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
5842 the Ada 83 reference manual for an exact description of the semantics of
5845 @node Max_Interrupt_Priority
5846 @unnumberedsec Max_Interrupt_Priority
5847 @cindex Interrupt priority, maximum
5848 @findex Max_Interrupt_Priority
5850 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5851 permissible prefix), provides the same value as
5852 @code{System.Max_Interrupt_Priority}.
5855 @unnumberedsec Max_Priority
5856 @cindex Priority, maximum
5857 @findex Max_Priority
5859 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5860 prefix) provides the same value as @code{System.Max_Priority}.
5862 @node Maximum_Alignment
5863 @unnumberedsec Maximum_Alignment
5864 @cindex Alignment, maximum
5865 @findex Maximum_Alignment
5867 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5868 permissible prefix) provides the maximum useful alignment value for the
5869 target. This is a static value that can be used to specify the alignment
5870 for an object, guaranteeing that it is properly aligned in all
5873 @node Mechanism_Code
5874 @unnumberedsec Mechanism_Code
5875 @cindex Return values, passing mechanism
5876 @cindex Parameters, passing mechanism
5877 @findex Mechanism_Code
5879 @code{@var{function}'Mechanism_Code} yields an integer code for the
5880 mechanism used for the result of function, and
5881 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5882 used for formal parameter number @var{n} (a static integer value with 1
5883 meaning the first parameter) of @var{subprogram}. The code returned is:
5891 by descriptor (default descriptor class)
5893 by descriptor (UBS: unaligned bit string)
5895 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5897 by descriptor (UBA: unaligned bit array)
5899 by descriptor (S: string, also scalar access type parameter)
5901 by descriptor (SB: string with arbitrary bounds)
5903 by descriptor (A: contiguous array)
5905 by descriptor (NCA: non-contiguous array)
5909 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5912 @node Null_Parameter
5913 @unnumberedsec Null_Parameter
5914 @cindex Zero address, passing
5915 @findex Null_Parameter
5917 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5918 type or subtype @var{T} allocated at machine address zero. The attribute
5919 is allowed only as the default expression of a formal parameter, or as
5920 an actual expression of a subprogram call. In either case, the
5921 subprogram must be imported.
5923 The identity of the object is represented by the address zero in the
5924 argument list, independent of the passing mechanism (explicit or
5927 This capability is needed to specify that a zero address should be
5928 passed for a record or other composite object passed by reference.
5929 There is no way of indicating this without the @code{Null_Parameter}
5933 @unnumberedsec Object_Size
5934 @cindex Size, used for objects
5937 The size of an object is not necessarily the same as the size of the type
5938 of an object. This is because by default object sizes are increased to be
5939 a multiple of the alignment of the object. For example,
5940 @code{Natural'Size} is
5941 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5942 Similarly, a record containing an integer and a character:
5944 @smallexample @c ada
5952 will have a size of 40 (that is @code{Rec'Size} will be 40). The
5953 alignment will be 4, because of the
5954 integer field, and so the default size of record objects for this type
5955 will be 64 (8 bytes).
5959 @cindex Capturing Old values
5960 @cindex Postconditions
5962 The attribute Prefix'Old can be used within a
5963 subprogram to refer to the value of the prefix on entry. So for
5964 example if you have an argument of a record type X called Arg1,
5965 you can refer to Arg1.Field'Old which yields the value of
5966 Arg1.Field on entry. The implementation simply involves generating
5967 an object declaration which captures the value on entry. Any
5968 prefix is allowed except one of a limited type (since limited
5969 types cannot be copied to capture their values) or a local variable
5970 (since it does not exist at subprogram entry time).
5972 The following example shows the use of 'Old to implement
5973 a test of a postcondition:
5975 @smallexample @c ada
5986 package body Old_Pkg is
5987 Count : Natural := 0;
5991 ... code manipulating the value of Count
5993 pragma Assert (Count = Count'Old + 1);
5999 Note that it is allowed to apply 'Old to a constant entity, but this will
6000 result in a warning, since the old and new values will always be the same.
6002 @node Passed_By_Reference
6003 @unnumberedsec Passed_By_Reference
6004 @cindex Parameters, when passed by reference
6005 @findex Passed_By_Reference
6007 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6008 a value of type @code{Boolean} value that is @code{True} if the type is
6009 normally passed by reference and @code{False} if the type is normally
6010 passed by copy in calls. For scalar types, the result is always @code{False}
6011 and is static. For non-scalar types, the result is non-static.
6014 @unnumberedsec Pool_Address
6015 @cindex Parameters, when passed by reference
6016 @findex Pool_Address
6018 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6019 of X within its storage pool. This is the same as
6020 @code{@var{X}'Address}, except that for an unconstrained array whose
6021 bounds are allocated just before the first component,
6022 @code{@var{X}'Pool_Address} returns the address of those bounds,
6023 whereas @code{@var{X}'Address} returns the address of the first
6026 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6027 the object is allocated'', which could be a user-defined storage pool,
6028 the global heap, on the stack, or in a static memory area. For an
6029 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6030 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6033 @unnumberedsec Range_Length
6034 @findex Range_Length
6036 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6037 the number of values represented by the subtype (zero for a null
6038 range). The result is static for static subtypes. @code{Range_Length}
6039 applied to the index subtype of a one dimensional array always gives the
6040 same result as @code{Range} applied to the array itself.
6043 @unnumberedsec Result
6046 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6047 for a function. The prefix must be the name of the corresponding function. This
6048 is used to refer to the result of the function in the postcondition expression.
6049 For a further discussion of the use of this attribute and examples of its use,
6050 see the description of pragma Postcondition.
6053 @unnumberedsec Safe_Emax
6054 @cindex Ada 83 attributes
6057 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6058 the Ada 83 reference manual for an exact description of the semantics of
6062 @unnumberedsec Safe_Large
6063 @cindex Ada 83 attributes
6066 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6067 the Ada 83 reference manual for an exact description of the semantics of
6071 @unnumberedsec Small
6072 @cindex Ada 83 attributes
6075 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6077 GNAT also allows this attribute to be applied to floating-point types
6078 for compatibility with Ada 83. See
6079 the Ada 83 reference manual for an exact description of the semantics of
6080 this attribute when applied to floating-point types.
6083 @unnumberedsec Storage_Unit
6084 @findex Storage_Unit
6086 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6087 prefix) provides the same value as @code{System.Storage_Unit}.
6090 @unnumberedsec Stub_Type
6093 The GNAT implementation of remote access-to-classwide types is
6094 organized as described in AARM section E.4 (20.t): a value of an RACW type
6095 (designating a remote object) is represented as a normal access
6096 value, pointing to a "stub" object which in turn contains the
6097 necessary information to contact the designated remote object. A
6098 call on any dispatching operation of such a stub object does the
6099 remote call, if necessary, using the information in the stub object
6100 to locate the target partition, etc.
6102 For a prefix @code{T} that denotes a remote access-to-classwide type,
6103 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6105 By construction, the layout of @code{T'Stub_Type} is identical to that of
6106 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6107 unit @code{System.Partition_Interface}. Use of this attribute will create
6108 an implicit dependency on this unit.
6111 @unnumberedsec Target_Name
6114 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6115 prefix) provides a static string value that identifies the target
6116 for the current compilation. For GCC implementations, this is the
6117 standard gcc target name without the terminating slash (for
6118 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6124 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6125 provides the same value as @code{System.Tick},
6128 @unnumberedsec To_Address
6131 The @code{System'To_Address}
6132 (@code{System} is the only permissible prefix)
6133 denotes a function identical to
6134 @code{System.Storage_Elements.To_Address} except that
6135 it is a static attribute. This means that if its argument is
6136 a static expression, then the result of the attribute is a
6137 static expression. The result is that such an expression can be
6138 used in contexts (e.g.@: preelaborable packages) which require a
6139 static expression and where the function call could not be used
6140 (since the function call is always non-static, even if its
6141 argument is static).
6144 @unnumberedsec Type_Class
6147 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6148 the value of the type class for the full type of @var{type}. If
6149 @var{type} is a generic formal type, the value is the value for the
6150 corresponding actual subtype. The value of this attribute is of type
6151 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6153 @smallexample @c ada
6155 (Type_Class_Enumeration,
6157 Type_Class_Fixed_Point,
6158 Type_Class_Floating_Point,
6163 Type_Class_Address);
6167 Protected types yield the value @code{Type_Class_Task}, which thus
6168 applies to all concurrent types. This attribute is designed to
6169 be compatible with the DEC Ada 83 attribute of the same name.
6172 @unnumberedsec UET_Address
6175 The @code{UET_Address} attribute can only be used for a prefix which
6176 denotes a library package. It yields the address of the unit exception
6177 table when zero cost exception handling is used. This attribute is
6178 intended only for use within the GNAT implementation. See the unit
6179 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6180 for details on how this attribute is used in the implementation.
6182 @node Unconstrained_Array
6183 @unnumberedsec Unconstrained_Array
6184 @findex Unconstrained_Array
6186 The @code{Unconstrained_Array} attribute can be used with a prefix that
6187 denotes any type or subtype. It is a static attribute that yields
6188 @code{True} if the prefix designates an unconstrained array,
6189 and @code{False} otherwise. In a generic instance, the result is
6190 still static, and yields the result of applying this test to the
6193 @node Universal_Literal_String
6194 @unnumberedsec Universal_Literal_String
6195 @cindex Named numbers, representation of
6196 @findex Universal_Literal_String
6198 The prefix of @code{Universal_Literal_String} must be a named
6199 number. The static result is the string consisting of the characters of
6200 the number as defined in the original source. This allows the user
6201 program to access the actual text of named numbers without intermediate
6202 conversions and without the need to enclose the strings in quotes (which
6203 would preclude their use as numbers). This is used internally for the
6204 construction of values of the floating-point attributes from the file
6205 @file{ttypef.ads}, but may also be used by user programs.
6207 For example, the following program prints the first 50 digits of pi:
6209 @smallexample @c ada
6210 with Text_IO; use Text_IO;
6214 Put (Ada.Numerics.Pi'Universal_Literal_String);
6218 @node Unrestricted_Access
6219 @unnumberedsec Unrestricted_Access
6220 @cindex @code{Access}, unrestricted
6221 @findex Unrestricted_Access
6223 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6224 except that all accessibility and aliased view checks are omitted. This
6225 is a user-beware attribute. It is similar to
6226 @code{Address}, for which it is a desirable replacement where the value
6227 desired is an access type. In other words, its effect is identical to
6228 first applying the @code{Address} attribute and then doing an unchecked
6229 conversion to a desired access type. In GNAT, but not necessarily in
6230 other implementations, the use of static chains for inner level
6231 subprograms means that @code{Unrestricted_Access} applied to a
6232 subprogram yields a value that can be called as long as the subprogram
6233 is in scope (normal Ada accessibility rules restrict this usage).
6235 It is possible to use @code{Unrestricted_Access} for any type, but care
6236 must be exercised if it is used to create pointers to unconstrained
6237 objects. In this case, the resulting pointer has the same scope as the
6238 context of the attribute, and may not be returned to some enclosing
6239 scope. For instance, a function cannot use @code{Unrestricted_Access}
6240 to create a unconstrained pointer and then return that value to the
6244 @unnumberedsec VADS_Size
6245 @cindex @code{Size}, VADS compatibility
6248 The @code{'VADS_Size} attribute is intended to make it easier to port
6249 legacy code which relies on the semantics of @code{'Size} as implemented
6250 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6251 same semantic interpretation. In particular, @code{'VADS_Size} applied
6252 to a predefined or other primitive type with no Size clause yields the
6253 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6254 typical machines). In addition @code{'VADS_Size} applied to an object
6255 gives the result that would be obtained by applying the attribute to
6256 the corresponding type.
6259 @unnumberedsec Value_Size
6260 @cindex @code{Size}, setting for not-first subtype
6262 @code{@var{type}'Value_Size} is the number of bits required to represent
6263 a value of the given subtype. It is the same as @code{@var{type}'Size},
6264 but, unlike @code{Size}, may be set for non-first subtypes.
6267 @unnumberedsec Wchar_T_Size
6268 @findex Wchar_T_Size
6269 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6270 prefix) provides the size in bits of the C @code{wchar_t} type
6271 primarily for constructing the definition of this type in
6272 package @code{Interfaces.C}.
6275 @unnumberedsec Word_Size
6277 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6278 prefix) provides the value @code{System.Word_Size}.
6280 @c ------------------------
6281 @node Implementation Advice
6282 @chapter Implementation Advice
6284 The main text of the Ada Reference Manual describes the required
6285 behavior of all Ada compilers, and the GNAT compiler conforms to
6288 In addition, there are sections throughout the Ada Reference Manual headed
6289 by the phrase ``Implementation advice''. These sections are not normative,
6290 i.e., they do not specify requirements that all compilers must
6291 follow. Rather they provide advice on generally desirable behavior. You
6292 may wonder why they are not requirements. The most typical answer is
6293 that they describe behavior that seems generally desirable, but cannot
6294 be provided on all systems, or which may be undesirable on some systems.
6296 As far as practical, GNAT follows the implementation advice sections in
6297 the Ada Reference Manual. This chapter contains a table giving the
6298 reference manual section number, paragraph number and several keywords
6299 for each advice. Each entry consists of the text of the advice followed
6300 by the GNAT interpretation of this advice. Most often, this simply says
6301 ``followed'', which means that GNAT follows the advice. However, in a
6302 number of cases, GNAT deliberately deviates from this advice, in which
6303 case the text describes what GNAT does and why.
6305 @cindex Error detection
6306 @unnumberedsec 1.1.3(20): Error Detection
6309 If an implementation detects the use of an unsupported Specialized Needs
6310 Annex feature at run time, it should raise @code{Program_Error} if
6313 Not relevant. All specialized needs annex features are either supported,
6314 or diagnosed at compile time.
6317 @unnumberedsec 1.1.3(31): Child Units
6320 If an implementation wishes to provide implementation-defined
6321 extensions to the functionality of a language-defined library unit, it
6322 should normally do so by adding children to the library unit.
6326 @cindex Bounded errors
6327 @unnumberedsec 1.1.5(12): Bounded Errors
6330 If an implementation detects a bounded error or erroneous
6331 execution, it should raise @code{Program_Error}.
6333 Followed in all cases in which the implementation detects a bounded
6334 error or erroneous execution. Not all such situations are detected at
6338 @unnumberedsec 2.8(16): Pragmas
6341 Normally, implementation-defined pragmas should have no semantic effect
6342 for error-free programs; that is, if the implementation-defined pragmas
6343 are removed from a working program, the program should still be legal,
6344 and should still have the same semantics.
6346 The following implementation defined pragmas are exceptions to this
6358 @item CPP_Constructor
6362 @item Interface_Name
6364 @item Machine_Attribute
6366 @item Unimplemented_Unit
6368 @item Unchecked_Union
6373 In each of the above cases, it is essential to the purpose of the pragma
6374 that this advice not be followed. For details see the separate section
6375 on implementation defined pragmas.
6377 @unnumberedsec 2.8(17-19): Pragmas
6380 Normally, an implementation should not define pragmas that can
6381 make an illegal program legal, except as follows:
6385 A pragma used to complete a declaration, such as a pragma @code{Import};
6389 A pragma used to configure the environment by adding, removing, or
6390 replacing @code{library_items}.
6392 See response to paragraph 16 of this same section.
6394 @cindex Character Sets
6395 @cindex Alternative Character Sets
6396 @unnumberedsec 3.5.2(5): Alternative Character Sets
6399 If an implementation supports a mode with alternative interpretations
6400 for @code{Character} and @code{Wide_Character}, the set of graphic
6401 characters of @code{Character} should nevertheless remain a proper
6402 subset of the set of graphic characters of @code{Wide_Character}. Any
6403 character set ``localizations'' should be reflected in the results of
6404 the subprograms defined in the language-defined package
6405 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6406 an alternative interpretation of @code{Character}, the implementation should
6407 also support a corresponding change in what is a legal
6408 @code{identifier_letter}.
6410 Not all wide character modes follow this advice, in particular the JIS
6411 and IEC modes reflect standard usage in Japan, and in these encoding,
6412 the upper half of the Latin-1 set is not part of the wide-character
6413 subset, since the most significant bit is used for wide character
6414 encoding. However, this only applies to the external forms. Internally
6415 there is no such restriction.
6417 @cindex Integer types
6418 @unnumberedsec 3.5.4(28): Integer Types
6422 An implementation should support @code{Long_Integer} in addition to
6423 @code{Integer} if the target machine supports 32-bit (or longer)
6424 arithmetic. No other named integer subtypes are recommended for package
6425 @code{Standard}. Instead, appropriate named integer subtypes should be
6426 provided in the library package @code{Interfaces} (see B.2).
6428 @code{Long_Integer} is supported. Other standard integer types are supported
6429 so this advice is not fully followed. These types
6430 are supported for convenient interface to C, and so that all hardware
6431 types of the machine are easily available.
6432 @unnumberedsec 3.5.4(29): Integer Types
6436 An implementation for a two's complement machine should support
6437 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6438 implementation should support a non-binary modules up to @code{Integer'Last}.
6442 @cindex Enumeration values
6443 @unnumberedsec 3.5.5(8): Enumeration Values
6446 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6447 subtype, if the value of the operand does not correspond to the internal
6448 code for any enumeration literal of its type (perhaps due to an
6449 un-initialized variable), then the implementation should raise
6450 @code{Program_Error}. This is particularly important for enumeration
6451 types with noncontiguous internal codes specified by an
6452 enumeration_representation_clause.
6457 @unnumberedsec 3.5.7(17): Float Types
6460 An implementation should support @code{Long_Float} in addition to
6461 @code{Float} if the target machine supports 11 or more digits of
6462 precision. No other named floating point subtypes are recommended for
6463 package @code{Standard}. Instead, appropriate named floating point subtypes
6464 should be provided in the library package @code{Interfaces} (see B.2).
6466 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6467 former provides improved compatibility with other implementations
6468 supporting this type. The latter corresponds to the highest precision
6469 floating-point type supported by the hardware. On most machines, this
6470 will be the same as @code{Long_Float}, but on some machines, it will
6471 correspond to the IEEE extended form. The notable case is all ia32
6472 (x86) implementations, where @code{Long_Long_Float} corresponds to
6473 the 80-bit extended precision format supported in hardware on this
6474 processor. Note that the 128-bit format on SPARC is not supported,
6475 since this is a software rather than a hardware format.
6477 @cindex Multidimensional arrays
6478 @cindex Arrays, multidimensional
6479 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6482 An implementation should normally represent multidimensional arrays in
6483 row-major order, consistent with the notation used for multidimensional
6484 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6485 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6486 column-major order should be used instead (see B.5, ``Interfacing with
6491 @findex Duration'Small
6492 @unnumberedsec 9.6(30-31): Duration'Small
6495 Whenever possible in an implementation, the value of @code{Duration'Small}
6496 should be no greater than 100 microseconds.
6498 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6502 The time base for @code{delay_relative_statements} should be monotonic;
6503 it need not be the same time base as used for @code{Calendar.Clock}.
6507 @unnumberedsec 10.2.1(12): Consistent Representation
6510 In an implementation, a type declared in a pre-elaborated package should
6511 have the same representation in every elaboration of a given version of
6512 the package, whether the elaborations occur in distinct executions of
6513 the same program, or in executions of distinct programs or partitions
6514 that include the given version.
6516 Followed, except in the case of tagged types. Tagged types involve
6517 implicit pointers to a local copy of a dispatch table, and these pointers
6518 have representations which thus depend on a particular elaboration of the
6519 package. It is not easy to see how it would be possible to follow this
6520 advice without severely impacting efficiency of execution.
6522 @cindex Exception information
6523 @unnumberedsec 11.4.1(19): Exception Information
6526 @code{Exception_Message} by default and @code{Exception_Information}
6527 should produce information useful for
6528 debugging. @code{Exception_Message} should be short, about one
6529 line. @code{Exception_Information} can be long. @code{Exception_Message}
6530 should not include the
6531 @code{Exception_Name}. @code{Exception_Information} should include both
6532 the @code{Exception_Name} and the @code{Exception_Message}.
6534 Followed. For each exception that doesn't have a specified
6535 @code{Exception_Message}, the compiler generates one containing the location
6536 of the raise statement. This location has the form ``file:line'', where
6537 file is the short file name (without path information) and line is the line
6538 number in the file. Note that in the case of the Zero Cost Exception
6539 mechanism, these messages become redundant with the Exception_Information that
6540 contains a full backtrace of the calling sequence, so they are disabled.
6541 To disable explicitly the generation of the source location message, use the
6542 Pragma @code{Discard_Names}.
6544 @cindex Suppression of checks
6545 @cindex Checks, suppression of
6546 @unnumberedsec 11.5(28): Suppression of Checks
6549 The implementation should minimize the code executed for checks that
6550 have been suppressed.
6554 @cindex Representation clauses
6555 @unnumberedsec 13.1 (21-24): Representation Clauses
6558 The recommended level of support for all representation items is
6559 qualified as follows:
6563 An implementation need not support representation items containing
6564 non-static expressions, except that an implementation should support a
6565 representation item for a given entity if each non-static expression in
6566 the representation item is a name that statically denotes a constant
6567 declared before the entity.
6569 Followed. In fact, GNAT goes beyond the recommended level of support
6570 by allowing nonstatic expressions in some representation clauses even
6571 without the need to declare constants initialized with the values of
6575 @smallexample @c ada
6578 for Y'Address use X'Address;>>
6583 An implementation need not support a specification for the @code{Size}
6584 for a given composite subtype, nor the size or storage place for an
6585 object (including a component) of a given composite subtype, unless the
6586 constraints on the subtype and its composite subcomponents (if any) are
6587 all static constraints.
6589 Followed. Size Clauses are not permitted on non-static components, as
6594 An aliased component, or a component whose type is by-reference, should
6595 always be allocated at an addressable location.
6599 @cindex Packed types
6600 @unnumberedsec 13.2(6-8): Packed Types
6603 If a type is packed, then the implementation should try to minimize
6604 storage allocated to objects of the type, possibly at the expense of
6605 speed of accessing components, subject to reasonable complexity in
6606 addressing calculations.
6610 The recommended level of support pragma @code{Pack} is:
6612 For a packed record type, the components should be packed as tightly as
6613 possible subject to the Sizes of the component subtypes, and subject to
6614 any @code{record_representation_clause} that applies to the type; the
6615 implementation may, but need not, reorder components or cross aligned
6616 word boundaries to improve the packing. A component whose @code{Size} is
6617 greater than the word size may be allocated an integral number of words.
6619 Followed. Tight packing of arrays is supported for all component sizes
6620 up to 64-bits. If the array component size is 1 (that is to say, if
6621 the component is a boolean type or an enumeration type with two values)
6622 then values of the type are implicitly initialized to zero. This
6623 happens both for objects of the packed type, and for objects that have a
6624 subcomponent of the packed type.
6628 An implementation should support Address clauses for imported
6632 @cindex @code{Address} clauses
6633 @unnumberedsec 13.3(14-19): Address Clauses
6637 For an array @var{X}, @code{@var{X}'Address} should point at the first
6638 component of the array, and not at the array bounds.
6644 The recommended level of support for the @code{Address} attribute is:
6646 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6647 object that is aliased or of a by-reference type, or is an entity whose
6648 @code{Address} has been specified.
6650 Followed. A valid address will be produced even if none of those
6651 conditions have been met. If necessary, the object is forced into
6652 memory to ensure the address is valid.
6656 An implementation should support @code{Address} clauses for imported
6663 Objects (including subcomponents) that are aliased or of a by-reference
6664 type should be allocated on storage element boundaries.
6670 If the @code{Address} of an object is specified, or it is imported or exported,
6671 then the implementation should not perform optimizations based on
6672 assumptions of no aliases.
6676 @cindex @code{Alignment} clauses
6677 @unnumberedsec 13.3(29-35): Alignment Clauses
6680 The recommended level of support for the @code{Alignment} attribute for
6683 An implementation should support specified Alignments that are factors
6684 and multiples of the number of storage elements per word, subject to the
6691 An implementation need not support specified @code{Alignment}s for
6692 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6693 loaded and stored by available machine instructions.
6699 An implementation need not support specified @code{Alignment}s that are
6700 greater than the maximum @code{Alignment} the implementation ever returns by
6707 The recommended level of support for the @code{Alignment} attribute for
6710 Same as above, for subtypes, but in addition:
6716 For stand-alone library-level objects of statically constrained
6717 subtypes, the implementation should support all @code{Alignment}s
6718 supported by the target linker. For example, page alignment is likely to
6719 be supported for such objects, but not for subtypes.
6723 @cindex @code{Size} clauses
6724 @unnumberedsec 13.3(42-43): Size Clauses
6727 The recommended level of support for the @code{Size} attribute of
6730 A @code{Size} clause should be supported for an object if the specified
6731 @code{Size} is at least as large as its subtype's @code{Size}, and
6732 corresponds to a size in storage elements that is a multiple of the
6733 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6737 @unnumberedsec 13.3(50-56): Size Clauses
6740 If the @code{Size} of a subtype is specified, and allows for efficient
6741 independent addressability (see 9.10) on the target architecture, then
6742 the @code{Size} of the following objects of the subtype should equal the
6743 @code{Size} of the subtype:
6745 Aliased objects (including components).
6751 @code{Size} clause on a composite subtype should not affect the
6752 internal layout of components.
6754 Followed. But note that this can be overridden by use of the implementation
6755 pragma Implicit_Packing in the case of packed arrays.
6759 The recommended level of support for the @code{Size} attribute of subtypes is:
6763 The @code{Size} (if not specified) of a static discrete or fixed point
6764 subtype should be the number of bits needed to represent each value
6765 belonging to the subtype using an unbiased representation, leaving space
6766 for a sign bit only if the subtype contains negative values. If such a
6767 subtype is a first subtype, then an implementation should support a
6768 specified @code{Size} for it that reflects this representation.
6774 For a subtype implemented with levels of indirection, the @code{Size}
6775 should include the size of the pointers, but not the size of what they
6780 @cindex @code{Component_Size} clauses
6781 @unnumberedsec 13.3(71-73): Component Size Clauses
6784 The recommended level of support for the @code{Component_Size}
6789 An implementation need not support specified @code{Component_Sizes} that are
6790 less than the @code{Size} of the component subtype.
6796 An implementation should support specified @code{Component_Size}s that
6797 are factors and multiples of the word size. For such
6798 @code{Component_Size}s, the array should contain no gaps between
6799 components. For other @code{Component_Size}s (if supported), the array
6800 should contain no gaps between components when packing is also
6801 specified; the implementation should forbid this combination in cases
6802 where it cannot support a no-gaps representation.
6806 @cindex Enumeration representation clauses
6807 @cindex Representation clauses, enumeration
6808 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6811 The recommended level of support for enumeration representation clauses
6814 An implementation need not support enumeration representation clauses
6815 for boolean types, but should at minimum support the internal codes in
6816 the range @code{System.Min_Int.System.Max_Int}.
6820 @cindex Record representation clauses
6821 @cindex Representation clauses, records
6822 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6825 The recommended level of support for
6826 @*@code{record_representation_clauses} is:
6828 An implementation should support storage places that can be extracted
6829 with a load, mask, shift sequence of machine code, and set with a load,
6830 shift, mask, store sequence, given the available machine instructions
6837 A storage place should be supported if its size is equal to the
6838 @code{Size} of the component subtype, and it starts and ends on a
6839 boundary that obeys the @code{Alignment} of the component subtype.
6845 If the default bit ordering applies to the declaration of a given type,
6846 then for a component whose subtype's @code{Size} is less than the word
6847 size, any storage place that does not cross an aligned word boundary
6848 should be supported.
6854 An implementation may reserve a storage place for the tag field of a
6855 tagged type, and disallow other components from overlapping that place.
6857 Followed. The storage place for the tag field is the beginning of the tagged
6858 record, and its size is Address'Size. GNAT will reject an explicit component
6859 clause for the tag field.
6863 An implementation need not support a @code{component_clause} for a
6864 component of an extension part if the storage place is not after the
6865 storage places of all components of the parent type, whether or not
6866 those storage places had been specified.
6868 Followed. The above advice on record representation clauses is followed,
6869 and all mentioned features are implemented.
6871 @cindex Storage place attributes
6872 @unnumberedsec 13.5.2(5): Storage Place Attributes
6875 If a component is represented using some form of pointer (such as an
6876 offset) to the actual data of the component, and this data is contiguous
6877 with the rest of the object, then the storage place attributes should
6878 reflect the place of the actual data, not the pointer. If a component is
6879 allocated discontinuously from the rest of the object, then a warning
6880 should be generated upon reference to one of its storage place
6883 Followed. There are no such components in GNAT@.
6885 @cindex Bit ordering
6886 @unnumberedsec 13.5.3(7-8): Bit Ordering
6889 The recommended level of support for the non-default bit ordering is:
6893 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6894 should support the non-default bit ordering in addition to the default
6897 Followed. Word size does not equal storage size in this implementation.
6898 Thus non-default bit ordering is not supported.
6900 @cindex @code{Address}, as private type
6901 @unnumberedsec 13.7(37): Address as Private
6904 @code{Address} should be of a private type.
6908 @cindex Operations, on @code{Address}
6909 @cindex @code{Address}, operations of
6910 @unnumberedsec 13.7.1(16): Address Operations
6913 Operations in @code{System} and its children should reflect the target
6914 environment semantics as closely as is reasonable. For example, on most
6915 machines, it makes sense for address arithmetic to ``wrap around''.
6916 Operations that do not make sense should raise @code{Program_Error}.
6918 Followed. Address arithmetic is modular arithmetic that wraps around. No
6919 operation raises @code{Program_Error}, since all operations make sense.
6921 @cindex Unchecked conversion
6922 @unnumberedsec 13.9(14-17): Unchecked Conversion
6925 The @code{Size} of an array object should not include its bounds; hence,
6926 the bounds should not be part of the converted data.
6932 The implementation should not generate unnecessary run-time checks to
6933 ensure that the representation of @var{S} is a representation of the
6934 target type. It should take advantage of the permission to return by
6935 reference when possible. Restrictions on unchecked conversions should be
6936 avoided unless required by the target environment.
6938 Followed. There are no restrictions on unchecked conversion. A warning is
6939 generated if the source and target types do not have the same size since
6940 the semantics in this case may be target dependent.
6944 The recommended level of support for unchecked conversions is:
6948 Unchecked conversions should be supported and should be reversible in
6949 the cases where this clause defines the result. To enable meaningful use
6950 of unchecked conversion, a contiguous representation should be used for
6951 elementary subtypes, for statically constrained array subtypes whose
6952 component subtype is one of the subtypes described in this paragraph,
6953 and for record subtypes without discriminants whose component subtypes
6954 are described in this paragraph.
6958 @cindex Heap usage, implicit
6959 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6962 An implementation should document any cases in which it dynamically
6963 allocates heap storage for a purpose other than the evaluation of an
6966 Followed, the only other points at which heap storage is dynamically
6967 allocated are as follows:
6971 At initial elaboration time, to allocate dynamically sized global
6975 To allocate space for a task when a task is created.
6978 To extend the secondary stack dynamically when needed. The secondary
6979 stack is used for returning variable length results.
6984 A default (implementation-provided) storage pool for an
6985 access-to-constant type should not have overhead to support deallocation of
6992 A storage pool for an anonymous access type should be created at the
6993 point of an allocator for the type, and be reclaimed when the designated
6994 object becomes inaccessible.
6998 @cindex Unchecked deallocation
6999 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7002 For a standard storage pool, @code{Free} should actually reclaim the
7007 @cindex Stream oriented attributes
7008 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7011 If a stream element is the same size as a storage element, then the
7012 normal in-memory representation should be used by @code{Read} and
7013 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7014 should use the smallest number of stream elements needed to represent
7015 all values in the base range of the scalar type.
7018 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7019 which specifies using the size of the first subtype.
7020 However, such an implementation is based on direct binary
7021 representations and is therefore target- and endianness-dependent.
7022 To address this issue, GNAT also supplies an alternate implementation
7023 of the stream attributes @code{Read} and @code{Write},
7024 which uses the target-independent XDR standard representation
7026 @cindex XDR representation
7027 @cindex @code{Read} attribute
7028 @cindex @code{Write} attribute
7029 @cindex Stream oriented attributes
7030 The XDR implementation is provided as an alternative body of the
7031 @code{System.Stream_Attributes} package, in the file
7032 @file{s-strxdr.adb} in the GNAT library.
7033 There is no @file{s-strxdr.ads} file.
7034 In order to install the XDR implementation, do the following:
7036 @item Replace the default implementation of the
7037 @code{System.Stream_Attributes} package with the XDR implementation.
7038 For example on a Unix platform issue the commands:
7040 $ mv s-stratt.adb s-strold.adb
7041 $ mv s-strxdr.adb s-stratt.adb
7045 Rebuild the GNAT run-time library as documented in
7046 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7049 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7052 If an implementation provides additional named predefined integer types,
7053 then the names should end with @samp{Integer} as in
7054 @samp{Long_Integer}. If an implementation provides additional named
7055 predefined floating point types, then the names should end with
7056 @samp{Float} as in @samp{Long_Float}.
7060 @findex Ada.Characters.Handling
7061 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7064 If an implementation provides a localized definition of @code{Character}
7065 or @code{Wide_Character}, then the effects of the subprograms in
7066 @code{Characters.Handling} should reflect the localizations. See also
7069 Followed. GNAT provides no such localized definitions.
7071 @cindex Bounded-length strings
7072 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7075 Bounded string objects should not be implemented by implicit pointers
7076 and dynamic allocation.
7078 Followed. No implicit pointers or dynamic allocation are used.
7080 @cindex Random number generation
7081 @unnumberedsec A.5.2(46-47): Random Number Generation
7084 Any storage associated with an object of type @code{Generator} should be
7085 reclaimed on exit from the scope of the object.
7091 If the generator period is sufficiently long in relation to the number
7092 of distinct initiator values, then each possible value of
7093 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7094 random numbers that does not, in a practical sense, overlap the sequence
7095 initiated by any other value. If this is not possible, then the mapping
7096 between initiator values and generator states should be a rapidly
7097 varying function of the initiator value.
7099 Followed. The generator period is sufficiently long for the first
7100 condition here to hold true.
7102 @findex Get_Immediate
7103 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7106 The @code{Get_Immediate} procedures should be implemented with
7107 unbuffered input. For a device such as a keyboard, input should be
7108 @dfn{available} if a key has already been typed, whereas for a disk
7109 file, input should always be available except at end of file. For a file
7110 associated with a keyboard-like device, any line-editing features of the
7111 underlying operating system should be disabled during the execution of
7112 @code{Get_Immediate}.
7114 Followed on all targets except VxWorks. For VxWorks, there is no way to
7115 provide this functionality that does not result in the input buffer being
7116 flushed before the @code{Get_Immediate} call. A special unit
7117 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7121 @unnumberedsec B.1(39-41): Pragma @code{Export}
7124 If an implementation supports pragma @code{Export} to a given language,
7125 then it should also allow the main subprogram to be written in that
7126 language. It should support some mechanism for invoking the elaboration
7127 of the Ada library units included in the system, and for invoking the
7128 finalization of the environment task. On typical systems, the
7129 recommended mechanism is to provide two subprograms whose link names are
7130 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7131 elaboration code for library units. @code{adafinal} should contain the
7132 finalization code. These subprograms should have no effect the second
7133 and subsequent time they are called.
7139 Automatic elaboration of pre-elaborated packages should be
7140 provided when pragma @code{Export} is supported.
7142 Followed when the main program is in Ada. If the main program is in a
7143 foreign language, then
7144 @code{adainit} must be called to elaborate pre-elaborated
7149 For each supported convention @var{L} other than @code{Intrinsic}, an
7150 implementation should support @code{Import} and @code{Export} pragmas
7151 for objects of @var{L}-compatible types and for subprograms, and pragma
7152 @code{Convention} for @var{L}-eligible types and for subprograms,
7153 presuming the other language has corresponding features. Pragma
7154 @code{Convention} need not be supported for scalar types.
7158 @cindex Package @code{Interfaces}
7160 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7163 For each implementation-defined convention identifier, there should be a
7164 child package of package Interfaces with the corresponding name. This
7165 package should contain any declarations that would be useful for
7166 interfacing to the language (implementation) represented by the
7167 convention. Any declarations useful for interfacing to any language on
7168 the given hardware architecture should be provided directly in
7171 Followed. An additional package not defined
7172 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7173 for interfacing to C++.
7177 An implementation supporting an interface to C, COBOL, or Fortran should
7178 provide the corresponding package or packages described in the following
7181 Followed. GNAT provides all the packages described in this section.
7183 @cindex C, interfacing with
7184 @unnumberedsec B.3(63-71): Interfacing with C
7187 An implementation should support the following interface correspondences
7194 An Ada procedure corresponds to a void-returning C function.
7200 An Ada function corresponds to a non-void C function.
7206 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7213 An Ada @code{in} parameter of an access-to-object type with designated
7214 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7215 where @var{t} is the C type corresponding to the Ada type @var{T}.
7221 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7222 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7223 argument to a C function, where @var{t} is the C type corresponding to
7224 the Ada type @var{T}. In the case of an elementary @code{out} or
7225 @code{in out} parameter, a pointer to a temporary copy is used to
7226 preserve by-copy semantics.
7232 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7233 @code{@var{t}*} argument to a C function, where @var{t} is the C
7234 structure corresponding to the Ada type @var{T}.
7236 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7237 pragma, or Convention, or by explicitly specifying the mechanism for a given
7238 call using an extended import or export pragma.
7242 An Ada parameter of an array type with component type @var{T}, of any
7243 mode, is passed as a @code{@var{t}*} argument to a C function, where
7244 @var{t} is the C type corresponding to the Ada type @var{T}.
7250 An Ada parameter of an access-to-subprogram type is passed as a pointer
7251 to a C function whose prototype corresponds to the designated
7252 subprogram's specification.
7256 @cindex COBOL, interfacing with
7257 @unnumberedsec B.4(95-98): Interfacing with COBOL
7260 An Ada implementation should support the following interface
7261 correspondences between Ada and COBOL@.
7267 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7268 the COBOL type corresponding to @var{T}.
7274 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7275 the corresponding COBOL type.
7281 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7282 COBOL type corresponding to the Ada parameter type; for scalars, a local
7283 copy is used if necessary to ensure by-copy semantics.
7287 @cindex Fortran, interfacing with
7288 @unnumberedsec B.5(22-26): Interfacing with Fortran
7291 An Ada implementation should support the following interface
7292 correspondences between Ada and Fortran:
7298 An Ada procedure corresponds to a Fortran subroutine.
7304 An Ada function corresponds to a Fortran function.
7310 An Ada parameter of an elementary, array, or record type @var{T} is
7311 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7312 the Fortran type corresponding to the Ada type @var{T}, and where the
7313 INTENT attribute of the corresponding dummy argument matches the Ada
7314 formal parameter mode; the Fortran implementation's parameter passing
7315 conventions are used. For elementary types, a local copy is used if
7316 necessary to ensure by-copy semantics.
7322 An Ada parameter of an access-to-subprogram type is passed as a
7323 reference to a Fortran procedure whose interface corresponds to the
7324 designated subprogram's specification.
7328 @cindex Machine operations
7329 @unnumberedsec C.1(3-5): Access to Machine Operations
7332 The machine code or intrinsic support should allow access to all
7333 operations normally available to assembly language programmers for the
7334 target environment, including privileged instructions, if any.
7340 The interfacing pragmas (see Annex B) should support interface to
7341 assembler; the default assembler should be associated with the
7342 convention identifier @code{Assembler}.
7348 If an entity is exported to assembly language, then the implementation
7349 should allocate it at an addressable location, and should ensure that it
7350 is retained by the linking process, even if not otherwise referenced
7351 from the Ada code. The implementation should assume that any call to a
7352 machine code or assembler subprogram is allowed to read or update every
7353 object that is specified as exported.
7357 @unnumberedsec C.1(10-16): Access to Machine Operations
7360 The implementation should ensure that little or no overhead is
7361 associated with calling intrinsic and machine-code subprograms.
7363 Followed for both intrinsics and machine-code subprograms.
7367 It is recommended that intrinsic subprograms be provided for convenient
7368 access to any machine operations that provide special capabilities or
7369 efficiency and that are not otherwise available through the language
7372 Followed. A full set of machine operation intrinsic subprograms is provided.
7376 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7377 swap, decrement and test, enqueue/dequeue.
7379 Followed on any target supporting such operations.
7383 Standard numeric functions---e.g.@:, sin, log.
7385 Followed on any target supporting such operations.
7389 String manipulation operations---e.g.@:, translate and test.
7391 Followed on any target supporting such operations.
7395 Vector operations---e.g.@:, compare vector against thresholds.
7397 Followed on any target supporting such operations.
7401 Direct operations on I/O ports.
7403 Followed on any target supporting such operations.
7405 @cindex Interrupt support
7406 @unnumberedsec C.3(28): Interrupt Support
7409 If the @code{Ceiling_Locking} policy is not in effect, the
7410 implementation should provide means for the application to specify which
7411 interrupts are to be blocked during protected actions, if the underlying
7412 system allows for a finer-grain control of interrupt blocking.
7414 Followed. The underlying system does not allow for finer-grain control
7415 of interrupt blocking.
7417 @cindex Protected procedure handlers
7418 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7421 Whenever possible, the implementation should allow interrupt handlers to
7422 be called directly by the hardware.
7426 This is never possible under IRIX, so this is followed by default.
7428 Followed on any target where the underlying operating system permits
7433 Whenever practical, violations of any
7434 implementation-defined restrictions should be detected before run time.
7436 Followed. Compile time warnings are given when possible.
7438 @cindex Package @code{Interrupts}
7440 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7444 If implementation-defined forms of interrupt handler procedures are
7445 supported, such as protected procedures with parameters, then for each
7446 such form of a handler, a type analogous to @code{Parameterless_Handler}
7447 should be specified in a child package of @code{Interrupts}, with the
7448 same operations as in the predefined package Interrupts.
7452 @cindex Pre-elaboration requirements
7453 @unnumberedsec C.4(14): Pre-elaboration Requirements
7456 It is recommended that pre-elaborated packages be implemented in such a
7457 way that there should be little or no code executed at run time for the
7458 elaboration of entities not already covered by the Implementation
7461 Followed. Executable code is generated in some cases, e.g.@: loops
7462 to initialize large arrays.
7464 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7468 If the pragma applies to an entity, then the implementation should
7469 reduce the amount of storage used for storing names associated with that
7474 @cindex Package @code{Task_Attributes}
7475 @findex Task_Attributes
7476 @unnumberedsec C.7.2(30): The Package Task_Attributes
7479 Some implementations are targeted to domains in which memory use at run
7480 time must be completely deterministic. For such implementations, it is
7481 recommended that the storage for task attributes will be pre-allocated
7482 statically and not from the heap. This can be accomplished by either
7483 placing restrictions on the number and the size of the task's
7484 attributes, or by using the pre-allocated storage for the first @var{N}
7485 attribute objects, and the heap for the others. In the latter case,
7486 @var{N} should be documented.
7488 Not followed. This implementation is not targeted to such a domain.
7490 @cindex Locking Policies
7491 @unnumberedsec D.3(17): Locking Policies
7495 The implementation should use names that end with @samp{_Locking} for
7496 locking policies defined by the implementation.
7498 Followed. A single implementation-defined locking policy is defined,
7499 whose name (@code{Inheritance_Locking}) follows this suggestion.
7501 @cindex Entry queuing policies
7502 @unnumberedsec D.4(16): Entry Queuing Policies
7505 Names that end with @samp{_Queuing} should be used
7506 for all implementation-defined queuing policies.
7508 Followed. No such implementation-defined queuing policies exist.
7510 @cindex Preemptive abort
7511 @unnumberedsec D.6(9-10): Preemptive Abort
7514 Even though the @code{abort_statement} is included in the list of
7515 potentially blocking operations (see 9.5.1), it is recommended that this
7516 statement be implemented in a way that never requires the task executing
7517 the @code{abort_statement} to block.
7523 On a multi-processor, the delay associated with aborting a task on
7524 another processor should be bounded; the implementation should use
7525 periodic polling, if necessary, to achieve this.
7529 @cindex Tasking restrictions
7530 @unnumberedsec D.7(21): Tasking Restrictions
7533 When feasible, the implementation should take advantage of the specified
7534 restrictions to produce a more efficient implementation.
7536 GNAT currently takes advantage of these restrictions by providing an optimized
7537 run time when the Ravenscar profile and the GNAT restricted run time set
7538 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7539 pragma @code{Profile (Restricted)} for more details.
7541 @cindex Time, monotonic
7542 @unnumberedsec D.8(47-49): Monotonic Time
7545 When appropriate, implementations should provide configuration
7546 mechanisms to change the value of @code{Tick}.
7548 Such configuration mechanisms are not appropriate to this implementation
7549 and are thus not supported.
7553 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7554 be implemented as transformations of the same time base.
7560 It is recommended that the @dfn{best} time base which exists in
7561 the underlying system be available to the application through
7562 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7566 @cindex Partition communication subsystem
7568 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7571 Whenever possible, the PCS on the called partition should allow for
7572 multiple tasks to call the RPC-receiver with different messages and
7573 should allow them to block until the corresponding subprogram body
7576 Followed by GLADE, a separately supplied PCS that can be used with
7581 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7582 should raise @code{Storage_Error} if it runs out of space trying to
7583 write the @code{Item} into the stream.
7585 Followed by GLADE, a separately supplied PCS that can be used with
7588 @cindex COBOL support
7589 @unnumberedsec F(7): COBOL Support
7592 If COBOL (respectively, C) is widely supported in the target
7593 environment, implementations supporting the Information Systems Annex
7594 should provide the child package @code{Interfaces.COBOL} (respectively,
7595 @code{Interfaces.C}) specified in Annex B and should support a
7596 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7597 pragmas (see Annex B), thus allowing Ada programs to interface with
7598 programs written in that language.
7602 @cindex Decimal radix support
7603 @unnumberedsec F.1(2): Decimal Radix Support
7606 Packed decimal should be used as the internal representation for objects
7607 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7609 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7613 @unnumberedsec G: Numerics
7616 If Fortran (respectively, C) is widely supported in the target
7617 environment, implementations supporting the Numerics Annex
7618 should provide the child package @code{Interfaces.Fortran} (respectively,
7619 @code{Interfaces.C}) specified in Annex B and should support a
7620 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7621 pragmas (see Annex B), thus allowing Ada programs to interface with
7622 programs written in that language.
7626 @cindex Complex types
7627 @unnumberedsec G.1.1(56-58): Complex Types
7630 Because the usual mathematical meaning of multiplication of a complex
7631 operand and a real operand is that of the scaling of both components of
7632 the former by the latter, an implementation should not perform this
7633 operation by first promoting the real operand to complex type and then
7634 performing a full complex multiplication. In systems that, in the
7635 future, support an Ada binding to IEC 559:1989, the latter technique
7636 will not generate the required result when one of the components of the
7637 complex operand is infinite. (Explicit multiplication of the infinite
7638 component by the zero component obtained during promotion yields a NaN
7639 that propagates into the final result.) Analogous advice applies in the
7640 case of multiplication of a complex operand and a pure-imaginary
7641 operand, and in the case of division of a complex operand by a real or
7642 pure-imaginary operand.
7648 Similarly, because the usual mathematical meaning of addition of a
7649 complex operand and a real operand is that the imaginary operand remains
7650 unchanged, an implementation should not perform this operation by first
7651 promoting the real operand to complex type and then performing a full
7652 complex addition. In implementations in which the @code{Signed_Zeros}
7653 attribute of the component type is @code{True} (and which therefore
7654 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7655 predefined arithmetic operations), the latter technique will not
7656 generate the required result when the imaginary component of the complex
7657 operand is a negatively signed zero. (Explicit addition of the negative
7658 zero to the zero obtained during promotion yields a positive zero.)
7659 Analogous advice applies in the case of addition of a complex operand
7660 and a pure-imaginary operand, and in the case of subtraction of a
7661 complex operand and a real or pure-imaginary operand.
7667 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7668 attempt to provide a rational treatment of the signs of zero results and
7669 result components. As one example, the result of the @code{Argument}
7670 function should have the sign of the imaginary component of the
7671 parameter @code{X} when the point represented by that parameter lies on
7672 the positive real axis; as another, the sign of the imaginary component
7673 of the @code{Compose_From_Polar} function should be the same as
7674 (respectively, the opposite of) that of the @code{Argument} parameter when that
7675 parameter has a value of zero and the @code{Modulus} parameter has a
7676 nonnegative (respectively, negative) value.
7680 @cindex Complex elementary functions
7681 @unnumberedsec G.1.2(49): Complex Elementary Functions
7684 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7685 @code{True} should attempt to provide a rational treatment of the signs
7686 of zero results and result components. For example, many of the complex
7687 elementary functions have components that are odd functions of one of
7688 the parameter components; in these cases, the result component should
7689 have the sign of the parameter component at the origin. Other complex
7690 elementary functions have zero components whose sign is opposite that of
7691 a parameter component at the origin, or is always positive or always
7696 @cindex Accuracy requirements
7697 @unnumberedsec G.2.4(19): Accuracy Requirements
7700 The versions of the forward trigonometric functions without a
7701 @code{Cycle} parameter should not be implemented by calling the
7702 corresponding version with a @code{Cycle} parameter of
7703 @code{2.0*Numerics.Pi}, since this will not provide the required
7704 accuracy in some portions of the domain. For the same reason, the
7705 version of @code{Log} without a @code{Base} parameter should not be
7706 implemented by calling the corresponding version with a @code{Base}
7707 parameter of @code{Numerics.e}.
7711 @cindex Complex arithmetic accuracy
7712 @cindex Accuracy, complex arithmetic
7713 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7717 The version of the @code{Compose_From_Polar} function without a
7718 @code{Cycle} parameter should not be implemented by calling the
7719 corresponding version with a @code{Cycle} parameter of
7720 @code{2.0*Numerics.Pi}, since this will not provide the required
7721 accuracy in some portions of the domain.
7725 @c -----------------------------------------
7726 @node Implementation Defined Characteristics
7727 @chapter Implementation Defined Characteristics
7730 In addition to the implementation dependent pragmas and attributes, and
7731 the implementation advice, there are a number of other Ada features
7732 that are potentially implementation dependent. These are mentioned
7733 throughout the Ada Reference Manual, and are summarized in Annex M@.
7735 A requirement for conforming Ada compilers is that they provide
7736 documentation describing how the implementation deals with each of these
7737 issues. In this chapter, you will find each point in Annex M listed
7738 followed by a description in italic font of how GNAT
7742 implementation on IRIX 5.3 operating system or greater
7744 handles the implementation dependence.
7746 You can use this chapter as a guide to minimizing implementation
7747 dependent features in your programs if portability to other compilers
7748 and other operating systems is an important consideration. The numbers
7749 in each section below correspond to the paragraph number in the Ada
7755 @strong{2}. Whether or not each recommendation given in Implementation
7756 Advice is followed. See 1.1.2(37).
7759 @xref{Implementation Advice}.
7764 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7767 The complexity of programs that can be processed is limited only by the
7768 total amount of available virtual memory, and disk space for the
7769 generated object files.
7774 @strong{4}. Variations from the standard that are impractical to avoid
7775 given the implementation's execution environment. See 1.1.3(6).
7778 There are no variations from the standard.
7783 @strong{5}. Which @code{code_statement}s cause external
7784 interactions. See 1.1.3(10).
7787 Any @code{code_statement} can potentially cause external interactions.
7792 @strong{6}. The coded representation for the text of an Ada
7793 program. See 2.1(4).
7796 See separate section on source representation.
7801 @strong{7}. The control functions allowed in comments. See 2.1(14).
7804 See separate section on source representation.
7809 @strong{8}. The representation for an end of line. See 2.2(2).
7812 See separate section on source representation.
7817 @strong{9}. Maximum supported line length and lexical element
7818 length. See 2.2(15).
7821 The maximum line length is 255 characters and the maximum length of a
7822 lexical element is also 255 characters.
7827 @strong{10}. Implementation defined pragmas. See 2.8(14).
7831 @xref{Implementation Defined Pragmas}.
7836 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
7839 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7840 parameter, checks that the optimization flag is set, and aborts if it is
7846 @strong{12}. The sequence of characters of the value returned by
7847 @code{@var{S}'Image} when some of the graphic characters of
7848 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
7852 The sequence of characters is as defined by the wide character encoding
7853 method used for the source. See section on source representation for
7859 @strong{13}. The predefined integer types declared in
7860 @code{Standard}. See 3.5.4(25).
7864 @item Short_Short_Integer
7867 (Short) 16 bit signed
7871 64 bit signed (Alpha OpenVMS only)
7872 32 bit signed (all other targets)
7873 @item Long_Long_Integer
7880 @strong{14}. Any nonstandard integer types and the operators defined
7881 for them. See 3.5.4(26).
7884 There are no nonstandard integer types.
7889 @strong{15}. Any nonstandard real types and the operators defined for
7893 There are no nonstandard real types.
7898 @strong{16}. What combinations of requested decimal precision and range
7899 are supported for floating point types. See 3.5.7(7).
7902 The precision and range is as defined by the IEEE standard.
7907 @strong{17}. The predefined floating point types declared in
7908 @code{Standard}. See 3.5.7(16).
7915 (Short) 32 bit IEEE short
7918 @item Long_Long_Float
7919 64 bit IEEE long (80 bit IEEE long on x86 processors)
7925 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
7928 @code{Fine_Delta} is 2**(@minus{}63)
7933 @strong{19}. What combinations of small, range, and digits are
7934 supported for fixed point types. See 3.5.9(10).
7937 Any combinations are permitted that do not result in a small less than
7938 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7939 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7940 is 64 bits (true of all architectures except ia32), then the output from
7941 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
7942 is because floating-point conversions are used to convert fixed point.
7947 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
7948 within an unnamed @code{block_statement}. See 3.9(10).
7951 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7952 decimal integer are allocated.
7957 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
7960 @xref{Implementation Defined Attributes}.
7965 @strong{22}. Any implementation-defined time types. See 9.6(6).
7968 There are no implementation-defined time types.
7973 @strong{23}. The time base associated with relative delays.
7976 See 9.6(20). The time base used is that provided by the C library
7977 function @code{gettimeofday}.
7982 @strong{24}. The time base of the type @code{Calendar.Time}. See
7986 The time base used is that provided by the C library function
7987 @code{gettimeofday}.
7992 @strong{25}. The time zone used for package @code{Calendar}
7993 operations. See 9.6(24).
7996 The time zone used by package @code{Calendar} is the current system time zone
7997 setting for local time, as accessed by the C library function
8003 @strong{26}. Any limit on @code{delay_until_statements} of
8004 @code{select_statements}. See 9.6(29).
8007 There are no such limits.
8012 @strong{27}. Whether or not two non-overlapping parts of a composite
8013 object are independently addressable, in the case where packing, record
8014 layout, or @code{Component_Size} is specified for the object. See
8018 Separate components are independently addressable if they do not share
8019 overlapping storage units.
8024 @strong{28}. The representation for a compilation. See 10.1(2).
8027 A compilation is represented by a sequence of files presented to the
8028 compiler in a single invocation of the @command{gcc} command.
8033 @strong{29}. Any restrictions on compilations that contain multiple
8034 compilation_units. See 10.1(4).
8037 No single file can contain more than one compilation unit, but any
8038 sequence of files can be presented to the compiler as a single
8044 @strong{30}. The mechanisms for creating an environment and for adding
8045 and replacing compilation units. See 10.1.4(3).
8048 See separate section on compilation model.
8053 @strong{31}. The manner of explicitly assigning library units to a
8054 partition. See 10.2(2).
8057 If a unit contains an Ada main program, then the Ada units for the partition
8058 are determined by recursive application of the rules in the Ada Reference
8059 Manual section 10.2(2-6). In other words, the Ada units will be those that
8060 are needed by the main program, and then this definition of need is applied
8061 recursively to those units, and the partition contains the transitive
8062 closure determined by this relationship. In short, all the necessary units
8063 are included, with no need to explicitly specify the list. If additional
8064 units are required, e.g.@: by foreign language units, then all units must be
8065 mentioned in the context clause of one of the needed Ada units.
8067 If the partition contains no main program, or if the main program is in
8068 a language other than Ada, then GNAT
8069 provides the binder options @option{-z} and @option{-n} respectively, and in
8070 this case a list of units can be explicitly supplied to the binder for
8071 inclusion in the partition (all units needed by these units will also
8072 be included automatically). For full details on the use of these
8073 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8074 @value{EDITION} User's Guide}.
8079 @strong{32}. The implementation-defined means, if any, of specifying
8080 which compilation units are needed by a given compilation unit. See
8084 The units needed by a given compilation unit are as defined in
8085 the Ada Reference Manual section 10.2(2-6). There are no
8086 implementation-defined pragmas or other implementation-defined
8087 means for specifying needed units.
8092 @strong{33}. The manner of designating the main subprogram of a
8093 partition. See 10.2(7).
8096 The main program is designated by providing the name of the
8097 corresponding @file{ALI} file as the input parameter to the binder.
8102 @strong{34}. The order of elaboration of @code{library_items}. See
8106 The first constraint on ordering is that it meets the requirements of
8107 Chapter 10 of the Ada Reference Manual. This still leaves some
8108 implementation dependent choices, which are resolved by first
8109 elaborating bodies as early as possible (i.e., in preference to specs
8110 where there is a choice), and second by evaluating the immediate with
8111 clauses of a unit to determine the probably best choice, and
8112 third by elaborating in alphabetical order of unit names
8113 where a choice still remains.
8118 @strong{35}. Parameter passing and function return for the main
8119 subprogram. See 10.2(21).
8122 The main program has no parameters. It may be a procedure, or a function
8123 returning an integer type. In the latter case, the returned integer
8124 value is the return code of the program (overriding any value that
8125 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8130 @strong{36}. The mechanisms for building and running partitions. See
8134 GNAT itself supports programs with only a single partition. The GNATDIST
8135 tool provided with the GLADE package (which also includes an implementation
8136 of the PCS) provides a completely flexible method for building and running
8137 programs consisting of multiple partitions. See the separate GLADE manual
8143 @strong{37}. The details of program execution, including program
8144 termination. See 10.2(25).
8147 See separate section on compilation model.
8152 @strong{38}. The semantics of any non-active partitions supported by the
8153 implementation. See 10.2(28).
8156 Passive partitions are supported on targets where shared memory is
8157 provided by the operating system. See the GLADE reference manual for
8163 @strong{39}. The information returned by @code{Exception_Message}. See
8167 Exception message returns the null string unless a specific message has
8168 been passed by the program.
8173 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8174 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8177 Blocks have implementation defined names of the form @code{B@var{nnn}}
8178 where @var{nnn} is an integer.
8183 @strong{41}. The information returned by
8184 @code{Exception_Information}. See 11.4.1(13).
8187 @code{Exception_Information} returns a string in the following format:
8190 @emph{Exception_Name:} nnnnn
8191 @emph{Message:} mmmmm
8193 @emph{Call stack traceback locations:}
8194 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8202 @code{nnnn} is the fully qualified name of the exception in all upper
8203 case letters. This line is always present.
8206 @code{mmmm} is the message (this line present only if message is non-null)
8209 @code{ppp} is the Process Id value as a decimal integer (this line is
8210 present only if the Process Id is nonzero). Currently we are
8211 not making use of this field.
8214 The Call stack traceback locations line and the following values
8215 are present only if at least one traceback location was recorded.
8216 The values are given in C style format, with lower case letters
8217 for a-f, and only as many digits present as are necessary.
8221 The line terminator sequence at the end of each line, including
8222 the last line is a single @code{LF} character (@code{16#0A#}).
8227 @strong{42}. Implementation-defined check names. See 11.5(27).
8230 The implementation defined check name Alignment_Check controls checking of
8231 address clause values for proper alignment (that is, the address supplied
8232 must be consistent with the alignment of the type).
8234 In addition, a user program can add implementation-defined check names
8235 by means of the pragma Check_Name.
8240 @strong{43}. The interpretation of each aspect of representation. See
8244 See separate section on data representations.
8249 @strong{44}. Any restrictions placed upon representation items. See
8253 See separate section on data representations.
8258 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8262 Size for an indefinite subtype is the maximum possible size, except that
8263 for the case of a subprogram parameter, the size of the parameter object
8269 @strong{46}. The default external representation for a type tag. See
8273 The default external representation for a type tag is the fully expanded
8274 name of the type in upper case letters.
8279 @strong{47}. What determines whether a compilation unit is the same in
8280 two different partitions. See 13.3(76).
8283 A compilation unit is the same in two different partitions if and only
8284 if it derives from the same source file.
8289 @strong{48}. Implementation-defined components. See 13.5.1(15).
8292 The only implementation defined component is the tag for a tagged type,
8293 which contains a pointer to the dispatching table.
8298 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8299 ordering. See 13.5.3(5).
8302 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8303 implementation, so no non-default bit ordering is supported. The default
8304 bit ordering corresponds to the natural endianness of the target architecture.
8309 @strong{50}. The contents of the visible part of package @code{System}
8310 and its language-defined children. See 13.7(2).
8313 See the definition of these packages in files @file{system.ads} and
8314 @file{s-stoele.ads}.
8319 @strong{51}. The contents of the visible part of package
8320 @code{System.Machine_Code}, and the meaning of
8321 @code{code_statements}. See 13.8(7).
8324 See the definition and documentation in file @file{s-maccod.ads}.
8329 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8332 Unchecked conversion between types of the same size
8333 results in an uninterpreted transmission of the bits from one type
8334 to the other. If the types are of unequal sizes, then in the case of
8335 discrete types, a shorter source is first zero or sign extended as
8336 necessary, and a shorter target is simply truncated on the left.
8337 For all non-discrete types, the source is first copied if necessary
8338 to ensure that the alignment requirements of the target are met, then
8339 a pointer is constructed to the source value, and the result is obtained
8340 by dereferencing this pointer after converting it to be a pointer to the
8341 target type. Unchecked conversions where the target subtype is an
8342 unconstrained array are not permitted. If the target alignment is
8343 greater than the source alignment, then a copy of the result is
8344 made with appropriate alignment
8349 @strong{53}. The manner of choosing a storage pool for an access type
8350 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8353 There are 3 different standard pools used by the compiler when
8354 @code{Storage_Pool} is not specified depending whether the type is local
8355 to a subprogram or defined at the library level and whether
8356 @code{Storage_Size}is specified or not. See documentation in the runtime
8357 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8358 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8359 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8365 @strong{54}. Whether or not the implementation provides user-accessible
8366 names for the standard pool type(s). See 13.11(17).
8370 See documentation in the sources of the run time mentioned in paragraph
8371 @strong{53} . All these pools are accessible by means of @code{with}'ing
8377 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8380 @code{Storage_Size} is measured in storage units, and refers to the
8381 total space available for an access type collection, or to the primary
8382 stack space for a task.
8387 @strong{56}. Implementation-defined aspects of storage pools. See
8391 See documentation in the sources of the run time mentioned in paragraph
8392 @strong{53} for details on GNAT-defined aspects of storage pools.
8397 @strong{57}. The set of restrictions allowed in a pragma
8398 @code{Restrictions}. See 13.12(7).
8401 All RM defined Restriction identifiers are implemented. The following
8402 additional restriction identifiers are provided. There are two separate
8403 lists of implementation dependent restriction identifiers. The first
8404 set requires consistency throughout a partition (in other words, if the
8405 restriction identifier is used for any compilation unit in the partition,
8406 then all compilation units in the partition must obey the restriction.
8410 @item Simple_Barriers
8411 @findex Simple_Barriers
8412 This restriction ensures at compile time that barriers in entry declarations
8413 for protected types are restricted to either static boolean expressions or
8414 references to simple boolean variables defined in the private part of the
8415 protected type. No other form of entry barriers is permitted. This is one
8416 of the restrictions of the Ravenscar profile for limited tasking (see also
8417 pragma @code{Profile (Ravenscar)}).
8419 @item Max_Entry_Queue_Length => Expr
8420 @findex Max_Entry_Queue_Length
8421 This restriction is a declaration that any protected entry compiled in
8422 the scope of the restriction has at most the specified number of
8423 tasks waiting on the entry
8424 at any one time, and so no queue is required. This restriction is not
8425 checked at compile time. A program execution is erroneous if an attempt
8426 is made to queue more than the specified number of tasks on such an entry.
8430 This restriction ensures at compile time that there is no implicit or
8431 explicit dependence on the package @code{Ada.Calendar}.
8433 @item No_Default_Initialization
8434 @findex No_Default_Initialization
8436 This restriction prohibits any instance of default initialization of variables.
8437 The binder implements a consistency rule which prevents any unit compiled
8438 without the restriction from with'ing a unit with the restriction (this allows
8439 the generation of initialization procedures to be skipped, since you can be
8440 sure that no call is ever generated to an initialization procedure in a unit
8441 with the restriction active). If used in conjunction with Initialize_Scalars or
8442 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8443 without a specific initializer (including the case of OUT scalar parameters).
8445 @item No_Direct_Boolean_Operators
8446 @findex No_Direct_Boolean_Operators
8447 This restriction ensures that no logical (and/or/xor) are used on
8448 operands of type Boolean (or any type derived
8449 from Boolean). This is intended for use in safety critical programs
8450 where the certification protocol requires the use of short-circuit
8451 (and then, or else) forms for all composite boolean operations.
8453 @item No_Dispatching_Calls
8454 @findex No_Dispatching_Calls
8455 This restriction ensures at compile time that the code generated by the
8456 compiler involves no dispatching calls. The use of this restriction allows the
8457 safe use of record extensions, classwide membership tests and other classwide
8458 features not involving implicit dispatching. This restriction ensures that
8459 the code contains no indirect calls through a dispatching mechanism. Note that
8460 this includes internally-generated calls created by the compiler, for example
8461 in the implementation of class-wide objects assignments. The
8462 membership test is allowed in the presence of this restriction, because its
8463 implementation requires no dispatching.
8464 This restriction is comparable to the official Ada restriction
8465 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8466 all classwide constructs that do not imply dispatching.
8467 The following example indicates constructs that violate this restriction.
8471 type T is tagged record
8474 procedure P (X : T);
8476 type DT is new T with record
8477 More_Data : Natural;
8479 procedure Q (X : DT);
8483 procedure Example is
8484 procedure Test (O : T'Class) is
8485 N : Natural := O'Size;-- Error: Dispatching call
8486 C : T'Class := O; -- Error: implicit Dispatching Call
8488 if O in DT'Class then -- OK : Membership test
8489 Q (DT (O)); -- OK : Type conversion plus direct call
8491 P (O); -- Error: Dispatching call
8497 P (Obj); -- OK : Direct call
8498 P (T (Obj)); -- OK : Type conversion plus direct call
8499 P (T'Class (Obj)); -- Error: Dispatching call
8501 Test (Obj); -- OK : Type conversion
8503 if Obj in T'Class then -- OK : Membership test
8509 @item No_Dynamic_Attachment
8510 @findex No_Dynamic_Attachment
8511 This restriction ensures that there is no call to any of the operations
8512 defined in package Ada.Interrupts.
8514 @item No_Enumeration_Maps
8515 @findex No_Enumeration_Maps
8516 This restriction ensures at compile time that no operations requiring
8517 enumeration maps are used (that is Image and Value attributes applied
8518 to enumeration types).
8520 @item No_Entry_Calls_In_Elaboration_Code
8521 @findex No_Entry_Calls_In_Elaboration_Code
8522 This restriction ensures at compile time that no task or protected entry
8523 calls are made during elaboration code. As a result of the use of this
8524 restriction, the compiler can assume that no code past an accept statement
8525 in a task can be executed at elaboration time.
8527 @item No_Exception_Handlers
8528 @findex No_Exception_Handlers
8529 This restriction ensures at compile time that there are no explicit
8530 exception handlers. It also indicates that no exception propagation will
8531 be provided. In this mode, exceptions may be raised but will result in
8532 an immediate call to the last chance handler, a routine that the user
8533 must define with the following profile:
8535 @smallexample @c ada
8536 procedure Last_Chance_Handler
8537 (Source_Location : System.Address; Line : Integer);
8538 pragma Export (C, Last_Chance_Handler,
8539 "__gnat_last_chance_handler");
8542 The parameter is a C null-terminated string representing a message to be
8543 associated with the exception (typically the source location of the raise
8544 statement generated by the compiler). The Line parameter when nonzero
8545 represents the line number in the source program where the raise occurs.
8547 @item No_Exception_Propagation
8548 @findex No_Exception_Propagation
8549 This restriction guarantees that exceptions are never propagated to an outer
8550 subprogram scope). The only case in which an exception may be raised is when
8551 the handler is statically in the same subprogram, so that the effect of a raise
8552 is essentially like a goto statement. Any other raise statement (implicit or
8553 explicit) will be considered unhandled. Exception handlers are allowed, but may
8554 not contain an exception occurrence identifier (exception choice). In addition
8555 use of the package GNAT.Current_Exception is not permitted, and reraise
8556 statements (raise with no operand) are not permitted.
8558 @item No_Exception_Registration
8559 @findex No_Exception_Registration
8560 This restriction ensures at compile time that no stream operations for
8561 types Exception_Id or Exception_Occurrence are used. This also makes it
8562 impossible to pass exceptions to or from a partition with this restriction
8563 in a distributed environment. If this exception is active, then the generated
8564 code is simplified by omitting the otherwise-required global registration
8565 of exceptions when they are declared.
8567 @item No_Implicit_Conditionals
8568 @findex No_Implicit_Conditionals
8569 This restriction ensures that the generated code does not contain any
8570 implicit conditionals, either by modifying the generated code where possible,
8571 or by rejecting any construct that would otherwise generate an implicit
8572 conditional. Note that this check does not include run time constraint
8573 checks, which on some targets may generate implicit conditionals as
8574 well. To control the latter, constraint checks can be suppressed in the
8575 normal manner. Constructs generating implicit conditionals include comparisons
8576 of composite objects and the Max/Min attributes.
8578 @item No_Implicit_Dynamic_Code
8579 @findex No_Implicit_Dynamic_Code
8581 This restriction prevents the compiler from building ``trampolines''.
8582 This is a structure that is built on the stack and contains dynamic
8583 code to be executed at run time. On some targets, a trampoline is
8584 built for the following features: @code{Access},
8585 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8586 nested task bodies; primitive operations of nested tagged types.
8587 Trampolines do not work on machines that prevent execution of stack
8588 data. For example, on windows systems, enabling DEP (data execution
8589 protection) will cause trampolines to raise an exception.
8590 Trampolines are also quite slow at run time.
8592 On many targets, trampolines have been largely eliminated. Look at the
8593 version of system.ads for your target --- if it has
8594 Always_Compatible_Rep equal to False, then trampolines are largely
8595 eliminated. In particular, a trampoline is built for the following
8596 features: @code{Address} of a nested subprogram;
8597 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8598 but only if pragma Favor_Top_Level applies, or the access type has a
8599 foreign-language convention; primitive operations of nested tagged
8602 @item No_Implicit_Loops
8603 @findex No_Implicit_Loops
8604 This restriction ensures that the generated code does not contain any
8605 implicit @code{for} loops, either by modifying
8606 the generated code where possible,
8607 or by rejecting any construct that would otherwise generate an implicit
8608 @code{for} loop. If this restriction is active, it is possible to build
8609 large array aggregates with all static components without generating an
8610 intermediate temporary, and without generating a loop to initialize individual
8611 components. Otherwise, a loop is created for arrays larger than about 5000
8614 @item No_Initialize_Scalars
8615 @findex No_Initialize_Scalars
8616 This restriction ensures that no unit in the partition is compiled with
8617 pragma Initialize_Scalars. This allows the generation of more efficient
8618 code, and in particular eliminates dummy null initialization routines that
8619 are otherwise generated for some record and array types.
8621 @item No_Local_Protected_Objects
8622 @findex No_Local_Protected_Objects
8623 This restriction ensures at compile time that protected objects are
8624 only declared at the library level.
8626 @item No_Protected_Type_Allocators
8627 @findex No_Protected_Type_Allocators
8628 This restriction ensures at compile time that there are no allocator
8629 expressions that attempt to allocate protected objects.
8631 @item No_Secondary_Stack
8632 @findex No_Secondary_Stack
8633 This restriction ensures at compile time that the generated code does not
8634 contain any reference to the secondary stack. The secondary stack is used
8635 to implement functions returning unconstrained objects (arrays or records)
8638 @item No_Select_Statements
8639 @findex No_Select_Statements
8640 This restriction ensures at compile time no select statements of any kind
8641 are permitted, that is the keyword @code{select} may not appear.
8642 This is one of the restrictions of the Ravenscar
8643 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8645 @item No_Standard_Storage_Pools
8646 @findex No_Standard_Storage_Pools
8647 This restriction ensures at compile time that no access types
8648 use the standard default storage pool. Any access type declared must
8649 have an explicit Storage_Pool attribute defined specifying a
8650 user-defined storage pool.
8654 This restriction ensures at compile/bind time that there are no
8655 stream objects created and no use of stream attributes.
8656 This restriction does not forbid dependences on the package
8657 @code{Ada.Streams}. So it is permissible to with
8658 @code{Ada.Streams} (or another package that does so itself)
8659 as long as no actual stream objects are created and no
8660 stream attributes are used.
8662 Note that the use of restriction allows optimization of tagged types,
8663 since they do not need to worry about dispatching stream operations.
8664 To take maximum advantage of this space-saving optimization, any
8665 unit declaring a tagged type should be compiled with the restriction,
8666 though this is not required.
8668 @item No_Task_Attributes_Package
8669 @findex No_Task_Attributes_Package
8670 This restriction ensures at compile time that there are no implicit or
8671 explicit dependencies on the package @code{Ada.Task_Attributes}.
8673 @item No_Task_Termination
8674 @findex No_Task_Termination
8675 This restriction ensures at compile time that no terminate alternatives
8676 appear in any task body.
8680 This restriction prevents the declaration of tasks or task types throughout
8681 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8682 except that violations are caught at compile time and cause an error message
8683 to be output either by the compiler or binder.
8685 @item Static_Priorities
8686 @findex Static_Priorities
8687 This restriction ensures at compile time that all priority expressions
8688 are static, and that there are no dependencies on the package
8689 @code{Ada.Dynamic_Priorities}.
8691 @item Static_Storage_Size
8692 @findex Static_Storage_Size
8693 This restriction ensures at compile time that any expression appearing
8694 in a Storage_Size pragma or attribute definition clause is static.
8699 The second set of implementation dependent restriction identifiers
8700 does not require partition-wide consistency.
8701 The restriction may be enforced for a single
8702 compilation unit without any effect on any of the
8703 other compilation units in the partition.
8707 @item No_Elaboration_Code
8708 @findex No_Elaboration_Code
8709 This restriction ensures at compile time that no elaboration code is
8710 generated. Note that this is not the same condition as is enforced
8711 by pragma @code{Preelaborate}. There are cases in which pragma
8712 @code{Preelaborate} still permits code to be generated (e.g.@: code
8713 to initialize a large array to all zeroes), and there are cases of units
8714 which do not meet the requirements for pragma @code{Preelaborate},
8715 but for which no elaboration code is generated. Generally, it is
8716 the case that preelaborable units will meet the restrictions, with
8717 the exception of large aggregates initialized with an others_clause,
8718 and exception declarations (which generate calls to a run-time
8719 registry procedure). This restriction is enforced on
8720 a unit by unit basis, it need not be obeyed consistently
8721 throughout a partition.
8723 In the case of aggregates with others, if the aggregate has a dynamic
8724 size, there is no way to eliminate the elaboration code (such dynamic
8725 bounds would be incompatible with @code{Preelaborate} in any case). If
8726 the bounds are static, then use of this restriction actually modifies
8727 the code choice of the compiler to avoid generating a loop, and instead
8728 generate the aggregate statically if possible, no matter how many times
8729 the data for the others clause must be repeatedly generated.
8731 It is not possible to precisely document
8732 the constructs which are compatible with this restriction, since,
8733 unlike most other restrictions, this is not a restriction on the
8734 source code, but a restriction on the generated object code. For
8735 example, if the source contains a declaration:
8738 Val : constant Integer := X;
8742 where X is not a static constant, it may be possible, depending
8743 on complex optimization circuitry, for the compiler to figure
8744 out the value of X at compile time, in which case this initialization
8745 can be done by the loader, and requires no initialization code. It
8746 is not possible to document the precise conditions under which the
8747 optimizer can figure this out.
8749 Note that this the implementation of this restriction requires full
8750 code generation. If it is used in conjunction with "semantics only"
8751 checking, then some cases of violations may be missed.
8753 @item No_Entry_Queue
8754 @findex No_Entry_Queue
8755 This restriction is a declaration that any protected entry compiled in
8756 the scope of the restriction has at most one task waiting on the entry
8757 at any one time, and so no queue is required. This restriction is not
8758 checked at compile time. A program execution is erroneous if an attempt
8759 is made to queue a second task on such an entry.
8761 @item No_Implementation_Attributes
8762 @findex No_Implementation_Attributes
8763 This restriction checks at compile time that no GNAT-defined attributes
8764 are present. With this restriction, the only attributes that can be used
8765 are those defined in the Ada Reference Manual.
8767 @item No_Implementation_Pragmas
8768 @findex No_Implementation_Pragmas
8769 This restriction checks at compile time that no GNAT-defined pragmas
8770 are present. With this restriction, the only pragmas that can be used
8771 are those defined in the Ada Reference Manual.
8773 @item No_Implementation_Restrictions
8774 @findex No_Implementation_Restrictions
8775 This restriction checks at compile time that no GNAT-defined restriction
8776 identifiers (other than @code{No_Implementation_Restrictions} itself)
8777 are present. With this restriction, the only other restriction identifiers
8778 that can be used are those defined in the Ada Reference Manual.
8780 @item No_Wide_Characters
8781 @findex No_Wide_Characters
8782 This restriction ensures at compile time that no uses of the types
8783 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8785 appear, and that no wide or wide wide string or character literals
8786 appear in the program (that is literals representing characters not in
8787 type @code{Character}.
8794 @strong{58}. The consequences of violating limitations on
8795 @code{Restrictions} pragmas. See 13.12(9).
8798 Restrictions that can be checked at compile time result in illegalities
8799 if violated. Currently there are no other consequences of violating
8805 @strong{59}. The representation used by the @code{Read} and
8806 @code{Write} attributes of elementary types in terms of stream
8807 elements. See 13.13.2(9).
8810 The representation is the in-memory representation of the base type of
8811 the type, using the number of bits corresponding to the
8812 @code{@var{type}'Size} value, and the natural ordering of the machine.
8817 @strong{60}. The names and characteristics of the numeric subtypes
8818 declared in the visible part of package @code{Standard}. See A.1(3).
8821 See items describing the integer and floating-point types supported.
8826 @strong{61}. The accuracy actually achieved by the elementary
8827 functions. See A.5.1(1).
8830 The elementary functions correspond to the functions available in the C
8831 library. Only fast math mode is implemented.
8836 @strong{62}. The sign of a zero result from some of the operators or
8837 functions in @code{Numerics.Generic_Elementary_Functions}, when
8838 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
8841 The sign of zeroes follows the requirements of the IEEE 754 standard on
8847 @strong{63}. The value of
8848 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
8851 Maximum image width is 6864, see library file @file{s-rannum.ads}.
8856 @strong{64}. The value of
8857 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
8860 Maximum image width is 6864, see library file @file{s-rannum.ads}.
8865 @strong{65}. The algorithms for random number generation. See
8869 The algorithm is the Mersenne Twister, as documented in the source file
8870 @file{s-rannum.adb}.
8875 @strong{66}. The string representation of a random number generator's
8876 state. See A.5.2(38).
8879 The value returned by the Image function is the concatenation of
8880 the fixed-width decimal representations of the 624 32-bit integers
8881 of the state vector.
8886 @strong{67}. The minimum time interval between calls to the
8887 time-dependent Reset procedure that are guaranteed to initiate different
8888 random number sequences. See A.5.2(45).
8891 The minimum period between reset calls to guarantee distinct series of
8892 random numbers is one microsecond.
8897 @strong{68}. The values of the @code{Model_Mantissa},
8898 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8899 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8900 Annex is not supported. See A.5.3(72).
8903 See the source file @file{ttypef.ads} for the values of all numeric
8909 @strong{69}. Any implementation-defined characteristics of the
8910 input-output packages. See A.7(14).
8913 There are no special implementation defined characteristics for these
8919 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
8923 All type representations are contiguous, and the @code{Buffer_Size} is
8924 the value of @code{@var{type}'Size} rounded up to the next storage unit
8930 @strong{71}. External files for standard input, standard output, and
8931 standard error See A.10(5).
8934 These files are mapped onto the files provided by the C streams
8935 libraries. See source file @file{i-cstrea.ads} for further details.
8940 @strong{72}. The accuracy of the value produced by @code{Put}. See
8944 If more digits are requested in the output than are represented by the
8945 precision of the value, zeroes are output in the corresponding least
8946 significant digit positions.
8951 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
8952 @code{Command_Name}. See A.15(1).
8955 These are mapped onto the @code{argv} and @code{argc} parameters of the
8956 main program in the natural manner.
8961 @strong{74}. Implementation-defined convention names. See B.1(11).
8964 The following convention names are supported
8972 Synonym for Assembler
8974 Synonym for Assembler
8977 @item C_Pass_By_Copy
8978 Allowed only for record types, like C, but also notes that record
8979 is to be passed by copy rather than reference.
8982 @item C_Plus_Plus (or CPP)
8985 Treated the same as C
8987 Treated the same as C
8991 For support of pragma @code{Import} with convention Intrinsic, see
8992 separate section on Intrinsic Subprograms.
8994 Stdcall (used for Windows implementations only). This convention correspond
8995 to the WINAPI (previously called Pascal convention) C/C++ convention under
8996 Windows. A function with this convention cleans the stack before exit.
9002 Stubbed is a special convention used to indicate that the body of the
9003 subprogram will be entirely ignored. Any call to the subprogram
9004 is converted into a raise of the @code{Program_Error} exception. If a
9005 pragma @code{Import} specifies convention @code{stubbed} then no body need
9006 be present at all. This convention is useful during development for the
9007 inclusion of subprograms whose body has not yet been written.
9011 In addition, all otherwise unrecognized convention names are also
9012 treated as being synonymous with convention C@. In all implementations
9013 except for VMS, use of such other names results in a warning. In VMS
9014 implementations, these names are accepted silently.
9019 @strong{75}. The meaning of link names. See B.1(36).
9022 Link names are the actual names used by the linker.
9027 @strong{76}. The manner of choosing link names when neither the link
9028 name nor the address of an imported or exported entity is specified. See
9032 The default linker name is that which would be assigned by the relevant
9033 external language, interpreting the Ada name as being in all lower case
9039 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
9042 The string passed to @code{Linker_Options} is presented uninterpreted as
9043 an argument to the link command, unless it contains ASCII.NUL characters.
9044 NUL characters if they appear act as argument separators, so for example
9046 @smallexample @c ada
9047 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9051 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9052 linker. The order of linker options is preserved for a given unit. The final
9053 list of options passed to the linker is in reverse order of the elaboration
9054 order. For example, linker options for a body always appear before the options
9055 from the corresponding package spec.
9060 @strong{78}. The contents of the visible part of package
9061 @code{Interfaces} and its language-defined descendants. See B.2(1).
9064 See files with prefix @file{i-} in the distributed library.
9069 @strong{79}. Implementation-defined children of package
9070 @code{Interfaces}. The contents of the visible part of package
9071 @code{Interfaces}. See B.2(11).
9074 See files with prefix @file{i-} in the distributed library.
9079 @strong{80}. The types @code{Floating}, @code{Long_Floating},
9080 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9081 @code{COBOL_Character}; and the initialization of the variables
9082 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9083 @code{Interfaces.COBOL}. See B.4(50).
9090 (Floating) Long_Float
9095 @item Decimal_Element
9097 @item COBOL_Character
9102 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9107 @strong{81}. Support for access to machine instructions. See C.1(1).
9110 See documentation in file @file{s-maccod.ads} in the distributed library.
9115 @strong{82}. Implementation-defined aspects of access to machine
9116 operations. See C.1(9).
9119 See documentation in file @file{s-maccod.ads} in the distributed library.
9124 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
9127 Interrupts are mapped to signals or conditions as appropriate. See
9129 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9130 on the interrupts supported on a particular target.
9135 @strong{84}. Implementation-defined aspects of pre-elaboration. See
9139 GNAT does not permit a partition to be restarted without reloading,
9140 except under control of the debugger.
9145 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9148 Pragma @code{Discard_Names} causes names of enumeration literals to
9149 be suppressed. In the presence of this pragma, the Image attribute
9150 provides the image of the Pos of the literal, and Value accepts
9156 @strong{86}. The result of the @code{Task_Identification.Image}
9157 attribute. See C.7.1(7).
9160 The result of this attribute is a string that identifies
9161 the object or component that denotes a given task. If a variable @code{Var}
9162 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9164 is the hexadecimal representation of the virtual address of the corresponding
9165 task control block. If the variable is an array of tasks, the image of each
9166 task will have the form of an indexed component indicating the position of a
9167 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9168 component of a record, the image of the task will have the form of a selected
9169 component. These rules are fully recursive, so that the image of a task that
9170 is a subcomponent of a composite object corresponds to the expression that
9171 designates this task.
9173 If a task is created by an allocator, its image depends on the context. If the
9174 allocator is part of an object declaration, the rules described above are used
9175 to construct its image, and this image is not affected by subsequent
9176 assignments. If the allocator appears within an expression, the image
9177 includes only the name of the task type.
9179 If the configuration pragma Discard_Names is present, or if the restriction
9180 No_Implicit_Heap_Allocation is in effect, the image reduces to
9181 the numeric suffix, that is to say the hexadecimal representation of the
9182 virtual address of the control block of the task.
9186 @strong{87}. The value of @code{Current_Task} when in a protected entry
9187 or interrupt handler. See C.7.1(17).
9190 Protected entries or interrupt handlers can be executed by any
9191 convenient thread, so the value of @code{Current_Task} is undefined.
9196 @strong{88}. The effect of calling @code{Current_Task} from an entry
9197 body or interrupt handler. See C.7.1(19).
9200 The effect of calling @code{Current_Task} from an entry body or
9201 interrupt handler is to return the identification of the task currently
9207 @strong{89}. Implementation-defined aspects of
9208 @code{Task_Attributes}. See C.7.2(19).
9211 There are no implementation-defined aspects of @code{Task_Attributes}.
9216 @strong{90}. Values of all @code{Metrics}. See D(2).
9219 The metrics information for GNAT depends on the performance of the
9220 underlying operating system. The sources of the run-time for tasking
9221 implementation, together with the output from @option{-gnatG} can be
9222 used to determine the exact sequence of operating systems calls made
9223 to implement various tasking constructs. Together with appropriate
9224 information on the performance of the underlying operating system,
9225 on the exact target in use, this information can be used to determine
9226 the required metrics.
9231 @strong{91}. The declarations of @code{Any_Priority} and
9232 @code{Priority}. See D.1(11).
9235 See declarations in file @file{system.ads}.
9240 @strong{92}. Implementation-defined execution resources. See D.1(15).
9243 There are no implementation-defined execution resources.
9248 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9249 access to a protected object keeps its processor busy. See D.2.1(3).
9252 On a multi-processor, a task that is waiting for access to a protected
9253 object does not keep its processor busy.
9258 @strong{94}. The affect of implementation defined execution resources
9259 on task dispatching. See D.2.1(9).
9264 Tasks map to IRIX threads, and the dispatching policy is as defined by
9265 the IRIX implementation of threads.
9267 Tasks map to threads in the threads package used by GNAT@. Where possible
9268 and appropriate, these threads correspond to native threads of the
9269 underlying operating system.
9274 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9275 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9278 There are no implementation-defined policy-identifiers allowed in this
9284 @strong{96}. Implementation-defined aspects of priority inversion. See
9288 Execution of a task cannot be preempted by the implementation processing
9289 of delay expirations for lower priority tasks.
9294 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9299 Tasks map to IRIX threads, and the dispatching policy is as defined by
9300 the IRIX implementation of threads.
9302 The policy is the same as that of the underlying threads implementation.
9307 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9308 in a pragma @code{Locking_Policy}. See D.3(4).
9311 The only implementation defined policy permitted in GNAT is
9312 @code{Inheritance_Locking}. On targets that support this policy, locking
9313 is implemented by inheritance, i.e.@: the task owning the lock operates
9314 at a priority equal to the highest priority of any task currently
9315 requesting the lock.
9320 @strong{99}. Default ceiling priorities. See D.3(10).
9323 The ceiling priority of protected objects of the type
9324 @code{System.Interrupt_Priority'Last} as described in the Ada
9325 Reference Manual D.3(10),
9330 @strong{100}. The ceiling of any protected object used internally by
9331 the implementation. See D.3(16).
9334 The ceiling priority of internal protected objects is
9335 @code{System.Priority'Last}.
9340 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9343 There are no implementation-defined queuing policies.
9348 @strong{102}. On a multiprocessor, any conditions that cause the
9349 completion of an aborted construct to be delayed later than what is
9350 specified for a single processor. See D.6(3).
9353 The semantics for abort on a multi-processor is the same as on a single
9354 processor, there are no further delays.
9359 @strong{103}. Any operations that implicitly require heap storage
9360 allocation. See D.7(8).
9363 The only operation that implicitly requires heap storage allocation is
9369 @strong{104}. Implementation-defined aspects of pragma
9370 @code{Restrictions}. See D.7(20).
9373 There are no such implementation-defined aspects.
9378 @strong{105}. Implementation-defined aspects of package
9379 @code{Real_Time}. See D.8(17).
9382 There are no implementation defined aspects of package @code{Real_Time}.
9387 @strong{106}. Implementation-defined aspects of
9388 @code{delay_statements}. See D.9(8).
9391 Any difference greater than one microsecond will cause the task to be
9392 delayed (see D.9(7)).
9397 @strong{107}. The upper bound on the duration of interrupt blocking
9398 caused by the implementation. See D.12(5).
9401 The upper bound is determined by the underlying operating system. In
9402 no cases is it more than 10 milliseconds.
9407 @strong{108}. The means for creating and executing distributed
9411 The GLADE package provides a utility GNATDIST for creating and executing
9412 distributed programs. See the GLADE reference manual for further details.
9417 @strong{109}. Any events that can result in a partition becoming
9418 inaccessible. See E.1(7).
9421 See the GLADE reference manual for full details on such events.
9426 @strong{110}. The scheduling policies, treatment of priorities, and
9427 management of shared resources between partitions in certain cases. See
9431 See the GLADE reference manual for full details on these aspects of
9432 multi-partition execution.
9437 @strong{111}. Events that cause the version of a compilation unit to
9441 Editing the source file of a compilation unit, or the source files of
9442 any units on which it is dependent in a significant way cause the version
9443 to change. No other actions cause the version number to change. All changes
9444 are significant except those which affect only layout, capitalization or
9450 @strong{112}. Whether the execution of the remote subprogram is
9451 immediately aborted as a result of cancellation. See E.4(13).
9454 See the GLADE reference manual for details on the effect of abort in
9455 a distributed application.
9460 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9463 See the GLADE reference manual for a full description of all implementation
9464 defined aspects of the PCS@.
9469 @strong{114}. Implementation-defined interfaces in the PCS@. See
9473 See the GLADE reference manual for a full description of all
9474 implementation defined interfaces.
9479 @strong{115}. The values of named numbers in the package
9480 @code{Decimal}. See F.2(7).
9492 @item Max_Decimal_Digits
9499 @strong{116}. The value of @code{Max_Picture_Length} in the package
9500 @code{Text_IO.Editing}. See F.3.3(16).
9508 @strong{117}. The value of @code{Max_Picture_Length} in the package
9509 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9517 @strong{118}. The accuracy actually achieved by the complex elementary
9518 functions and by other complex arithmetic operations. See G.1(1).
9521 Standard library functions are used for the complex arithmetic
9522 operations. Only fast math mode is currently supported.
9527 @strong{119}. The sign of a zero result (or a component thereof) from
9528 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9529 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9532 The signs of zero values are as recommended by the relevant
9533 implementation advice.
9538 @strong{120}. The sign of a zero result (or a component thereof) from
9539 any operator or function in
9540 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9541 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9544 The signs of zero values are as recommended by the relevant
9545 implementation advice.
9550 @strong{121}. Whether the strict mode or the relaxed mode is the
9551 default. See G.2(2).
9554 The strict mode is the default. There is no separate relaxed mode. GNAT
9555 provides a highly efficient implementation of strict mode.
9560 @strong{122}. The result interval in certain cases of fixed-to-float
9561 conversion. See G.2.1(10).
9564 For cases where the result interval is implementation dependent, the
9565 accuracy is that provided by performing all operations in 64-bit IEEE
9566 floating-point format.
9571 @strong{123}. The result of a floating point arithmetic operation in
9572 overflow situations, when the @code{Machine_Overflows} attribute of the
9573 result type is @code{False}. See G.2.1(13).
9576 Infinite and NaN values are produced as dictated by the IEEE
9577 floating-point standard.
9579 Note that on machines that are not fully compliant with the IEEE
9580 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9581 must be used for achieving IEEE confirming behavior (although at the cost
9582 of a significant performance penalty), so infinite and NaN values are
9588 @strong{124}. The result interval for division (or exponentiation by a
9589 negative exponent), when the floating point hardware implements division
9590 as multiplication by a reciprocal. See G.2.1(16).
9593 Not relevant, division is IEEE exact.
9598 @strong{125}. The definition of close result set, which determines the
9599 accuracy of certain fixed point multiplications and divisions. See
9603 Operations in the close result set are performed using IEEE long format
9604 floating-point arithmetic. The input operands are converted to
9605 floating-point, the operation is done in floating-point, and the result
9606 is converted to the target type.
9611 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9612 point multiplication or division for which the result shall be in the
9613 perfect result set. See G.2.3(22).
9616 The result is only defined to be in the perfect result set if the result
9617 can be computed by a single scaling operation involving a scale factor
9618 representable in 64-bits.
9623 @strong{127}. The result of a fixed point arithmetic operation in
9624 overflow situations, when the @code{Machine_Overflows} attribute of the
9625 result type is @code{False}. See G.2.3(27).
9628 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9634 @strong{128}. The result of an elementary function reference in
9635 overflow situations, when the @code{Machine_Overflows} attribute of the
9636 result type is @code{False}. See G.2.4(4).
9639 IEEE infinite and Nan values are produced as appropriate.
9644 @strong{129}. The value of the angle threshold, within which certain
9645 elementary functions, complex arithmetic operations, and complex
9646 elementary functions yield results conforming to a maximum relative
9647 error bound. See G.2.4(10).
9650 Information on this subject is not yet available.
9655 @strong{130}. The accuracy of certain elementary functions for
9656 parameters beyond the angle threshold. See G.2.4(10).
9659 Information on this subject is not yet available.
9664 @strong{131}. The result of a complex arithmetic operation or complex
9665 elementary function reference in overflow situations, when the
9666 @code{Machine_Overflows} attribute of the corresponding real type is
9667 @code{False}. See G.2.6(5).
9670 IEEE infinite and Nan values are produced as appropriate.
9675 @strong{132}. The accuracy of certain complex arithmetic operations and
9676 certain complex elementary functions for parameters (or components
9677 thereof) beyond the angle threshold. See G.2.6(8).
9680 Information on those subjects is not yet available.
9685 @strong{133}. Information regarding bounded errors and erroneous
9686 execution. See H.2(1).
9689 Information on this subject is not yet available.
9694 @strong{134}. Implementation-defined aspects of pragma
9695 @code{Inspection_Point}. See H.3.2(8).
9698 Pragma @code{Inspection_Point} ensures that the variable is live and can
9699 be examined by the debugger at the inspection point.
9704 @strong{135}. Implementation-defined aspects of pragma
9705 @code{Restrictions}. See H.4(25).
9708 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9709 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9710 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9715 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9719 There are no restrictions on pragma @code{Restrictions}.
9721 @node Intrinsic Subprograms
9722 @chapter Intrinsic Subprograms
9723 @cindex Intrinsic Subprograms
9726 * Intrinsic Operators::
9727 * Enclosing_Entity::
9728 * Exception_Information::
9729 * Exception_Message::
9737 * Shift_Right_Arithmetic::
9742 GNAT allows a user application program to write the declaration:
9744 @smallexample @c ada
9745 pragma Import (Intrinsic, name);
9749 providing that the name corresponds to one of the implemented intrinsic
9750 subprograms in GNAT, and that the parameter profile of the referenced
9751 subprogram meets the requirements. This chapter describes the set of
9752 implemented intrinsic subprograms, and the requirements on parameter profiles.
9753 Note that no body is supplied; as with other uses of pragma Import, the
9754 body is supplied elsewhere (in this case by the compiler itself). Note
9755 that any use of this feature is potentially non-portable, since the
9756 Ada standard does not require Ada compilers to implement this feature.
9758 @node Intrinsic Operators
9759 @section Intrinsic Operators
9760 @cindex Intrinsic operator
9763 All the predefined numeric operators in package Standard
9764 in @code{pragma Import (Intrinsic,..)}
9765 declarations. In the binary operator case, the operands must have the same
9766 size. The operand or operands must also be appropriate for
9767 the operator. For example, for addition, the operands must
9768 both be floating-point or both be fixed-point, and the
9769 right operand for @code{"**"} must have a root type of
9770 @code{Standard.Integer'Base}.
9771 You can use an intrinsic operator declaration as in the following example:
9773 @smallexample @c ada
9774 type Int1 is new Integer;
9775 type Int2 is new Integer;
9777 function "+" (X1 : Int1; X2 : Int2) return Int1;
9778 function "+" (X1 : Int1; X2 : Int2) return Int2;
9779 pragma Import (Intrinsic, "+");
9783 This declaration would permit ``mixed mode'' arithmetic on items
9784 of the differing types @code{Int1} and @code{Int2}.
9785 It is also possible to specify such operators for private types, if the
9786 full views are appropriate arithmetic types.
9788 @node Enclosing_Entity
9789 @section Enclosing_Entity
9790 @cindex Enclosing_Entity
9792 This intrinsic subprogram is used in the implementation of the
9793 library routine @code{GNAT.Source_Info}. The only useful use of the
9794 intrinsic import in this case is the one in this unit, so an
9795 application program should simply call the function
9796 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9797 the current subprogram, package, task, entry, or protected subprogram.
9799 @node Exception_Information
9800 @section Exception_Information
9801 @cindex Exception_Information'
9803 This intrinsic subprogram is used in the implementation of the
9804 library routine @code{GNAT.Current_Exception}. The only useful
9805 use of the intrinsic import in this case is the one in this unit,
9806 so an application program should simply call the function
9807 @code{GNAT.Current_Exception.Exception_Information} to obtain
9808 the exception information associated with the current exception.
9810 @node Exception_Message
9811 @section Exception_Message
9812 @cindex Exception_Message
9814 This intrinsic subprogram is used in the implementation of the
9815 library routine @code{GNAT.Current_Exception}. The only useful
9816 use of the intrinsic import in this case is the one in this unit,
9817 so an application program should simply call the function
9818 @code{GNAT.Current_Exception.Exception_Message} to obtain
9819 the message associated with the current exception.
9821 @node Exception_Name
9822 @section Exception_Name
9823 @cindex Exception_Name
9825 This intrinsic subprogram is used in the implementation of the
9826 library routine @code{GNAT.Current_Exception}. The only useful
9827 use of the intrinsic import in this case is the one in this unit,
9828 so an application program should simply call the function
9829 @code{GNAT.Current_Exception.Exception_Name} to obtain
9830 the name of the current exception.
9836 This intrinsic subprogram is used in the implementation of the
9837 library routine @code{GNAT.Source_Info}. The only useful use of the
9838 intrinsic import in this case is the one in this unit, so an
9839 application program should simply call the function
9840 @code{GNAT.Source_Info.File} to obtain the name of the current
9847 This intrinsic subprogram is used in the implementation of the
9848 library routine @code{GNAT.Source_Info}. The only useful use of the
9849 intrinsic import in this case is the one in this unit, so an
9850 application program should simply call the function
9851 @code{GNAT.Source_Info.Line} to obtain the number of the current
9855 @section Rotate_Left
9858 In standard Ada, the @code{Rotate_Left} function is available only
9859 for the predefined modular types in package @code{Interfaces}. However, in
9860 GNAT it is possible to define a Rotate_Left function for a user
9861 defined modular type or any signed integer type as in this example:
9863 @smallexample @c ada
9865 (Value : My_Modular_Type;
9867 return My_Modular_Type;
9871 The requirements are that the profile be exactly as in the example
9872 above. The only modifications allowed are in the formal parameter
9873 names, and in the type of @code{Value} and the return type, which
9874 must be the same, and must be either a signed integer type, or
9875 a modular integer type with a binary modulus, and the size must
9876 be 8. 16, 32 or 64 bits.
9879 @section Rotate_Right
9880 @cindex Rotate_Right
9882 A @code{Rotate_Right} function can be defined for any user defined
9883 binary modular integer type, or signed integer type, as described
9884 above for @code{Rotate_Left}.
9890 A @code{Shift_Left} function can be defined for any user defined
9891 binary modular integer type, or signed integer type, as described
9892 above for @code{Rotate_Left}.
9895 @section Shift_Right
9898 A @code{Shift_Right} function can be defined for any user defined
9899 binary modular integer type, or signed integer type, as described
9900 above for @code{Rotate_Left}.
9902 @node Shift_Right_Arithmetic
9903 @section Shift_Right_Arithmetic
9904 @cindex Shift_Right_Arithmetic
9906 A @code{Shift_Right_Arithmetic} function can be defined for any user
9907 defined binary modular integer type, or signed integer type, as described
9908 above for @code{Rotate_Left}.
9910 @node Source_Location
9911 @section Source_Location
9912 @cindex Source_Location
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.Source_Location} to obtain the current
9919 source file location.
9921 @node Representation Clauses and Pragmas
9922 @chapter Representation Clauses and Pragmas
9923 @cindex Representation Clauses
9926 * Alignment Clauses::
9928 * Storage_Size Clauses::
9929 * Size of Variant Record Objects::
9930 * Biased Representation ::
9931 * Value_Size and Object_Size Clauses::
9932 * Component_Size Clauses::
9933 * Bit_Order Clauses::
9934 * Effect of Bit_Order on Byte Ordering::
9935 * Pragma Pack for Arrays::
9936 * Pragma Pack for Records::
9937 * Record Representation Clauses::
9938 * Enumeration Clauses::
9940 * Effect of Convention on Representation::
9941 * Determining the Representations chosen by GNAT::
9945 @cindex Representation Clause
9946 @cindex Representation Pragma
9947 @cindex Pragma, representation
9948 This section describes the representation clauses accepted by GNAT, and
9949 their effect on the representation of corresponding data objects.
9951 GNAT fully implements Annex C (Systems Programming). This means that all
9952 the implementation advice sections in chapter 13 are fully implemented.
9953 However, these sections only require a minimal level of support for
9954 representation clauses. GNAT provides much more extensive capabilities,
9955 and this section describes the additional capabilities provided.
9957 @node Alignment Clauses
9958 @section Alignment Clauses
9959 @cindex Alignment Clause
9962 GNAT requires that all alignment clauses specify a power of 2, and all
9963 default alignments are always a power of 2. The default alignment
9964 values are as follows:
9967 @item @emph{Primitive Types}.
9968 For primitive types, the alignment is the minimum of the actual size of
9969 objects of the type divided by @code{Storage_Unit},
9970 and the maximum alignment supported by the target.
9971 (This maximum alignment is given by the GNAT-specific attribute
9972 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9973 @cindex @code{Maximum_Alignment} attribute
9974 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9975 default alignment will be 8 on any target that supports alignments
9976 this large, but on some targets, the maximum alignment may be smaller
9977 than 8, in which case objects of type @code{Long_Float} will be maximally
9980 @item @emph{Arrays}.
9981 For arrays, the alignment is equal to the alignment of the component type
9982 for the normal case where no packing or component size is given. If the
9983 array is packed, and the packing is effective (see separate section on
9984 packed arrays), then the alignment will be one for long packed arrays,
9985 or arrays whose length is not known at compile time. For short packed
9986 arrays, which are handled internally as modular types, the alignment
9987 will be as described for primitive types, e.g.@: a packed array of length
9988 31 bits will have an object size of four bytes, and an alignment of 4.
9990 @item @emph{Records}.
9991 For the normal non-packed case, the alignment of a record is equal to
9992 the maximum alignment of any of its components. For tagged records, this
9993 includes the implicit access type used for the tag. If a pragma @code{Pack}
9994 is used and all components are packable (see separate section on pragma
9995 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9996 record makes it profitable to increase it.
9998 A special case is when:
10001 the size of the record is given explicitly, or a
10002 full record representation clause is given, and
10004 the size of the record is 2, 4, or 8 bytes.
10007 In this case, an alignment is chosen to match the
10008 size of the record. For example, if we have:
10010 @smallexample @c ada
10011 type Small is record
10014 for Small'Size use 16;
10018 then the default alignment of the record type @code{Small} is 2, not 1. This
10019 leads to more efficient code when the record is treated as a unit, and also
10020 allows the type to specified as @code{Atomic} on architectures requiring
10026 An alignment clause may specify a larger alignment than the default value
10027 up to some maximum value dependent on the target (obtainable by using the
10028 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10029 a smaller alignment than the default value for enumeration, integer and
10030 fixed point types, as well as for record types, for example
10032 @smallexample @c ada
10037 for V'alignment use 1;
10041 @cindex Alignment, default
10042 The default alignment for the type @code{V} is 4, as a result of the
10043 Integer field in the record, but it is permissible, as shown, to
10044 override the default alignment of the record with a smaller value.
10047 @section Size Clauses
10048 @cindex Size Clause
10051 The default size for a type @code{T} is obtainable through the
10052 language-defined attribute @code{T'Size} and also through the
10053 equivalent GNAT-defined attribute @code{T'Value_Size}.
10054 For objects of type @code{T}, GNAT will generally increase the type size
10055 so that the object size (obtainable through the GNAT-defined attribute
10056 @code{T'Object_Size})
10057 is a multiple of @code{T'Alignment * Storage_Unit}.
10060 @smallexample @c ada
10061 type Smallint is range 1 .. 6;
10070 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10071 as specified by the RM rules,
10072 but objects of this type will have a size of 8
10073 (@code{Smallint'Object_Size} = 8),
10074 since objects by default occupy an integral number
10075 of storage units. On some targets, notably older
10076 versions of the Digital Alpha, the size of stand
10077 alone objects of this type may be 32, reflecting
10078 the inability of the hardware to do byte load/stores.
10080 Similarly, the size of type @code{Rec} is 40 bits
10081 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10082 the alignment is 4, so objects of this type will have
10083 their size increased to 64 bits so that it is a multiple
10084 of the alignment (in bits). This decision is
10085 in accordance with the specific Implementation Advice in RM 13.3(43):
10088 A @code{Size} clause should be supported for an object if the specified
10089 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10090 to a size in storage elements that is a multiple of the object's
10091 @code{Alignment} (if the @code{Alignment} is nonzero).
10095 An explicit size clause may be used to override the default size by
10096 increasing it. For example, if we have:
10098 @smallexample @c ada
10099 type My_Boolean is new Boolean;
10100 for My_Boolean'Size use 32;
10104 then values of this type will always be 32 bits long. In the case of
10105 discrete types, the size can be increased up to 64 bits, with the effect
10106 that the entire specified field is used to hold the value, sign- or
10107 zero-extended as appropriate. If more than 64 bits is specified, then
10108 padding space is allocated after the value, and a warning is issued that
10109 there are unused bits.
10111 Similarly the size of records and arrays may be increased, and the effect
10112 is to add padding bits after the value. This also causes a warning message
10115 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10116 Size in bits, this corresponds to an object of size 256 megabytes (minus
10117 one). This limitation is true on all targets. The reason for this
10118 limitation is that it improves the quality of the code in many cases
10119 if it is known that a Size value can be accommodated in an object of
10122 @node Storage_Size Clauses
10123 @section Storage_Size Clauses
10124 @cindex Storage_Size Clause
10127 For tasks, the @code{Storage_Size} clause specifies the amount of space
10128 to be allocated for the task stack. This cannot be extended, and if the
10129 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10130 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10131 or a @code{Storage_Size} pragma in the task definition to set the
10132 appropriate required size. A useful technique is to include in every
10133 task definition a pragma of the form:
10135 @smallexample @c ada
10136 pragma Storage_Size (Default_Stack_Size);
10140 Then @code{Default_Stack_Size} can be defined in a global package, and
10141 modified as required. Any tasks requiring stack sizes different from the
10142 default can have an appropriate alternative reference in the pragma.
10144 You can also use the @option{-d} binder switch to modify the default stack
10147 For access types, the @code{Storage_Size} clause specifies the maximum
10148 space available for allocation of objects of the type. If this space is
10149 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10150 In the case where the access type is declared local to a subprogram, the
10151 use of a @code{Storage_Size} clause triggers automatic use of a special
10152 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10153 space for the pool is automatically reclaimed on exit from the scope in
10154 which the type is declared.
10156 A special case recognized by the compiler is the specification of a
10157 @code{Storage_Size} of zero for an access type. This means that no
10158 items can be allocated from the pool, and this is recognized at compile
10159 time, and all the overhead normally associated with maintaining a fixed
10160 size storage pool is eliminated. Consider the following example:
10162 @smallexample @c ada
10164 type R is array (Natural) of Character;
10165 type P is access all R;
10166 for P'Storage_Size use 0;
10167 -- Above access type intended only for interfacing purposes
10171 procedure g (m : P);
10172 pragma Import (C, g);
10183 As indicated in this example, these dummy storage pools are often useful in
10184 connection with interfacing where no object will ever be allocated. If you
10185 compile the above example, you get the warning:
10188 p.adb:16:09: warning: allocation from empty storage pool
10189 p.adb:16:09: warning: Storage_Error will be raised at run time
10193 Of course in practice, there will not be any explicit allocators in the
10194 case of such an access declaration.
10196 @node Size of Variant Record Objects
10197 @section Size of Variant Record Objects
10198 @cindex Size, variant record objects
10199 @cindex Variant record objects, size
10202 In the case of variant record objects, there is a question whether Size gives
10203 information about a particular variant, or the maximum size required
10204 for any variant. Consider the following program
10206 @smallexample @c ada
10207 with Text_IO; use Text_IO;
10209 type R1 (A : Boolean := False) is record
10211 when True => X : Character;
10212 when False => null;
10220 Put_Line (Integer'Image (V1'Size));
10221 Put_Line (Integer'Image (V2'Size));
10226 Here we are dealing with a variant record, where the True variant
10227 requires 16 bits, and the False variant requires 8 bits.
10228 In the above example, both V1 and V2 contain the False variant,
10229 which is only 8 bits long. However, the result of running the
10238 The reason for the difference here is that the discriminant value of
10239 V1 is fixed, and will always be False. It is not possible to assign
10240 a True variant value to V1, therefore 8 bits is sufficient. On the
10241 other hand, in the case of V2, the initial discriminant value is
10242 False (from the default), but it is possible to assign a True
10243 variant value to V2, therefore 16 bits must be allocated for V2
10244 in the general case, even fewer bits may be needed at any particular
10245 point during the program execution.
10247 As can be seen from the output of this program, the @code{'Size}
10248 attribute applied to such an object in GNAT gives the actual allocated
10249 size of the variable, which is the largest size of any of the variants.
10250 The Ada Reference Manual is not completely clear on what choice should
10251 be made here, but the GNAT behavior seems most consistent with the
10252 language in the RM@.
10254 In some cases, it may be desirable to obtain the size of the current
10255 variant, rather than the size of the largest variant. This can be
10256 achieved in GNAT by making use of the fact that in the case of a
10257 subprogram parameter, GNAT does indeed return the size of the current
10258 variant (because a subprogram has no way of knowing how much space
10259 is actually allocated for the actual).
10261 Consider the following modified version of the above program:
10263 @smallexample @c ada
10264 with Text_IO; use Text_IO;
10266 type R1 (A : Boolean := False) is record
10268 when True => X : Character;
10269 when False => null;
10275 function Size (V : R1) return Integer is
10281 Put_Line (Integer'Image (V2'Size));
10282 Put_Line (Integer'IMage (Size (V2)));
10284 Put_Line (Integer'Image (V2'Size));
10285 Put_Line (Integer'IMage (Size (V2)));
10290 The output from this program is
10300 Here we see that while the @code{'Size} attribute always returns
10301 the maximum size, regardless of the current variant value, the
10302 @code{Size} function does indeed return the size of the current
10305 @node Biased Representation
10306 @section Biased Representation
10307 @cindex Size for biased representation
10308 @cindex Biased representation
10311 In the case of scalars with a range starting at other than zero, it is
10312 possible in some cases to specify a size smaller than the default minimum
10313 value, and in such cases, GNAT uses an unsigned biased representation,
10314 in which zero is used to represent the lower bound, and successive values
10315 represent successive values of the type.
10317 For example, suppose we have the declaration:
10319 @smallexample @c ada
10320 type Small is range -7 .. -4;
10321 for Small'Size use 2;
10325 Although the default size of type @code{Small} is 4, the @code{Size}
10326 clause is accepted by GNAT and results in the following representation
10330 -7 is represented as 2#00#
10331 -6 is represented as 2#01#
10332 -5 is represented as 2#10#
10333 -4 is represented as 2#11#
10337 Biased representation is only used if the specified @code{Size} clause
10338 cannot be accepted in any other manner. These reduced sizes that force
10339 biased representation can be used for all discrete types except for
10340 enumeration types for which a representation clause is given.
10342 @node Value_Size and Object_Size Clauses
10343 @section Value_Size and Object_Size Clauses
10345 @findex Object_Size
10346 @cindex Size, of objects
10349 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10350 number of bits required to hold values of type @code{T}.
10351 Although this interpretation was allowed in Ada 83, it was not required,
10352 and this requirement in practice can cause some significant difficulties.
10353 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10354 However, in Ada 95 and Ada 2005,
10355 @code{Natural'Size} is
10356 typically 31. This means that code may change in behavior when moving
10357 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10359 @smallexample @c ada
10360 type Rec is record;
10366 at 0 range 0 .. Natural'Size - 1;
10367 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10372 In the above code, since the typical size of @code{Natural} objects
10373 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10374 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10375 there are cases where the fact that the object size can exceed the
10376 size of the type causes surprises.
10378 To help get around this problem GNAT provides two implementation
10379 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10380 applied to a type, these attributes yield the size of the type
10381 (corresponding to the RM defined size attribute), and the size of
10382 objects of the type respectively.
10384 The @code{Object_Size} is used for determining the default size of
10385 objects and components. This size value can be referred to using the
10386 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10387 the basis of the determination of the size. The backend is free to
10388 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10389 character might be stored in 32 bits on a machine with no efficient
10390 byte access instructions such as the Alpha.
10392 The default rules for the value of @code{Object_Size} for
10393 discrete types are as follows:
10397 The @code{Object_Size} for base subtypes reflect the natural hardware
10398 size in bits (run the compiler with @option{-gnatS} to find those values
10399 for numeric types). Enumeration types and fixed-point base subtypes have
10400 8, 16, 32 or 64 bits for this size, depending on the range of values
10404 The @code{Object_Size} of a subtype is the same as the
10405 @code{Object_Size} of
10406 the type from which it is obtained.
10409 The @code{Object_Size} of a derived base type is copied from the parent
10410 base type, and the @code{Object_Size} of a derived first subtype is copied
10411 from the parent first subtype.
10415 The @code{Value_Size} attribute
10416 is the (minimum) number of bits required to store a value
10418 This value is used to determine how tightly to pack
10419 records or arrays with components of this type, and also affects
10420 the semantics of unchecked conversion (unchecked conversions where
10421 the @code{Value_Size} values differ generate a warning, and are potentially
10424 The default rules for the value of @code{Value_Size} are as follows:
10428 The @code{Value_Size} for a base subtype is the minimum number of bits
10429 required to store all values of the type (including the sign bit
10430 only if negative values are possible).
10433 If a subtype statically matches the first subtype of a given type, then it has
10434 by default the same @code{Value_Size} as the first subtype. This is a
10435 consequence of RM 13.1(14) (``if two subtypes statically match,
10436 then their subtype-specific aspects are the same''.)
10439 All other subtypes have a @code{Value_Size} corresponding to the minimum
10440 number of bits required to store all values of the subtype. For
10441 dynamic bounds, it is assumed that the value can range down or up
10442 to the corresponding bound of the ancestor
10446 The RM defined attribute @code{Size} corresponds to the
10447 @code{Value_Size} attribute.
10449 The @code{Size} attribute may be defined for a first-named subtype. This sets
10450 the @code{Value_Size} of
10451 the first-named subtype to the given value, and the
10452 @code{Object_Size} of this first-named subtype to the given value padded up
10453 to an appropriate boundary. It is a consequence of the default rules
10454 above that this @code{Object_Size} will apply to all further subtypes. On the
10455 other hand, @code{Value_Size} is affected only for the first subtype, any
10456 dynamic subtypes obtained from it directly, and any statically matching
10457 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10459 @code{Value_Size} and
10460 @code{Object_Size} may be explicitly set for any subtype using
10461 an attribute definition clause. Note that the use of these attributes
10462 can cause the RM 13.1(14) rule to be violated. If two access types
10463 reference aliased objects whose subtypes have differing @code{Object_Size}
10464 values as a result of explicit attribute definition clauses, then it
10465 is erroneous to convert from one access subtype to the other.
10467 At the implementation level, Esize stores the Object_Size and the
10468 RM_Size field stores the @code{Value_Size} (and hence the value of the
10469 @code{Size} attribute,
10470 which, as noted above, is equivalent to @code{Value_Size}).
10472 To get a feel for the difference, consider the following examples (note
10473 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10476 Object_Size Value_Size
10478 type x1 is range 0 .. 5; 8 3
10480 type x2 is range 0 .. 5;
10481 for x2'size use 12; 16 12
10483 subtype x3 is x2 range 0 .. 3; 16 2
10485 subtype x4 is x2'base range 0 .. 10; 8 4
10487 subtype x5 is x2 range 0 .. dynamic; 16 3*
10489 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10494 Note: the entries marked ``3*'' are not actually specified by the Ada
10495 Reference Manual, but it seems in the spirit of the RM rules to allocate
10496 the minimum number of bits (here 3, given the range for @code{x2})
10497 known to be large enough to hold the given range of values.
10499 So far, so good, but GNAT has to obey the RM rules, so the question is
10500 under what conditions must the RM @code{Size} be used.
10501 The following is a list
10502 of the occasions on which the RM @code{Size} must be used:
10506 Component size for packed arrays or records
10509 Value of the attribute @code{Size} for a type
10512 Warning about sizes not matching for unchecked conversion
10516 For record types, the @code{Object_Size} is always a multiple of the
10517 alignment of the type (this is true for all types). In some cases the
10518 @code{Value_Size} can be smaller. Consider:
10528 On a typical 32-bit architecture, the X component will be four bytes, and
10529 require four-byte alignment, and the Y component will be one byte. In this
10530 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10531 required to store a value of this type, and for example, it is permissible
10532 to have a component of type R in an outer array whose component size is
10533 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10534 since it must be rounded up so that this value is a multiple of the
10535 alignment (4 bytes = 32 bits).
10538 For all other types, the @code{Object_Size}
10539 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10540 Only @code{Size} may be specified for such types.
10542 @node Component_Size Clauses
10543 @section Component_Size Clauses
10544 @cindex Component_Size Clause
10547 Normally, the value specified in a component size clause must be consistent
10548 with the subtype of the array component with regard to size and alignment.
10549 In other words, the value specified must be at least equal to the size
10550 of this subtype, and must be a multiple of the alignment value.
10552 In addition, component size clauses are allowed which cause the array
10553 to be packed, by specifying a smaller value. A first case is for
10554 component size values in the range 1 through 63. The value specified
10555 must not be smaller than the Size of the subtype. GNAT will accurately
10556 honor all packing requests in this range. For example, if we have:
10558 @smallexample @c ada
10559 type r is array (1 .. 8) of Natural;
10560 for r'Component_Size use 31;
10564 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10565 Of course access to the components of such an array is considerably
10566 less efficient than if the natural component size of 32 is used.
10567 A second case is when the subtype of the component is a record type
10568 padded because of its default alignment. For example, if we have:
10570 @smallexample @c ada
10577 type a is array (1 .. 8) of r;
10578 for a'Component_Size use 72;
10582 then the resulting array has a length of 72 bytes, instead of 96 bytes
10583 if the alignment of the record (4) was obeyed.
10585 Note that there is no point in giving both a component size clause
10586 and a pragma Pack for the same array type. if such duplicate
10587 clauses are given, the pragma Pack will be ignored.
10589 @node Bit_Order Clauses
10590 @section Bit_Order Clauses
10591 @cindex Bit_Order Clause
10592 @cindex bit ordering
10593 @cindex ordering, of bits
10596 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10597 attribute. The specification may either correspond to the default bit
10598 order for the target, in which case the specification has no effect and
10599 places no additional restrictions, or it may be for the non-standard
10600 setting (that is the opposite of the default).
10602 In the case where the non-standard value is specified, the effect is
10603 to renumber bits within each byte, but the ordering of bytes is not
10604 affected. There are certain
10605 restrictions placed on component clauses as follows:
10609 @item Components fitting within a single storage unit.
10611 These are unrestricted, and the effect is merely to renumber bits. For
10612 example if we are on a little-endian machine with @code{Low_Order_First}
10613 being the default, then the following two declarations have exactly
10616 @smallexample @c ada
10619 B : Integer range 1 .. 120;
10623 A at 0 range 0 .. 0;
10624 B at 0 range 1 .. 7;
10629 B : Integer range 1 .. 120;
10632 for R2'Bit_Order use High_Order_First;
10635 A at 0 range 7 .. 7;
10636 B at 0 range 0 .. 6;
10641 The useful application here is to write the second declaration with the
10642 @code{Bit_Order} attribute definition clause, and know that it will be treated
10643 the same, regardless of whether the target is little-endian or big-endian.
10645 @item Components occupying an integral number of bytes.
10647 These are components that exactly fit in two or more bytes. Such component
10648 declarations are allowed, but have no effect, since it is important to realize
10649 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10650 In particular, the following attempt at getting an endian-independent integer
10653 @smallexample @c ada
10658 for R2'Bit_Order use High_Order_First;
10661 A at 0 range 0 .. 31;
10666 This declaration will result in a little-endian integer on a
10667 little-endian machine, and a big-endian integer on a big-endian machine.
10668 If byte flipping is required for interoperability between big- and
10669 little-endian machines, this must be explicitly programmed. This capability
10670 is not provided by @code{Bit_Order}.
10672 @item Components that are positioned across byte boundaries
10674 but do not occupy an integral number of bytes. Given that bytes are not
10675 reordered, such fields would occupy a non-contiguous sequence of bits
10676 in memory, requiring non-trivial code to reassemble. They are for this
10677 reason not permitted, and any component clause specifying such a layout
10678 will be flagged as illegal by GNAT@.
10683 Since the misconception that Bit_Order automatically deals with all
10684 endian-related incompatibilities is a common one, the specification of
10685 a component field that is an integral number of bytes will always
10686 generate a warning. This warning may be suppressed using @code{pragma
10687 Warnings (Off)} if desired. The following section contains additional
10688 details regarding the issue of byte ordering.
10690 @node Effect of Bit_Order on Byte Ordering
10691 @section Effect of Bit_Order on Byte Ordering
10692 @cindex byte ordering
10693 @cindex ordering, of bytes
10696 In this section we will review the effect of the @code{Bit_Order} attribute
10697 definition clause on byte ordering. Briefly, it has no effect at all, but
10698 a detailed example will be helpful. Before giving this
10699 example, let us review the precise
10700 definition of the effect of defining @code{Bit_Order}. The effect of a
10701 non-standard bit order is described in section 15.5.3 of the Ada
10705 2 A bit ordering is a method of interpreting the meaning of
10706 the storage place attributes.
10710 To understand the precise definition of storage place attributes in
10711 this context, we visit section 13.5.1 of the manual:
10714 13 A record_representation_clause (without the mod_clause)
10715 specifies the layout. The storage place attributes (see 13.5.2)
10716 are taken from the values of the position, first_bit, and last_bit
10717 expressions after normalizing those values so that first_bit is
10718 less than Storage_Unit.
10722 The critical point here is that storage places are taken from
10723 the values after normalization, not before. So the @code{Bit_Order}
10724 interpretation applies to normalized values. The interpretation
10725 is described in the later part of the 15.5.3 paragraph:
10728 2 A bit ordering is a method of interpreting the meaning of
10729 the storage place attributes. High_Order_First (known in the
10730 vernacular as ``big endian'') means that the first bit of a
10731 storage element (bit 0) is the most significant bit (interpreting
10732 the sequence of bits that represent a component as an unsigned
10733 integer value). Low_Order_First (known in the vernacular as
10734 ``little endian'') means the opposite: the first bit is the
10739 Note that the numbering is with respect to the bits of a storage
10740 unit. In other words, the specification affects only the numbering
10741 of bits within a single storage unit.
10743 We can make the effect clearer by giving an example.
10745 Suppose that we have an external device which presents two bytes, the first
10746 byte presented, which is the first (low addressed byte) of the two byte
10747 record is called Master, and the second byte is called Slave.
10749 The left most (most significant bit is called Control for each byte, and
10750 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10751 (least significant) bit.
10753 On a big-endian machine, we can write the following representation clause
10755 @smallexample @c ada
10756 type Data is record
10757 Master_Control : Bit;
10765 Slave_Control : Bit;
10775 for Data use record
10776 Master_Control at 0 range 0 .. 0;
10777 Master_V1 at 0 range 1 .. 1;
10778 Master_V2 at 0 range 2 .. 2;
10779 Master_V3 at 0 range 3 .. 3;
10780 Master_V4 at 0 range 4 .. 4;
10781 Master_V5 at 0 range 5 .. 5;
10782 Master_V6 at 0 range 6 .. 6;
10783 Master_V7 at 0 range 7 .. 7;
10784 Slave_Control at 1 range 0 .. 0;
10785 Slave_V1 at 1 range 1 .. 1;
10786 Slave_V2 at 1 range 2 .. 2;
10787 Slave_V3 at 1 range 3 .. 3;
10788 Slave_V4 at 1 range 4 .. 4;
10789 Slave_V5 at 1 range 5 .. 5;
10790 Slave_V6 at 1 range 6 .. 6;
10791 Slave_V7 at 1 range 7 .. 7;
10796 Now if we move this to a little endian machine, then the bit ordering within
10797 the byte is backwards, so we have to rewrite the record rep clause as:
10799 @smallexample @c ada
10800 for Data use record
10801 Master_Control at 0 range 7 .. 7;
10802 Master_V1 at 0 range 6 .. 6;
10803 Master_V2 at 0 range 5 .. 5;
10804 Master_V3 at 0 range 4 .. 4;
10805 Master_V4 at 0 range 3 .. 3;
10806 Master_V5 at 0 range 2 .. 2;
10807 Master_V6 at 0 range 1 .. 1;
10808 Master_V7 at 0 range 0 .. 0;
10809 Slave_Control at 1 range 7 .. 7;
10810 Slave_V1 at 1 range 6 .. 6;
10811 Slave_V2 at 1 range 5 .. 5;
10812 Slave_V3 at 1 range 4 .. 4;
10813 Slave_V4 at 1 range 3 .. 3;
10814 Slave_V5 at 1 range 2 .. 2;
10815 Slave_V6 at 1 range 1 .. 1;
10816 Slave_V7 at 1 range 0 .. 0;
10821 It is a nuisance to have to rewrite the clause, especially if
10822 the code has to be maintained on both machines. However,
10823 this is a case that we can handle with the
10824 @code{Bit_Order} attribute if it is implemented.
10825 Note that the implementation is not required on byte addressed
10826 machines, but it is indeed implemented in GNAT.
10827 This means that we can simply use the
10828 first record clause, together with the declaration
10830 @smallexample @c ada
10831 for Data'Bit_Order use High_Order_First;
10835 and the effect is what is desired, namely the layout is exactly the same,
10836 independent of whether the code is compiled on a big-endian or little-endian
10839 The important point to understand is that byte ordering is not affected.
10840 A @code{Bit_Order} attribute definition never affects which byte a field
10841 ends up in, only where it ends up in that byte.
10842 To make this clear, let us rewrite the record rep clause of the previous
10845 @smallexample @c ada
10846 for Data'Bit_Order use High_Order_First;
10847 for Data use record
10848 Master_Control at 0 range 0 .. 0;
10849 Master_V1 at 0 range 1 .. 1;
10850 Master_V2 at 0 range 2 .. 2;
10851 Master_V3 at 0 range 3 .. 3;
10852 Master_V4 at 0 range 4 .. 4;
10853 Master_V5 at 0 range 5 .. 5;
10854 Master_V6 at 0 range 6 .. 6;
10855 Master_V7 at 0 range 7 .. 7;
10856 Slave_Control at 0 range 8 .. 8;
10857 Slave_V1 at 0 range 9 .. 9;
10858 Slave_V2 at 0 range 10 .. 10;
10859 Slave_V3 at 0 range 11 .. 11;
10860 Slave_V4 at 0 range 12 .. 12;
10861 Slave_V5 at 0 range 13 .. 13;
10862 Slave_V6 at 0 range 14 .. 14;
10863 Slave_V7 at 0 range 15 .. 15;
10868 This is exactly equivalent to saying (a repeat of the first example):
10870 @smallexample @c ada
10871 for Data'Bit_Order use High_Order_First;
10872 for Data use record
10873 Master_Control at 0 range 0 .. 0;
10874 Master_V1 at 0 range 1 .. 1;
10875 Master_V2 at 0 range 2 .. 2;
10876 Master_V3 at 0 range 3 .. 3;
10877 Master_V4 at 0 range 4 .. 4;
10878 Master_V5 at 0 range 5 .. 5;
10879 Master_V6 at 0 range 6 .. 6;
10880 Master_V7 at 0 range 7 .. 7;
10881 Slave_Control at 1 range 0 .. 0;
10882 Slave_V1 at 1 range 1 .. 1;
10883 Slave_V2 at 1 range 2 .. 2;
10884 Slave_V3 at 1 range 3 .. 3;
10885 Slave_V4 at 1 range 4 .. 4;
10886 Slave_V5 at 1 range 5 .. 5;
10887 Slave_V6 at 1 range 6 .. 6;
10888 Slave_V7 at 1 range 7 .. 7;
10893 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10894 field. The storage place attributes are obtained by normalizing the
10895 values given so that the @code{First_Bit} value is less than 8. After
10896 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10897 we specified in the other case.
10899 Now one might expect that the @code{Bit_Order} attribute might affect
10900 bit numbering within the entire record component (two bytes in this
10901 case, thus affecting which byte fields end up in), but that is not
10902 the way this feature is defined, it only affects numbering of bits,
10903 not which byte they end up in.
10905 Consequently it never makes sense to specify a starting bit number
10906 greater than 7 (for a byte addressable field) if an attribute
10907 definition for @code{Bit_Order} has been given, and indeed it
10908 may be actively confusing to specify such a value, so the compiler
10909 generates a warning for such usage.
10911 If you do need to control byte ordering then appropriate conditional
10912 values must be used. If in our example, the slave byte came first on
10913 some machines we might write:
10915 @smallexample @c ada
10916 Master_Byte_First constant Boolean := @dots{};
10918 Master_Byte : constant Natural :=
10919 1 - Boolean'Pos (Master_Byte_First);
10920 Slave_Byte : constant Natural :=
10921 Boolean'Pos (Master_Byte_First);
10923 for Data'Bit_Order use High_Order_First;
10924 for Data use record
10925 Master_Control at Master_Byte range 0 .. 0;
10926 Master_V1 at Master_Byte range 1 .. 1;
10927 Master_V2 at Master_Byte range 2 .. 2;
10928 Master_V3 at Master_Byte range 3 .. 3;
10929 Master_V4 at Master_Byte range 4 .. 4;
10930 Master_V5 at Master_Byte range 5 .. 5;
10931 Master_V6 at Master_Byte range 6 .. 6;
10932 Master_V7 at Master_Byte range 7 .. 7;
10933 Slave_Control at Slave_Byte range 0 .. 0;
10934 Slave_V1 at Slave_Byte range 1 .. 1;
10935 Slave_V2 at Slave_Byte range 2 .. 2;
10936 Slave_V3 at Slave_Byte range 3 .. 3;
10937 Slave_V4 at Slave_Byte range 4 .. 4;
10938 Slave_V5 at Slave_Byte range 5 .. 5;
10939 Slave_V6 at Slave_Byte range 6 .. 6;
10940 Slave_V7 at Slave_Byte range 7 .. 7;
10945 Now to switch between machines, all that is necessary is
10946 to set the boolean constant @code{Master_Byte_First} in
10947 an appropriate manner.
10949 @node Pragma Pack for Arrays
10950 @section Pragma Pack for Arrays
10951 @cindex Pragma Pack (for arrays)
10954 Pragma @code{Pack} applied to an array has no effect unless the component type
10955 is packable. For a component type to be packable, it must be one of the
10962 Any type whose size is specified with a size clause
10964 Any packed array type with a static size
10966 Any record type padded because of its default alignment
10970 For all these cases, if the component subtype size is in the range
10971 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10972 component size were specified giving the component subtype size.
10973 For example if we have:
10975 @smallexample @c ada
10976 type r is range 0 .. 17;
10978 type ar is array (1 .. 8) of r;
10983 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10984 and the size of the array @code{ar} will be exactly 40 bits.
10986 Note that in some cases this rather fierce approach to packing can produce
10987 unexpected effects. For example, in Ada 95 and Ada 2005,
10988 subtype @code{Natural} typically has a size of 31, meaning that if you
10989 pack an array of @code{Natural}, you get 31-bit
10990 close packing, which saves a few bits, but results in far less efficient
10991 access. Since many other Ada compilers will ignore such a packing request,
10992 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10993 might not be what is intended. You can easily remove this warning by
10994 using an explicit @code{Component_Size} setting instead, which never generates
10995 a warning, since the intention of the programmer is clear in this case.
10997 GNAT treats packed arrays in one of two ways. If the size of the array is
10998 known at compile time and is less than 64 bits, then internally the array
10999 is represented as a single modular type, of exactly the appropriate number
11000 of bits. If the length is greater than 63 bits, or is not known at compile
11001 time, then the packed array is represented as an array of bytes, and the
11002 length is always a multiple of 8 bits.
11004 Note that to represent a packed array as a modular type, the alignment must
11005 be suitable for the modular type involved. For example, on typical machines
11006 a 32-bit packed array will be represented by a 32-bit modular integer with
11007 an alignment of four bytes. If you explicitly override the default alignment
11008 with an alignment clause that is too small, the modular representation
11009 cannot be used. For example, consider the following set of declarations:
11011 @smallexample @c ada
11012 type R is range 1 .. 3;
11013 type S is array (1 .. 31) of R;
11014 for S'Component_Size use 2;
11016 for S'Alignment use 1;
11020 If the alignment clause were not present, then a 62-bit modular
11021 representation would be chosen (typically with an alignment of 4 or 8
11022 bytes depending on the target). But the default alignment is overridden
11023 with the explicit alignment clause. This means that the modular
11024 representation cannot be used, and instead the array of bytes
11025 representation must be used, meaning that the length must be a multiple
11026 of 8. Thus the above set of declarations will result in a diagnostic
11027 rejecting the size clause and noting that the minimum size allowed is 64.
11029 @cindex Pragma Pack (for type Natural)
11030 @cindex Pragma Pack warning
11032 One special case that is worth noting occurs when the base type of the
11033 component size is 8/16/32 and the subtype is one bit less. Notably this
11034 occurs with subtype @code{Natural}. Consider:
11036 @smallexample @c ada
11037 type Arr is array (1 .. 32) of Natural;
11042 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11043 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11044 Ada 83 compilers did not attempt 31 bit packing.
11046 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11047 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11048 substantial unintended performance penalty when porting legacy Ada 83 code.
11049 To help prevent this, GNAT generates a warning in such cases. If you really
11050 want 31 bit packing in a case like this, you can set the component size
11053 @smallexample @c ada
11054 type Arr is array (1 .. 32) of Natural;
11055 for Arr'Component_Size use 31;
11059 Here 31-bit packing is achieved as required, and no warning is generated,
11060 since in this case the programmer intention is clear.
11062 @node Pragma Pack for Records
11063 @section Pragma Pack for Records
11064 @cindex Pragma Pack (for records)
11067 Pragma @code{Pack} applied to a record will pack the components to reduce
11068 wasted space from alignment gaps and by reducing the amount of space
11069 taken by components. We distinguish between @emph{packable} components and
11070 @emph{non-packable} components.
11071 Components of the following types are considered packable:
11074 All primitive types are packable.
11077 Small packed arrays, whose size does not exceed 64 bits, and where the
11078 size is statically known at compile time, are represented internally
11079 as modular integers, and so they are also packable.
11084 All packable components occupy the exact number of bits corresponding to
11085 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11086 can start on an arbitrary bit boundary.
11088 All other types are non-packable, they occupy an integral number of
11090 are placed at a boundary corresponding to their alignment requirements.
11092 For example, consider the record
11094 @smallexample @c ada
11095 type Rb1 is array (1 .. 13) of Boolean;
11098 type Rb2 is array (1 .. 65) of Boolean;
11113 The representation for the record x2 is as follows:
11115 @smallexample @c ada
11116 for x2'Size use 224;
11118 l1 at 0 range 0 .. 0;
11119 l2 at 0 range 1 .. 64;
11120 l3 at 12 range 0 .. 31;
11121 l4 at 16 range 0 .. 0;
11122 l5 at 16 range 1 .. 13;
11123 l6 at 18 range 0 .. 71;
11128 Studying this example, we see that the packable fields @code{l1}
11130 of length equal to their sizes, and placed at specific bit boundaries (and
11131 not byte boundaries) to
11132 eliminate padding. But @code{l3} is of a non-packable float type, so
11133 it is on the next appropriate alignment boundary.
11135 The next two fields are fully packable, so @code{l4} and @code{l5} are
11136 minimally packed with no gaps. However, type @code{Rb2} is a packed
11137 array that is longer than 64 bits, so it is itself non-packable. Thus
11138 the @code{l6} field is aligned to the next byte boundary, and takes an
11139 integral number of bytes, i.e.@: 72 bits.
11141 @node Record Representation Clauses
11142 @section Record Representation Clauses
11143 @cindex Record Representation Clause
11146 Record representation clauses may be given for all record types, including
11147 types obtained by record extension. Component clauses are allowed for any
11148 static component. The restrictions on component clauses depend on the type
11151 @cindex Component Clause
11152 For all components of an elementary type, the only restriction on component
11153 clauses is that the size must be at least the 'Size value of the type
11154 (actually the Value_Size). There are no restrictions due to alignment,
11155 and such components may freely cross storage boundaries.
11157 Packed arrays with a size up to and including 64 bits are represented
11158 internally using a modular type with the appropriate number of bits, and
11159 thus the same lack of restriction applies. For example, if you declare:
11161 @smallexample @c ada
11162 type R is array (1 .. 49) of Boolean;
11168 then a component clause for a component of type R may start on any
11169 specified bit boundary, and may specify a value of 49 bits or greater.
11171 For packed bit arrays that are longer than 64 bits, there are two
11172 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11173 including the important case of single bits or boolean values, then
11174 there are no limitations on placement of such components, and they
11175 may start and end at arbitrary bit boundaries.
11177 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11178 an array of this type longer than 64 bits must always be placed on
11179 on a storage unit (byte) boundary and occupy an integral number
11180 of storage units (bytes). Any component clause that does not
11181 meet this requirement will be rejected.
11183 Any aliased component, or component of an aliased type, must
11184 have its normal alignment and size. A component clause that
11185 does not meet this requirement will be rejected.
11187 The tag field of a tagged type always occupies an address sized field at
11188 the start of the record. No component clause may attempt to overlay this
11189 tag. When a tagged type appears as a component, the tag field must have
11192 In the case of a record extension T1, of a type T, no component clause applied
11193 to the type T1 can specify a storage location that would overlap the first
11194 T'Size bytes of the record.
11196 For all other component types, including non-bit-packed arrays,
11197 the component can be placed at an arbitrary bit boundary,
11198 so for example, the following is permitted:
11200 @smallexample @c ada
11201 type R is array (1 .. 10) of Boolean;
11210 G at 0 range 0 .. 0;
11211 H at 0 range 1 .. 1;
11212 L at 0 range 2 .. 81;
11213 R at 0 range 82 .. 161;
11218 Note: the above rules apply to recent releases of GNAT 5.
11219 In GNAT 3, there are more severe restrictions on larger components.
11220 For non-primitive types, including packed arrays with a size greater than
11221 64 bits, component clauses must respect the alignment requirement of the
11222 type, in particular, always starting on a byte boundary, and the length
11223 must be a multiple of the storage unit.
11225 @node Enumeration Clauses
11226 @section Enumeration Clauses
11228 The only restriction on enumeration clauses is that the range of values
11229 must be representable. For the signed case, if one or more of the
11230 representation values are negative, all values must be in the range:
11232 @smallexample @c ada
11233 System.Min_Int .. System.Max_Int
11237 For the unsigned case, where all values are nonnegative, the values must
11240 @smallexample @c ada
11241 0 .. System.Max_Binary_Modulus;
11245 A @emph{confirming} representation clause is one in which the values range
11246 from 0 in sequence, i.e.@: a clause that confirms the default representation
11247 for an enumeration type.
11248 Such a confirming representation
11249 is permitted by these rules, and is specially recognized by the compiler so
11250 that no extra overhead results from the use of such a clause.
11252 If an array has an index type which is an enumeration type to which an
11253 enumeration clause has been applied, then the array is stored in a compact
11254 manner. Consider the declarations:
11256 @smallexample @c ada
11257 type r is (A, B, C);
11258 for r use (A => 1, B => 5, C => 10);
11259 type t is array (r) of Character;
11263 The array type t corresponds to a vector with exactly three elements and
11264 has a default size equal to @code{3*Character'Size}. This ensures efficient
11265 use of space, but means that accesses to elements of the array will incur
11266 the overhead of converting representation values to the corresponding
11267 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11269 @node Address Clauses
11270 @section Address Clauses
11271 @cindex Address Clause
11273 The reference manual allows a general restriction on representation clauses,
11274 as found in RM 13.1(22):
11277 An implementation need not support representation
11278 items containing nonstatic expressions, except that
11279 an implementation should support a representation item
11280 for a given entity if each nonstatic expression in the
11281 representation item is a name that statically denotes
11282 a constant declared before the entity.
11286 In practice this is applicable only to address clauses, since this is the
11287 only case in which a non-static expression is permitted by the syntax. As
11288 the AARM notes in sections 13.1 (22.a-22.h):
11291 22.a Reason: This is to avoid the following sort of thing:
11293 22.b X : Integer := F(@dots{});
11294 Y : Address := G(@dots{});
11295 for X'Address use Y;
11297 22.c In the above, we have to evaluate the
11298 initialization expression for X before we
11299 know where to put the result. This seems
11300 like an unreasonable implementation burden.
11302 22.d The above code should instead be written
11305 22.e Y : constant Address := G(@dots{});
11306 X : Integer := F(@dots{});
11307 for X'Address use Y;
11309 22.f This allows the expression ``Y'' to be safely
11310 evaluated before X is created.
11312 22.g The constant could be a formal parameter of mode in.
11314 22.h An implementation can support other nonstatic
11315 expressions if it wants to. Expressions of type
11316 Address are hardly ever static, but their value
11317 might be known at compile time anyway in many
11322 GNAT does indeed permit many additional cases of non-static expressions. In
11323 particular, if the type involved is elementary there are no restrictions
11324 (since in this case, holding a temporary copy of the initialization value,
11325 if one is present, is inexpensive). In addition, if there is no implicit or
11326 explicit initialization, then there are no restrictions. GNAT will reject
11327 only the case where all three of these conditions hold:
11332 The type of the item is non-elementary (e.g.@: a record or array).
11335 There is explicit or implicit initialization required for the object.
11336 Note that access values are always implicitly initialized, and also
11337 in GNAT, certain bit-packed arrays (those having a dynamic length or
11338 a length greater than 64) will also be implicitly initialized to zero.
11341 The address value is non-static. Here GNAT is more permissive than the
11342 RM, and allows the address value to be the address of a previously declared
11343 stand-alone variable, as long as it does not itself have an address clause.
11345 @smallexample @c ada
11346 Anchor : Some_Initialized_Type;
11347 Overlay : Some_Initialized_Type;
11348 for Overlay'Address use Anchor'Address;
11352 However, the prefix of the address clause cannot be an array component, or
11353 a component of a discriminated record.
11358 As noted above in section 22.h, address values are typically non-static. In
11359 particular the To_Address function, even if applied to a literal value, is
11360 a non-static function call. To avoid this minor annoyance, GNAT provides
11361 the implementation defined attribute 'To_Address. The following two
11362 expressions have identical values:
11366 @smallexample @c ada
11367 To_Address (16#1234_0000#)
11368 System'To_Address (16#1234_0000#);
11372 except that the second form is considered to be a static expression, and
11373 thus when used as an address clause value is always permitted.
11376 Additionally, GNAT treats as static an address clause that is an
11377 unchecked_conversion of a static integer value. This simplifies the porting
11378 of legacy code, and provides a portable equivalent to the GNAT attribute
11381 Another issue with address clauses is the interaction with alignment
11382 requirements. When an address clause is given for an object, the address
11383 value must be consistent with the alignment of the object (which is usually
11384 the same as the alignment of the type of the object). If an address clause
11385 is given that specifies an inappropriately aligned address value, then the
11386 program execution is erroneous.
11388 Since this source of erroneous behavior can have unfortunate effects, GNAT
11389 checks (at compile time if possible, generating a warning, or at execution
11390 time with a run-time check) that the alignment is appropriate. If the
11391 run-time check fails, then @code{Program_Error} is raised. This run-time
11392 check is suppressed if range checks are suppressed, or if the special GNAT
11393 check Alignment_Check is suppressed, or if
11394 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11396 Finally, GNAT does not permit overlaying of objects of controlled types or
11397 composite types containing a controlled component. In most cases, the compiler
11398 can detect an attempt at such overlays and will generate a warning at compile
11399 time and a Program_Error exception at run time.
11402 An address clause cannot be given for an exported object. More
11403 understandably the real restriction is that objects with an address
11404 clause cannot be exported. This is because such variables are not
11405 defined by the Ada program, so there is no external object to export.
11408 It is permissible to give an address clause and a pragma Import for the
11409 same object. In this case, the variable is not really defined by the
11410 Ada program, so there is no external symbol to be linked. The link name
11411 and the external name are ignored in this case. The reason that we allow this
11412 combination is that it provides a useful idiom to avoid unwanted
11413 initializations on objects with address clauses.
11415 When an address clause is given for an object that has implicit or
11416 explicit initialization, then by default initialization takes place. This
11417 means that the effect of the object declaration is to overwrite the
11418 memory at the specified address. This is almost always not what the
11419 programmer wants, so GNAT will output a warning:
11429 for Ext'Address use System'To_Address (16#1234_1234#);
11431 >>> warning: implicit initialization of "Ext" may
11432 modify overlaid storage
11433 >>> warning: use pragma Import for "Ext" to suppress
11434 initialization (RM B(24))
11440 As indicated by the warning message, the solution is to use a (dummy) pragma
11441 Import to suppress this initialization. The pragma tell the compiler that the
11442 object is declared and initialized elsewhere. The following package compiles
11443 without warnings (and the initialization is suppressed):
11445 @smallexample @c ada
11453 for Ext'Address use System'To_Address (16#1234_1234#);
11454 pragma Import (Ada, Ext);
11459 A final issue with address clauses involves their use for overlaying
11460 variables, as in the following example:
11461 @cindex Overlaying of objects
11463 @smallexample @c ada
11466 for B'Address use A'Address;
11470 or alternatively, using the form recommended by the RM:
11472 @smallexample @c ada
11474 Addr : constant Address := A'Address;
11476 for B'Address use Addr;
11480 In both of these cases, @code{A}
11481 and @code{B} become aliased to one another via the
11482 address clause. This use of address clauses to overlay
11483 variables, achieving an effect similar to unchecked
11484 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11485 the effect is implementation defined. Furthermore, the
11486 Ada RM specifically recommends that in a situation
11487 like this, @code{B} should be subject to the following
11488 implementation advice (RM 13.3(19)):
11491 19 If the Address of an object is specified, or it is imported
11492 or exported, then the implementation should not perform
11493 optimizations based on assumptions of no aliases.
11497 GNAT follows this recommendation, and goes further by also applying
11498 this recommendation to the overlaid variable (@code{A}
11499 in the above example) in this case. This means that the overlay
11500 works "as expected", in that a modification to one of the variables
11501 will affect the value of the other.
11503 @node Effect of Convention on Representation
11504 @section Effect of Convention on Representation
11505 @cindex Convention, effect on representation
11508 Normally the specification of a foreign language convention for a type or
11509 an object has no effect on the chosen representation. In particular, the
11510 representation chosen for data in GNAT generally meets the standard system
11511 conventions, and for example records are laid out in a manner that is
11512 consistent with C@. This means that specifying convention C (for example)
11515 There are four exceptions to this general rule:
11519 @item Convention Fortran and array subtypes
11520 If pragma Convention Fortran is specified for an array subtype, then in
11521 accordance with the implementation advice in section 3.6.2(11) of the
11522 Ada Reference Manual, the array will be stored in a Fortran-compatible
11523 column-major manner, instead of the normal default row-major order.
11525 @item Convention C and enumeration types
11526 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11527 to accommodate all values of the type. For example, for the enumeration
11530 @smallexample @c ada
11531 type Color is (Red, Green, Blue);
11535 8 bits is sufficient to store all values of the type, so by default, objects
11536 of type @code{Color} will be represented using 8 bits. However, normal C
11537 convention is to use 32 bits for all enum values in C, since enum values
11538 are essentially of type int. If pragma @code{Convention C} is specified for an
11539 Ada enumeration type, then the size is modified as necessary (usually to
11540 32 bits) to be consistent with the C convention for enum values.
11542 Note that this treatment applies only to types. If Convention C is given for
11543 an enumeration object, where the enumeration type is not Convention C, then
11544 Object_Size bits are allocated. For example, for a normal enumeration type,
11545 with less than 256 elements, only 8 bits will be allocated for the object.
11546 Since this may be a surprise in terms of what C expects, GNAT will issue a
11547 warning in this situation. The warning can be suppressed by giving an explicit
11548 size clause specifying the desired size.
11550 @item Convention C/Fortran and Boolean types
11551 In C, the usual convention for boolean values, that is values used for
11552 conditions, is that zero represents false, and nonzero values represent
11553 true. In Ada, the normal convention is that two specific values, typically
11554 0/1, are used to represent false/true respectively.
11556 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11557 value represents true).
11559 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11560 C or Fortran convention for a derived Boolean, as in the following example:
11562 @smallexample @c ada
11563 type C_Switch is new Boolean;
11564 pragma Convention (C, C_Switch);
11568 then the GNAT generated code will treat any nonzero value as true. For truth
11569 values generated by GNAT, the conventional value 1 will be used for True, but
11570 when one of these values is read, any nonzero value is treated as True.
11572 @item Access types on OpenVMS
11573 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11574 arrays) are 64-bits long. An exception to this rule is for the case of
11575 C-convention access types where there is no explicit size clause present (or
11576 inherited for derived types). In this case, GNAT chooses to make these
11577 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11578 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11582 @node Determining the Representations chosen by GNAT
11583 @section Determining the Representations chosen by GNAT
11584 @cindex Representation, determination of
11585 @cindex @option{-gnatR} switch
11588 Although the descriptions in this section are intended to be complete, it is
11589 often easier to simply experiment to see what GNAT accepts and what the
11590 effect is on the layout of types and objects.
11592 As required by the Ada RM, if a representation clause is not accepted, then
11593 it must be rejected as illegal by the compiler. However, when a
11594 representation clause or pragma is accepted, there can still be questions
11595 of what the compiler actually does. For example, if a partial record
11596 representation clause specifies the location of some components and not
11597 others, then where are the non-specified components placed? Or if pragma
11598 @code{Pack} is used on a record, then exactly where are the resulting
11599 fields placed? The section on pragma @code{Pack} in this chapter can be
11600 used to answer the second question, but it is often easier to just see
11601 what the compiler does.
11603 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11604 with this option, then the compiler will output information on the actual
11605 representations chosen, in a format similar to source representation
11606 clauses. For example, if we compile the package:
11608 @smallexample @c ada
11610 type r (x : boolean) is tagged record
11612 when True => S : String (1 .. 100);
11613 when False => null;
11617 type r2 is new r (false) with record
11622 y2 at 16 range 0 .. 31;
11629 type x1 is array (1 .. 10) of x;
11630 for x1'component_size use 11;
11632 type ia is access integer;
11634 type Rb1 is array (1 .. 13) of Boolean;
11637 type Rb2 is array (1 .. 65) of Boolean;
11653 using the switch @option{-gnatR} we obtain the following output:
11656 Representation information for unit q
11657 -------------------------------------
11660 for r'Alignment use 4;
11662 x at 4 range 0 .. 7;
11663 _tag at 0 range 0 .. 31;
11664 s at 5 range 0 .. 799;
11667 for r2'Size use 160;
11668 for r2'Alignment use 4;
11670 x at 4 range 0 .. 7;
11671 _tag at 0 range 0 .. 31;
11672 _parent at 0 range 0 .. 63;
11673 y2 at 16 range 0 .. 31;
11677 for x'Alignment use 1;
11679 y at 0 range 0 .. 7;
11682 for x1'Size use 112;
11683 for x1'Alignment use 1;
11684 for x1'Component_Size use 11;
11686 for rb1'Size use 13;
11687 for rb1'Alignment use 2;
11688 for rb1'Component_Size use 1;
11690 for rb2'Size use 72;
11691 for rb2'Alignment use 1;
11692 for rb2'Component_Size use 1;
11694 for x2'Size use 224;
11695 for x2'Alignment use 4;
11697 l1 at 0 range 0 .. 0;
11698 l2 at 0 range 1 .. 64;
11699 l3 at 12 range 0 .. 31;
11700 l4 at 16 range 0 .. 0;
11701 l5 at 16 range 1 .. 13;
11702 l6 at 18 range 0 .. 71;
11707 The Size values are actually the Object_Size, i.e.@: the default size that
11708 will be allocated for objects of the type.
11709 The ?? size for type r indicates that we have a variant record, and the
11710 actual size of objects will depend on the discriminant value.
11712 The Alignment values show the actual alignment chosen by the compiler
11713 for each record or array type.
11715 The record representation clause for type r shows where all fields
11716 are placed, including the compiler generated tag field (whose location
11717 cannot be controlled by the programmer).
11719 The record representation clause for the type extension r2 shows all the
11720 fields present, including the parent field, which is a copy of the fields
11721 of the parent type of r2, i.e.@: r1.
11723 The component size and size clauses for types rb1 and rb2 show
11724 the exact effect of pragma @code{Pack} on these arrays, and the record
11725 representation clause for type x2 shows how pragma @code{Pack} affects
11728 In some cases, it may be useful to cut and paste the representation clauses
11729 generated by the compiler into the original source to fix and guarantee
11730 the actual representation to be used.
11732 @node Standard Library Routines
11733 @chapter Standard Library Routines
11736 The Ada Reference Manual contains in Annex A a full description of an
11737 extensive set of standard library routines that can be used in any Ada
11738 program, and which must be provided by all Ada compilers. They are
11739 analogous to the standard C library used by C programs.
11741 GNAT implements all of the facilities described in annex A, and for most
11742 purposes the description in the Ada Reference Manual, or appropriate Ada
11743 text book, will be sufficient for making use of these facilities.
11745 In the case of the input-output facilities,
11746 @xref{The Implementation of Standard I/O},
11747 gives details on exactly how GNAT interfaces to the
11748 file system. For the remaining packages, the Ada Reference Manual
11749 should be sufficient. The following is a list of the packages included,
11750 together with a brief description of the functionality that is provided.
11752 For completeness, references are included to other predefined library
11753 routines defined in other sections of the Ada Reference Manual (these are
11754 cross-indexed from Annex A).
11758 This is a parent package for all the standard library packages. It is
11759 usually included implicitly in your program, and itself contains no
11760 useful data or routines.
11762 @item Ada.Calendar (9.6)
11763 @code{Calendar} provides time of day access, and routines for
11764 manipulating times and durations.
11766 @item Ada.Characters (A.3.1)
11767 This is a dummy parent package that contains no useful entities
11769 @item Ada.Characters.Handling (A.3.2)
11770 This package provides some basic character handling capabilities,
11771 including classification functions for classes of characters (e.g.@: test
11772 for letters, or digits).
11774 @item Ada.Characters.Latin_1 (A.3.3)
11775 This package includes a complete set of definitions of the characters
11776 that appear in type CHARACTER@. It is useful for writing programs that
11777 will run in international environments. For example, if you want an
11778 upper case E with an acute accent in a string, it is often better to use
11779 the definition of @code{UC_E_Acute} in this package. Then your program
11780 will print in an understandable manner even if your environment does not
11781 support these extended characters.
11783 @item Ada.Command_Line (A.15)
11784 This package provides access to the command line parameters and the name
11785 of the current program (analogous to the use of @code{argc} and @code{argv}
11786 in C), and also allows the exit status for the program to be set in a
11787 system-independent manner.
11789 @item Ada.Decimal (F.2)
11790 This package provides constants describing the range of decimal numbers
11791 implemented, and also a decimal divide routine (analogous to the COBOL
11792 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11794 @item Ada.Direct_IO (A.8.4)
11795 This package provides input-output using a model of a set of records of
11796 fixed-length, containing an arbitrary definite Ada type, indexed by an
11797 integer record number.
11799 @item Ada.Dynamic_Priorities (D.5)
11800 This package allows the priorities of a task to be adjusted dynamically
11801 as the task is running.
11803 @item Ada.Exceptions (11.4.1)
11804 This package provides additional information on exceptions, and also
11805 contains facilities for treating exceptions as data objects, and raising
11806 exceptions with associated messages.
11808 @item Ada.Finalization (7.6)
11809 This package contains the declarations and subprograms to support the
11810 use of controlled types, providing for automatic initialization and
11811 finalization (analogous to the constructors and destructors of C++)
11813 @item Ada.Interrupts (C.3.2)
11814 This package provides facilities for interfacing to interrupts, which
11815 includes the set of signals or conditions that can be raised and
11816 recognized as interrupts.
11818 @item Ada.Interrupts.Names (C.3.2)
11819 This package provides the set of interrupt names (actually signal
11820 or condition names) that can be handled by GNAT@.
11822 @item Ada.IO_Exceptions (A.13)
11823 This package defines the set of exceptions that can be raised by use of
11824 the standard IO packages.
11827 This package contains some standard constants and exceptions used
11828 throughout the numerics packages. Note that the constants pi and e are
11829 defined here, and it is better to use these definitions than rolling
11832 @item Ada.Numerics.Complex_Elementary_Functions
11833 Provides the implementation of standard elementary functions (such as
11834 log and trigonometric functions) operating on complex numbers using the
11835 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11836 created by the package @code{Numerics.Complex_Types}.
11838 @item Ada.Numerics.Complex_Types
11839 This is a predefined instantiation of
11840 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11841 build the type @code{Complex} and @code{Imaginary}.
11843 @item Ada.Numerics.Discrete_Random
11844 This generic package provides a random number generator suitable for generating
11845 uniformly distributed values of a specified discrete subtype.
11847 @item Ada.Numerics.Float_Random
11848 This package provides a random number generator suitable for generating
11849 uniformly distributed floating point values in the unit interval.
11851 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11852 This is a generic version of the package that provides the
11853 implementation of standard elementary functions (such as log and
11854 trigonometric functions) for an arbitrary complex type.
11856 The following predefined instantiations of this package are provided:
11860 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11862 @code{Ada.Numerics.Complex_Elementary_Functions}
11864 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11867 @item Ada.Numerics.Generic_Complex_Types
11868 This is a generic package that allows the creation of complex types,
11869 with associated complex arithmetic operations.
11871 The following predefined instantiations of this package exist
11874 @code{Ada.Numerics.Short_Complex_Complex_Types}
11876 @code{Ada.Numerics.Complex_Complex_Types}
11878 @code{Ada.Numerics.Long_Complex_Complex_Types}
11881 @item Ada.Numerics.Generic_Elementary_Functions
11882 This is a generic package that provides the implementation of standard
11883 elementary functions (such as log an trigonometric functions) for an
11884 arbitrary float type.
11886 The following predefined instantiations of this package exist
11890 @code{Ada.Numerics.Short_Elementary_Functions}
11892 @code{Ada.Numerics.Elementary_Functions}
11894 @code{Ada.Numerics.Long_Elementary_Functions}
11897 @item Ada.Real_Time (D.8)
11898 This package provides facilities similar to those of @code{Calendar}, but
11899 operating with a finer clock suitable for real time control. Note that
11900 annex D requires that there be no backward clock jumps, and GNAT generally
11901 guarantees this behavior, but of course if the external clock on which
11902 the GNAT runtime depends is deliberately reset by some external event,
11903 then such a backward jump may occur.
11905 @item Ada.Sequential_IO (A.8.1)
11906 This package provides input-output facilities for sequential files,
11907 which can contain a sequence of values of a single type, which can be
11908 any Ada type, including indefinite (unconstrained) types.
11910 @item Ada.Storage_IO (A.9)
11911 This package provides a facility for mapping arbitrary Ada types to and
11912 from a storage buffer. It is primarily intended for the creation of new
11915 @item Ada.Streams (13.13.1)
11916 This is a generic package that provides the basic support for the
11917 concept of streams as used by the stream attributes (@code{Input},
11918 @code{Output}, @code{Read} and @code{Write}).
11920 @item Ada.Streams.Stream_IO (A.12.1)
11921 This package is a specialization of the type @code{Streams} defined in
11922 package @code{Streams} together with a set of operations providing
11923 Stream_IO capability. The Stream_IO model permits both random and
11924 sequential access to a file which can contain an arbitrary set of values
11925 of one or more Ada types.
11927 @item Ada.Strings (A.4.1)
11928 This package provides some basic constants used by the string handling
11931 @item Ada.Strings.Bounded (A.4.4)
11932 This package provides facilities for handling variable length
11933 strings. The bounded model requires a maximum length. It is thus
11934 somewhat more limited than the unbounded model, but avoids the use of
11935 dynamic allocation or finalization.
11937 @item Ada.Strings.Fixed (A.4.3)
11938 This package provides facilities for handling fixed length strings.
11940 @item Ada.Strings.Maps (A.4.2)
11941 This package provides facilities for handling character mappings and
11942 arbitrarily defined subsets of characters. For instance it is useful in
11943 defining specialized translation tables.
11945 @item Ada.Strings.Maps.Constants (A.4.6)
11946 This package provides a standard set of predefined mappings and
11947 predefined character sets. For example, the standard upper to lower case
11948 conversion table is found in this package. Note that upper to lower case
11949 conversion is non-trivial if you want to take the entire set of
11950 characters, including extended characters like E with an acute accent,
11951 into account. You should use the mappings in this package (rather than
11952 adding 32 yourself) to do case mappings.
11954 @item Ada.Strings.Unbounded (A.4.5)
11955 This package provides facilities for handling variable length
11956 strings. The unbounded model allows arbitrary length strings, but
11957 requires the use of dynamic allocation and finalization.
11959 @item Ada.Strings.Wide_Bounded (A.4.7)
11960 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11961 @itemx Ada.Strings.Wide_Maps (A.4.7)
11962 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11963 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11964 These packages provide analogous capabilities to the corresponding
11965 packages without @samp{Wide_} in the name, but operate with the types
11966 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11967 and @code{Character}.
11969 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11970 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11971 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11972 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11973 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11974 These packages provide analogous capabilities to the corresponding
11975 packages without @samp{Wide_} in the name, but operate with the types
11976 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11977 of @code{String} and @code{Character}.
11979 @item Ada.Synchronous_Task_Control (D.10)
11980 This package provides some standard facilities for controlling task
11981 communication in a synchronous manner.
11984 This package contains definitions for manipulation of the tags of tagged
11987 @item Ada.Task_Attributes
11988 This package provides the capability of associating arbitrary
11989 task-specific data with separate tasks.
11992 This package provides basic text input-output capabilities for
11993 character, string and numeric data. The subpackages of this
11994 package are listed next.
11996 @item Ada.Text_IO.Decimal_IO
11997 Provides input-output facilities for decimal fixed-point types
11999 @item Ada.Text_IO.Enumeration_IO
12000 Provides input-output facilities for enumeration types.
12002 @item Ada.Text_IO.Fixed_IO
12003 Provides input-output facilities for ordinary fixed-point types.
12005 @item Ada.Text_IO.Float_IO
12006 Provides input-output facilities for float types. The following
12007 predefined instantiations of this generic package are available:
12011 @code{Short_Float_Text_IO}
12013 @code{Float_Text_IO}
12015 @code{Long_Float_Text_IO}
12018 @item Ada.Text_IO.Integer_IO
12019 Provides input-output facilities for integer types. The following
12020 predefined instantiations of this generic package are available:
12023 @item Short_Short_Integer
12024 @code{Ada.Short_Short_Integer_Text_IO}
12025 @item Short_Integer
12026 @code{Ada.Short_Integer_Text_IO}
12028 @code{Ada.Integer_Text_IO}
12030 @code{Ada.Long_Integer_Text_IO}
12031 @item Long_Long_Integer
12032 @code{Ada.Long_Long_Integer_Text_IO}
12035 @item Ada.Text_IO.Modular_IO
12036 Provides input-output facilities for modular (unsigned) types
12038 @item Ada.Text_IO.Complex_IO (G.1.3)
12039 This package provides basic text input-output capabilities for complex
12042 @item Ada.Text_IO.Editing (F.3.3)
12043 This package contains routines for edited output, analogous to the use
12044 of pictures in COBOL@. The picture formats used by this package are a
12045 close copy of the facility in COBOL@.
12047 @item Ada.Text_IO.Text_Streams (A.12.2)
12048 This package provides a facility that allows Text_IO files to be treated
12049 as streams, so that the stream attributes can be used for writing
12050 arbitrary data, including binary data, to Text_IO files.
12052 @item Ada.Unchecked_Conversion (13.9)
12053 This generic package allows arbitrary conversion from one type to
12054 another of the same size, providing for breaking the type safety in
12055 special circumstances.
12057 If the types have the same Size (more accurately the same Value_Size),
12058 then the effect is simply to transfer the bits from the source to the
12059 target type without any modification. This usage is well defined, and
12060 for simple types whose representation is typically the same across
12061 all implementations, gives a portable method of performing such
12064 If the types do not have the same size, then the result is implementation
12065 defined, and thus may be non-portable. The following describes how GNAT
12066 handles such unchecked conversion cases.
12068 If the types are of different sizes, and are both discrete types, then
12069 the effect is of a normal type conversion without any constraint checking.
12070 In particular if the result type has a larger size, the result will be
12071 zero or sign extended. If the result type has a smaller size, the result
12072 will be truncated by ignoring high order bits.
12074 If the types are of different sizes, and are not both discrete types,
12075 then the conversion works as though pointers were created to the source
12076 and target, and the pointer value is converted. The effect is that bits
12077 are copied from successive low order storage units and bits of the source
12078 up to the length of the target type.
12080 A warning is issued if the lengths differ, since the effect in this
12081 case is implementation dependent, and the above behavior may not match
12082 that of some other compiler.
12084 A pointer to one type may be converted to a pointer to another type using
12085 unchecked conversion. The only case in which the effect is undefined is
12086 when one or both pointers are pointers to unconstrained array types. In
12087 this case, the bounds information may get incorrectly transferred, and in
12088 particular, GNAT uses double size pointers for such types, and it is
12089 meaningless to convert between such pointer types. GNAT will issue a
12090 warning if the alignment of the target designated type is more strict
12091 than the alignment of the source designated type (since the result may
12092 be unaligned in this case).
12094 A pointer other than a pointer to an unconstrained array type may be
12095 converted to and from System.Address. Such usage is common in Ada 83
12096 programs, but note that Ada.Address_To_Access_Conversions is the
12097 preferred method of performing such conversions in Ada 95 and Ada 2005.
12099 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12100 used in conjunction with pointers to unconstrained objects, since
12101 the bounds information cannot be handled correctly in this case.
12103 @item Ada.Unchecked_Deallocation (13.11.2)
12104 This generic package allows explicit freeing of storage previously
12105 allocated by use of an allocator.
12107 @item Ada.Wide_Text_IO (A.11)
12108 This package is similar to @code{Ada.Text_IO}, except that the external
12109 file supports wide character representations, and the internal types are
12110 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12111 and @code{String}. It contains generic subpackages listed next.
12113 @item Ada.Wide_Text_IO.Decimal_IO
12114 Provides input-output facilities for decimal fixed-point types
12116 @item Ada.Wide_Text_IO.Enumeration_IO
12117 Provides input-output facilities for enumeration types.
12119 @item Ada.Wide_Text_IO.Fixed_IO
12120 Provides input-output facilities for ordinary fixed-point types.
12122 @item Ada.Wide_Text_IO.Float_IO
12123 Provides input-output facilities for float types. The following
12124 predefined instantiations of this generic package are available:
12128 @code{Short_Float_Wide_Text_IO}
12130 @code{Float_Wide_Text_IO}
12132 @code{Long_Float_Wide_Text_IO}
12135 @item Ada.Wide_Text_IO.Integer_IO
12136 Provides input-output facilities for integer types. The following
12137 predefined instantiations of this generic package are available:
12140 @item Short_Short_Integer
12141 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12142 @item Short_Integer
12143 @code{Ada.Short_Integer_Wide_Text_IO}
12145 @code{Ada.Integer_Wide_Text_IO}
12147 @code{Ada.Long_Integer_Wide_Text_IO}
12148 @item Long_Long_Integer
12149 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12152 @item Ada.Wide_Text_IO.Modular_IO
12153 Provides input-output facilities for modular (unsigned) types
12155 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12156 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12157 external file supports wide character representations.
12159 @item Ada.Wide_Text_IO.Editing (F.3.4)
12160 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12161 types are @code{Wide_Character} and @code{Wide_String} instead of
12162 @code{Character} and @code{String}.
12164 @item Ada.Wide_Text_IO.Streams (A.12.3)
12165 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12166 types are @code{Wide_Character} and @code{Wide_String} instead of
12167 @code{Character} and @code{String}.
12169 @item Ada.Wide_Wide_Text_IO (A.11)
12170 This package is similar to @code{Ada.Text_IO}, except that the external
12171 file supports wide character representations, and the internal types are
12172 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12173 and @code{String}. It contains generic subpackages listed next.
12175 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12176 Provides input-output facilities for decimal fixed-point types
12178 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12179 Provides input-output facilities for enumeration types.
12181 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12182 Provides input-output facilities for ordinary fixed-point types.
12184 @item Ada.Wide_Wide_Text_IO.Float_IO
12185 Provides input-output facilities for float types. The following
12186 predefined instantiations of this generic package are available:
12190 @code{Short_Float_Wide_Wide_Text_IO}
12192 @code{Float_Wide_Wide_Text_IO}
12194 @code{Long_Float_Wide_Wide_Text_IO}
12197 @item Ada.Wide_Wide_Text_IO.Integer_IO
12198 Provides input-output facilities for integer types. The following
12199 predefined instantiations of this generic package are available:
12202 @item Short_Short_Integer
12203 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12204 @item Short_Integer
12205 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12207 @code{Ada.Integer_Wide_Wide_Text_IO}
12209 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12210 @item Long_Long_Integer
12211 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12214 @item Ada.Wide_Wide_Text_IO.Modular_IO
12215 Provides input-output facilities for modular (unsigned) types
12217 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12218 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12219 external file supports wide character representations.
12221 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12222 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12223 types are @code{Wide_Character} and @code{Wide_String} instead of
12224 @code{Character} and @code{String}.
12226 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12227 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12228 types are @code{Wide_Character} and @code{Wide_String} instead of
12229 @code{Character} and @code{String}.
12232 @node The Implementation of Standard I/O
12233 @chapter The Implementation of Standard I/O
12236 GNAT implements all the required input-output facilities described in
12237 A.6 through A.14. These sections of the Ada Reference Manual describe the
12238 required behavior of these packages from the Ada point of view, and if
12239 you are writing a portable Ada program that does not need to know the
12240 exact manner in which Ada maps to the outside world when it comes to
12241 reading or writing external files, then you do not need to read this
12242 chapter. As long as your files are all regular files (not pipes or
12243 devices), and as long as you write and read the files only from Ada, the
12244 description in the Ada Reference Manual is sufficient.
12246 However, if you want to do input-output to pipes or other devices, such
12247 as the keyboard or screen, or if the files you are dealing with are
12248 either generated by some other language, or to be read by some other
12249 language, then you need to know more about the details of how the GNAT
12250 implementation of these input-output facilities behaves.
12252 In this chapter we give a detailed description of exactly how GNAT
12253 interfaces to the file system. As always, the sources of the system are
12254 available to you for answering questions at an even more detailed level,
12255 but for most purposes the information in this chapter will suffice.
12257 Another reason that you may need to know more about how input-output is
12258 implemented arises when you have a program written in mixed languages
12259 where, for example, files are shared between the C and Ada sections of
12260 the same program. GNAT provides some additional facilities, in the form
12261 of additional child library packages, that facilitate this sharing, and
12262 these additional facilities are also described in this chapter.
12265 * Standard I/O Packages::
12271 * Wide_Wide_Text_IO::
12273 * Text Translation::
12275 * Filenames encoding::
12277 * Operations on C Streams::
12278 * Interfacing to C Streams::
12281 @node Standard I/O Packages
12282 @section Standard I/O Packages
12285 The Standard I/O packages described in Annex A for
12291 Ada.Text_IO.Complex_IO
12293 Ada.Text_IO.Text_Streams
12297 Ada.Wide_Text_IO.Complex_IO
12299 Ada.Wide_Text_IO.Text_Streams
12301 Ada.Wide_Wide_Text_IO
12303 Ada.Wide_Wide_Text_IO.Complex_IO
12305 Ada.Wide_Wide_Text_IO.Text_Streams
12315 are implemented using the C
12316 library streams facility; where
12320 All files are opened using @code{fopen}.
12322 All input/output operations use @code{fread}/@code{fwrite}.
12326 There is no internal buffering of any kind at the Ada library level. The only
12327 buffering is that provided at the system level in the implementation of the
12328 library routines that support streams. This facilitates shared use of these
12329 streams by mixed language programs. Note though that system level buffering is
12330 explicitly enabled at elaboration of the standard I/O packages and that can
12331 have an impact on mixed language programs, in particular those using I/O before
12332 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12333 the Ada elaboration routine before performing any I/O or when impractical,
12334 flush the common I/O streams and in particular Standard_Output before
12335 elaborating the Ada code.
12338 @section FORM Strings
12341 The format of a FORM string in GNAT is:
12344 "keyword=value,keyword=value,@dots{},keyword=value"
12348 where letters may be in upper or lower case, and there are no spaces
12349 between values. The order of the entries is not important. Currently
12350 the following keywords defined.
12353 TEXT_TRANSLATION=[YES|NO]
12355 WCEM=[n|h|u|s|e|8|b]
12356 ENCODING=[UTF8|8BITS]
12360 The use of these parameters is described later in this section.
12366 Direct_IO can only be instantiated for definite types. This is a
12367 restriction of the Ada language, which means that the records are fixed
12368 length (the length being determined by @code{@var{type}'Size}, rounded
12369 up to the next storage unit boundary if necessary).
12371 The records of a Direct_IO file are simply written to the file in index
12372 sequence, with the first record starting at offset zero, and subsequent
12373 records following. There is no control information of any kind. For
12374 example, if 32-bit integers are being written, each record takes
12375 4-bytes, so the record at index @var{K} starts at offset
12376 (@var{K}@minus{}1)*4.
12378 There is no limit on the size of Direct_IO files, they are expanded as
12379 necessary to accommodate whatever records are written to the file.
12381 @node Sequential_IO
12382 @section Sequential_IO
12385 Sequential_IO may be instantiated with either a definite (constrained)
12386 or indefinite (unconstrained) type.
12388 For the definite type case, the elements written to the file are simply
12389 the memory images of the data values with no control information of any
12390 kind. The resulting file should be read using the same type, no validity
12391 checking is performed on input.
12393 For the indefinite type case, the elements written consist of two
12394 parts. First is the size of the data item, written as the memory image
12395 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12396 the data value. The resulting file can only be read using the same
12397 (unconstrained) type. Normal assignment checks are performed on these
12398 read operations, and if these checks fail, @code{Data_Error} is
12399 raised. In particular, in the array case, the lengths must match, and in
12400 the variant record case, if the variable for a particular read operation
12401 is constrained, the discriminants must match.
12403 Note that it is not possible to use Sequential_IO to write variable
12404 length array items, and then read the data back into different length
12405 arrays. For example, the following will raise @code{Data_Error}:
12407 @smallexample @c ada
12408 package IO is new Sequential_IO (String);
12413 IO.Write (F, "hello!")
12414 IO.Reset (F, Mode=>In_File);
12421 On some Ada implementations, this will print @code{hell}, but the program is
12422 clearly incorrect, since there is only one element in the file, and that
12423 element is the string @code{hello!}.
12425 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12426 using Stream_IO, and this is the preferred mechanism. In particular, the
12427 above program fragment rewritten to use Stream_IO will work correctly.
12433 Text_IO files consist of a stream of characters containing the following
12434 special control characters:
12437 LF (line feed, 16#0A#) Line Mark
12438 FF (form feed, 16#0C#) Page Mark
12442 A canonical Text_IO file is defined as one in which the following
12443 conditions are met:
12447 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12451 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12452 end of a page and consequently can appear only immediately following a
12453 @code{LF} (line mark) character.
12456 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12457 (line mark, page mark). In the former case, the page mark is implicitly
12458 assumed to be present.
12462 A file written using Text_IO will be in canonical form provided that no
12463 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12464 or @code{Put_Line}. There will be no @code{FF} character at the end of
12465 the file unless an explicit @code{New_Page} operation was performed
12466 before closing the file.
12468 A canonical Text_IO file that is a regular file (i.e., not a device or a
12469 pipe) can be read using any of the routines in Text_IO@. The
12470 semantics in this case will be exactly as defined in the Ada Reference
12471 Manual, and all the routines in Text_IO are fully implemented.
12473 A text file that does not meet the requirements for a canonical Text_IO
12474 file has one of the following:
12478 The file contains @code{FF} characters not immediately following a
12479 @code{LF} character.
12482 The file contains @code{LF} or @code{FF} characters written by
12483 @code{Put} or @code{Put_Line}, which are not logically considered to be
12484 line marks or page marks.
12487 The file ends in a character other than @code{LF} or @code{FF},
12488 i.e.@: there is no explicit line mark or page mark at the end of the file.
12492 Text_IO can be used to read such non-standard text files but subprograms
12493 to do with line or page numbers do not have defined meanings. In
12494 particular, a @code{FF} character that does not follow a @code{LF}
12495 character may or may not be treated as a page mark from the point of
12496 view of page and line numbering. Every @code{LF} character is considered
12497 to end a line, and there is an implied @code{LF} character at the end of
12501 * Text_IO Stream Pointer Positioning::
12502 * Text_IO Reading and Writing Non-Regular Files::
12504 * Treating Text_IO Files as Streams::
12505 * Text_IO Extensions::
12506 * Text_IO Facilities for Unbounded Strings::
12509 @node Text_IO Stream Pointer Positioning
12510 @subsection Stream Pointer Positioning
12513 @code{Ada.Text_IO} has a definition of current position for a file that
12514 is being read. No internal buffering occurs in Text_IO, and usually the
12515 physical position in the stream used to implement the file corresponds
12516 to this logical position defined by Text_IO@. There are two exceptions:
12520 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12521 is positioned past the @code{LF} (line mark) that precedes the page
12522 mark. Text_IO maintains an internal flag so that subsequent read
12523 operations properly handle the logical position which is unchanged by
12524 the @code{End_Of_Page} call.
12527 After a call to @code{End_Of_File} that returns @code{True}, if the
12528 Text_IO file was positioned before the line mark at the end of file
12529 before the call, then the logical position is unchanged, but the stream
12530 is physically positioned right at the end of file (past the line mark,
12531 and past a possible page mark following the line mark. Again Text_IO
12532 maintains internal flags so that subsequent read operations properly
12533 handle the logical position.
12537 These discrepancies have no effect on the observable behavior of
12538 Text_IO, but if a single Ada stream is shared between a C program and
12539 Ada program, or shared (using @samp{shared=yes} in the form string)
12540 between two Ada files, then the difference may be observable in some
12543 @node Text_IO Reading and Writing Non-Regular Files
12544 @subsection Reading and Writing Non-Regular Files
12547 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12548 can be used for reading and writing. Writing is not affected and the
12549 sequence of characters output is identical to the normal file case, but
12550 for reading, the behavior of Text_IO is modified to avoid undesirable
12551 look-ahead as follows:
12553 An input file that is not a regular file is considered to have no page
12554 marks. Any @code{Ascii.FF} characters (the character normally used for a
12555 page mark) appearing in the file are considered to be data
12556 characters. In particular:
12560 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12561 following a line mark. If a page mark appears, it will be treated as a
12565 This avoids the need to wait for an extra character to be typed or
12566 entered from the pipe to complete one of these operations.
12569 @code{End_Of_Page} always returns @code{False}
12572 @code{End_Of_File} will return @code{False} if there is a page mark at
12573 the end of the file.
12577 Output to non-regular files is the same as for regular files. Page marks
12578 may be written to non-regular files using @code{New_Page}, but as noted
12579 above they will not be treated as page marks on input if the output is
12580 piped to another Ada program.
12582 Another important discrepancy when reading non-regular files is that the end
12583 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12584 pressing the @key{EOT} key,
12586 is signaled once (i.e.@: the test @code{End_Of_File}
12587 will yield @code{True}, or a read will
12588 raise @code{End_Error}), but then reading can resume
12589 to read data past that end of
12590 file indication, until another end of file indication is entered.
12592 @node Get_Immediate
12593 @subsection Get_Immediate
12594 @cindex Get_Immediate
12597 Get_Immediate returns the next character (including control characters)
12598 from the input file. In particular, Get_Immediate will return LF or FF
12599 characters used as line marks or page marks. Such operations leave the
12600 file positioned past the control character, and it is thus not treated
12601 as having its normal function. This means that page, line and column
12602 counts after this kind of Get_Immediate call are set as though the mark
12603 did not occur. In the case where a Get_Immediate leaves the file
12604 positioned between the line mark and page mark (which is not normally
12605 possible), it is undefined whether the FF character will be treated as a
12608 @node Treating Text_IO Files as Streams
12609 @subsection Treating Text_IO Files as Streams
12610 @cindex Stream files
12613 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12614 as a stream. Data written to a Text_IO file in this stream mode is
12615 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12616 16#0C# (@code{FF}), the resulting file may have non-standard
12617 format. Similarly if read operations are used to read from a Text_IO
12618 file treated as a stream, then @code{LF} and @code{FF} characters may be
12619 skipped and the effect is similar to that described above for
12620 @code{Get_Immediate}.
12622 @node Text_IO Extensions
12623 @subsection Text_IO Extensions
12624 @cindex Text_IO extensions
12627 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12628 to the standard @code{Text_IO} package:
12631 @item function File_Exists (Name : String) return Boolean;
12632 Determines if a file of the given name exists.
12634 @item function Get_Line return String;
12635 Reads a string from the standard input file. The value returned is exactly
12636 the length of the line that was read.
12638 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12639 Similar, except that the parameter File specifies the file from which
12640 the string is to be read.
12644 @node Text_IO Facilities for Unbounded Strings
12645 @subsection Text_IO Facilities for Unbounded Strings
12646 @cindex Text_IO for unbounded strings
12647 @cindex Unbounded_String, Text_IO operations
12650 The package @code{Ada.Strings.Unbounded.Text_IO}
12651 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12652 subprograms useful for Text_IO operations on unbounded strings:
12656 @item function Get_Line (File : File_Type) return Unbounded_String;
12657 Reads a line from the specified file
12658 and returns the result as an unbounded string.
12660 @item procedure Put (File : File_Type; U : Unbounded_String);
12661 Writes the value of the given unbounded string to the specified file
12662 Similar to the effect of
12663 @code{Put (To_String (U))} except that an extra copy is avoided.
12665 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12666 Writes the value of the given unbounded string to the specified file,
12667 followed by a @code{New_Line}.
12668 Similar to the effect of @code{Put_Line (To_String (U))} except
12669 that an extra copy is avoided.
12673 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12674 and is optional. If the parameter is omitted, then the standard input or
12675 output file is referenced as appropriate.
12677 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12678 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12679 @code{Wide_Text_IO} functionality for unbounded wide strings.
12681 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12682 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12683 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12686 @section Wide_Text_IO
12689 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12690 both input and output files may contain special sequences that represent
12691 wide character values. The encoding scheme for a given file may be
12692 specified using a FORM parameter:
12699 as part of the FORM string (WCEM = wide character encoding method),
12700 where @var{x} is one of the following characters
12706 Upper half encoding
12718 The encoding methods match those that
12719 can be used in a source
12720 program, but there is no requirement that the encoding method used for
12721 the source program be the same as the encoding method used for files,
12722 and different files may use different encoding methods.
12724 The default encoding method for the standard files, and for opened files
12725 for which no WCEM parameter is given in the FORM string matches the
12726 wide character encoding specified for the main program (the default
12727 being brackets encoding if no coding method was specified with -gnatW).
12731 In this encoding, a wide character is represented by a five character
12739 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12740 characters (using upper case letters) of the wide character code. For
12741 example, ESC A345 is used to represent the wide character with code
12742 16#A345#. This scheme is compatible with use of the full
12743 @code{Wide_Character} set.
12745 @item Upper Half Coding
12746 The wide character with encoding 16#abcd#, where the upper bit is on
12747 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12748 16#cd#. The second byte may never be a format control character, but is
12749 not required to be in the upper half. This method can be also used for
12750 shift-JIS or EUC where the internal coding matches the external coding.
12752 @item Shift JIS Coding
12753 A wide character is represented by a two character sequence 16#ab# and
12754 16#cd#, with the restrictions described for upper half encoding as
12755 described above. The internal character code is the corresponding JIS
12756 character according to the standard algorithm for Shift-JIS
12757 conversion. Only characters defined in the JIS code set table can be
12758 used with this encoding method.
12761 A wide character is represented by a two character sequence 16#ab# and
12762 16#cd#, with both characters being in the upper half. The internal
12763 character code is the corresponding JIS character according to the EUC
12764 encoding algorithm. Only characters defined in the JIS code set table
12765 can be used with this encoding method.
12768 A wide character is represented using
12769 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12770 10646-1/Am.2. Depending on the character value, the representation
12771 is a one, two, or three byte sequence:
12774 16#0000#-16#007f#: 2#0xxxxxxx#
12775 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12776 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12780 where the @var{xxx} bits correspond to the left-padded bits of the
12781 16-bit character value. Note that all lower half ASCII characters
12782 are represented as ASCII bytes and all upper half characters and
12783 other wide characters are represented as sequences of upper-half
12784 (The full UTF-8 scheme allows for encoding 31-bit characters as
12785 6-byte sequences, but in this implementation, all UTF-8 sequences
12786 of four or more bytes length will raise a Constraint_Error, as
12787 will all invalid UTF-8 sequences.)
12789 @item Brackets Coding
12790 In this encoding, a wide character is represented by the following eight
12791 character sequence:
12798 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12799 characters (using uppercase letters) of the wide character code. For
12800 example, @code{["A345"]} is used to represent the wide character with code
12802 This scheme is compatible with use of the full Wide_Character set.
12803 On input, brackets coding can also be used for upper half characters,
12804 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12805 is only used for wide characters with a code greater than @code{16#FF#}.
12807 Note that brackets coding is not normally used in the context of
12808 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12809 a portable way of encoding source files. In the context of Wide_Text_IO
12810 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12811 any instance of the left bracket character other than to encode wide
12812 character values using the brackets encoding method. In practice it is
12813 expected that some standard wide character encoding method such
12814 as UTF-8 will be used for text input output.
12816 If brackets notation is used, then any occurrence of a left bracket
12817 in the input file which is not the start of a valid wide character
12818 sequence will cause Constraint_Error to be raised. It is possible to
12819 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12820 input will interpret this as a left bracket.
12822 However, when a left bracket is output, it will be output as a left bracket
12823 and not as ["5B"]. We make this decision because for normal use of
12824 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12825 brackets. For example, if we write:
12828 Put_Line ("Start of output [first run]");
12832 we really do not want to have the left bracket in this message clobbered so
12833 that the output reads:
12836 Start of output ["5B"]first run]
12840 In practice brackets encoding is reasonably useful for normal Put_Line use
12841 since we won't get confused between left brackets and wide character
12842 sequences in the output. But for input, or when files are written out
12843 and read back in, it really makes better sense to use one of the standard
12844 encoding methods such as UTF-8.
12849 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12850 not all wide character
12851 values can be represented. An attempt to output a character that cannot
12852 be represented using the encoding scheme for the file causes
12853 Constraint_Error to be raised. An invalid wide character sequence on
12854 input also causes Constraint_Error to be raised.
12857 * Wide_Text_IO Stream Pointer Positioning::
12858 * Wide_Text_IO Reading and Writing Non-Regular Files::
12861 @node Wide_Text_IO Stream Pointer Positioning
12862 @subsection Stream Pointer Positioning
12865 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12866 of stream pointer positioning (@pxref{Text_IO}). There is one additional
12869 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12870 normal lower ASCII set (i.e.@: a character in the range:
12872 @smallexample @c ada
12873 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12877 then although the logical position of the file pointer is unchanged by
12878 the @code{Look_Ahead} call, the stream is physically positioned past the
12879 wide character sequence. Again this is to avoid the need for buffering
12880 or backup, and all @code{Wide_Text_IO} routines check the internal
12881 indication that this situation has occurred so that this is not visible
12882 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
12883 can be observed if the wide text file shares a stream with another file.
12885 @node Wide_Text_IO Reading and Writing Non-Regular Files
12886 @subsection Reading and Writing Non-Regular Files
12889 As in the case of Text_IO, when a non-regular file is read, it is
12890 assumed that the file contains no page marks (any form characters are
12891 treated as data characters), and @code{End_Of_Page} always returns
12892 @code{False}. Similarly, the end of file indication is not sticky, so
12893 it is possible to read beyond an end of file.
12895 @node Wide_Wide_Text_IO
12896 @section Wide_Wide_Text_IO
12899 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12900 both input and output files may contain special sequences that represent
12901 wide wide character values. The encoding scheme for a given file may be
12902 specified using a FORM parameter:
12909 as part of the FORM string (WCEM = wide character encoding method),
12910 where @var{x} is one of the following characters
12916 Upper half encoding
12928 The encoding methods match those that
12929 can be used in a source
12930 program, but there is no requirement that the encoding method used for
12931 the source program be the same as the encoding method used for files,
12932 and different files may use different encoding methods.
12934 The default encoding method for the standard files, and for opened files
12935 for which no WCEM parameter is given in the FORM string matches the
12936 wide character encoding specified for the main program (the default
12937 being brackets encoding if no coding method was specified with -gnatW).
12942 A wide character is represented using
12943 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12944 10646-1/Am.2. Depending on the character value, the representation
12945 is a one, two, three, or four byte sequence:
12948 16#000000#-16#00007f#: 2#0xxxxxxx#
12949 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12950 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12951 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12955 where the @var{xxx} bits correspond to the left-padded bits of the
12956 21-bit character value. Note that all lower half ASCII characters
12957 are represented as ASCII bytes and all upper half characters and
12958 other wide characters are represented as sequences of upper-half
12961 @item Brackets Coding
12962 In this encoding, a wide wide character is represented by the following eight
12963 character sequence if is in wide character range
12969 and by the following ten character sequence if not
12972 [ " a b c d e f " ]
12976 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12977 are the four or six hexadecimal
12978 characters (using uppercase letters) of the wide wide character code. For
12979 example, @code{["01A345"]} is used to represent the wide wide character
12980 with code @code{16#01A345#}.
12982 This scheme is compatible with use of the full Wide_Wide_Character set.
12983 On input, brackets coding can also be used for upper half characters,
12984 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12985 is only used for wide characters with a code greater than @code{16#FF#}.
12990 If is also possible to use the other Wide_Character encoding methods,
12991 such as Shift-JIS, but the other schemes cannot support the full range
12992 of wide wide characters.
12993 An attempt to output a character that cannot
12994 be represented using the encoding scheme for the file causes
12995 Constraint_Error to be raised. An invalid wide character sequence on
12996 input also causes Constraint_Error to be raised.
12999 * Wide_Wide_Text_IO Stream Pointer Positioning::
13000 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13003 @node Wide_Wide_Text_IO Stream Pointer Positioning
13004 @subsection Stream Pointer Positioning
13007 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13008 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13011 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13012 normal lower ASCII set (i.e.@: a character in the range:
13014 @smallexample @c ada
13015 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13019 then although the logical position of the file pointer is unchanged by
13020 the @code{Look_Ahead} call, the stream is physically positioned past the
13021 wide character sequence. Again this is to avoid the need for buffering
13022 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13023 indication that this situation has occurred so that this is not visible
13024 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13025 can be observed if the wide text file shares a stream with another file.
13027 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13028 @subsection Reading and Writing Non-Regular Files
13031 As in the case of Text_IO, when a non-regular file is read, it is
13032 assumed that the file contains no page marks (any form characters are
13033 treated as data characters), and @code{End_Of_Page} always returns
13034 @code{False}. Similarly, the end of file indication is not sticky, so
13035 it is possible to read beyond an end of file.
13041 A stream file is a sequence of bytes, where individual elements are
13042 written to the file as described in the Ada Reference Manual. The type
13043 @code{Stream_Element} is simply a byte. There are two ways to read or
13044 write a stream file.
13048 The operations @code{Read} and @code{Write} directly read or write a
13049 sequence of stream elements with no control information.
13052 The stream attributes applied to a stream file transfer data in the
13053 manner described for stream attributes.
13056 @node Text Translation
13057 @section Text Translation
13060 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13061 passed to Text_IO.Create and Text_IO.Open:
13062 @samp{Text_Translation=@var{Yes}} is the default, which means to
13063 translate LF to/from CR/LF on Windows systems.
13064 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13065 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13066 may be used to create Unix-style files on
13067 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13071 @section Shared Files
13074 Section A.14 of the Ada Reference Manual allows implementations to
13075 provide a wide variety of behavior if an attempt is made to access the
13076 same external file with two or more internal files.
13078 To provide a full range of functionality, while at the same time
13079 minimizing the problems of portability caused by this implementation
13080 dependence, GNAT handles file sharing as follows:
13084 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13085 to open two or more files with the same full name is considered an error
13086 and is not supported. The exception @code{Use_Error} will be
13087 raised. Note that a file that is not explicitly closed by the program
13088 remains open until the program terminates.
13091 If the form parameter @samp{shared=no} appears in the form string, the
13092 file can be opened or created with its own separate stream identifier,
13093 regardless of whether other files sharing the same external file are
13094 opened. The exact effect depends on how the C stream routines handle
13095 multiple accesses to the same external files using separate streams.
13098 If the form parameter @samp{shared=yes} appears in the form string for
13099 each of two or more files opened using the same full name, the same
13100 stream is shared between these files, and the semantics are as described
13101 in Ada Reference Manual, Section A.14.
13105 When a program that opens multiple files with the same name is ported
13106 from another Ada compiler to GNAT, the effect will be that
13107 @code{Use_Error} is raised.
13109 The documentation of the original compiler and the documentation of the
13110 program should then be examined to determine if file sharing was
13111 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13112 and @code{Create} calls as required.
13114 When a program is ported from GNAT to some other Ada compiler, no
13115 special attention is required unless the @samp{shared=@var{xxx}} form
13116 parameter is used in the program. In this case, you must examine the
13117 documentation of the new compiler to see if it supports the required
13118 file sharing semantics, and form strings modified appropriately. Of
13119 course it may be the case that the program cannot be ported if the
13120 target compiler does not support the required functionality. The best
13121 approach in writing portable code is to avoid file sharing (and hence
13122 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13125 One common use of file sharing in Ada 83 is the use of instantiations of
13126 Sequential_IO on the same file with different types, to achieve
13127 heterogeneous input-output. Although this approach will work in GNAT if
13128 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13129 for this purpose (using the stream attributes)
13131 @node Filenames encoding
13132 @section Filenames encoding
13135 An encoding form parameter can be used to specify the filename
13136 encoding @samp{encoding=@var{xxx}}.
13140 If the form parameter @samp{encoding=utf8} appears in the form string, the
13141 filename must be encoded in UTF-8.
13144 If the form parameter @samp{encoding=8bits} appears in the form
13145 string, the filename must be a standard 8bits string.
13148 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13149 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13150 variable. And if not set @samp{utf8} is assumed.
13154 The current system Windows ANSI code page.
13159 This encoding form parameter is only supported on the Windows
13160 platform. On the other Operating Systems the run-time is supporting
13164 @section Open Modes
13167 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13168 using the mode shown in the following table:
13171 @center @code{Open} and @code{Create} Call Modes
13173 @b{OPEN } @b{CREATE}
13174 Append_File "r+" "w+"
13176 Out_File (Direct_IO) "r+" "w"
13177 Out_File (all other cases) "w" "w"
13178 Inout_File "r+" "w+"
13182 If text file translation is required, then either @samp{b} or @samp{t}
13183 is added to the mode, depending on the setting of Text. Text file
13184 translation refers to the mapping of CR/LF sequences in an external file
13185 to LF characters internally. This mapping only occurs in DOS and
13186 DOS-like systems, and is not relevant to other systems.
13188 A special case occurs with Stream_IO@. As shown in the above table, the
13189 file is initially opened in @samp{r} or @samp{w} mode for the
13190 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13191 subsequently requires switching from reading to writing or vice-versa,
13192 then the file is reopened in @samp{r+} mode to permit the required operation.
13194 @node Operations on C Streams
13195 @section Operations on C Streams
13196 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13197 access to the C library functions for operations on C streams:
13199 @smallexample @c adanocomment
13200 package Interfaces.C_Streams is
13201 -- Note: the reason we do not use the types that are in
13202 -- Interfaces.C is that we want to avoid dragging in the
13203 -- code in this unit if possible.
13204 subtype chars is System.Address;
13205 -- Pointer to null-terminated array of characters
13206 subtype FILEs is System.Address;
13207 -- Corresponds to the C type FILE*
13208 subtype voids is System.Address;
13209 -- Corresponds to the C type void*
13210 subtype int is Integer;
13211 subtype long is Long_Integer;
13212 -- Note: the above types are subtypes deliberately, and it
13213 -- is part of this spec that the above correspondences are
13214 -- guaranteed. This means that it is legitimate to, for
13215 -- example, use Integer instead of int. We provide these
13216 -- synonyms for clarity, but in some cases it may be
13217 -- convenient to use the underlying types (for example to
13218 -- avoid an unnecessary dependency of a spec on the spec
13220 type size_t is mod 2 ** Standard'Address_Size;
13221 NULL_Stream : constant FILEs;
13222 -- Value returned (NULL in C) to indicate an
13223 -- fdopen/fopen/tmpfile error
13224 ----------------------------------
13225 -- Constants Defined in stdio.h --
13226 ----------------------------------
13227 EOF : constant int;
13228 -- Used by a number of routines to indicate error or
13230 IOFBF : constant int;
13231 IOLBF : constant int;
13232 IONBF : constant int;
13233 -- Used to indicate buffering mode for setvbuf call
13234 SEEK_CUR : constant int;
13235 SEEK_END : constant int;
13236 SEEK_SET : constant int;
13237 -- Used to indicate origin for fseek call
13238 function stdin return FILEs;
13239 function stdout return FILEs;
13240 function stderr return FILEs;
13241 -- Streams associated with standard files
13242 --------------------------
13243 -- Standard C functions --
13244 --------------------------
13245 -- The functions selected below are ones that are
13246 -- available in DOS, OS/2, UNIX and Xenix (but not
13247 -- necessarily in ANSI C). These are very thin interfaces
13248 -- which copy exactly the C headers. For more
13249 -- documentation on these functions, see the Microsoft C
13250 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13251 -- ISBN 1-55615-225-6), which includes useful information
13252 -- on system compatibility.
13253 procedure clearerr (stream : FILEs);
13254 function fclose (stream : FILEs) return int;
13255 function fdopen (handle : int; mode : chars) return FILEs;
13256 function feof (stream : FILEs) return int;
13257 function ferror (stream : FILEs) return int;
13258 function fflush (stream : FILEs) return int;
13259 function fgetc (stream : FILEs) return int;
13260 function fgets (strng : chars; n : int; stream : FILEs)
13262 function fileno (stream : FILEs) return int;
13263 function fopen (filename : chars; Mode : chars)
13265 -- Note: to maintain target independence, use
13266 -- text_translation_required, a boolean variable defined in
13267 -- a-sysdep.c to deal with the target dependent text
13268 -- translation requirement. If this variable is set,
13269 -- then b/t should be appended to the standard mode
13270 -- argument to set the text translation mode off or on
13272 function fputc (C : int; stream : FILEs) return int;
13273 function fputs (Strng : chars; Stream : FILEs) return int;
13290 function ftell (stream : FILEs) return long;
13297 function isatty (handle : int) return int;
13298 procedure mktemp (template : chars);
13299 -- The return value (which is just a pointer to template)
13301 procedure rewind (stream : FILEs);
13302 function rmtmp return int;
13310 function tmpfile return FILEs;
13311 function ungetc (c : int; stream : FILEs) return int;
13312 function unlink (filename : chars) return int;
13313 ---------------------
13314 -- Extra functions --
13315 ---------------------
13316 -- These functions supply slightly thicker bindings than
13317 -- those above. They are derived from functions in the
13318 -- C Run-Time Library, but may do a bit more work than
13319 -- just directly calling one of the Library functions.
13320 function is_regular_file (handle : int) return int;
13321 -- Tests if given handle is for a regular file (result 1)
13322 -- or for a non-regular file (pipe or device, result 0).
13323 ---------------------------------
13324 -- Control of Text/Binary Mode --
13325 ---------------------------------
13326 -- If text_translation_required is true, then the following
13327 -- functions may be used to dynamically switch a file from
13328 -- binary to text mode or vice versa. These functions have
13329 -- no effect if text_translation_required is false (i.e.@: in
13330 -- normal UNIX mode). Use fileno to get a stream handle.
13331 procedure set_binary_mode (handle : int);
13332 procedure set_text_mode (handle : int);
13333 ----------------------------
13334 -- Full Path Name support --
13335 ----------------------------
13336 procedure full_name (nam : chars; buffer : chars);
13337 -- Given a NUL terminated string representing a file
13338 -- name, returns in buffer a NUL terminated string
13339 -- representing the full path name for the file name.
13340 -- On systems where it is relevant the drive is also
13341 -- part of the full path name. It is the responsibility
13342 -- of the caller to pass an actual parameter for buffer
13343 -- that is big enough for any full path name. Use
13344 -- max_path_len given below as the size of buffer.
13345 max_path_len : integer;
13346 -- Maximum length of an allowable full path name on the
13347 -- system, including a terminating NUL character.
13348 end Interfaces.C_Streams;
13351 @node Interfacing to C Streams
13352 @section Interfacing to C Streams
13355 The packages in this section permit interfacing Ada files to C Stream
13358 @smallexample @c ada
13359 with Interfaces.C_Streams;
13360 package Ada.Sequential_IO.C_Streams is
13361 function C_Stream (F : File_Type)
13362 return Interfaces.C_Streams.FILEs;
13364 (File : in out File_Type;
13365 Mode : in File_Mode;
13366 C_Stream : in Interfaces.C_Streams.FILEs;
13367 Form : in String := "");
13368 end Ada.Sequential_IO.C_Streams;
13370 with Interfaces.C_Streams;
13371 package Ada.Direct_IO.C_Streams is
13372 function C_Stream (F : File_Type)
13373 return Interfaces.C_Streams.FILEs;
13375 (File : in out File_Type;
13376 Mode : in File_Mode;
13377 C_Stream : in Interfaces.C_Streams.FILEs;
13378 Form : in String := "");
13379 end Ada.Direct_IO.C_Streams;
13381 with Interfaces.C_Streams;
13382 package Ada.Text_IO.C_Streams is
13383 function C_Stream (F : File_Type)
13384 return Interfaces.C_Streams.FILEs;
13386 (File : in out File_Type;
13387 Mode : in File_Mode;
13388 C_Stream : in Interfaces.C_Streams.FILEs;
13389 Form : in String := "");
13390 end Ada.Text_IO.C_Streams;
13392 with Interfaces.C_Streams;
13393 package Ada.Wide_Text_IO.C_Streams is
13394 function C_Stream (F : File_Type)
13395 return Interfaces.C_Streams.FILEs;
13397 (File : in out File_Type;
13398 Mode : in File_Mode;
13399 C_Stream : in Interfaces.C_Streams.FILEs;
13400 Form : in String := "");
13401 end Ada.Wide_Text_IO.C_Streams;
13403 with Interfaces.C_Streams;
13404 package Ada.Wide_Wide_Text_IO.C_Streams is
13405 function C_Stream (F : File_Type)
13406 return Interfaces.C_Streams.FILEs;
13408 (File : in out File_Type;
13409 Mode : in File_Mode;
13410 C_Stream : in Interfaces.C_Streams.FILEs;
13411 Form : in String := "");
13412 end Ada.Wide_Wide_Text_IO.C_Streams;
13414 with Interfaces.C_Streams;
13415 package Ada.Stream_IO.C_Streams is
13416 function C_Stream (F : File_Type)
13417 return Interfaces.C_Streams.FILEs;
13419 (File : in out File_Type;
13420 Mode : in File_Mode;
13421 C_Stream : in Interfaces.C_Streams.FILEs;
13422 Form : in String := "");
13423 end Ada.Stream_IO.C_Streams;
13427 In each of these six packages, the @code{C_Stream} function obtains the
13428 @code{FILE} pointer from a currently opened Ada file. It is then
13429 possible to use the @code{Interfaces.C_Streams} package to operate on
13430 this stream, or the stream can be passed to a C program which can
13431 operate on it directly. Of course the program is responsible for
13432 ensuring that only appropriate sequences of operations are executed.
13434 One particular use of relevance to an Ada program is that the
13435 @code{setvbuf} function can be used to control the buffering of the
13436 stream used by an Ada file. In the absence of such a call the standard
13437 default buffering is used.
13439 The @code{Open} procedures in these packages open a file giving an
13440 existing C Stream instead of a file name. Typically this stream is
13441 imported from a C program, allowing an Ada file to operate on an
13444 @node The GNAT Library
13445 @chapter The GNAT Library
13448 The GNAT library contains a number of general and special purpose packages.
13449 It represents functionality that the GNAT developers have found useful, and
13450 which is made available to GNAT users. The packages described here are fully
13451 supported, and upwards compatibility will be maintained in future releases,
13452 so you can use these facilities with the confidence that the same functionality
13453 will be available in future releases.
13455 The chapter here simply gives a brief summary of the facilities available.
13456 The full documentation is found in the spec file for the package. The full
13457 sources of these library packages, including both spec and body, are provided
13458 with all GNAT releases. For example, to find out the full specifications of
13459 the SPITBOL pattern matching capability, including a full tutorial and
13460 extensive examples, look in the @file{g-spipat.ads} file in the library.
13462 For each entry here, the package name (as it would appear in a @code{with}
13463 clause) is given, followed by the name of the corresponding spec file in
13464 parentheses. The packages are children in four hierarchies, @code{Ada},
13465 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13466 GNAT-specific hierarchy.
13468 Note that an application program should only use packages in one of these
13469 four hierarchies if the package is defined in the Ada Reference Manual,
13470 or is listed in this section of the GNAT Programmers Reference Manual.
13471 All other units should be considered internal implementation units and
13472 should not be directly @code{with}'ed by application code. The use of
13473 a @code{with} statement that references one of these internal implementation
13474 units makes an application potentially dependent on changes in versions
13475 of GNAT, and will generate a warning message.
13478 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13479 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13480 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13481 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13482 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13483 * Ada.Command_Line.Environment (a-colien.ads)::
13484 * Ada.Command_Line.Remove (a-colire.ads)::
13485 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13486 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13487 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13488 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13489 * Ada.Exceptions.Traceback (a-exctra.ads)::
13490 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13491 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13492 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13493 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13494 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13495 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13496 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13497 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13498 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13499 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13500 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13501 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13502 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13503 * GNAT.Altivec (g-altive.ads)::
13504 * GNAT.Altivec.Conversions (g-altcon.ads)::
13505 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13506 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13507 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13508 * GNAT.Array_Split (g-arrspl.ads)::
13509 * GNAT.AWK (g-awk.ads)::
13510 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13511 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13512 * GNAT.Bubble_Sort (g-bubsor.ads)::
13513 * GNAT.Bubble_Sort_A (g-busora.ads)::
13514 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13515 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13516 * GNAT.Byte_Swapping (g-bytswa.ads)::
13517 * GNAT.Calendar (g-calend.ads)::
13518 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13519 * GNAT.Case_Util (g-casuti.ads)::
13520 * GNAT.CGI (g-cgi.ads)::
13521 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13522 * GNAT.CGI.Debug (g-cgideb.ads)::
13523 * GNAT.Command_Line (g-comlin.ads)::
13524 * GNAT.Compiler_Version (g-comver.ads)::
13525 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13526 * GNAT.CRC32 (g-crc32.ads)::
13527 * GNAT.Current_Exception (g-curexc.ads)::
13528 * GNAT.Debug_Pools (g-debpoo.ads)::
13529 * GNAT.Debug_Utilities (g-debuti.ads)::
13530 * GNAT.Decode_String (g-decstr.ads)::
13531 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13532 * GNAT.Directory_Operations (g-dirope.ads)::
13533 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13534 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13535 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13536 * GNAT.Encode_String (g-encstr.ads)::
13537 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13538 * GNAT.Exception_Actions (g-excact.ads)::
13539 * GNAT.Exception_Traces (g-exctra.ads)::
13540 * GNAT.Exceptions (g-except.ads)::
13541 * GNAT.Expect (g-expect.ads)::
13542 * GNAT.Float_Control (g-flocon.ads)::
13543 * GNAT.Heap_Sort (g-heasor.ads)::
13544 * GNAT.Heap_Sort_A (g-hesora.ads)::
13545 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13546 * GNAT.HTable (g-htable.ads)::
13547 * GNAT.IO (g-io.ads)::
13548 * GNAT.IO_Aux (g-io_aux.ads)::
13549 * GNAT.Lock_Files (g-locfil.ads)::
13550 * GNAT.MD5 (g-md5.ads)::
13551 * GNAT.Memory_Dump (g-memdum.ads)::
13552 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13553 * GNAT.OS_Lib (g-os_lib.ads)::
13554 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13555 * GNAT.Random_Numbers (g-rannum.ads)::
13556 * GNAT.Regexp (g-regexp.ads)::
13557 * GNAT.Registry (g-regist.ads)::
13558 * GNAT.Regpat (g-regpat.ads)::
13559 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13560 * GNAT.Semaphores (g-semaph.ads)::
13561 * GNAT.Serial_Communications (g-sercom.ads)::
13562 * GNAT.SHA1 (g-sha1.ads)::
13563 * GNAT.SHA224 (g-sha224.ads)::
13564 * GNAT.SHA256 (g-sha256.ads)::
13565 * GNAT.SHA384 (g-sha384.ads)::
13566 * GNAT.SHA512 (g-sha512.ads)::
13567 * GNAT.Signals (g-signal.ads)::
13568 * GNAT.Sockets (g-socket.ads)::
13569 * GNAT.Source_Info (g-souinf.ads)::
13570 * GNAT.Spelling_Checker (g-speche.ads)::
13571 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13572 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13573 * GNAT.Spitbol (g-spitbo.ads)::
13574 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13575 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13576 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13577 * GNAT.SSE (g-sse.ads)::
13578 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13579 * GNAT.Strings (g-string.ads)::
13580 * GNAT.String_Split (g-strspl.ads)::
13581 * GNAT.Table (g-table.ads)::
13582 * GNAT.Task_Lock (g-tasloc.ads)::
13583 * GNAT.Threads (g-thread.ads)::
13584 * GNAT.Time_Stamp (g-timsta.ads)::
13585 * GNAT.Traceback (g-traceb.ads)::
13586 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13587 * GNAT.UTF_32 (g-utf_32.ads)::
13588 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13589 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13590 * GNAT.Wide_String_Split (g-wistsp.ads)::
13591 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13592 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13593 * Interfaces.C.Extensions (i-cexten.ads)::
13594 * Interfaces.C.Streams (i-cstrea.ads)::
13595 * Interfaces.CPP (i-cpp.ads)::
13596 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13597 * Interfaces.VxWorks (i-vxwork.ads)::
13598 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13599 * System.Address_Image (s-addima.ads)::
13600 * System.Assertions (s-assert.ads)::
13601 * System.Memory (s-memory.ads)::
13602 * System.Partition_Interface (s-parint.ads)::
13603 * System.Pool_Global (s-pooglo.ads)::
13604 * System.Pool_Local (s-pooloc.ads)::
13605 * System.Restrictions (s-restri.ads)::
13606 * System.Rident (s-rident.ads)::
13607 * System.Strings.Stream_Ops (s-ststop.ads)::
13608 * System.Task_Info (s-tasinf.ads)::
13609 * System.Wch_Cnv (s-wchcnv.ads)::
13610 * System.Wch_Con (s-wchcon.ads)::
13613 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13614 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13615 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13616 @cindex Latin_9 constants for Character
13619 This child of @code{Ada.Characters}
13620 provides a set of definitions corresponding to those in the
13621 RM-defined package @code{Ada.Characters.Latin_1} but with the
13622 few modifications required for @code{Latin-9}
13623 The provision of such a package
13624 is specifically authorized by the Ada Reference Manual
13627 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13628 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13629 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13630 @cindex Latin_1 constants for Wide_Character
13633 This child of @code{Ada.Characters}
13634 provides a set of definitions corresponding to those in the
13635 RM-defined package @code{Ada.Characters.Latin_1} but with the
13636 types of the constants being @code{Wide_Character}
13637 instead of @code{Character}. The provision of such a package
13638 is specifically authorized by the Ada Reference Manual
13641 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13642 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13643 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13644 @cindex Latin_9 constants for Wide_Character
13647 This child of @code{Ada.Characters}
13648 provides a set of definitions corresponding to those in the
13649 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13650 types of the constants being @code{Wide_Character}
13651 instead of @code{Character}. The provision of such a package
13652 is specifically authorized by the Ada Reference Manual
13655 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13656 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13657 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13658 @cindex Latin_1 constants for Wide_Wide_Character
13661 This child of @code{Ada.Characters}
13662 provides a set of definitions corresponding to those in the
13663 RM-defined package @code{Ada.Characters.Latin_1} but with the
13664 types of the constants being @code{Wide_Wide_Character}
13665 instead of @code{Character}. The provision of such a package
13666 is specifically authorized by the Ada Reference Manual
13669 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13670 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13671 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13672 @cindex Latin_9 constants for Wide_Wide_Character
13675 This child of @code{Ada.Characters}
13676 provides a set of definitions corresponding to those in the
13677 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13678 types of the constants being @code{Wide_Wide_Character}
13679 instead of @code{Character}. The provision of such a package
13680 is specifically authorized by the Ada Reference Manual
13683 @node Ada.Command_Line.Environment (a-colien.ads)
13684 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13685 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13686 @cindex Environment entries
13689 This child of @code{Ada.Command_Line}
13690 provides a mechanism for obtaining environment values on systems
13691 where this concept makes sense.
13693 @node Ada.Command_Line.Remove (a-colire.ads)
13694 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13695 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13696 @cindex Removing command line arguments
13697 @cindex Command line, argument removal
13700 This child of @code{Ada.Command_Line}
13701 provides a mechanism for logically removing
13702 arguments from the argument list. Once removed, an argument is not visible
13703 to further calls on the subprograms in @code{Ada.Command_Line} will not
13704 see the removed argument.
13706 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13707 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13708 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13709 @cindex Response file for command line
13710 @cindex Command line, response file
13711 @cindex Command line, handling long command lines
13714 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13715 getting command line arguments from a text file, called a "response file".
13716 Using a response file allow passing a set of arguments to an executable longer
13717 than the maximum allowed by the system on the command line.
13719 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13720 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13721 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13722 @cindex C Streams, Interfacing with Direct_IO
13725 This package provides subprograms that allow interfacing between
13726 C streams and @code{Direct_IO}. The stream identifier can be
13727 extracted from a file opened on the Ada side, and an Ada file
13728 can be constructed from a stream opened on the C side.
13730 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13731 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13732 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13733 @cindex Null_Occurrence, testing for
13736 This child subprogram provides a way of testing for the null
13737 exception occurrence (@code{Null_Occurrence}) without raising
13740 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13741 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13742 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13743 @cindex Null_Occurrence, testing for
13746 This child subprogram is used for handling otherwise unhandled
13747 exceptions (hence the name last chance), and perform clean ups before
13748 terminating the program. Note that this subprogram never returns.
13750 @node Ada.Exceptions.Traceback (a-exctra.ads)
13751 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13752 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13753 @cindex Traceback for Exception Occurrence
13756 This child package provides the subprogram (@code{Tracebacks}) to
13757 give a traceback array of addresses based on an exception
13760 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13761 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13762 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13763 @cindex C Streams, Interfacing with Sequential_IO
13766 This package provides subprograms that allow interfacing between
13767 C streams and @code{Sequential_IO}. The stream identifier can be
13768 extracted from a file opened on the Ada side, and an Ada file
13769 can be constructed from a stream opened on the C side.
13771 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13772 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13773 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13774 @cindex C Streams, Interfacing with Stream_IO
13777 This package provides subprograms that allow interfacing between
13778 C streams and @code{Stream_IO}. The stream identifier can be
13779 extracted from a file opened on the Ada side, and an Ada file
13780 can be constructed from a stream opened on the C side.
13782 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13783 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13784 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13785 @cindex @code{Unbounded_String}, IO support
13786 @cindex @code{Text_IO}, extensions for unbounded strings
13789 This package provides subprograms for Text_IO for unbounded
13790 strings, avoiding the necessity for an intermediate operation
13791 with ordinary strings.
13793 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13794 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13795 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13796 @cindex @code{Unbounded_Wide_String}, IO support
13797 @cindex @code{Text_IO}, extensions for unbounded wide strings
13800 This package provides subprograms for Text_IO for unbounded
13801 wide strings, avoiding the necessity for an intermediate operation
13802 with ordinary wide strings.
13804 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13805 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13806 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13807 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13808 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13811 This package provides subprograms for Text_IO for unbounded
13812 wide wide strings, avoiding the necessity for an intermediate operation
13813 with ordinary wide wide strings.
13815 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13816 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13817 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13818 @cindex C Streams, Interfacing with @code{Text_IO}
13821 This package provides subprograms that allow interfacing between
13822 C streams and @code{Text_IO}. The stream identifier can be
13823 extracted from a file opened on the Ada side, and an Ada file
13824 can be constructed from a stream opened on the C side.
13826 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
13827 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13828 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13829 @cindex @code{Text_IO} resetting standard files
13832 This procedure is used to reset the status of the standard files used
13833 by Ada.Text_IO. This is useful in a situation (such as a restart in an
13834 embedded application) where the status of the files may change during
13835 execution (for example a standard input file may be redefined to be
13838 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13839 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13840 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13841 @cindex Unicode categorization, Wide_Character
13844 This package provides subprograms that allow categorization of
13845 Wide_Character values according to Unicode categories.
13847 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13848 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13849 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13850 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13853 This package provides subprograms that allow interfacing between
13854 C streams and @code{Wide_Text_IO}. The stream identifier can be
13855 extracted from a file opened on the Ada side, and an Ada file
13856 can be constructed from a stream opened on the C side.
13858 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
13859 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13860 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13861 @cindex @code{Wide_Text_IO} resetting standard files
13864 This procedure is used to reset the status of the standard files used
13865 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
13866 embedded application) where the status of the files may change during
13867 execution (for example a standard input file may be redefined to be
13870 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13871 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13872 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13873 @cindex Unicode categorization, Wide_Wide_Character
13876 This package provides subprograms that allow categorization of
13877 Wide_Wide_Character values according to Unicode categories.
13879 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13880 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13881 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13882 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13885 This package provides subprograms that allow interfacing between
13886 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
13887 extracted from a file opened on the Ada side, and an Ada file
13888 can be constructed from a stream opened on the C side.
13890 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
13891 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13892 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13893 @cindex @code{Wide_Wide_Text_IO} resetting standard files
13896 This procedure is used to reset the status of the standard files used
13897 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
13898 restart in an embedded application) where the status of the files may
13899 change during execution (for example a standard input file may be
13900 redefined to be interactive).
13902 @node GNAT.Altivec (g-altive.ads)
13903 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13904 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13908 This is the root package of the GNAT AltiVec binding. It provides
13909 definitions of constants and types common to all the versions of the
13912 @node GNAT.Altivec.Conversions (g-altcon.ads)
13913 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13914 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13918 This package provides the Vector/View conversion routines.
13920 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13921 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13922 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13926 This package exposes the Ada interface to the AltiVec operations on
13927 vector objects. A soft emulation is included by default in the GNAT
13928 library. The hard binding is provided as a separate package. This unit
13929 is common to both bindings.
13931 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13932 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13933 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13937 This package exposes the various vector types part of the Ada binding
13938 to AltiVec facilities.
13940 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13941 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13942 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13946 This package provides public 'View' data types from/to which private
13947 vector representations can be converted via
13948 GNAT.Altivec.Conversions. This allows convenient access to individual
13949 vector elements and provides a simple way to initialize vector
13952 @node GNAT.Array_Split (g-arrspl.ads)
13953 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13954 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13955 @cindex Array splitter
13958 Useful array-manipulation routines: given a set of separators, split
13959 an array wherever the separators appear, and provide direct access
13960 to the resulting slices.
13962 @node GNAT.AWK (g-awk.ads)
13963 @section @code{GNAT.AWK} (@file{g-awk.ads})
13964 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13969 Provides AWK-like parsing functions, with an easy interface for parsing one
13970 or more files containing formatted data. The file is viewed as a database
13971 where each record is a line and a field is a data element in this line.
13973 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13974 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13975 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13977 @cindex Bounded Buffers
13980 Provides a concurrent generic bounded buffer abstraction. Instances are
13981 useful directly or as parts of the implementations of other abstractions,
13984 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13985 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13986 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13991 Provides a thread-safe asynchronous intertask mailbox communication facility.
13993 @node GNAT.Bubble_Sort (g-bubsor.ads)
13994 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13995 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13997 @cindex Bubble sort
14000 Provides a general implementation of bubble sort usable for sorting arbitrary
14001 data items. Exchange and comparison procedures are provided by passing
14002 access-to-procedure values.
14004 @node GNAT.Bubble_Sort_A (g-busora.ads)
14005 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14006 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14008 @cindex Bubble sort
14011 Provides a general implementation of bubble sort usable for sorting arbitrary
14012 data items. Move and comparison procedures are provided by passing
14013 access-to-procedure values. This is an older version, retained for
14014 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14016 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14017 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14018 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14020 @cindex Bubble sort
14023 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14024 are provided as generic parameters, this improves efficiency, especially
14025 if the procedures can be inlined, at the expense of duplicating code for
14026 multiple instantiations.
14028 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14029 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14030 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14031 @cindex UTF-8 representation
14032 @cindex Wide characte representations
14035 Provides a routine which given a string, reads the start of the string to
14036 see whether it is one of the standard byte order marks (BOM's) which signal
14037 the encoding of the string. The routine includes detection of special XML
14038 sequences for various UCS input formats.
14040 @node GNAT.Byte_Swapping (g-bytswa.ads)
14041 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14042 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14043 @cindex Byte swapping
14047 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14048 Machine-specific implementations are available in some cases.
14050 @node GNAT.Calendar (g-calend.ads)
14051 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14052 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14053 @cindex @code{Calendar}
14056 Extends the facilities provided by @code{Ada.Calendar} to include handling
14057 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14058 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14059 C @code{timeval} format.
14061 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14062 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14063 @cindex @code{Calendar}
14065 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14067 @node GNAT.CRC32 (g-crc32.ads)
14068 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14069 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14071 @cindex Cyclic Redundancy Check
14074 This package implements the CRC-32 algorithm. For a full description
14075 of this algorithm see
14076 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14077 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14078 Aug.@: 1988. Sarwate, D.V@.
14080 @node GNAT.Case_Util (g-casuti.ads)
14081 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14082 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14083 @cindex Casing utilities
14084 @cindex Character handling (@code{GNAT.Case_Util})
14087 A set of simple routines for handling upper and lower casing of strings
14088 without the overhead of the full casing tables
14089 in @code{Ada.Characters.Handling}.
14091 @node GNAT.CGI (g-cgi.ads)
14092 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14093 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14094 @cindex CGI (Common Gateway Interface)
14097 This is a package for interfacing a GNAT program with a Web server via the
14098 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14099 parameters, which are a set of key/value pairs sent by the Web server. It
14100 builds a table whose index is the key and provides some services to deal
14103 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14104 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14105 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14106 @cindex CGI (Common Gateway Interface) cookie support
14107 @cindex Cookie support in CGI
14110 This is a package to interface a GNAT program with a Web server via the
14111 Common Gateway Interface (CGI). It exports services to deal with Web
14112 cookies (piece of information kept in the Web client software).
14114 @node GNAT.CGI.Debug (g-cgideb.ads)
14115 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14116 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14117 @cindex CGI (Common Gateway Interface) debugging
14120 This is a package to help debugging CGI (Common Gateway Interface)
14121 programs written in Ada.
14123 @node GNAT.Command_Line (g-comlin.ads)
14124 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14125 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14126 @cindex Command line
14129 Provides a high level interface to @code{Ada.Command_Line} facilities,
14130 including the ability to scan for named switches with optional parameters
14131 and expand file names using wild card notations.
14133 @node GNAT.Compiler_Version (g-comver.ads)
14134 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14135 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14136 @cindex Compiler Version
14137 @cindex Version, of compiler
14140 Provides a routine for obtaining the version of the compiler used to
14141 compile the program. More accurately this is the version of the binder
14142 used to bind the program (this will normally be the same as the version
14143 of the compiler if a consistent tool set is used to compile all units
14146 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14147 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14148 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14152 Provides a simple interface to handle Ctrl-C keyboard events.
14154 @node GNAT.Current_Exception (g-curexc.ads)
14155 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14156 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14157 @cindex Current exception
14158 @cindex Exception retrieval
14161 Provides access to information on the current exception that has been raised
14162 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14163 specification syntax.
14164 This is particularly useful in simulating typical facilities for
14165 obtaining information about exceptions provided by Ada 83 compilers.
14167 @node GNAT.Debug_Pools (g-debpoo.ads)
14168 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14169 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14171 @cindex Debug pools
14172 @cindex Memory corruption debugging
14175 Provide a debugging storage pools that helps tracking memory corruption
14176 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14177 @value{EDITION} User's Guide}.
14179 @node GNAT.Debug_Utilities (g-debuti.ads)
14180 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14181 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14185 Provides a few useful utilities for debugging purposes, including conversion
14186 to and from string images of address values. Supports both C and Ada formats
14187 for hexadecimal literals.
14189 @node GNAT.Decode_String (g-decstr.ads)
14190 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14191 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14192 @cindex Decoding strings
14193 @cindex String decoding
14194 @cindex Wide character encoding
14199 A generic package providing routines for decoding wide character and wide wide
14200 character strings encoded as sequences of 8-bit characters using a specified
14201 encoding method. Includes validation routines, and also routines for stepping
14202 to next or previous encoded character in an encoded string.
14203 Useful in conjunction with Unicode character coding. Note there is a
14204 preinstantiation for UTF-8. See next entry.
14206 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14207 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14208 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14209 @cindex Decoding strings
14210 @cindex Decoding UTF-8 strings
14211 @cindex UTF-8 string decoding
14212 @cindex Wide character decoding
14217 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14219 @node GNAT.Directory_Operations (g-dirope.ads)
14220 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14221 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14222 @cindex Directory operations
14225 Provides a set of routines for manipulating directories, including changing
14226 the current directory, making new directories, and scanning the files in a
14229 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14230 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14231 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14232 @cindex Directory operations iteration
14235 A child unit of GNAT.Directory_Operations providing additional operations
14236 for iterating through directories.
14238 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14239 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14240 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14241 @cindex Hash tables
14244 A generic implementation of hash tables that can be used to hash arbitrary
14245 data. Provided in two forms, a simple form with built in hash functions,
14246 and a more complex form in which the hash function is supplied.
14249 This package provides a facility similar to that of @code{GNAT.HTable},
14250 except that this package declares a type that can be used to define
14251 dynamic instances of the hash table, while an instantiation of
14252 @code{GNAT.HTable} creates a single instance of the hash table.
14254 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14255 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14256 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14257 @cindex Table implementation
14258 @cindex Arrays, extendable
14261 A generic package providing a single dimension array abstraction where the
14262 length of the array can be dynamically modified.
14265 This package provides a facility similar to that of @code{GNAT.Table},
14266 except that this package declares a type that can be used to define
14267 dynamic instances of the table, while an instantiation of
14268 @code{GNAT.Table} creates a single instance of the table type.
14270 @node GNAT.Encode_String (g-encstr.ads)
14271 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14272 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14273 @cindex Encoding strings
14274 @cindex String encoding
14275 @cindex Wide character encoding
14280 A generic package providing routines for encoding wide character and wide
14281 wide character strings as sequences of 8-bit characters using a specified
14282 encoding method. Useful in conjunction with Unicode character coding.
14283 Note there is a preinstantiation for UTF-8. See next entry.
14285 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14286 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14287 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14288 @cindex Encoding strings
14289 @cindex Encoding UTF-8 strings
14290 @cindex UTF-8 string encoding
14291 @cindex Wide character encoding
14296 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14298 @node GNAT.Exception_Actions (g-excact.ads)
14299 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14300 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14301 @cindex Exception actions
14304 Provides callbacks when an exception is raised. Callbacks can be registered
14305 for specific exceptions, or when any exception is raised. This
14306 can be used for instance to force a core dump to ease debugging.
14308 @node GNAT.Exception_Traces (g-exctra.ads)
14309 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14310 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14311 @cindex Exception traces
14315 Provides an interface allowing to control automatic output upon exception
14318 @node GNAT.Exceptions (g-except.ads)
14319 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14320 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14321 @cindex Exceptions, Pure
14322 @cindex Pure packages, exceptions
14325 Normally it is not possible to raise an exception with
14326 a message from a subprogram in a pure package, since the
14327 necessary types and subprograms are in @code{Ada.Exceptions}
14328 which is not a pure unit. @code{GNAT.Exceptions} provides a
14329 facility for getting around this limitation for a few
14330 predefined exceptions, and for example allow raising
14331 @code{Constraint_Error} with a message from a pure subprogram.
14333 @node GNAT.Expect (g-expect.ads)
14334 @section @code{GNAT.Expect} (@file{g-expect.ads})
14335 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14338 Provides a set of subprograms similar to what is available
14339 with the standard Tcl Expect tool.
14340 It allows you to easily spawn and communicate with an external process.
14341 You can send commands or inputs to the process, and compare the output
14342 with some expected regular expression. Currently @code{GNAT.Expect}
14343 is implemented on all native GNAT ports except for OpenVMS@.
14344 It is not implemented for cross ports, and in particular is not
14345 implemented for VxWorks or LynxOS@.
14347 @node GNAT.Float_Control (g-flocon.ads)
14348 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14349 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14350 @cindex Floating-Point Processor
14353 Provides an interface for resetting the floating-point processor into the
14354 mode required for correct semantic operation in Ada. Some third party
14355 library calls may cause this mode to be modified, and the Reset procedure
14356 in this package can be used to reestablish the required mode.
14358 @node GNAT.Heap_Sort (g-heasor.ads)
14359 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14360 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14364 Provides a general implementation of heap sort usable for sorting arbitrary
14365 data items. Exchange and comparison procedures are provided by passing
14366 access-to-procedure values. The algorithm used is a modified heap sort
14367 that performs approximately N*log(N) comparisons in the worst case.
14369 @node GNAT.Heap_Sort_A (g-hesora.ads)
14370 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14371 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14375 Provides a general implementation of heap sort usable for sorting arbitrary
14376 data items. Move and comparison procedures are provided by passing
14377 access-to-procedure values. The algorithm used is a modified heap sort
14378 that performs approximately N*log(N) comparisons in the worst case.
14379 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14380 interface, but may be slightly more efficient.
14382 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14383 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14384 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14388 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14389 are provided as generic parameters, this improves efficiency, especially
14390 if the procedures can be inlined, at the expense of duplicating code for
14391 multiple instantiations.
14393 @node GNAT.HTable (g-htable.ads)
14394 @section @code{GNAT.HTable} (@file{g-htable.ads})
14395 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14396 @cindex Hash tables
14399 A generic implementation of hash tables that can be used to hash arbitrary
14400 data. Provides two approaches, one a simple static approach, and the other
14401 allowing arbitrary dynamic hash tables.
14403 @node GNAT.IO (g-io.ads)
14404 @section @code{GNAT.IO} (@file{g-io.ads})
14405 @cindex @code{GNAT.IO} (@file{g-io.ads})
14407 @cindex Input/Output facilities
14410 A simple preelaborable input-output package that provides a subset of
14411 simple Text_IO functions for reading characters and strings from
14412 Standard_Input, and writing characters, strings and integers to either
14413 Standard_Output or Standard_Error.
14415 @node GNAT.IO_Aux (g-io_aux.ads)
14416 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14417 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14419 @cindex Input/Output facilities
14421 Provides some auxiliary functions for use with Text_IO, including a test
14422 for whether a file exists, and functions for reading a line of text.
14424 @node GNAT.Lock_Files (g-locfil.ads)
14425 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14426 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14427 @cindex File locking
14428 @cindex Locking using files
14431 Provides a general interface for using files as locks. Can be used for
14432 providing program level synchronization.
14434 @node GNAT.MD5 (g-md5.ads)
14435 @section @code{GNAT.MD5} (@file{g-md5.ads})
14436 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14437 @cindex Message Digest MD5
14440 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14442 @node GNAT.Memory_Dump (g-memdum.ads)
14443 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14444 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14445 @cindex Dump Memory
14448 Provides a convenient routine for dumping raw memory to either the
14449 standard output or standard error files. Uses GNAT.IO for actual
14452 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14453 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14454 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14455 @cindex Exception, obtaining most recent
14458 Provides access to the most recently raised exception. Can be used for
14459 various logging purposes, including duplicating functionality of some
14460 Ada 83 implementation dependent extensions.
14462 @node GNAT.OS_Lib (g-os_lib.ads)
14463 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14464 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14465 @cindex Operating System interface
14466 @cindex Spawn capability
14469 Provides a range of target independent operating system interface functions,
14470 including time/date management, file operations, subprocess management,
14471 including a portable spawn procedure, and access to environment variables
14472 and error return codes.
14474 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14475 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14476 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14477 @cindex Hash functions
14480 Provides a generator of static minimal perfect hash functions. No
14481 collisions occur and each item can be retrieved from the table in one
14482 probe (perfect property). The hash table size corresponds to the exact
14483 size of the key set and no larger (minimal property). The key set has to
14484 be know in advance (static property). The hash functions are also order
14485 preserving. If w2 is inserted after w1 in the generator, their
14486 hashcode are in the same order. These hashing functions are very
14487 convenient for use with realtime applications.
14489 @node GNAT.Random_Numbers (g-rannum.ads)
14490 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14491 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14492 @cindex Random number generation
14495 Provides random number capabilities which extend those available in the
14496 standard Ada library and are more convenient to use.
14498 @node GNAT.Regexp (g-regexp.ads)
14499 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14500 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14501 @cindex Regular expressions
14502 @cindex Pattern matching
14505 A simple implementation of regular expressions, using a subset of regular
14506 expression syntax copied from familiar Unix style utilities. This is the
14507 simples of the three pattern matching packages provided, and is particularly
14508 suitable for ``file globbing'' applications.
14510 @node GNAT.Registry (g-regist.ads)
14511 @section @code{GNAT.Registry} (@file{g-regist.ads})
14512 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14513 @cindex Windows Registry
14516 This is a high level binding to the Windows registry. It is possible to
14517 do simple things like reading a key value, creating a new key. For full
14518 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14519 package provided with the Win32Ada binding
14521 @node GNAT.Regpat (g-regpat.ads)
14522 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14523 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14524 @cindex Regular expressions
14525 @cindex Pattern matching
14528 A complete implementation of Unix-style regular expression matching, copied
14529 from the original V7 style regular expression library written in C by
14530 Henry Spencer (and binary compatible with this C library).
14532 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14533 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14534 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14535 @cindex Secondary Stack Info
14538 Provide the capability to query the high water mark of the current task's
14541 @node GNAT.Semaphores (g-semaph.ads)
14542 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14543 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14547 Provides classic counting and binary semaphores using protected types.
14549 @node GNAT.Serial_Communications (g-sercom.ads)
14550 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14551 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14552 @cindex Serial_Communications
14555 Provides a simple interface to send and receive data over a serial
14556 port. This is only supported on GNU/Linux and Windows.
14558 @node GNAT.SHA1 (g-sha1.ads)
14559 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14560 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14561 @cindex Secure Hash Algorithm SHA-1
14564 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14567 @node GNAT.SHA224 (g-sha224.ads)
14568 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
14569 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14570 @cindex Secure Hash Algorithm SHA-224
14573 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14575 @node GNAT.SHA256 (g-sha256.ads)
14576 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
14577 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14578 @cindex Secure Hash Algorithm SHA-256
14581 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14583 @node GNAT.SHA384 (g-sha384.ads)
14584 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
14585 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14586 @cindex Secure Hash Algorithm SHA-384
14589 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14591 @node GNAT.SHA512 (g-sha512.ads)
14592 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
14593 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14594 @cindex Secure Hash Algorithm SHA-512
14597 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14599 @node GNAT.Signals (g-signal.ads)
14600 @section @code{GNAT.Signals} (@file{g-signal.ads})
14601 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14605 Provides the ability to manipulate the blocked status of signals on supported
14608 @node GNAT.Sockets (g-socket.ads)
14609 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14610 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14614 A high level and portable interface to develop sockets based applications.
14615 This package is based on the sockets thin binding found in
14616 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14617 on all native GNAT ports except for OpenVMS@. It is not implemented
14618 for the LynxOS@ cross port.
14620 @node GNAT.Source_Info (g-souinf.ads)
14621 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14622 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14623 @cindex Source Information
14626 Provides subprograms that give access to source code information known at
14627 compile time, such as the current file name and line number.
14629 @node GNAT.Spelling_Checker (g-speche.ads)
14630 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14631 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14632 @cindex Spell checking
14635 Provides a function for determining whether one string is a plausible
14636 near misspelling of another string.
14638 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14639 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14640 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14641 @cindex Spell checking
14644 Provides a generic function that can be instantiated with a string type for
14645 determining whether one string is a plausible near misspelling of another
14648 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14649 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14650 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14651 @cindex SPITBOL pattern matching
14652 @cindex Pattern matching
14655 A complete implementation of SNOBOL4 style pattern matching. This is the
14656 most elaborate of the pattern matching packages provided. It fully duplicates
14657 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14658 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14660 @node GNAT.Spitbol (g-spitbo.ads)
14661 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14662 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14663 @cindex SPITBOL interface
14666 The top level package of the collection of SPITBOL-style functionality, this
14667 package provides basic SNOBOL4 string manipulation functions, such as
14668 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14669 useful for constructing arbitrary mappings from strings in the style of
14670 the SNOBOL4 TABLE function.
14672 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14673 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14674 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14675 @cindex Sets of strings
14676 @cindex SPITBOL Tables
14679 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14680 for type @code{Standard.Boolean}, giving an implementation of sets of
14683 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14684 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14685 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14686 @cindex Integer maps
14688 @cindex SPITBOL Tables
14691 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14692 for type @code{Standard.Integer}, giving an implementation of maps
14693 from string to integer values.
14695 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14696 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14697 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14698 @cindex String maps
14700 @cindex SPITBOL Tables
14703 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14704 a variable length string type, giving an implementation of general
14705 maps from strings to strings.
14707 @node GNAT.SSE (g-sse.ads)
14708 @section @code{GNAT.SSE} (@file{g-sse.ads})
14709 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14712 Root of a set of units aimed at offering Ada bindings to a subset of
14713 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14714 targets. It exposes vector component types together with a general
14715 introduction to the binding contents and use.
14717 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14718 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14719 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14722 SSE vector types for use with SSE related intrinsics.
14724 @node GNAT.Strings (g-string.ads)
14725 @section @code{GNAT.Strings} (@file{g-string.ads})
14726 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14729 Common String access types and related subprograms. Basically it
14730 defines a string access and an array of string access types.
14732 @node GNAT.String_Split (g-strspl.ads)
14733 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14734 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14735 @cindex String splitter
14738 Useful string manipulation routines: given a set of separators, split
14739 a string wherever the separators appear, and provide direct access
14740 to the resulting slices. This package is instantiated from
14741 @code{GNAT.Array_Split}.
14743 @node GNAT.Table (g-table.ads)
14744 @section @code{GNAT.Table} (@file{g-table.ads})
14745 @cindex @code{GNAT.Table} (@file{g-table.ads})
14746 @cindex Table implementation
14747 @cindex Arrays, extendable
14750 A generic package providing a single dimension array abstraction where the
14751 length of the array can be dynamically modified.
14754 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14755 except that this package declares a single instance of the table type,
14756 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14757 used to define dynamic instances of the table.
14759 @node GNAT.Task_Lock (g-tasloc.ads)
14760 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14761 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14762 @cindex Task synchronization
14763 @cindex Task locking
14767 A very simple facility for locking and unlocking sections of code using a
14768 single global task lock. Appropriate for use in situations where contention
14769 between tasks is very rarely expected.
14771 @node GNAT.Time_Stamp (g-timsta.ads)
14772 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14773 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14775 @cindex Current time
14778 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14779 represents the current date and time in ISO 8601 format. This is a very simple
14780 routine with minimal code and there are no dependencies on any other unit.
14782 @node GNAT.Threads (g-thread.ads)
14783 @section @code{GNAT.Threads} (@file{g-thread.ads})
14784 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14785 @cindex Foreign threads
14786 @cindex Threads, foreign
14789 Provides facilities for dealing with foreign threads which need to be known
14790 by the GNAT run-time system. Consult the documentation of this package for
14791 further details if your program has threads that are created by a non-Ada
14792 environment which then accesses Ada code.
14794 @node GNAT.Traceback (g-traceb.ads)
14795 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14796 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14797 @cindex Trace back facilities
14800 Provides a facility for obtaining non-symbolic traceback information, useful
14801 in various debugging situations.
14803 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14804 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14805 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14806 @cindex Trace back facilities
14808 @node GNAT.UTF_32 (g-utf_32.ads)
14809 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14810 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14811 @cindex Wide character codes
14814 This is a package intended to be used in conjunction with the
14815 @code{Wide_Character} type in Ada 95 and the
14816 @code{Wide_Wide_Character} type in Ada 2005 (available
14817 in @code{GNAT} in Ada 2005 mode). This package contains
14818 Unicode categorization routines, as well as lexical
14819 categorization routines corresponding to the Ada 2005
14820 lexical rules for identifiers and strings, and also a
14821 lower case to upper case fold routine corresponding to
14822 the Ada 2005 rules for identifier equivalence.
14824 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14825 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14826 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14827 @cindex Spell checking
14830 Provides a function for determining whether one wide wide string is a plausible
14831 near misspelling of another wide wide string, where the strings are represented
14832 using the UTF_32_String type defined in System.Wch_Cnv.
14834 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14835 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14836 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14837 @cindex Spell checking
14840 Provides a function for determining whether one wide string is a plausible
14841 near misspelling of another wide string.
14843 @node GNAT.Wide_String_Split (g-wistsp.ads)
14844 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14845 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14846 @cindex Wide_String splitter
14849 Useful wide string manipulation routines: given a set of separators, split
14850 a wide string wherever the separators appear, and provide direct access
14851 to the resulting slices. This package is instantiated from
14852 @code{GNAT.Array_Split}.
14854 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14855 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14856 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14857 @cindex Spell checking
14860 Provides a function for determining whether one wide wide string is a plausible
14861 near misspelling of another wide wide string.
14863 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14864 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14865 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14866 @cindex Wide_Wide_String splitter
14869 Useful wide wide string manipulation routines: given a set of separators, split
14870 a wide wide string wherever the separators appear, and provide direct access
14871 to the resulting slices. This package is instantiated from
14872 @code{GNAT.Array_Split}.
14874 @node Interfaces.C.Extensions (i-cexten.ads)
14875 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14876 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14879 This package contains additional C-related definitions, intended
14880 for use with either manually or automatically generated bindings
14883 @node Interfaces.C.Streams (i-cstrea.ads)
14884 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14885 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14886 @cindex C streams, interfacing
14889 This package is a binding for the most commonly used operations
14892 @node Interfaces.CPP (i-cpp.ads)
14893 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14894 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14895 @cindex C++ interfacing
14896 @cindex Interfacing, to C++
14899 This package provides facilities for use in interfacing to C++. It
14900 is primarily intended to be used in connection with automated tools
14901 for the generation of C++ interfaces.
14903 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14904 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14905 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14906 @cindex IBM Packed Format
14907 @cindex Packed Decimal
14910 This package provides a set of routines for conversions to and
14911 from a packed decimal format compatible with that used on IBM
14914 @node Interfaces.VxWorks (i-vxwork.ads)
14915 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14916 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14917 @cindex Interfacing to VxWorks
14918 @cindex VxWorks, interfacing
14921 This package provides a limited binding to the VxWorks API.
14922 In particular, it interfaces with the
14923 VxWorks hardware interrupt facilities.
14925 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14926 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14927 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14928 @cindex Interfacing to VxWorks' I/O
14929 @cindex VxWorks, I/O interfacing
14930 @cindex VxWorks, Get_Immediate
14931 @cindex Get_Immediate, VxWorks
14934 This package provides a binding to the ioctl (IO/Control)
14935 function of VxWorks, defining a set of option values and
14936 function codes. A particular use of this package is
14937 to enable the use of Get_Immediate under VxWorks.
14939 @node System.Address_Image (s-addima.ads)
14940 @section @code{System.Address_Image} (@file{s-addima.ads})
14941 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14942 @cindex Address image
14943 @cindex Image, of an address
14946 This function provides a useful debugging
14947 function that gives an (implementation dependent)
14948 string which identifies an address.
14950 @node System.Assertions (s-assert.ads)
14951 @section @code{System.Assertions} (@file{s-assert.ads})
14952 @cindex @code{System.Assertions} (@file{s-assert.ads})
14954 @cindex Assert_Failure, exception
14957 This package provides the declaration of the exception raised
14958 by an run-time assertion failure, as well as the routine that
14959 is used internally to raise this assertion.
14961 @node System.Memory (s-memory.ads)
14962 @section @code{System.Memory} (@file{s-memory.ads})
14963 @cindex @code{System.Memory} (@file{s-memory.ads})
14964 @cindex Memory allocation
14967 This package provides the interface to the low level routines used
14968 by the generated code for allocation and freeing storage for the
14969 default storage pool (analogous to the C routines malloc and free.
14970 It also provides a reallocation interface analogous to the C routine
14971 realloc. The body of this unit may be modified to provide alternative
14972 allocation mechanisms for the default pool, and in addition, direct
14973 calls to this unit may be made for low level allocation uses (for
14974 example see the body of @code{GNAT.Tables}).
14976 @node System.Partition_Interface (s-parint.ads)
14977 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14978 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14979 @cindex Partition interfacing functions
14982 This package provides facilities for partition interfacing. It
14983 is used primarily in a distribution context when using Annex E
14986 @node System.Pool_Global (s-pooglo.ads)
14987 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14988 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14989 @cindex Storage pool, global
14990 @cindex Global storage pool
14993 This package provides a storage pool that is equivalent to the default
14994 storage pool used for access types for which no pool is specifically
14995 declared. It uses malloc/free to allocate/free and does not attempt to
14996 do any automatic reclamation.
14998 @node System.Pool_Local (s-pooloc.ads)
14999 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15000 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15001 @cindex Storage pool, local
15002 @cindex Local storage pool
15005 This package provides a storage pool that is intended for use with locally
15006 defined access types. It uses malloc/free for allocate/free, and maintains
15007 a list of allocated blocks, so that all storage allocated for the pool can
15008 be freed automatically when the pool is finalized.
15010 @node System.Restrictions (s-restri.ads)
15011 @section @code{System.Restrictions} (@file{s-restri.ads})
15012 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15013 @cindex Run-time restrictions access
15016 This package provides facilities for accessing at run time
15017 the status of restrictions specified at compile time for
15018 the partition. Information is available both with regard
15019 to actual restrictions specified, and with regard to
15020 compiler determined information on which restrictions
15021 are violated by one or more packages in the partition.
15023 @node System.Rident (s-rident.ads)
15024 @section @code{System.Rident} (@file{s-rident.ads})
15025 @cindex @code{System.Rident} (@file{s-rident.ads})
15026 @cindex Restrictions definitions
15029 This package provides definitions of the restrictions
15030 identifiers supported by GNAT, and also the format of
15031 the restrictions provided in package System.Restrictions.
15032 It is not normally necessary to @code{with} this generic package
15033 since the necessary instantiation is included in
15034 package System.Restrictions.
15036 @node System.Strings.Stream_Ops (s-ststop.ads)
15037 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15038 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15039 @cindex Stream operations
15040 @cindex String stream operations
15043 This package provides a set of stream subprograms for standard string types.
15044 It is intended primarily to support implicit use of such subprograms when
15045 stream attributes are applied to string types, but the subprograms in this
15046 package can be used directly by application programs.
15048 @node System.Task_Info (s-tasinf.ads)
15049 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15050 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15051 @cindex Task_Info pragma
15054 This package provides target dependent functionality that is used
15055 to support the @code{Task_Info} pragma
15057 @node System.Wch_Cnv (s-wchcnv.ads)
15058 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15059 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15060 @cindex Wide Character, Representation
15061 @cindex Wide String, Conversion
15062 @cindex Representation of wide characters
15065 This package provides routines for converting between
15066 wide and wide wide characters and a representation as a value of type
15067 @code{Standard.String}, using a specified wide character
15068 encoding method. It uses definitions in
15069 package @code{System.Wch_Con}.
15071 @node System.Wch_Con (s-wchcon.ads)
15072 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15073 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15076 This package provides definitions and descriptions of
15077 the various methods used for encoding wide characters
15078 in ordinary strings. These definitions are used by
15079 the package @code{System.Wch_Cnv}.
15081 @node Interfacing to Other Languages
15082 @chapter Interfacing to Other Languages
15084 The facilities in annex B of the Ada Reference Manual are fully
15085 implemented in GNAT, and in addition, a full interface to C++ is
15089 * Interfacing to C::
15090 * Interfacing to C++::
15091 * Interfacing to COBOL::
15092 * Interfacing to Fortran::
15093 * Interfacing to non-GNAT Ada code::
15096 @node Interfacing to C
15097 @section Interfacing to C
15100 Interfacing to C with GNAT can use one of two approaches:
15104 The types in the package @code{Interfaces.C} may be used.
15106 Standard Ada types may be used directly. This may be less portable to
15107 other compilers, but will work on all GNAT compilers, which guarantee
15108 correspondence between the C and Ada types.
15112 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15113 effect, since this is the default. The following table shows the
15114 correspondence between Ada scalar types and the corresponding C types.
15119 @item Short_Integer
15121 @item Short_Short_Integer
15125 @item Long_Long_Integer
15133 @item Long_Long_Float
15134 This is the longest floating-point type supported by the hardware.
15138 Additionally, there are the following general correspondences between Ada
15142 Ada enumeration types map to C enumeration types directly if pragma
15143 @code{Convention C} is specified, which causes them to have int
15144 length. Without pragma @code{Convention C}, Ada enumeration types map to
15145 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15146 @code{int}, respectively) depending on the number of values passed.
15147 This is the only case in which pragma @code{Convention C} affects the
15148 representation of an Ada type.
15151 Ada access types map to C pointers, except for the case of pointers to
15152 unconstrained types in Ada, which have no direct C equivalent.
15155 Ada arrays map directly to C arrays.
15158 Ada records map directly to C structures.
15161 Packed Ada records map to C structures where all members are bit fields
15162 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15165 @node Interfacing to C++
15166 @section Interfacing to C++
15169 The interface to C++ makes use of the following pragmas, which are
15170 primarily intended to be constructed automatically using a binding generator
15171 tool, although it is possible to construct them by hand. No suitable binding
15172 generator tool is supplied with GNAT though.
15174 Using these pragmas it is possible to achieve complete
15175 inter-operability between Ada tagged types and C++ class definitions.
15176 See @ref{Implementation Defined Pragmas}, for more details.
15179 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15180 The argument denotes an entity in the current declarative region that is
15181 declared as a tagged or untagged record type. It indicates that the type
15182 corresponds to an externally declared C++ class type, and is to be laid
15183 out the same way that C++ would lay out the type.
15185 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15186 for backward compatibility but its functionality is available
15187 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15189 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15190 This pragma identifies an imported function (imported in the usual way
15191 with pragma @code{Import}) as corresponding to a C++ constructor.
15194 @node Interfacing to COBOL
15195 @section Interfacing to COBOL
15198 Interfacing to COBOL is achieved as described in section B.4 of
15199 the Ada Reference Manual.
15201 @node Interfacing to Fortran
15202 @section Interfacing to Fortran
15205 Interfacing to Fortran is achieved as described in section B.5 of the
15206 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15207 multi-dimensional array causes the array to be stored in column-major
15208 order as required for convenient interface to Fortran.
15210 @node Interfacing to non-GNAT Ada code
15211 @section Interfacing to non-GNAT Ada code
15213 It is possible to specify the convention @code{Ada} in a pragma
15214 @code{Import} or pragma @code{Export}. However this refers to
15215 the calling conventions used by GNAT, which may or may not be
15216 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15217 compiler to allow interoperation.
15219 If arguments types are kept simple, and if the foreign compiler generally
15220 follows system calling conventions, then it may be possible to integrate
15221 files compiled by other Ada compilers, provided that the elaboration
15222 issues are adequately addressed (for example by eliminating the
15223 need for any load time elaboration).
15225 In particular, GNAT running on VMS is designed to
15226 be highly compatible with the DEC Ada 83 compiler, so this is one
15227 case in which it is possible to import foreign units of this type,
15228 provided that the data items passed are restricted to simple scalar
15229 values or simple record types without variants, or simple array
15230 types with fixed bounds.
15232 @node Specialized Needs Annexes
15233 @chapter Specialized Needs Annexes
15236 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15237 required in all implementations. However, as described in this chapter,
15238 GNAT implements all of these annexes:
15241 @item Systems Programming (Annex C)
15242 The Systems Programming Annex is fully implemented.
15244 @item Real-Time Systems (Annex D)
15245 The Real-Time Systems Annex is fully implemented.
15247 @item Distributed Systems (Annex E)
15248 Stub generation is fully implemented in the GNAT compiler. In addition,
15249 a complete compatible PCS is available as part of the GLADE system,
15250 a separate product. When the two
15251 products are used in conjunction, this annex is fully implemented.
15253 @item Information Systems (Annex F)
15254 The Information Systems annex is fully implemented.
15256 @item Numerics (Annex G)
15257 The Numerics Annex is fully implemented.
15259 @item Safety and Security / High-Integrity Systems (Annex H)
15260 The Safety and Security Annex (termed the High-Integrity Systems Annex
15261 in Ada 2005) is fully implemented.
15264 @node Implementation of Specific Ada Features
15265 @chapter Implementation of Specific Ada Features
15268 This chapter describes the GNAT implementation of several Ada language
15272 * Machine Code Insertions::
15273 * GNAT Implementation of Tasking::
15274 * GNAT Implementation of Shared Passive Packages::
15275 * Code Generation for Array Aggregates::
15276 * The Size of Discriminated Records with Default Discriminants::
15277 * Strict Conformance to the Ada Reference Manual::
15280 @node Machine Code Insertions
15281 @section Machine Code Insertions
15282 @cindex Machine Code insertions
15285 Package @code{Machine_Code} provides machine code support as described
15286 in the Ada Reference Manual in two separate forms:
15289 Machine code statements, consisting of qualified expressions that
15290 fit the requirements of RM section 13.8.
15292 An intrinsic callable procedure, providing an alternative mechanism of
15293 including machine instructions in a subprogram.
15297 The two features are similar, and both are closely related to the mechanism
15298 provided by the asm instruction in the GNU C compiler. Full understanding
15299 and use of the facilities in this package requires understanding the asm
15300 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15301 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15303 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15304 semantic restrictions and effects as described below. Both are provided so
15305 that the procedure call can be used as a statement, and the function call
15306 can be used to form a code_statement.
15308 The first example given in the GCC documentation is the C @code{asm}
15311 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15315 The equivalent can be written for GNAT as:
15317 @smallexample @c ada
15318 Asm ("fsinx %1 %0",
15319 My_Float'Asm_Output ("=f", result),
15320 My_Float'Asm_Input ("f", angle));
15324 The first argument to @code{Asm} is the assembler template, and is
15325 identical to what is used in GNU C@. This string must be a static
15326 expression. The second argument is the output operand list. It is
15327 either a single @code{Asm_Output} attribute reference, or a list of such
15328 references enclosed in parentheses (technically an array aggregate of
15331 The @code{Asm_Output} attribute denotes a function that takes two
15332 parameters. The first is a string, the second is the name of a variable
15333 of the type designated by the attribute prefix. The first (string)
15334 argument is required to be a static expression and designates the
15335 constraint for the parameter (e.g.@: what kind of register is
15336 required). The second argument is the variable to be updated with the
15337 result. The possible values for constraint are the same as those used in
15338 the RTL, and are dependent on the configuration file used to build the
15339 GCC back end. If there are no output operands, then this argument may
15340 either be omitted, or explicitly given as @code{No_Output_Operands}.
15342 The second argument of @code{@var{my_float}'Asm_Output} functions as
15343 though it were an @code{out} parameter, which is a little curious, but
15344 all names have the form of expressions, so there is no syntactic
15345 irregularity, even though normally functions would not be permitted
15346 @code{out} parameters. The third argument is the list of input
15347 operands. It is either a single @code{Asm_Input} attribute reference, or
15348 a list of such references enclosed in parentheses (technically an array
15349 aggregate of such references).
15351 The @code{Asm_Input} attribute denotes a function that takes two
15352 parameters. The first is a string, the second is an expression of the
15353 type designated by the prefix. The first (string) argument is required
15354 to be a static expression, and is the constraint for the parameter,
15355 (e.g.@: what kind of register is required). The second argument is the
15356 value to be used as the input argument. The possible values for the
15357 constant are the same as those used in the RTL, and are dependent on
15358 the configuration file used to built the GCC back end.
15360 If there are no input operands, this argument may either be omitted, or
15361 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15362 present in the above example, is a list of register names, called the
15363 @dfn{clobber} argument. This argument, if given, must be a static string
15364 expression, and is a space or comma separated list of names of registers
15365 that must be considered destroyed as a result of the @code{Asm} call. If
15366 this argument is the null string (the default value), then the code
15367 generator assumes that no additional registers are destroyed.
15369 The fifth argument, not present in the above example, called the
15370 @dfn{volatile} argument, is by default @code{False}. It can be set to
15371 the literal value @code{True} to indicate to the code generator that all
15372 optimizations with respect to the instruction specified should be
15373 suppressed, and that in particular, for an instruction that has outputs,
15374 the instruction will still be generated, even if none of the outputs are
15375 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15376 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15377 Generally it is strongly advisable to use Volatile for any ASM statement
15378 that is missing either input or output operands, or when two or more ASM
15379 statements appear in sequence, to avoid unwanted optimizations. A warning
15380 is generated if this advice is not followed.
15382 The @code{Asm} subprograms may be used in two ways. First the procedure
15383 forms can be used anywhere a procedure call would be valid, and
15384 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15385 be used to intersperse machine instructions with other Ada statements.
15386 Second, the function forms, which return a dummy value of the limited
15387 private type @code{Asm_Insn}, can be used in code statements, and indeed
15388 this is the only context where such calls are allowed. Code statements
15389 appear as aggregates of the form:
15391 @smallexample @c ada
15392 Asm_Insn'(Asm (@dots{}));
15393 Asm_Insn'(Asm_Volatile (@dots{}));
15397 In accordance with RM rules, such code statements are allowed only
15398 within subprograms whose entire body consists of such statements. It is
15399 not permissible to intermix such statements with other Ada statements.
15401 Typically the form using intrinsic procedure calls is more convenient
15402 and more flexible. The code statement form is provided to meet the RM
15403 suggestion that such a facility should be made available. The following
15404 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15405 is used, the arguments may be given in arbitrary order, following the
15406 normal rules for use of positional and named arguments)
15410 [Template =>] static_string_EXPRESSION
15411 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15412 [,[Inputs =>] INPUT_OPERAND_LIST ]
15413 [,[Clobber =>] static_string_EXPRESSION ]
15414 [,[Volatile =>] static_boolean_EXPRESSION] )
15416 OUTPUT_OPERAND_LIST ::=
15417 [PREFIX.]No_Output_Operands
15418 | OUTPUT_OPERAND_ATTRIBUTE
15419 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15421 OUTPUT_OPERAND_ATTRIBUTE ::=
15422 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15424 INPUT_OPERAND_LIST ::=
15425 [PREFIX.]No_Input_Operands
15426 | INPUT_OPERAND_ATTRIBUTE
15427 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15429 INPUT_OPERAND_ATTRIBUTE ::=
15430 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15434 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15435 are declared in the package @code{Machine_Code} and must be referenced
15436 according to normal visibility rules. In particular if there is no
15437 @code{use} clause for this package, then appropriate package name
15438 qualification is required.
15440 @node GNAT Implementation of Tasking
15441 @section GNAT Implementation of Tasking
15444 This chapter outlines the basic GNAT approach to tasking (in particular,
15445 a multi-layered library for portability) and discusses issues related
15446 to compliance with the Real-Time Systems Annex.
15449 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15450 * Ensuring Compliance with the Real-Time Annex::
15453 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15454 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15457 GNAT's run-time support comprises two layers:
15460 @item GNARL (GNAT Run-time Layer)
15461 @item GNULL (GNAT Low-level Library)
15465 In GNAT, Ada's tasking services rely on a platform and OS independent
15466 layer known as GNARL@. This code is responsible for implementing the
15467 correct semantics of Ada's task creation, rendezvous, protected
15470 GNARL decomposes Ada's tasking semantics into simpler lower level
15471 operations such as create a thread, set the priority of a thread,
15472 yield, create a lock, lock/unlock, etc. The spec for these low-level
15473 operations constitutes GNULLI, the GNULL Interface. This interface is
15474 directly inspired from the POSIX real-time API@.
15476 If the underlying executive or OS implements the POSIX standard
15477 faithfully, the GNULL Interface maps as is to the services offered by
15478 the underlying kernel. Otherwise, some target dependent glue code maps
15479 the services offered by the underlying kernel to the semantics expected
15482 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15483 key point is that each Ada task is mapped on a thread in the underlying
15484 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15486 In addition Ada task priorities map onto the underlying thread priorities.
15487 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15491 The underlying scheduler is used to schedule the Ada tasks. This
15492 makes Ada tasks as efficient as kernel threads from a scheduling
15496 Interaction with code written in C containing threads is eased
15497 since at the lowest level Ada tasks and C threads map onto the same
15498 underlying kernel concept.
15501 When an Ada task is blocked during I/O the remaining Ada tasks are
15505 On multiprocessor systems Ada tasks can execute in parallel.
15509 Some threads libraries offer a mechanism to fork a new process, with the
15510 child process duplicating the threads from the parent.
15512 support this functionality when the parent contains more than one task.
15513 @cindex Forking a new process
15515 @node Ensuring Compliance with the Real-Time Annex
15516 @subsection Ensuring Compliance with the Real-Time Annex
15517 @cindex Real-Time Systems Annex compliance
15520 Although mapping Ada tasks onto
15521 the underlying threads has significant advantages, it does create some
15522 complications when it comes to respecting the scheduling semantics
15523 specified in the real-time annex (Annex D).
15525 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15526 scheduling policy states:
15529 @emph{When the active priority of a ready task that is not running
15530 changes, or the setting of its base priority takes effect, the
15531 task is removed from the ready queue for its old active priority
15532 and is added at the tail of the ready queue for its new active
15533 priority, except in the case where the active priority is lowered
15534 due to the loss of inherited priority, in which case the task is
15535 added at the head of the ready queue for its new active priority.}
15539 While most kernels do put tasks at the end of the priority queue when
15540 a task changes its priority, (which respects the main
15541 FIFO_Within_Priorities requirement), almost none keep a thread at the
15542 beginning of its priority queue when its priority drops from the loss
15543 of inherited priority.
15545 As a result most vendors have provided incomplete Annex D implementations.
15547 The GNAT run-time, has a nice cooperative solution to this problem
15548 which ensures that accurate FIFO_Within_Priorities semantics are
15551 The principle is as follows. When an Ada task T is about to start
15552 running, it checks whether some other Ada task R with the same
15553 priority as T has been suspended due to the loss of priority
15554 inheritance. If this is the case, T yields and is placed at the end of
15555 its priority queue. When R arrives at the front of the queue it
15558 Note that this simple scheme preserves the relative order of the tasks
15559 that were ready to execute in the priority queue where R has been
15562 @node GNAT Implementation of Shared Passive Packages
15563 @section GNAT Implementation of Shared Passive Packages
15564 @cindex Shared passive packages
15567 GNAT fully implements the pragma @code{Shared_Passive} for
15568 @cindex pragma @code{Shared_Passive}
15569 the purpose of designating shared passive packages.
15570 This allows the use of passive partitions in the
15571 context described in the Ada Reference Manual; i.e., for communication
15572 between separate partitions of a distributed application using the
15573 features in Annex E.
15575 @cindex Distribution Systems Annex
15577 However, the implementation approach used by GNAT provides for more
15578 extensive usage as follows:
15581 @item Communication between separate programs
15583 This allows separate programs to access the data in passive
15584 partitions, using protected objects for synchronization where
15585 needed. The only requirement is that the two programs have a
15586 common shared file system. It is even possible for programs
15587 running on different machines with different architectures
15588 (e.g.@: different endianness) to communicate via the data in
15589 a passive partition.
15591 @item Persistence between program runs
15593 The data in a passive package can persist from one run of a
15594 program to another, so that a later program sees the final
15595 values stored by a previous run of the same program.
15600 The implementation approach used is to store the data in files. A
15601 separate stream file is created for each object in the package, and
15602 an access to an object causes the corresponding file to be read or
15605 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15606 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15607 set to the directory to be used for these files.
15608 The files in this directory
15609 have names that correspond to their fully qualified names. For
15610 example, if we have the package
15612 @smallexample @c ada
15614 pragma Shared_Passive (X);
15621 and the environment variable is set to @code{/stemp/}, then the files created
15622 will have the names:
15630 These files are created when a value is initially written to the object, and
15631 the files are retained until manually deleted. This provides the persistence
15632 semantics. If no file exists, it means that no partition has assigned a value
15633 to the variable; in this case the initial value declared in the package
15634 will be used. This model ensures that there are no issues in synchronizing
15635 the elaboration process, since elaboration of passive packages elaborates the
15636 initial values, but does not create the files.
15638 The files are written using normal @code{Stream_IO} access.
15639 If you want to be able
15640 to communicate between programs or partitions running on different
15641 architectures, then you should use the XDR versions of the stream attribute
15642 routines, since these are architecture independent.
15644 If active synchronization is required for access to the variables in the
15645 shared passive package, then as described in the Ada Reference Manual, the
15646 package may contain protected objects used for this purpose. In this case
15647 a lock file (whose name is @file{___lock} (three underscores)
15648 is created in the shared memory directory.
15649 @cindex @file{___lock} file (for shared passive packages)
15650 This is used to provide the required locking
15651 semantics for proper protected object synchronization.
15653 As of January 2003, GNAT supports shared passive packages on all platforms
15654 except for OpenVMS.
15656 @node Code Generation for Array Aggregates
15657 @section Code Generation for Array Aggregates
15660 * Static constant aggregates with static bounds::
15661 * Constant aggregates with unconstrained nominal types::
15662 * Aggregates with static bounds::
15663 * Aggregates with non-static bounds::
15664 * Aggregates in assignment statements::
15668 Aggregates have a rich syntax and allow the user to specify the values of
15669 complex data structures by means of a single construct. As a result, the
15670 code generated for aggregates can be quite complex and involve loops, case
15671 statements and multiple assignments. In the simplest cases, however, the
15672 compiler will recognize aggregates whose components and constraints are
15673 fully static, and in those cases the compiler will generate little or no
15674 executable code. The following is an outline of the code that GNAT generates
15675 for various aggregate constructs. For further details, you will find it
15676 useful to examine the output produced by the -gnatG flag to see the expanded
15677 source that is input to the code generator. You may also want to examine
15678 the assembly code generated at various levels of optimization.
15680 The code generated for aggregates depends on the context, the component values,
15681 and the type. In the context of an object declaration the code generated is
15682 generally simpler than in the case of an assignment. As a general rule, static
15683 component values and static subtypes also lead to simpler code.
15685 @node Static constant aggregates with static bounds
15686 @subsection Static constant aggregates with static bounds
15689 For the declarations:
15690 @smallexample @c ada
15691 type One_Dim is array (1..10) of integer;
15692 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15696 GNAT generates no executable code: the constant ar0 is placed in static memory.
15697 The same is true for constant aggregates with named associations:
15699 @smallexample @c ada
15700 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15701 Cr3 : constant One_Dim := (others => 7777);
15705 The same is true for multidimensional constant arrays such as:
15707 @smallexample @c ada
15708 type two_dim is array (1..3, 1..3) of integer;
15709 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15713 The same is true for arrays of one-dimensional arrays: the following are
15716 @smallexample @c ada
15717 type ar1b is array (1..3) of boolean;
15718 type ar_ar is array (1..3) of ar1b;
15719 None : constant ar1b := (others => false); -- fully static
15720 None2 : constant ar_ar := (1..3 => None); -- fully static
15724 However, for multidimensional aggregates with named associations, GNAT will
15725 generate assignments and loops, even if all associations are static. The
15726 following two declarations generate a loop for the first dimension, and
15727 individual component assignments for the second dimension:
15729 @smallexample @c ada
15730 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15731 Zero2: constant two_dim := (others => (others => 0));
15734 @node Constant aggregates with unconstrained nominal types
15735 @subsection Constant aggregates with unconstrained nominal types
15738 In such cases the aggregate itself establishes the subtype, so that
15739 associations with @code{others} cannot be used. GNAT determines the
15740 bounds for the actual subtype of the aggregate, and allocates the
15741 aggregate statically as well. No code is generated for the following:
15743 @smallexample @c ada
15744 type One_Unc is array (natural range <>) of integer;
15745 Cr_Unc : constant One_Unc := (12,24,36);
15748 @node Aggregates with static bounds
15749 @subsection Aggregates with static bounds
15752 In all previous examples the aggregate was the initial (and immutable) value
15753 of a constant. If the aggregate initializes a variable, then code is generated
15754 for it as a combination of individual assignments and loops over the target
15755 object. The declarations
15757 @smallexample @c ada
15758 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15759 Cr_Var2 : One_Dim := (others > -1);
15763 generate the equivalent of
15765 @smallexample @c ada
15771 for I in Cr_Var2'range loop
15776 @node Aggregates with non-static bounds
15777 @subsection Aggregates with non-static bounds
15780 If the bounds of the aggregate are not statically compatible with the bounds
15781 of the nominal subtype of the target, then constraint checks have to be
15782 generated on the bounds. For a multidimensional array, constraint checks may
15783 have to be applied to sub-arrays individually, if they do not have statically
15784 compatible subtypes.
15786 @node Aggregates in assignment statements
15787 @subsection Aggregates in assignment statements
15790 In general, aggregate assignment requires the construction of a temporary,
15791 and a copy from the temporary to the target of the assignment. This is because
15792 it is not always possible to convert the assignment into a series of individual
15793 component assignments. For example, consider the simple case:
15795 @smallexample @c ada
15800 This cannot be converted into:
15802 @smallexample @c ada
15808 So the aggregate has to be built first in a separate location, and then
15809 copied into the target. GNAT recognizes simple cases where this intermediate
15810 step is not required, and the assignments can be performed in place, directly
15811 into the target. The following sufficient criteria are applied:
15815 The bounds of the aggregate are static, and the associations are static.
15817 The components of the aggregate are static constants, names of
15818 simple variables that are not renamings, or expressions not involving
15819 indexed components whose operands obey these rules.
15823 If any of these conditions are violated, the aggregate will be built in
15824 a temporary (created either by the front-end or the code generator) and then
15825 that temporary will be copied onto the target.
15827 @node The Size of Discriminated Records with Default Discriminants
15828 @section The Size of Discriminated Records with Default Discriminants
15831 If a discriminated type @code{T} has discriminants with default values, it is
15832 possible to declare an object of this type without providing an explicit
15835 @smallexample @c ada
15837 type Size is range 1..100;
15839 type Rec (D : Size := 15) is record
15840 Name : String (1..D);
15848 Such an object is said to be @emph{unconstrained}.
15849 The discriminant of the object
15850 can be modified by a full assignment to the object, as long as it preserves the
15851 relation between the value of the discriminant, and the value of the components
15854 @smallexample @c ada
15856 Word := (3, "yes");
15858 Word := (5, "maybe");
15860 Word := (5, "no"); -- raises Constraint_Error
15865 In order to support this behavior efficiently, an unconstrained object is
15866 given the maximum size that any value of the type requires. In the case
15867 above, @code{Word} has storage for the discriminant and for
15868 a @code{String} of length 100.
15869 It is important to note that unconstrained objects do not require dynamic
15870 allocation. It would be an improper implementation to place on the heap those
15871 components whose size depends on discriminants. (This improper implementation
15872 was used by some Ada83 compilers, where the @code{Name} component above
15874 been stored as a pointer to a dynamic string). Following the principle that
15875 dynamic storage management should never be introduced implicitly,
15876 an Ada compiler should reserve the full size for an unconstrained declared
15877 object, and place it on the stack.
15879 This maximum size approach
15880 has been a source of surprise to some users, who expect the default
15881 values of the discriminants to determine the size reserved for an
15882 unconstrained object: ``If the default is 15, why should the object occupy
15884 The answer, of course, is that the discriminant may be later modified,
15885 and its full range of values must be taken into account. This is why the
15890 type Rec (D : Positive := 15) is record
15891 Name : String (1..D);
15899 is flagged by the compiler with a warning:
15900 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15901 because the required size includes @code{Positive'Last}
15902 bytes. As the first example indicates, the proper approach is to declare an
15903 index type of ``reasonable'' range so that unconstrained objects are not too
15906 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15907 created in the heap by means of an allocator, then it is @emph{not}
15909 it is constrained by the default values of the discriminants, and those values
15910 cannot be modified by full assignment. This is because in the presence of
15911 aliasing all views of the object (which may be manipulated by different tasks,
15912 say) must be consistent, so it is imperative that the object, once created,
15915 @node Strict Conformance to the Ada Reference Manual
15916 @section Strict Conformance to the Ada Reference Manual
15919 The dynamic semantics defined by the Ada Reference Manual impose a set of
15920 run-time checks to be generated. By default, the GNAT compiler will insert many
15921 run-time checks into the compiled code, including most of those required by the
15922 Ada Reference Manual. However, there are three checks that are not enabled
15923 in the default mode for efficiency reasons: arithmetic overflow checking for
15924 integer operations (including division by zero), checks for access before
15925 elaboration on subprogram calls, and stack overflow checking (most operating
15926 systems do not perform this check by default).
15928 Strict conformance to the Ada Reference Manual can be achieved by adding
15929 three compiler options for overflow checking for integer operations
15930 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15931 calls and generic instantiations (@option{-gnatE}), and stack overflow
15932 checking (@option{-fstack-check}).
15934 Note that the result of a floating point arithmetic operation in overflow and
15935 invalid situations, when the @code{Machine_Overflows} attribute of the result
15936 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15937 case for machines compliant with the IEEE floating-point standard, but on
15938 machines that are not fully compliant with this standard, such as Alpha, the
15939 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15940 behavior (although at the cost of a significant performance penalty), so
15941 infinite and and NaN values are properly generated.
15943 @node Obsolescent Features
15944 @chapter Obsolescent Features
15947 This chapter describes features that are provided by GNAT, but are
15948 considered obsolescent since there are preferred ways of achieving
15949 the same effect. These features are provided solely for historical
15950 compatibility purposes.
15953 * pragma No_Run_Time::
15954 * pragma Ravenscar::
15955 * pragma Restricted_Run_Time::
15958 @node pragma No_Run_Time
15959 @section pragma No_Run_Time
15961 The pragma @code{No_Run_Time} is used to achieve an affect similar
15962 to the use of the "Zero Foot Print" configurable run time, but without
15963 requiring a specially configured run time. The result of using this
15964 pragma, which must be used for all units in a partition, is to restrict
15965 the use of any language features requiring run-time support code. The
15966 preferred usage is to use an appropriately configured run-time that
15967 includes just those features that are to be made accessible.
15969 @node pragma Ravenscar
15970 @section pragma Ravenscar
15972 The pragma @code{Ravenscar} has exactly the same effect as pragma
15973 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15974 is part of the new Ada 2005 standard.
15976 @node pragma Restricted_Run_Time
15977 @section pragma Restricted_Run_Time
15979 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15980 pragma @code{Profile (Restricted)}. The latter usage is
15981 preferred since the Ada 2005 pragma @code{Profile} is intended for
15982 this kind of implementation dependent addition.
15985 @c GNU Free Documentation License
15987 @node Index,,GNU Free Documentation License, Top