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::
106 * Pragma Assume_No_Invalid_Values::
108 * Pragma C_Pass_By_Copy::
110 * Pragma Check_Name::
111 * Pragma Check_Policy::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Compiler_Unit::
117 * Pragma Complete_Representation::
118 * Pragma Complex_Representation::
119 * Pragma Component_Alignment::
120 * Pragma Convention_Identifier::
122 * Pragma CPP_Constructor::
123 * Pragma CPP_Virtual::
124 * Pragma CPP_Vtable::
126 * Pragma Debug_Policy::
127 * Pragma Detect_Blocking::
128 * Pragma Elaboration_Checks::
130 * Pragma Export_Exception::
131 * Pragma Export_Function::
132 * Pragma Export_Object::
133 * Pragma Export_Procedure::
134 * Pragma Export_Value::
135 * Pragma Export_Valued_Procedure::
136 * Pragma Extend_System::
137 * Pragma Extensions_Allowed::
139 * Pragma External_Name_Casing::
141 * Pragma Favor_Top_Level::
142 * Pragma Finalize_Storage_Only::
143 * Pragma Float_Representation::
145 * Pragma Implemented_By_Entry::
146 * Pragma Implicit_Packing::
147 * Pragma Import_Exception::
148 * Pragma Import_Function::
149 * Pragma Import_Object::
150 * Pragma Import_Procedure::
151 * Pragma Import_Valued_Procedure::
152 * Pragma Initialize_Scalars::
153 * Pragma Inline_Always::
154 * Pragma Inline_Generic::
156 * Pragma Interface_Name::
157 * Pragma Interrupt_Handler::
158 * Pragma Interrupt_State::
159 * Pragma Keep_Names::
162 * Pragma Linker_Alias::
163 * Pragma Linker_Constructor::
164 * Pragma Linker_Destructor::
165 * Pragma Linker_Section::
166 * Pragma Long_Float::
167 * Pragma Machine_Attribute::
169 * Pragma Main_Storage::
172 * Pragma No_Strict_Aliasing ::
173 * Pragma Normalize_Scalars::
174 * Pragma Obsolescent::
175 * Pragma Optimize_Alignment::
178 * Pragma Persistent_BSS::
180 * Pragma Postcondition::
181 * Pragma Precondition::
182 * Pragma Profile (Ravenscar)::
183 * Pragma Profile (Restricted)::
184 * Pragma Psect_Object::
185 * Pragma Pure_Function::
186 * Pragma Restriction_Warnings::
188 * Pragma Short_Circuit_And_Or::
189 * Pragma Short_Descriptors::
190 * Pragma Source_File_Name::
191 * Pragma Source_File_Name_Project::
192 * Pragma Source_Reference::
193 * Pragma Stream_Convert::
194 * Pragma Style_Checks::
197 * Pragma Suppress_All::
198 * Pragma Suppress_Exception_Locations::
199 * Pragma Suppress_Initialization::
202 * Pragma Task_Storage::
203 * Pragma Thread_Local_Storage::
204 * Pragma Time_Slice::
206 * Pragma Unchecked_Union::
207 * Pragma Unimplemented_Unit::
208 * Pragma Universal_Aliasing ::
209 * Pragma Universal_Data::
210 * Pragma Unmodified::
211 * Pragma Unreferenced::
212 * Pragma Unreferenced_Objects::
213 * Pragma Unreserve_All_Interrupts::
214 * Pragma Unsuppress::
215 * Pragma Use_VADS_Size::
216 * Pragma Validity_Checks::
219 * Pragma Weak_External::
220 * Pragma Wide_Character_Encoding::
222 Implementation Defined Attributes
233 * Default_Bit_Order::
243 * Has_Access_Values::
244 * Has_Discriminants::
251 * Max_Interrupt_Priority::
253 * Maximum_Alignment::
258 * Passed_By_Reference::
272 * Unconstrained_Array::
273 * Universal_Literal_String::
274 * Unrestricted_Access::
280 The Implementation of Standard I/O
282 * Standard I/O Packages::
288 * Wide_Wide_Text_IO::
292 * Filenames encoding::
294 * Operations on C Streams::
295 * Interfacing to C Streams::
299 * Ada.Characters.Latin_9 (a-chlat9.ads)::
300 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
301 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
302 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
303 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
304 * Ada.Command_Line.Environment (a-colien.ads)::
305 * Ada.Command_Line.Remove (a-colire.ads)::
306 * Ada.Command_Line.Response_File (a-clrefi.ads)::
307 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
308 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
309 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
310 * Ada.Exceptions.Traceback (a-exctra.ads)::
311 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
312 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
313 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
314 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
315 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
316 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
317 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
318 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
319 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
320 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
321 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
322 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
323 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
324 * GNAT.Altivec (g-altive.ads)::
325 * GNAT.Altivec.Conversions (g-altcon.ads)::
326 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
327 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
328 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
329 * GNAT.Array_Split (g-arrspl.ads)::
330 * GNAT.AWK (g-awk.ads)::
331 * GNAT.Bounded_Buffers (g-boubuf.ads)::
332 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
333 * GNAT.Bubble_Sort (g-bubsor.ads)::
334 * GNAT.Bubble_Sort_A (g-busora.ads)::
335 * GNAT.Bubble_Sort_G (g-busorg.ads)::
336 * GNAT.Byte_Order_Mark (g-byorma.ads)::
337 * GNAT.Byte_Swapping (g-bytswa.ads)::
338 * GNAT.Calendar (g-calend.ads)::
339 * GNAT.Calendar.Time_IO (g-catiio.ads)::
340 * GNAT.Case_Util (g-casuti.ads)::
341 * GNAT.CGI (g-cgi.ads)::
342 * GNAT.CGI.Cookie (g-cgicoo.ads)::
343 * GNAT.CGI.Debug (g-cgideb.ads)::
344 * GNAT.Command_Line (g-comlin.ads)::
345 * GNAT.Compiler_Version (g-comver.ads)::
346 * GNAT.Ctrl_C (g-ctrl_c.ads)::
347 * GNAT.CRC32 (g-crc32.ads)::
348 * GNAT.Current_Exception (g-curexc.ads)::
349 * GNAT.Debug_Pools (g-debpoo.ads)::
350 * GNAT.Debug_Utilities (g-debuti.ads)::
351 * GNAT.Decode_String (g-decstr.ads)::
352 * GNAT.Decode_UTF8_String (g-deutst.ads)::
353 * GNAT.Directory_Operations (g-dirope.ads)::
354 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
355 * GNAT.Dynamic_HTables (g-dynhta.ads)::
356 * GNAT.Dynamic_Tables (g-dyntab.ads)::
357 * GNAT.Encode_String (g-encstr.ads)::
358 * GNAT.Encode_UTF8_String (g-enutst.ads)::
359 * GNAT.Exception_Actions (g-excact.ads)::
360 * GNAT.Exception_Traces (g-exctra.ads)::
361 * GNAT.Exceptions (g-except.ads)::
362 * GNAT.Expect (g-expect.ads)::
363 * GNAT.Float_Control (g-flocon.ads)::
364 * GNAT.Heap_Sort (g-heasor.ads)::
365 * GNAT.Heap_Sort_A (g-hesora.ads)::
366 * GNAT.Heap_Sort_G (g-hesorg.ads)::
367 * GNAT.HTable (g-htable.ads)::
368 * GNAT.IO (g-io.ads)::
369 * GNAT.IO_Aux (g-io_aux.ads)::
370 * GNAT.Lock_Files (g-locfil.ads)::
371 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
372 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
373 * GNAT.MD5 (g-md5.ads)::
374 * GNAT.Memory_Dump (g-memdum.ads)::
375 * GNAT.Most_Recent_Exception (g-moreex.ads)::
376 * GNAT.OS_Lib (g-os_lib.ads)::
377 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
378 * GNAT.Random_Numbers (g-rannum.ads)::
379 * GNAT.Regexp (g-regexp.ads)::
380 * GNAT.Registry (g-regist.ads)::
381 * GNAT.Regpat (g-regpat.ads)::
382 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
383 * GNAT.Semaphores (g-semaph.ads)::
384 * GNAT.Serial_Communications (g-sercom.ads)::
385 * GNAT.SHA1 (g-sha1.ads)::
386 * GNAT.SHA224 (g-sha224.ads)::
387 * GNAT.SHA256 (g-sha256.ads)::
388 * GNAT.SHA384 (g-sha384.ads)::
389 * GNAT.SHA512 (g-sha512.ads)::
390 * GNAT.Signals (g-signal.ads)::
391 * GNAT.Sockets (g-socket.ads)::
392 * GNAT.Source_Info (g-souinf.ads)::
393 * GNAT.Spelling_Checker (g-speche.ads)::
394 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
395 * GNAT.Spitbol.Patterns (g-spipat.ads)::
396 * GNAT.Spitbol (g-spitbo.ads)::
397 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
398 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
399 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
400 * GNAT.SSE (g-sse.ads)::
401 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
402 * GNAT.Strings (g-string.ads)::
403 * GNAT.String_Split (g-strspl.ads)::
404 * GNAT.Table (g-table.ads)::
405 * GNAT.Task_Lock (g-tasloc.ads)::
406 * GNAT.Threads (g-thread.ads)::
407 * GNAT.Time_Stamp (g-timsta.ads)::
408 * GNAT.Traceback (g-traceb.ads)::
409 * GNAT.Traceback.Symbolic (g-trasym.ads)::
410 * GNAT.UTF_32 (g-utf_32.ads)::
411 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
412 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
413 * GNAT.Wide_String_Split (g-wistsp.ads)::
414 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
415 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
416 * Interfaces.C.Extensions (i-cexten.ads)::
417 * Interfaces.C.Streams (i-cstrea.ads)::
418 * Interfaces.CPP (i-cpp.ads)::
419 * Interfaces.Packed_Decimal (i-pacdec.ads)::
420 * Interfaces.VxWorks (i-vxwork.ads)::
421 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
422 * System.Address_Image (s-addima.ads)::
423 * System.Assertions (s-assert.ads)::
424 * System.Memory (s-memory.ads)::
425 * System.Partition_Interface (s-parint.ads)::
426 * System.Pool_Global (s-pooglo.ads)::
427 * System.Pool_Local (s-pooloc.ads)::
428 * System.Restrictions (s-restri.ads)::
429 * System.Rident (s-rident.ads)::
430 * System.Strings.Stream_Ops (s-ststop.ads)::
431 * System.Task_Info (s-tasinf.ads)::
432 * System.Wch_Cnv (s-wchcnv.ads)::
433 * System.Wch_Con (s-wchcon.ads)::
437 * Text_IO Stream Pointer Positioning::
438 * Text_IO Reading and Writing Non-Regular Files::
440 * Treating Text_IO Files as Streams::
441 * Text_IO Extensions::
442 * Text_IO Facilities for Unbounded Strings::
446 * Wide_Text_IO Stream Pointer Positioning::
447 * Wide_Text_IO Reading and Writing Non-Regular Files::
451 * Wide_Wide_Text_IO Stream Pointer Positioning::
452 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
454 Interfacing to Other Languages
457 * Interfacing to C++::
458 * Interfacing to COBOL::
459 * Interfacing to Fortran::
460 * Interfacing to non-GNAT Ada code::
462 Specialized Needs Annexes
464 Implementation of Specific Ada Features
465 * Machine Code Insertions::
466 * GNAT Implementation of Tasking::
467 * GNAT Implementation of Shared Passive Packages::
468 * Code Generation for Array Aggregates::
469 * The Size of Discriminated Records with Default Discriminants::
470 * Strict Conformance to the Ada Reference Manual::
474 GNU Free Documentation License
481 @node About This Guide
482 @unnumbered About This Guide
485 This manual contains useful information in writing programs using the
486 @value{EDITION} compiler. It includes information on implementation dependent
487 characteristics of @value{EDITION}, including all the information required by
488 Annex M of the Ada language standard.
490 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
491 Ada 83 compatibility mode.
492 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
493 but you can override with a compiler switch
494 to explicitly specify the language version.
495 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
496 @value{EDITION} User's Guide}, for details on these switches.)
497 Throughout this manual, references to ``Ada'' without a year suffix
498 apply to both the Ada 95 and Ada 2005 versions of the language.
500 Ada is designed to be highly portable.
501 In general, a program will have the same effect even when compiled by
502 different compilers on different platforms.
503 However, since Ada is designed to be used in a
504 wide variety of applications, it also contains a number of system
505 dependent features to be used in interfacing to the external world.
506 @cindex Implementation-dependent features
509 Note: Any program that makes use of implementation-dependent features
510 may be non-portable. You should follow good programming practice and
511 isolate and clearly document any sections of your program that make use
512 of these features in a non-portable manner.
515 For ease of exposition, ``GNAT Pro'' will be referred to simply as
516 ``GNAT'' in the remainder of this document.
520 * What This Reference Manual Contains::
522 * Related Information::
525 @node What This Reference Manual Contains
526 @unnumberedsec What This Reference Manual Contains
529 This reference manual contains the following chapters:
533 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
534 pragmas, which can be used to extend and enhance the functionality of the
538 @ref{Implementation Defined Attributes}, lists GNAT
539 implementation-dependent attributes which can be used to extend and
540 enhance the functionality of the compiler.
543 @ref{Implementation Advice}, provides information on generally
544 desirable behavior which are not requirements that all compilers must
545 follow since it cannot be provided on all systems, or which may be
546 undesirable on some systems.
549 @ref{Implementation Defined Characteristics}, provides a guide to
550 minimizing implementation dependent features.
553 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
554 implemented by GNAT, and how they can be imported into user
555 application programs.
558 @ref{Representation Clauses and Pragmas}, describes in detail the
559 way that GNAT represents data, and in particular the exact set
560 of representation clauses and pragmas that is accepted.
563 @ref{Standard Library Routines}, provides a listing of packages and a
564 brief description of the functionality that is provided by Ada's
565 extensive set of standard library routines as implemented by GNAT@.
568 @ref{The Implementation of Standard I/O}, details how the GNAT
569 implementation of the input-output facilities.
572 @ref{The GNAT Library}, is a catalog of packages that complement
573 the Ada predefined library.
576 @ref{Interfacing to Other Languages}, describes how programs
577 written in Ada using GNAT can be interfaced to other programming
580 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
581 of the specialized needs annexes.
584 @ref{Implementation of Specific Ada Features}, discusses issues related
585 to GNAT's implementation of machine code insertions, tasking, and several
589 @ref{Obsolescent Features} documents implementation dependent features,
590 including pragmas and attributes, which are considered obsolescent, since
591 there are other preferred ways of achieving the same results. These
592 obsolescent forms are retained for backwards compatibility.
596 @cindex Ada 95 Language Reference Manual
597 @cindex Ada 2005 Language Reference Manual
599 This reference manual assumes a basic familiarity with the Ada 95 language, as
600 described in the International Standard ANSI/ISO/IEC-8652:1995,
602 It does not require knowledge of the new features introduced by Ada 2005,
603 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
605 Both reference manuals are included in the GNAT documentation
609 @unnumberedsec Conventions
610 @cindex Conventions, typographical
611 @cindex Typographical conventions
614 Following are examples of the typographical and graphic conventions used
619 @code{Functions}, @code{utility program names}, @code{standard names},
626 @file{File names}, @samp{button names}, and @samp{field names}.
629 @code{Variables}, @env{environment variables}, and @var{metasyntactic
636 [optional information or parameters]
639 Examples are described by text
641 and then shown this way.
646 Commands that are entered by the user are preceded in this manual by the
647 characters @samp{$ } (dollar sign followed by space). If your system uses this
648 sequence as a prompt, then the commands will appear exactly as you see them
649 in the manual. If your system uses some other prompt, then the command will
650 appear with the @samp{$} replaced by whatever prompt character you are using.
652 @node Related Information
653 @unnumberedsec Related Information
655 See the following documents for further information on GNAT:
659 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
660 @value{EDITION} User's Guide}, which provides information on how to use the
661 GNAT compiler system.
664 @cite{Ada 95 Reference Manual}, which contains all reference
665 material for the Ada 95 programming language.
668 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
669 of the Ada 95 standard. The annotations describe
670 detailed aspects of the design decision, and in particular contain useful
671 sections on Ada 83 compatibility.
674 @cite{Ada 2005 Reference Manual}, which contains all reference
675 material for the Ada 2005 programming language.
678 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
679 of the Ada 2005 standard. The annotations describe
680 detailed aspects of the design decision, and in particular contain useful
681 sections on Ada 83 and Ada 95 compatibility.
684 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
685 which contains specific information on compatibility between GNAT and
689 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
690 describes in detail the pragmas and attributes provided by the DEC Ada 83
695 @node Implementation Defined Pragmas
696 @chapter Implementation Defined Pragmas
699 Ada defines a set of pragmas that can be used to supply additional
700 information to the compiler. These language defined pragmas are
701 implemented in GNAT and work as described in the Ada Reference Manual.
703 In addition, Ada allows implementations to define additional pragmas
704 whose meaning is defined by the implementation. GNAT provides a number
705 of these implementation-defined pragmas, which can be used to extend
706 and enhance the functionality of the compiler. This section of the GNAT
707 Reference Manual describes these additional pragmas.
709 Note that any program using these pragmas might not be portable to other
710 compilers (although GNAT implements this set of pragmas on all
711 platforms). Therefore if portability to other compilers is an important
712 consideration, the use of these pragmas should be minimized.
715 * Pragma Abort_Defer::
724 * Pragma Assume_No_Invalid_Values::
726 * Pragma C_Pass_By_Copy::
728 * Pragma Check_Name::
729 * Pragma Check_Policy::
731 * Pragma Common_Object::
732 * Pragma Compile_Time_Error::
733 * Pragma Compile_Time_Warning::
734 * Pragma Compiler_Unit::
735 * Pragma Complete_Representation::
736 * Pragma Complex_Representation::
737 * Pragma Component_Alignment::
738 * Pragma Convention_Identifier::
740 * Pragma CPP_Constructor::
741 * Pragma CPP_Virtual::
742 * Pragma CPP_Vtable::
744 * Pragma Debug_Policy::
745 * Pragma Detect_Blocking::
746 * Pragma Elaboration_Checks::
748 * Pragma Export_Exception::
749 * Pragma Export_Function::
750 * Pragma Export_Object::
751 * Pragma Export_Procedure::
752 * Pragma Export_Value::
753 * Pragma Export_Valued_Procedure::
754 * Pragma Extend_System::
755 * Pragma Extensions_Allowed::
757 * Pragma External_Name_Casing::
759 * Pragma Favor_Top_Level::
760 * Pragma Finalize_Storage_Only::
761 * Pragma Float_Representation::
763 * Pragma Implemented_By_Entry::
764 * Pragma Implicit_Packing::
765 * Pragma Import_Exception::
766 * Pragma Import_Function::
767 * Pragma Import_Object::
768 * Pragma Import_Procedure::
769 * Pragma Import_Valued_Procedure::
770 * Pragma Initialize_Scalars::
771 * Pragma Inline_Always::
772 * Pragma Inline_Generic::
774 * Pragma Interface_Name::
775 * Pragma Interrupt_Handler::
776 * Pragma Interrupt_State::
777 * Pragma Keep_Names::
780 * Pragma Linker_Alias::
781 * Pragma Linker_Constructor::
782 * Pragma Linker_Destructor::
783 * Pragma Linker_Section::
784 * Pragma Long_Float::
785 * Pragma Machine_Attribute::
787 * Pragma Main_Storage::
790 * Pragma No_Strict_Aliasing::
791 * Pragma Normalize_Scalars::
792 * Pragma Obsolescent::
793 * Pragma Optimize_Alignment::
796 * Pragma Persistent_BSS::
798 * Pragma Postcondition::
799 * Pragma Precondition::
800 * Pragma Profile (Ravenscar)::
801 * Pragma Profile (Restricted)::
802 * Pragma Psect_Object::
803 * Pragma Pure_Function::
804 * Pragma Restriction_Warnings::
806 * Pragma Short_Circuit_And_Or::
807 * Pragma Short_Descriptors::
808 * Pragma Source_File_Name::
809 * Pragma Source_File_Name_Project::
810 * Pragma Source_Reference::
811 * Pragma Stream_Convert::
812 * Pragma Style_Checks::
815 * Pragma Suppress_All::
816 * Pragma Suppress_Exception_Locations::
817 * Pragma Suppress_Initialization::
820 * Pragma Task_Storage::
821 * Pragma Thread_Local_Storage::
822 * Pragma Time_Slice::
824 * Pragma Unchecked_Union::
825 * Pragma Unimplemented_Unit::
826 * Pragma Universal_Aliasing ::
827 * Pragma Universal_Data::
828 * Pragma Unmodified::
829 * Pragma Unreferenced::
830 * Pragma Unreferenced_Objects::
831 * Pragma Unreserve_All_Interrupts::
832 * Pragma Unsuppress::
833 * Pragma Use_VADS_Size::
834 * Pragma Validity_Checks::
837 * Pragma Weak_External::
838 * Pragma Wide_Character_Encoding::
841 @node Pragma Abort_Defer
842 @unnumberedsec Pragma Abort_Defer
844 @cindex Deferring aborts
852 This pragma must appear at the start of the statement sequence of a
853 handled sequence of statements (right after the @code{begin}). It has
854 the effect of deferring aborts for the sequence of statements (but not
855 for the declarations or handlers, if any, associated with this statement
859 @unnumberedsec Pragma Ada_83
868 A configuration pragma that establishes Ada 83 mode for the unit to
869 which it applies, regardless of the mode set by the command line
870 switches. In Ada 83 mode, GNAT attempts to be as compatible with
871 the syntax and semantics of Ada 83, as defined in the original Ada
872 83 Reference Manual as possible. In particular, the keywords added by Ada 95
873 and Ada 2005 are not recognized, optional package bodies are allowed,
874 and generics may name types with unknown discriminants without using
875 the @code{(<>)} notation. In addition, some but not all of the additional
876 restrictions of Ada 83 are enforced.
878 Ada 83 mode is intended for two purposes. Firstly, it allows existing
879 Ada 83 code to be compiled and adapted to GNAT with less effort.
880 Secondly, it aids in keeping code backwards compatible with Ada 83.
881 However, there is no guarantee that code that is processed correctly
882 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
883 83 compiler, since GNAT does not enforce all the additional checks
887 @unnumberedsec Pragma Ada_95
896 A configuration pragma that establishes Ada 95 mode for the unit to which
897 it applies, regardless of the mode set by the command line switches.
898 This mode is set automatically for the @code{Ada} and @code{System}
899 packages and their children, so you need not specify it in these
900 contexts. This pragma is useful when writing a reusable component that
901 itself uses Ada 95 features, but which is intended to be usable from
902 either Ada 83 or Ada 95 programs.
905 @unnumberedsec Pragma Ada_05
914 A configuration pragma that establishes Ada 2005 mode for the unit to which
915 it applies, regardless of the mode set by the command line switches.
916 This pragma is useful when writing a reusable component that
917 itself uses Ada 2005 features, but which is intended to be usable from
918 either Ada 83 or Ada 95 programs.
920 @node Pragma Ada_2005
921 @unnumberedsec Pragma Ada_2005
930 This configuration pragma is a synonym for pragma Ada_05 and has the
931 same syntax and effect.
934 @unnumberedsec Pragma Ada_12
943 A configuration pragma that establishes Ada 2012 mode for the unit to which
944 it applies, regardless of the mode set by the command line switches.
945 This mode is set automatically for the @code{Ada} and @code{System}
946 packages and their children, so you need not specify it in these
947 contexts. This pragma is useful when writing a reusable component that
948 itself uses Ada 2012 features, but which is intended to be usable from
949 Ada 83, Ada 95, or Ada 2005 programs.
951 @node Pragma Ada_2012
952 @unnumberedsec Pragma Ada_2012
961 This configuration pragma is a synonym for pragma Ada_12 and has the
962 same syntax and effect.
964 @node Pragma Annotate
965 @unnumberedsec Pragma Annotate
970 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
972 ARG ::= NAME | EXPRESSION
976 This pragma is used to annotate programs. @var{identifier} identifies
977 the type of annotation. GNAT verifies that it is an identifier, but does
978 not otherwise analyze it. The second optional identifier is also left
979 unanalyzed, and by convention is used to control the action of the tool to
980 which the annotation is addressed. The remaining @var{arg} arguments
981 can be either string literals or more generally expressions.
982 String literals are assumed to be either of type
983 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
984 depending on the character literals they contain.
985 All other kinds of arguments are analyzed as expressions, and must be
988 The analyzed pragma is retained in the tree, but not otherwise processed
989 by any part of the GNAT compiler. This pragma is intended for use by
990 external tools, including ASIS@.
993 @unnumberedsec Pragma Assert
1000 [, string_EXPRESSION]);
1004 The effect of this pragma depends on whether the corresponding command
1005 line switch is set to activate assertions. The pragma expands into code
1006 equivalent to the following:
1008 @smallexample @c ada
1009 if assertions-enabled then
1010 if not boolean_EXPRESSION then
1011 System.Assertions.Raise_Assert_Failure
1012 (string_EXPRESSION);
1018 The string argument, if given, is the message that will be associated
1019 with the exception occurrence if the exception is raised. If no second
1020 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1021 where @var{file} is the name of the source file containing the assert,
1022 and @var{nnn} is the line number of the assert. A pragma is not a
1023 statement, so if a statement sequence contains nothing but a pragma
1024 assert, then a null statement is required in addition, as in:
1026 @smallexample @c ada
1029 pragma Assert (K > 3, "Bad value for K");
1035 Note that, as with the @code{if} statement to which it is equivalent, the
1036 type of the expression is either @code{Standard.Boolean}, or any type derived
1037 from this standard type.
1039 If assertions are disabled (switch @option{-gnata} not used), then there
1040 is no run-time effect (and in particular, any side effects from the
1041 expression will not occur at run time). (The expression is still
1042 analyzed at compile time, and may cause types to be frozen if they are
1043 mentioned here for the first time).
1045 If assertions are enabled, then the given expression is tested, and if
1046 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1047 which results in the raising of @code{Assert_Failure} with the given message.
1049 You should generally avoid side effects in the expression arguments of
1050 this pragma, because these side effects will turn on and off with the
1051 setting of the assertions mode, resulting in assertions that have an
1052 effect on the program. However, the expressions are analyzed for
1053 semantic correctness whether or not assertions are enabled, so turning
1054 assertions on and off cannot affect the legality of a program.
1056 @node Pragma Assume_No_Invalid_Values
1057 @unnumberedsec Pragma Assume_No_Invalid_Values
1058 @findex Assume_No_Invalid_Values
1059 @cindex Invalid representations
1060 @cindex Invalid values
1063 @smallexample @c ada
1064 pragma Assume_No_Invalid_Values (On | Off);
1068 This is a configuration pragma that controls the assumptions made by the
1069 compiler about the occurrence of invalid representations (invalid values)
1072 The default behavior (corresponding to an Off argument for this pragma), is
1073 to assume that values may in general be invalid unless the compiler can
1074 prove they are valid. Consider the following example:
1076 @smallexample @c ada
1077 V1 : Integer range 1 .. 10;
1078 V2 : Integer range 11 .. 20;
1080 for J in V2 .. V1 loop
1086 if V1 and V2 have valid values, then the loop is known at compile
1087 time not to execute since the lower bound must be greater than the
1088 upper bound. However in default mode, no such assumption is made,
1089 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1090 is given, the compiler will assume that any occurrence of a variable
1091 other than in an explicit @code{'Valid} test always has a valid
1092 value, and the loop above will be optimized away.
1094 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1095 you know your code is free of uninitialized variables and other
1096 possible sources of invalid representations, and may result in
1097 more efficient code. A program that accesses an invalid representation
1098 with this pragma in effect is erroneous, so no guarantees can be made
1101 It is peculiar though permissible to use this pragma in conjunction
1102 with validity checking (-gnatVa). In such cases, accessing invalid
1103 values will generally give an exception, though formally the program
1104 is erroneous so there are no guarantees that this will always be the
1105 case, and it is recommended that these two options not be used together.
1107 @node Pragma Ast_Entry
1108 @unnumberedsec Pragma Ast_Entry
1113 @smallexample @c ada
1114 pragma AST_Entry (entry_IDENTIFIER);
1118 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1119 argument is the simple name of a single entry; at most one @code{AST_Entry}
1120 pragma is allowed for any given entry. This pragma must be used in
1121 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1122 the entry declaration and in the same task type specification or single task
1123 as the entry to which it applies. This pragma specifies that the given entry
1124 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1125 resulting from an OpenVMS system service call. The pragma does not affect
1126 normal use of the entry. For further details on this pragma, see the
1127 DEC Ada Language Reference Manual, section 9.12a.
1129 @node Pragma C_Pass_By_Copy
1130 @unnumberedsec Pragma C_Pass_By_Copy
1131 @cindex Passing by copy
1132 @findex C_Pass_By_Copy
1135 @smallexample @c ada
1136 pragma C_Pass_By_Copy
1137 ([Max_Size =>] static_integer_EXPRESSION);
1141 Normally the default mechanism for passing C convention records to C
1142 convention subprograms is to pass them by reference, as suggested by RM
1143 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1144 this default, by requiring that record formal parameters be passed by
1145 copy if all of the following conditions are met:
1149 The size of the record type does not exceed the value specified for
1152 The record type has @code{Convention C}.
1154 The formal parameter has this record type, and the subprogram has a
1155 foreign (non-Ada) convention.
1159 If these conditions are met the argument is passed by copy, i.e.@: in a
1160 manner consistent with what C expects if the corresponding formal in the
1161 C prototype is a struct (rather than a pointer to a struct).
1163 You can also pass records by copy by specifying the convention
1164 @code{C_Pass_By_Copy} for the record type, or by using the extended
1165 @code{Import} and @code{Export} pragmas, which allow specification of
1166 passing mechanisms on a parameter by parameter basis.
1169 @unnumberedsec Pragma Check
1171 @cindex Named assertions
1175 @smallexample @c ada
1177 [Name =>] Identifier,
1178 [Check =>] Boolean_EXPRESSION
1179 [, [Message =>] string_EXPRESSION] );
1183 This pragma is similar to the predefined pragma @code{Assert} except that an
1184 extra identifier argument is present. In conjunction with pragma
1185 @code{Check_Policy}, this can be used to define groups of assertions that can
1186 be independently controlled. The identifier @code{Assertion} is special, it
1187 refers to the normal set of pragma @code{Assert} statements. The identifiers
1188 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1189 names, so these three names would normally not be used directly in a pragma
1192 Checks introduced by this pragma are normally deactivated by default. They can
1193 be activated either by the command line option @option{-gnata}, which turns on
1194 all checks, or individually controlled using pragma @code{Check_Policy}.
1196 @node Pragma Check_Name
1197 @unnumberedsec Pragma Check_Name
1198 @cindex Defining check names
1199 @cindex Check names, defining
1203 @smallexample @c ada
1204 pragma Check_Name (check_name_IDENTIFIER);
1208 This is a configuration pragma that defines a new implementation
1209 defined check name (unless IDENTIFIER matches one of the predefined
1210 check names, in which case the pragma has no effect). Check names
1211 are global to a partition, so if two or more configuration pragmas
1212 are present in a partition mentioning the same name, only one new
1213 check name is introduced.
1215 An implementation defined check name introduced with this pragma may
1216 be used in only three contexts: @code{pragma Suppress},
1217 @code{pragma Unsuppress},
1218 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1219 any of these three cases, the check name must be visible. A check
1220 name is visible if it is in the configuration pragmas applying to
1221 the current unit, or if it appears at the start of any unit that
1222 is part of the dependency set of the current unit (e.g., units that
1223 are mentioned in @code{with} clauses).
1225 @node Pragma Check_Policy
1226 @unnumberedsec Pragma Check_Policy
1227 @cindex Controlling assertions
1228 @cindex Assertions, control
1229 @cindex Check pragma control
1230 @cindex Named assertions
1234 @smallexample @c ada
1236 ([Name =>] Identifier,
1237 [Policy =>] POLICY_IDENTIFIER);
1239 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1243 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1244 except that it controls sets of named assertions introduced using the
1245 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1246 @code{Assertion_Policy}) can be used within a declarative part, in which case
1247 it controls the status to the end of the corresponding construct (in a manner
1248 identical to pragma @code{Suppress)}.
1250 The identifier given as the first argument corresponds to a name used in
1251 associated @code{Check} pragmas. For example, if the pragma:
1253 @smallexample @c ada
1254 pragma Check_Policy (Critical_Error, Off);
1258 is given, then subsequent @code{Check} pragmas whose first argument is also
1259 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1260 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1261 @code{Check_Policy} with this identifier is similar to the normal
1262 @code{Assertion_Policy} pragma except that it can appear within a
1265 The special identifiers @code{Precondition} and @code{Postcondition} control
1266 the status of preconditions and postconditions. If a @code{Precondition} pragma
1267 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1268 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1269 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1272 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1273 to turn on corresponding checks. The default for a set of checks for which no
1274 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1275 @option{-gnata} is given, which turns on all checks by default.
1277 The check policy settings @code{Check} and @code{Ignore} are also recognized
1278 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1279 compatibility with the standard @code{Assertion_Policy} pragma.
1281 @node Pragma Comment
1282 @unnumberedsec Pragma Comment
1287 @smallexample @c ada
1288 pragma Comment (static_string_EXPRESSION);
1292 This is almost identical in effect to pragma @code{Ident}. It allows the
1293 placement of a comment into the object file and hence into the
1294 executable file if the operating system permits such usage. The
1295 difference is that @code{Comment}, unlike @code{Ident}, has
1296 no limitations on placement of the pragma (it can be placed
1297 anywhere in the main source unit), and if more than one pragma
1298 is used, all comments are retained.
1300 @node Pragma Common_Object
1301 @unnumberedsec Pragma Common_Object
1302 @findex Common_Object
1306 @smallexample @c ada
1307 pragma Common_Object (
1308 [Internal =>] LOCAL_NAME
1309 [, [External =>] EXTERNAL_SYMBOL]
1310 [, [Size =>] EXTERNAL_SYMBOL] );
1314 | static_string_EXPRESSION
1318 This pragma enables the shared use of variables stored in overlaid
1319 linker areas corresponding to the use of @code{COMMON}
1320 in Fortran. The single
1321 object @var{LOCAL_NAME} is assigned to the area designated by
1322 the @var{External} argument.
1323 You may define a record to correspond to a series
1324 of fields. The @var{Size} argument
1325 is syntax checked in GNAT, but otherwise ignored.
1327 @code{Common_Object} is not supported on all platforms. If no
1328 support is available, then the code generator will issue a message
1329 indicating that the necessary attribute for implementation of this
1330 pragma is not available.
1332 @node Pragma Compile_Time_Error
1333 @unnumberedsec Pragma Compile_Time_Error
1334 @findex Compile_Time_Error
1338 @smallexample @c ada
1339 pragma Compile_Time_Error
1340 (boolean_EXPRESSION, static_string_EXPRESSION);
1344 This pragma can be used to generate additional compile time
1346 is particularly useful in generics, where errors can be issued for
1347 specific problematic instantiations. The first parameter is a boolean
1348 expression. The pragma is effective only if the value of this expression
1349 is known at compile time, and has the value True. The set of expressions
1350 whose values are known at compile time includes all static boolean
1351 expressions, and also other values which the compiler can determine
1352 at compile time (e.g., the size of a record type set by an explicit
1353 size representation clause, or the value of a variable which was
1354 initialized to a constant and is known not to have been modified).
1355 If these conditions are met, an error message is generated using
1356 the value given as the second argument. This string value may contain
1357 embedded ASCII.LF characters to break the message into multiple lines.
1359 @node Pragma Compile_Time_Warning
1360 @unnumberedsec Pragma Compile_Time_Warning
1361 @findex Compile_Time_Warning
1365 @smallexample @c ada
1366 pragma Compile_Time_Warning
1367 (boolean_EXPRESSION, static_string_EXPRESSION);
1371 Same as pragma Compile_Time_Error, except a warning is issued instead
1372 of an error message. Note that if this pragma is used in a package that
1373 is with'ed by a client, the client will get the warning even though it
1374 is issued by a with'ed package (normally warnings in with'ed units are
1375 suppressed, but this is a special exception to that rule).
1377 One typical use is within a generic where compile time known characteristics
1378 of formal parameters are tested, and warnings given appropriately. Another use
1379 with a first parameter of True is to warn a client about use of a package,
1380 for example that it is not fully implemented.
1382 @node Pragma Compiler_Unit
1383 @unnumberedsec Pragma Compiler_Unit
1384 @findex Compiler_Unit
1388 @smallexample @c ada
1389 pragma Compiler_Unit;
1393 This pragma is intended only for internal use in the GNAT run-time library.
1394 It indicates that the unit is used as part of the compiler build. The effect
1395 is to disallow constructs (raise with message, conditional expressions etc)
1396 that would cause trouble when bootstrapping using an older version of GNAT.
1397 For the exact list of restrictions, see the compiler sources and references
1398 to Is_Compiler_Unit.
1400 @node Pragma Complete_Representation
1401 @unnumberedsec Pragma Complete_Representation
1402 @findex Complete_Representation
1406 @smallexample @c ada
1407 pragma Complete_Representation;
1411 This pragma must appear immediately within a record representation
1412 clause. Typical placements are before the first component clause
1413 or after the last component clause. The effect is to give an error
1414 message if any component is missing a component clause. This pragma
1415 may be used to ensure that a record representation clause is
1416 complete, and that this invariant is maintained if fields are
1417 added to the record in the future.
1419 @node Pragma Complex_Representation
1420 @unnumberedsec Pragma Complex_Representation
1421 @findex Complex_Representation
1425 @smallexample @c ada
1426 pragma Complex_Representation
1427 ([Entity =>] LOCAL_NAME);
1431 The @var{Entity} argument must be the name of a record type which has
1432 two fields of the same floating-point type. The effect of this pragma is
1433 to force gcc to use the special internal complex representation form for
1434 this record, which may be more efficient. Note that this may result in
1435 the code for this type not conforming to standard ABI (application
1436 binary interface) requirements for the handling of record types. For
1437 example, in some environments, there is a requirement for passing
1438 records by pointer, and the use of this pragma may result in passing
1439 this type in floating-point registers.
1441 @node Pragma Component_Alignment
1442 @unnumberedsec Pragma Component_Alignment
1443 @cindex Alignments of components
1444 @findex Component_Alignment
1448 @smallexample @c ada
1449 pragma Component_Alignment (
1450 [Form =>] ALIGNMENT_CHOICE
1451 [, [Name =>] type_LOCAL_NAME]);
1453 ALIGNMENT_CHOICE ::=
1461 Specifies the alignment of components in array or record types.
1462 The meaning of the @var{Form} argument is as follows:
1465 @findex Component_Size
1466 @item Component_Size
1467 Aligns scalar components and subcomponents of the array or record type
1468 on boundaries appropriate to their inherent size (naturally
1469 aligned). For example, 1-byte components are aligned on byte boundaries,
1470 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1471 integer components are aligned on 4-byte boundaries and so on. These
1472 alignment rules correspond to the normal rules for C compilers on all
1473 machines except the VAX@.
1475 @findex Component_Size_4
1476 @item Component_Size_4
1477 Naturally aligns components with a size of four or fewer
1478 bytes. Components that are larger than 4 bytes are placed on the next
1481 @findex Storage_Unit
1483 Specifies that array or record components are byte aligned, i.e.@:
1484 aligned on boundaries determined by the value of the constant
1485 @code{System.Storage_Unit}.
1489 Specifies that array or record components are aligned on default
1490 boundaries, appropriate to the underlying hardware or operating system or
1491 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1492 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1493 the @code{Default} choice is the same as @code{Component_Size} (natural
1498 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1499 refer to a local record or array type, and the specified alignment
1500 choice applies to the specified type. The use of
1501 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1502 @code{Component_Alignment} pragma to be ignored. The use of
1503 @code{Component_Alignment} together with a record representation clause
1504 is only effective for fields not specified by the representation clause.
1506 If the @code{Name} parameter is absent, the pragma can be used as either
1507 a configuration pragma, in which case it applies to one or more units in
1508 accordance with the normal rules for configuration pragmas, or it can be
1509 used within a declarative part, in which case it applies to types that
1510 are declared within this declarative part, or within any nested scope
1511 within this declarative part. In either case it specifies the alignment
1512 to be applied to any record or array type which has otherwise standard
1515 If the alignment for a record or array type is not specified (using
1516 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1517 clause), the GNAT uses the default alignment as described previously.
1519 @node Pragma Convention_Identifier
1520 @unnumberedsec Pragma Convention_Identifier
1521 @findex Convention_Identifier
1522 @cindex Conventions, synonyms
1526 @smallexample @c ada
1527 pragma Convention_Identifier (
1528 [Name =>] IDENTIFIER,
1529 [Convention =>] convention_IDENTIFIER);
1533 This pragma provides a mechanism for supplying synonyms for existing
1534 convention identifiers. The @code{Name} identifier can subsequently
1535 be used as a synonym for the given convention in other pragmas (including
1536 for example pragma @code{Import} or another @code{Convention_Identifier}
1537 pragma). As an example of the use of this, suppose you had legacy code
1538 which used Fortran77 as the identifier for Fortran. Then the pragma:
1540 @smallexample @c ada
1541 pragma Convention_Identifier (Fortran77, Fortran);
1545 would allow the use of the convention identifier @code{Fortran77} in
1546 subsequent code, avoiding the need to modify the sources. As another
1547 example, you could use this to parametrize convention requirements
1548 according to systems. Suppose you needed to use @code{Stdcall} on
1549 windows systems, and @code{C} on some other system, then you could
1550 define a convention identifier @code{Library} and use a single
1551 @code{Convention_Identifier} pragma to specify which convention
1552 would be used system-wide.
1554 @node Pragma CPP_Class
1555 @unnumberedsec Pragma CPP_Class
1557 @cindex Interfacing with C++
1561 @smallexample @c ada
1562 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1566 The argument denotes an entity in the current declarative region that is
1567 declared as a record type. It indicates that the type corresponds to an
1568 externally declared C++ class type, and is to be laid out the same way
1569 that C++ would lay out the type. If the C++ class has virtual primitives
1570 then the record must be declared as a tagged record type.
1572 Types for which @code{CPP_Class} is specified do not have assignment or
1573 equality operators defined (such operations can be imported or declared
1574 as subprograms as required). Initialization is allowed only by constructor
1575 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1576 limited if not explicitly declared as limited or derived from a limited
1577 type, and an error is issued in that case.
1579 Pragma @code{CPP_Class} is intended primarily for automatic generation
1580 using an automatic binding generator tool.
1581 See @ref{Interfacing to C++} for related information.
1583 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1584 for backward compatibility but its functionality is available
1585 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1587 @node Pragma CPP_Constructor
1588 @unnumberedsec Pragma CPP_Constructor
1589 @cindex Interfacing with C++
1590 @findex CPP_Constructor
1594 @smallexample @c ada
1595 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1596 [, [External_Name =>] static_string_EXPRESSION ]
1597 [, [Link_Name =>] static_string_EXPRESSION ]);
1601 This pragma identifies an imported function (imported in the usual way
1602 with pragma @code{Import}) as corresponding to a C++ constructor. If
1603 @code{External_Name} and @code{Link_Name} are not specified then the
1604 @code{Entity} argument is a name that must have been previously mentioned
1605 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1606 must be of one of the following forms:
1610 @code{function @var{Fname} return @var{T}}
1614 @code{function @var{Fname} return @var{T}'Class}
1617 @code{function @var{Fname} (@dots{}) return @var{T}}
1621 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1625 where @var{T} is a limited record type imported from C++ with pragma
1626 @code{Import} and @code{Convention} = @code{CPP}.
1628 The first two forms import the default constructor, used when an object
1629 of type @var{T} is created on the Ada side with no explicit constructor.
1630 The latter two forms cover all the non-default constructors of the type.
1631 See the GNAT users guide for details.
1633 If no constructors are imported, it is impossible to create any objects
1634 on the Ada side and the type is implicitly declared abstract.
1636 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1637 using an automatic binding generator tool.
1638 See @ref{Interfacing to C++} for more related information.
1640 Note: The use of functions returning class-wide types for constructors is
1641 currently obsolete. They are supported for backward compatibility. The
1642 use of functions returning the type T leave the Ada sources more clear
1643 because the imported C++ constructors always return an object of type T;
1644 that is, they never return an object whose type is a descendant of type T.
1646 @node Pragma CPP_Virtual
1647 @unnumberedsec Pragma CPP_Virtual
1648 @cindex Interfacing to C++
1651 This pragma is now obsolete has has no effect because GNAT generates
1652 the same object layout than the G++ compiler.
1654 See @ref{Interfacing to C++} for related information.
1656 @node Pragma CPP_Vtable
1657 @unnumberedsec Pragma CPP_Vtable
1658 @cindex Interfacing with C++
1661 This pragma is now obsolete has has no effect because GNAT generates
1662 the same object layout than the G++ compiler.
1664 See @ref{Interfacing to C++} for related information.
1667 @unnumberedsec Pragma Debug
1672 @smallexample @c ada
1673 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1675 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1677 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1681 The procedure call argument has the syntactic form of an expression, meeting
1682 the syntactic requirements for pragmas.
1684 If debug pragmas are not enabled or if the condition is present and evaluates
1685 to False, this pragma has no effect. If debug pragmas are enabled, the
1686 semantics of the pragma is exactly equivalent to the procedure call statement
1687 corresponding to the argument with a terminating semicolon. Pragmas are
1688 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1689 intersperse calls to debug procedures in the middle of declarations. Debug
1690 pragmas can be enabled either by use of the command line switch @option{-gnata}
1691 or by use of the configuration pragma @code{Debug_Policy}.
1693 @node Pragma Debug_Policy
1694 @unnumberedsec Pragma Debug_Policy
1695 @findex Debug_Policy
1699 @smallexample @c ada
1700 pragma Debug_Policy (CHECK | IGNORE);
1704 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1705 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1706 This pragma overrides the effect of the @option{-gnata} switch on the
1709 @node Pragma Detect_Blocking
1710 @unnumberedsec Pragma Detect_Blocking
1711 @findex Detect_Blocking
1715 @smallexample @c ada
1716 pragma Detect_Blocking;
1720 This is a configuration pragma that forces the detection of potentially
1721 blocking operations within a protected operation, and to raise Program_Error
1724 @node Pragma Elaboration_Checks
1725 @unnumberedsec Pragma Elaboration_Checks
1726 @cindex Elaboration control
1727 @findex Elaboration_Checks
1731 @smallexample @c ada
1732 pragma Elaboration_Checks (Dynamic | Static);
1736 This is a configuration pragma that provides control over the
1737 elaboration model used by the compilation affected by the
1738 pragma. If the parameter is @code{Dynamic},
1739 then the dynamic elaboration
1740 model described in the Ada Reference Manual is used, as though
1741 the @option{-gnatE} switch had been specified on the command
1742 line. If the parameter is @code{Static}, then the default GNAT static
1743 model is used. This configuration pragma overrides the setting
1744 of the command line. For full details on the elaboration models
1745 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1746 gnat_ugn, @value{EDITION} User's Guide}.
1748 @node Pragma Eliminate
1749 @unnumberedsec Pragma Eliminate
1750 @cindex Elimination of unused subprograms
1755 @smallexample @c ada
1757 [Unit_Name =>] IDENTIFIER |
1758 SELECTED_COMPONENT);
1761 [Unit_Name =>] IDENTIFIER |
1763 [Entity =>] IDENTIFIER |
1764 SELECTED_COMPONENT |
1766 [,OVERLOADING_RESOLUTION]);
1768 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1771 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1774 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1776 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1777 Result_Type => result_SUBTYPE_NAME]
1779 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1780 SUBTYPE_NAME ::= STRING_VALUE
1782 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1783 SOURCE_TRACE ::= STRING_VALUE
1785 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1789 This pragma indicates that the given entity is not used outside the
1790 compilation unit it is defined in. The entity must be an explicitly declared
1791 subprogram; this includes generic subprogram instances and
1792 subprograms declared in generic package instances.
1794 If the entity to be eliminated is a library level subprogram, then
1795 the first form of pragma @code{Eliminate} is used with only a single argument.
1796 In this form, the @code{Unit_Name} argument specifies the name of the
1797 library level unit to be eliminated.
1799 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1800 are required. If item is an entity of a library package, then the first
1801 argument specifies the unit name, and the second argument specifies
1802 the particular entity. If the second argument is in string form, it must
1803 correspond to the internal manner in which GNAT stores entity names (see
1804 compilation unit Namet in the compiler sources for details).
1806 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1807 to distinguish between overloaded subprograms. If a pragma does not contain
1808 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1809 subprograms denoted by the first two parameters.
1811 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1812 to be eliminated in a manner similar to that used for the extended
1813 @code{Import} and @code{Export} pragmas, except that the subtype names are
1814 always given as strings. At the moment, this form of distinguishing
1815 overloaded subprograms is implemented only partially, so we do not recommend
1816 using it for practical subprogram elimination.
1818 Note that in case of a parameterless procedure its profile is represented
1819 as @code{Parameter_Types => ("")}
1821 Alternatively, the @code{Source_Location} parameter is used to specify
1822 which overloaded alternative is to be eliminated by pointing to the
1823 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1824 source text. The string literal (or concatenation of string literals)
1825 given as SOURCE_TRACE must have the following format:
1827 @smallexample @c ada
1828 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1833 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1834 FILE_NAME ::= STRING_LITERAL
1835 LINE_NUMBER ::= DIGIT @{DIGIT@}
1838 SOURCE_TRACE should be the short name of the source file (with no directory
1839 information), and LINE_NUMBER is supposed to point to the line where the
1840 defining name of the subprogram is located.
1842 For the subprograms that are not a part of generic instantiations, only one
1843 SOURCE_LOCATION is used. If a subprogram is declared in a package
1844 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1845 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1846 second one denotes the declaration of the corresponding subprogram in the
1847 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1848 in case of nested instantiations.
1850 The effect of the pragma is to allow the compiler to eliminate
1851 the code or data associated with the named entity. Any reference to
1852 an eliminated entity outside the compilation unit it is defined in,
1853 causes a compile time or link time error.
1855 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1856 in a system independent manner, with unused entities eliminated, without
1857 the requirement of modifying the source text. Normally the required set
1858 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1859 tool. Elimination of unused entities local to a compilation unit is
1860 automatic, without requiring the use of pragma @code{Eliminate}.
1862 Note that the reason this pragma takes string literals where names might
1863 be expected is that a pragma @code{Eliminate} can appear in a context where the
1864 relevant names are not visible.
1866 Note that any change in the source files that includes removing, splitting of
1867 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1870 It is legal to use pragma Eliminate where the referenced entity is a
1871 dispatching operation, but it is not clear what this would mean, since
1872 in general the call does not know which entity is actually being called.
1873 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1875 @node Pragma Export_Exception
1876 @unnumberedsec Pragma Export_Exception
1878 @findex Export_Exception
1882 @smallexample @c ada
1883 pragma Export_Exception (
1884 [Internal =>] LOCAL_NAME
1885 [, [External =>] EXTERNAL_SYMBOL]
1886 [, [Form =>] Ada | VMS]
1887 [, [Code =>] static_integer_EXPRESSION]);
1891 | static_string_EXPRESSION
1895 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1896 causes the specified exception to be propagated outside of the Ada program,
1897 so that it can be handled by programs written in other OpenVMS languages.
1898 This pragma establishes an external name for an Ada exception and makes the
1899 name available to the OpenVMS Linker as a global symbol. For further details
1900 on this pragma, see the
1901 DEC Ada Language Reference Manual, section 13.9a3.2.
1903 @node Pragma Export_Function
1904 @unnumberedsec Pragma Export_Function
1905 @cindex Argument passing mechanisms
1906 @findex Export_Function
1911 @smallexample @c ada
1912 pragma Export_Function (
1913 [Internal =>] LOCAL_NAME
1914 [, [External =>] EXTERNAL_SYMBOL]
1915 [, [Parameter_Types =>] PARAMETER_TYPES]
1916 [, [Result_Type =>] result_SUBTYPE_MARK]
1917 [, [Mechanism =>] MECHANISM]
1918 [, [Result_Mechanism =>] MECHANISM_NAME]);
1922 | static_string_EXPRESSION
1927 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1931 | subtype_Name ' Access
1935 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1937 MECHANISM_ASSOCIATION ::=
1938 [formal_parameter_NAME =>] MECHANISM_NAME
1943 | Descriptor [([Class =>] CLASS_NAME)]
1944 | Short_Descriptor [([Class =>] CLASS_NAME)]
1946 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1950 Use this pragma to make a function externally callable and optionally
1951 provide information on mechanisms to be used for passing parameter and
1952 result values. We recommend, for the purposes of improving portability,
1953 this pragma always be used in conjunction with a separate pragma
1954 @code{Export}, which must precede the pragma @code{Export_Function}.
1955 GNAT does not require a separate pragma @code{Export}, but if none is
1956 present, @code{Convention Ada} is assumed, which is usually
1957 not what is wanted, so it is usually appropriate to use this
1958 pragma in conjunction with a @code{Export} or @code{Convention}
1959 pragma that specifies the desired foreign convention.
1960 Pragma @code{Export_Function}
1961 (and @code{Export}, if present) must appear in the same declarative
1962 region as the function to which they apply.
1964 @var{internal_name} must uniquely designate the function to which the
1965 pragma applies. If more than one function name exists of this name in
1966 the declarative part you must use the @code{Parameter_Types} and
1967 @code{Result_Type} parameters is mandatory to achieve the required
1968 unique designation. @var{subtype_mark}s in these parameters must
1969 exactly match the subtypes in the corresponding function specification,
1970 using positional notation to match parameters with subtype marks.
1971 The form with an @code{'Access} attribute can be used to match an
1972 anonymous access parameter.
1975 @cindex Passing by descriptor
1976 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1977 The default behavior for Export_Function is to accept either 64bit or
1978 32bit descriptors unless short_descriptor is specified, then only 32bit
1979 descriptors are accepted.
1981 @cindex Suppressing external name
1982 Special treatment is given if the EXTERNAL is an explicit null
1983 string or a static string expressions that evaluates to the null
1984 string. In this case, no external name is generated. This form
1985 still allows the specification of parameter mechanisms.
1987 @node Pragma Export_Object
1988 @unnumberedsec Pragma Export_Object
1989 @findex Export_Object
1993 @smallexample @c ada
1994 pragma Export_Object
1995 [Internal =>] LOCAL_NAME
1996 [, [External =>] EXTERNAL_SYMBOL]
1997 [, [Size =>] EXTERNAL_SYMBOL]
2001 | static_string_EXPRESSION
2005 This pragma designates an object as exported, and apart from the
2006 extended rules for external symbols, is identical in effect to the use of
2007 the normal @code{Export} pragma applied to an object. You may use a
2008 separate Export pragma (and you probably should from the point of view
2009 of portability), but it is not required. @var{Size} is syntax checked,
2010 but otherwise ignored by GNAT@.
2012 @node Pragma Export_Procedure
2013 @unnumberedsec Pragma Export_Procedure
2014 @findex Export_Procedure
2018 @smallexample @c ada
2019 pragma Export_Procedure (
2020 [Internal =>] LOCAL_NAME
2021 [, [External =>] EXTERNAL_SYMBOL]
2022 [, [Parameter_Types =>] PARAMETER_TYPES]
2023 [, [Mechanism =>] MECHANISM]);
2027 | static_string_EXPRESSION
2032 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2036 | subtype_Name ' Access
2040 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2042 MECHANISM_ASSOCIATION ::=
2043 [formal_parameter_NAME =>] MECHANISM_NAME
2048 | Descriptor [([Class =>] CLASS_NAME)]
2049 | Short_Descriptor [([Class =>] CLASS_NAME)]
2051 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2055 This pragma is identical to @code{Export_Function} except that it
2056 applies to a procedure rather than a function and the parameters
2057 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2058 GNAT does not require a separate pragma @code{Export}, but if none is
2059 present, @code{Convention Ada} is assumed, which is usually
2060 not what is wanted, so it is usually appropriate to use this
2061 pragma in conjunction with a @code{Export} or @code{Convention}
2062 pragma that specifies the desired foreign convention.
2065 @cindex Passing by descriptor
2066 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2067 The default behavior for Export_Procedure is to accept either 64bit or
2068 32bit descriptors unless short_descriptor is specified, then only 32bit
2069 descriptors are accepted.
2071 @cindex Suppressing external name
2072 Special treatment is given if the EXTERNAL is an explicit null
2073 string or a static string expressions that evaluates to the null
2074 string. In this case, no external name is generated. This form
2075 still allows the specification of parameter mechanisms.
2077 @node Pragma Export_Value
2078 @unnumberedsec Pragma Export_Value
2079 @findex Export_Value
2083 @smallexample @c ada
2084 pragma Export_Value (
2085 [Value =>] static_integer_EXPRESSION,
2086 [Link_Name =>] static_string_EXPRESSION);
2090 This pragma serves to export a static integer value for external use.
2091 The first argument specifies the value to be exported. The Link_Name
2092 argument specifies the symbolic name to be associated with the integer
2093 value. This pragma is useful for defining a named static value in Ada
2094 that can be referenced in assembly language units to be linked with
2095 the application. This pragma is currently supported only for the
2096 AAMP target and is ignored for other targets.
2098 @node Pragma Export_Valued_Procedure
2099 @unnumberedsec Pragma Export_Valued_Procedure
2100 @findex Export_Valued_Procedure
2104 @smallexample @c ada
2105 pragma Export_Valued_Procedure (
2106 [Internal =>] LOCAL_NAME
2107 [, [External =>] EXTERNAL_SYMBOL]
2108 [, [Parameter_Types =>] PARAMETER_TYPES]
2109 [, [Mechanism =>] MECHANISM]);
2113 | static_string_EXPRESSION
2118 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2122 | subtype_Name ' Access
2126 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2128 MECHANISM_ASSOCIATION ::=
2129 [formal_parameter_NAME =>] MECHANISM_NAME
2134 | Descriptor [([Class =>] CLASS_NAME)]
2135 | Short_Descriptor [([Class =>] CLASS_NAME)]
2137 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2141 This pragma is identical to @code{Export_Procedure} except that the
2142 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2143 mode @code{OUT}, and externally the subprogram is treated as a function
2144 with this parameter as the result of the function. GNAT provides for
2145 this capability to allow the use of @code{OUT} and @code{IN OUT}
2146 parameters in interfacing to external functions (which are not permitted
2148 GNAT does not require a separate pragma @code{Export}, but if none is
2149 present, @code{Convention Ada} is assumed, which is almost certainly
2150 not what is wanted since the whole point of this pragma is to interface
2151 with foreign language functions, so it is usually appropriate to use this
2152 pragma in conjunction with a @code{Export} or @code{Convention}
2153 pragma that specifies the desired foreign convention.
2156 @cindex Passing by descriptor
2157 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2158 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2159 32bit descriptors unless short_descriptor is specified, then only 32bit
2160 descriptors are accepted.
2162 @cindex Suppressing external name
2163 Special treatment is given if the EXTERNAL is an explicit null
2164 string or a static string expressions that evaluates to the null
2165 string. In this case, no external name is generated. This form
2166 still allows the specification of parameter mechanisms.
2168 @node Pragma Extend_System
2169 @unnumberedsec Pragma Extend_System
2170 @cindex @code{system}, extending
2172 @findex Extend_System
2176 @smallexample @c ada
2177 pragma Extend_System ([Name =>] IDENTIFIER);
2181 This pragma is used to provide backwards compatibility with other
2182 implementations that extend the facilities of package @code{System}. In
2183 GNAT, @code{System} contains only the definitions that are present in
2184 the Ada RM@. However, other implementations, notably the DEC Ada 83
2185 implementation, provide many extensions to package @code{System}.
2187 For each such implementation accommodated by this pragma, GNAT provides a
2188 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2189 implementation, which provides the required additional definitions. You
2190 can use this package in two ways. You can @code{with} it in the normal
2191 way and access entities either by selection or using a @code{use}
2192 clause. In this case no special processing is required.
2194 However, if existing code contains references such as
2195 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2196 definitions provided in package @code{System}, you may use this pragma
2197 to extend visibility in @code{System} in a non-standard way that
2198 provides greater compatibility with the existing code. Pragma
2199 @code{Extend_System} is a configuration pragma whose single argument is
2200 the name of the package containing the extended definition
2201 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2202 control of this pragma will be processed using special visibility
2203 processing that looks in package @code{System.Aux_@var{xxx}} where
2204 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2205 package @code{System}, but not found in package @code{System}.
2207 You can use this pragma either to access a predefined @code{System}
2208 extension supplied with the compiler, for example @code{Aux_DEC} or
2209 you can construct your own extension unit following the above
2210 definition. Note that such a package is a child of @code{System}
2211 and thus is considered part of the implementation. To compile
2212 it you will have to use the appropriate switch for compiling
2214 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2217 @node Pragma Extensions_Allowed
2218 @unnumberedsec Pragma Extensions_Allowed
2219 @cindex Ada Extensions
2220 @cindex GNAT Extensions
2221 @findex Extensions_Allowed
2225 @smallexample @c ada
2226 pragma Extensions_Allowed (On | Off);
2230 This configuration pragma enables or disables the implementation
2231 extension mode (the use of Off as a parameter cancels the effect
2232 of the @option{-gnatX} command switch).
2234 In extension mode, the latest version of the Ada language is
2235 implemented (currently Ada 2012), and in addition a small number
2236 of GNAT specific extensions are recognized as follows:
2239 @item Constrained attribute for generic objects
2240 The @code{Constrained} attribute is permitted for objects of
2241 generic types. The result indicates if the corresponding actual
2246 @node Pragma External
2247 @unnumberedsec Pragma External
2252 @smallexample @c ada
2254 [ Convention =>] convention_IDENTIFIER,
2255 [ Entity =>] LOCAL_NAME
2256 [, [External_Name =>] static_string_EXPRESSION ]
2257 [, [Link_Name =>] static_string_EXPRESSION ]);
2261 This pragma is identical in syntax and semantics to pragma
2262 @code{Export} as defined in the Ada Reference Manual. It is
2263 provided for compatibility with some Ada 83 compilers that
2264 used this pragma for exactly the same purposes as pragma
2265 @code{Export} before the latter was standardized.
2267 @node Pragma External_Name_Casing
2268 @unnumberedsec Pragma External_Name_Casing
2269 @cindex Dec Ada 83 casing compatibility
2270 @cindex External Names, casing
2271 @cindex Casing of External names
2272 @findex External_Name_Casing
2276 @smallexample @c ada
2277 pragma External_Name_Casing (
2278 Uppercase | Lowercase
2279 [, Uppercase | Lowercase | As_Is]);
2283 This pragma provides control over the casing of external names associated
2284 with Import and Export pragmas. There are two cases to consider:
2287 @item Implicit external names
2288 Implicit external names are derived from identifiers. The most common case
2289 arises when a standard Ada Import or Export pragma is used with only two
2292 @smallexample @c ada
2293 pragma Import (C, C_Routine);
2297 Since Ada is a case-insensitive language, the spelling of the identifier in
2298 the Ada source program does not provide any information on the desired
2299 casing of the external name, and so a convention is needed. In GNAT the
2300 default treatment is that such names are converted to all lower case
2301 letters. This corresponds to the normal C style in many environments.
2302 The first argument of pragma @code{External_Name_Casing} can be used to
2303 control this treatment. If @code{Uppercase} is specified, then the name
2304 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2305 then the normal default of all lower case letters will be used.
2307 This same implicit treatment is also used in the case of extended DEC Ada 83
2308 compatible Import and Export pragmas where an external name is explicitly
2309 specified using an identifier rather than a string.
2311 @item Explicit external names
2312 Explicit external names are given as string literals. The most common case
2313 arises when a standard Ada Import or Export pragma is used with three
2316 @smallexample @c ada
2317 pragma Import (C, C_Routine, "C_routine");
2321 In this case, the string literal normally provides the exact casing required
2322 for the external name. The second argument of pragma
2323 @code{External_Name_Casing} may be used to modify this behavior.
2324 If @code{Uppercase} is specified, then the name
2325 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2326 then the name will be forced to all lowercase letters. A specification of
2327 @code{As_Is} provides the normal default behavior in which the casing is
2328 taken from the string provided.
2332 This pragma may appear anywhere that a pragma is valid. In particular, it
2333 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2334 case it applies to all subsequent compilations, or it can be used as a program
2335 unit pragma, in which case it only applies to the current unit, or it can
2336 be used more locally to control individual Import/Export pragmas.
2338 It is primarily intended for use with OpenVMS systems, where many
2339 compilers convert all symbols to upper case by default. For interfacing to
2340 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2343 @smallexample @c ada
2344 pragma External_Name_Casing (Uppercase, Uppercase);
2348 to enforce the upper casing of all external symbols.
2350 @node Pragma Fast_Math
2351 @unnumberedsec Pragma Fast_Math
2356 @smallexample @c ada
2361 This is a configuration pragma which activates a mode in which speed is
2362 considered more important for floating-point operations than absolutely
2363 accurate adherence to the requirements of the standard. Currently the
2364 following operations are affected:
2367 @item Complex Multiplication
2368 The normal simple formula for complex multiplication can result in intermediate
2369 overflows for numbers near the end of the range. The Ada standard requires that
2370 this situation be detected and corrected by scaling, but in Fast_Math mode such
2371 cases will simply result in overflow. Note that to take advantage of this you
2372 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2373 under control of the pragma, rather than use the preinstantiated versions.
2376 @node Pragma Favor_Top_Level
2377 @unnumberedsec Pragma Favor_Top_Level
2378 @findex Favor_Top_Level
2382 @smallexample @c ada
2383 pragma Favor_Top_Level (type_NAME);
2387 The named type must be an access-to-subprogram type. This pragma is an
2388 efficiency hint to the compiler, regarding the use of 'Access or
2389 'Unrestricted_Access on nested (non-library-level) subprograms. The
2390 pragma means that nested subprograms are not used with this type, or
2391 are rare, so that the generated code should be efficient in the
2392 top-level case. When this pragma is used, dynamically generated
2393 trampolines may be used on some targets for nested subprograms.
2394 See also the No_Implicit_Dynamic_Code restriction.
2396 @node Pragma Finalize_Storage_Only
2397 @unnumberedsec Pragma Finalize_Storage_Only
2398 @findex Finalize_Storage_Only
2402 @smallexample @c ada
2403 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2407 This pragma allows the compiler not to emit a Finalize call for objects
2408 defined at the library level. This is mostly useful for types where
2409 finalization is only used to deal with storage reclamation since in most
2410 environments it is not necessary to reclaim memory just before terminating
2411 execution, hence the name.
2413 @node Pragma Float_Representation
2414 @unnumberedsec Pragma Float_Representation
2416 @findex Float_Representation
2420 @smallexample @c ada
2421 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2423 FLOAT_REP ::= VAX_Float | IEEE_Float
2427 In the one argument form, this pragma is a configuration pragma which
2428 allows control over the internal representation chosen for the predefined
2429 floating point types declared in the packages @code{Standard} and
2430 @code{System}. On all systems other than OpenVMS, the argument must
2431 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2432 argument may be @code{VAX_Float} to specify the use of the VAX float
2433 format for the floating-point types in Standard. This requires that
2434 the standard runtime libraries be recompiled.
2436 The two argument form specifies the representation to be used for
2437 the specified floating-point type. On all systems other than OpenVMS,
2439 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2440 argument may be @code{VAX_Float} to specify the use of the VAX float
2445 For digits values up to 6, F float format will be used.
2447 For digits values from 7 to 9, G float format will be used.
2449 For digits values from 10 to 15, F float format will be used.
2451 Digits values above 15 are not allowed.
2455 @unnumberedsec Pragma Ident
2460 @smallexample @c ada
2461 pragma Ident (static_string_EXPRESSION);
2465 This pragma provides a string identification in the generated object file,
2466 if the system supports the concept of this kind of identification string.
2467 This pragma is allowed only in the outermost declarative part or
2468 declarative items of a compilation unit. If more than one @code{Ident}
2469 pragma is given, only the last one processed is effective.
2471 On OpenVMS systems, the effect of the pragma is identical to the effect of
2472 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2473 maximum allowed length is 31 characters, so if it is important to
2474 maintain compatibility with this compiler, you should obey this length
2477 @node Pragma Implemented_By_Entry
2478 @unnumberedsec Pragma Implemented_By_Entry
2479 @findex Implemented_By_Entry
2483 @smallexample @c ada
2484 pragma Implemented_By_Entry (LOCAL_NAME);
2488 This is a representation pragma which applies to protected, synchronized and
2489 task interface primitives. If the pragma is applied to primitive operation Op
2490 of interface Iface, it is illegal to override Op in a type that implements
2491 Iface, with anything other than an entry.
2493 @smallexample @c ada
2494 type Iface is protected interface;
2495 procedure Do_Something (Object : in out Iface) is abstract;
2496 pragma Implemented_By_Entry (Do_Something);
2498 protected type P is new Iface with
2499 procedure Do_Something; -- Illegal
2502 task type T is new Iface with
2503 entry Do_Something; -- Legal
2508 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2509 is intended to be used in conjunction with dispatching requeue statements as
2510 described in AI05-0030. Should the ARG decide on an official name and syntax,
2511 this pragma will become language-defined rather than GNAT-specific.
2513 @node Pragma Implicit_Packing
2514 @unnumberedsec Pragma Implicit_Packing
2515 @findex Implicit_Packing
2519 @smallexample @c ada
2520 pragma Implicit_Packing;
2524 This is a configuration pragma that requests implicit packing for packed
2525 arrays for which a size clause is given but no explicit pragma Pack or
2526 specification of Component_Size is present. It also applies to records
2527 where no record representation clause is present. Consider this example:
2529 @smallexample @c ada
2530 type R is array (0 .. 7) of Boolean;
2535 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2536 does not change the layout of a composite object. So the Size clause in the
2537 above example is normally rejected, since the default layout of the array uses
2538 8-bit components, and thus the array requires a minimum of 64 bits.
2540 If this declaration is compiled in a region of code covered by an occurrence
2541 of the configuration pragma Implicit_Packing, then the Size clause in this
2542 and similar examples will cause implicit packing and thus be accepted. For
2543 this implicit packing to occur, the type in question must be an array of small
2544 components whose size is known at compile time, and the Size clause must
2545 specify the exact size that corresponds to the length of the array multiplied
2546 by the size in bits of the component type.
2547 @cindex Array packing
2549 Similarly, the following example shows the use in the record case
2551 @smallexample @c ada
2553 a, b, c, d, e, f, g, h : boolean;
2560 Without a pragma Pack, each Boolean field requires 8 bits, so the
2561 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2562 sufficient. The use of pragma Implciit_Packing allows this record
2563 declaration to compile without an explicit pragma Pack.
2564 @node Pragma Import_Exception
2565 @unnumberedsec Pragma Import_Exception
2567 @findex Import_Exception
2571 @smallexample @c ada
2572 pragma Import_Exception (
2573 [Internal =>] LOCAL_NAME
2574 [, [External =>] EXTERNAL_SYMBOL]
2575 [, [Form =>] Ada | VMS]
2576 [, [Code =>] static_integer_EXPRESSION]);
2580 | static_string_EXPRESSION
2584 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2585 It allows OpenVMS conditions (for example, from OpenVMS system services or
2586 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2587 The pragma specifies that the exception associated with an exception
2588 declaration in an Ada program be defined externally (in non-Ada code).
2589 For further details on this pragma, see the
2590 DEC Ada Language Reference Manual, section 13.9a.3.1.
2592 @node Pragma Import_Function
2593 @unnumberedsec Pragma Import_Function
2594 @findex Import_Function
2598 @smallexample @c ada
2599 pragma Import_Function (
2600 [Internal =>] LOCAL_NAME,
2601 [, [External =>] EXTERNAL_SYMBOL]
2602 [, [Parameter_Types =>] PARAMETER_TYPES]
2603 [, [Result_Type =>] SUBTYPE_MARK]
2604 [, [Mechanism =>] MECHANISM]
2605 [, [Result_Mechanism =>] MECHANISM_NAME]
2606 [, [First_Optional_Parameter =>] IDENTIFIER]);
2610 | static_string_EXPRESSION
2614 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2618 | subtype_Name ' Access
2622 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2624 MECHANISM_ASSOCIATION ::=
2625 [formal_parameter_NAME =>] MECHANISM_NAME
2630 | Descriptor [([Class =>] CLASS_NAME)]
2631 | Short_Descriptor [([Class =>] CLASS_NAME)]
2633 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2637 This pragma is used in conjunction with a pragma @code{Import} to
2638 specify additional information for an imported function. The pragma
2639 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2640 @code{Import_Function} pragma and both must appear in the same
2641 declarative part as the function specification.
2643 The @var{Internal} argument must uniquely designate
2644 the function to which the
2645 pragma applies. If more than one function name exists of this name in
2646 the declarative part you must use the @code{Parameter_Types} and
2647 @var{Result_Type} parameters to achieve the required unique
2648 designation. Subtype marks in these parameters must exactly match the
2649 subtypes in the corresponding function specification, using positional
2650 notation to match parameters with subtype marks.
2651 The form with an @code{'Access} attribute can be used to match an
2652 anonymous access parameter.
2654 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2655 parameters to specify passing mechanisms for the
2656 parameters and result. If you specify a single mechanism name, it
2657 applies to all parameters. Otherwise you may specify a mechanism on a
2658 parameter by parameter basis using either positional or named
2659 notation. If the mechanism is not specified, the default mechanism
2663 @cindex Passing by descriptor
2664 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2665 The default behavior for Import_Function is to pass a 64bit descriptor
2666 unless short_descriptor is specified, then a 32bit descriptor is passed.
2668 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2669 It specifies that the designated parameter and all following parameters
2670 are optional, meaning that they are not passed at the generated code
2671 level (this is distinct from the notion of optional parameters in Ada
2672 where the parameters are passed anyway with the designated optional
2673 parameters). All optional parameters must be of mode @code{IN} and have
2674 default parameter values that are either known at compile time
2675 expressions, or uses of the @code{'Null_Parameter} attribute.
2677 @node Pragma Import_Object
2678 @unnumberedsec Pragma Import_Object
2679 @findex Import_Object
2683 @smallexample @c ada
2684 pragma Import_Object
2685 [Internal =>] LOCAL_NAME
2686 [, [External =>] EXTERNAL_SYMBOL]
2687 [, [Size =>] EXTERNAL_SYMBOL]);
2691 | static_string_EXPRESSION
2695 This pragma designates an object as imported, and apart from the
2696 extended rules for external symbols, is identical in effect to the use of
2697 the normal @code{Import} pragma applied to an object. Unlike the
2698 subprogram case, you need not use a separate @code{Import} pragma,
2699 although you may do so (and probably should do so from a portability
2700 point of view). @var{size} is syntax checked, but otherwise ignored by
2703 @node Pragma Import_Procedure
2704 @unnumberedsec Pragma Import_Procedure
2705 @findex Import_Procedure
2709 @smallexample @c ada
2710 pragma Import_Procedure (
2711 [Internal =>] LOCAL_NAME
2712 [, [External =>] EXTERNAL_SYMBOL]
2713 [, [Parameter_Types =>] PARAMETER_TYPES]
2714 [, [Mechanism =>] MECHANISM]
2715 [, [First_Optional_Parameter =>] IDENTIFIER]);
2719 | static_string_EXPRESSION
2723 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2727 | subtype_Name ' Access
2731 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2733 MECHANISM_ASSOCIATION ::=
2734 [formal_parameter_NAME =>] MECHANISM_NAME
2739 | Descriptor [([Class =>] CLASS_NAME)]
2740 | Short_Descriptor [([Class =>] CLASS_NAME)]
2742 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2746 This pragma is identical to @code{Import_Function} except that it
2747 applies to a procedure rather than a function and the parameters
2748 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2750 @node Pragma Import_Valued_Procedure
2751 @unnumberedsec Pragma Import_Valued_Procedure
2752 @findex Import_Valued_Procedure
2756 @smallexample @c ada
2757 pragma Import_Valued_Procedure (
2758 [Internal =>] LOCAL_NAME
2759 [, [External =>] EXTERNAL_SYMBOL]
2760 [, [Parameter_Types =>] PARAMETER_TYPES]
2761 [, [Mechanism =>] MECHANISM]
2762 [, [First_Optional_Parameter =>] IDENTIFIER]);
2766 | static_string_EXPRESSION
2770 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2774 | subtype_Name ' Access
2778 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2780 MECHANISM_ASSOCIATION ::=
2781 [formal_parameter_NAME =>] MECHANISM_NAME
2786 | Descriptor [([Class =>] CLASS_NAME)]
2787 | Short_Descriptor [([Class =>] CLASS_NAME)]
2789 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2793 This pragma is identical to @code{Import_Procedure} except that the
2794 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2795 mode @code{OUT}, and externally the subprogram is treated as a function
2796 with this parameter as the result of the function. The purpose of this
2797 capability is to allow the use of @code{OUT} and @code{IN OUT}
2798 parameters in interfacing to external functions (which are not permitted
2799 in Ada functions). You may optionally use the @code{Mechanism}
2800 parameters to specify passing mechanisms for the parameters.
2801 If you specify a single mechanism name, it applies to all parameters.
2802 Otherwise you may specify a mechanism on a parameter by parameter
2803 basis using either positional or named notation. If the mechanism is not
2804 specified, the default mechanism is used.
2806 Note that it is important to use this pragma in conjunction with a separate
2807 pragma Import that specifies the desired convention, since otherwise the
2808 default convention is Ada, which is almost certainly not what is required.
2810 @node Pragma Initialize_Scalars
2811 @unnumberedsec Pragma Initialize_Scalars
2812 @findex Initialize_Scalars
2813 @cindex debugging with Initialize_Scalars
2817 @smallexample @c ada
2818 pragma Initialize_Scalars;
2822 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2823 two important differences. First, there is no requirement for the pragma
2824 to be used uniformly in all units of a partition, in particular, it is fine
2825 to use this just for some or all of the application units of a partition,
2826 without needing to recompile the run-time library.
2828 In the case where some units are compiled with the pragma, and some without,
2829 then a declaration of a variable where the type is defined in package
2830 Standard or is locally declared will always be subject to initialization,
2831 as will any declaration of a scalar variable. For composite variables,
2832 whether the variable is initialized may also depend on whether the package
2833 in which the type of the variable is declared is compiled with the pragma.
2835 The other important difference is that you can control the value used
2836 for initializing scalar objects. At bind time, you can select several
2837 options for initialization. You can
2838 initialize with invalid values (similar to Normalize_Scalars, though for
2839 Initialize_Scalars it is not always possible to determine the invalid
2840 values in complex cases like signed component fields with non-standard
2841 sizes). You can also initialize with high or
2842 low values, or with a specified bit pattern. See the users guide for binder
2843 options for specifying these cases.
2845 This means that you can compile a program, and then without having to
2846 recompile the program, you can run it with different values being used
2847 for initializing otherwise uninitialized values, to test if your program
2848 behavior depends on the choice. Of course the behavior should not change,
2849 and if it does, then most likely you have an erroneous reference to an
2850 uninitialized value.
2852 It is even possible to change the value at execution time eliminating even
2853 the need to rebind with a different switch using an environment variable.
2854 See the GNAT users guide for details.
2856 Note that pragma @code{Initialize_Scalars} is particularly useful in
2857 conjunction with the enhanced validity checking that is now provided
2858 in GNAT, which checks for invalid values under more conditions.
2859 Using this feature (see description of the @option{-gnatV} flag in the
2860 users guide) in conjunction with pragma @code{Initialize_Scalars}
2861 provides a powerful new tool to assist in the detection of problems
2862 caused by uninitialized variables.
2864 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2865 effect on the generated code. This may cause your code to be
2866 substantially larger. It may also cause an increase in the amount
2867 of stack required, so it is probably a good idea to turn on stack
2868 checking (see description of stack checking in the GNAT users guide)
2869 when using this pragma.
2871 @node Pragma Inline_Always
2872 @unnumberedsec Pragma Inline_Always
2873 @findex Inline_Always
2877 @smallexample @c ada
2878 pragma Inline_Always (NAME [, NAME]);
2882 Similar to pragma @code{Inline} except that inlining is not subject to
2883 the use of option @option{-gnatn} and the inlining happens regardless of
2884 whether this option is used.
2886 @node Pragma Inline_Generic
2887 @unnumberedsec Pragma Inline_Generic
2888 @findex Inline_Generic
2892 @smallexample @c ada
2893 pragma Inline_Generic (generic_package_NAME);
2897 This is implemented for compatibility with DEC Ada 83 and is recognized,
2898 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2899 by default when using GNAT@.
2901 @node Pragma Interface
2902 @unnumberedsec Pragma Interface
2907 @smallexample @c ada
2909 [Convention =>] convention_identifier,
2910 [Entity =>] local_NAME
2911 [, [External_Name =>] static_string_expression]
2912 [, [Link_Name =>] static_string_expression]);
2916 This pragma is identical in syntax and semantics to
2917 the standard Ada pragma @code{Import}. It is provided for compatibility
2918 with Ada 83. The definition is upwards compatible both with pragma
2919 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2920 with some extended implementations of this pragma in certain Ada 83
2921 implementations. The only difference between pragma @code{Interface}
2922 and pragma @code{Import} is that there is special circuitry to allow
2923 both pragmas to appear for the same subprogram entity (normally it
2924 is illegal to have multiple @code{Import} pragmas. This is useful in
2925 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2928 @node Pragma Interface_Name
2929 @unnumberedsec Pragma Interface_Name
2930 @findex Interface_Name
2934 @smallexample @c ada
2935 pragma Interface_Name (
2936 [Entity =>] LOCAL_NAME
2937 [, [External_Name =>] static_string_EXPRESSION]
2938 [, [Link_Name =>] static_string_EXPRESSION]);
2942 This pragma provides an alternative way of specifying the interface name
2943 for an interfaced subprogram, and is provided for compatibility with Ada
2944 83 compilers that use the pragma for this purpose. You must provide at
2945 least one of @var{External_Name} or @var{Link_Name}.
2947 @node Pragma Interrupt_Handler
2948 @unnumberedsec Pragma Interrupt_Handler
2949 @findex Interrupt_Handler
2953 @smallexample @c ada
2954 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2958 This program unit pragma is supported for parameterless protected procedures
2959 as described in Annex C of the Ada Reference Manual. On the AAMP target
2960 the pragma can also be specified for nonprotected parameterless procedures
2961 that are declared at the library level (which includes procedures
2962 declared at the top level of a library package). In the case of AAMP,
2963 when this pragma is applied to a nonprotected procedure, the instruction
2964 @code{IERET} is generated for returns from the procedure, enabling
2965 maskable interrupts, in place of the normal return instruction.
2967 @node Pragma Interrupt_State
2968 @unnumberedsec Pragma Interrupt_State
2969 @findex Interrupt_State
2973 @smallexample @c ada
2974 pragma Interrupt_State
2976 [State =>] SYSTEM | RUNTIME | USER);
2980 Normally certain interrupts are reserved to the implementation. Any attempt
2981 to attach an interrupt causes Program_Error to be raised, as described in
2982 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
2983 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
2984 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2985 interrupt execution. Additionally, signals such as @code{SIGSEGV},
2986 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2987 Ada exceptions, or used to implement run-time functions such as the
2988 @code{abort} statement and stack overflow checking.
2990 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2991 such uses of interrupts. It subsumes the functionality of pragma
2992 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
2993 available on Windows or VMS. On all other platforms than VxWorks,
2994 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2995 and may be used to mark interrupts required by the board support package
2998 Interrupts can be in one of three states:
3002 The interrupt is reserved (no Ada handler can be installed), and the
3003 Ada run-time may not install a handler. As a result you are guaranteed
3004 standard system default action if this interrupt is raised.
3008 The interrupt is reserved (no Ada handler can be installed). The run time
3009 is allowed to install a handler for internal control purposes, but is
3010 not required to do so.
3014 The interrupt is unreserved. The user may install a handler to provide
3019 These states are the allowed values of the @code{State} parameter of the
3020 pragma. The @code{Name} parameter is a value of the type
3021 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3022 @code{Ada.Interrupts.Names}.
3024 This is a configuration pragma, and the binder will check that there
3025 are no inconsistencies between different units in a partition in how a
3026 given interrupt is specified. It may appear anywhere a pragma is legal.
3028 The effect is to move the interrupt to the specified state.
3030 By declaring interrupts to be SYSTEM, you guarantee the standard system
3031 action, such as a core dump.
3033 By declaring interrupts to be USER, you guarantee that you can install
3036 Note that certain signals on many operating systems cannot be caught and
3037 handled by applications. In such cases, the pragma is ignored. See the
3038 operating system documentation, or the value of the array @code{Reserved}
3039 declared in the spec of package @code{System.OS_Interface}.
3041 Overriding the default state of signals used by the Ada runtime may interfere
3042 with an application's runtime behavior in the cases of the synchronous signals,
3043 and in the case of the signal used to implement the @code{abort} statement.
3045 @node Pragma Keep_Names
3046 @unnumberedsec Pragma Keep_Names
3051 @smallexample @c ada
3052 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3056 The @var{LOCAL_NAME} argument
3057 must refer to an enumeration first subtype
3058 in the current declarative part. The effect is to retain the enumeration
3059 literal names for use by @code{Image} and @code{Value} even if a global
3060 @code{Discard_Names} pragma applies. This is useful when you want to
3061 generally suppress enumeration literal names and for example you therefore
3062 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3063 want to retain the names for specific enumeration types.
3065 @node Pragma License
3066 @unnumberedsec Pragma License
3068 @cindex License checking
3072 @smallexample @c ada
3073 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3077 This pragma is provided to allow automated checking for appropriate license
3078 conditions with respect to the standard and modified GPL@. A pragma
3079 @code{License}, which is a configuration pragma that typically appears at
3080 the start of a source file or in a separate @file{gnat.adc} file, specifies
3081 the licensing conditions of a unit as follows:
3085 This is used for a unit that can be freely used with no license restrictions.
3086 Examples of such units are public domain units, and units from the Ada
3090 This is used for a unit that is licensed under the unmodified GPL, and which
3091 therefore cannot be @code{with}'ed by a restricted unit.
3094 This is used for a unit licensed under the GNAT modified GPL that includes
3095 a special exception paragraph that specifically permits the inclusion of
3096 the unit in programs without requiring the entire program to be released
3100 This is used for a unit that is restricted in that it is not permitted to
3101 depend on units that are licensed under the GPL@. Typical examples are
3102 proprietary code that is to be released under more restrictive license
3103 conditions. Note that restricted units are permitted to @code{with} units
3104 which are licensed under the modified GPL (this is the whole point of the
3110 Normally a unit with no @code{License} pragma is considered to have an
3111 unknown license, and no checking is done. However, standard GNAT headers
3112 are recognized, and license information is derived from them as follows.
3116 A GNAT license header starts with a line containing 78 hyphens. The following
3117 comment text is searched for the appearance of any of the following strings.
3119 If the string ``GNU General Public License'' is found, then the unit is assumed
3120 to have GPL license, unless the string ``As a special exception'' follows, in
3121 which case the license is assumed to be modified GPL@.
3123 If one of the strings
3124 ``This specification is adapted from the Ada Semantic Interface'' or
3125 ``This specification is derived from the Ada Reference Manual'' is found
3126 then the unit is assumed to be unrestricted.
3130 These default actions means that a program with a restricted license pragma
3131 will automatically get warnings if a GPL unit is inappropriately
3132 @code{with}'ed. For example, the program:
3134 @smallexample @c ada
3137 procedure Secret_Stuff is
3143 if compiled with pragma @code{License} (@code{Restricted}) in a
3144 @file{gnat.adc} file will generate the warning:
3149 >>> license of withed unit "Sem_Ch3" is incompatible
3151 2. with GNAT.Sockets;
3152 3. procedure Secret_Stuff is
3156 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3157 compiler and is licensed under the
3158 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3159 run time, and is therefore licensed under the modified GPL@.
3161 @node Pragma Link_With
3162 @unnumberedsec Pragma Link_With
3167 @smallexample @c ada
3168 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3172 This pragma is provided for compatibility with certain Ada 83 compilers.
3173 It has exactly the same effect as pragma @code{Linker_Options} except
3174 that spaces occurring within one of the string expressions are treated
3175 as separators. For example, in the following case:
3177 @smallexample @c ada
3178 pragma Link_With ("-labc -ldef");
3182 results in passing the strings @code{-labc} and @code{-ldef} as two
3183 separate arguments to the linker. In addition pragma Link_With allows
3184 multiple arguments, with the same effect as successive pragmas.
3186 @node Pragma Linker_Alias
3187 @unnumberedsec Pragma Linker_Alias
3188 @findex Linker_Alias
3192 @smallexample @c ada
3193 pragma Linker_Alias (
3194 [Entity =>] LOCAL_NAME,
3195 [Target =>] static_string_EXPRESSION);
3199 @var{LOCAL_NAME} must refer to an object that is declared at the library
3200 level. This pragma establishes the given entity as a linker alias for the
3201 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3202 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3203 @var{static_string_EXPRESSION} in the object file, that is to say no space
3204 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3205 to the same address as @var{static_string_EXPRESSION} by the linker.
3207 The actual linker name for the target must be used (e.g.@: the fully
3208 encoded name with qualification in Ada, or the mangled name in C++),
3209 or it must be declared using the C convention with @code{pragma Import}
3210 or @code{pragma Export}.
3212 Not all target machines support this pragma. On some of them it is accepted
3213 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3215 @smallexample @c ada
3216 -- Example of the use of pragma Linker_Alias
3220 pragma Export (C, i);
3222 new_name_for_i : Integer;
3223 pragma Linker_Alias (new_name_for_i, "i");
3227 @node Pragma Linker_Constructor
3228 @unnumberedsec Pragma Linker_Constructor
3229 @findex Linker_Constructor
3233 @smallexample @c ada
3234 pragma Linker_Constructor (procedure_LOCAL_NAME);
3238 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3239 is declared at the library level. A procedure to which this pragma is
3240 applied will be treated as an initialization routine by the linker.
3241 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3242 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3243 of the executable is called (or immediately after the shared library is
3244 loaded if the procedure is linked in a shared library), in particular
3245 before the Ada run-time environment is set up.
3247 Because of these specific contexts, the set of operations such a procedure
3248 can perform is very limited and the type of objects it can manipulate is
3249 essentially restricted to the elementary types. In particular, it must only
3250 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3252 This pragma is used by GNAT to implement auto-initialization of shared Stand
3253 Alone Libraries, which provides a related capability without the restrictions
3254 listed above. Where possible, the use of Stand Alone Libraries is preferable
3255 to the use of this pragma.
3257 @node Pragma Linker_Destructor
3258 @unnumberedsec Pragma Linker_Destructor
3259 @findex Linker_Destructor
3263 @smallexample @c ada
3264 pragma Linker_Destructor (procedure_LOCAL_NAME);
3268 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3269 is declared at the library level. A procedure to which this pragma is
3270 applied will be treated as a finalization routine by the linker.
3271 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3272 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3273 of the executable has exited (or immediately before the shared library
3274 is unloaded if the procedure is linked in a shared library), in particular
3275 after the Ada run-time environment is shut down.
3277 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3278 because of these specific contexts.
3280 @node Pragma Linker_Section
3281 @unnumberedsec Pragma Linker_Section
3282 @findex Linker_Section
3286 @smallexample @c ada
3287 pragma Linker_Section (
3288 [Entity =>] LOCAL_NAME,
3289 [Section =>] static_string_EXPRESSION);
3293 @var{LOCAL_NAME} must refer to an object that is declared at the library
3294 level. This pragma specifies the name of the linker section for the given
3295 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3296 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3297 section of the executable (assuming the linker doesn't rename the section).
3299 The compiler normally places library-level objects in standard sections
3300 depending on their type: procedures and functions generally go in the
3301 @code{.text} section, initialized variables in the @code{.data} section
3302 and uninitialized variables in the @code{.bss} section.
3304 Other, special sections may exist on given target machines to map special
3305 hardware, for example I/O ports or flash memory. This pragma is a means to
3306 defer the final layout of the executable to the linker, thus fully working
3307 at the symbolic level with the compiler.
3309 Some file formats do not support arbitrary sections so not all target
3310 machines support this pragma. The use of this pragma may cause a program
3311 execution to be erroneous if it is used to place an entity into an
3312 inappropriate section (e.g.@: a modified variable into the @code{.text}
3313 section). See also @code{pragma Persistent_BSS}.
3315 @smallexample @c ada
3316 -- Example of the use of pragma Linker_Section
3320 pragma Volatile (Port_A);
3321 pragma Linker_Section (Port_A, ".bss.port_a");
3324 pragma Volatile (Port_B);
3325 pragma Linker_Section (Port_B, ".bss.port_b");
3329 @node Pragma Long_Float
3330 @unnumberedsec Pragma Long_Float
3336 @smallexample @c ada
3337 pragma Long_Float (FLOAT_FORMAT);
3339 FLOAT_FORMAT ::= D_Float | G_Float
3343 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3344 It allows control over the internal representation chosen for the predefined
3345 type @code{Long_Float} and for floating point type representations with
3346 @code{digits} specified in the range 7 through 15.
3347 For further details on this pragma, see the
3348 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3349 this pragma, the standard runtime libraries must be recompiled.
3351 @node Pragma Machine_Attribute
3352 @unnumberedsec Pragma Machine_Attribute
3353 @findex Machine_Attribute
3357 @smallexample @c ada
3358 pragma Machine_Attribute (
3359 [Entity =>] LOCAL_NAME,
3360 [Attribute_Name =>] static_string_EXPRESSION
3361 [, [Info =>] static_EXPRESSION] );
3365 Machine-dependent attributes can be specified for types and/or
3366 declarations. This pragma is semantically equivalent to
3367 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3368 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3369 in GNU C, where @code{@var{attribute_name}} is recognized by the
3370 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3371 specific macro. A string literal for the optional parameter @var{info}
3372 is transformed into an identifier, which may make this pragma unusable
3373 for some attributes. @xref{Target Attributes,, Defining target-specific
3374 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3375 Internals}, further information.
3378 @unnumberedsec Pragma Main
3384 @smallexample @c ada
3386 (MAIN_OPTION [, MAIN_OPTION]);
3389 [Stack_Size =>] static_integer_EXPRESSION
3390 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3391 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3395 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3396 no effect in GNAT, other than being syntax checked.
3398 @node Pragma Main_Storage
3399 @unnumberedsec Pragma Main_Storage
3401 @findex Main_Storage
3405 @smallexample @c ada
3407 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3409 MAIN_STORAGE_OPTION ::=
3410 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3411 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3415 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3416 no effect in GNAT, other than being syntax checked. Note that the pragma
3417 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3419 @node Pragma No_Body
3420 @unnumberedsec Pragma No_Body
3425 @smallexample @c ada
3430 There are a number of cases in which a package spec does not require a body,
3431 and in fact a body is not permitted. GNAT will not permit the spec to be
3432 compiled if there is a body around. The pragma No_Body allows you to provide
3433 a body file, even in a case where no body is allowed. The body file must
3434 contain only comments and a single No_Body pragma. This is recognized by
3435 the compiler as indicating that no body is logically present.
3437 This is particularly useful during maintenance when a package is modified in
3438 such a way that a body needed before is no longer needed. The provision of a
3439 dummy body with a No_Body pragma ensures that there is no interference from
3440 earlier versions of the package body.
3442 @node Pragma No_Return
3443 @unnumberedsec Pragma No_Return
3448 @smallexample @c ada
3449 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3453 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3454 declarations in the current declarative part. A procedure to which this
3455 pragma is applied may not contain any explicit @code{return} statements.
3456 In addition, if the procedure contains any implicit returns from falling
3457 off the end of a statement sequence, then execution of that implicit
3458 return will cause Program_Error to be raised.
3460 One use of this pragma is to identify procedures whose only purpose is to raise
3461 an exception. Another use of this pragma is to suppress incorrect warnings
3462 about missing returns in functions, where the last statement of a function
3463 statement sequence is a call to such a procedure.
3465 Note that in Ada 2005 mode, this pragma is part of the language, and is
3466 identical in effect to the pragma as implemented in Ada 95 mode.
3468 @node Pragma No_Strict_Aliasing
3469 @unnumberedsec Pragma No_Strict_Aliasing
3470 @findex No_Strict_Aliasing
3474 @smallexample @c ada
3475 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3479 @var{type_LOCAL_NAME} must refer to an access type
3480 declaration in the current declarative part. The effect is to inhibit
3481 strict aliasing optimization for the given type. The form with no
3482 arguments is a configuration pragma which applies to all access types
3483 declared in units to which the pragma applies. For a detailed
3484 description of the strict aliasing optimization, and the situations
3485 in which it must be suppressed, see @ref{Optimization and Strict
3486 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3488 @node Pragma Normalize_Scalars
3489 @unnumberedsec Pragma Normalize_Scalars
3490 @findex Normalize_Scalars
3494 @smallexample @c ada
3495 pragma Normalize_Scalars;
3499 This is a language defined pragma which is fully implemented in GNAT@. The
3500 effect is to cause all scalar objects that are not otherwise initialized
3501 to be initialized. The initial values are implementation dependent and
3505 @item Standard.Character
3507 Objects whose root type is Standard.Character are initialized to
3508 Character'Last unless the subtype range excludes NUL (in which case
3509 NUL is used). This choice will always generate an invalid value if
3512 @item Standard.Wide_Character
3514 Objects whose root type is Standard.Wide_Character are initialized to
3515 Wide_Character'Last unless the subtype range excludes NUL (in which case
3516 NUL is used). This choice will always generate an invalid value if
3519 @item Standard.Wide_Wide_Character
3521 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3522 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3523 which case NUL is used). This choice will always generate an invalid value if
3528 Objects of an integer type are treated differently depending on whether
3529 negative values are present in the subtype. If no negative values are
3530 present, then all one bits is used as the initial value except in the
3531 special case where zero is excluded from the subtype, in which case
3532 all zero bits are used. This choice will always generate an invalid
3533 value if one exists.
3535 For subtypes with negative values present, the largest negative number
3536 is used, except in the unusual case where this largest negative number
3537 is in the subtype, and the largest positive number is not, in which case
3538 the largest positive value is used. This choice will always generate
3539 an invalid value if one exists.
3541 @item Floating-Point Types
3542 Objects of all floating-point types are initialized to all 1-bits. For
3543 standard IEEE format, this corresponds to a NaN (not a number) which is
3544 indeed an invalid value.
3546 @item Fixed-Point Types
3547 Objects of all fixed-point types are treated as described above for integers,
3548 with the rules applying to the underlying integer value used to represent
3549 the fixed-point value.
3552 Objects of a modular type are initialized to all one bits, except in
3553 the special case where zero is excluded from the subtype, in which
3554 case all zero bits are used. This choice will always generate an
3555 invalid value if one exists.
3557 @item Enumeration types
3558 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3559 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3560 whose Pos value is zero, in which case a code of zero is used. This choice
3561 will always generate an invalid value if one exists.
3565 @node Pragma Obsolescent
3566 @unnumberedsec Pragma Obsolescent
3571 @smallexample @c ada
3574 pragma Obsolescent (
3575 [Message =>] static_string_EXPRESSION
3576 [,[Version =>] Ada_05]]);
3578 pragma Obsolescent (
3580 [,[Message =>] static_string_EXPRESSION
3581 [,[Version =>] Ada_05]] );
3585 This pragma can occur immediately following a declaration of an entity,
3586 including the case of a record component. If no Entity argument is present,
3587 then this declaration is the one to which the pragma applies. If an Entity
3588 parameter is present, it must either match the name of the entity in this
3589 declaration, or alternatively, the pragma can immediately follow an enumeration
3590 type declaration, where the Entity argument names one of the enumeration
3593 This pragma is used to indicate that the named entity
3594 is considered obsolescent and should not be used. Typically this is
3595 used when an API must be modified by eventually removing or modifying
3596 existing subprograms or other entities. The pragma can be used at an
3597 intermediate stage when the entity is still present, but will be
3600 The effect of this pragma is to output a warning message on a reference to
3601 an entity thus marked that the subprogram is obsolescent if the appropriate
3602 warning option in the compiler is activated. If the Message parameter is
3603 present, then a second warning message is given containing this text. In
3604 addition, a reference to the eneity is considered to be a violation of pragma
3605 Restrictions (No_Obsolescent_Features).
3607 This pragma can also be used as a program unit pragma for a package,
3608 in which case the entity name is the name of the package, and the
3609 pragma indicates that the entire package is considered
3610 obsolescent. In this case a client @code{with}'ing such a package
3611 violates the restriction, and the @code{with} statement is
3612 flagged with warnings if the warning option is set.
3614 If the Version parameter is present (which must be exactly
3615 the identifier Ada_05, no other argument is allowed), then the
3616 indication of obsolescence applies only when compiling in Ada 2005
3617 mode. This is primarily intended for dealing with the situations
3618 in the predefined library where subprograms or packages
3619 have become defined as obsolescent in Ada 2005
3620 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3622 The following examples show typical uses of this pragma:
3624 @smallexample @c ada
3626 pragma Obsolescent (p, Message => "use pp instead of p");
3631 pragma Obsolescent ("use q2new instead");
3633 type R is new integer;
3636 Message => "use RR in Ada 2005",
3646 type E is (a, bc, 'd', quack);
3647 pragma Obsolescent (Entity => bc)
3648 pragma Obsolescent (Entity => 'd')
3651 (a, b : character) return character;
3652 pragma Obsolescent (Entity => "+");
3657 Note that, as for all pragmas, if you use a pragma argument identifier,
3658 then all subsequent parameters must also use a pragma argument identifier.
3659 So if you specify "Entity =>" for the Entity argument, and a Message
3660 argument is present, it must be preceded by "Message =>".
3662 @node Pragma Optimize_Alignment
3663 @unnumberedsec Pragma Optimize_Alignment
3664 @findex Optimize_Alignment
3665 @cindex Alignment, default settings
3669 @smallexample @c ada
3670 pragma Optimize_Alignment (TIME | SPACE | OFF);
3674 This is a configuration pragma which affects the choice of default alignments
3675 for types where no alignment is explicitly specified. There is a time/space
3676 trade-off in the selection of these values. Large alignments result in more
3677 efficient code, at the expense of larger data space, since sizes have to be
3678 increased to match these alignments. Smaller alignments save space, but the
3679 access code is slower. The normal choice of default alignments (which is what
3680 you get if you do not use this pragma, or if you use an argument of OFF),
3681 tries to balance these two requirements.
3683 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3684 First any packed record is given an alignment of 1. Second, if a size is given
3685 for the type, then the alignment is chosen to avoid increasing this size. For
3688 @smallexample @c ada
3698 In the default mode, this type gets an alignment of 4, so that access to the
3699 Integer field X are efficient. But this means that objects of the type end up
3700 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3701 allowed to be bigger than the size of the type, but it can waste space if for
3702 example fields of type R appear in an enclosing record. If the above type is
3703 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3705 Specifying TIME causes larger default alignments to be chosen in the case of
3706 small types with sizes that are not a power of 2. For example, consider:
3708 @smallexample @c ada
3720 The default alignment for this record is normally 1, but if this type is
3721 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3722 to 4, which wastes space for objects of the type, since they are now 4 bytes
3723 long, but results in more efficient access when the whole record is referenced.
3725 As noted above, this is a configuration pragma, and there is a requirement
3726 that all units in a partition be compiled with a consistent setting of the
3727 optimization setting. This would normally be achieved by use of a configuration
3728 pragma file containing the appropriate setting. The exception to this rule is
3729 that units with an explicit configuration pragma in the same file as the source
3730 unit are excluded from the consistency check, as are all predefined units. The
3731 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3732 pragma appears at the start of the file.
3734 @node Pragma Ordered
3735 @unnumberedsec Pragma Ordered
3737 @findex pragma @code{Ordered}
3741 @smallexample @c ada
3742 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3746 Most enumeration types are from a conceptual point of view unordered.
3747 For example, consider:
3749 @smallexample @c ada
3750 type Color is (Red, Blue, Green, Yellow);
3754 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3755 but really these relations make no sense; the enumeration type merely
3756 specifies a set of possible colors, and the order is unimportant.
3758 For unordered enumeration types, it is generally a good idea if
3759 clients avoid comparisons (other than equality or inequality) and
3760 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3761 other than the unit where the type is declared, its body, and its subunits.)
3762 For example, if code buried in some client says:
3764 @smallexample @c ada
3765 if Current_Color < Yellow then ...
3766 if Current_Color in Blue .. Green then ...
3770 then the client code is relying on the order, which is undesirable.
3771 It makes the code hard to read and creates maintenance difficulties if
3772 entries have to be added to the enumeration type. Instead,
3773 the code in the client should list the possibilities, or an
3774 appropriate subtype should be declared in the unit that declares
3775 the original enumeration type. E.g., the following subtype could
3776 be declared along with the type @code{Color}:
3778 @smallexample @c ada
3779 subtype RBG is Color range Red .. Green;
3783 and then the client could write:
3785 @smallexample @c ada
3786 if Current_Color in RBG then ...
3787 if Current_Color = Blue or Current_Color = Green then ...
3791 However, some enumeration types are legitimately ordered from a conceptual
3792 point of view. For example, if you declare:
3794 @smallexample @c ada
3795 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3799 then the ordering imposed by the language is reasonable, and
3800 clients can depend on it, writing for example:
3802 @smallexample @c ada
3803 if D in Mon .. Fri then ...
3808 The pragma @option{Ordered} is provided to mark enumeration types that
3809 are conceptually ordered, alerting the reader that clients may depend
3810 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3811 rather than one to mark them as unordered, since in our experience,
3812 the great majority of enumeration types are conceptually unordered.
3814 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3815 and @code{Wide_Wide_Character}
3816 are considered to be ordered types, so each is declared with a
3817 pragma @code{Ordered} in package @code{Standard}.
3819 Normally pragma @code{Ordered} serves only as documentation and a guide for
3820 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3821 requests warnings for inappropriate uses (comparisons and explicit
3822 subranges) for unordered types. If this switch is used, then any
3823 enumeration type not marked with pragma @code{Ordered} will be considered
3824 as unordered, and will generate warnings for inappropriate uses.
3826 For additional information please refer to the description of the
3827 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3829 @node Pragma Passive
3830 @unnumberedsec Pragma Passive
3835 @smallexample @c ada
3836 pragma Passive [(Semaphore | No)];
3840 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3841 compatibility with DEC Ada 83 implementations, where it is used within a
3842 task definition to request that a task be made passive. If the argument
3843 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3844 treats the pragma as an assertion that the containing task is passive
3845 and that optimization of context switch with this task is permitted and
3846 desired. If the argument @code{No} is present, the task must not be
3847 optimized. GNAT does not attempt to optimize any tasks in this manner
3848 (since protected objects are available in place of passive tasks).
3850 @node Pragma Persistent_BSS
3851 @unnumberedsec Pragma Persistent_BSS
3852 @findex Persistent_BSS
3856 @smallexample @c ada
3857 pragma Persistent_BSS [(LOCAL_NAME)]
3861 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3862 section. On some targets the linker and loader provide for special
3863 treatment of this section, allowing a program to be reloaded without
3864 affecting the contents of this data (hence the name persistent).
3866 There are two forms of usage. If an argument is given, it must be the
3867 local name of a library level object, with no explicit initialization
3868 and whose type is potentially persistent. If no argument is given, then
3869 the pragma is a configuration pragma, and applies to all library level
3870 objects with no explicit initialization of potentially persistent types.
3872 A potentially persistent type is a scalar type, or a non-tagged,
3873 non-discriminated record, all of whose components have no explicit
3874 initialization and are themselves of a potentially persistent type,
3875 or an array, all of whose constraints are static, and whose component
3876 type is potentially persistent.
3878 If this pragma is used on a target where this feature is not supported,
3879 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3881 @node Pragma Polling
3882 @unnumberedsec Pragma Polling
3887 @smallexample @c ada
3888 pragma Polling (ON | OFF);
3892 This pragma controls the generation of polling code. This is normally off.
3893 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3894 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3895 runtime library, and can be found in file @file{a-excpol.adb}.
3897 Pragma @code{Polling} can appear as a configuration pragma (for example it
3898 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3899 can be used in the statement or declaration sequence to control polling
3902 A call to the polling routine is generated at the start of every loop and
3903 at the start of every subprogram call. This guarantees that the @code{Poll}
3904 routine is called frequently, and places an upper bound (determined by
3905 the complexity of the code) on the period between two @code{Poll} calls.
3907 The primary purpose of the polling interface is to enable asynchronous
3908 aborts on targets that cannot otherwise support it (for example Windows
3909 NT), but it may be used for any other purpose requiring periodic polling.
3910 The standard version is null, and can be replaced by a user program. This
3911 will require re-compilation of the @code{Ada.Exceptions} package that can
3912 be found in files @file{a-except.ads} and @file{a-except.adb}.
3914 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3915 distribution) is used to enable the asynchronous abort capability on
3916 targets that do not normally support the capability. The version of
3917 @code{Poll} in this file makes a call to the appropriate runtime routine
3918 to test for an abort condition.
3920 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3921 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3924 @node Pragma Postcondition
3925 @unnumberedsec Pragma Postcondition
3926 @cindex Postconditions
3927 @cindex Checks, postconditions
3928 @findex Postconditions
3932 @smallexample @c ada
3933 pragma Postcondition (
3934 [Check =>] Boolean_Expression
3935 [,[Message =>] String_Expression]);
3939 The @code{Postcondition} pragma allows specification of automatic
3940 postcondition checks for subprograms. These checks are similar to
3941 assertions, but are automatically inserted just prior to the return
3942 statements of the subprogram with which they are associated (including
3943 implicit returns at the end of procedure bodies and associated
3944 exception handlers).
3946 In addition, the boolean expression which is the condition which
3947 must be true may contain references to function'Result in the case
3948 of a function to refer to the returned value.
3950 @code{Postcondition} pragmas may appear either immediate following the
3951 (separate) declaration of a subprogram, or at the start of the
3952 declarations of a subprogram body. Only other pragmas may intervene
3953 (that is appear between the subprogram declaration and its
3954 postconditions, or appear before the postcondition in the
3955 declaration sequence in a subprogram body). In the case of a
3956 postcondition appearing after a subprogram declaration, the
3957 formal arguments of the subprogram are visible, and can be
3958 referenced in the postcondition expressions.
3960 The postconditions are collected and automatically tested just
3961 before any return (implicit or explicit) in the subprogram body.
3962 A postcondition is only recognized if postconditions are active
3963 at the time the pragma is encountered. The compiler switch @option{gnata}
3964 turns on all postconditions by default, and pragma @code{Check_Policy}
3965 with an identifier of @code{Postcondition} can also be used to
3966 control whether postconditions are active.
3968 The general approach is that postconditions are placed in the spec
3969 if they represent functional aspects which make sense to the client.
3970 For example we might have:
3972 @smallexample @c ada
3973 function Direction return Integer;
3974 pragma Postcondition
3975 (Direction'Result = +1
3977 Direction'Result = -1);
3981 which serves to document that the result must be +1 or -1, and
3982 will test that this is the case at run time if postcondition
3985 Postconditions within the subprogram body can be used to
3986 check that some internal aspect of the implementation,
3987 not visible to the client, is operating as expected.
3988 For instance if a square root routine keeps an internal
3989 counter of the number of times it is called, then we
3990 might have the following postcondition:
3992 @smallexample @c ada
3993 Sqrt_Calls : Natural := 0;
3995 function Sqrt (Arg : Float) return Float is
3996 pragma Postcondition
3997 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4003 As this example, shows, the use of the @code{Old} attribute
4004 is often useful in postconditions to refer to the state on
4005 entry to the subprogram.
4007 Note that postconditions are only checked on normal returns
4008 from the subprogram. If an abnormal return results from
4009 raising an exception, then the postconditions are not checked.
4011 If a postcondition fails, then the exception
4012 @code{System.Assertions.Assert_Failure} is raised. If
4013 a message argument was supplied, then the given string
4014 will be used as the exception message. If no message
4015 argument was supplied, then the default message has
4016 the form "Postcondition failed at file:line". The
4017 exception is raised in the context of the subprogram
4018 body, so it is possible to catch postcondition failures
4019 within the subprogram body itself.
4021 Within a package spec, normal visibility rules
4022 in Ada would prevent forward references within a
4023 postcondition pragma to functions defined later in
4024 the same package. This would introduce undesirable
4025 ordering constraints. To avoid this problem, all
4026 postcondition pragmas are analyzed at the end of
4027 the package spec, allowing forward references.
4029 The following example shows that this even allows
4030 mutually recursive postconditions as in:
4032 @smallexample @c ada
4033 package Parity_Functions is
4034 function Odd (X : Natural) return Boolean;
4035 pragma Postcondition
4039 (x /= 0 and then Even (X - 1))));
4041 function Even (X : Natural) return Boolean;
4042 pragma Postcondition
4046 (x /= 1 and then Odd (X - 1))));
4048 end Parity_Functions;
4052 There are no restrictions on the complexity or form of
4053 conditions used within @code{Postcondition} pragmas.
4054 The following example shows that it is even possible
4055 to verify performance behavior.
4057 @smallexample @c ada
4060 Performance : constant Float;
4061 -- Performance constant set by implementation
4062 -- to match target architecture behavior.
4064 procedure Treesort (Arg : String);
4065 -- Sorts characters of argument using N*logN sort
4066 pragma Postcondition
4067 (Float (Clock - Clock'Old) <=
4068 Float (Arg'Length) *
4069 log (Float (Arg'Length)) *
4075 Note: postcondition pragmas associated with subprograms that are
4076 marked as Inline_Always, or those marked as Inline with front-end
4077 inlining (-gnatN option set) are accepted and legality-checked
4078 by the compiler, but are ignored at run-time even if postcondition
4079 checking is enabled.
4081 @node Pragma Precondition
4082 @unnumberedsec Pragma Precondition
4083 @cindex Preconditions
4084 @cindex Checks, preconditions
4085 @findex Preconditions
4089 @smallexample @c ada
4090 pragma Precondition (
4091 [Check =>] Boolean_Expression
4092 [,[Message =>] String_Expression]);
4096 The @code{Precondition} pragma is similar to @code{Postcondition}
4097 except that the corresponding checks take place immediately upon
4098 entry to the subprogram, and if a precondition fails, the exception
4099 is raised in the context of the caller, and the attribute 'Result
4100 cannot be used within the precondition expression.
4102 Otherwise, the placement and visibility rules are identical to those
4103 described for postconditions. The following is an example of use
4104 within a package spec:
4106 @smallexample @c ada
4107 package Math_Functions is
4109 function Sqrt (Arg : Float) return Float;
4110 pragma Precondition (Arg >= 0.0)
4116 @code{Precondition} pragmas may appear either immediate following the
4117 (separate) declaration of a subprogram, or at the start of the
4118 declarations of a subprogram body. Only other pragmas may intervene
4119 (that is appear between the subprogram declaration and its
4120 postconditions, or appear before the postcondition in the
4121 declaration sequence in a subprogram body).
4123 Note: postcondition pragmas associated with subprograms that are
4124 marked as Inline_Always, or those marked as Inline with front-end
4125 inlining (-gnatN option set) are accepted and legality-checked
4126 by the compiler, but are ignored at run-time even if postcondition
4127 checking is enabled.
4129 @node Pragma Profile (Ravenscar)
4130 @unnumberedsec Pragma Profile (Ravenscar)
4135 @smallexample @c ada
4136 pragma Profile (Ravenscar);
4140 A configuration pragma that establishes the following set of configuration
4144 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4145 [RM D.2.2] Tasks are dispatched following a preemptive
4146 priority-ordered scheduling policy.
4148 @item Locking_Policy (Ceiling_Locking)
4149 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4150 the ceiling priority of the corresponding protected object.
4152 @c @item Detect_Blocking
4153 @c This pragma forces the detection of potentially blocking operations within a
4154 @c protected operation, and to raise Program_Error if that happens.
4158 plus the following set of restrictions:
4161 @item Max_Entry_Queue_Length = 1
4162 Defines the maximum number of calls that are queued on a (protected) entry.
4163 Note that this restrictions is checked at run time. Violation of this
4164 restriction results in the raising of Program_Error exception at the point of
4165 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4166 always 1 and hence no task can be queued on a protected entry.
4168 @item Max_Protected_Entries = 1
4169 [RM D.7] Specifies the maximum number of entries per protected type. The
4170 bounds of every entry family of a protected unit shall be static, or shall be
4171 defined by a discriminant of a subtype whose corresponding bound is static.
4172 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4174 @item Max_Task_Entries = 0
4175 [RM D.7] Specifies the maximum number of entries
4176 per task. The bounds of every entry family
4177 of a task unit shall be static, or shall be
4178 defined by a discriminant of a subtype whose
4179 corresponding bound is static. A value of zero
4180 indicates that no rendezvous are possible. For
4181 the Profile (Ravenscar), the value of Max_Task_Entries is always
4184 @item No_Abort_Statements
4185 [RM D.7] There are no abort_statements, and there are
4186 no calls to Task_Identification.Abort_Task.
4188 @item No_Asynchronous_Control
4189 There are no semantic dependences on the package
4190 Asynchronous_Task_Control.
4193 There are no semantic dependencies on the package Ada.Calendar.
4195 @item No_Dynamic_Attachment
4196 There is no call to any of the operations defined in package Ada.Interrupts
4197 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4198 Detach_Handler, and Reference).
4200 @item No_Dynamic_Priorities
4201 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4203 @item No_Implicit_Heap_Allocations
4204 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4206 @item No_Local_Protected_Objects
4207 Protected objects and access types that designate
4208 such objects shall be declared only at library level.
4210 @item No_Local_Timing_Events
4211 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4212 declared at the library level.
4214 @item No_Protected_Type_Allocators
4215 There are no allocators for protected types or
4216 types containing protected subcomponents.
4218 @item No_Relative_Delay
4219 There are no delay_relative statements.
4221 @item No_Requeue_Statements
4222 Requeue statements are not allowed.
4224 @item No_Select_Statements
4225 There are no select_statements.
4227 @item No_Specific_Termination_Handlers
4228 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4229 or to Ada.Task_Termination.Specific_Handler.
4231 @item No_Task_Allocators
4232 [RM D.7] There are no allocators for task types
4233 or types containing task subcomponents.
4235 @item No_Task_Attributes_Package
4236 There are no semantic dependencies on the Ada.Task_Attributes package.
4238 @item No_Task_Hierarchy
4239 [RM D.7] All (non-environment) tasks depend
4240 directly on the environment task of the partition.
4242 @item No_Task_Termination
4243 Tasks which terminate are erroneous.
4245 @item No_Unchecked_Conversion
4246 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4248 @item No_Unchecked_Deallocation
4249 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4251 @item Simple_Barriers
4252 Entry barrier condition expressions shall be either static
4253 boolean expressions or boolean objects which are declared in
4254 the protected type which contains the entry.
4258 This set of configuration pragmas and restrictions correspond to the
4259 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4260 published by the @cite{International Real-Time Ada Workshop}, 1997,
4261 and whose most recent description is available at
4262 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4264 The original definition of the profile was revised at subsequent IRTAW
4265 meetings. It has been included in the ISO
4266 @cite{Guide for the Use of the Ada Programming Language in High
4267 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4268 the next revision of the standard. The formal definition given by
4269 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4270 AI-305) available at
4271 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4272 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4275 The above set is a superset of the restrictions provided by pragma
4276 @code{Profile (Restricted)}, it includes six additional restrictions
4277 (@code{Simple_Barriers}, @code{No_Select_Statements},
4278 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4279 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4280 that pragma @code{Profile (Ravenscar)}, like the pragma
4281 @code{Profile (Restricted)},
4282 automatically causes the use of a simplified,
4283 more efficient version of the tasking run-time system.
4285 @node Pragma Profile (Restricted)
4286 @unnumberedsec Pragma Profile (Restricted)
4287 @findex Restricted Run Time
4291 @smallexample @c ada
4292 pragma Profile (Restricted);
4296 A configuration pragma that establishes the following set of restrictions:
4299 @item No_Abort_Statements
4300 @item No_Entry_Queue
4301 @item No_Task_Hierarchy
4302 @item No_Task_Allocators
4303 @item No_Dynamic_Priorities
4304 @item No_Terminate_Alternatives
4305 @item No_Dynamic_Attachment
4306 @item No_Protected_Type_Allocators
4307 @item No_Local_Protected_Objects
4308 @item No_Requeue_Statements
4309 @item No_Task_Attributes_Package
4310 @item Max_Asynchronous_Select_Nesting = 0
4311 @item Max_Task_Entries = 0
4312 @item Max_Protected_Entries = 1
4313 @item Max_Select_Alternatives = 0
4317 This set of restrictions causes the automatic selection of a simplified
4318 version of the run time that provides improved performance for the
4319 limited set of tasking functionality permitted by this set of restrictions.
4321 @node Pragma Psect_Object
4322 @unnumberedsec Pragma Psect_Object
4323 @findex Psect_Object
4327 @smallexample @c ada
4328 pragma Psect_Object (
4329 [Internal =>] LOCAL_NAME,
4330 [, [External =>] EXTERNAL_SYMBOL]
4331 [, [Size =>] EXTERNAL_SYMBOL]);
4335 | static_string_EXPRESSION
4339 This pragma is identical in effect to pragma @code{Common_Object}.
4341 @node Pragma Pure_Function
4342 @unnumberedsec Pragma Pure_Function
4343 @findex Pure_Function
4347 @smallexample @c ada
4348 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4352 This pragma appears in the same declarative part as a function
4353 declaration (or a set of function declarations if more than one
4354 overloaded declaration exists, in which case the pragma applies
4355 to all entities). It specifies that the function @code{Entity} is
4356 to be considered pure for the purposes of code generation. This means
4357 that the compiler can assume that there are no side effects, and
4358 in particular that two calls with identical arguments produce the
4359 same result. It also means that the function can be used in an
4362 Note that, quite deliberately, there are no static checks to try
4363 to ensure that this promise is met, so @code{Pure_Function} can be used
4364 with functions that are conceptually pure, even if they do modify
4365 global variables. For example, a square root function that is
4366 instrumented to count the number of times it is called is still
4367 conceptually pure, and can still be optimized, even though it
4368 modifies a global variable (the count). Memo functions are another
4369 example (where a table of previous calls is kept and consulted to
4370 avoid re-computation).
4373 Note: Most functions in a @code{Pure} package are automatically pure, and
4374 there is no need to use pragma @code{Pure_Function} for such functions. One
4375 exception is any function that has at least one formal of type
4376 @code{System.Address} or a type derived from it. Such functions are not
4377 considered pure by default, since the compiler assumes that the
4378 @code{Address} parameter may be functioning as a pointer and that the
4379 referenced data may change even if the address value does not.
4380 Similarly, imported functions are not considered to be pure by default,
4381 since there is no way of checking that they are in fact pure. The use
4382 of pragma @code{Pure_Function} for such a function will override these default
4383 assumption, and cause the compiler to treat a designated subprogram as pure
4386 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4387 applies to the underlying renamed function. This can be used to
4388 disambiguate cases of overloading where some but not all functions
4389 in a set of overloaded functions are to be designated as pure.
4391 If pragma @code{Pure_Function} is applied to a library level function, the
4392 function is also considered pure from an optimization point of view, but the
4393 unit is not a Pure unit in the categorization sense. So for example, a function
4394 thus marked is free to @code{with} non-pure units.
4396 @node Pragma Restriction_Warnings
4397 @unnumberedsec Pragma Restriction_Warnings
4398 @findex Restriction_Warnings
4402 @smallexample @c ada
4403 pragma Restriction_Warnings
4404 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4408 This pragma allows a series of restriction identifiers to be
4409 specified (the list of allowed identifiers is the same as for
4410 pragma @code{Restrictions}). For each of these identifiers
4411 the compiler checks for violations of the restriction, but
4412 generates a warning message rather than an error message
4413 if the restriction is violated.
4416 @unnumberedsec Pragma Shared
4420 This pragma is provided for compatibility with Ada 83. The syntax and
4421 semantics are identical to pragma Atomic.
4423 @node Pragma Short_Circuit_And_Or
4424 @unnumberedsec Pragma Short_Circuit_And_Or
4425 @findex Short_Circuit_And_Or
4428 This configuration pragma causes any occurrence of the AND operator applied to
4429 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4430 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4431 may be useful in the context of certification protocols requiring the use of
4432 short-circuited logical operators. If this configuration pragma occurs locally
4433 within the file being compiled, it applies only to the file being compiled.
4434 There is no requirement that all units in a partition use this option.
4436 @node Pragma Short_Descriptors
4437 @unnumberedsec Pragma Short_Descriptors
4438 @findex Short_Descriptors
4442 @smallexample @c ada
4443 pragma Short_Descriptors
4447 In VMS versions of the compiler, this configuration pragma causes all
4448 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4449 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4450 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4453 @node Pragma Source_File_Name
4454 @unnumberedsec Pragma Source_File_Name
4455 @findex Source_File_Name
4459 @smallexample @c ada
4460 pragma Source_File_Name (
4461 [Unit_Name =>] unit_NAME,
4462 Spec_File_Name => STRING_LITERAL,
4463 [Index => INTEGER_LITERAL]);
4465 pragma Source_File_Name (
4466 [Unit_Name =>] unit_NAME,
4467 Body_File_Name => STRING_LITERAL,
4468 [Index => INTEGER_LITERAL]);
4472 Use this to override the normal naming convention. It is a configuration
4473 pragma, and so has the usual applicability of configuration pragmas
4474 (i.e.@: it applies to either an entire partition, or to all units in a
4475 compilation, or to a single unit, depending on how it is used.
4476 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4477 the second argument is required, and indicates whether this is the file
4478 name for the spec or for the body.
4480 The optional Index argument should be used when a file contains multiple
4481 units, and when you do not want to use @code{gnatchop} to separate then
4482 into multiple files (which is the recommended procedure to limit the
4483 number of recompilations that are needed when some sources change).
4484 For instance, if the source file @file{source.ada} contains
4486 @smallexample @c ada
4498 you could use the following configuration pragmas:
4500 @smallexample @c ada
4501 pragma Source_File_Name
4502 (B, Spec_File_Name => "source.ada", Index => 1);
4503 pragma Source_File_Name
4504 (A, Body_File_Name => "source.ada", Index => 2);
4507 Note that the @code{gnatname} utility can also be used to generate those
4508 configuration pragmas.
4510 Another form of the @code{Source_File_Name} pragma allows
4511 the specification of patterns defining alternative file naming schemes
4512 to apply to all files.
4514 @smallexample @c ada
4515 pragma Source_File_Name
4516 ( [Spec_File_Name =>] STRING_LITERAL
4517 [,[Casing =>] CASING_SPEC]
4518 [,[Dot_Replacement =>] STRING_LITERAL]);
4520 pragma Source_File_Name
4521 ( [Body_File_Name =>] STRING_LITERAL
4522 [,[Casing =>] CASING_SPEC]
4523 [,[Dot_Replacement =>] STRING_LITERAL]);
4525 pragma Source_File_Name
4526 ( [Subunit_File_Name =>] STRING_LITERAL
4527 [,[Casing =>] CASING_SPEC]
4528 [,[Dot_Replacement =>] STRING_LITERAL]);
4530 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4534 The first argument is a pattern that contains a single asterisk indicating
4535 the point at which the unit name is to be inserted in the pattern string
4536 to form the file name. The second argument is optional. If present it
4537 specifies the casing of the unit name in the resulting file name string.
4538 The default is lower case. Finally the third argument allows for systematic
4539 replacement of any dots in the unit name by the specified string literal.
4541 A pragma Source_File_Name cannot appear after a
4542 @ref{Pragma Source_File_Name_Project}.
4544 For more details on the use of the @code{Source_File_Name} pragma,
4545 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4546 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4549 @node Pragma Source_File_Name_Project
4550 @unnumberedsec Pragma Source_File_Name_Project
4551 @findex Source_File_Name_Project
4554 This pragma has the same syntax and semantics as pragma Source_File_Name.
4555 It is only allowed as a stand alone configuration pragma.
4556 It cannot appear after a @ref{Pragma Source_File_Name}, and
4557 most importantly, once pragma Source_File_Name_Project appears,
4558 no further Source_File_Name pragmas are allowed.
4560 The intention is that Source_File_Name_Project pragmas are always
4561 generated by the Project Manager in a manner consistent with the naming
4562 specified in a project file, and when naming is controlled in this manner,
4563 it is not permissible to attempt to modify this naming scheme using
4564 Source_File_Name pragmas (which would not be known to the project manager).
4566 @node Pragma Source_Reference
4567 @unnumberedsec Pragma Source_Reference
4568 @findex Source_Reference
4572 @smallexample @c ada
4573 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4577 This pragma must appear as the first line of a source file.
4578 @var{integer_literal} is the logical line number of the line following
4579 the pragma line (for use in error messages and debugging
4580 information). @var{string_literal} is a static string constant that
4581 specifies the file name to be used in error messages and debugging
4582 information. This is most notably used for the output of @code{gnatchop}
4583 with the @option{-r} switch, to make sure that the original unchopped
4584 source file is the one referred to.
4586 The second argument must be a string literal, it cannot be a static
4587 string expression other than a string literal. This is because its value
4588 is needed for error messages issued by all phases of the compiler.
4590 @node Pragma Stream_Convert
4591 @unnumberedsec Pragma Stream_Convert
4592 @findex Stream_Convert
4596 @smallexample @c ada
4597 pragma Stream_Convert (
4598 [Entity =>] type_LOCAL_NAME,
4599 [Read =>] function_NAME,
4600 [Write =>] function_NAME);
4604 This pragma provides an efficient way of providing stream functions for
4605 types defined in packages. Not only is it simpler to use than declaring
4606 the necessary functions with attribute representation clauses, but more
4607 significantly, it allows the declaration to made in such a way that the
4608 stream packages are not loaded unless they are needed. The use of
4609 the Stream_Convert pragma adds no overhead at all, unless the stream
4610 attributes are actually used on the designated type.
4612 The first argument specifies the type for which stream functions are
4613 provided. The second parameter provides a function used to read values
4614 of this type. It must name a function whose argument type may be any
4615 subtype, and whose returned type must be the type given as the first
4616 argument to the pragma.
4618 The meaning of the @var{Read}
4619 parameter is that if a stream attribute directly
4620 or indirectly specifies reading of the type given as the first parameter,
4621 then a value of the type given as the argument to the Read function is
4622 read from the stream, and then the Read function is used to convert this
4623 to the required target type.
4625 Similarly the @var{Write} parameter specifies how to treat write attributes
4626 that directly or indirectly apply to the type given as the first parameter.
4627 It must have an input parameter of the type specified by the first parameter,
4628 and the return type must be the same as the input type of the Read function.
4629 The effect is to first call the Write function to convert to the given stream
4630 type, and then write the result type to the stream.
4632 The Read and Write functions must not be overloaded subprograms. If necessary
4633 renamings can be supplied to meet this requirement.
4634 The usage of this attribute is best illustrated by a simple example, taken
4635 from the GNAT implementation of package Ada.Strings.Unbounded:
4637 @smallexample @c ada
4638 function To_Unbounded (S : String)
4639 return Unbounded_String
4640 renames To_Unbounded_String;
4642 pragma Stream_Convert
4643 (Unbounded_String, To_Unbounded, To_String);
4647 The specifications of the referenced functions, as given in the Ada
4648 Reference Manual are:
4650 @smallexample @c ada
4651 function To_Unbounded_String (Source : String)
4652 return Unbounded_String;
4654 function To_String (Source : Unbounded_String)
4659 The effect is that if the value of an unbounded string is written to a stream,
4660 then the representation of the item in the stream is in the same format that
4661 would be used for @code{Standard.String'Output}, and this same representation
4662 is expected when a value of this type is read from the stream. Note that the
4663 value written always includes the bounds, even for Unbounded_String'Write,
4664 since Unbounded_String is not an array type.
4666 @node Pragma Style_Checks
4667 @unnumberedsec Pragma Style_Checks
4668 @findex Style_Checks
4672 @smallexample @c ada
4673 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4674 On | Off [, LOCAL_NAME]);
4678 This pragma is used in conjunction with compiler switches to control the
4679 built in style checking provided by GNAT@. The compiler switches, if set,
4680 provide an initial setting for the switches, and this pragma may be used
4681 to modify these settings, or the settings may be provided entirely by
4682 the use of the pragma. This pragma can be used anywhere that a pragma
4683 is legal, including use as a configuration pragma (including use in
4684 the @file{gnat.adc} file).
4686 The form with a string literal specifies which style options are to be
4687 activated. These are additive, so they apply in addition to any previously
4688 set style check options. The codes for the options are the same as those
4689 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4690 For example the following two methods can be used to enable
4695 @smallexample @c ada
4696 pragma Style_Checks ("l");
4701 gcc -c -gnatyl @dots{}
4706 The form ALL_CHECKS activates all standard checks (its use is equivalent
4707 to the use of the @code{gnaty} switch with no options. @xref{Top,
4708 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4709 @value{EDITION} User's Guide}, for details.)
4711 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4712 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4713 options (i.e. equivalent to -gnatyg).
4715 The forms with @code{Off} and @code{On}
4716 can be used to temporarily disable style checks
4717 as shown in the following example:
4719 @smallexample @c ada
4723 pragma Style_Checks ("k"); -- requires keywords in lower case
4724 pragma Style_Checks (Off); -- turn off style checks
4725 NULL; -- this will not generate an error message
4726 pragma Style_Checks (On); -- turn style checks back on
4727 NULL; -- this will generate an error message
4731 Finally the two argument form is allowed only if the first argument is
4732 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4733 for the specified entity, as shown in the following example:
4735 @smallexample @c ada
4739 pragma Style_Checks ("r"); -- require consistency of identifier casing
4741 Rf1 : Integer := ARG; -- incorrect, wrong case
4742 pragma Style_Checks (Off, Arg);
4743 Rf2 : Integer := ARG; -- OK, no error
4746 @node Pragma Subtitle
4747 @unnumberedsec Pragma Subtitle
4752 @smallexample @c ada
4753 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4757 This pragma is recognized for compatibility with other Ada compilers
4758 but is ignored by GNAT@.
4760 @node Pragma Suppress
4761 @unnumberedsec Pragma Suppress
4766 @smallexample @c ada
4767 pragma Suppress (Identifier [, [On =>] Name]);
4771 This is a standard pragma, and supports all the check names required in
4772 the RM. It is included here because GNAT recognizes one additional check
4773 name: @code{Alignment_Check} which can be used to suppress alignment checks
4774 on addresses used in address clauses. Such checks can also be suppressed
4775 by suppressing range checks, but the specific use of @code{Alignment_Check}
4776 allows suppression of alignment checks without suppressing other range checks.
4778 Note that pragma Suppress gives the compiler permission to omit
4779 checks, but does not require the compiler to omit checks. The compiler
4780 will generate checks if they are essentially free, even when they are
4781 suppressed. In particular, if the compiler can prove that a certain
4782 check will necessarily fail, it will generate code to do an
4783 unconditional ``raise'', even if checks are suppressed. The compiler
4786 Of course, run-time checks are omitted whenever the compiler can prove
4787 that they will not fail, whether or not checks are suppressed.
4789 @node Pragma Suppress_All
4790 @unnumberedsec Pragma Suppress_All
4791 @findex Suppress_All
4795 @smallexample @c ada
4796 pragma Suppress_All;
4800 This pragma can only appear immediately following a compilation
4801 unit. The effect is to apply @code{Suppress (All_Checks)} to the unit
4802 which it follows. This pragma is implemented for compatibility with DEC
4803 Ada 83 usage. The use of pragma @code{Suppress (All_Checks)} as a normal
4804 configuration pragma is the preferred usage in GNAT@.
4806 @node Pragma Suppress_Exception_Locations
4807 @unnumberedsec Pragma Suppress_Exception_Locations
4808 @findex Suppress_Exception_Locations
4812 @smallexample @c ada
4813 pragma Suppress_Exception_Locations;
4817 In normal mode, a raise statement for an exception by default generates
4818 an exception message giving the file name and line number for the location
4819 of the raise. This is useful for debugging and logging purposes, but this
4820 entails extra space for the strings for the messages. The configuration
4821 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4822 generation of these strings, with the result that space is saved, but the
4823 exception message for such raises is null. This configuration pragma may
4824 appear in a global configuration pragma file, or in a specific unit as
4825 usual. It is not required that this pragma be used consistently within
4826 a partition, so it is fine to have some units within a partition compiled
4827 with this pragma and others compiled in normal mode without it.
4829 @node Pragma Suppress_Initialization
4830 @unnumberedsec Pragma Suppress_Initialization
4831 @findex Suppress_Initialization
4832 @cindex Suppressing initialization
4833 @cindex Initialization, suppression of
4837 @smallexample @c ada
4838 pragma Suppress_Initialization ([Entity =>] type_Name);
4842 This pragma suppresses any implicit or explicit initialization
4843 associated with the given type name for all variables of this type.
4845 @node Pragma Task_Info
4846 @unnumberedsec Pragma Task_Info
4851 @smallexample @c ada
4852 pragma Task_Info (EXPRESSION);
4856 This pragma appears within a task definition (like pragma
4857 @code{Priority}) and applies to the task in which it appears. The
4858 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4859 The @code{Task_Info} pragma provides system dependent control over
4860 aspects of tasking implementation, for example, the ability to map
4861 tasks to specific processors. For details on the facilities available
4862 for the version of GNAT that you are using, see the documentation
4863 in the spec of package System.Task_Info in the runtime
4866 @node Pragma Task_Name
4867 @unnumberedsec Pragma Task_Name
4872 @smallexample @c ada
4873 pragma Task_Name (string_EXPRESSION);
4877 This pragma appears within a task definition (like pragma
4878 @code{Priority}) and applies to the task in which it appears. The
4879 argument must be of type String, and provides a name to be used for
4880 the task instance when the task is created. Note that this expression
4881 is not required to be static, and in particular, it can contain
4882 references to task discriminants. This facility can be used to
4883 provide different names for different tasks as they are created,
4884 as illustrated in the example below.
4886 The task name is recorded internally in the run-time structures
4887 and is accessible to tools like the debugger. In addition the
4888 routine @code{Ada.Task_Identification.Image} will return this
4889 string, with a unique task address appended.
4891 @smallexample @c ada
4892 -- Example of the use of pragma Task_Name
4894 with Ada.Task_Identification;
4895 use Ada.Task_Identification;
4896 with Text_IO; use Text_IO;
4899 type Astring is access String;
4901 task type Task_Typ (Name : access String) is
4902 pragma Task_Name (Name.all);
4905 task body Task_Typ is
4906 Nam : constant String := Image (Current_Task);
4908 Put_Line ("-->" & Nam (1 .. 14) & "<--");
4911 type Ptr_Task is access Task_Typ;
4912 Task_Var : Ptr_Task;
4916 new Task_Typ (new String'("This is task 1"));
4918 new Task_Typ (new String'("This is task 2"));
4922 @node Pragma Task_Storage
4923 @unnumberedsec Pragma Task_Storage
4924 @findex Task_Storage
4927 @smallexample @c ada
4928 pragma Task_Storage (
4929 [Task_Type =>] LOCAL_NAME,
4930 [Top_Guard =>] static_integer_EXPRESSION);
4934 This pragma specifies the length of the guard area for tasks. The guard
4935 area is an additional storage area allocated to a task. A value of zero
4936 means that either no guard area is created or a minimal guard area is
4937 created, depending on the target. This pragma can appear anywhere a
4938 @code{Storage_Size} attribute definition clause is allowed for a task
4941 @node Pragma Thread_Local_Storage
4942 @unnumberedsec Pragma Thread_Local_Storage
4943 @findex Thread_Local_Storage
4944 @cindex Task specific storage
4945 @cindex TLS (Thread Local Storage)
4948 @smallexample @c ada
4949 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4953 This pragma specifies that the specified entity, which must be
4954 a variable declared in a library level package, is to be marked as
4955 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4956 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4957 (and hence each Ada task) to see a distinct copy of the variable.
4959 The variable may not have default initialization, and if there is
4960 an explicit initialization, it must be either @code{null} for an
4961 access variable, or a static expression for a scalar variable.
4962 This provides a low level mechanism similar to that provided by
4963 the @code{Ada.Task_Attributes} package, but much more efficient
4964 and is also useful in writing interface code that will interact
4965 with foreign threads.
4967 If this pragma is used on a system where @code{TLS} is not supported,
4968 then an error message will be generated and the program will be rejected.
4970 @node Pragma Time_Slice
4971 @unnumberedsec Pragma Time_Slice
4976 @smallexample @c ada
4977 pragma Time_Slice (static_duration_EXPRESSION);
4981 For implementations of GNAT on operating systems where it is possible
4982 to supply a time slice value, this pragma may be used for this purpose.
4983 It is ignored if it is used in a system that does not allow this control,
4984 or if it appears in other than the main program unit.
4986 Note that the effect of this pragma is identical to the effect of the
4987 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4990 @unnumberedsec Pragma Title
4995 @smallexample @c ada
4996 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4999 [Title =>] STRING_LITERAL,
5000 | [Subtitle =>] STRING_LITERAL
5004 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5005 pragma used in DEC Ada 83 implementations to provide a title and/or
5006 subtitle for the program listing. The program listing generated by GNAT
5007 does not have titles or subtitles.
5009 Unlike other pragmas, the full flexibility of named notation is allowed
5010 for this pragma, i.e.@: the parameters may be given in any order if named
5011 notation is used, and named and positional notation can be mixed
5012 following the normal rules for procedure calls in Ada.
5014 @node Pragma Unchecked_Union
5015 @unnumberedsec Pragma Unchecked_Union
5017 @findex Unchecked_Union
5021 @smallexample @c ada
5022 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5026 This pragma is used to specify a representation of a record type that is
5027 equivalent to a C union. It was introduced as a GNAT implementation defined
5028 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5029 pragma, making it language defined, and GNAT fully implements this extended
5030 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5031 details, consult the Ada 2005 Reference Manual, section B.3.3.
5033 @node Pragma Unimplemented_Unit
5034 @unnumberedsec Pragma Unimplemented_Unit
5035 @findex Unimplemented_Unit
5039 @smallexample @c ada
5040 pragma Unimplemented_Unit;
5044 If this pragma occurs in a unit that is processed by the compiler, GNAT
5045 aborts with the message @samp{@var{xxx} not implemented}, where
5046 @var{xxx} is the name of the current compilation unit. This pragma is
5047 intended to allow the compiler to handle unimplemented library units in
5050 The abort only happens if code is being generated. Thus you can use
5051 specs of unimplemented packages in syntax or semantic checking mode.
5053 @node Pragma Universal_Aliasing
5054 @unnumberedsec Pragma Universal_Aliasing
5055 @findex Universal_Aliasing
5059 @smallexample @c ada
5060 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5064 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5065 declarative part. The effect is to inhibit strict type-based aliasing
5066 optimization for the given type. In other words, the effect is as though
5067 access types designating this type were subject to pragma No_Strict_Aliasing.
5068 For a detailed description of the strict aliasing optimization, and the
5069 situations in which it must be suppressed, @xref{Optimization and Strict
5070 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5072 @node Pragma Universal_Data
5073 @unnumberedsec Pragma Universal_Data
5074 @findex Universal_Data
5078 @smallexample @c ada
5079 pragma Universal_Data [(library_unit_Name)];
5083 This pragma is supported only for the AAMP target and is ignored for
5084 other targets. The pragma specifies that all library-level objects
5085 (Counter 0 data) associated with the library unit are to be accessed
5086 and updated using universal addressing (24-bit addresses for AAMP5)
5087 rather than the default of 16-bit Data Environment (DENV) addressing.
5088 Use of this pragma will generally result in less efficient code for
5089 references to global data associated with the library unit, but
5090 allows such data to be located anywhere in memory. This pragma is
5091 a library unit pragma, but can also be used as a configuration pragma
5092 (including use in the @file{gnat.adc} file). The functionality
5093 of this pragma is also available by applying the -univ switch on the
5094 compilations of units where universal addressing of the data is desired.
5096 @node Pragma Unmodified
5097 @unnumberedsec Pragma Unmodified
5099 @cindex Warnings, unmodified
5103 @smallexample @c ada
5104 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5108 This pragma signals that the assignable entities (variables,
5109 @code{out} parameters, @code{in out} parameters) whose names are listed are
5110 deliberately not assigned in the current source unit. This
5111 suppresses warnings about the
5112 entities being referenced but not assigned, and in addition a warning will be
5113 generated if one of these entities is in fact assigned in the
5114 same unit as the pragma (or in the corresponding body, or one
5117 This is particularly useful for clearly signaling that a particular
5118 parameter is not modified, even though the spec suggests that it might
5121 @node Pragma Unreferenced
5122 @unnumberedsec Pragma Unreferenced
5123 @findex Unreferenced
5124 @cindex Warnings, unreferenced
5128 @smallexample @c ada
5129 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5130 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5134 This pragma signals that the entities whose names are listed are
5135 deliberately not referenced in the current source unit. This
5136 suppresses warnings about the
5137 entities being unreferenced, and in addition a warning will be
5138 generated if one of these entities is in fact referenced in the
5139 same unit as the pragma (or in the corresponding body, or one
5142 This is particularly useful for clearly signaling that a particular
5143 parameter is not referenced in some particular subprogram implementation
5144 and that this is deliberate. It can also be useful in the case of
5145 objects declared only for their initialization or finalization side
5148 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5149 current scope, then the entity most recently declared is the one to which
5150 the pragma applies. Note that in the case of accept formals, the pragma
5151 Unreferenced may appear immediately after the keyword @code{do} which
5152 allows the indication of whether or not accept formals are referenced
5153 or not to be given individually for each accept statement.
5155 The left hand side of an assignment does not count as a reference for the
5156 purpose of this pragma. Thus it is fine to assign to an entity for which
5157 pragma Unreferenced is given.
5159 Note that if a warning is desired for all calls to a given subprogram,
5160 regardless of whether they occur in the same unit as the subprogram
5161 declaration, then this pragma should not be used (calls from another
5162 unit would not be flagged); pragma Obsolescent can be used instead
5163 for this purpose, see @xref{Pragma Obsolescent}.
5165 The second form of pragma @code{Unreferenced} is used within a context
5166 clause. In this case the arguments must be unit names of units previously
5167 mentioned in @code{with} clauses (similar to the usage of pragma
5168 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5169 units and unreferenced entities within these units.
5171 @node Pragma Unreferenced_Objects
5172 @unnumberedsec Pragma Unreferenced_Objects
5173 @findex Unreferenced_Objects
5174 @cindex Warnings, unreferenced
5178 @smallexample @c ada
5179 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5183 This pragma signals that for the types or subtypes whose names are
5184 listed, objects which are declared with one of these types or subtypes may
5185 not be referenced, and if no references appear, no warnings are given.
5187 This is particularly useful for objects which are declared solely for their
5188 initialization and finalization effect. Such variables are sometimes referred
5189 to as RAII variables (Resource Acquisition Is Initialization). Using this
5190 pragma on the relevant type (most typically a limited controlled type), the
5191 compiler will automatically suppress unwanted warnings about these variables
5192 not being referenced.
5194 @node Pragma Unreserve_All_Interrupts
5195 @unnumberedsec Pragma Unreserve_All_Interrupts
5196 @findex Unreserve_All_Interrupts
5200 @smallexample @c ada
5201 pragma Unreserve_All_Interrupts;
5205 Normally certain interrupts are reserved to the implementation. Any attempt
5206 to attach an interrupt causes Program_Error to be raised, as described in
5207 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5208 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5209 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5210 interrupt execution.
5212 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5213 a program, then all such interrupts are unreserved. This allows the
5214 program to handle these interrupts, but disables their standard
5215 functions. For example, if this pragma is used, then pressing
5216 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5217 a program can then handle the @code{SIGINT} interrupt as it chooses.
5219 For a full list of the interrupts handled in a specific implementation,
5220 see the source code for the spec of @code{Ada.Interrupts.Names} in
5221 file @file{a-intnam.ads}. This is a target dependent file that contains the
5222 list of interrupts recognized for a given target. The documentation in
5223 this file also specifies what interrupts are affected by the use of
5224 the @code{Unreserve_All_Interrupts} pragma.
5226 For a more general facility for controlling what interrupts can be
5227 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5228 of the @code{Unreserve_All_Interrupts} pragma.
5230 @node Pragma Unsuppress
5231 @unnumberedsec Pragma Unsuppress
5236 @smallexample @c ada
5237 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5241 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5242 there is no corresponding pragma @code{Suppress} in effect, it has no
5243 effect. The range of the effect is the same as for pragma
5244 @code{Suppress}. The meaning of the arguments is identical to that used
5245 in pragma @code{Suppress}.
5247 One important application is to ensure that checks are on in cases where
5248 code depends on the checks for its correct functioning, so that the code
5249 will compile correctly even if the compiler switches are set to suppress
5252 @node Pragma Use_VADS_Size
5253 @unnumberedsec Pragma Use_VADS_Size
5254 @cindex @code{Size}, VADS compatibility
5255 @findex Use_VADS_Size
5259 @smallexample @c ada
5260 pragma Use_VADS_Size;
5264 This is a configuration pragma. In a unit to which it applies, any use
5265 of the 'Size attribute is automatically interpreted as a use of the
5266 'VADS_Size attribute. Note that this may result in incorrect semantic
5267 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5268 the handling of existing code which depends on the interpretation of Size
5269 as implemented in the VADS compiler. See description of the VADS_Size
5270 attribute for further details.
5272 @node Pragma Validity_Checks
5273 @unnumberedsec Pragma Validity_Checks
5274 @findex Validity_Checks
5278 @smallexample @c ada
5279 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5283 This pragma is used in conjunction with compiler switches to control the
5284 built-in validity checking provided by GNAT@. The compiler switches, if set
5285 provide an initial setting for the switches, and this pragma may be used
5286 to modify these settings, or the settings may be provided entirely by
5287 the use of the pragma. This pragma can be used anywhere that a pragma
5288 is legal, including use as a configuration pragma (including use in
5289 the @file{gnat.adc} file).
5291 The form with a string literal specifies which validity options are to be
5292 activated. The validity checks are first set to include only the default
5293 reference manual settings, and then a string of letters in the string
5294 specifies the exact set of options required. The form of this string
5295 is exactly as described for the @option{-gnatVx} compiler switch (see the
5296 GNAT users guide for details). For example the following two methods
5297 can be used to enable validity checking for mode @code{in} and
5298 @code{in out} subprogram parameters:
5302 @smallexample @c ada
5303 pragma Validity_Checks ("im");
5308 gcc -c -gnatVim @dots{}
5313 The form ALL_CHECKS activates all standard checks (its use is equivalent
5314 to the use of the @code{gnatva} switch.
5316 The forms with @code{Off} and @code{On}
5317 can be used to temporarily disable validity checks
5318 as shown in the following example:
5320 @smallexample @c ada
5324 pragma Validity_Checks ("c"); -- validity checks for copies
5325 pragma Validity_Checks (Off); -- turn off validity checks
5326 A := B; -- B will not be validity checked
5327 pragma Validity_Checks (On); -- turn validity checks back on
5328 A := C; -- C will be validity checked
5331 @node Pragma Volatile
5332 @unnumberedsec Pragma Volatile
5337 @smallexample @c ada
5338 pragma Volatile (LOCAL_NAME);
5342 This pragma is defined by the Ada Reference Manual, and the GNAT
5343 implementation is fully conformant with this definition. The reason it
5344 is mentioned in this section is that a pragma of the same name was supplied
5345 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5346 implementation of pragma Volatile is upwards compatible with the
5347 implementation in DEC Ada 83.
5349 @node Pragma Warnings
5350 @unnumberedsec Pragma Warnings
5355 @smallexample @c ada
5356 pragma Warnings (On | Off);
5357 pragma Warnings (On | Off, LOCAL_NAME);
5358 pragma Warnings (static_string_EXPRESSION);
5359 pragma Warnings (On | Off, static_string_EXPRESSION);
5363 Normally warnings are enabled, with the output being controlled by
5364 the command line switch. Warnings (@code{Off}) turns off generation of
5365 warnings until a Warnings (@code{On}) is encountered or the end of the
5366 current unit. If generation of warnings is turned off using this
5367 pragma, then no warning messages are output, regardless of the
5368 setting of the command line switches.
5370 The form with a single argument may be used as a configuration pragma.
5372 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5373 the specified entity. This suppression is effective from the point where
5374 it occurs till the end of the extended scope of the variable (similar to
5375 the scope of @code{Suppress}).
5377 The form with a single static_string_EXPRESSION argument provides more precise
5378 control over which warnings are active. The string is a list of letters
5379 specifying which warnings are to be activated and which deactivated. The
5380 code for these letters is the same as the string used in the command
5381 line switch controlling warnings. For a brief summary, use the gnatmake
5382 command with no arguments, which will generate usage information containing
5383 the list of warnings switches supported. For
5384 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5388 The specified warnings will be in effect until the end of the program
5389 or another pragma Warnings is encountered. The effect of the pragma is
5390 cumulative. Initially the set of warnings is the standard default set
5391 as possibly modified by compiler switches. Then each pragma Warning
5392 modifies this set of warnings as specified. This form of the pragma may
5393 also be used as a configuration pragma.
5395 The fourth form, with an On|Off parameter and a string, is used to
5396 control individual messages, based on their text. The string argument
5397 is a pattern that is used to match against the text of individual
5398 warning messages (not including the initial "warning: " tag).
5400 The pattern may contain asterisks, which match zero or more characters in
5401 the message. For example, you can use
5402 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5403 message @code{warning: 960 bits of "a" unused}. No other regular
5404 expression notations are permitted. All characters other than asterisk in
5405 these three specific cases are treated as literal characters in the match.
5407 There are two ways to use this pragma. The OFF form can be used as a
5408 configuration pragma. The effect is to suppress all warnings (if any)
5409 that match the pattern string throughout the compilation.
5411 The second usage is to suppress a warning locally, and in this case, two
5412 pragmas must appear in sequence:
5414 @smallexample @c ada
5415 pragma Warnings (Off, Pattern);
5416 @dots{} code where given warning is to be suppressed
5417 pragma Warnings (On, Pattern);
5421 In this usage, the pattern string must match in the Off and On pragmas,
5422 and at least one matching warning must be suppressed.
5424 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5425 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5426 be useful in checking whether obsolete pragmas in existing programs are hiding
5429 Note: pragma Warnings does not affect the processing of style messages. See
5430 separate entry for pragma Style_Checks for control of style messages.
5432 @node Pragma Weak_External
5433 @unnumberedsec Pragma Weak_External
5434 @findex Weak_External
5438 @smallexample @c ada
5439 pragma Weak_External ([Entity =>] LOCAL_NAME);
5443 @var{LOCAL_NAME} must refer to an object that is declared at the library
5444 level. This pragma specifies that the given entity should be marked as a
5445 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5446 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5447 of a regular symbol, that is to say a symbol that does not have to be
5448 resolved by the linker if used in conjunction with a pragma Import.
5450 When a weak symbol is not resolved by the linker, its address is set to
5451 zero. This is useful in writing interfaces to external modules that may
5452 or may not be linked in the final executable, for example depending on
5453 configuration settings.
5455 If a program references at run time an entity to which this pragma has been
5456 applied, and the corresponding symbol was not resolved at link time, then
5457 the execution of the program is erroneous. It is not erroneous to take the
5458 Address of such an entity, for example to guard potential references,
5459 as shown in the example below.
5461 Some file formats do not support weak symbols so not all target machines
5462 support this pragma.
5464 @smallexample @c ada
5465 -- Example of the use of pragma Weak_External
5467 package External_Module is
5469 pragma Import (C, key);
5470 pragma Weak_External (key);
5471 function Present return boolean;
5472 end External_Module;
5474 with System; use System;
5475 package body External_Module is
5476 function Present return boolean is
5478 return key'Address /= System.Null_Address;
5480 end External_Module;
5483 @node Pragma Wide_Character_Encoding
5484 @unnumberedsec Pragma Wide_Character_Encoding
5485 @findex Wide_Character_Encoding
5489 @smallexample @c ada
5490 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5494 This pragma specifies the wide character encoding to be used in program
5495 source text appearing subsequently. It is a configuration pragma, but may
5496 also be used at any point that a pragma is allowed, and it is permissible
5497 to have more than one such pragma in a file, allowing multiple encodings
5498 to appear within the same file.
5500 The argument can be an identifier or a character literal. In the identifier
5501 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5502 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5503 case it is correspondingly one of the characters @samp{h}, @samp{u},
5504 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5506 Note that when the pragma is used within a file, it affects only the
5507 encoding within that file, and does not affect withed units, specs,
5510 @node Implementation Defined Attributes
5511 @chapter Implementation Defined Attributes
5512 Ada defines (throughout the Ada reference manual,
5513 summarized in Annex K),
5514 a set of attributes that provide useful additional functionality in all
5515 areas of the language. These language defined attributes are implemented
5516 in GNAT and work as described in the Ada Reference Manual.
5518 In addition, Ada allows implementations to define additional
5519 attributes whose meaning is defined by the implementation. GNAT provides
5520 a number of these implementation-dependent attributes which can be used
5521 to extend and enhance the functionality of the compiler. This section of
5522 the GNAT reference manual describes these additional attributes.
5524 Note that any program using these attributes may not be portable to
5525 other compilers (although GNAT implements this set of attributes on all
5526 platforms). Therefore if portability to other compilers is an important
5527 consideration, you should minimize the use of these attributes.
5537 * Compiler_Version::
5539 * Default_Bit_Order::
5549 * Has_Access_Values::
5550 * Has_Discriminants::
5557 * Max_Interrupt_Priority::
5559 * Maximum_Alignment::
5564 * Passed_By_Reference::
5578 * Unconstrained_Array::
5579 * Universal_Literal_String::
5580 * Unrestricted_Access::
5588 @unnumberedsec Abort_Signal
5589 @findex Abort_Signal
5591 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5592 prefix) provides the entity for the special exception used to signal
5593 task abort or asynchronous transfer of control. Normally this attribute
5594 should only be used in the tasking runtime (it is highly peculiar, and
5595 completely outside the normal semantics of Ada, for a user program to
5596 intercept the abort exception).
5599 @unnumberedsec Address_Size
5600 @cindex Size of @code{Address}
5601 @findex Address_Size
5603 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5604 prefix) is a static constant giving the number of bits in an
5605 @code{Address}. It is the same value as System.Address'Size,
5606 but has the advantage of being static, while a direct
5607 reference to System.Address'Size is non-static because Address
5611 @unnumberedsec Asm_Input
5614 The @code{Asm_Input} attribute denotes a function that takes two
5615 parameters. The first is a string, the second is an expression of the
5616 type designated by the prefix. The first (string) argument is required
5617 to be a static expression, and is the constraint for the parameter,
5618 (e.g.@: what kind of register is required). The second argument is the
5619 value to be used as the input argument. The possible values for the
5620 constant are the same as those used in the RTL, and are dependent on
5621 the configuration file used to built the GCC back end.
5622 @ref{Machine Code Insertions}
5625 @unnumberedsec Asm_Output
5628 The @code{Asm_Output} attribute denotes a function that takes two
5629 parameters. The first is a string, the second is the name of a variable
5630 of the type designated by the attribute prefix. The first (string)
5631 argument is required to be a static expression and designates the
5632 constraint for the parameter (e.g.@: what kind of register is
5633 required). The second argument is the variable to be updated with the
5634 result. The possible values for constraint are the same as those used in
5635 the RTL, and are dependent on the configuration file used to build the
5636 GCC back end. If there are no output operands, then this argument may
5637 either be omitted, or explicitly given as @code{No_Output_Operands}.
5638 @ref{Machine Code Insertions}
5641 @unnumberedsec AST_Entry
5645 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5646 the name of an entry, it yields a value of the predefined type AST_Handler
5647 (declared in the predefined package System, as extended by the use of
5648 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5649 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5650 Language Reference Manual}, section 9.12a.
5655 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5656 offset within the storage unit (byte) that contains the first bit of
5657 storage allocated for the object. The value of this attribute is of the
5658 type @code{Universal_Integer}, and is always a non-negative number not
5659 exceeding the value of @code{System.Storage_Unit}.
5661 For an object that is a variable or a constant allocated in a register,
5662 the value is zero. (The use of this attribute does not force the
5663 allocation of a variable to memory).
5665 For an object that is a formal parameter, this attribute applies
5666 to either the matching actual parameter or to a copy of the
5667 matching actual parameter.
5669 For an access object the value is zero. Note that
5670 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5671 designated object. Similarly for a record component
5672 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5673 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5674 are subject to index checks.
5676 This attribute is designed to be compatible with the DEC Ada 83 definition
5677 and implementation of the @code{Bit} attribute.
5680 @unnumberedsec Bit_Position
5681 @findex Bit_Position
5683 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5684 of the fields of the record type, yields the bit
5685 offset within the record contains the first bit of
5686 storage allocated for the object. The value of this attribute is of the
5687 type @code{Universal_Integer}. The value depends only on the field
5688 @var{C} and is independent of the alignment of
5689 the containing record @var{R}.
5691 @node Compiler_Version
5692 @unnumberedsec Compiler_Version
5693 @findex Compiler_Version
5695 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5696 prefix) yields a static string identifying the version of the compiler
5697 being used to compile the unit containing the attribute reference. A
5698 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5701 @unnumberedsec Code_Address
5702 @findex Code_Address
5703 @cindex Subprogram address
5704 @cindex Address of subprogram code
5707 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5708 intended effect seems to be to provide
5709 an address value which can be used to call the subprogram by means of
5710 an address clause as in the following example:
5712 @smallexample @c ada
5713 procedure K is @dots{}
5716 for L'Address use K'Address;
5717 pragma Import (Ada, L);
5721 A call to @code{L} is then expected to result in a call to @code{K}@.
5722 In Ada 83, where there were no access-to-subprogram values, this was
5723 a common work-around for getting the effect of an indirect call.
5724 GNAT implements the above use of @code{Address} and the technique
5725 illustrated by the example code works correctly.
5727 However, for some purposes, it is useful to have the address of the start
5728 of the generated code for the subprogram. On some architectures, this is
5729 not necessarily the same as the @code{Address} value described above.
5730 For example, the @code{Address} value may reference a subprogram
5731 descriptor rather than the subprogram itself.
5733 The @code{'Code_Address} attribute, which can only be applied to
5734 subprogram entities, always returns the address of the start of the
5735 generated code of the specified subprogram, which may or may not be
5736 the same value as is returned by the corresponding @code{'Address}
5739 @node Default_Bit_Order
5740 @unnumberedsec Default_Bit_Order
5742 @cindex Little endian
5743 @findex Default_Bit_Order
5745 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5746 permissible prefix), provides the value @code{System.Default_Bit_Order}
5747 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5748 @code{Low_Order_First}). This is used to construct the definition of
5749 @code{Default_Bit_Order} in package @code{System}.
5752 @unnumberedsec Elaborated
5755 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5756 value is a Boolean which indicates whether or not the given unit has been
5757 elaborated. This attribute is primarily intended for internal use by the
5758 generated code for dynamic elaboration checking, but it can also be used
5759 in user programs. The value will always be True once elaboration of all
5760 units has been completed. An exception is for units which need no
5761 elaboration, the value is always False for such units.
5764 @unnumberedsec Elab_Body
5767 This attribute can only be applied to a program unit name. It returns
5768 the entity for the corresponding elaboration procedure for elaborating
5769 the body of the referenced unit. This is used in the main generated
5770 elaboration procedure by the binder and is not normally used in any
5771 other context. However, there may be specialized situations in which it
5772 is useful to be able to call this elaboration procedure from Ada code,
5773 e.g.@: if it is necessary to do selective re-elaboration to fix some
5777 @unnumberedsec Elab_Spec
5780 This attribute can only be applied to a program unit name. It returns
5781 the entity for the corresponding elaboration procedure for elaborating
5782 the spec of the referenced unit. This is used in the main
5783 generated elaboration procedure by the binder and is not normally used
5784 in any other context. However, there may be specialized situations in
5785 which it is useful to be able to call this elaboration procedure from
5786 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5791 @cindex Ada 83 attributes
5794 The @code{Emax} attribute is provided for compatibility with Ada 83. See
5795 the Ada 83 reference manual for an exact description of the semantics of
5799 @unnumberedsec Enabled
5802 The @code{Enabled} attribute allows an application program to check at compile
5803 time to see if the designated check is currently enabled. The prefix is a
5804 simple identifier, referencing any predefined check name (other than
5805 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5806 no argument is given for the attribute, the check is for the general state
5807 of the check, if an argument is given, then it is an entity name, and the
5808 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5809 given naming the entity (if not, then the argument is ignored).
5811 Note that instantiations inherit the check status at the point of the
5812 instantiation, so a useful idiom is to have a library package that
5813 introduces a check name with @code{pragma Check_Name}, and then contains
5814 generic packages or subprograms which use the @code{Enabled} attribute
5815 to see if the check is enabled. A user of this package can then issue
5816 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5817 the package or subprogram, controlling whether the check will be present.
5820 @unnumberedsec Enum_Rep
5821 @cindex Representation of enums
5824 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5825 function with the following spec:
5827 @smallexample @c ada
5828 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5829 return @i{Universal_Integer};
5833 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5834 enumeration type or to a non-overloaded enumeration
5835 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
5836 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5837 enumeration literal or object.
5839 The function returns the representation value for the given enumeration
5840 value. This will be equal to value of the @code{Pos} attribute in the
5841 absence of an enumeration representation clause. This is a static
5842 attribute (i.e.@: the result is static if the argument is static).
5844 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5845 in which case it simply returns the integer value. The reason for this
5846 is to allow it to be used for @code{(<>)} discrete formal arguments in
5847 a generic unit that can be instantiated with either enumeration types
5848 or integer types. Note that if @code{Enum_Rep} is used on a modular
5849 type whose upper bound exceeds the upper bound of the largest signed
5850 integer type, and the argument is a variable, so that the universal
5851 integer calculation is done at run time, then the call to @code{Enum_Rep}
5852 may raise @code{Constraint_Error}.
5855 @unnumberedsec Enum_Val
5856 @cindex Representation of enums
5859 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
5860 function with the following spec:
5862 @smallexample @c ada
5863 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
5864 return @var{S}'Base};
5868 The function returns the enumeration value whose representation matches the
5869 argument, or raises Constraint_Error if no enumeration literal of the type
5870 has the matching value.
5871 This will be equal to value of the @code{Val} attribute in the
5872 absence of an enumeration representation clause. This is a static
5873 attribute (i.e.@: the result is static if the argument is static).
5876 @unnumberedsec Epsilon
5877 @cindex Ada 83 attributes
5880 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
5881 the Ada 83 reference manual for an exact description of the semantics of
5885 @unnumberedsec Fixed_Value
5888 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5889 function with the following specification:
5891 @smallexample @c ada
5892 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5897 The value returned is the fixed-point value @var{V} such that
5899 @smallexample @c ada
5900 @var{V} = Arg * @var{S}'Small
5904 The effect is thus similar to first converting the argument to the
5905 integer type used to represent @var{S}, and then doing an unchecked
5906 conversion to the fixed-point type. The difference is
5907 that there are full range checks, to ensure that the result is in range.
5908 This attribute is primarily intended for use in implementation of the
5909 input-output functions for fixed-point values.
5911 @node Has_Access_Values
5912 @unnumberedsec Has_Access_Values
5913 @cindex Access values, testing for
5914 @findex Has_Access_Values
5916 The prefix of the @code{Has_Access_Values} attribute is a type. The result
5917 is a Boolean value which is True if the is an access type, or is a composite
5918 type with a component (at any nesting depth) that is an access type, and is
5920 The intended use of this attribute is in conjunction with generic
5921 definitions. If the attribute is applied to a generic private type, it
5922 indicates whether or not the corresponding actual type has access values.
5924 @node Has_Discriminants
5925 @unnumberedsec Has_Discriminants
5926 @cindex Discriminants, testing for
5927 @findex Has_Discriminants
5929 The prefix of the @code{Has_Discriminants} attribute is a type. The result
5930 is a Boolean value which is True if the type has discriminants, and False
5931 otherwise. The intended use of this attribute is in conjunction with generic
5932 definitions. If the attribute is applied to a generic private type, it
5933 indicates whether or not the corresponding actual type has discriminants.
5939 The @code{Img} attribute differs from @code{Image} in that it may be
5940 applied to objects as well as types, in which case it gives the
5941 @code{Image} for the subtype of the object. This is convenient for
5944 @smallexample @c ada
5945 Put_Line ("X = " & X'Img);
5949 has the same meaning as the more verbose:
5951 @smallexample @c ada
5952 Put_Line ("X = " & @var{T}'Image (X));
5956 where @var{T} is the (sub)type of the object @code{X}.
5959 @unnumberedsec Integer_Value
5960 @findex Integer_Value
5962 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5963 function with the following spec:
5965 @smallexample @c ada
5966 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5971 The value returned is the integer value @var{V}, such that
5973 @smallexample @c ada
5974 Arg = @var{V} * @var{T}'Small
5978 where @var{T} is the type of @code{Arg}.
5979 The effect is thus similar to first doing an unchecked conversion from
5980 the fixed-point type to its corresponding implementation type, and then
5981 converting the result to the target integer type. The difference is
5982 that there are full range checks, to ensure that the result is in range.
5983 This attribute is primarily intended for use in implementation of the
5984 standard input-output functions for fixed-point values.
5987 @unnumberedsec Invalid_Value
5988 @findex Invalid_Value
5990 For every scalar type S, S'Invalid_Value returns an undefined value of the
5991 type. If possible this value is an invalid representation for the type. The
5992 value returned is identical to the value used to initialize an otherwise
5993 uninitialized value of the type if pragma Initialize_Scalars is used,
5994 including the ability to modify the value with the binder -Sxx flag and
5995 relevant environment variables at run time.
5998 @unnumberedsec Large
5999 @cindex Ada 83 attributes
6002 The @code{Large} attribute is provided for compatibility with Ada 83. See
6003 the Ada 83 reference manual for an exact description of the semantics of
6007 @unnumberedsec Machine_Size
6008 @findex Machine_Size
6010 This attribute is identical to the @code{Object_Size} attribute. It is
6011 provided for compatibility with the DEC Ada 83 attribute of this name.
6014 @unnumberedsec Mantissa
6015 @cindex Ada 83 attributes
6018 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6019 the Ada 83 reference manual for an exact description of the semantics of
6022 @node Max_Interrupt_Priority
6023 @unnumberedsec Max_Interrupt_Priority
6024 @cindex Interrupt priority, maximum
6025 @findex Max_Interrupt_Priority
6027 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6028 permissible prefix), provides the same value as
6029 @code{System.Max_Interrupt_Priority}.
6032 @unnumberedsec Max_Priority
6033 @cindex Priority, maximum
6034 @findex Max_Priority
6036 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6037 prefix) provides the same value as @code{System.Max_Priority}.
6039 @node Maximum_Alignment
6040 @unnumberedsec Maximum_Alignment
6041 @cindex Alignment, maximum
6042 @findex Maximum_Alignment
6044 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6045 permissible prefix) provides the maximum useful alignment value for the
6046 target. This is a static value that can be used to specify the alignment
6047 for an object, guaranteeing that it is properly aligned in all
6050 @node Mechanism_Code
6051 @unnumberedsec Mechanism_Code
6052 @cindex Return values, passing mechanism
6053 @cindex Parameters, passing mechanism
6054 @findex Mechanism_Code
6056 @code{@var{function}'Mechanism_Code} yields an integer code for the
6057 mechanism used for the result of function, and
6058 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6059 used for formal parameter number @var{n} (a static integer value with 1
6060 meaning the first parameter) of @var{subprogram}. The code returned is:
6068 by descriptor (default descriptor class)
6070 by descriptor (UBS: unaligned bit string)
6072 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6074 by descriptor (UBA: unaligned bit array)
6076 by descriptor (S: string, also scalar access type parameter)
6078 by descriptor (SB: string with arbitrary bounds)
6080 by descriptor (A: contiguous array)
6082 by descriptor (NCA: non-contiguous array)
6086 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6089 @node Null_Parameter
6090 @unnumberedsec Null_Parameter
6091 @cindex Zero address, passing
6092 @findex Null_Parameter
6094 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6095 type or subtype @var{T} allocated at machine address zero. The attribute
6096 is allowed only as the default expression of a formal parameter, or as
6097 an actual expression of a subprogram call. In either case, the
6098 subprogram must be imported.
6100 The identity of the object is represented by the address zero in the
6101 argument list, independent of the passing mechanism (explicit or
6104 This capability is needed to specify that a zero address should be
6105 passed for a record or other composite object passed by reference.
6106 There is no way of indicating this without the @code{Null_Parameter}
6110 @unnumberedsec Object_Size
6111 @cindex Size, used for objects
6114 The size of an object is not necessarily the same as the size of the type
6115 of an object. This is because by default object sizes are increased to be
6116 a multiple of the alignment of the object. For example,
6117 @code{Natural'Size} is
6118 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6119 Similarly, a record containing an integer and a character:
6121 @smallexample @c ada
6129 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6130 alignment will be 4, because of the
6131 integer field, and so the default size of record objects for this type
6132 will be 64 (8 bytes).
6136 @cindex Capturing Old values
6137 @cindex Postconditions
6139 The attribute Prefix'Old can be used within a
6140 subprogram to refer to the value of the prefix on entry. So for
6141 example if you have an argument of a record type X called Arg1,
6142 you can refer to Arg1.Field'Old which yields the value of
6143 Arg1.Field on entry. The implementation simply involves generating
6144 an object declaration which captures the value on entry. Any
6145 prefix is allowed except one of a limited type (since limited
6146 types cannot be copied to capture their values) or a local variable
6147 (since it does not exist at subprogram entry time).
6149 The following example shows the use of 'Old to implement
6150 a test of a postcondition:
6152 @smallexample @c ada
6163 package body Old_Pkg is
6164 Count : Natural := 0;
6168 ... code manipulating the value of Count
6170 pragma Assert (Count = Count'Old + 1);
6176 Note that it is allowed to apply 'Old to a constant entity, but this will
6177 result in a warning, since the old and new values will always be the same.
6179 @node Passed_By_Reference
6180 @unnumberedsec Passed_By_Reference
6181 @cindex Parameters, when passed by reference
6182 @findex Passed_By_Reference
6184 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6185 a value of type @code{Boolean} value that is @code{True} if the type is
6186 normally passed by reference and @code{False} if the type is normally
6187 passed by copy in calls. For scalar types, the result is always @code{False}
6188 and is static. For non-scalar types, the result is non-static.
6191 @unnumberedsec Pool_Address
6192 @cindex Parameters, when passed by reference
6193 @findex Pool_Address
6195 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6196 of X within its storage pool. This is the same as
6197 @code{@var{X}'Address}, except that for an unconstrained array whose
6198 bounds are allocated just before the first component,
6199 @code{@var{X}'Pool_Address} returns the address of those bounds,
6200 whereas @code{@var{X}'Address} returns the address of the first
6203 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6204 the object is allocated'', which could be a user-defined storage pool,
6205 the global heap, on the stack, or in a static memory area. For an
6206 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6207 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6210 @unnumberedsec Range_Length
6211 @findex Range_Length
6213 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6214 the number of values represented by the subtype (zero for a null
6215 range). The result is static for static subtypes. @code{Range_Length}
6216 applied to the index subtype of a one dimensional array always gives the
6217 same result as @code{Range} applied to the array itself.
6220 @unnumberedsec Result
6223 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6224 for a function. The prefix must be the name of the corresponding function. This
6225 is used to refer to the result of the function in the postcondition expression.
6226 For a further discussion of the use of this attribute and examples of its use,
6227 see the description of pragma Postcondition.
6230 @unnumberedsec Safe_Emax
6231 @cindex Ada 83 attributes
6234 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6235 the Ada 83 reference manual for an exact description of the semantics of
6239 @unnumberedsec Safe_Large
6240 @cindex Ada 83 attributes
6243 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6244 the Ada 83 reference manual for an exact description of the semantics of
6248 @unnumberedsec Small
6249 @cindex Ada 83 attributes
6252 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6254 GNAT also allows this attribute to be applied to floating-point types
6255 for compatibility with Ada 83. See
6256 the Ada 83 reference manual for an exact description of the semantics of
6257 this attribute when applied to floating-point types.
6260 @unnumberedsec Storage_Unit
6261 @findex Storage_Unit
6263 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6264 prefix) provides the same value as @code{System.Storage_Unit}.
6267 @unnumberedsec Stub_Type
6270 The GNAT implementation of remote access-to-classwide types is
6271 organized as described in AARM section E.4 (20.t): a value of an RACW type
6272 (designating a remote object) is represented as a normal access
6273 value, pointing to a "stub" object which in turn contains the
6274 necessary information to contact the designated remote object. A
6275 call on any dispatching operation of such a stub object does the
6276 remote call, if necessary, using the information in the stub object
6277 to locate the target partition, etc.
6279 For a prefix @code{T} that denotes a remote access-to-classwide type,
6280 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6282 By construction, the layout of @code{T'Stub_Type} is identical to that of
6283 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6284 unit @code{System.Partition_Interface}. Use of this attribute will create
6285 an implicit dependency on this unit.
6288 @unnumberedsec Target_Name
6291 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6292 prefix) provides a static string value that identifies the target
6293 for the current compilation. For GCC implementations, this is the
6294 standard gcc target name without the terminating slash (for
6295 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6301 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6302 provides the same value as @code{System.Tick},
6305 @unnumberedsec To_Address
6308 The @code{System'To_Address}
6309 (@code{System} is the only permissible prefix)
6310 denotes a function identical to
6311 @code{System.Storage_Elements.To_Address} except that
6312 it is a static attribute. This means that if its argument is
6313 a static expression, then the result of the attribute is a
6314 static expression. The result is that such an expression can be
6315 used in contexts (e.g.@: preelaborable packages) which require a
6316 static expression and where the function call could not be used
6317 (since the function call is always non-static, even if its
6318 argument is static).
6321 @unnumberedsec Type_Class
6324 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6325 the value of the type class for the full type of @var{type}. If
6326 @var{type} is a generic formal type, the value is the value for the
6327 corresponding actual subtype. The value of this attribute is of type
6328 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6330 @smallexample @c ada
6332 (Type_Class_Enumeration,
6334 Type_Class_Fixed_Point,
6335 Type_Class_Floating_Point,
6340 Type_Class_Address);
6344 Protected types yield the value @code{Type_Class_Task}, which thus
6345 applies to all concurrent types. This attribute is designed to
6346 be compatible with the DEC Ada 83 attribute of the same name.
6349 @unnumberedsec UET_Address
6352 The @code{UET_Address} attribute can only be used for a prefix which
6353 denotes a library package. It yields the address of the unit exception
6354 table when zero cost exception handling is used. This attribute is
6355 intended only for use within the GNAT implementation. See the unit
6356 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6357 for details on how this attribute is used in the implementation.
6359 @node Unconstrained_Array
6360 @unnumberedsec Unconstrained_Array
6361 @findex Unconstrained_Array
6363 The @code{Unconstrained_Array} attribute can be used with a prefix that
6364 denotes any type or subtype. It is a static attribute that yields
6365 @code{True} if the prefix designates an unconstrained array,
6366 and @code{False} otherwise. In a generic instance, the result is
6367 still static, and yields the result of applying this test to the
6370 @node Universal_Literal_String
6371 @unnumberedsec Universal_Literal_String
6372 @cindex Named numbers, representation of
6373 @findex Universal_Literal_String
6375 The prefix of @code{Universal_Literal_String} must be a named
6376 number. The static result is the string consisting of the characters of
6377 the number as defined in the original source. This allows the user
6378 program to access the actual text of named numbers without intermediate
6379 conversions and without the need to enclose the strings in quotes (which
6380 would preclude their use as numbers). This is used internally for the
6381 construction of values of the floating-point attributes from the file
6382 @file{ttypef.ads}, but may also be used by user programs.
6384 For example, the following program prints the first 50 digits of pi:
6386 @smallexample @c ada
6387 with Text_IO; use Text_IO;
6391 Put (Ada.Numerics.Pi'Universal_Literal_String);
6395 @node Unrestricted_Access
6396 @unnumberedsec Unrestricted_Access
6397 @cindex @code{Access}, unrestricted
6398 @findex Unrestricted_Access
6400 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6401 except that all accessibility and aliased view checks are omitted. This
6402 is a user-beware attribute. It is similar to
6403 @code{Address}, for which it is a desirable replacement where the value
6404 desired is an access type. In other words, its effect is identical to
6405 first applying the @code{Address} attribute and then doing an unchecked
6406 conversion to a desired access type. In GNAT, but not necessarily in
6407 other implementations, the use of static chains for inner level
6408 subprograms means that @code{Unrestricted_Access} applied to a
6409 subprogram yields a value that can be called as long as the subprogram
6410 is in scope (normal Ada accessibility rules restrict this usage).
6412 It is possible to use @code{Unrestricted_Access} for any type, but care
6413 must be exercised if it is used to create pointers to unconstrained
6414 objects. In this case, the resulting pointer has the same scope as the
6415 context of the attribute, and may not be returned to some enclosing
6416 scope. For instance, a function cannot use @code{Unrestricted_Access}
6417 to create a unconstrained pointer and then return that value to the
6421 @unnumberedsec VADS_Size
6422 @cindex @code{Size}, VADS compatibility
6425 The @code{'VADS_Size} attribute is intended to make it easier to port
6426 legacy code which relies on the semantics of @code{'Size} as implemented
6427 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6428 same semantic interpretation. In particular, @code{'VADS_Size} applied
6429 to a predefined or other primitive type with no Size clause yields the
6430 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6431 typical machines). In addition @code{'VADS_Size} applied to an object
6432 gives the result that would be obtained by applying the attribute to
6433 the corresponding type.
6436 @unnumberedsec Value_Size
6437 @cindex @code{Size}, setting for not-first subtype
6439 @code{@var{type}'Value_Size} is the number of bits required to represent
6440 a value of the given subtype. It is the same as @code{@var{type}'Size},
6441 but, unlike @code{Size}, may be set for non-first subtypes.
6444 @unnumberedsec Wchar_T_Size
6445 @findex Wchar_T_Size
6446 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6447 prefix) provides the size in bits of the C @code{wchar_t} type
6448 primarily for constructing the definition of this type in
6449 package @code{Interfaces.C}.
6452 @unnumberedsec Word_Size
6454 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6455 prefix) provides the value @code{System.Word_Size}.
6457 @c ------------------------
6458 @node Implementation Advice
6459 @chapter Implementation Advice
6461 The main text of the Ada Reference Manual describes the required
6462 behavior of all Ada compilers, and the GNAT compiler conforms to
6465 In addition, there are sections throughout the Ada Reference Manual headed
6466 by the phrase ``Implementation advice''. These sections are not normative,
6467 i.e., they do not specify requirements that all compilers must
6468 follow. Rather they provide advice on generally desirable behavior. You
6469 may wonder why they are not requirements. The most typical answer is
6470 that they describe behavior that seems generally desirable, but cannot
6471 be provided on all systems, or which may be undesirable on some systems.
6473 As far as practical, GNAT follows the implementation advice sections in
6474 the Ada Reference Manual. This chapter contains a table giving the
6475 reference manual section number, paragraph number and several keywords
6476 for each advice. Each entry consists of the text of the advice followed
6477 by the GNAT interpretation of this advice. Most often, this simply says
6478 ``followed'', which means that GNAT follows the advice. However, in a
6479 number of cases, GNAT deliberately deviates from this advice, in which
6480 case the text describes what GNAT does and why.
6482 @cindex Error detection
6483 @unnumberedsec 1.1.3(20): Error Detection
6486 If an implementation detects the use of an unsupported Specialized Needs
6487 Annex feature at run time, it should raise @code{Program_Error} if
6490 Not relevant. All specialized needs annex features are either supported,
6491 or diagnosed at compile time.
6494 @unnumberedsec 1.1.3(31): Child Units
6497 If an implementation wishes to provide implementation-defined
6498 extensions to the functionality of a language-defined library unit, it
6499 should normally do so by adding children to the library unit.
6503 @cindex Bounded errors
6504 @unnumberedsec 1.1.5(12): Bounded Errors
6507 If an implementation detects a bounded error or erroneous
6508 execution, it should raise @code{Program_Error}.
6510 Followed in all cases in which the implementation detects a bounded
6511 error or erroneous execution. Not all such situations are detected at
6515 @unnumberedsec 2.8(16): Pragmas
6518 Normally, implementation-defined pragmas should have no semantic effect
6519 for error-free programs; that is, if the implementation-defined pragmas
6520 are removed from a working program, the program should still be legal,
6521 and should still have the same semantics.
6523 The following implementation defined pragmas are exceptions to this
6535 @item CPP_Constructor
6539 @item Interface_Name
6541 @item Machine_Attribute
6543 @item Unimplemented_Unit
6545 @item Unchecked_Union
6550 In each of the above cases, it is essential to the purpose of the pragma
6551 that this advice not be followed. For details see the separate section
6552 on implementation defined pragmas.
6554 @unnumberedsec 2.8(17-19): Pragmas
6557 Normally, an implementation should not define pragmas that can
6558 make an illegal program legal, except as follows:
6562 A pragma used to complete a declaration, such as a pragma @code{Import};
6566 A pragma used to configure the environment by adding, removing, or
6567 replacing @code{library_items}.
6569 See response to paragraph 16 of this same section.
6571 @cindex Character Sets
6572 @cindex Alternative Character Sets
6573 @unnumberedsec 3.5.2(5): Alternative Character Sets
6576 If an implementation supports a mode with alternative interpretations
6577 for @code{Character} and @code{Wide_Character}, the set of graphic
6578 characters of @code{Character} should nevertheless remain a proper
6579 subset of the set of graphic characters of @code{Wide_Character}. Any
6580 character set ``localizations'' should be reflected in the results of
6581 the subprograms defined in the language-defined package
6582 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6583 an alternative interpretation of @code{Character}, the implementation should
6584 also support a corresponding change in what is a legal
6585 @code{identifier_letter}.
6587 Not all wide character modes follow this advice, in particular the JIS
6588 and IEC modes reflect standard usage in Japan, and in these encoding,
6589 the upper half of the Latin-1 set is not part of the wide-character
6590 subset, since the most significant bit is used for wide character
6591 encoding. However, this only applies to the external forms. Internally
6592 there is no such restriction.
6594 @cindex Integer types
6595 @unnumberedsec 3.5.4(28): Integer Types
6599 An implementation should support @code{Long_Integer} in addition to
6600 @code{Integer} if the target machine supports 32-bit (or longer)
6601 arithmetic. No other named integer subtypes are recommended for package
6602 @code{Standard}. Instead, appropriate named integer subtypes should be
6603 provided in the library package @code{Interfaces} (see B.2).
6605 @code{Long_Integer} is supported. Other standard integer types are supported
6606 so this advice is not fully followed. These types
6607 are supported for convenient interface to C, and so that all hardware
6608 types of the machine are easily available.
6609 @unnumberedsec 3.5.4(29): Integer Types
6613 An implementation for a two's complement machine should support
6614 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6615 implementation should support a non-binary modules up to @code{Integer'Last}.
6619 @cindex Enumeration values
6620 @unnumberedsec 3.5.5(8): Enumeration Values
6623 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6624 subtype, if the value of the operand does not correspond to the internal
6625 code for any enumeration literal of its type (perhaps due to an
6626 un-initialized variable), then the implementation should raise
6627 @code{Program_Error}. This is particularly important for enumeration
6628 types with noncontiguous internal codes specified by an
6629 enumeration_representation_clause.
6634 @unnumberedsec 3.5.7(17): Float Types
6637 An implementation should support @code{Long_Float} in addition to
6638 @code{Float} if the target machine supports 11 or more digits of
6639 precision. No other named floating point subtypes are recommended for
6640 package @code{Standard}. Instead, appropriate named floating point subtypes
6641 should be provided in the library package @code{Interfaces} (see B.2).
6643 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6644 former provides improved compatibility with other implementations
6645 supporting this type. The latter corresponds to the highest precision
6646 floating-point type supported by the hardware. On most machines, this
6647 will be the same as @code{Long_Float}, but on some machines, it will
6648 correspond to the IEEE extended form. The notable case is all ia32
6649 (x86) implementations, where @code{Long_Long_Float} corresponds to
6650 the 80-bit extended precision format supported in hardware on this
6651 processor. Note that the 128-bit format on SPARC is not supported,
6652 since this is a software rather than a hardware format.
6654 @cindex Multidimensional arrays
6655 @cindex Arrays, multidimensional
6656 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6659 An implementation should normally represent multidimensional arrays in
6660 row-major order, consistent with the notation used for multidimensional
6661 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6662 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6663 column-major order should be used instead (see B.5, ``Interfacing with
6668 @findex Duration'Small
6669 @unnumberedsec 9.6(30-31): Duration'Small
6672 Whenever possible in an implementation, the value of @code{Duration'Small}
6673 should be no greater than 100 microseconds.
6675 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6679 The time base for @code{delay_relative_statements} should be monotonic;
6680 it need not be the same time base as used for @code{Calendar.Clock}.
6684 @unnumberedsec 10.2.1(12): Consistent Representation
6687 In an implementation, a type declared in a pre-elaborated package should
6688 have the same representation in every elaboration of a given version of
6689 the package, whether the elaborations occur in distinct executions of
6690 the same program, or in executions of distinct programs or partitions
6691 that include the given version.
6693 Followed, except in the case of tagged types. Tagged types involve
6694 implicit pointers to a local copy of a dispatch table, and these pointers
6695 have representations which thus depend on a particular elaboration of the
6696 package. It is not easy to see how it would be possible to follow this
6697 advice without severely impacting efficiency of execution.
6699 @cindex Exception information
6700 @unnumberedsec 11.4.1(19): Exception Information
6703 @code{Exception_Message} by default and @code{Exception_Information}
6704 should produce information useful for
6705 debugging. @code{Exception_Message} should be short, about one
6706 line. @code{Exception_Information} can be long. @code{Exception_Message}
6707 should not include the
6708 @code{Exception_Name}. @code{Exception_Information} should include both
6709 the @code{Exception_Name} and the @code{Exception_Message}.
6711 Followed. For each exception that doesn't have a specified
6712 @code{Exception_Message}, the compiler generates one containing the location
6713 of the raise statement. This location has the form ``file:line'', where
6714 file is the short file name (without path information) and line is the line
6715 number in the file. Note that in the case of the Zero Cost Exception
6716 mechanism, these messages become redundant with the Exception_Information that
6717 contains a full backtrace of the calling sequence, so they are disabled.
6718 To disable explicitly the generation of the source location message, use the
6719 Pragma @code{Discard_Names}.
6721 @cindex Suppression of checks
6722 @cindex Checks, suppression of
6723 @unnumberedsec 11.5(28): Suppression of Checks
6726 The implementation should minimize the code executed for checks that
6727 have been suppressed.
6731 @cindex Representation clauses
6732 @unnumberedsec 13.1 (21-24): Representation Clauses
6735 The recommended level of support for all representation items is
6736 qualified as follows:
6740 An implementation need not support representation items containing
6741 non-static expressions, except that an implementation should support a
6742 representation item for a given entity if each non-static expression in
6743 the representation item is a name that statically denotes a constant
6744 declared before the entity.
6746 Followed. In fact, GNAT goes beyond the recommended level of support
6747 by allowing nonstatic expressions in some representation clauses even
6748 without the need to declare constants initialized with the values of
6752 @smallexample @c ada
6755 for Y'Address use X'Address;>>
6760 An implementation need not support a specification for the @code{Size}
6761 for a given composite subtype, nor the size or storage place for an
6762 object (including a component) of a given composite subtype, unless the
6763 constraints on the subtype and its composite subcomponents (if any) are
6764 all static constraints.
6766 Followed. Size Clauses are not permitted on non-static components, as
6771 An aliased component, or a component whose type is by-reference, should
6772 always be allocated at an addressable location.
6776 @cindex Packed types
6777 @unnumberedsec 13.2(6-8): Packed Types
6780 If a type is packed, then the implementation should try to minimize
6781 storage allocated to objects of the type, possibly at the expense of
6782 speed of accessing components, subject to reasonable complexity in
6783 addressing calculations.
6787 The recommended level of support pragma @code{Pack} is:
6789 For a packed record type, the components should be packed as tightly as
6790 possible subject to the Sizes of the component subtypes, and subject to
6791 any @code{record_representation_clause} that applies to the type; the
6792 implementation may, but need not, reorder components or cross aligned
6793 word boundaries to improve the packing. A component whose @code{Size} is
6794 greater than the word size may be allocated an integral number of words.
6796 Followed. Tight packing of arrays is supported for all component sizes
6797 up to 64-bits. If the array component size is 1 (that is to say, if
6798 the component is a boolean type or an enumeration type with two values)
6799 then values of the type are implicitly initialized to zero. This
6800 happens both for objects of the packed type, and for objects that have a
6801 subcomponent of the packed type.
6805 An implementation should support Address clauses for imported
6809 @cindex @code{Address} clauses
6810 @unnumberedsec 13.3(14-19): Address Clauses
6814 For an array @var{X}, @code{@var{X}'Address} should point at the first
6815 component of the array, and not at the array bounds.
6821 The recommended level of support for the @code{Address} attribute is:
6823 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6824 object that is aliased or of a by-reference type, or is an entity whose
6825 @code{Address} has been specified.
6827 Followed. A valid address will be produced even if none of those
6828 conditions have been met. If necessary, the object is forced into
6829 memory to ensure the address is valid.
6833 An implementation should support @code{Address} clauses for imported
6840 Objects (including subcomponents) that are aliased or of a by-reference
6841 type should be allocated on storage element boundaries.
6847 If the @code{Address} of an object is specified, or it is imported or exported,
6848 then the implementation should not perform optimizations based on
6849 assumptions of no aliases.
6853 @cindex @code{Alignment} clauses
6854 @unnumberedsec 13.3(29-35): Alignment Clauses
6857 The recommended level of support for the @code{Alignment} attribute for
6860 An implementation should support specified Alignments that are factors
6861 and multiples of the number of storage elements per word, subject to the
6868 An implementation need not support specified @code{Alignment}s for
6869 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6870 loaded and stored by available machine instructions.
6876 An implementation need not support specified @code{Alignment}s that are
6877 greater than the maximum @code{Alignment} the implementation ever returns by
6884 The recommended level of support for the @code{Alignment} attribute for
6887 Same as above, for subtypes, but in addition:
6893 For stand-alone library-level objects of statically constrained
6894 subtypes, the implementation should support all @code{Alignment}s
6895 supported by the target linker. For example, page alignment is likely to
6896 be supported for such objects, but not for subtypes.
6900 @cindex @code{Size} clauses
6901 @unnumberedsec 13.3(42-43): Size Clauses
6904 The recommended level of support for the @code{Size} attribute of
6907 A @code{Size} clause should be supported for an object if the specified
6908 @code{Size} is at least as large as its subtype's @code{Size}, and
6909 corresponds to a size in storage elements that is a multiple of the
6910 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6914 @unnumberedsec 13.3(50-56): Size Clauses
6917 If the @code{Size} of a subtype is specified, and allows for efficient
6918 independent addressability (see 9.10) on the target architecture, then
6919 the @code{Size} of the following objects of the subtype should equal the
6920 @code{Size} of the subtype:
6922 Aliased objects (including components).
6928 @code{Size} clause on a composite subtype should not affect the
6929 internal layout of components.
6931 Followed. But note that this can be overridden by use of the implementation
6932 pragma Implicit_Packing in the case of packed arrays.
6936 The recommended level of support for the @code{Size} attribute of subtypes is:
6940 The @code{Size} (if not specified) of a static discrete or fixed point
6941 subtype should be the number of bits needed to represent each value
6942 belonging to the subtype using an unbiased representation, leaving space
6943 for a sign bit only if the subtype contains negative values. If such a
6944 subtype is a first subtype, then an implementation should support a
6945 specified @code{Size} for it that reflects this representation.
6951 For a subtype implemented with levels of indirection, the @code{Size}
6952 should include the size of the pointers, but not the size of what they
6957 @cindex @code{Component_Size} clauses
6958 @unnumberedsec 13.3(71-73): Component Size Clauses
6961 The recommended level of support for the @code{Component_Size}
6966 An implementation need not support specified @code{Component_Sizes} that are
6967 less than the @code{Size} of the component subtype.
6973 An implementation should support specified @code{Component_Size}s that
6974 are factors and multiples of the word size. For such
6975 @code{Component_Size}s, the array should contain no gaps between
6976 components. For other @code{Component_Size}s (if supported), the array
6977 should contain no gaps between components when packing is also
6978 specified; the implementation should forbid this combination in cases
6979 where it cannot support a no-gaps representation.
6983 @cindex Enumeration representation clauses
6984 @cindex Representation clauses, enumeration
6985 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6988 The recommended level of support for enumeration representation clauses
6991 An implementation need not support enumeration representation clauses
6992 for boolean types, but should at minimum support the internal codes in
6993 the range @code{System.Min_Int.System.Max_Int}.
6997 @cindex Record representation clauses
6998 @cindex Representation clauses, records
6999 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7002 The recommended level of support for
7003 @*@code{record_representation_clauses} is:
7005 An implementation should support storage places that can be extracted
7006 with a load, mask, shift sequence of machine code, and set with a load,
7007 shift, mask, store sequence, given the available machine instructions
7014 A storage place should be supported if its size is equal to the
7015 @code{Size} of the component subtype, and it starts and ends on a
7016 boundary that obeys the @code{Alignment} of the component subtype.
7022 If the default bit ordering applies to the declaration of a given type,
7023 then for a component whose subtype's @code{Size} is less than the word
7024 size, any storage place that does not cross an aligned word boundary
7025 should be supported.
7031 An implementation may reserve a storage place for the tag field of a
7032 tagged type, and disallow other components from overlapping that place.
7034 Followed. The storage place for the tag field is the beginning of the tagged
7035 record, and its size is Address'Size. GNAT will reject an explicit component
7036 clause for the tag field.
7040 An implementation need not support a @code{component_clause} for a
7041 component of an extension part if the storage place is not after the
7042 storage places of all components of the parent type, whether or not
7043 those storage places had been specified.
7045 Followed. The above advice on record representation clauses is followed,
7046 and all mentioned features are implemented.
7048 @cindex Storage place attributes
7049 @unnumberedsec 13.5.2(5): Storage Place Attributes
7052 If a component is represented using some form of pointer (such as an
7053 offset) to the actual data of the component, and this data is contiguous
7054 with the rest of the object, then the storage place attributes should
7055 reflect the place of the actual data, not the pointer. If a component is
7056 allocated discontinuously from the rest of the object, then a warning
7057 should be generated upon reference to one of its storage place
7060 Followed. There are no such components in GNAT@.
7062 @cindex Bit ordering
7063 @unnumberedsec 13.5.3(7-8): Bit Ordering
7066 The recommended level of support for the non-default bit ordering is:
7070 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7071 should support the non-default bit ordering in addition to the default
7074 Followed. Word size does not equal storage size in this implementation.
7075 Thus non-default bit ordering is not supported.
7077 @cindex @code{Address}, as private type
7078 @unnumberedsec 13.7(37): Address as Private
7081 @code{Address} should be of a private type.
7085 @cindex Operations, on @code{Address}
7086 @cindex @code{Address}, operations of
7087 @unnumberedsec 13.7.1(16): Address Operations
7090 Operations in @code{System} and its children should reflect the target
7091 environment semantics as closely as is reasonable. For example, on most
7092 machines, it makes sense for address arithmetic to ``wrap around''.
7093 Operations that do not make sense should raise @code{Program_Error}.
7095 Followed. Address arithmetic is modular arithmetic that wraps around. No
7096 operation raises @code{Program_Error}, since all operations make sense.
7098 @cindex Unchecked conversion
7099 @unnumberedsec 13.9(14-17): Unchecked Conversion
7102 The @code{Size} of an array object should not include its bounds; hence,
7103 the bounds should not be part of the converted data.
7109 The implementation should not generate unnecessary run-time checks to
7110 ensure that the representation of @var{S} is a representation of the
7111 target type. It should take advantage of the permission to return by
7112 reference when possible. Restrictions on unchecked conversions should be
7113 avoided unless required by the target environment.
7115 Followed. There are no restrictions on unchecked conversion. A warning is
7116 generated if the source and target types do not have the same size since
7117 the semantics in this case may be target dependent.
7121 The recommended level of support for unchecked conversions is:
7125 Unchecked conversions should be supported and should be reversible in
7126 the cases where this clause defines the result. To enable meaningful use
7127 of unchecked conversion, a contiguous representation should be used for
7128 elementary subtypes, for statically constrained array subtypes whose
7129 component subtype is one of the subtypes described in this paragraph,
7130 and for record subtypes without discriminants whose component subtypes
7131 are described in this paragraph.
7135 @cindex Heap usage, implicit
7136 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7139 An implementation should document any cases in which it dynamically
7140 allocates heap storage for a purpose other than the evaluation of an
7143 Followed, the only other points at which heap storage is dynamically
7144 allocated are as follows:
7148 At initial elaboration time, to allocate dynamically sized global
7152 To allocate space for a task when a task is created.
7155 To extend the secondary stack dynamically when needed. The secondary
7156 stack is used for returning variable length results.
7161 A default (implementation-provided) storage pool for an
7162 access-to-constant type should not have overhead to support deallocation of
7169 A storage pool for an anonymous access type should be created at the
7170 point of an allocator for the type, and be reclaimed when the designated
7171 object becomes inaccessible.
7175 @cindex Unchecked deallocation
7176 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7179 For a standard storage pool, @code{Free} should actually reclaim the
7184 @cindex Stream oriented attributes
7185 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7188 If a stream element is the same size as a storage element, then the
7189 normal in-memory representation should be used by @code{Read} and
7190 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7191 should use the smallest number of stream elements needed to represent
7192 all values in the base range of the scalar type.
7195 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7196 which specifies using the size of the first subtype.
7197 However, such an implementation is based on direct binary
7198 representations and is therefore target- and endianness-dependent.
7199 To address this issue, GNAT also supplies an alternate implementation
7200 of the stream attributes @code{Read} and @code{Write},
7201 which uses the target-independent XDR standard representation
7203 @cindex XDR representation
7204 @cindex @code{Read} attribute
7205 @cindex @code{Write} attribute
7206 @cindex Stream oriented attributes
7207 The XDR implementation is provided as an alternative body of the
7208 @code{System.Stream_Attributes} package, in the file
7209 @file{s-stratt-xdr.adb} in the GNAT library.
7210 There is no @file{s-stratt-xdr.ads} file.
7211 In order to install the XDR implementation, do the following:
7213 @item Replace the default implementation of the
7214 @code{System.Stream_Attributes} package with the XDR implementation.
7215 For example on a Unix platform issue the commands:
7217 $ mv s-stratt.adb s-stratt-default.adb
7218 $ mv s-stratt-xdr.adb s-stratt.adb
7222 Rebuild the GNAT run-time library as documented in
7223 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7226 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7229 If an implementation provides additional named predefined integer types,
7230 then the names should end with @samp{Integer} as in
7231 @samp{Long_Integer}. If an implementation provides additional named
7232 predefined floating point types, then the names should end with
7233 @samp{Float} as in @samp{Long_Float}.
7237 @findex Ada.Characters.Handling
7238 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7241 If an implementation provides a localized definition of @code{Character}
7242 or @code{Wide_Character}, then the effects of the subprograms in
7243 @code{Characters.Handling} should reflect the localizations. See also
7246 Followed. GNAT provides no such localized definitions.
7248 @cindex Bounded-length strings
7249 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7252 Bounded string objects should not be implemented by implicit pointers
7253 and dynamic allocation.
7255 Followed. No implicit pointers or dynamic allocation are used.
7257 @cindex Random number generation
7258 @unnumberedsec A.5.2(46-47): Random Number Generation
7261 Any storage associated with an object of type @code{Generator} should be
7262 reclaimed on exit from the scope of the object.
7268 If the generator period is sufficiently long in relation to the number
7269 of distinct initiator values, then each possible value of
7270 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7271 random numbers that does not, in a practical sense, overlap the sequence
7272 initiated by any other value. If this is not possible, then the mapping
7273 between initiator values and generator states should be a rapidly
7274 varying function of the initiator value.
7276 Followed. The generator period is sufficiently long for the first
7277 condition here to hold true.
7279 @findex Get_Immediate
7280 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7283 The @code{Get_Immediate} procedures should be implemented with
7284 unbuffered input. For a device such as a keyboard, input should be
7285 @dfn{available} if a key has already been typed, whereas for a disk
7286 file, input should always be available except at end of file. For a file
7287 associated with a keyboard-like device, any line-editing features of the
7288 underlying operating system should be disabled during the execution of
7289 @code{Get_Immediate}.
7291 Followed on all targets except VxWorks. For VxWorks, there is no way to
7292 provide this functionality that does not result in the input buffer being
7293 flushed before the @code{Get_Immediate} call. A special unit
7294 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7298 @unnumberedsec B.1(39-41): Pragma @code{Export}
7301 If an implementation supports pragma @code{Export} to a given language,
7302 then it should also allow the main subprogram to be written in that
7303 language. It should support some mechanism for invoking the elaboration
7304 of the Ada library units included in the system, and for invoking the
7305 finalization of the environment task. On typical systems, the
7306 recommended mechanism is to provide two subprograms whose link names are
7307 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7308 elaboration code for library units. @code{adafinal} should contain the
7309 finalization code. These subprograms should have no effect the second
7310 and subsequent time they are called.
7316 Automatic elaboration of pre-elaborated packages should be
7317 provided when pragma @code{Export} is supported.
7319 Followed when the main program is in Ada. If the main program is in a
7320 foreign language, then
7321 @code{adainit} must be called to elaborate pre-elaborated
7326 For each supported convention @var{L} other than @code{Intrinsic}, an
7327 implementation should support @code{Import} and @code{Export} pragmas
7328 for objects of @var{L}-compatible types and for subprograms, and pragma
7329 @code{Convention} for @var{L}-eligible types and for subprograms,
7330 presuming the other language has corresponding features. Pragma
7331 @code{Convention} need not be supported for scalar types.
7335 @cindex Package @code{Interfaces}
7337 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7340 For each implementation-defined convention identifier, there should be a
7341 child package of package Interfaces with the corresponding name. This
7342 package should contain any declarations that would be useful for
7343 interfacing to the language (implementation) represented by the
7344 convention. Any declarations useful for interfacing to any language on
7345 the given hardware architecture should be provided directly in
7348 Followed. An additional package not defined
7349 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7350 for interfacing to C++.
7354 An implementation supporting an interface to C, COBOL, or Fortran should
7355 provide the corresponding package or packages described in the following
7358 Followed. GNAT provides all the packages described in this section.
7360 @cindex C, interfacing with
7361 @unnumberedsec B.3(63-71): Interfacing with C
7364 An implementation should support the following interface correspondences
7371 An Ada procedure corresponds to a void-returning C function.
7377 An Ada function corresponds to a non-void C function.
7383 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7390 An Ada @code{in} parameter of an access-to-object type with designated
7391 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7392 where @var{t} is the C type corresponding to the Ada type @var{T}.
7398 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7399 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7400 argument to a C function, where @var{t} is the C type corresponding to
7401 the Ada type @var{T}. In the case of an elementary @code{out} or
7402 @code{in out} parameter, a pointer to a temporary copy is used to
7403 preserve by-copy semantics.
7409 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7410 @code{@var{t}*} argument to a C function, where @var{t} is the C
7411 structure corresponding to the Ada type @var{T}.
7413 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7414 pragma, or Convention, or by explicitly specifying the mechanism for a given
7415 call using an extended import or export pragma.
7419 An Ada parameter of an array type with component type @var{T}, of any
7420 mode, is passed as a @code{@var{t}*} argument to a C function, where
7421 @var{t} is the C type corresponding to the Ada type @var{T}.
7427 An Ada parameter of an access-to-subprogram type is passed as a pointer
7428 to a C function whose prototype corresponds to the designated
7429 subprogram's specification.
7433 @cindex COBOL, interfacing with
7434 @unnumberedsec B.4(95-98): Interfacing with COBOL
7437 An Ada implementation should support the following interface
7438 correspondences between Ada and COBOL@.
7444 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7445 the COBOL type corresponding to @var{T}.
7451 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7452 the corresponding COBOL type.
7458 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7459 COBOL type corresponding to the Ada parameter type; for scalars, a local
7460 copy is used if necessary to ensure by-copy semantics.
7464 @cindex Fortran, interfacing with
7465 @unnumberedsec B.5(22-26): Interfacing with Fortran
7468 An Ada implementation should support the following interface
7469 correspondences between Ada and Fortran:
7475 An Ada procedure corresponds to a Fortran subroutine.
7481 An Ada function corresponds to a Fortran function.
7487 An Ada parameter of an elementary, array, or record type @var{T} is
7488 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7489 the Fortran type corresponding to the Ada type @var{T}, and where the
7490 INTENT attribute of the corresponding dummy argument matches the Ada
7491 formal parameter mode; the Fortran implementation's parameter passing
7492 conventions are used. For elementary types, a local copy is used if
7493 necessary to ensure by-copy semantics.
7499 An Ada parameter of an access-to-subprogram type is passed as a
7500 reference to a Fortran procedure whose interface corresponds to the
7501 designated subprogram's specification.
7505 @cindex Machine operations
7506 @unnumberedsec C.1(3-5): Access to Machine Operations
7509 The machine code or intrinsic support should allow access to all
7510 operations normally available to assembly language programmers for the
7511 target environment, including privileged instructions, if any.
7517 The interfacing pragmas (see Annex B) should support interface to
7518 assembler; the default assembler should be associated with the
7519 convention identifier @code{Assembler}.
7525 If an entity is exported to assembly language, then the implementation
7526 should allocate it at an addressable location, and should ensure that it
7527 is retained by the linking process, even if not otherwise referenced
7528 from the Ada code. The implementation should assume that any call to a
7529 machine code or assembler subprogram is allowed to read or update every
7530 object that is specified as exported.
7534 @unnumberedsec C.1(10-16): Access to Machine Operations
7537 The implementation should ensure that little or no overhead is
7538 associated with calling intrinsic and machine-code subprograms.
7540 Followed for both intrinsics and machine-code subprograms.
7544 It is recommended that intrinsic subprograms be provided for convenient
7545 access to any machine operations that provide special capabilities or
7546 efficiency and that are not otherwise available through the language
7549 Followed. A full set of machine operation intrinsic subprograms is provided.
7553 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7554 swap, decrement and test, enqueue/dequeue.
7556 Followed on any target supporting such operations.
7560 Standard numeric functions---e.g.@:, sin, log.
7562 Followed on any target supporting such operations.
7566 String manipulation operations---e.g.@:, translate and test.
7568 Followed on any target supporting such operations.
7572 Vector operations---e.g.@:, compare vector against thresholds.
7574 Followed on any target supporting such operations.
7578 Direct operations on I/O ports.
7580 Followed on any target supporting such operations.
7582 @cindex Interrupt support
7583 @unnumberedsec C.3(28): Interrupt Support
7586 If the @code{Ceiling_Locking} policy is not in effect, the
7587 implementation should provide means for the application to specify which
7588 interrupts are to be blocked during protected actions, if the underlying
7589 system allows for a finer-grain control of interrupt blocking.
7591 Followed. The underlying system does not allow for finer-grain control
7592 of interrupt blocking.
7594 @cindex Protected procedure handlers
7595 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7598 Whenever possible, the implementation should allow interrupt handlers to
7599 be called directly by the hardware.
7603 This is never possible under IRIX, so this is followed by default.
7605 Followed on any target where the underlying operating system permits
7610 Whenever practical, violations of any
7611 implementation-defined restrictions should be detected before run time.
7613 Followed. Compile time warnings are given when possible.
7615 @cindex Package @code{Interrupts}
7617 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7621 If implementation-defined forms of interrupt handler procedures are
7622 supported, such as protected procedures with parameters, then for each
7623 such form of a handler, a type analogous to @code{Parameterless_Handler}
7624 should be specified in a child package of @code{Interrupts}, with the
7625 same operations as in the predefined package Interrupts.
7629 @cindex Pre-elaboration requirements
7630 @unnumberedsec C.4(14): Pre-elaboration Requirements
7633 It is recommended that pre-elaborated packages be implemented in such a
7634 way that there should be little or no code executed at run time for the
7635 elaboration of entities not already covered by the Implementation
7638 Followed. Executable code is generated in some cases, e.g.@: loops
7639 to initialize large arrays.
7641 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7645 If the pragma applies to an entity, then the implementation should
7646 reduce the amount of storage used for storing names associated with that
7651 @cindex Package @code{Task_Attributes}
7652 @findex Task_Attributes
7653 @unnumberedsec C.7.2(30): The Package Task_Attributes
7656 Some implementations are targeted to domains in which memory use at run
7657 time must be completely deterministic. For such implementations, it is
7658 recommended that the storage for task attributes will be pre-allocated
7659 statically and not from the heap. This can be accomplished by either
7660 placing restrictions on the number and the size of the task's
7661 attributes, or by using the pre-allocated storage for the first @var{N}
7662 attribute objects, and the heap for the others. In the latter case,
7663 @var{N} should be documented.
7665 Not followed. This implementation is not targeted to such a domain.
7667 @cindex Locking Policies
7668 @unnumberedsec D.3(17): Locking Policies
7672 The implementation should use names that end with @samp{_Locking} for
7673 locking policies defined by the implementation.
7675 Followed. A single implementation-defined locking policy is defined,
7676 whose name (@code{Inheritance_Locking}) follows this suggestion.
7678 @cindex Entry queuing policies
7679 @unnumberedsec D.4(16): Entry Queuing Policies
7682 Names that end with @samp{_Queuing} should be used
7683 for all implementation-defined queuing policies.
7685 Followed. No such implementation-defined queuing policies exist.
7687 @cindex Preemptive abort
7688 @unnumberedsec D.6(9-10): Preemptive Abort
7691 Even though the @code{abort_statement} is included in the list of
7692 potentially blocking operations (see 9.5.1), it is recommended that this
7693 statement be implemented in a way that never requires the task executing
7694 the @code{abort_statement} to block.
7700 On a multi-processor, the delay associated with aborting a task on
7701 another processor should be bounded; the implementation should use
7702 periodic polling, if necessary, to achieve this.
7706 @cindex Tasking restrictions
7707 @unnumberedsec D.7(21): Tasking Restrictions
7710 When feasible, the implementation should take advantage of the specified
7711 restrictions to produce a more efficient implementation.
7713 GNAT currently takes advantage of these restrictions by providing an optimized
7714 run time when the Ravenscar profile and the GNAT restricted run time set
7715 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7716 pragma @code{Profile (Restricted)} for more details.
7718 @cindex Time, monotonic
7719 @unnumberedsec D.8(47-49): Monotonic Time
7722 When appropriate, implementations should provide configuration
7723 mechanisms to change the value of @code{Tick}.
7725 Such configuration mechanisms are not appropriate to this implementation
7726 and are thus not supported.
7730 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7731 be implemented as transformations of the same time base.
7737 It is recommended that the @dfn{best} time base which exists in
7738 the underlying system be available to the application through
7739 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7743 @cindex Partition communication subsystem
7745 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7748 Whenever possible, the PCS on the called partition should allow for
7749 multiple tasks to call the RPC-receiver with different messages and
7750 should allow them to block until the corresponding subprogram body
7753 Followed by GLADE, a separately supplied PCS that can be used with
7758 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7759 should raise @code{Storage_Error} if it runs out of space trying to
7760 write the @code{Item} into the stream.
7762 Followed by GLADE, a separately supplied PCS that can be used with
7765 @cindex COBOL support
7766 @unnumberedsec F(7): COBOL Support
7769 If COBOL (respectively, C) is widely supported in the target
7770 environment, implementations supporting the Information Systems Annex
7771 should provide the child package @code{Interfaces.COBOL} (respectively,
7772 @code{Interfaces.C}) specified in Annex B and should support a
7773 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7774 pragmas (see Annex B), thus allowing Ada programs to interface with
7775 programs written in that language.
7779 @cindex Decimal radix support
7780 @unnumberedsec F.1(2): Decimal Radix Support
7783 Packed decimal should be used as the internal representation for objects
7784 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7786 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
7790 @unnumberedsec G: Numerics
7793 If Fortran (respectively, C) is widely supported in the target
7794 environment, implementations supporting the Numerics Annex
7795 should provide the child package @code{Interfaces.Fortran} (respectively,
7796 @code{Interfaces.C}) specified in Annex B and should support a
7797 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7798 pragmas (see Annex B), thus allowing Ada programs to interface with
7799 programs written in that language.
7803 @cindex Complex types
7804 @unnumberedsec G.1.1(56-58): Complex Types
7807 Because the usual mathematical meaning of multiplication of a complex
7808 operand and a real operand is that of the scaling of both components of
7809 the former by the latter, an implementation should not perform this
7810 operation by first promoting the real operand to complex type and then
7811 performing a full complex multiplication. In systems that, in the
7812 future, support an Ada binding to IEC 559:1989, the latter technique
7813 will not generate the required result when one of the components of the
7814 complex operand is infinite. (Explicit multiplication of the infinite
7815 component by the zero component obtained during promotion yields a NaN
7816 that propagates into the final result.) Analogous advice applies in the
7817 case of multiplication of a complex operand and a pure-imaginary
7818 operand, and in the case of division of a complex operand by a real or
7819 pure-imaginary operand.
7825 Similarly, because the usual mathematical meaning of addition of a
7826 complex operand and a real operand is that the imaginary operand remains
7827 unchanged, an implementation should not perform this operation by first
7828 promoting the real operand to complex type and then performing a full
7829 complex addition. In implementations in which the @code{Signed_Zeros}
7830 attribute of the component type is @code{True} (and which therefore
7831 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7832 predefined arithmetic operations), the latter technique will not
7833 generate the required result when the imaginary component of the complex
7834 operand is a negatively signed zero. (Explicit addition of the negative
7835 zero to the zero obtained during promotion yields a positive zero.)
7836 Analogous advice applies in the case of addition of a complex operand
7837 and a pure-imaginary operand, and in the case of subtraction of a
7838 complex operand and a real or pure-imaginary operand.
7844 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7845 attempt to provide a rational treatment of the signs of zero results and
7846 result components. As one example, the result of the @code{Argument}
7847 function should have the sign of the imaginary component of the
7848 parameter @code{X} when the point represented by that parameter lies on
7849 the positive real axis; as another, the sign of the imaginary component
7850 of the @code{Compose_From_Polar} function should be the same as
7851 (respectively, the opposite of) that of the @code{Argument} parameter when that
7852 parameter has a value of zero and the @code{Modulus} parameter has a
7853 nonnegative (respectively, negative) value.
7857 @cindex Complex elementary functions
7858 @unnumberedsec G.1.2(49): Complex Elementary Functions
7861 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7862 @code{True} should attempt to provide a rational treatment of the signs
7863 of zero results and result components. For example, many of the complex
7864 elementary functions have components that are odd functions of one of
7865 the parameter components; in these cases, the result component should
7866 have the sign of the parameter component at the origin. Other complex
7867 elementary functions have zero components whose sign is opposite that of
7868 a parameter component at the origin, or is always positive or always
7873 @cindex Accuracy requirements
7874 @unnumberedsec G.2.4(19): Accuracy Requirements
7877 The versions of the forward trigonometric functions without a
7878 @code{Cycle} parameter should not be implemented by calling the
7879 corresponding version with a @code{Cycle} parameter of
7880 @code{2.0*Numerics.Pi}, since this will not provide the required
7881 accuracy in some portions of the domain. For the same reason, the
7882 version of @code{Log} without a @code{Base} parameter should not be
7883 implemented by calling the corresponding version with a @code{Base}
7884 parameter of @code{Numerics.e}.
7888 @cindex Complex arithmetic accuracy
7889 @cindex Accuracy, complex arithmetic
7890 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7894 The version of the @code{Compose_From_Polar} function without a
7895 @code{Cycle} parameter should not be implemented by calling the
7896 corresponding version with a @code{Cycle} parameter of
7897 @code{2.0*Numerics.Pi}, since this will not provide the required
7898 accuracy in some portions of the domain.
7902 @c -----------------------------------------
7903 @node Implementation Defined Characteristics
7904 @chapter Implementation Defined Characteristics
7907 In addition to the implementation dependent pragmas and attributes, and
7908 the implementation advice, there are a number of other Ada features
7909 that are potentially implementation dependent. These are mentioned
7910 throughout the Ada Reference Manual, and are summarized in Annex M@.
7912 A requirement for conforming Ada compilers is that they provide
7913 documentation describing how the implementation deals with each of these
7914 issues. In this chapter, you will find each point in Annex M listed
7915 followed by a description in italic font of how GNAT
7919 implementation on IRIX 5.3 operating system or greater
7921 handles the implementation dependence.
7923 You can use this chapter as a guide to minimizing implementation
7924 dependent features in your programs if portability to other compilers
7925 and other operating systems is an important consideration. The numbers
7926 in each section below correspond to the paragraph number in the Ada
7932 @strong{2}. Whether or not each recommendation given in Implementation
7933 Advice is followed. See 1.1.2(37).
7936 @xref{Implementation Advice}.
7941 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
7944 The complexity of programs that can be processed is limited only by the
7945 total amount of available virtual memory, and disk space for the
7946 generated object files.
7951 @strong{4}. Variations from the standard that are impractical to avoid
7952 given the implementation's execution environment. See 1.1.3(6).
7955 There are no variations from the standard.
7960 @strong{5}. Which @code{code_statement}s cause external
7961 interactions. See 1.1.3(10).
7964 Any @code{code_statement} can potentially cause external interactions.
7969 @strong{6}. The coded representation for the text of an Ada
7970 program. See 2.1(4).
7973 See separate section on source representation.
7978 @strong{7}. The control functions allowed in comments. See 2.1(14).
7981 See separate section on source representation.
7986 @strong{8}. The representation for an end of line. See 2.2(2).
7989 See separate section on source representation.
7994 @strong{9}. Maximum supported line length and lexical element
7995 length. See 2.2(15).
7998 The maximum line length is 255 characters and the maximum length of a
7999 lexical element is also 255 characters.
8004 @strong{10}. Implementation defined pragmas. See 2.8(14).
8008 @xref{Implementation Defined Pragmas}.
8013 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
8016 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8017 parameter, checks that the optimization flag is set, and aborts if it is
8023 @strong{12}. The sequence of characters of the value returned by
8024 @code{@var{S}'Image} when some of the graphic characters of
8025 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8029 The sequence of characters is as defined by the wide character encoding
8030 method used for the source. See section on source representation for
8036 @strong{13}. The predefined integer types declared in
8037 @code{Standard}. See 3.5.4(25).
8041 @item Short_Short_Integer
8044 (Short) 16 bit signed
8048 64 bit signed (Alpha OpenVMS only)
8049 32 bit signed (all other targets)
8050 @item Long_Long_Integer
8057 @strong{14}. Any nonstandard integer types and the operators defined
8058 for them. See 3.5.4(26).
8061 There are no nonstandard integer types.
8066 @strong{15}. Any nonstandard real types and the operators defined for
8070 There are no nonstandard real types.
8075 @strong{16}. What combinations of requested decimal precision and range
8076 are supported for floating point types. See 3.5.7(7).
8079 The precision and range is as defined by the IEEE standard.
8084 @strong{17}. The predefined floating point types declared in
8085 @code{Standard}. See 3.5.7(16).
8092 (Short) 32 bit IEEE short
8095 @item Long_Long_Float
8096 64 bit IEEE long (80 bit IEEE long on x86 processors)
8102 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8105 @code{Fine_Delta} is 2**(@minus{}63)
8110 @strong{19}. What combinations of small, range, and digits are
8111 supported for fixed point types. See 3.5.9(10).
8114 Any combinations are permitted that do not result in a small less than
8115 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8116 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8117 is 64 bits (true of all architectures except ia32), then the output from
8118 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8119 is because floating-point conversions are used to convert fixed point.
8124 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8125 within an unnamed @code{block_statement}. See 3.9(10).
8128 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8129 decimal integer are allocated.
8134 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8137 @xref{Implementation Defined Attributes}.
8142 @strong{22}. Any implementation-defined time types. See 9.6(6).
8145 There are no implementation-defined time types.
8150 @strong{23}. The time base associated with relative delays.
8153 See 9.6(20). The time base used is that provided by the C library
8154 function @code{gettimeofday}.
8159 @strong{24}. The time base of the type @code{Calendar.Time}. See
8163 The time base used is that provided by the C library function
8164 @code{gettimeofday}.
8169 @strong{25}. The time zone used for package @code{Calendar}
8170 operations. See 9.6(24).
8173 The time zone used by package @code{Calendar} is the current system time zone
8174 setting for local time, as accessed by the C library function
8180 @strong{26}. Any limit on @code{delay_until_statements} of
8181 @code{select_statements}. See 9.6(29).
8184 There are no such limits.
8189 @strong{27}. Whether or not two non-overlapping parts of a composite
8190 object are independently addressable, in the case where packing, record
8191 layout, or @code{Component_Size} is specified for the object. See
8195 Separate components are independently addressable if they do not share
8196 overlapping storage units.
8201 @strong{28}. The representation for a compilation. See 10.1(2).
8204 A compilation is represented by a sequence of files presented to the
8205 compiler in a single invocation of the @command{gcc} command.
8210 @strong{29}. Any restrictions on compilations that contain multiple
8211 compilation_units. See 10.1(4).
8214 No single file can contain more than one compilation unit, but any
8215 sequence of files can be presented to the compiler as a single
8221 @strong{30}. The mechanisms for creating an environment and for adding
8222 and replacing compilation units. See 10.1.4(3).
8225 See separate section on compilation model.
8230 @strong{31}. The manner of explicitly assigning library units to a
8231 partition. See 10.2(2).
8234 If a unit contains an Ada main program, then the Ada units for the partition
8235 are determined by recursive application of the rules in the Ada Reference
8236 Manual section 10.2(2-6). In other words, the Ada units will be those that
8237 are needed by the main program, and then this definition of need is applied
8238 recursively to those units, and the partition contains the transitive
8239 closure determined by this relationship. In short, all the necessary units
8240 are included, with no need to explicitly specify the list. If additional
8241 units are required, e.g.@: by foreign language units, then all units must be
8242 mentioned in the context clause of one of the needed Ada units.
8244 If the partition contains no main program, or if the main program is in
8245 a language other than Ada, then GNAT
8246 provides the binder options @option{-z} and @option{-n} respectively, and in
8247 this case a list of units can be explicitly supplied to the binder for
8248 inclusion in the partition (all units needed by these units will also
8249 be included automatically). For full details on the use of these
8250 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8251 @value{EDITION} User's Guide}.
8256 @strong{32}. The implementation-defined means, if any, of specifying
8257 which compilation units are needed by a given compilation unit. See
8261 The units needed by a given compilation unit are as defined in
8262 the Ada Reference Manual section 10.2(2-6). There are no
8263 implementation-defined pragmas or other implementation-defined
8264 means for specifying needed units.
8269 @strong{33}. The manner of designating the main subprogram of a
8270 partition. See 10.2(7).
8273 The main program is designated by providing the name of the
8274 corresponding @file{ALI} file as the input parameter to the binder.
8279 @strong{34}. The order of elaboration of @code{library_items}. See
8283 The first constraint on ordering is that it meets the requirements of
8284 Chapter 10 of the Ada Reference Manual. This still leaves some
8285 implementation dependent choices, which are resolved by first
8286 elaborating bodies as early as possible (i.e., in preference to specs
8287 where there is a choice), and second by evaluating the immediate with
8288 clauses of a unit to determine the probably best choice, and
8289 third by elaborating in alphabetical order of unit names
8290 where a choice still remains.
8295 @strong{35}. Parameter passing and function return for the main
8296 subprogram. See 10.2(21).
8299 The main program has no parameters. It may be a procedure, or a function
8300 returning an integer type. In the latter case, the returned integer
8301 value is the return code of the program (overriding any value that
8302 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8307 @strong{36}. The mechanisms for building and running partitions. See
8311 GNAT itself supports programs with only a single partition. The GNATDIST
8312 tool provided with the GLADE package (which also includes an implementation
8313 of the PCS) provides a completely flexible method for building and running
8314 programs consisting of multiple partitions. See the separate GLADE manual
8320 @strong{37}. The details of program execution, including program
8321 termination. See 10.2(25).
8324 See separate section on compilation model.
8329 @strong{38}. The semantics of any non-active partitions supported by the
8330 implementation. See 10.2(28).
8333 Passive partitions are supported on targets where shared memory is
8334 provided by the operating system. See the GLADE reference manual for
8340 @strong{39}. The information returned by @code{Exception_Message}. See
8344 Exception message returns the null string unless a specific message has
8345 been passed by the program.
8350 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8351 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8354 Blocks have implementation defined names of the form @code{B@var{nnn}}
8355 where @var{nnn} is an integer.
8360 @strong{41}. The information returned by
8361 @code{Exception_Information}. See 11.4.1(13).
8364 @code{Exception_Information} returns a string in the following format:
8367 @emph{Exception_Name:} nnnnn
8368 @emph{Message:} mmmmm
8370 @emph{Call stack traceback locations:}
8371 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8379 @code{nnnn} is the fully qualified name of the exception in all upper
8380 case letters. This line is always present.
8383 @code{mmmm} is the message (this line present only if message is non-null)
8386 @code{ppp} is the Process Id value as a decimal integer (this line is
8387 present only if the Process Id is nonzero). Currently we are
8388 not making use of this field.
8391 The Call stack traceback locations line and the following values
8392 are present only if at least one traceback location was recorded.
8393 The values are given in C style format, with lower case letters
8394 for a-f, and only as many digits present as are necessary.
8398 The line terminator sequence at the end of each line, including
8399 the last line is a single @code{LF} character (@code{16#0A#}).
8404 @strong{42}. Implementation-defined check names. See 11.5(27).
8407 The implementation defined check name Alignment_Check controls checking of
8408 address clause values for proper alignment (that is, the address supplied
8409 must be consistent with the alignment of the type).
8411 In addition, a user program can add implementation-defined check names
8412 by means of the pragma Check_Name.
8417 @strong{43}. The interpretation of each aspect of representation. See
8421 See separate section on data representations.
8426 @strong{44}. Any restrictions placed upon representation items. See
8430 See separate section on data representations.
8435 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8439 Size for an indefinite subtype is the maximum possible size, except that
8440 for the case of a subprogram parameter, the size of the parameter object
8446 @strong{46}. The default external representation for a type tag. See
8450 The default external representation for a type tag is the fully expanded
8451 name of the type in upper case letters.
8456 @strong{47}. What determines whether a compilation unit is the same in
8457 two different partitions. See 13.3(76).
8460 A compilation unit is the same in two different partitions if and only
8461 if it derives from the same source file.
8466 @strong{48}. Implementation-defined components. See 13.5.1(15).
8469 The only implementation defined component is the tag for a tagged type,
8470 which contains a pointer to the dispatching table.
8475 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8476 ordering. See 13.5.3(5).
8479 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8480 implementation, so no non-default bit ordering is supported. The default
8481 bit ordering corresponds to the natural endianness of the target architecture.
8486 @strong{50}. The contents of the visible part of package @code{System}
8487 and its language-defined children. See 13.7(2).
8490 See the definition of these packages in files @file{system.ads} and
8491 @file{s-stoele.ads}.
8496 @strong{51}. The contents of the visible part of package
8497 @code{System.Machine_Code}, and the meaning of
8498 @code{code_statements}. See 13.8(7).
8501 See the definition and documentation in file @file{s-maccod.ads}.
8506 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8509 Unchecked conversion between types of the same size
8510 results in an uninterpreted transmission of the bits from one type
8511 to the other. If the types are of unequal sizes, then in the case of
8512 discrete types, a shorter source is first zero or sign extended as
8513 necessary, and a shorter target is simply truncated on the left.
8514 For all non-discrete types, the source is first copied if necessary
8515 to ensure that the alignment requirements of the target are met, then
8516 a pointer is constructed to the source value, and the result is obtained
8517 by dereferencing this pointer after converting it to be a pointer to the
8518 target type. Unchecked conversions where the target subtype is an
8519 unconstrained array are not permitted. If the target alignment is
8520 greater than the source alignment, then a copy of the result is
8521 made with appropriate alignment
8526 @strong{53}. The manner of choosing a storage pool for an access type
8527 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8530 There are 3 different standard pools used by the compiler when
8531 @code{Storage_Pool} is not specified depending whether the type is local
8532 to a subprogram or defined at the library level and whether
8533 @code{Storage_Size}is specified or not. See documentation in the runtime
8534 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8535 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8536 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8542 @strong{54}. Whether or not the implementation provides user-accessible
8543 names for the standard pool type(s). See 13.11(17).
8547 See documentation in the sources of the run time mentioned in paragraph
8548 @strong{53} . All these pools are accessible by means of @code{with}'ing
8554 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8557 @code{Storage_Size} is measured in storage units, and refers to the
8558 total space available for an access type collection, or to the primary
8559 stack space for a task.
8564 @strong{56}. Implementation-defined aspects of storage pools. See
8568 See documentation in the sources of the run time mentioned in paragraph
8569 @strong{53} for details on GNAT-defined aspects of storage pools.
8574 @strong{57}. The set of restrictions allowed in a pragma
8575 @code{Restrictions}. See 13.12(7).
8578 All RM defined Restriction identifiers are implemented. The following
8579 additional restriction identifiers are provided. There are two separate
8580 lists of implementation dependent restriction identifiers. The first
8581 set requires consistency throughout a partition (in other words, if the
8582 restriction identifier is used for any compilation unit in the partition,
8583 then all compilation units in the partition must obey the restriction.
8587 @item Simple_Barriers
8588 @findex Simple_Barriers
8589 This restriction ensures at compile time that barriers in entry declarations
8590 for protected types are restricted to either static boolean expressions or
8591 references to simple boolean variables defined in the private part of the
8592 protected type. No other form of entry barriers is permitted. This is one
8593 of the restrictions of the Ravenscar profile for limited tasking (see also
8594 pragma @code{Profile (Ravenscar)}).
8596 @item Max_Entry_Queue_Length => Expr
8597 @findex Max_Entry_Queue_Length
8598 This restriction is a declaration that any protected entry compiled in
8599 the scope of the restriction has at most the specified number of
8600 tasks waiting on the entry
8601 at any one time, and so no queue is required. This restriction is not
8602 checked at compile time. A program execution is erroneous if an attempt
8603 is made to queue more than the specified number of tasks on such an entry.
8607 This restriction ensures at compile time that there is no implicit or
8608 explicit dependence on the package @code{Ada.Calendar}.
8610 @item No_Default_Initialization
8611 @findex No_Default_Initialization
8613 This restriction prohibits any instance of default initialization of variables.
8614 The binder implements a consistency rule which prevents any unit compiled
8615 without the restriction from with'ing a unit with the restriction (this allows
8616 the generation of initialization procedures to be skipped, since you can be
8617 sure that no call is ever generated to an initialization procedure in a unit
8618 with the restriction active). If used in conjunction with Initialize_Scalars or
8619 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8620 without a specific initializer (including the case of OUT scalar parameters).
8622 @item No_Direct_Boolean_Operators
8623 @findex No_Direct_Boolean_Operators
8624 This restriction ensures that no logical (and/or/xor) are used on
8625 operands of type Boolean (or any type derived
8626 from Boolean). This is intended for use in safety critical programs
8627 where the certification protocol requires the use of short-circuit
8628 (and then, or else) forms for all composite boolean operations.
8630 @item No_Dispatching_Calls
8631 @findex No_Dispatching_Calls
8632 This restriction ensures at compile time that the code generated by the
8633 compiler involves no dispatching calls. The use of this restriction allows the
8634 safe use of record extensions, classwide membership tests and other classwide
8635 features not involving implicit dispatching. This restriction ensures that
8636 the code contains no indirect calls through a dispatching mechanism. Note that
8637 this includes internally-generated calls created by the compiler, for example
8638 in the implementation of class-wide objects assignments. The
8639 membership test is allowed in the presence of this restriction, because its
8640 implementation requires no dispatching.
8641 This restriction is comparable to the official Ada restriction
8642 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8643 all classwide constructs that do not imply dispatching.
8644 The following example indicates constructs that violate this restriction.
8648 type T is tagged record
8651 procedure P (X : T);
8653 type DT is new T with record
8654 More_Data : Natural;
8656 procedure Q (X : DT);
8660 procedure Example is
8661 procedure Test (O : T'Class) is
8662 N : Natural := O'Size;-- Error: Dispatching call
8663 C : T'Class := O; -- Error: implicit Dispatching Call
8665 if O in DT'Class then -- OK : Membership test
8666 Q (DT (O)); -- OK : Type conversion plus direct call
8668 P (O); -- Error: Dispatching call
8674 P (Obj); -- OK : Direct call
8675 P (T (Obj)); -- OK : Type conversion plus direct call
8676 P (T'Class (Obj)); -- Error: Dispatching call
8678 Test (Obj); -- OK : Type conversion
8680 if Obj in T'Class then -- OK : Membership test
8686 @item No_Dynamic_Attachment
8687 @findex No_Dynamic_Attachment
8688 This restriction ensures that there is no call to any of the operations
8689 defined in package Ada.Interrupts.
8691 @item No_Enumeration_Maps
8692 @findex No_Enumeration_Maps
8693 This restriction ensures at compile time that no operations requiring
8694 enumeration maps are used (that is Image and Value attributes applied
8695 to enumeration types).
8697 @item No_Entry_Calls_In_Elaboration_Code
8698 @findex No_Entry_Calls_In_Elaboration_Code
8699 This restriction ensures at compile time that no task or protected entry
8700 calls are made during elaboration code. As a result of the use of this
8701 restriction, the compiler can assume that no code past an accept statement
8702 in a task can be executed at elaboration time.
8704 @item No_Exception_Handlers
8705 @findex No_Exception_Handlers
8706 This restriction ensures at compile time that there are no explicit
8707 exception handlers. It also indicates that no exception propagation will
8708 be provided. In this mode, exceptions may be raised but will result in
8709 an immediate call to the last chance handler, a routine that the user
8710 must define with the following profile:
8712 @smallexample @c ada
8713 procedure Last_Chance_Handler
8714 (Source_Location : System.Address; Line : Integer);
8715 pragma Export (C, Last_Chance_Handler,
8716 "__gnat_last_chance_handler");
8719 The parameter is a C null-terminated string representing a message to be
8720 associated with the exception (typically the source location of the raise
8721 statement generated by the compiler). The Line parameter when nonzero
8722 represents the line number in the source program where the raise occurs.
8724 @item No_Exception_Propagation
8725 @findex No_Exception_Propagation
8726 This restriction guarantees that exceptions are never propagated to an outer
8727 subprogram scope). The only case in which an exception may be raised is when
8728 the handler is statically in the same subprogram, so that the effect of a raise
8729 is essentially like a goto statement. Any other raise statement (implicit or
8730 explicit) will be considered unhandled. Exception handlers are allowed, but may
8731 not contain an exception occurrence identifier (exception choice). In addition
8732 use of the package GNAT.Current_Exception is not permitted, and reraise
8733 statements (raise with no operand) are not permitted.
8735 @item No_Exception_Registration
8736 @findex No_Exception_Registration
8737 This restriction ensures at compile time that no stream operations for
8738 types Exception_Id or Exception_Occurrence are used. This also makes it
8739 impossible to pass exceptions to or from a partition with this restriction
8740 in a distributed environment. If this exception is active, then the generated
8741 code is simplified by omitting the otherwise-required global registration
8742 of exceptions when they are declared.
8744 @item No_Implicit_Conditionals
8745 @findex No_Implicit_Conditionals
8746 This restriction ensures that the generated code does not contain any
8747 implicit conditionals, either by modifying the generated code where possible,
8748 or by rejecting any construct that would otherwise generate an implicit
8749 conditional. Note that this check does not include run time constraint
8750 checks, which on some targets may generate implicit conditionals as
8751 well. To control the latter, constraint checks can be suppressed in the
8752 normal manner. Constructs generating implicit conditionals include comparisons
8753 of composite objects and the Max/Min attributes.
8755 @item No_Implicit_Dynamic_Code
8756 @findex No_Implicit_Dynamic_Code
8758 This restriction prevents the compiler from building ``trampolines''.
8759 This is a structure that is built on the stack and contains dynamic
8760 code to be executed at run time. On some targets, a trampoline is
8761 built for the following features: @code{Access},
8762 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8763 nested task bodies; primitive operations of nested tagged types.
8764 Trampolines do not work on machines that prevent execution of stack
8765 data. For example, on windows systems, enabling DEP (data execution
8766 protection) will cause trampolines to raise an exception.
8767 Trampolines are also quite slow at run time.
8769 On many targets, trampolines have been largely eliminated. Look at the
8770 version of system.ads for your target --- if it has
8771 Always_Compatible_Rep equal to False, then trampolines are largely
8772 eliminated. In particular, a trampoline is built for the following
8773 features: @code{Address} of a nested subprogram;
8774 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8775 but only if pragma Favor_Top_Level applies, or the access type has a
8776 foreign-language convention; primitive operations of nested tagged
8779 @item No_Implicit_Loops
8780 @findex No_Implicit_Loops
8781 This restriction ensures that the generated code does not contain any
8782 implicit @code{for} loops, either by modifying
8783 the generated code where possible,
8784 or by rejecting any construct that would otherwise generate an implicit
8785 @code{for} loop. If this restriction is active, it is possible to build
8786 large array aggregates with all static components without generating an
8787 intermediate temporary, and without generating a loop to initialize individual
8788 components. Otherwise, a loop is created for arrays larger than about 5000
8791 @item No_Initialize_Scalars
8792 @findex No_Initialize_Scalars
8793 This restriction ensures that no unit in the partition is compiled with
8794 pragma Initialize_Scalars. This allows the generation of more efficient
8795 code, and in particular eliminates dummy null initialization routines that
8796 are otherwise generated for some record and array types.
8798 @item No_Local_Protected_Objects
8799 @findex No_Local_Protected_Objects
8800 This restriction ensures at compile time that protected objects are
8801 only declared at the library level.
8803 @item No_Protected_Type_Allocators
8804 @findex No_Protected_Type_Allocators
8805 This restriction ensures at compile time that there are no allocator
8806 expressions that attempt to allocate protected objects.
8808 @item No_Secondary_Stack
8809 @findex No_Secondary_Stack
8810 This restriction ensures at compile time that the generated code does not
8811 contain any reference to the secondary stack. The secondary stack is used
8812 to implement functions returning unconstrained objects (arrays or records)
8815 @item No_Select_Statements
8816 @findex No_Select_Statements
8817 This restriction ensures at compile time no select statements of any kind
8818 are permitted, that is the keyword @code{select} may not appear.
8819 This is one of the restrictions of the Ravenscar
8820 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8822 @item No_Standard_Storage_Pools
8823 @findex No_Standard_Storage_Pools
8824 This restriction ensures at compile time that no access types
8825 use the standard default storage pool. Any access type declared must
8826 have an explicit Storage_Pool attribute defined specifying a
8827 user-defined storage pool.
8831 This restriction ensures at compile/bind time that there are no
8832 stream objects created and no use of stream attributes.
8833 This restriction does not forbid dependences on the package
8834 @code{Ada.Streams}. So it is permissible to with
8835 @code{Ada.Streams} (or another package that does so itself)
8836 as long as no actual stream objects are created and no
8837 stream attributes are used.
8839 Note that the use of restriction allows optimization of tagged types,
8840 since they do not need to worry about dispatching stream operations.
8841 To take maximum advantage of this space-saving optimization, any
8842 unit declaring a tagged type should be compiled with the restriction,
8843 though this is not required.
8845 @item No_Task_Attributes_Package
8846 @findex No_Task_Attributes_Package
8847 This restriction ensures at compile time that there are no implicit or
8848 explicit dependencies on the package @code{Ada.Task_Attributes}.
8850 @item No_Task_Termination
8851 @findex No_Task_Termination
8852 This restriction ensures at compile time that no terminate alternatives
8853 appear in any task body.
8857 This restriction prevents the declaration of tasks or task types throughout
8858 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
8859 except that violations are caught at compile time and cause an error message
8860 to be output either by the compiler or binder.
8862 @item Static_Priorities
8863 @findex Static_Priorities
8864 This restriction ensures at compile time that all priority expressions
8865 are static, and that there are no dependencies on the package
8866 @code{Ada.Dynamic_Priorities}.
8868 @item Static_Storage_Size
8869 @findex Static_Storage_Size
8870 This restriction ensures at compile time that any expression appearing
8871 in a Storage_Size pragma or attribute definition clause is static.
8876 The second set of implementation dependent restriction identifiers
8877 does not require partition-wide consistency.
8878 The restriction may be enforced for a single
8879 compilation unit without any effect on any of the
8880 other compilation units in the partition.
8884 @item No_Elaboration_Code
8885 @findex No_Elaboration_Code
8886 This restriction ensures at compile time that no elaboration code is
8887 generated. Note that this is not the same condition as is enforced
8888 by pragma @code{Preelaborate}. There are cases in which pragma
8889 @code{Preelaborate} still permits code to be generated (e.g.@: code
8890 to initialize a large array to all zeroes), and there are cases of units
8891 which do not meet the requirements for pragma @code{Preelaborate},
8892 but for which no elaboration code is generated. Generally, it is
8893 the case that preelaborable units will meet the restrictions, with
8894 the exception of large aggregates initialized with an others_clause,
8895 and exception declarations (which generate calls to a run-time
8896 registry procedure). This restriction is enforced on
8897 a unit by unit basis, it need not be obeyed consistently
8898 throughout a partition.
8900 In the case of aggregates with others, if the aggregate has a dynamic
8901 size, there is no way to eliminate the elaboration code (such dynamic
8902 bounds would be incompatible with @code{Preelaborate} in any case). If
8903 the bounds are static, then use of this restriction actually modifies
8904 the code choice of the compiler to avoid generating a loop, and instead
8905 generate the aggregate statically if possible, no matter how many times
8906 the data for the others clause must be repeatedly generated.
8908 It is not possible to precisely document
8909 the constructs which are compatible with this restriction, since,
8910 unlike most other restrictions, this is not a restriction on the
8911 source code, but a restriction on the generated object code. For
8912 example, if the source contains a declaration:
8915 Val : constant Integer := X;
8919 where X is not a static constant, it may be possible, depending
8920 on complex optimization circuitry, for the compiler to figure
8921 out the value of X at compile time, in which case this initialization
8922 can be done by the loader, and requires no initialization code. It
8923 is not possible to document the precise conditions under which the
8924 optimizer can figure this out.
8926 Note that this the implementation of this restriction requires full
8927 code generation. If it is used in conjunction with "semantics only"
8928 checking, then some cases of violations may be missed.
8930 @item No_Entry_Queue
8931 @findex No_Entry_Queue
8932 This restriction is a declaration that any protected entry compiled in
8933 the scope of the restriction has at most one task waiting on the entry
8934 at any one time, and so no queue is required. This restriction is not
8935 checked at compile time. A program execution is erroneous if an attempt
8936 is made to queue a second task on such an entry.
8938 @item No_Implementation_Attributes
8939 @findex No_Implementation_Attributes
8940 This restriction checks at compile time that no GNAT-defined attributes
8941 are present. With this restriction, the only attributes that can be used
8942 are those defined in the Ada Reference Manual.
8944 @item No_Implementation_Pragmas
8945 @findex No_Implementation_Pragmas
8946 This restriction checks at compile time that no GNAT-defined pragmas
8947 are present. With this restriction, the only pragmas that can be used
8948 are those defined in the Ada Reference Manual.
8950 @item No_Implementation_Restrictions
8951 @findex No_Implementation_Restrictions
8952 This restriction checks at compile time that no GNAT-defined restriction
8953 identifiers (other than @code{No_Implementation_Restrictions} itself)
8954 are present. With this restriction, the only other restriction identifiers
8955 that can be used are those defined in the Ada Reference Manual.
8957 @item No_Wide_Characters
8958 @findex No_Wide_Characters
8959 This restriction ensures at compile time that no uses of the types
8960 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8962 appear, and that no wide or wide wide string or character literals
8963 appear in the program (that is literals representing characters not in
8964 type @code{Character}.
8971 @strong{58}. The consequences of violating limitations on
8972 @code{Restrictions} pragmas. See 13.12(9).
8975 Restrictions that can be checked at compile time result in illegalities
8976 if violated. Currently there are no other consequences of violating
8982 @strong{59}. The representation used by the @code{Read} and
8983 @code{Write} attributes of elementary types in terms of stream
8984 elements. See 13.13.2(9).
8987 The representation is the in-memory representation of the base type of
8988 the type, using the number of bits corresponding to the
8989 @code{@var{type}'Size} value, and the natural ordering of the machine.
8994 @strong{60}. The names and characteristics of the numeric subtypes
8995 declared in the visible part of package @code{Standard}. See A.1(3).
8998 See items describing the integer and floating-point types supported.
9003 @strong{61}. The accuracy actually achieved by the elementary
9004 functions. See A.5.1(1).
9007 The elementary functions correspond to the functions available in the C
9008 library. Only fast math mode is implemented.
9013 @strong{62}. The sign of a zero result from some of the operators or
9014 functions in @code{Numerics.Generic_Elementary_Functions}, when
9015 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9018 The sign of zeroes follows the requirements of the IEEE 754 standard on
9024 @strong{63}. The value of
9025 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9028 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9033 @strong{64}. The value of
9034 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9037 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9042 @strong{65}. The algorithms for random number generation. See
9046 The algorithm is the Mersenne Twister, as documented in the source file
9047 @file{s-rannum.adb}. This version of the algorithm has a period of
9053 @strong{66}. The string representation of a random number generator's
9054 state. See A.5.2(38).
9057 The value returned by the Image function is the concatenation of
9058 the fixed-width decimal representations of the 624 32-bit integers
9059 of the state vector.
9064 @strong{67}. The minimum time interval between calls to the
9065 time-dependent Reset procedure that are guaranteed to initiate different
9066 random number sequences. See A.5.2(45).
9069 The minimum period between reset calls to guarantee distinct series of
9070 random numbers is one microsecond.
9075 @strong{68}. The values of the @code{Model_Mantissa},
9076 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9077 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9078 Annex is not supported. See A.5.3(72).
9081 See the source file @file{ttypef.ads} for the values of all numeric
9087 @strong{69}. Any implementation-defined characteristics of the
9088 input-output packages. See A.7(14).
9091 There are no special implementation defined characteristics for these
9097 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9101 All type representations are contiguous, and the @code{Buffer_Size} is
9102 the value of @code{@var{type}'Size} rounded up to the next storage unit
9108 @strong{71}. External files for standard input, standard output, and
9109 standard error See A.10(5).
9112 These files are mapped onto the files provided by the C streams
9113 libraries. See source file @file{i-cstrea.ads} for further details.
9118 @strong{72}. The accuracy of the value produced by @code{Put}. See
9122 If more digits are requested in the output than are represented by the
9123 precision of the value, zeroes are output in the corresponding least
9124 significant digit positions.
9129 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9130 @code{Command_Name}. See A.15(1).
9133 These are mapped onto the @code{argv} and @code{argc} parameters of the
9134 main program in the natural manner.
9139 @strong{74}. Implementation-defined convention names. See B.1(11).
9142 The following convention names are supported
9150 Synonym for Assembler
9152 Synonym for Assembler
9155 @item C_Pass_By_Copy
9156 Allowed only for record types, like C, but also notes that record
9157 is to be passed by copy rather than reference.
9160 @item C_Plus_Plus (or CPP)
9163 Treated the same as C
9165 Treated the same as C
9169 For support of pragma @code{Import} with convention Intrinsic, see
9170 separate section on Intrinsic Subprograms.
9172 Stdcall (used for Windows implementations only). This convention correspond
9173 to the WINAPI (previously called Pascal convention) C/C++ convention under
9174 Windows. A function with this convention cleans the stack before exit.
9180 Stubbed is a special convention used to indicate that the body of the
9181 subprogram will be entirely ignored. Any call to the subprogram
9182 is converted into a raise of the @code{Program_Error} exception. If a
9183 pragma @code{Import} specifies convention @code{stubbed} then no body need
9184 be present at all. This convention is useful during development for the
9185 inclusion of subprograms whose body has not yet been written.
9189 In addition, all otherwise unrecognized convention names are also
9190 treated as being synonymous with convention C@. In all implementations
9191 except for VMS, use of such other names results in a warning. In VMS
9192 implementations, these names are accepted silently.
9197 @strong{75}. The meaning of link names. See B.1(36).
9200 Link names are the actual names used by the linker.
9205 @strong{76}. The manner of choosing link names when neither the link
9206 name nor the address of an imported or exported entity is specified. See
9210 The default linker name is that which would be assigned by the relevant
9211 external language, interpreting the Ada name as being in all lower case
9217 @strong{77}. The effect of pragma @code{Linker_Options}. See B.1(37).
9220 The string passed to @code{Linker_Options} is presented uninterpreted as
9221 an argument to the link command, unless it contains ASCII.NUL characters.
9222 NUL characters if they appear act as argument separators, so for example
9224 @smallexample @c ada
9225 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9229 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9230 linker. The order of linker options is preserved for a given unit. The final
9231 list of options passed to the linker is in reverse order of the elaboration
9232 order. For example, linker options for a body always appear before the options
9233 from the corresponding package spec.
9238 @strong{78}. The contents of the visible part of package
9239 @code{Interfaces} and its language-defined descendants. See B.2(1).
9242 See files with prefix @file{i-} in the distributed library.
9247 @strong{79}. Implementation-defined children of package
9248 @code{Interfaces}. The contents of the visible part of package
9249 @code{Interfaces}. See B.2(11).
9252 See files with prefix @file{i-} in the distributed library.
9257 @strong{80}. The types @code{Floating}, @code{Long_Floating},
9258 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9259 @code{COBOL_Character}; and the initialization of the variables
9260 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9261 @code{Interfaces.COBOL}. See B.4(50).
9268 (Floating) Long_Float
9273 @item Decimal_Element
9275 @item COBOL_Character
9280 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9285 @strong{81}. Support for access to machine instructions. See C.1(1).
9288 See documentation in file @file{s-maccod.ads} in the distributed library.
9293 @strong{82}. Implementation-defined aspects of access to machine
9294 operations. See C.1(9).
9297 See documentation in file @file{s-maccod.ads} in the distributed library.
9302 @strong{83}. Implementation-defined aspects of interrupts. See C.3(2).
9305 Interrupts are mapped to signals or conditions as appropriate. See
9307 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9308 on the interrupts supported on a particular target.
9313 @strong{84}. Implementation-defined aspects of pre-elaboration. See
9317 GNAT does not permit a partition to be restarted without reloading,
9318 except under control of the debugger.
9323 @strong{85}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9326 Pragma @code{Discard_Names} causes names of enumeration literals to
9327 be suppressed. In the presence of this pragma, the Image attribute
9328 provides the image of the Pos of the literal, and Value accepts
9334 @strong{86}. The result of the @code{Task_Identification.Image}
9335 attribute. See C.7.1(7).
9338 The result of this attribute is a string that identifies
9339 the object or component that denotes a given task. If a variable @code{Var}
9340 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9342 is the hexadecimal representation of the virtual address of the corresponding
9343 task control block. If the variable is an array of tasks, the image of each
9344 task will have the form of an indexed component indicating the position of a
9345 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9346 component of a record, the image of the task will have the form of a selected
9347 component. These rules are fully recursive, so that the image of a task that
9348 is a subcomponent of a composite object corresponds to the expression that
9349 designates this task.
9351 If a task is created by an allocator, its image depends on the context. If the
9352 allocator is part of an object declaration, the rules described above are used
9353 to construct its image, and this image is not affected by subsequent
9354 assignments. If the allocator appears within an expression, the image
9355 includes only the name of the task type.
9357 If the configuration pragma Discard_Names is present, or if the restriction
9358 No_Implicit_Heap_Allocation is in effect, the image reduces to
9359 the numeric suffix, that is to say the hexadecimal representation of the
9360 virtual address of the control block of the task.
9364 @strong{87}. The value of @code{Current_Task} when in a protected entry
9365 or interrupt handler. See C.7.1(17).
9368 Protected entries or interrupt handlers can be executed by any
9369 convenient thread, so the value of @code{Current_Task} is undefined.
9374 @strong{88}. The effect of calling @code{Current_Task} from an entry
9375 body or interrupt handler. See C.7.1(19).
9378 The effect of calling @code{Current_Task} from an entry body or
9379 interrupt handler is to return the identification of the task currently
9385 @strong{89}. Implementation-defined aspects of
9386 @code{Task_Attributes}. See C.7.2(19).
9389 There are no implementation-defined aspects of @code{Task_Attributes}.
9394 @strong{90}. Values of all @code{Metrics}. See D(2).
9397 The metrics information for GNAT depends on the performance of the
9398 underlying operating system. The sources of the run-time for tasking
9399 implementation, together with the output from @option{-gnatG} can be
9400 used to determine the exact sequence of operating systems calls made
9401 to implement various tasking constructs. Together with appropriate
9402 information on the performance of the underlying operating system,
9403 on the exact target in use, this information can be used to determine
9404 the required metrics.
9409 @strong{91}. The declarations of @code{Any_Priority} and
9410 @code{Priority}. See D.1(11).
9413 See declarations in file @file{system.ads}.
9418 @strong{92}. Implementation-defined execution resources. See D.1(15).
9421 There are no implementation-defined execution resources.
9426 @strong{93}. Whether, on a multiprocessor, a task that is waiting for
9427 access to a protected object keeps its processor busy. See D.2.1(3).
9430 On a multi-processor, a task that is waiting for access to a protected
9431 object does not keep its processor busy.
9436 @strong{94}. The affect of implementation defined execution resources
9437 on task dispatching. See D.2.1(9).
9442 Tasks map to IRIX threads, and the dispatching policy is as defined by
9443 the IRIX implementation of threads.
9445 Tasks map to threads in the threads package used by GNAT@. Where possible
9446 and appropriate, these threads correspond to native threads of the
9447 underlying operating system.
9452 @strong{95}. Implementation-defined @code{policy_identifiers} allowed
9453 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9456 There are no implementation-defined policy-identifiers allowed in this
9462 @strong{96}. Implementation-defined aspects of priority inversion. See
9466 Execution of a task cannot be preempted by the implementation processing
9467 of delay expirations for lower priority tasks.
9472 @strong{97}. Implementation defined task dispatching. See D.2.2(18).
9477 Tasks map to IRIX threads, and the dispatching policy is as defined by
9478 the IRIX implementation of threads.
9480 The policy is the same as that of the underlying threads implementation.
9485 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9486 in a pragma @code{Locking_Policy}. See D.3(4).
9489 The only implementation defined policy permitted in GNAT is
9490 @code{Inheritance_Locking}. On targets that support this policy, locking
9491 is implemented by inheritance, i.e.@: the task owning the lock operates
9492 at a priority equal to the highest priority of any task currently
9493 requesting the lock.
9498 @strong{99}. Default ceiling priorities. See D.3(10).
9501 The ceiling priority of protected objects of the type
9502 @code{System.Interrupt_Priority'Last} as described in the Ada
9503 Reference Manual D.3(10),
9508 @strong{100}. The ceiling of any protected object used internally by
9509 the implementation. See D.3(16).
9512 The ceiling priority of internal protected objects is
9513 @code{System.Priority'Last}.
9518 @strong{101}. Implementation-defined queuing policies. See D.4(1).
9521 There are no implementation-defined queuing policies.
9526 @strong{102}. On a multiprocessor, any conditions that cause the
9527 completion of an aborted construct to be delayed later than what is
9528 specified for a single processor. See D.6(3).
9531 The semantics for abort on a multi-processor is the same as on a single
9532 processor, there are no further delays.
9537 @strong{103}. Any operations that implicitly require heap storage
9538 allocation. See D.7(8).
9541 The only operation that implicitly requires heap storage allocation is
9547 @strong{104}. Implementation-defined aspects of pragma
9548 @code{Restrictions}. See D.7(20).
9551 There are no such implementation-defined aspects.
9556 @strong{105}. Implementation-defined aspects of package
9557 @code{Real_Time}. See D.8(17).
9560 There are no implementation defined aspects of package @code{Real_Time}.
9565 @strong{106}. Implementation-defined aspects of
9566 @code{delay_statements}. See D.9(8).
9569 Any difference greater than one microsecond will cause the task to be
9570 delayed (see D.9(7)).
9575 @strong{107}. The upper bound on the duration of interrupt blocking
9576 caused by the implementation. See D.12(5).
9579 The upper bound is determined by the underlying operating system. In
9580 no cases is it more than 10 milliseconds.
9585 @strong{108}. The means for creating and executing distributed
9589 The GLADE package provides a utility GNATDIST for creating and executing
9590 distributed programs. See the GLADE reference manual for further details.
9595 @strong{109}. Any events that can result in a partition becoming
9596 inaccessible. See E.1(7).
9599 See the GLADE reference manual for full details on such events.
9604 @strong{110}. The scheduling policies, treatment of priorities, and
9605 management of shared resources between partitions in certain cases. See
9609 See the GLADE reference manual for full details on these aspects of
9610 multi-partition execution.
9615 @strong{111}. Events that cause the version of a compilation unit to
9619 Editing the source file of a compilation unit, or the source files of
9620 any units on which it is dependent in a significant way cause the version
9621 to change. No other actions cause the version number to change. All changes
9622 are significant except those which affect only layout, capitalization or
9628 @strong{112}. Whether the execution of the remote subprogram is
9629 immediately aborted as a result of cancellation. See E.4(13).
9632 See the GLADE reference manual for details on the effect of abort in
9633 a distributed application.
9638 @strong{113}. Implementation-defined aspects of the PCS@. See E.5(25).
9641 See the GLADE reference manual for a full description of all implementation
9642 defined aspects of the PCS@.
9647 @strong{114}. Implementation-defined interfaces in the PCS@. See
9651 See the GLADE reference manual for a full description of all
9652 implementation defined interfaces.
9657 @strong{115}. The values of named numbers in the package
9658 @code{Decimal}. See F.2(7).
9670 @item Max_Decimal_Digits
9677 @strong{116}. The value of @code{Max_Picture_Length} in the package
9678 @code{Text_IO.Editing}. See F.3.3(16).
9686 @strong{117}. The value of @code{Max_Picture_Length} in the package
9687 @code{Wide_Text_IO.Editing}. See F.3.4(5).
9695 @strong{118}. The accuracy actually achieved by the complex elementary
9696 functions and by other complex arithmetic operations. See G.1(1).
9699 Standard library functions are used for the complex arithmetic
9700 operations. Only fast math mode is currently supported.
9705 @strong{119}. The sign of a zero result (or a component thereof) from
9706 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9707 @code{Real'Signed_Zeros} is True. See G.1.1(53).
9710 The signs of zero values are as recommended by the relevant
9711 implementation advice.
9716 @strong{120}. The sign of a zero result (or a component thereof) from
9717 any operator or function in
9718 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9719 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
9722 The signs of zero values are as recommended by the relevant
9723 implementation advice.
9728 @strong{121}. Whether the strict mode or the relaxed mode is the
9729 default. See G.2(2).
9732 The strict mode is the default. There is no separate relaxed mode. GNAT
9733 provides a highly efficient implementation of strict mode.
9738 @strong{122}. The result interval in certain cases of fixed-to-float
9739 conversion. See G.2.1(10).
9742 For cases where the result interval is implementation dependent, the
9743 accuracy is that provided by performing all operations in 64-bit IEEE
9744 floating-point format.
9749 @strong{123}. The result of a floating point arithmetic operation in
9750 overflow situations, when the @code{Machine_Overflows} attribute of the
9751 result type is @code{False}. See G.2.1(13).
9754 Infinite and NaN values are produced as dictated by the IEEE
9755 floating-point standard.
9757 Note that on machines that are not fully compliant with the IEEE
9758 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9759 must be used for achieving IEEE confirming behavior (although at the cost
9760 of a significant performance penalty), so infinite and NaN values are
9766 @strong{124}. The result interval for division (or exponentiation by a
9767 negative exponent), when the floating point hardware implements division
9768 as multiplication by a reciprocal. See G.2.1(16).
9771 Not relevant, division is IEEE exact.
9776 @strong{125}. The definition of close result set, which determines the
9777 accuracy of certain fixed point multiplications and divisions. See
9781 Operations in the close result set are performed using IEEE long format
9782 floating-point arithmetic. The input operands are converted to
9783 floating-point, the operation is done in floating-point, and the result
9784 is converted to the target type.
9789 @strong{126}. Conditions on a @code{universal_real} operand of a fixed
9790 point multiplication or division for which the result shall be in the
9791 perfect result set. See G.2.3(22).
9794 The result is only defined to be in the perfect result set if the result
9795 can be computed by a single scaling operation involving a scale factor
9796 representable in 64-bits.
9801 @strong{127}. The result of a fixed point arithmetic operation in
9802 overflow situations, when the @code{Machine_Overflows} attribute of the
9803 result type is @code{False}. See G.2.3(27).
9806 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9812 @strong{128}. The result of an elementary function reference in
9813 overflow situations, when the @code{Machine_Overflows} attribute of the
9814 result type is @code{False}. See G.2.4(4).
9817 IEEE infinite and Nan values are produced as appropriate.
9822 @strong{129}. The value of the angle threshold, within which certain
9823 elementary functions, complex arithmetic operations, and complex
9824 elementary functions yield results conforming to a maximum relative
9825 error bound. See G.2.4(10).
9828 Information on this subject is not yet available.
9833 @strong{130}. The accuracy of certain elementary functions for
9834 parameters beyond the angle threshold. See G.2.4(10).
9837 Information on this subject is not yet available.
9842 @strong{131}. The result of a complex arithmetic operation or complex
9843 elementary function reference in overflow situations, when the
9844 @code{Machine_Overflows} attribute of the corresponding real type is
9845 @code{False}. See G.2.6(5).
9848 IEEE infinite and Nan values are produced as appropriate.
9853 @strong{132}. The accuracy of certain complex arithmetic operations and
9854 certain complex elementary functions for parameters (or components
9855 thereof) beyond the angle threshold. See G.2.6(8).
9858 Information on those subjects is not yet available.
9863 @strong{133}. Information regarding bounded errors and erroneous
9864 execution. See H.2(1).
9867 Information on this subject is not yet available.
9872 @strong{134}. Implementation-defined aspects of pragma
9873 @code{Inspection_Point}. See H.3.2(8).
9876 Pragma @code{Inspection_Point} ensures that the variable is live and can
9877 be examined by the debugger at the inspection point.
9882 @strong{135}. Implementation-defined aspects of pragma
9883 @code{Restrictions}. See H.4(25).
9886 There are no implementation-defined aspects of pragma @code{Restrictions}. The
9887 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9888 generated code. Checks must suppressed by use of pragma @code{Suppress}.
9893 @strong{136}. Any restrictions on pragma @code{Restrictions}. See
9897 There are no restrictions on pragma @code{Restrictions}.
9899 @node Intrinsic Subprograms
9900 @chapter Intrinsic Subprograms
9901 @cindex Intrinsic Subprograms
9904 * Intrinsic Operators::
9905 * Enclosing_Entity::
9906 * Exception_Information::
9907 * Exception_Message::
9915 * Shift_Right_Arithmetic::
9920 GNAT allows a user application program to write the declaration:
9922 @smallexample @c ada
9923 pragma Import (Intrinsic, name);
9927 providing that the name corresponds to one of the implemented intrinsic
9928 subprograms in GNAT, and that the parameter profile of the referenced
9929 subprogram meets the requirements. This chapter describes the set of
9930 implemented intrinsic subprograms, and the requirements on parameter profiles.
9931 Note that no body is supplied; as with other uses of pragma Import, the
9932 body is supplied elsewhere (in this case by the compiler itself). Note
9933 that any use of this feature is potentially non-portable, since the
9934 Ada standard does not require Ada compilers to implement this feature.
9936 @node Intrinsic Operators
9937 @section Intrinsic Operators
9938 @cindex Intrinsic operator
9941 All the predefined numeric operators in package Standard
9942 in @code{pragma Import (Intrinsic,..)}
9943 declarations. In the binary operator case, the operands must have the same
9944 size. The operand or operands must also be appropriate for
9945 the operator. For example, for addition, the operands must
9946 both be floating-point or both be fixed-point, and the
9947 right operand for @code{"**"} must have a root type of
9948 @code{Standard.Integer'Base}.
9949 You can use an intrinsic operator declaration as in the following example:
9951 @smallexample @c ada
9952 type Int1 is new Integer;
9953 type Int2 is new Integer;
9955 function "+" (X1 : Int1; X2 : Int2) return Int1;
9956 function "+" (X1 : Int1; X2 : Int2) return Int2;
9957 pragma Import (Intrinsic, "+");
9961 This declaration would permit ``mixed mode'' arithmetic on items
9962 of the differing types @code{Int1} and @code{Int2}.
9963 It is also possible to specify such operators for private types, if the
9964 full views are appropriate arithmetic types.
9966 @node Enclosing_Entity
9967 @section Enclosing_Entity
9968 @cindex Enclosing_Entity
9970 This intrinsic subprogram is used in the implementation of the
9971 library routine @code{GNAT.Source_Info}. The only useful use of the
9972 intrinsic import in this case is the one in this unit, so an
9973 application program should simply call the function
9974 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9975 the current subprogram, package, task, entry, or protected subprogram.
9977 @node Exception_Information
9978 @section Exception_Information
9979 @cindex Exception_Information'
9981 This intrinsic subprogram is used in the implementation of the
9982 library routine @code{GNAT.Current_Exception}. The only useful
9983 use of the intrinsic import in this case is the one in this unit,
9984 so an application program should simply call the function
9985 @code{GNAT.Current_Exception.Exception_Information} to obtain
9986 the exception information associated with the current exception.
9988 @node Exception_Message
9989 @section Exception_Message
9990 @cindex Exception_Message
9992 This intrinsic subprogram is used in the implementation of the
9993 library routine @code{GNAT.Current_Exception}. The only useful
9994 use of the intrinsic import in this case is the one in this unit,
9995 so an application program should simply call the function
9996 @code{GNAT.Current_Exception.Exception_Message} to obtain
9997 the message associated with the current exception.
9999 @node Exception_Name
10000 @section Exception_Name
10001 @cindex Exception_Name
10003 This intrinsic subprogram is used in the implementation of the
10004 library routine @code{GNAT.Current_Exception}. The only useful
10005 use of the intrinsic import in this case is the one in this unit,
10006 so an application program should simply call the function
10007 @code{GNAT.Current_Exception.Exception_Name} to obtain
10008 the name of the current exception.
10014 This intrinsic subprogram is used in the implementation of the
10015 library routine @code{GNAT.Source_Info}. The only useful use of the
10016 intrinsic import in this case is the one in this unit, so an
10017 application program should simply call the function
10018 @code{GNAT.Source_Info.File} to obtain the name of the current
10025 This intrinsic subprogram is used in the implementation of the
10026 library routine @code{GNAT.Source_Info}. The only useful use of the
10027 intrinsic import in this case is the one in this unit, so an
10028 application program should simply call the function
10029 @code{GNAT.Source_Info.Line} to obtain the number of the current
10033 @section Rotate_Left
10034 @cindex Rotate_Left
10036 In standard Ada, the @code{Rotate_Left} function is available only
10037 for the predefined modular types in package @code{Interfaces}. However, in
10038 GNAT it is possible to define a Rotate_Left function for a user
10039 defined modular type or any signed integer type as in this example:
10041 @smallexample @c ada
10042 function Shift_Left
10043 (Value : My_Modular_Type;
10045 return My_Modular_Type;
10049 The requirements are that the profile be exactly as in the example
10050 above. The only modifications allowed are in the formal parameter
10051 names, and in the type of @code{Value} and the return type, which
10052 must be the same, and must be either a signed integer type, or
10053 a modular integer type with a binary modulus, and the size must
10054 be 8. 16, 32 or 64 bits.
10057 @section Rotate_Right
10058 @cindex Rotate_Right
10060 A @code{Rotate_Right} function can be defined for any user defined
10061 binary modular integer type, or signed integer type, as described
10062 above for @code{Rotate_Left}.
10065 @section Shift_Left
10068 A @code{Shift_Left} function can be defined for any user defined
10069 binary modular integer type, or signed integer type, as described
10070 above for @code{Rotate_Left}.
10073 @section Shift_Right
10074 @cindex Shift_Right
10076 A @code{Shift_Right} function can be defined for any user defined
10077 binary modular integer type, or signed integer type, as described
10078 above for @code{Rotate_Left}.
10080 @node Shift_Right_Arithmetic
10081 @section Shift_Right_Arithmetic
10082 @cindex Shift_Right_Arithmetic
10084 A @code{Shift_Right_Arithmetic} function can be defined for any user
10085 defined binary modular integer type, or signed integer type, as described
10086 above for @code{Rotate_Left}.
10088 @node Source_Location
10089 @section Source_Location
10090 @cindex Source_Location
10092 This intrinsic subprogram is used in the implementation of the
10093 library routine @code{GNAT.Source_Info}. The only useful use of the
10094 intrinsic import in this case is the one in this unit, so an
10095 application program should simply call the function
10096 @code{GNAT.Source_Info.Source_Location} to obtain the current
10097 source file location.
10099 @node Representation Clauses and Pragmas
10100 @chapter Representation Clauses and Pragmas
10101 @cindex Representation Clauses
10104 * Alignment Clauses::
10106 * Storage_Size Clauses::
10107 * Size of Variant Record Objects::
10108 * Biased Representation ::
10109 * Value_Size and Object_Size Clauses::
10110 * Component_Size Clauses::
10111 * Bit_Order Clauses::
10112 * Effect of Bit_Order on Byte Ordering::
10113 * Pragma Pack for Arrays::
10114 * Pragma Pack for Records::
10115 * Record Representation Clauses::
10116 * Enumeration Clauses::
10117 * Address Clauses::
10118 * Effect of Convention on Representation::
10119 * Determining the Representations chosen by GNAT::
10123 @cindex Representation Clause
10124 @cindex Representation Pragma
10125 @cindex Pragma, representation
10126 This section describes the representation clauses accepted by GNAT, and
10127 their effect on the representation of corresponding data objects.
10129 GNAT fully implements Annex C (Systems Programming). This means that all
10130 the implementation advice sections in chapter 13 are fully implemented.
10131 However, these sections only require a minimal level of support for
10132 representation clauses. GNAT provides much more extensive capabilities,
10133 and this section describes the additional capabilities provided.
10135 @node Alignment Clauses
10136 @section Alignment Clauses
10137 @cindex Alignment Clause
10140 GNAT requires that all alignment clauses specify a power of 2, and all
10141 default alignments are always a power of 2. The default alignment
10142 values are as follows:
10145 @item @emph{Primitive Types}.
10146 For primitive types, the alignment is the minimum of the actual size of
10147 objects of the type divided by @code{Storage_Unit},
10148 and the maximum alignment supported by the target.
10149 (This maximum alignment is given by the GNAT-specific attribute
10150 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10151 @cindex @code{Maximum_Alignment} attribute
10152 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10153 default alignment will be 8 on any target that supports alignments
10154 this large, but on some targets, the maximum alignment may be smaller
10155 than 8, in which case objects of type @code{Long_Float} will be maximally
10158 @item @emph{Arrays}.
10159 For arrays, the alignment is equal to the alignment of the component type
10160 for the normal case where no packing or component size is given. If the
10161 array is packed, and the packing is effective (see separate section on
10162 packed arrays), then the alignment will be one for long packed arrays,
10163 or arrays whose length is not known at compile time. For short packed
10164 arrays, which are handled internally as modular types, the alignment
10165 will be as described for primitive types, e.g.@: a packed array of length
10166 31 bits will have an object size of four bytes, and an alignment of 4.
10168 @item @emph{Records}.
10169 For the normal non-packed case, the alignment of a record is equal to
10170 the maximum alignment of any of its components. For tagged records, this
10171 includes the implicit access type used for the tag. If a pragma @code{Pack}
10172 is used and all components are packable (see separate section on pragma
10173 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10174 record makes it profitable to increase it.
10176 A special case is when:
10179 the size of the record is given explicitly, or a
10180 full record representation clause is given, and
10182 the size of the record is 2, 4, or 8 bytes.
10185 In this case, an alignment is chosen to match the
10186 size of the record. For example, if we have:
10188 @smallexample @c ada
10189 type Small is record
10192 for Small'Size use 16;
10196 then the default alignment of the record type @code{Small} is 2, not 1. This
10197 leads to more efficient code when the record is treated as a unit, and also
10198 allows the type to specified as @code{Atomic} on architectures requiring
10204 An alignment clause may specify a larger alignment than the default value
10205 up to some maximum value dependent on the target (obtainable by using the
10206 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10207 a smaller alignment than the default value for enumeration, integer and
10208 fixed point types, as well as for record types, for example
10210 @smallexample @c ada
10215 for V'alignment use 1;
10219 @cindex Alignment, default
10220 The default alignment for the type @code{V} is 4, as a result of the
10221 Integer field in the record, but it is permissible, as shown, to
10222 override the default alignment of the record with a smaller value.
10225 @section Size Clauses
10226 @cindex Size Clause
10229 The default size for a type @code{T} is obtainable through the
10230 language-defined attribute @code{T'Size} and also through the
10231 equivalent GNAT-defined attribute @code{T'Value_Size}.
10232 For objects of type @code{T}, GNAT will generally increase the type size
10233 so that the object size (obtainable through the GNAT-defined attribute
10234 @code{T'Object_Size})
10235 is a multiple of @code{T'Alignment * Storage_Unit}.
10238 @smallexample @c ada
10239 type Smallint is range 1 .. 6;
10248 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10249 as specified by the RM rules,
10250 but objects of this type will have a size of 8
10251 (@code{Smallint'Object_Size} = 8),
10252 since objects by default occupy an integral number
10253 of storage units. On some targets, notably older
10254 versions of the Digital Alpha, the size of stand
10255 alone objects of this type may be 32, reflecting
10256 the inability of the hardware to do byte load/stores.
10258 Similarly, the size of type @code{Rec} is 40 bits
10259 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10260 the alignment is 4, so objects of this type will have
10261 their size increased to 64 bits so that it is a multiple
10262 of the alignment (in bits). This decision is
10263 in accordance with the specific Implementation Advice in RM 13.3(43):
10266 A @code{Size} clause should be supported for an object if the specified
10267 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10268 to a size in storage elements that is a multiple of the object's
10269 @code{Alignment} (if the @code{Alignment} is nonzero).
10273 An explicit size clause may be used to override the default size by
10274 increasing it. For example, if we have:
10276 @smallexample @c ada
10277 type My_Boolean is new Boolean;
10278 for My_Boolean'Size use 32;
10282 then values of this type will always be 32 bits long. In the case of
10283 discrete types, the size can be increased up to 64 bits, with the effect
10284 that the entire specified field is used to hold the value, sign- or
10285 zero-extended as appropriate. If more than 64 bits is specified, then
10286 padding space is allocated after the value, and a warning is issued that
10287 there are unused bits.
10289 Similarly the size of records and arrays may be increased, and the effect
10290 is to add padding bits after the value. This also causes a warning message
10293 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10294 Size in bits, this corresponds to an object of size 256 megabytes (minus
10295 one). This limitation is true on all targets. The reason for this
10296 limitation is that it improves the quality of the code in many cases
10297 if it is known that a Size value can be accommodated in an object of
10300 @node Storage_Size Clauses
10301 @section Storage_Size Clauses
10302 @cindex Storage_Size Clause
10305 For tasks, the @code{Storage_Size} clause specifies the amount of space
10306 to be allocated for the task stack. This cannot be extended, and if the
10307 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10308 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10309 or a @code{Storage_Size} pragma in the task definition to set the
10310 appropriate required size. A useful technique is to include in every
10311 task definition a pragma of the form:
10313 @smallexample @c ada
10314 pragma Storage_Size (Default_Stack_Size);
10318 Then @code{Default_Stack_Size} can be defined in a global package, and
10319 modified as required. Any tasks requiring stack sizes different from the
10320 default can have an appropriate alternative reference in the pragma.
10322 You can also use the @option{-d} binder switch to modify the default stack
10325 For access types, the @code{Storage_Size} clause specifies the maximum
10326 space available for allocation of objects of the type. If this space is
10327 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10328 In the case where the access type is declared local to a subprogram, the
10329 use of a @code{Storage_Size} clause triggers automatic use of a special
10330 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10331 space for the pool is automatically reclaimed on exit from the scope in
10332 which the type is declared.
10334 A special case recognized by the compiler is the specification of a
10335 @code{Storage_Size} of zero for an access type. This means that no
10336 items can be allocated from the pool, and this is recognized at compile
10337 time, and all the overhead normally associated with maintaining a fixed
10338 size storage pool is eliminated. Consider the following example:
10340 @smallexample @c ada
10342 type R is array (Natural) of Character;
10343 type P is access all R;
10344 for P'Storage_Size use 0;
10345 -- Above access type intended only for interfacing purposes
10349 procedure g (m : P);
10350 pragma Import (C, g);
10361 As indicated in this example, these dummy storage pools are often useful in
10362 connection with interfacing where no object will ever be allocated. If you
10363 compile the above example, you get the warning:
10366 p.adb:16:09: warning: allocation from empty storage pool
10367 p.adb:16:09: warning: Storage_Error will be raised at run time
10371 Of course in practice, there will not be any explicit allocators in the
10372 case of such an access declaration.
10374 @node Size of Variant Record Objects
10375 @section Size of Variant Record Objects
10376 @cindex Size, variant record objects
10377 @cindex Variant record objects, size
10380 In the case of variant record objects, there is a question whether Size gives
10381 information about a particular variant, or the maximum size required
10382 for any variant. Consider the following program
10384 @smallexample @c ada
10385 with Text_IO; use Text_IO;
10387 type R1 (A : Boolean := False) is record
10389 when True => X : Character;
10390 when False => null;
10398 Put_Line (Integer'Image (V1'Size));
10399 Put_Line (Integer'Image (V2'Size));
10404 Here we are dealing with a variant record, where the True variant
10405 requires 16 bits, and the False variant requires 8 bits.
10406 In the above example, both V1 and V2 contain the False variant,
10407 which is only 8 bits long. However, the result of running the
10416 The reason for the difference here is that the discriminant value of
10417 V1 is fixed, and will always be False. It is not possible to assign
10418 a True variant value to V1, therefore 8 bits is sufficient. On the
10419 other hand, in the case of V2, the initial discriminant value is
10420 False (from the default), but it is possible to assign a True
10421 variant value to V2, therefore 16 bits must be allocated for V2
10422 in the general case, even fewer bits may be needed at any particular
10423 point during the program execution.
10425 As can be seen from the output of this program, the @code{'Size}
10426 attribute applied to such an object in GNAT gives the actual allocated
10427 size of the variable, which is the largest size of any of the variants.
10428 The Ada Reference Manual is not completely clear on what choice should
10429 be made here, but the GNAT behavior seems most consistent with the
10430 language in the RM@.
10432 In some cases, it may be desirable to obtain the size of the current
10433 variant, rather than the size of the largest variant. This can be
10434 achieved in GNAT by making use of the fact that in the case of a
10435 subprogram parameter, GNAT does indeed return the size of the current
10436 variant (because a subprogram has no way of knowing how much space
10437 is actually allocated for the actual).
10439 Consider the following modified version of the above program:
10441 @smallexample @c ada
10442 with Text_IO; use Text_IO;
10444 type R1 (A : Boolean := False) is record
10446 when True => X : Character;
10447 when False => null;
10453 function Size (V : R1) return Integer is
10459 Put_Line (Integer'Image (V2'Size));
10460 Put_Line (Integer'IMage (Size (V2)));
10462 Put_Line (Integer'Image (V2'Size));
10463 Put_Line (Integer'IMage (Size (V2)));
10468 The output from this program is
10478 Here we see that while the @code{'Size} attribute always returns
10479 the maximum size, regardless of the current variant value, the
10480 @code{Size} function does indeed return the size of the current
10483 @node Biased Representation
10484 @section Biased Representation
10485 @cindex Size for biased representation
10486 @cindex Biased representation
10489 In the case of scalars with a range starting at other than zero, it is
10490 possible in some cases to specify a size smaller than the default minimum
10491 value, and in such cases, GNAT uses an unsigned biased representation,
10492 in which zero is used to represent the lower bound, and successive values
10493 represent successive values of the type.
10495 For example, suppose we have the declaration:
10497 @smallexample @c ada
10498 type Small is range -7 .. -4;
10499 for Small'Size use 2;
10503 Although the default size of type @code{Small} is 4, the @code{Size}
10504 clause is accepted by GNAT and results in the following representation
10508 -7 is represented as 2#00#
10509 -6 is represented as 2#01#
10510 -5 is represented as 2#10#
10511 -4 is represented as 2#11#
10515 Biased representation is only used if the specified @code{Size} clause
10516 cannot be accepted in any other manner. These reduced sizes that force
10517 biased representation can be used for all discrete types except for
10518 enumeration types for which a representation clause is given.
10520 @node Value_Size and Object_Size Clauses
10521 @section Value_Size and Object_Size Clauses
10523 @findex Object_Size
10524 @cindex Size, of objects
10527 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10528 number of bits required to hold values of type @code{T}.
10529 Although this interpretation was allowed in Ada 83, it was not required,
10530 and this requirement in practice can cause some significant difficulties.
10531 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10532 However, in Ada 95 and Ada 2005,
10533 @code{Natural'Size} is
10534 typically 31. This means that code may change in behavior when moving
10535 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10537 @smallexample @c ada
10538 type Rec is record;
10544 at 0 range 0 .. Natural'Size - 1;
10545 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10550 In the above code, since the typical size of @code{Natural} objects
10551 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10552 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10553 there are cases where the fact that the object size can exceed the
10554 size of the type causes surprises.
10556 To help get around this problem GNAT provides two implementation
10557 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10558 applied to a type, these attributes yield the size of the type
10559 (corresponding to the RM defined size attribute), and the size of
10560 objects of the type respectively.
10562 The @code{Object_Size} is used for determining the default size of
10563 objects and components. This size value can be referred to using the
10564 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10565 the basis of the determination of the size. The backend is free to
10566 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10567 character might be stored in 32 bits on a machine with no efficient
10568 byte access instructions such as the Alpha.
10570 The default rules for the value of @code{Object_Size} for
10571 discrete types are as follows:
10575 The @code{Object_Size} for base subtypes reflect the natural hardware
10576 size in bits (run the compiler with @option{-gnatS} to find those values
10577 for numeric types). Enumeration types and fixed-point base subtypes have
10578 8, 16, 32 or 64 bits for this size, depending on the range of values
10582 The @code{Object_Size} of a subtype is the same as the
10583 @code{Object_Size} of
10584 the type from which it is obtained.
10587 The @code{Object_Size} of a derived base type is copied from the parent
10588 base type, and the @code{Object_Size} of a derived first subtype is copied
10589 from the parent first subtype.
10593 The @code{Value_Size} attribute
10594 is the (minimum) number of bits required to store a value
10596 This value is used to determine how tightly to pack
10597 records or arrays with components of this type, and also affects
10598 the semantics of unchecked conversion (unchecked conversions where
10599 the @code{Value_Size} values differ generate a warning, and are potentially
10602 The default rules for the value of @code{Value_Size} are as follows:
10606 The @code{Value_Size} for a base subtype is the minimum number of bits
10607 required to store all values of the type (including the sign bit
10608 only if negative values are possible).
10611 If a subtype statically matches the first subtype of a given type, then it has
10612 by default the same @code{Value_Size} as the first subtype. This is a
10613 consequence of RM 13.1(14) (``if two subtypes statically match,
10614 then their subtype-specific aspects are the same''.)
10617 All other subtypes have a @code{Value_Size} corresponding to the minimum
10618 number of bits required to store all values of the subtype. For
10619 dynamic bounds, it is assumed that the value can range down or up
10620 to the corresponding bound of the ancestor
10624 The RM defined attribute @code{Size} corresponds to the
10625 @code{Value_Size} attribute.
10627 The @code{Size} attribute may be defined for a first-named subtype. This sets
10628 the @code{Value_Size} of
10629 the first-named subtype to the given value, and the
10630 @code{Object_Size} of this first-named subtype to the given value padded up
10631 to an appropriate boundary. It is a consequence of the default rules
10632 above that this @code{Object_Size} will apply to all further subtypes. On the
10633 other hand, @code{Value_Size} is affected only for the first subtype, any
10634 dynamic subtypes obtained from it directly, and any statically matching
10635 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
10637 @code{Value_Size} and
10638 @code{Object_Size} may be explicitly set for any subtype using
10639 an attribute definition clause. Note that the use of these attributes
10640 can cause the RM 13.1(14) rule to be violated. If two access types
10641 reference aliased objects whose subtypes have differing @code{Object_Size}
10642 values as a result of explicit attribute definition clauses, then it
10643 is erroneous to convert from one access subtype to the other.
10645 At the implementation level, Esize stores the Object_Size and the
10646 RM_Size field stores the @code{Value_Size} (and hence the value of the
10647 @code{Size} attribute,
10648 which, as noted above, is equivalent to @code{Value_Size}).
10650 To get a feel for the difference, consider the following examples (note
10651 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10654 Object_Size Value_Size
10656 type x1 is range 0 .. 5; 8 3
10658 type x2 is range 0 .. 5;
10659 for x2'size use 12; 16 12
10661 subtype x3 is x2 range 0 .. 3; 16 2
10663 subtype x4 is x2'base range 0 .. 10; 8 4
10665 subtype x5 is x2 range 0 .. dynamic; 16 3*
10667 subtype x6 is x2'base range 0 .. dynamic; 8 3*
10672 Note: the entries marked ``3*'' are not actually specified by the Ada
10673 Reference Manual, but it seems in the spirit of the RM rules to allocate
10674 the minimum number of bits (here 3, given the range for @code{x2})
10675 known to be large enough to hold the given range of values.
10677 So far, so good, but GNAT has to obey the RM rules, so the question is
10678 under what conditions must the RM @code{Size} be used.
10679 The following is a list
10680 of the occasions on which the RM @code{Size} must be used:
10684 Component size for packed arrays or records
10687 Value of the attribute @code{Size} for a type
10690 Warning about sizes not matching for unchecked conversion
10694 For record types, the @code{Object_Size} is always a multiple of the
10695 alignment of the type (this is true for all types). In some cases the
10696 @code{Value_Size} can be smaller. Consider:
10706 On a typical 32-bit architecture, the X component will be four bytes, and
10707 require four-byte alignment, and the Y component will be one byte. In this
10708 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10709 required to store a value of this type, and for example, it is permissible
10710 to have a component of type R in an outer array whose component size is
10711 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10712 since it must be rounded up so that this value is a multiple of the
10713 alignment (4 bytes = 32 bits).
10716 For all other types, the @code{Object_Size}
10717 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10718 Only @code{Size} may be specified for such types.
10720 @node Component_Size Clauses
10721 @section Component_Size Clauses
10722 @cindex Component_Size Clause
10725 Normally, the value specified in a component size clause must be consistent
10726 with the subtype of the array component with regard to size and alignment.
10727 In other words, the value specified must be at least equal to the size
10728 of this subtype, and must be a multiple of the alignment value.
10730 In addition, component size clauses are allowed which cause the array
10731 to be packed, by specifying a smaller value. A first case is for
10732 component size values in the range 1 through 63. The value specified
10733 must not be smaller than the Size of the subtype. GNAT will accurately
10734 honor all packing requests in this range. For example, if we have:
10736 @smallexample @c ada
10737 type r is array (1 .. 8) of Natural;
10738 for r'Component_Size use 31;
10742 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10743 Of course access to the components of such an array is considerably
10744 less efficient than if the natural component size of 32 is used.
10745 A second case is when the subtype of the component is a record type
10746 padded because of its default alignment. For example, if we have:
10748 @smallexample @c ada
10755 type a is array (1 .. 8) of r;
10756 for a'Component_Size use 72;
10760 then the resulting array has a length of 72 bytes, instead of 96 bytes
10761 if the alignment of the record (4) was obeyed.
10763 Note that there is no point in giving both a component size clause
10764 and a pragma Pack for the same array type. if such duplicate
10765 clauses are given, the pragma Pack will be ignored.
10767 @node Bit_Order Clauses
10768 @section Bit_Order Clauses
10769 @cindex Bit_Order Clause
10770 @cindex bit ordering
10771 @cindex ordering, of bits
10774 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10775 attribute. The specification may either correspond to the default bit
10776 order for the target, in which case the specification has no effect and
10777 places no additional restrictions, or it may be for the non-standard
10778 setting (that is the opposite of the default).
10780 In the case where the non-standard value is specified, the effect is
10781 to renumber bits within each byte, but the ordering of bytes is not
10782 affected. There are certain
10783 restrictions placed on component clauses as follows:
10787 @item Components fitting within a single storage unit.
10789 These are unrestricted, and the effect is merely to renumber bits. For
10790 example if we are on a little-endian machine with @code{Low_Order_First}
10791 being the default, then the following two declarations have exactly
10794 @smallexample @c ada
10797 B : Integer range 1 .. 120;
10801 A at 0 range 0 .. 0;
10802 B at 0 range 1 .. 7;
10807 B : Integer range 1 .. 120;
10810 for R2'Bit_Order use High_Order_First;
10813 A at 0 range 7 .. 7;
10814 B at 0 range 0 .. 6;
10819 The useful application here is to write the second declaration with the
10820 @code{Bit_Order} attribute definition clause, and know that it will be treated
10821 the same, regardless of whether the target is little-endian or big-endian.
10823 @item Components occupying an integral number of bytes.
10825 These are components that exactly fit in two or more bytes. Such component
10826 declarations are allowed, but have no effect, since it is important to realize
10827 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10828 In particular, the following attempt at getting an endian-independent integer
10831 @smallexample @c ada
10836 for R2'Bit_Order use High_Order_First;
10839 A at 0 range 0 .. 31;
10844 This declaration will result in a little-endian integer on a
10845 little-endian machine, and a big-endian integer on a big-endian machine.
10846 If byte flipping is required for interoperability between big- and
10847 little-endian machines, this must be explicitly programmed. This capability
10848 is not provided by @code{Bit_Order}.
10850 @item Components that are positioned across byte boundaries
10852 but do not occupy an integral number of bytes. Given that bytes are not
10853 reordered, such fields would occupy a non-contiguous sequence of bits
10854 in memory, requiring non-trivial code to reassemble. They are for this
10855 reason not permitted, and any component clause specifying such a layout
10856 will be flagged as illegal by GNAT@.
10861 Since the misconception that Bit_Order automatically deals with all
10862 endian-related incompatibilities is a common one, the specification of
10863 a component field that is an integral number of bytes will always
10864 generate a warning. This warning may be suppressed using @code{pragma
10865 Warnings (Off)} if desired. The following section contains additional
10866 details regarding the issue of byte ordering.
10868 @node Effect of Bit_Order on Byte Ordering
10869 @section Effect of Bit_Order on Byte Ordering
10870 @cindex byte ordering
10871 @cindex ordering, of bytes
10874 In this section we will review the effect of the @code{Bit_Order} attribute
10875 definition clause on byte ordering. Briefly, it has no effect at all, but
10876 a detailed example will be helpful. Before giving this
10877 example, let us review the precise
10878 definition of the effect of defining @code{Bit_Order}. The effect of a
10879 non-standard bit order is described in section 15.5.3 of the Ada
10883 2 A bit ordering is a method of interpreting the meaning of
10884 the storage place attributes.
10888 To understand the precise definition of storage place attributes in
10889 this context, we visit section 13.5.1 of the manual:
10892 13 A record_representation_clause (without the mod_clause)
10893 specifies the layout. The storage place attributes (see 13.5.2)
10894 are taken from the values of the position, first_bit, and last_bit
10895 expressions after normalizing those values so that first_bit is
10896 less than Storage_Unit.
10900 The critical point here is that storage places are taken from
10901 the values after normalization, not before. So the @code{Bit_Order}
10902 interpretation applies to normalized values. The interpretation
10903 is described in the later part of the 15.5.3 paragraph:
10906 2 A bit ordering is a method of interpreting the meaning of
10907 the storage place attributes. High_Order_First (known in the
10908 vernacular as ``big endian'') means that the first bit of a
10909 storage element (bit 0) is the most significant bit (interpreting
10910 the sequence of bits that represent a component as an unsigned
10911 integer value). Low_Order_First (known in the vernacular as
10912 ``little endian'') means the opposite: the first bit is the
10917 Note that the numbering is with respect to the bits of a storage
10918 unit. In other words, the specification affects only the numbering
10919 of bits within a single storage unit.
10921 We can make the effect clearer by giving an example.
10923 Suppose that we have an external device which presents two bytes, the first
10924 byte presented, which is the first (low addressed byte) of the two byte
10925 record is called Master, and the second byte is called Slave.
10927 The left most (most significant bit is called Control for each byte, and
10928 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10929 (least significant) bit.
10931 On a big-endian machine, we can write the following representation clause
10933 @smallexample @c ada
10934 type Data is record
10935 Master_Control : Bit;
10943 Slave_Control : Bit;
10953 for Data use record
10954 Master_Control at 0 range 0 .. 0;
10955 Master_V1 at 0 range 1 .. 1;
10956 Master_V2 at 0 range 2 .. 2;
10957 Master_V3 at 0 range 3 .. 3;
10958 Master_V4 at 0 range 4 .. 4;
10959 Master_V5 at 0 range 5 .. 5;
10960 Master_V6 at 0 range 6 .. 6;
10961 Master_V7 at 0 range 7 .. 7;
10962 Slave_Control at 1 range 0 .. 0;
10963 Slave_V1 at 1 range 1 .. 1;
10964 Slave_V2 at 1 range 2 .. 2;
10965 Slave_V3 at 1 range 3 .. 3;
10966 Slave_V4 at 1 range 4 .. 4;
10967 Slave_V5 at 1 range 5 .. 5;
10968 Slave_V6 at 1 range 6 .. 6;
10969 Slave_V7 at 1 range 7 .. 7;
10974 Now if we move this to a little endian machine, then the bit ordering within
10975 the byte is backwards, so we have to rewrite the record rep clause as:
10977 @smallexample @c ada
10978 for Data use record
10979 Master_Control at 0 range 7 .. 7;
10980 Master_V1 at 0 range 6 .. 6;
10981 Master_V2 at 0 range 5 .. 5;
10982 Master_V3 at 0 range 4 .. 4;
10983 Master_V4 at 0 range 3 .. 3;
10984 Master_V5 at 0 range 2 .. 2;
10985 Master_V6 at 0 range 1 .. 1;
10986 Master_V7 at 0 range 0 .. 0;
10987 Slave_Control at 1 range 7 .. 7;
10988 Slave_V1 at 1 range 6 .. 6;
10989 Slave_V2 at 1 range 5 .. 5;
10990 Slave_V3 at 1 range 4 .. 4;
10991 Slave_V4 at 1 range 3 .. 3;
10992 Slave_V5 at 1 range 2 .. 2;
10993 Slave_V6 at 1 range 1 .. 1;
10994 Slave_V7 at 1 range 0 .. 0;
10999 It is a nuisance to have to rewrite the clause, especially if
11000 the code has to be maintained on both machines. However,
11001 this is a case that we can handle with the
11002 @code{Bit_Order} attribute if it is implemented.
11003 Note that the implementation is not required on byte addressed
11004 machines, but it is indeed implemented in GNAT.
11005 This means that we can simply use the
11006 first record clause, together with the declaration
11008 @smallexample @c ada
11009 for Data'Bit_Order use High_Order_First;
11013 and the effect is what is desired, namely the layout is exactly the same,
11014 independent of whether the code is compiled on a big-endian or little-endian
11017 The important point to understand is that byte ordering is not affected.
11018 A @code{Bit_Order} attribute definition never affects which byte a field
11019 ends up in, only where it ends up in that byte.
11020 To make this clear, let us rewrite the record rep clause of the previous
11023 @smallexample @c ada
11024 for Data'Bit_Order use High_Order_First;
11025 for Data use record
11026 Master_Control at 0 range 0 .. 0;
11027 Master_V1 at 0 range 1 .. 1;
11028 Master_V2 at 0 range 2 .. 2;
11029 Master_V3 at 0 range 3 .. 3;
11030 Master_V4 at 0 range 4 .. 4;
11031 Master_V5 at 0 range 5 .. 5;
11032 Master_V6 at 0 range 6 .. 6;
11033 Master_V7 at 0 range 7 .. 7;
11034 Slave_Control at 0 range 8 .. 8;
11035 Slave_V1 at 0 range 9 .. 9;
11036 Slave_V2 at 0 range 10 .. 10;
11037 Slave_V3 at 0 range 11 .. 11;
11038 Slave_V4 at 0 range 12 .. 12;
11039 Slave_V5 at 0 range 13 .. 13;
11040 Slave_V6 at 0 range 14 .. 14;
11041 Slave_V7 at 0 range 15 .. 15;
11046 This is exactly equivalent to saying (a repeat of the first example):
11048 @smallexample @c ada
11049 for Data'Bit_Order use High_Order_First;
11050 for Data use record
11051 Master_Control at 0 range 0 .. 0;
11052 Master_V1 at 0 range 1 .. 1;
11053 Master_V2 at 0 range 2 .. 2;
11054 Master_V3 at 0 range 3 .. 3;
11055 Master_V4 at 0 range 4 .. 4;
11056 Master_V5 at 0 range 5 .. 5;
11057 Master_V6 at 0 range 6 .. 6;
11058 Master_V7 at 0 range 7 .. 7;
11059 Slave_Control at 1 range 0 .. 0;
11060 Slave_V1 at 1 range 1 .. 1;
11061 Slave_V2 at 1 range 2 .. 2;
11062 Slave_V3 at 1 range 3 .. 3;
11063 Slave_V4 at 1 range 4 .. 4;
11064 Slave_V5 at 1 range 5 .. 5;
11065 Slave_V6 at 1 range 6 .. 6;
11066 Slave_V7 at 1 range 7 .. 7;
11071 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11072 field. The storage place attributes are obtained by normalizing the
11073 values given so that the @code{First_Bit} value is less than 8. After
11074 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11075 we specified in the other case.
11077 Now one might expect that the @code{Bit_Order} attribute might affect
11078 bit numbering within the entire record component (two bytes in this
11079 case, thus affecting which byte fields end up in), but that is not
11080 the way this feature is defined, it only affects numbering of bits,
11081 not which byte they end up in.
11083 Consequently it never makes sense to specify a starting bit number
11084 greater than 7 (for a byte addressable field) if an attribute
11085 definition for @code{Bit_Order} has been given, and indeed it
11086 may be actively confusing to specify such a value, so the compiler
11087 generates a warning for such usage.
11089 If you do need to control byte ordering then appropriate conditional
11090 values must be used. If in our example, the slave byte came first on
11091 some machines we might write:
11093 @smallexample @c ada
11094 Master_Byte_First constant Boolean := @dots{};
11096 Master_Byte : constant Natural :=
11097 1 - Boolean'Pos (Master_Byte_First);
11098 Slave_Byte : constant Natural :=
11099 Boolean'Pos (Master_Byte_First);
11101 for Data'Bit_Order use High_Order_First;
11102 for Data use record
11103 Master_Control at Master_Byte range 0 .. 0;
11104 Master_V1 at Master_Byte range 1 .. 1;
11105 Master_V2 at Master_Byte range 2 .. 2;
11106 Master_V3 at Master_Byte range 3 .. 3;
11107 Master_V4 at Master_Byte range 4 .. 4;
11108 Master_V5 at Master_Byte range 5 .. 5;
11109 Master_V6 at Master_Byte range 6 .. 6;
11110 Master_V7 at Master_Byte range 7 .. 7;
11111 Slave_Control at Slave_Byte range 0 .. 0;
11112 Slave_V1 at Slave_Byte range 1 .. 1;
11113 Slave_V2 at Slave_Byte range 2 .. 2;
11114 Slave_V3 at Slave_Byte range 3 .. 3;
11115 Slave_V4 at Slave_Byte range 4 .. 4;
11116 Slave_V5 at Slave_Byte range 5 .. 5;
11117 Slave_V6 at Slave_Byte range 6 .. 6;
11118 Slave_V7 at Slave_Byte range 7 .. 7;
11123 Now to switch between machines, all that is necessary is
11124 to set the boolean constant @code{Master_Byte_First} in
11125 an appropriate manner.
11127 @node Pragma Pack for Arrays
11128 @section Pragma Pack for Arrays
11129 @cindex Pragma Pack (for arrays)
11132 Pragma @code{Pack} applied to an array has no effect unless the component type
11133 is packable. For a component type to be packable, it must be one of the
11140 Any type whose size is specified with a size clause
11142 Any packed array type with a static size
11144 Any record type padded because of its default alignment
11148 For all these cases, if the component subtype size is in the range
11149 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11150 component size were specified giving the component subtype size.
11151 For example if we have:
11153 @smallexample @c ada
11154 type r is range 0 .. 17;
11156 type ar is array (1 .. 8) of r;
11161 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11162 and the size of the array @code{ar} will be exactly 40 bits.
11164 Note that in some cases this rather fierce approach to packing can produce
11165 unexpected effects. For example, in Ada 95 and Ada 2005,
11166 subtype @code{Natural} typically has a size of 31, meaning that if you
11167 pack an array of @code{Natural}, you get 31-bit
11168 close packing, which saves a few bits, but results in far less efficient
11169 access. Since many other Ada compilers will ignore such a packing request,
11170 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11171 might not be what is intended. You can easily remove this warning by
11172 using an explicit @code{Component_Size} setting instead, which never generates
11173 a warning, since the intention of the programmer is clear in this case.
11175 GNAT treats packed arrays in one of two ways. If the size of the array is
11176 known at compile time and is less than 64 bits, then internally the array
11177 is represented as a single modular type, of exactly the appropriate number
11178 of bits. If the length is greater than 63 bits, or is not known at compile
11179 time, then the packed array is represented as an array of bytes, and the
11180 length is always a multiple of 8 bits.
11182 Note that to represent a packed array as a modular type, the alignment must
11183 be suitable for the modular type involved. For example, on typical machines
11184 a 32-bit packed array will be represented by a 32-bit modular integer with
11185 an alignment of four bytes. If you explicitly override the default alignment
11186 with an alignment clause that is too small, the modular representation
11187 cannot be used. For example, consider the following set of declarations:
11189 @smallexample @c ada
11190 type R is range 1 .. 3;
11191 type S is array (1 .. 31) of R;
11192 for S'Component_Size use 2;
11194 for S'Alignment use 1;
11198 If the alignment clause were not present, then a 62-bit modular
11199 representation would be chosen (typically with an alignment of 4 or 8
11200 bytes depending on the target). But the default alignment is overridden
11201 with the explicit alignment clause. This means that the modular
11202 representation cannot be used, and instead the array of bytes
11203 representation must be used, meaning that the length must be a multiple
11204 of 8. Thus the above set of declarations will result in a diagnostic
11205 rejecting the size clause and noting that the minimum size allowed is 64.
11207 @cindex Pragma Pack (for type Natural)
11208 @cindex Pragma Pack warning
11210 One special case that is worth noting occurs when the base type of the
11211 component size is 8/16/32 and the subtype is one bit less. Notably this
11212 occurs with subtype @code{Natural}. Consider:
11214 @smallexample @c ada
11215 type Arr is array (1 .. 32) of Natural;
11220 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11221 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11222 Ada 83 compilers did not attempt 31 bit packing.
11224 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11225 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11226 substantial unintended performance penalty when porting legacy Ada 83 code.
11227 To help prevent this, GNAT generates a warning in such cases. If you really
11228 want 31 bit packing in a case like this, you can set the component size
11231 @smallexample @c ada
11232 type Arr is array (1 .. 32) of Natural;
11233 for Arr'Component_Size use 31;
11237 Here 31-bit packing is achieved as required, and no warning is generated,
11238 since in this case the programmer intention is clear.
11240 @node Pragma Pack for Records
11241 @section Pragma Pack for Records
11242 @cindex Pragma Pack (for records)
11245 Pragma @code{Pack} applied to a record will pack the components to reduce
11246 wasted space from alignment gaps and by reducing the amount of space
11247 taken by components. We distinguish between @emph{packable} components and
11248 @emph{non-packable} components.
11249 Components of the following types are considered packable:
11252 All primitive types are packable.
11255 Small packed arrays, whose size does not exceed 64 bits, and where the
11256 size is statically known at compile time, are represented internally
11257 as modular integers, and so they are also packable.
11262 All packable components occupy the exact number of bits corresponding to
11263 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11264 can start on an arbitrary bit boundary.
11266 All other types are non-packable, they occupy an integral number of
11268 are placed at a boundary corresponding to their alignment requirements.
11270 For example, consider the record
11272 @smallexample @c ada
11273 type Rb1 is array (1 .. 13) of Boolean;
11276 type Rb2 is array (1 .. 65) of Boolean;
11291 The representation for the record x2 is as follows:
11293 @smallexample @c ada
11294 for x2'Size use 224;
11296 l1 at 0 range 0 .. 0;
11297 l2 at 0 range 1 .. 64;
11298 l3 at 12 range 0 .. 31;
11299 l4 at 16 range 0 .. 0;
11300 l5 at 16 range 1 .. 13;
11301 l6 at 18 range 0 .. 71;
11306 Studying this example, we see that the packable fields @code{l1}
11308 of length equal to their sizes, and placed at specific bit boundaries (and
11309 not byte boundaries) to
11310 eliminate padding. But @code{l3} is of a non-packable float type, so
11311 it is on the next appropriate alignment boundary.
11313 The next two fields are fully packable, so @code{l4} and @code{l5} are
11314 minimally packed with no gaps. However, type @code{Rb2} is a packed
11315 array that is longer than 64 bits, so it is itself non-packable. Thus
11316 the @code{l6} field is aligned to the next byte boundary, and takes an
11317 integral number of bytes, i.e.@: 72 bits.
11319 @node Record Representation Clauses
11320 @section Record Representation Clauses
11321 @cindex Record Representation Clause
11324 Record representation clauses may be given for all record types, including
11325 types obtained by record extension. Component clauses are allowed for any
11326 static component. The restrictions on component clauses depend on the type
11329 @cindex Component Clause
11330 For all components of an elementary type, the only restriction on component
11331 clauses is that the size must be at least the 'Size value of the type
11332 (actually the Value_Size). There are no restrictions due to alignment,
11333 and such components may freely cross storage boundaries.
11335 Packed arrays with a size up to and including 64 bits are represented
11336 internally using a modular type with the appropriate number of bits, and
11337 thus the same lack of restriction applies. For example, if you declare:
11339 @smallexample @c ada
11340 type R is array (1 .. 49) of Boolean;
11346 then a component clause for a component of type R may start on any
11347 specified bit boundary, and may specify a value of 49 bits or greater.
11349 For packed bit arrays that are longer than 64 bits, there are two
11350 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11351 including the important case of single bits or boolean values, then
11352 there are no limitations on placement of such components, and they
11353 may start and end at arbitrary bit boundaries.
11355 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11356 an array of this type longer than 64 bits must always be placed on
11357 on a storage unit (byte) boundary and occupy an integral number
11358 of storage units (bytes). Any component clause that does not
11359 meet this requirement will be rejected.
11361 Any aliased component, or component of an aliased type, must
11362 have its normal alignment and size. A component clause that
11363 does not meet this requirement will be rejected.
11365 The tag field of a tagged type always occupies an address sized field at
11366 the start of the record. No component clause may attempt to overlay this
11367 tag. When a tagged type appears as a component, the tag field must have
11370 In the case of a record extension T1, of a type T, no component clause applied
11371 to the type T1 can specify a storage location that would overlap the first
11372 T'Size bytes of the record.
11374 For all other component types, including non-bit-packed arrays,
11375 the component can be placed at an arbitrary bit boundary,
11376 so for example, the following is permitted:
11378 @smallexample @c ada
11379 type R is array (1 .. 10) of Boolean;
11388 G at 0 range 0 .. 0;
11389 H at 0 range 1 .. 1;
11390 L at 0 range 2 .. 81;
11391 R at 0 range 82 .. 161;
11396 Note: the above rules apply to recent releases of GNAT 5.
11397 In GNAT 3, there are more severe restrictions on larger components.
11398 For non-primitive types, including packed arrays with a size greater than
11399 64 bits, component clauses must respect the alignment requirement of the
11400 type, in particular, always starting on a byte boundary, and the length
11401 must be a multiple of the storage unit.
11403 @node Enumeration Clauses
11404 @section Enumeration Clauses
11406 The only restriction on enumeration clauses is that the range of values
11407 must be representable. For the signed case, if one or more of the
11408 representation values are negative, all values must be in the range:
11410 @smallexample @c ada
11411 System.Min_Int .. System.Max_Int
11415 For the unsigned case, where all values are nonnegative, the values must
11418 @smallexample @c ada
11419 0 .. System.Max_Binary_Modulus;
11423 A @emph{confirming} representation clause is one in which the values range
11424 from 0 in sequence, i.e.@: a clause that confirms the default representation
11425 for an enumeration type.
11426 Such a confirming representation
11427 is permitted by these rules, and is specially recognized by the compiler so
11428 that no extra overhead results from the use of such a clause.
11430 If an array has an index type which is an enumeration type to which an
11431 enumeration clause has been applied, then the array is stored in a compact
11432 manner. Consider the declarations:
11434 @smallexample @c ada
11435 type r is (A, B, C);
11436 for r use (A => 1, B => 5, C => 10);
11437 type t is array (r) of Character;
11441 The array type t corresponds to a vector with exactly three elements and
11442 has a default size equal to @code{3*Character'Size}. This ensures efficient
11443 use of space, but means that accesses to elements of the array will incur
11444 the overhead of converting representation values to the corresponding
11445 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11447 @node Address Clauses
11448 @section Address Clauses
11449 @cindex Address Clause
11451 The reference manual allows a general restriction on representation clauses,
11452 as found in RM 13.1(22):
11455 An implementation need not support representation
11456 items containing nonstatic expressions, except that
11457 an implementation should support a representation item
11458 for a given entity if each nonstatic expression in the
11459 representation item is a name that statically denotes
11460 a constant declared before the entity.
11464 In practice this is applicable only to address clauses, since this is the
11465 only case in which a non-static expression is permitted by the syntax. As
11466 the AARM notes in sections 13.1 (22.a-22.h):
11469 22.a Reason: This is to avoid the following sort of thing:
11471 22.b X : Integer := F(@dots{});
11472 Y : Address := G(@dots{});
11473 for X'Address use Y;
11475 22.c In the above, we have to evaluate the
11476 initialization expression for X before we
11477 know where to put the result. This seems
11478 like an unreasonable implementation burden.
11480 22.d The above code should instead be written
11483 22.e Y : constant Address := G(@dots{});
11484 X : Integer := F(@dots{});
11485 for X'Address use Y;
11487 22.f This allows the expression ``Y'' to be safely
11488 evaluated before X is created.
11490 22.g The constant could be a formal parameter of mode in.
11492 22.h An implementation can support other nonstatic
11493 expressions if it wants to. Expressions of type
11494 Address are hardly ever static, but their value
11495 might be known at compile time anyway in many
11500 GNAT does indeed permit many additional cases of non-static expressions. In
11501 particular, if the type involved is elementary there are no restrictions
11502 (since in this case, holding a temporary copy of the initialization value,
11503 if one is present, is inexpensive). In addition, if there is no implicit or
11504 explicit initialization, then there are no restrictions. GNAT will reject
11505 only the case where all three of these conditions hold:
11510 The type of the item is non-elementary (e.g.@: a record or array).
11513 There is explicit or implicit initialization required for the object.
11514 Note that access values are always implicitly initialized, and also
11515 in GNAT, certain bit-packed arrays (those having a dynamic length or
11516 a length greater than 64) will also be implicitly initialized to zero.
11519 The address value is non-static. Here GNAT is more permissive than the
11520 RM, and allows the address value to be the address of a previously declared
11521 stand-alone variable, as long as it does not itself have an address clause.
11523 @smallexample @c ada
11524 Anchor : Some_Initialized_Type;
11525 Overlay : Some_Initialized_Type;
11526 for Overlay'Address use Anchor'Address;
11530 However, the prefix of the address clause cannot be an array component, or
11531 a component of a discriminated record.
11536 As noted above in section 22.h, address values are typically non-static. In
11537 particular the To_Address function, even if applied to a literal value, is
11538 a non-static function call. To avoid this minor annoyance, GNAT provides
11539 the implementation defined attribute 'To_Address. The following two
11540 expressions have identical values:
11544 @smallexample @c ada
11545 To_Address (16#1234_0000#)
11546 System'To_Address (16#1234_0000#);
11550 except that the second form is considered to be a static expression, and
11551 thus when used as an address clause value is always permitted.
11554 Additionally, GNAT treats as static an address clause that is an
11555 unchecked_conversion of a static integer value. This simplifies the porting
11556 of legacy code, and provides a portable equivalent to the GNAT attribute
11559 Another issue with address clauses is the interaction with alignment
11560 requirements. When an address clause is given for an object, the address
11561 value must be consistent with the alignment of the object (which is usually
11562 the same as the alignment of the type of the object). If an address clause
11563 is given that specifies an inappropriately aligned address value, then the
11564 program execution is erroneous.
11566 Since this source of erroneous behavior can have unfortunate effects, GNAT
11567 checks (at compile time if possible, generating a warning, or at execution
11568 time with a run-time check) that the alignment is appropriate. If the
11569 run-time check fails, then @code{Program_Error} is raised. This run-time
11570 check is suppressed if range checks are suppressed, or if the special GNAT
11571 check Alignment_Check is suppressed, or if
11572 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11574 Finally, GNAT does not permit overlaying of objects of controlled types or
11575 composite types containing a controlled component. In most cases, the compiler
11576 can detect an attempt at such overlays and will generate a warning at compile
11577 time and a Program_Error exception at run time.
11580 An address clause cannot be given for an exported object. More
11581 understandably the real restriction is that objects with an address
11582 clause cannot be exported. This is because such variables are not
11583 defined by the Ada program, so there is no external object to export.
11586 It is permissible to give an address clause and a pragma Import for the
11587 same object. In this case, the variable is not really defined by the
11588 Ada program, so there is no external symbol to be linked. The link name
11589 and the external name are ignored in this case. The reason that we allow this
11590 combination is that it provides a useful idiom to avoid unwanted
11591 initializations on objects with address clauses.
11593 When an address clause is given for an object that has implicit or
11594 explicit initialization, then by default initialization takes place. This
11595 means that the effect of the object declaration is to overwrite the
11596 memory at the specified address. This is almost always not what the
11597 programmer wants, so GNAT will output a warning:
11607 for Ext'Address use System'To_Address (16#1234_1234#);
11609 >>> warning: implicit initialization of "Ext" may
11610 modify overlaid storage
11611 >>> warning: use pragma Import for "Ext" to suppress
11612 initialization (RM B(24))
11618 As indicated by the warning message, the solution is to use a (dummy) pragma
11619 Import to suppress this initialization. The pragma tell the compiler that the
11620 object is declared and initialized elsewhere. The following package compiles
11621 without warnings (and the initialization is suppressed):
11623 @smallexample @c ada
11631 for Ext'Address use System'To_Address (16#1234_1234#);
11632 pragma Import (Ada, Ext);
11637 A final issue with address clauses involves their use for overlaying
11638 variables, as in the following example:
11639 @cindex Overlaying of objects
11641 @smallexample @c ada
11644 for B'Address use A'Address;
11648 or alternatively, using the form recommended by the RM:
11650 @smallexample @c ada
11652 Addr : constant Address := A'Address;
11654 for B'Address use Addr;
11658 In both of these cases, @code{A}
11659 and @code{B} become aliased to one another via the
11660 address clause. This use of address clauses to overlay
11661 variables, achieving an effect similar to unchecked
11662 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11663 the effect is implementation defined. Furthermore, the
11664 Ada RM specifically recommends that in a situation
11665 like this, @code{B} should be subject to the following
11666 implementation advice (RM 13.3(19)):
11669 19 If the Address of an object is specified, or it is imported
11670 or exported, then the implementation should not perform
11671 optimizations based on assumptions of no aliases.
11675 GNAT follows this recommendation, and goes further by also applying
11676 this recommendation to the overlaid variable (@code{A}
11677 in the above example) in this case. This means that the overlay
11678 works "as expected", in that a modification to one of the variables
11679 will affect the value of the other.
11681 @node Effect of Convention on Representation
11682 @section Effect of Convention on Representation
11683 @cindex Convention, effect on representation
11686 Normally the specification of a foreign language convention for a type or
11687 an object has no effect on the chosen representation. In particular, the
11688 representation chosen for data in GNAT generally meets the standard system
11689 conventions, and for example records are laid out in a manner that is
11690 consistent with C@. This means that specifying convention C (for example)
11693 There are four exceptions to this general rule:
11697 @item Convention Fortran and array subtypes
11698 If pragma Convention Fortran is specified for an array subtype, then in
11699 accordance with the implementation advice in section 3.6.2(11) of the
11700 Ada Reference Manual, the array will be stored in a Fortran-compatible
11701 column-major manner, instead of the normal default row-major order.
11703 @item Convention C and enumeration types
11704 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11705 to accommodate all values of the type. For example, for the enumeration
11708 @smallexample @c ada
11709 type Color is (Red, Green, Blue);
11713 8 bits is sufficient to store all values of the type, so by default, objects
11714 of type @code{Color} will be represented using 8 bits. However, normal C
11715 convention is to use 32 bits for all enum values in C, since enum values
11716 are essentially of type int. If pragma @code{Convention C} is specified for an
11717 Ada enumeration type, then the size is modified as necessary (usually to
11718 32 bits) to be consistent with the C convention for enum values.
11720 Note that this treatment applies only to types. If Convention C is given for
11721 an enumeration object, where the enumeration type is not Convention C, then
11722 Object_Size bits are allocated. For example, for a normal enumeration type,
11723 with less than 256 elements, only 8 bits will be allocated for the object.
11724 Since this may be a surprise in terms of what C expects, GNAT will issue a
11725 warning in this situation. The warning can be suppressed by giving an explicit
11726 size clause specifying the desired size.
11728 @item Convention C/Fortran and Boolean types
11729 In C, the usual convention for boolean values, that is values used for
11730 conditions, is that zero represents false, and nonzero values represent
11731 true. In Ada, the normal convention is that two specific values, typically
11732 0/1, are used to represent false/true respectively.
11734 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11735 value represents true).
11737 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11738 C or Fortran convention for a derived Boolean, as in the following example:
11740 @smallexample @c ada
11741 type C_Switch is new Boolean;
11742 pragma Convention (C, C_Switch);
11746 then the GNAT generated code will treat any nonzero value as true. For truth
11747 values generated by GNAT, the conventional value 1 will be used for True, but
11748 when one of these values is read, any nonzero value is treated as True.
11750 @item Access types on OpenVMS
11751 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11752 arrays) are 64-bits long. An exception to this rule is for the case of
11753 C-convention access types where there is no explicit size clause present (or
11754 inherited for derived types). In this case, GNAT chooses to make these
11755 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11756 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11760 @node Determining the Representations chosen by GNAT
11761 @section Determining the Representations chosen by GNAT
11762 @cindex Representation, determination of
11763 @cindex @option{-gnatR} switch
11766 Although the descriptions in this section are intended to be complete, it is
11767 often easier to simply experiment to see what GNAT accepts and what the
11768 effect is on the layout of types and objects.
11770 As required by the Ada RM, if a representation clause is not accepted, then
11771 it must be rejected as illegal by the compiler. However, when a
11772 representation clause or pragma is accepted, there can still be questions
11773 of what the compiler actually does. For example, if a partial record
11774 representation clause specifies the location of some components and not
11775 others, then where are the non-specified components placed? Or if pragma
11776 @code{Pack} is used on a record, then exactly where are the resulting
11777 fields placed? The section on pragma @code{Pack} in this chapter can be
11778 used to answer the second question, but it is often easier to just see
11779 what the compiler does.
11781 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
11782 with this option, then the compiler will output information on the actual
11783 representations chosen, in a format similar to source representation
11784 clauses. For example, if we compile the package:
11786 @smallexample @c ada
11788 type r (x : boolean) is tagged record
11790 when True => S : String (1 .. 100);
11791 when False => null;
11795 type r2 is new r (false) with record
11800 y2 at 16 range 0 .. 31;
11807 type x1 is array (1 .. 10) of x;
11808 for x1'component_size use 11;
11810 type ia is access integer;
11812 type Rb1 is array (1 .. 13) of Boolean;
11815 type Rb2 is array (1 .. 65) of Boolean;
11831 using the switch @option{-gnatR} we obtain the following output:
11834 Representation information for unit q
11835 -------------------------------------
11838 for r'Alignment use 4;
11840 x at 4 range 0 .. 7;
11841 _tag at 0 range 0 .. 31;
11842 s at 5 range 0 .. 799;
11845 for r2'Size use 160;
11846 for r2'Alignment use 4;
11848 x at 4 range 0 .. 7;
11849 _tag at 0 range 0 .. 31;
11850 _parent at 0 range 0 .. 63;
11851 y2 at 16 range 0 .. 31;
11855 for x'Alignment use 1;
11857 y at 0 range 0 .. 7;
11860 for x1'Size use 112;
11861 for x1'Alignment use 1;
11862 for x1'Component_Size use 11;
11864 for rb1'Size use 13;
11865 for rb1'Alignment use 2;
11866 for rb1'Component_Size use 1;
11868 for rb2'Size use 72;
11869 for rb2'Alignment use 1;
11870 for rb2'Component_Size use 1;
11872 for x2'Size use 224;
11873 for x2'Alignment use 4;
11875 l1 at 0 range 0 .. 0;
11876 l2 at 0 range 1 .. 64;
11877 l3 at 12 range 0 .. 31;
11878 l4 at 16 range 0 .. 0;
11879 l5 at 16 range 1 .. 13;
11880 l6 at 18 range 0 .. 71;
11885 The Size values are actually the Object_Size, i.e.@: the default size that
11886 will be allocated for objects of the type.
11887 The ?? size for type r indicates that we have a variant record, and the
11888 actual size of objects will depend on the discriminant value.
11890 The Alignment values show the actual alignment chosen by the compiler
11891 for each record or array type.
11893 The record representation clause for type r shows where all fields
11894 are placed, including the compiler generated tag field (whose location
11895 cannot be controlled by the programmer).
11897 The record representation clause for the type extension r2 shows all the
11898 fields present, including the parent field, which is a copy of the fields
11899 of the parent type of r2, i.e.@: r1.
11901 The component size and size clauses for types rb1 and rb2 show
11902 the exact effect of pragma @code{Pack} on these arrays, and the record
11903 representation clause for type x2 shows how pragma @code{Pack} affects
11906 In some cases, it may be useful to cut and paste the representation clauses
11907 generated by the compiler into the original source to fix and guarantee
11908 the actual representation to be used.
11910 @node Standard Library Routines
11911 @chapter Standard Library Routines
11914 The Ada Reference Manual contains in Annex A a full description of an
11915 extensive set of standard library routines that can be used in any Ada
11916 program, and which must be provided by all Ada compilers. They are
11917 analogous to the standard C library used by C programs.
11919 GNAT implements all of the facilities described in annex A, and for most
11920 purposes the description in the Ada Reference Manual, or appropriate Ada
11921 text book, will be sufficient for making use of these facilities.
11923 In the case of the input-output facilities,
11924 @xref{The Implementation of Standard I/O},
11925 gives details on exactly how GNAT interfaces to the
11926 file system. For the remaining packages, the Ada Reference Manual
11927 should be sufficient. The following is a list of the packages included,
11928 together with a brief description of the functionality that is provided.
11930 For completeness, references are included to other predefined library
11931 routines defined in other sections of the Ada Reference Manual (these are
11932 cross-indexed from Annex A).
11936 This is a parent package for all the standard library packages. It is
11937 usually included implicitly in your program, and itself contains no
11938 useful data or routines.
11940 @item Ada.Calendar (9.6)
11941 @code{Calendar} provides time of day access, and routines for
11942 manipulating times and durations.
11944 @item Ada.Characters (A.3.1)
11945 This is a dummy parent package that contains no useful entities
11947 @item Ada.Characters.Handling (A.3.2)
11948 This package provides some basic character handling capabilities,
11949 including classification functions for classes of characters (e.g.@: test
11950 for letters, or digits).
11952 @item Ada.Characters.Latin_1 (A.3.3)
11953 This package includes a complete set of definitions of the characters
11954 that appear in type CHARACTER@. It is useful for writing programs that
11955 will run in international environments. For example, if you want an
11956 upper case E with an acute accent in a string, it is often better to use
11957 the definition of @code{UC_E_Acute} in this package. Then your program
11958 will print in an understandable manner even if your environment does not
11959 support these extended characters.
11961 @item Ada.Command_Line (A.15)
11962 This package provides access to the command line parameters and the name
11963 of the current program (analogous to the use of @code{argc} and @code{argv}
11964 in C), and also allows the exit status for the program to be set in a
11965 system-independent manner.
11967 @item Ada.Decimal (F.2)
11968 This package provides constants describing the range of decimal numbers
11969 implemented, and also a decimal divide routine (analogous to the COBOL
11970 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11972 @item Ada.Direct_IO (A.8.4)
11973 This package provides input-output using a model of a set of records of
11974 fixed-length, containing an arbitrary definite Ada type, indexed by an
11975 integer record number.
11977 @item Ada.Dynamic_Priorities (D.5)
11978 This package allows the priorities of a task to be adjusted dynamically
11979 as the task is running.
11981 @item Ada.Exceptions (11.4.1)
11982 This package provides additional information on exceptions, and also
11983 contains facilities for treating exceptions as data objects, and raising
11984 exceptions with associated messages.
11986 @item Ada.Finalization (7.6)
11987 This package contains the declarations and subprograms to support the
11988 use of controlled types, providing for automatic initialization and
11989 finalization (analogous to the constructors and destructors of C++)
11991 @item Ada.Interrupts (C.3.2)
11992 This package provides facilities for interfacing to interrupts, which
11993 includes the set of signals or conditions that can be raised and
11994 recognized as interrupts.
11996 @item Ada.Interrupts.Names (C.3.2)
11997 This package provides the set of interrupt names (actually signal
11998 or condition names) that can be handled by GNAT@.
12000 @item Ada.IO_Exceptions (A.13)
12001 This package defines the set of exceptions that can be raised by use of
12002 the standard IO packages.
12005 This package contains some standard constants and exceptions used
12006 throughout the numerics packages. Note that the constants pi and e are
12007 defined here, and it is better to use these definitions than rolling
12010 @item Ada.Numerics.Complex_Elementary_Functions
12011 Provides the implementation of standard elementary functions (such as
12012 log and trigonometric functions) operating on complex numbers using the
12013 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12014 created by the package @code{Numerics.Complex_Types}.
12016 @item Ada.Numerics.Complex_Types
12017 This is a predefined instantiation of
12018 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12019 build the type @code{Complex} and @code{Imaginary}.
12021 @item Ada.Numerics.Discrete_Random
12022 This generic package provides a random number generator suitable for generating
12023 uniformly distributed values of a specified discrete subtype.
12025 @item Ada.Numerics.Float_Random
12026 This package provides a random number generator suitable for generating
12027 uniformly distributed floating point values in the unit interval.
12029 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12030 This is a generic version of the package that provides the
12031 implementation of standard elementary functions (such as log and
12032 trigonometric functions) for an arbitrary complex type.
12034 The following predefined instantiations of this package are provided:
12038 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12040 @code{Ada.Numerics.Complex_Elementary_Functions}
12042 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12045 @item Ada.Numerics.Generic_Complex_Types
12046 This is a generic package that allows the creation of complex types,
12047 with associated complex arithmetic operations.
12049 The following predefined instantiations of this package exist
12052 @code{Ada.Numerics.Short_Complex_Complex_Types}
12054 @code{Ada.Numerics.Complex_Complex_Types}
12056 @code{Ada.Numerics.Long_Complex_Complex_Types}
12059 @item Ada.Numerics.Generic_Elementary_Functions
12060 This is a generic package that provides the implementation of standard
12061 elementary functions (such as log an trigonometric functions) for an
12062 arbitrary float type.
12064 The following predefined instantiations of this package exist
12068 @code{Ada.Numerics.Short_Elementary_Functions}
12070 @code{Ada.Numerics.Elementary_Functions}
12072 @code{Ada.Numerics.Long_Elementary_Functions}
12075 @item Ada.Real_Time (D.8)
12076 This package provides facilities similar to those of @code{Calendar}, but
12077 operating with a finer clock suitable for real time control. Note that
12078 annex D requires that there be no backward clock jumps, and GNAT generally
12079 guarantees this behavior, but of course if the external clock on which
12080 the GNAT runtime depends is deliberately reset by some external event,
12081 then such a backward jump may occur.
12083 @item Ada.Sequential_IO (A.8.1)
12084 This package provides input-output facilities for sequential files,
12085 which can contain a sequence of values of a single type, which can be
12086 any Ada type, including indefinite (unconstrained) types.
12088 @item Ada.Storage_IO (A.9)
12089 This package provides a facility for mapping arbitrary Ada types to and
12090 from a storage buffer. It is primarily intended for the creation of new
12093 @item Ada.Streams (13.13.1)
12094 This is a generic package that provides the basic support for the
12095 concept of streams as used by the stream attributes (@code{Input},
12096 @code{Output}, @code{Read} and @code{Write}).
12098 @item Ada.Streams.Stream_IO (A.12.1)
12099 This package is a specialization of the type @code{Streams} defined in
12100 package @code{Streams} together with a set of operations providing
12101 Stream_IO capability. The Stream_IO model permits both random and
12102 sequential access to a file which can contain an arbitrary set of values
12103 of one or more Ada types.
12105 @item Ada.Strings (A.4.1)
12106 This package provides some basic constants used by the string handling
12109 @item Ada.Strings.Bounded (A.4.4)
12110 This package provides facilities for handling variable length
12111 strings. The bounded model requires a maximum length. It is thus
12112 somewhat more limited than the unbounded model, but avoids the use of
12113 dynamic allocation or finalization.
12115 @item Ada.Strings.Fixed (A.4.3)
12116 This package provides facilities for handling fixed length strings.
12118 @item Ada.Strings.Maps (A.4.2)
12119 This package provides facilities for handling character mappings and
12120 arbitrarily defined subsets of characters. For instance it is useful in
12121 defining specialized translation tables.
12123 @item Ada.Strings.Maps.Constants (A.4.6)
12124 This package provides a standard set of predefined mappings and
12125 predefined character sets. For example, the standard upper to lower case
12126 conversion table is found in this package. Note that upper to lower case
12127 conversion is non-trivial if you want to take the entire set of
12128 characters, including extended characters like E with an acute accent,
12129 into account. You should use the mappings in this package (rather than
12130 adding 32 yourself) to do case mappings.
12132 @item Ada.Strings.Unbounded (A.4.5)
12133 This package provides facilities for handling variable length
12134 strings. The unbounded model allows arbitrary length strings, but
12135 requires the use of dynamic allocation and finalization.
12137 @item Ada.Strings.Wide_Bounded (A.4.7)
12138 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12139 @itemx Ada.Strings.Wide_Maps (A.4.7)
12140 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12141 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12142 These packages provide analogous capabilities to the corresponding
12143 packages without @samp{Wide_} in the name, but operate with the types
12144 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12145 and @code{Character}.
12147 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12148 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12149 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12150 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12151 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12152 These packages provide analogous capabilities to the corresponding
12153 packages without @samp{Wide_} in the name, but operate with the types
12154 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12155 of @code{String} and @code{Character}.
12157 @item Ada.Synchronous_Task_Control (D.10)
12158 This package provides some standard facilities for controlling task
12159 communication in a synchronous manner.
12162 This package contains definitions for manipulation of the tags of tagged
12165 @item Ada.Task_Attributes
12166 This package provides the capability of associating arbitrary
12167 task-specific data with separate tasks.
12170 This package provides basic text input-output capabilities for
12171 character, string and numeric data. The subpackages of this
12172 package are listed next.
12174 @item Ada.Text_IO.Decimal_IO
12175 Provides input-output facilities for decimal fixed-point types
12177 @item Ada.Text_IO.Enumeration_IO
12178 Provides input-output facilities for enumeration types.
12180 @item Ada.Text_IO.Fixed_IO
12181 Provides input-output facilities for ordinary fixed-point types.
12183 @item Ada.Text_IO.Float_IO
12184 Provides input-output facilities for float types. The following
12185 predefined instantiations of this generic package are available:
12189 @code{Short_Float_Text_IO}
12191 @code{Float_Text_IO}
12193 @code{Long_Float_Text_IO}
12196 @item Ada.Text_IO.Integer_IO
12197 Provides input-output facilities for integer types. The following
12198 predefined instantiations of this generic package are available:
12201 @item Short_Short_Integer
12202 @code{Ada.Short_Short_Integer_Text_IO}
12203 @item Short_Integer
12204 @code{Ada.Short_Integer_Text_IO}
12206 @code{Ada.Integer_Text_IO}
12208 @code{Ada.Long_Integer_Text_IO}
12209 @item Long_Long_Integer
12210 @code{Ada.Long_Long_Integer_Text_IO}
12213 @item Ada.Text_IO.Modular_IO
12214 Provides input-output facilities for modular (unsigned) types
12216 @item Ada.Text_IO.Complex_IO (G.1.3)
12217 This package provides basic text input-output capabilities for complex
12220 @item Ada.Text_IO.Editing (F.3.3)
12221 This package contains routines for edited output, analogous to the use
12222 of pictures in COBOL@. The picture formats used by this package are a
12223 close copy of the facility in COBOL@.
12225 @item Ada.Text_IO.Text_Streams (A.12.2)
12226 This package provides a facility that allows Text_IO files to be treated
12227 as streams, so that the stream attributes can be used for writing
12228 arbitrary data, including binary data, to Text_IO files.
12230 @item Ada.Unchecked_Conversion (13.9)
12231 This generic package allows arbitrary conversion from one type to
12232 another of the same size, providing for breaking the type safety in
12233 special circumstances.
12235 If the types have the same Size (more accurately the same Value_Size),
12236 then the effect is simply to transfer the bits from the source to the
12237 target type without any modification. This usage is well defined, and
12238 for simple types whose representation is typically the same across
12239 all implementations, gives a portable method of performing such
12242 If the types do not have the same size, then the result is implementation
12243 defined, and thus may be non-portable. The following describes how GNAT
12244 handles such unchecked conversion cases.
12246 If the types are of different sizes, and are both discrete types, then
12247 the effect is of a normal type conversion without any constraint checking.
12248 In particular if the result type has a larger size, the result will be
12249 zero or sign extended. If the result type has a smaller size, the result
12250 will be truncated by ignoring high order bits.
12252 If the types are of different sizes, and are not both discrete types,
12253 then the conversion works as though pointers were created to the source
12254 and target, and the pointer value is converted. The effect is that bits
12255 are copied from successive low order storage units and bits of the source
12256 up to the length of the target type.
12258 A warning is issued if the lengths differ, since the effect in this
12259 case is implementation dependent, and the above behavior may not match
12260 that of some other compiler.
12262 A pointer to one type may be converted to a pointer to another type using
12263 unchecked conversion. The only case in which the effect is undefined is
12264 when one or both pointers are pointers to unconstrained array types. In
12265 this case, the bounds information may get incorrectly transferred, and in
12266 particular, GNAT uses double size pointers for such types, and it is
12267 meaningless to convert between such pointer types. GNAT will issue a
12268 warning if the alignment of the target designated type is more strict
12269 than the alignment of the source designated type (since the result may
12270 be unaligned in this case).
12272 A pointer other than a pointer to an unconstrained array type may be
12273 converted to and from System.Address. Such usage is common in Ada 83
12274 programs, but note that Ada.Address_To_Access_Conversions is the
12275 preferred method of performing such conversions in Ada 95 and Ada 2005.
12277 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12278 used in conjunction with pointers to unconstrained objects, since
12279 the bounds information cannot be handled correctly in this case.
12281 @item Ada.Unchecked_Deallocation (13.11.2)
12282 This generic package allows explicit freeing of storage previously
12283 allocated by use of an allocator.
12285 @item Ada.Wide_Text_IO (A.11)
12286 This package is similar to @code{Ada.Text_IO}, except that the external
12287 file supports wide character representations, and the internal types are
12288 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12289 and @code{String}. It contains generic subpackages listed next.
12291 @item Ada.Wide_Text_IO.Decimal_IO
12292 Provides input-output facilities for decimal fixed-point types
12294 @item Ada.Wide_Text_IO.Enumeration_IO
12295 Provides input-output facilities for enumeration types.
12297 @item Ada.Wide_Text_IO.Fixed_IO
12298 Provides input-output facilities for ordinary fixed-point types.
12300 @item Ada.Wide_Text_IO.Float_IO
12301 Provides input-output facilities for float types. The following
12302 predefined instantiations of this generic package are available:
12306 @code{Short_Float_Wide_Text_IO}
12308 @code{Float_Wide_Text_IO}
12310 @code{Long_Float_Wide_Text_IO}
12313 @item Ada.Wide_Text_IO.Integer_IO
12314 Provides input-output facilities for integer types. The following
12315 predefined instantiations of this generic package are available:
12318 @item Short_Short_Integer
12319 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12320 @item Short_Integer
12321 @code{Ada.Short_Integer_Wide_Text_IO}
12323 @code{Ada.Integer_Wide_Text_IO}
12325 @code{Ada.Long_Integer_Wide_Text_IO}
12326 @item Long_Long_Integer
12327 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12330 @item Ada.Wide_Text_IO.Modular_IO
12331 Provides input-output facilities for modular (unsigned) types
12333 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12334 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12335 external file supports wide character representations.
12337 @item Ada.Wide_Text_IO.Editing (F.3.4)
12338 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12339 types are @code{Wide_Character} and @code{Wide_String} instead of
12340 @code{Character} and @code{String}.
12342 @item Ada.Wide_Text_IO.Streams (A.12.3)
12343 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12344 types are @code{Wide_Character} and @code{Wide_String} instead of
12345 @code{Character} and @code{String}.
12347 @item Ada.Wide_Wide_Text_IO (A.11)
12348 This package is similar to @code{Ada.Text_IO}, except that the external
12349 file supports wide character representations, and the internal types are
12350 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12351 and @code{String}. It contains generic subpackages listed next.
12353 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12354 Provides input-output facilities for decimal fixed-point types
12356 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12357 Provides input-output facilities for enumeration types.
12359 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12360 Provides input-output facilities for ordinary fixed-point types.
12362 @item Ada.Wide_Wide_Text_IO.Float_IO
12363 Provides input-output facilities for float types. The following
12364 predefined instantiations of this generic package are available:
12368 @code{Short_Float_Wide_Wide_Text_IO}
12370 @code{Float_Wide_Wide_Text_IO}
12372 @code{Long_Float_Wide_Wide_Text_IO}
12375 @item Ada.Wide_Wide_Text_IO.Integer_IO
12376 Provides input-output facilities for integer types. The following
12377 predefined instantiations of this generic package are available:
12380 @item Short_Short_Integer
12381 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12382 @item Short_Integer
12383 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12385 @code{Ada.Integer_Wide_Wide_Text_IO}
12387 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12388 @item Long_Long_Integer
12389 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12392 @item Ada.Wide_Wide_Text_IO.Modular_IO
12393 Provides input-output facilities for modular (unsigned) types
12395 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12396 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12397 external file supports wide character representations.
12399 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12400 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12401 types are @code{Wide_Character} and @code{Wide_String} instead of
12402 @code{Character} and @code{String}.
12404 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12405 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12406 types are @code{Wide_Character} and @code{Wide_String} instead of
12407 @code{Character} and @code{String}.
12410 @node The Implementation of Standard I/O
12411 @chapter The Implementation of Standard I/O
12414 GNAT implements all the required input-output facilities described in
12415 A.6 through A.14. These sections of the Ada Reference Manual describe the
12416 required behavior of these packages from the Ada point of view, and if
12417 you are writing a portable Ada program that does not need to know the
12418 exact manner in which Ada maps to the outside world when it comes to
12419 reading or writing external files, then you do not need to read this
12420 chapter. As long as your files are all regular files (not pipes or
12421 devices), and as long as you write and read the files only from Ada, the
12422 description in the Ada Reference Manual is sufficient.
12424 However, if you want to do input-output to pipes or other devices, such
12425 as the keyboard or screen, or if the files you are dealing with are
12426 either generated by some other language, or to be read by some other
12427 language, then you need to know more about the details of how the GNAT
12428 implementation of these input-output facilities behaves.
12430 In this chapter we give a detailed description of exactly how GNAT
12431 interfaces to the file system. As always, the sources of the system are
12432 available to you for answering questions at an even more detailed level,
12433 but for most purposes the information in this chapter will suffice.
12435 Another reason that you may need to know more about how input-output is
12436 implemented arises when you have a program written in mixed languages
12437 where, for example, files are shared between the C and Ada sections of
12438 the same program. GNAT provides some additional facilities, in the form
12439 of additional child library packages, that facilitate this sharing, and
12440 these additional facilities are also described in this chapter.
12443 * Standard I/O Packages::
12449 * Wide_Wide_Text_IO::
12451 * Text Translation::
12453 * Filenames encoding::
12455 * Operations on C Streams::
12456 * Interfacing to C Streams::
12459 @node Standard I/O Packages
12460 @section Standard I/O Packages
12463 The Standard I/O packages described in Annex A for
12469 Ada.Text_IO.Complex_IO
12471 Ada.Text_IO.Text_Streams
12475 Ada.Wide_Text_IO.Complex_IO
12477 Ada.Wide_Text_IO.Text_Streams
12479 Ada.Wide_Wide_Text_IO
12481 Ada.Wide_Wide_Text_IO.Complex_IO
12483 Ada.Wide_Wide_Text_IO.Text_Streams
12493 are implemented using the C
12494 library streams facility; where
12498 All files are opened using @code{fopen}.
12500 All input/output operations use @code{fread}/@code{fwrite}.
12504 There is no internal buffering of any kind at the Ada library level. The only
12505 buffering is that provided at the system level in the implementation of the
12506 library routines that support streams. This facilitates shared use of these
12507 streams by mixed language programs. Note though that system level buffering is
12508 explicitly enabled at elaboration of the standard I/O packages and that can
12509 have an impact on mixed language programs, in particular those using I/O before
12510 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12511 the Ada elaboration routine before performing any I/O or when impractical,
12512 flush the common I/O streams and in particular Standard_Output before
12513 elaborating the Ada code.
12516 @section FORM Strings
12519 The format of a FORM string in GNAT is:
12522 "keyword=value,keyword=value,@dots{},keyword=value"
12526 where letters may be in upper or lower case, and there are no spaces
12527 between values. The order of the entries is not important. Currently
12528 the following keywords defined.
12531 TEXT_TRANSLATION=[YES|NO]
12533 WCEM=[n|h|u|s|e|8|b]
12534 ENCODING=[UTF8|8BITS]
12538 The use of these parameters is described later in this section.
12544 Direct_IO can only be instantiated for definite types. This is a
12545 restriction of the Ada language, which means that the records are fixed
12546 length (the length being determined by @code{@var{type}'Size}, rounded
12547 up to the next storage unit boundary if necessary).
12549 The records of a Direct_IO file are simply written to the file in index
12550 sequence, with the first record starting at offset zero, and subsequent
12551 records following. There is no control information of any kind. For
12552 example, if 32-bit integers are being written, each record takes
12553 4-bytes, so the record at index @var{K} starts at offset
12554 (@var{K}@minus{}1)*4.
12556 There is no limit on the size of Direct_IO files, they are expanded as
12557 necessary to accommodate whatever records are written to the file.
12559 @node Sequential_IO
12560 @section Sequential_IO
12563 Sequential_IO may be instantiated with either a definite (constrained)
12564 or indefinite (unconstrained) type.
12566 For the definite type case, the elements written to the file are simply
12567 the memory images of the data values with no control information of any
12568 kind. The resulting file should be read using the same type, no validity
12569 checking is performed on input.
12571 For the indefinite type case, the elements written consist of two
12572 parts. First is the size of the data item, written as the memory image
12573 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12574 the data value. The resulting file can only be read using the same
12575 (unconstrained) type. Normal assignment checks are performed on these
12576 read operations, and if these checks fail, @code{Data_Error} is
12577 raised. In particular, in the array case, the lengths must match, and in
12578 the variant record case, if the variable for a particular read operation
12579 is constrained, the discriminants must match.
12581 Note that it is not possible to use Sequential_IO to write variable
12582 length array items, and then read the data back into different length
12583 arrays. For example, the following will raise @code{Data_Error}:
12585 @smallexample @c ada
12586 package IO is new Sequential_IO (String);
12591 IO.Write (F, "hello!")
12592 IO.Reset (F, Mode=>In_File);
12599 On some Ada implementations, this will print @code{hell}, but the program is
12600 clearly incorrect, since there is only one element in the file, and that
12601 element is the string @code{hello!}.
12603 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12604 using Stream_IO, and this is the preferred mechanism. In particular, the
12605 above program fragment rewritten to use Stream_IO will work correctly.
12611 Text_IO files consist of a stream of characters containing the following
12612 special control characters:
12615 LF (line feed, 16#0A#) Line Mark
12616 FF (form feed, 16#0C#) Page Mark
12620 A canonical Text_IO file is defined as one in which the following
12621 conditions are met:
12625 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12629 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12630 end of a page and consequently can appear only immediately following a
12631 @code{LF} (line mark) character.
12634 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12635 (line mark, page mark). In the former case, the page mark is implicitly
12636 assumed to be present.
12640 A file written using Text_IO will be in canonical form provided that no
12641 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12642 or @code{Put_Line}. There will be no @code{FF} character at the end of
12643 the file unless an explicit @code{New_Page} operation was performed
12644 before closing the file.
12646 A canonical Text_IO file that is a regular file (i.e., not a device or a
12647 pipe) can be read using any of the routines in Text_IO@. The
12648 semantics in this case will be exactly as defined in the Ada Reference
12649 Manual, and all the routines in Text_IO are fully implemented.
12651 A text file that does not meet the requirements for a canonical Text_IO
12652 file has one of the following:
12656 The file contains @code{FF} characters not immediately following a
12657 @code{LF} character.
12660 The file contains @code{LF} or @code{FF} characters written by
12661 @code{Put} or @code{Put_Line}, which are not logically considered to be
12662 line marks or page marks.
12665 The file ends in a character other than @code{LF} or @code{FF},
12666 i.e.@: there is no explicit line mark or page mark at the end of the file.
12670 Text_IO can be used to read such non-standard text files but subprograms
12671 to do with line or page numbers do not have defined meanings. In
12672 particular, a @code{FF} character that does not follow a @code{LF}
12673 character may or may not be treated as a page mark from the point of
12674 view of page and line numbering. Every @code{LF} character is considered
12675 to end a line, and there is an implied @code{LF} character at the end of
12679 * Text_IO Stream Pointer Positioning::
12680 * Text_IO Reading and Writing Non-Regular Files::
12682 * Treating Text_IO Files as Streams::
12683 * Text_IO Extensions::
12684 * Text_IO Facilities for Unbounded Strings::
12687 @node Text_IO Stream Pointer Positioning
12688 @subsection Stream Pointer Positioning
12691 @code{Ada.Text_IO} has a definition of current position for a file that
12692 is being read. No internal buffering occurs in Text_IO, and usually the
12693 physical position in the stream used to implement the file corresponds
12694 to this logical position defined by Text_IO@. There are two exceptions:
12698 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12699 is positioned past the @code{LF} (line mark) that precedes the page
12700 mark. Text_IO maintains an internal flag so that subsequent read
12701 operations properly handle the logical position which is unchanged by
12702 the @code{End_Of_Page} call.
12705 After a call to @code{End_Of_File} that returns @code{True}, if the
12706 Text_IO file was positioned before the line mark at the end of file
12707 before the call, then the logical position is unchanged, but the stream
12708 is physically positioned right at the end of file (past the line mark,
12709 and past a possible page mark following the line mark. Again Text_IO
12710 maintains internal flags so that subsequent read operations properly
12711 handle the logical position.
12715 These discrepancies have no effect on the observable behavior of
12716 Text_IO, but if a single Ada stream is shared between a C program and
12717 Ada program, or shared (using @samp{shared=yes} in the form string)
12718 between two Ada files, then the difference may be observable in some
12721 @node Text_IO Reading and Writing Non-Regular Files
12722 @subsection Reading and Writing Non-Regular Files
12725 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
12726 can be used for reading and writing. Writing is not affected and the
12727 sequence of characters output is identical to the normal file case, but
12728 for reading, the behavior of Text_IO is modified to avoid undesirable
12729 look-ahead as follows:
12731 An input file that is not a regular file is considered to have no page
12732 marks. Any @code{Ascii.FF} characters (the character normally used for a
12733 page mark) appearing in the file are considered to be data
12734 characters. In particular:
12738 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12739 following a line mark. If a page mark appears, it will be treated as a
12743 This avoids the need to wait for an extra character to be typed or
12744 entered from the pipe to complete one of these operations.
12747 @code{End_Of_Page} always returns @code{False}
12750 @code{End_Of_File} will return @code{False} if there is a page mark at
12751 the end of the file.
12755 Output to non-regular files is the same as for regular files. Page marks
12756 may be written to non-regular files using @code{New_Page}, but as noted
12757 above they will not be treated as page marks on input if the output is
12758 piped to another Ada program.
12760 Another important discrepancy when reading non-regular files is that the end
12761 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
12762 pressing the @key{EOT} key,
12764 is signaled once (i.e.@: the test @code{End_Of_File}
12765 will yield @code{True}, or a read will
12766 raise @code{End_Error}), but then reading can resume
12767 to read data past that end of
12768 file indication, until another end of file indication is entered.
12770 @node Get_Immediate
12771 @subsection Get_Immediate
12772 @cindex Get_Immediate
12775 Get_Immediate returns the next character (including control characters)
12776 from the input file. In particular, Get_Immediate will return LF or FF
12777 characters used as line marks or page marks. Such operations leave the
12778 file positioned past the control character, and it is thus not treated
12779 as having its normal function. This means that page, line and column
12780 counts after this kind of Get_Immediate call are set as though the mark
12781 did not occur. In the case where a Get_Immediate leaves the file
12782 positioned between the line mark and page mark (which is not normally
12783 possible), it is undefined whether the FF character will be treated as a
12786 @node Treating Text_IO Files as Streams
12787 @subsection Treating Text_IO Files as Streams
12788 @cindex Stream files
12791 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12792 as a stream. Data written to a Text_IO file in this stream mode is
12793 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
12794 16#0C# (@code{FF}), the resulting file may have non-standard
12795 format. Similarly if read operations are used to read from a Text_IO
12796 file treated as a stream, then @code{LF} and @code{FF} characters may be
12797 skipped and the effect is similar to that described above for
12798 @code{Get_Immediate}.
12800 @node Text_IO Extensions
12801 @subsection Text_IO Extensions
12802 @cindex Text_IO extensions
12805 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12806 to the standard @code{Text_IO} package:
12809 @item function File_Exists (Name : String) return Boolean;
12810 Determines if a file of the given name exists.
12812 @item function Get_Line return String;
12813 Reads a string from the standard input file. The value returned is exactly
12814 the length of the line that was read.
12816 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12817 Similar, except that the parameter File specifies the file from which
12818 the string is to be read.
12822 @node Text_IO Facilities for Unbounded Strings
12823 @subsection Text_IO Facilities for Unbounded Strings
12824 @cindex Text_IO for unbounded strings
12825 @cindex Unbounded_String, Text_IO operations
12828 The package @code{Ada.Strings.Unbounded.Text_IO}
12829 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12830 subprograms useful for Text_IO operations on unbounded strings:
12834 @item function Get_Line (File : File_Type) return Unbounded_String;
12835 Reads a line from the specified file
12836 and returns the result as an unbounded string.
12838 @item procedure Put (File : File_Type; U : Unbounded_String);
12839 Writes the value of the given unbounded string to the specified file
12840 Similar to the effect of
12841 @code{Put (To_String (U))} except that an extra copy is avoided.
12843 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12844 Writes the value of the given unbounded string to the specified file,
12845 followed by a @code{New_Line}.
12846 Similar to the effect of @code{Put_Line (To_String (U))} except
12847 that an extra copy is avoided.
12851 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12852 and is optional. If the parameter is omitted, then the standard input or
12853 output file is referenced as appropriate.
12855 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12856 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12857 @code{Wide_Text_IO} functionality for unbounded wide strings.
12859 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12860 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12861 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12864 @section Wide_Text_IO
12867 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12868 both input and output files may contain special sequences that represent
12869 wide character values. The encoding scheme for a given file may be
12870 specified using a FORM parameter:
12877 as part of the FORM string (WCEM = wide character encoding method),
12878 where @var{x} is one of the following characters
12884 Upper half encoding
12896 The encoding methods match those that
12897 can be used in a source
12898 program, but there is no requirement that the encoding method used for
12899 the source program be the same as the encoding method used for files,
12900 and different files may use different encoding methods.
12902 The default encoding method for the standard files, and for opened files
12903 for which no WCEM parameter is given in the FORM string matches the
12904 wide character encoding specified for the main program (the default
12905 being brackets encoding if no coding method was specified with -gnatW).
12909 In this encoding, a wide character is represented by a five character
12917 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12918 characters (using upper case letters) of the wide character code. For
12919 example, ESC A345 is used to represent the wide character with code
12920 16#A345#. This scheme is compatible with use of the full
12921 @code{Wide_Character} set.
12923 @item Upper Half Coding
12924 The wide character with encoding 16#abcd#, where the upper bit is on
12925 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12926 16#cd#. The second byte may never be a format control character, but is
12927 not required to be in the upper half. This method can be also used for
12928 shift-JIS or EUC where the internal coding matches the external coding.
12930 @item Shift JIS Coding
12931 A wide character is represented by a two character sequence 16#ab# and
12932 16#cd#, with the restrictions described for upper half encoding as
12933 described above. The internal character code is the corresponding JIS
12934 character according to the standard algorithm for Shift-JIS
12935 conversion. Only characters defined in the JIS code set table can be
12936 used with this encoding method.
12939 A wide character is represented by a two character sequence 16#ab# and
12940 16#cd#, with both characters being in the upper half. The internal
12941 character code is the corresponding JIS character according to the EUC
12942 encoding algorithm. Only characters defined in the JIS code set table
12943 can be used with this encoding method.
12946 A wide character is represented using
12947 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12948 10646-1/Am.2. Depending on the character value, the representation
12949 is a one, two, or three byte sequence:
12952 16#0000#-16#007f#: 2#0xxxxxxx#
12953 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12954 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12958 where the @var{xxx} bits correspond to the left-padded bits of the
12959 16-bit character value. Note that all lower half ASCII characters
12960 are represented as ASCII bytes and all upper half characters and
12961 other wide characters are represented as sequences of upper-half
12962 (The full UTF-8 scheme allows for encoding 31-bit characters as
12963 6-byte sequences, but in this implementation, all UTF-8 sequences
12964 of four or more bytes length will raise a Constraint_Error, as
12965 will all invalid UTF-8 sequences.)
12967 @item Brackets Coding
12968 In this encoding, a wide character is represented by the following eight
12969 character sequence:
12976 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12977 characters (using uppercase letters) of the wide character code. For
12978 example, @code{["A345"]} is used to represent the wide character with code
12980 This scheme is compatible with use of the full Wide_Character set.
12981 On input, brackets coding can also be used for upper half characters,
12982 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
12983 is only used for wide characters with a code greater than @code{16#FF#}.
12985 Note that brackets coding is not normally used in the context of
12986 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12987 a portable way of encoding source files. In the context of Wide_Text_IO
12988 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12989 any instance of the left bracket character other than to encode wide
12990 character values using the brackets encoding method. In practice it is
12991 expected that some standard wide character encoding method such
12992 as UTF-8 will be used for text input output.
12994 If brackets notation is used, then any occurrence of a left bracket
12995 in the input file which is not the start of a valid wide character
12996 sequence will cause Constraint_Error to be raised. It is possible to
12997 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12998 input will interpret this as a left bracket.
13000 However, when a left bracket is output, it will be output as a left bracket
13001 and not as ["5B"]. We make this decision because for normal use of
13002 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13003 brackets. For example, if we write:
13006 Put_Line ("Start of output [first run]");
13010 we really do not want to have the left bracket in this message clobbered so
13011 that the output reads:
13014 Start of output ["5B"]first run]
13018 In practice brackets encoding is reasonably useful for normal Put_Line use
13019 since we won't get confused between left brackets and wide character
13020 sequences in the output. But for input, or when files are written out
13021 and read back in, it really makes better sense to use one of the standard
13022 encoding methods such as UTF-8.
13027 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13028 not all wide character
13029 values can be represented. An attempt to output a character that cannot
13030 be represented using the encoding scheme for the file causes
13031 Constraint_Error to be raised. An invalid wide character sequence on
13032 input also causes Constraint_Error to be raised.
13035 * Wide_Text_IO Stream Pointer Positioning::
13036 * Wide_Text_IO Reading and Writing Non-Regular Files::
13039 @node Wide_Text_IO Stream Pointer Positioning
13040 @subsection Stream Pointer Positioning
13043 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13044 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13047 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13048 normal lower ASCII set (i.e.@: a character in the range:
13050 @smallexample @c ada
13051 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13055 then although the logical position of the file pointer is unchanged by
13056 the @code{Look_Ahead} call, the stream is physically positioned past the
13057 wide character sequence. Again this is to avoid the need for buffering
13058 or backup, and all @code{Wide_Text_IO} routines check the internal
13059 indication that this situation has occurred so that this is not visible
13060 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13061 can be observed if the wide text file shares a stream with another file.
13063 @node Wide_Text_IO Reading and Writing Non-Regular Files
13064 @subsection Reading and Writing Non-Regular Files
13067 As in the case of Text_IO, when a non-regular file is read, it is
13068 assumed that the file contains no page marks (any form characters are
13069 treated as data characters), and @code{End_Of_Page} always returns
13070 @code{False}. Similarly, the end of file indication is not sticky, so
13071 it is possible to read beyond an end of file.
13073 @node Wide_Wide_Text_IO
13074 @section Wide_Wide_Text_IO
13077 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13078 both input and output files may contain special sequences that represent
13079 wide wide character values. The encoding scheme for a given file may be
13080 specified using a FORM parameter:
13087 as part of the FORM string (WCEM = wide character encoding method),
13088 where @var{x} is one of the following characters
13094 Upper half encoding
13106 The encoding methods match those that
13107 can be used in a source
13108 program, but there is no requirement that the encoding method used for
13109 the source program be the same as the encoding method used for files,
13110 and different files may use different encoding methods.
13112 The default encoding method for the standard files, and for opened files
13113 for which no WCEM parameter is given in the FORM string matches the
13114 wide character encoding specified for the main program (the default
13115 being brackets encoding if no coding method was specified with -gnatW).
13120 A wide character is represented using
13121 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13122 10646-1/Am.2. Depending on the character value, the representation
13123 is a one, two, three, or four byte sequence:
13126 16#000000#-16#00007f#: 2#0xxxxxxx#
13127 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13128 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13129 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13133 where the @var{xxx} bits correspond to the left-padded bits of the
13134 21-bit character value. Note that all lower half ASCII characters
13135 are represented as ASCII bytes and all upper half characters and
13136 other wide characters are represented as sequences of upper-half
13139 @item Brackets Coding
13140 In this encoding, a wide wide character is represented by the following eight
13141 character sequence if is in wide character range
13147 and by the following ten character sequence if not
13150 [ " a b c d e f " ]
13154 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13155 are the four or six hexadecimal
13156 characters (using uppercase letters) of the wide wide character code. For
13157 example, @code{["01A345"]} is used to represent the wide wide character
13158 with code @code{16#01A345#}.
13160 This scheme is compatible with use of the full Wide_Wide_Character set.
13161 On input, brackets coding can also be used for upper half characters,
13162 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13163 is only used for wide characters with a code greater than @code{16#FF#}.
13168 If is also possible to use the other Wide_Character encoding methods,
13169 such as Shift-JIS, but the other schemes cannot support the full range
13170 of wide wide characters.
13171 An attempt to output a character that cannot
13172 be represented using the encoding scheme for the file causes
13173 Constraint_Error to be raised. An invalid wide character sequence on
13174 input also causes Constraint_Error to be raised.
13177 * Wide_Wide_Text_IO Stream Pointer Positioning::
13178 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13181 @node Wide_Wide_Text_IO Stream Pointer Positioning
13182 @subsection Stream Pointer Positioning
13185 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13186 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13189 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13190 normal lower ASCII set (i.e.@: a character in the range:
13192 @smallexample @c ada
13193 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13197 then although the logical position of the file pointer is unchanged by
13198 the @code{Look_Ahead} call, the stream is physically positioned past the
13199 wide character sequence. Again this is to avoid the need for buffering
13200 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13201 indication that this situation has occurred so that this is not visible
13202 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13203 can be observed if the wide text file shares a stream with another file.
13205 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13206 @subsection Reading and Writing Non-Regular Files
13209 As in the case of Text_IO, when a non-regular file is read, it is
13210 assumed that the file contains no page marks (any form characters are
13211 treated as data characters), and @code{End_Of_Page} always returns
13212 @code{False}. Similarly, the end of file indication is not sticky, so
13213 it is possible to read beyond an end of file.
13219 A stream file is a sequence of bytes, where individual elements are
13220 written to the file as described in the Ada Reference Manual. The type
13221 @code{Stream_Element} is simply a byte. There are two ways to read or
13222 write a stream file.
13226 The operations @code{Read} and @code{Write} directly read or write a
13227 sequence of stream elements with no control information.
13230 The stream attributes applied to a stream file transfer data in the
13231 manner described for stream attributes.
13234 @node Text Translation
13235 @section Text Translation
13238 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13239 passed to Text_IO.Create and Text_IO.Open:
13240 @samp{Text_Translation=@var{Yes}} is the default, which means to
13241 translate LF to/from CR/LF on Windows systems.
13242 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13243 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13244 may be used to create Unix-style files on
13245 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13249 @section Shared Files
13252 Section A.14 of the Ada Reference Manual allows implementations to
13253 provide a wide variety of behavior if an attempt is made to access the
13254 same external file with two or more internal files.
13256 To provide a full range of functionality, while at the same time
13257 minimizing the problems of portability caused by this implementation
13258 dependence, GNAT handles file sharing as follows:
13262 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13263 to open two or more files with the same full name is considered an error
13264 and is not supported. The exception @code{Use_Error} will be
13265 raised. Note that a file that is not explicitly closed by the program
13266 remains open until the program terminates.
13269 If the form parameter @samp{shared=no} appears in the form string, the
13270 file can be opened or created with its own separate stream identifier,
13271 regardless of whether other files sharing the same external file are
13272 opened. The exact effect depends on how the C stream routines handle
13273 multiple accesses to the same external files using separate streams.
13276 If the form parameter @samp{shared=yes} appears in the form string for
13277 each of two or more files opened using the same full name, the same
13278 stream is shared between these files, and the semantics are as described
13279 in Ada Reference Manual, Section A.14.
13283 When a program that opens multiple files with the same name is ported
13284 from another Ada compiler to GNAT, the effect will be that
13285 @code{Use_Error} is raised.
13287 The documentation of the original compiler and the documentation of the
13288 program should then be examined to determine if file sharing was
13289 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13290 and @code{Create} calls as required.
13292 When a program is ported from GNAT to some other Ada compiler, no
13293 special attention is required unless the @samp{shared=@var{xxx}} form
13294 parameter is used in the program. In this case, you must examine the
13295 documentation of the new compiler to see if it supports the required
13296 file sharing semantics, and form strings modified appropriately. Of
13297 course it may be the case that the program cannot be ported if the
13298 target compiler does not support the required functionality. The best
13299 approach in writing portable code is to avoid file sharing (and hence
13300 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13303 One common use of file sharing in Ada 83 is the use of instantiations of
13304 Sequential_IO on the same file with different types, to achieve
13305 heterogeneous input-output. Although this approach will work in GNAT if
13306 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13307 for this purpose (using the stream attributes)
13309 @node Filenames encoding
13310 @section Filenames encoding
13313 An encoding form parameter can be used to specify the filename
13314 encoding @samp{encoding=@var{xxx}}.
13318 If the form parameter @samp{encoding=utf8} appears in the form string, the
13319 filename must be encoded in UTF-8.
13322 If the form parameter @samp{encoding=8bits} appears in the form
13323 string, the filename must be a standard 8bits string.
13326 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13327 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13328 variable. And if not set @samp{utf8} is assumed.
13332 The current system Windows ANSI code page.
13337 This encoding form parameter is only supported on the Windows
13338 platform. On the other Operating Systems the run-time is supporting
13342 @section Open Modes
13345 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13346 using the mode shown in the following table:
13349 @center @code{Open} and @code{Create} Call Modes
13351 @b{OPEN } @b{CREATE}
13352 Append_File "r+" "w+"
13354 Out_File (Direct_IO) "r+" "w"
13355 Out_File (all other cases) "w" "w"
13356 Inout_File "r+" "w+"
13360 If text file translation is required, then either @samp{b} or @samp{t}
13361 is added to the mode, depending on the setting of Text. Text file
13362 translation refers to the mapping of CR/LF sequences in an external file
13363 to LF characters internally. This mapping only occurs in DOS and
13364 DOS-like systems, and is not relevant to other systems.
13366 A special case occurs with Stream_IO@. As shown in the above table, the
13367 file is initially opened in @samp{r} or @samp{w} mode for the
13368 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13369 subsequently requires switching from reading to writing or vice-versa,
13370 then the file is reopened in @samp{r+} mode to permit the required operation.
13372 @node Operations on C Streams
13373 @section Operations on C Streams
13374 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13375 access to the C library functions for operations on C streams:
13377 @smallexample @c adanocomment
13378 package Interfaces.C_Streams is
13379 -- Note: the reason we do not use the types that are in
13380 -- Interfaces.C is that we want to avoid dragging in the
13381 -- code in this unit if possible.
13382 subtype chars is System.Address;
13383 -- Pointer to null-terminated array of characters
13384 subtype FILEs is System.Address;
13385 -- Corresponds to the C type FILE*
13386 subtype voids is System.Address;
13387 -- Corresponds to the C type void*
13388 subtype int is Integer;
13389 subtype long is Long_Integer;
13390 -- Note: the above types are subtypes deliberately, and it
13391 -- is part of this spec that the above correspondences are
13392 -- guaranteed. This means that it is legitimate to, for
13393 -- example, use Integer instead of int. We provide these
13394 -- synonyms for clarity, but in some cases it may be
13395 -- convenient to use the underlying types (for example to
13396 -- avoid an unnecessary dependency of a spec on the spec
13398 type size_t is mod 2 ** Standard'Address_Size;
13399 NULL_Stream : constant FILEs;
13400 -- Value returned (NULL in C) to indicate an
13401 -- fdopen/fopen/tmpfile error
13402 ----------------------------------
13403 -- Constants Defined in stdio.h --
13404 ----------------------------------
13405 EOF : constant int;
13406 -- Used by a number of routines to indicate error or
13408 IOFBF : constant int;
13409 IOLBF : constant int;
13410 IONBF : constant int;
13411 -- Used to indicate buffering mode for setvbuf call
13412 SEEK_CUR : constant int;
13413 SEEK_END : constant int;
13414 SEEK_SET : constant int;
13415 -- Used to indicate origin for fseek call
13416 function stdin return FILEs;
13417 function stdout return FILEs;
13418 function stderr return FILEs;
13419 -- Streams associated with standard files
13420 --------------------------
13421 -- Standard C functions --
13422 --------------------------
13423 -- The functions selected below are ones that are
13424 -- available in UNIX (but not necessarily in ANSI C).
13425 -- These are very thin interfaces
13426 -- which copy exactly the C headers. For more
13427 -- documentation on these functions, see the Microsoft C
13428 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13429 -- ISBN 1-55615-225-6), which includes useful information
13430 -- on system compatibility.
13431 procedure clearerr (stream : FILEs);
13432 function fclose (stream : FILEs) return int;
13433 function fdopen (handle : int; mode : chars) return FILEs;
13434 function feof (stream : FILEs) return int;
13435 function ferror (stream : FILEs) return int;
13436 function fflush (stream : FILEs) return int;
13437 function fgetc (stream : FILEs) return int;
13438 function fgets (strng : chars; n : int; stream : FILEs)
13440 function fileno (stream : FILEs) return int;
13441 function fopen (filename : chars; Mode : chars)
13443 -- Note: to maintain target independence, use
13444 -- text_translation_required, a boolean variable defined in
13445 -- a-sysdep.c to deal with the target dependent text
13446 -- translation requirement. If this variable is set,
13447 -- then b/t should be appended to the standard mode
13448 -- argument to set the text translation mode off or on
13450 function fputc (C : int; stream : FILEs) return int;
13451 function fputs (Strng : chars; Stream : FILEs) return int;
13468 function ftell (stream : FILEs) return long;
13475 function isatty (handle : int) return int;
13476 procedure mktemp (template : chars);
13477 -- The return value (which is just a pointer to template)
13479 procedure rewind (stream : FILEs);
13480 function rmtmp return int;
13488 function tmpfile return FILEs;
13489 function ungetc (c : int; stream : FILEs) return int;
13490 function unlink (filename : chars) return int;
13491 ---------------------
13492 -- Extra functions --
13493 ---------------------
13494 -- These functions supply slightly thicker bindings than
13495 -- those above. They are derived from functions in the
13496 -- C Run-Time Library, but may do a bit more work than
13497 -- just directly calling one of the Library functions.
13498 function is_regular_file (handle : int) return int;
13499 -- Tests if given handle is for a regular file (result 1)
13500 -- or for a non-regular file (pipe or device, result 0).
13501 ---------------------------------
13502 -- Control of Text/Binary Mode --
13503 ---------------------------------
13504 -- If text_translation_required is true, then the following
13505 -- functions may be used to dynamically switch a file from
13506 -- binary to text mode or vice versa. These functions have
13507 -- no effect if text_translation_required is false (i.e.@: in
13508 -- normal UNIX mode). Use fileno to get a stream handle.
13509 procedure set_binary_mode (handle : int);
13510 procedure set_text_mode (handle : int);
13511 ----------------------------
13512 -- Full Path Name support --
13513 ----------------------------
13514 procedure full_name (nam : chars; buffer : chars);
13515 -- Given a NUL terminated string representing a file
13516 -- name, returns in buffer a NUL terminated string
13517 -- representing the full path name for the file name.
13518 -- On systems where it is relevant the drive is also
13519 -- part of the full path name. It is the responsibility
13520 -- of the caller to pass an actual parameter for buffer
13521 -- that is big enough for any full path name. Use
13522 -- max_path_len given below as the size of buffer.
13523 max_path_len : integer;
13524 -- Maximum length of an allowable full path name on the
13525 -- system, including a terminating NUL character.
13526 end Interfaces.C_Streams;
13529 @node Interfacing to C Streams
13530 @section Interfacing to C Streams
13533 The packages in this section permit interfacing Ada files to C Stream
13536 @smallexample @c ada
13537 with Interfaces.C_Streams;
13538 package Ada.Sequential_IO.C_Streams is
13539 function C_Stream (F : File_Type)
13540 return Interfaces.C_Streams.FILEs;
13542 (File : in out File_Type;
13543 Mode : in File_Mode;
13544 C_Stream : in Interfaces.C_Streams.FILEs;
13545 Form : in String := "");
13546 end Ada.Sequential_IO.C_Streams;
13548 with Interfaces.C_Streams;
13549 package Ada.Direct_IO.C_Streams is
13550 function C_Stream (F : File_Type)
13551 return Interfaces.C_Streams.FILEs;
13553 (File : in out File_Type;
13554 Mode : in File_Mode;
13555 C_Stream : in Interfaces.C_Streams.FILEs;
13556 Form : in String := "");
13557 end Ada.Direct_IO.C_Streams;
13559 with Interfaces.C_Streams;
13560 package Ada.Text_IO.C_Streams is
13561 function C_Stream (F : File_Type)
13562 return Interfaces.C_Streams.FILEs;
13564 (File : in out File_Type;
13565 Mode : in File_Mode;
13566 C_Stream : in Interfaces.C_Streams.FILEs;
13567 Form : in String := "");
13568 end Ada.Text_IO.C_Streams;
13570 with Interfaces.C_Streams;
13571 package Ada.Wide_Text_IO.C_Streams is
13572 function C_Stream (F : File_Type)
13573 return Interfaces.C_Streams.FILEs;
13575 (File : in out File_Type;
13576 Mode : in File_Mode;
13577 C_Stream : in Interfaces.C_Streams.FILEs;
13578 Form : in String := "");
13579 end Ada.Wide_Text_IO.C_Streams;
13581 with Interfaces.C_Streams;
13582 package Ada.Wide_Wide_Text_IO.C_Streams is
13583 function C_Stream (F : File_Type)
13584 return Interfaces.C_Streams.FILEs;
13586 (File : in out File_Type;
13587 Mode : in File_Mode;
13588 C_Stream : in Interfaces.C_Streams.FILEs;
13589 Form : in String := "");
13590 end Ada.Wide_Wide_Text_IO.C_Streams;
13592 with Interfaces.C_Streams;
13593 package Ada.Stream_IO.C_Streams is
13594 function C_Stream (F : File_Type)
13595 return Interfaces.C_Streams.FILEs;
13597 (File : in out File_Type;
13598 Mode : in File_Mode;
13599 C_Stream : in Interfaces.C_Streams.FILEs;
13600 Form : in String := "");
13601 end Ada.Stream_IO.C_Streams;
13605 In each of these six packages, the @code{C_Stream} function obtains the
13606 @code{FILE} pointer from a currently opened Ada file. It is then
13607 possible to use the @code{Interfaces.C_Streams} package to operate on
13608 this stream, or the stream can be passed to a C program which can
13609 operate on it directly. Of course the program is responsible for
13610 ensuring that only appropriate sequences of operations are executed.
13612 One particular use of relevance to an Ada program is that the
13613 @code{setvbuf} function can be used to control the buffering of the
13614 stream used by an Ada file. In the absence of such a call the standard
13615 default buffering is used.
13617 The @code{Open} procedures in these packages open a file giving an
13618 existing C Stream instead of a file name. Typically this stream is
13619 imported from a C program, allowing an Ada file to operate on an
13622 @node The GNAT Library
13623 @chapter The GNAT Library
13626 The GNAT library contains a number of general and special purpose packages.
13627 It represents functionality that the GNAT developers have found useful, and
13628 which is made available to GNAT users. The packages described here are fully
13629 supported, and upwards compatibility will be maintained in future releases,
13630 so you can use these facilities with the confidence that the same functionality
13631 will be available in future releases.
13633 The chapter here simply gives a brief summary of the facilities available.
13634 The full documentation is found in the spec file for the package. The full
13635 sources of these library packages, including both spec and body, are provided
13636 with all GNAT releases. For example, to find out the full specifications of
13637 the SPITBOL pattern matching capability, including a full tutorial and
13638 extensive examples, look in the @file{g-spipat.ads} file in the library.
13640 For each entry here, the package name (as it would appear in a @code{with}
13641 clause) is given, followed by the name of the corresponding spec file in
13642 parentheses. The packages are children in four hierarchies, @code{Ada},
13643 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13644 GNAT-specific hierarchy.
13646 Note that an application program should only use packages in one of these
13647 four hierarchies if the package is defined in the Ada Reference Manual,
13648 or is listed in this section of the GNAT Programmers Reference Manual.
13649 All other units should be considered internal implementation units and
13650 should not be directly @code{with}'ed by application code. The use of
13651 a @code{with} statement that references one of these internal implementation
13652 units makes an application potentially dependent on changes in versions
13653 of GNAT, and will generate a warning message.
13656 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13657 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13658 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13659 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13660 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13661 * Ada.Command_Line.Environment (a-colien.ads)::
13662 * Ada.Command_Line.Remove (a-colire.ads)::
13663 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13664 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13665 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13666 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13667 * Ada.Exceptions.Traceback (a-exctra.ads)::
13668 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13669 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13670 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13671 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13672 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13673 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13674 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13675 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13676 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13677 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13678 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13679 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13680 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13681 * GNAT.Altivec (g-altive.ads)::
13682 * GNAT.Altivec.Conversions (g-altcon.ads)::
13683 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13684 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13685 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13686 * GNAT.Array_Split (g-arrspl.ads)::
13687 * GNAT.AWK (g-awk.ads)::
13688 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13689 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13690 * GNAT.Bubble_Sort (g-bubsor.ads)::
13691 * GNAT.Bubble_Sort_A (g-busora.ads)::
13692 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13693 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13694 * GNAT.Byte_Swapping (g-bytswa.ads)::
13695 * GNAT.Calendar (g-calend.ads)::
13696 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13697 * GNAT.Case_Util (g-casuti.ads)::
13698 * GNAT.CGI (g-cgi.ads)::
13699 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13700 * GNAT.CGI.Debug (g-cgideb.ads)::
13701 * GNAT.Command_Line (g-comlin.ads)::
13702 * GNAT.Compiler_Version (g-comver.ads)::
13703 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13704 * GNAT.CRC32 (g-crc32.ads)::
13705 * GNAT.Current_Exception (g-curexc.ads)::
13706 * GNAT.Debug_Pools (g-debpoo.ads)::
13707 * GNAT.Debug_Utilities (g-debuti.ads)::
13708 * GNAT.Decode_String (g-decstr.ads)::
13709 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13710 * GNAT.Directory_Operations (g-dirope.ads)::
13711 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13712 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13713 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13714 * GNAT.Encode_String (g-encstr.ads)::
13715 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13716 * GNAT.Exception_Actions (g-excact.ads)::
13717 * GNAT.Exception_Traces (g-exctra.ads)::
13718 * GNAT.Exceptions (g-except.ads)::
13719 * GNAT.Expect (g-expect.ads)::
13720 * GNAT.Float_Control (g-flocon.ads)::
13721 * GNAT.Heap_Sort (g-heasor.ads)::
13722 * GNAT.Heap_Sort_A (g-hesora.ads)::
13723 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13724 * GNAT.HTable (g-htable.ads)::
13725 * GNAT.IO (g-io.ads)::
13726 * GNAT.IO_Aux (g-io_aux.ads)::
13727 * GNAT.Lock_Files (g-locfil.ads)::
13728 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
13729 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
13730 * GNAT.MD5 (g-md5.ads)::
13731 * GNAT.Memory_Dump (g-memdum.ads)::
13732 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13733 * GNAT.OS_Lib (g-os_lib.ads)::
13734 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13735 * GNAT.Random_Numbers (g-rannum.ads)::
13736 * GNAT.Regexp (g-regexp.ads)::
13737 * GNAT.Registry (g-regist.ads)::
13738 * GNAT.Regpat (g-regpat.ads)::
13739 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13740 * GNAT.Semaphores (g-semaph.ads)::
13741 * GNAT.Serial_Communications (g-sercom.ads)::
13742 * GNAT.SHA1 (g-sha1.ads)::
13743 * GNAT.SHA224 (g-sha224.ads)::
13744 * GNAT.SHA256 (g-sha256.ads)::
13745 * GNAT.SHA384 (g-sha384.ads)::
13746 * GNAT.SHA512 (g-sha512.ads)::
13747 * GNAT.Signals (g-signal.ads)::
13748 * GNAT.Sockets (g-socket.ads)::
13749 * GNAT.Source_Info (g-souinf.ads)::
13750 * GNAT.Spelling_Checker (g-speche.ads)::
13751 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13752 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13753 * GNAT.Spitbol (g-spitbo.ads)::
13754 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13755 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13756 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13757 * GNAT.SSE (g-sse.ads)::
13758 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13759 * GNAT.Strings (g-string.ads)::
13760 * GNAT.String_Split (g-strspl.ads)::
13761 * GNAT.Table (g-table.ads)::
13762 * GNAT.Task_Lock (g-tasloc.ads)::
13763 * GNAT.Threads (g-thread.ads)::
13764 * GNAT.Time_Stamp (g-timsta.ads)::
13765 * GNAT.Traceback (g-traceb.ads)::
13766 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13767 * GNAT.UTF_32 (g-utf_32.ads)::
13768 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13769 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13770 * GNAT.Wide_String_Split (g-wistsp.ads)::
13771 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13772 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13773 * Interfaces.C.Extensions (i-cexten.ads)::
13774 * Interfaces.C.Streams (i-cstrea.ads)::
13775 * Interfaces.CPP (i-cpp.ads)::
13776 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13777 * Interfaces.VxWorks (i-vxwork.ads)::
13778 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13779 * System.Address_Image (s-addima.ads)::
13780 * System.Assertions (s-assert.ads)::
13781 * System.Memory (s-memory.ads)::
13782 * System.Partition_Interface (s-parint.ads)::
13783 * System.Pool_Global (s-pooglo.ads)::
13784 * System.Pool_Local (s-pooloc.ads)::
13785 * System.Restrictions (s-restri.ads)::
13786 * System.Rident (s-rident.ads)::
13787 * System.Strings.Stream_Ops (s-ststop.ads)::
13788 * System.Task_Info (s-tasinf.ads)::
13789 * System.Wch_Cnv (s-wchcnv.ads)::
13790 * System.Wch_Con (s-wchcon.ads)::
13793 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13794 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13795 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13796 @cindex Latin_9 constants for Character
13799 This child of @code{Ada.Characters}
13800 provides a set of definitions corresponding to those in the
13801 RM-defined package @code{Ada.Characters.Latin_1} but with the
13802 few modifications required for @code{Latin-9}
13803 The provision of such a package
13804 is specifically authorized by the Ada Reference Manual
13807 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13808 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13809 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13810 @cindex Latin_1 constants for Wide_Character
13813 This child of @code{Ada.Characters}
13814 provides a set of definitions corresponding to those in the
13815 RM-defined package @code{Ada.Characters.Latin_1} but with the
13816 types of the constants being @code{Wide_Character}
13817 instead of @code{Character}. The provision of such a package
13818 is specifically authorized by the Ada Reference Manual
13821 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13822 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13823 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13824 @cindex Latin_9 constants for Wide_Character
13827 This child of @code{Ada.Characters}
13828 provides a set of definitions corresponding to those in the
13829 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13830 types of the constants being @code{Wide_Character}
13831 instead of @code{Character}. The provision of such a package
13832 is specifically authorized by the Ada Reference Manual
13835 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13836 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13837 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13838 @cindex Latin_1 constants for Wide_Wide_Character
13841 This child of @code{Ada.Characters}
13842 provides a set of definitions corresponding to those in the
13843 RM-defined package @code{Ada.Characters.Latin_1} but with the
13844 types of the constants being @code{Wide_Wide_Character}
13845 instead of @code{Character}. The provision of such a package
13846 is specifically authorized by the Ada Reference Manual
13849 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13850 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13851 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13852 @cindex Latin_9 constants for Wide_Wide_Character
13855 This child of @code{Ada.Characters}
13856 provides a set of definitions corresponding to those in the
13857 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13858 types of the constants being @code{Wide_Wide_Character}
13859 instead of @code{Character}. The provision of such a package
13860 is specifically authorized by the Ada Reference Manual
13863 @node Ada.Command_Line.Environment (a-colien.ads)
13864 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13865 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13866 @cindex Environment entries
13869 This child of @code{Ada.Command_Line}
13870 provides a mechanism for obtaining environment values on systems
13871 where this concept makes sense.
13873 @node Ada.Command_Line.Remove (a-colire.ads)
13874 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13875 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13876 @cindex Removing command line arguments
13877 @cindex Command line, argument removal
13880 This child of @code{Ada.Command_Line}
13881 provides a mechanism for logically removing
13882 arguments from the argument list. Once removed, an argument is not visible
13883 to further calls on the subprograms in @code{Ada.Command_Line} will not
13884 see the removed argument.
13886 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13887 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13888 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13889 @cindex Response file for command line
13890 @cindex Command line, response file
13891 @cindex Command line, handling long command lines
13894 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13895 getting command line arguments from a text file, called a "response file".
13896 Using a response file allow passing a set of arguments to an executable longer
13897 than the maximum allowed by the system on the command line.
13899 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13900 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13901 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13902 @cindex C Streams, Interfacing with Direct_IO
13905 This package provides subprograms that allow interfacing between
13906 C streams and @code{Direct_IO}. The stream identifier can be
13907 extracted from a file opened on the Ada side, and an Ada file
13908 can be constructed from a stream opened on the C side.
13910 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13911 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13912 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13913 @cindex Null_Occurrence, testing for
13916 This child subprogram provides a way of testing for the null
13917 exception occurrence (@code{Null_Occurrence}) without raising
13920 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13921 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13922 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13923 @cindex Null_Occurrence, testing for
13926 This child subprogram is used for handling otherwise unhandled
13927 exceptions (hence the name last chance), and perform clean ups before
13928 terminating the program. Note that this subprogram never returns.
13930 @node Ada.Exceptions.Traceback (a-exctra.ads)
13931 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13932 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13933 @cindex Traceback for Exception Occurrence
13936 This child package provides the subprogram (@code{Tracebacks}) to
13937 give a traceback array of addresses based on an exception
13940 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13941 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13942 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13943 @cindex C Streams, Interfacing with Sequential_IO
13946 This package provides subprograms that allow interfacing between
13947 C streams and @code{Sequential_IO}. The stream identifier can be
13948 extracted from a file opened on the Ada side, and an Ada file
13949 can be constructed from a stream opened on the C side.
13951 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13952 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13953 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13954 @cindex C Streams, Interfacing with Stream_IO
13957 This package provides subprograms that allow interfacing between
13958 C streams and @code{Stream_IO}. The stream identifier can be
13959 extracted from a file opened on the Ada side, and an Ada file
13960 can be constructed from a stream opened on the C side.
13962 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13963 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13964 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13965 @cindex @code{Unbounded_String}, IO support
13966 @cindex @code{Text_IO}, extensions for unbounded strings
13969 This package provides subprograms for Text_IO for unbounded
13970 strings, avoiding the necessity for an intermediate operation
13971 with ordinary strings.
13973 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13974 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13975 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13976 @cindex @code{Unbounded_Wide_String}, IO support
13977 @cindex @code{Text_IO}, extensions for unbounded wide strings
13980 This package provides subprograms for Text_IO for unbounded
13981 wide strings, avoiding the necessity for an intermediate operation
13982 with ordinary wide strings.
13984 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13985 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13986 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13987 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13988 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13991 This package provides subprograms for Text_IO for unbounded
13992 wide wide strings, avoiding the necessity for an intermediate operation
13993 with ordinary wide wide strings.
13995 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13996 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13997 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13998 @cindex C Streams, Interfacing with @code{Text_IO}
14001 This package provides subprograms that allow interfacing between
14002 C streams and @code{Text_IO}. The stream identifier can be
14003 extracted from a file opened on the Ada side, and an Ada file
14004 can be constructed from a stream opened on the C side.
14006 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14007 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14008 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14009 @cindex @code{Text_IO} resetting standard files
14012 This procedure is used to reset the status of the standard files used
14013 by Ada.Text_IO. This is useful in a situation (such as a restart in an
14014 embedded application) where the status of the files may change during
14015 execution (for example a standard input file may be redefined to be
14018 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14019 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14020 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14021 @cindex Unicode categorization, Wide_Character
14024 This package provides subprograms that allow categorization of
14025 Wide_Character values according to Unicode categories.
14027 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14028 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14029 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14030 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14033 This package provides subprograms that allow interfacing between
14034 C streams and @code{Wide_Text_IO}. The stream identifier can be
14035 extracted from a file opened on the Ada side, and an Ada file
14036 can be constructed from a stream opened on the C side.
14038 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14039 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14040 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14041 @cindex @code{Wide_Text_IO} resetting standard files
14044 This procedure is used to reset the status of the standard files used
14045 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14046 embedded application) where the status of the files may change during
14047 execution (for example a standard input file may be redefined to be
14050 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14051 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14052 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14053 @cindex Unicode categorization, Wide_Wide_Character
14056 This package provides subprograms that allow categorization of
14057 Wide_Wide_Character values according to Unicode categories.
14059 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14060 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14061 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14062 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14065 This package provides subprograms that allow interfacing between
14066 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14067 extracted from a file opened on the Ada side, and an Ada file
14068 can be constructed from a stream opened on the C side.
14070 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14071 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14072 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14073 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14076 This procedure is used to reset the status of the standard files used
14077 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14078 restart in an embedded application) where the status of the files may
14079 change during execution (for example a standard input file may be
14080 redefined to be interactive).
14082 @node GNAT.Altivec (g-altive.ads)
14083 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14084 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14088 This is the root package of the GNAT AltiVec binding. It provides
14089 definitions of constants and types common to all the versions of the
14092 @node GNAT.Altivec.Conversions (g-altcon.ads)
14093 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14094 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14098 This package provides the Vector/View conversion routines.
14100 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14101 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14102 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14106 This package exposes the Ada interface to the AltiVec operations on
14107 vector objects. A soft emulation is included by default in the GNAT
14108 library. The hard binding is provided as a separate package. This unit
14109 is common to both bindings.
14111 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14112 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14113 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14117 This package exposes the various vector types part of the Ada binding
14118 to AltiVec facilities.
14120 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14121 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14122 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14126 This package provides public 'View' data types from/to which private
14127 vector representations can be converted via
14128 GNAT.Altivec.Conversions. This allows convenient access to individual
14129 vector elements and provides a simple way to initialize vector
14132 @node GNAT.Array_Split (g-arrspl.ads)
14133 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14134 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14135 @cindex Array splitter
14138 Useful array-manipulation routines: given a set of separators, split
14139 an array wherever the separators appear, and provide direct access
14140 to the resulting slices.
14142 @node GNAT.AWK (g-awk.ads)
14143 @section @code{GNAT.AWK} (@file{g-awk.ads})
14144 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14149 Provides AWK-like parsing functions, with an easy interface for parsing one
14150 or more files containing formatted data. The file is viewed as a database
14151 where each record is a line and a field is a data element in this line.
14153 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14154 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14155 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14157 @cindex Bounded Buffers
14160 Provides a concurrent generic bounded buffer abstraction. Instances are
14161 useful directly or as parts of the implementations of other abstractions,
14164 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14165 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14166 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14171 Provides a thread-safe asynchronous intertask mailbox communication facility.
14173 @node GNAT.Bubble_Sort (g-bubsor.ads)
14174 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14175 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14177 @cindex Bubble sort
14180 Provides a general implementation of bubble sort usable for sorting arbitrary
14181 data items. Exchange and comparison procedures are provided by passing
14182 access-to-procedure values.
14184 @node GNAT.Bubble_Sort_A (g-busora.ads)
14185 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14186 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14188 @cindex Bubble sort
14191 Provides a general implementation of bubble sort usable for sorting arbitrary
14192 data items. Move and comparison procedures are provided by passing
14193 access-to-procedure values. This is an older version, retained for
14194 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14196 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14197 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14198 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14200 @cindex Bubble sort
14203 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14204 are provided as generic parameters, this improves efficiency, especially
14205 if the procedures can be inlined, at the expense of duplicating code for
14206 multiple instantiations.
14208 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14209 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14210 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14211 @cindex UTF-8 representation
14212 @cindex Wide characte representations
14215 Provides a routine which given a string, reads the start of the string to
14216 see whether it is one of the standard byte order marks (BOM's) which signal
14217 the encoding of the string. The routine includes detection of special XML
14218 sequences for various UCS input formats.
14220 @node GNAT.Byte_Swapping (g-bytswa.ads)
14221 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14222 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14223 @cindex Byte swapping
14227 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14228 Machine-specific implementations are available in some cases.
14230 @node GNAT.Calendar (g-calend.ads)
14231 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14232 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14233 @cindex @code{Calendar}
14236 Extends the facilities provided by @code{Ada.Calendar} to include handling
14237 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14238 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14239 C @code{timeval} format.
14241 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14242 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14243 @cindex @code{Calendar}
14245 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14247 @node GNAT.CRC32 (g-crc32.ads)
14248 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14249 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14251 @cindex Cyclic Redundancy Check
14254 This package implements the CRC-32 algorithm. For a full description
14255 of this algorithm see
14256 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14257 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14258 Aug.@: 1988. Sarwate, D.V@.
14260 @node GNAT.Case_Util (g-casuti.ads)
14261 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14262 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14263 @cindex Casing utilities
14264 @cindex Character handling (@code{GNAT.Case_Util})
14267 A set of simple routines for handling upper and lower casing of strings
14268 without the overhead of the full casing tables
14269 in @code{Ada.Characters.Handling}.
14271 @node GNAT.CGI (g-cgi.ads)
14272 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14273 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14274 @cindex CGI (Common Gateway Interface)
14277 This is a package for interfacing a GNAT program with a Web server via the
14278 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14279 parameters, which are a set of key/value pairs sent by the Web server. It
14280 builds a table whose index is the key and provides some services to deal
14283 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14284 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14285 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14286 @cindex CGI (Common Gateway Interface) cookie support
14287 @cindex Cookie support in CGI
14290 This is a package to interface a GNAT program with a Web server via the
14291 Common Gateway Interface (CGI). It exports services to deal with Web
14292 cookies (piece of information kept in the Web client software).
14294 @node GNAT.CGI.Debug (g-cgideb.ads)
14295 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14296 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14297 @cindex CGI (Common Gateway Interface) debugging
14300 This is a package to help debugging CGI (Common Gateway Interface)
14301 programs written in Ada.
14303 @node GNAT.Command_Line (g-comlin.ads)
14304 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14305 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14306 @cindex Command line
14309 Provides a high level interface to @code{Ada.Command_Line} facilities,
14310 including the ability to scan for named switches with optional parameters
14311 and expand file names using wild card notations.
14313 @node GNAT.Compiler_Version (g-comver.ads)
14314 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14315 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14316 @cindex Compiler Version
14317 @cindex Version, of compiler
14320 Provides a routine for obtaining the version of the compiler used to
14321 compile the program. More accurately this is the version of the binder
14322 used to bind the program (this will normally be the same as the version
14323 of the compiler if a consistent tool set is used to compile all units
14326 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14327 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14328 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14332 Provides a simple interface to handle Ctrl-C keyboard events.
14334 @node GNAT.Current_Exception (g-curexc.ads)
14335 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14336 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14337 @cindex Current exception
14338 @cindex Exception retrieval
14341 Provides access to information on the current exception that has been raised
14342 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14343 specification syntax.
14344 This is particularly useful in simulating typical facilities for
14345 obtaining information about exceptions provided by Ada 83 compilers.
14347 @node GNAT.Debug_Pools (g-debpoo.ads)
14348 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14349 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14351 @cindex Debug pools
14352 @cindex Memory corruption debugging
14355 Provide a debugging storage pools that helps tracking memory corruption
14356 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14357 @value{EDITION} User's Guide}.
14359 @node GNAT.Debug_Utilities (g-debuti.ads)
14360 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14361 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14365 Provides a few useful utilities for debugging purposes, including conversion
14366 to and from string images of address values. Supports both C and Ada formats
14367 for hexadecimal literals.
14369 @node GNAT.Decode_String (g-decstr.ads)
14370 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14371 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14372 @cindex Decoding strings
14373 @cindex String decoding
14374 @cindex Wide character encoding
14379 A generic package providing routines for decoding wide character and wide wide
14380 character strings encoded as sequences of 8-bit characters using a specified
14381 encoding method. Includes validation routines, and also routines for stepping
14382 to next or previous encoded character in an encoded string.
14383 Useful in conjunction with Unicode character coding. Note there is a
14384 preinstantiation for UTF-8. See next entry.
14386 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14387 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14388 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14389 @cindex Decoding strings
14390 @cindex Decoding UTF-8 strings
14391 @cindex UTF-8 string decoding
14392 @cindex Wide character decoding
14397 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14399 @node GNAT.Directory_Operations (g-dirope.ads)
14400 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14401 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14402 @cindex Directory operations
14405 Provides a set of routines for manipulating directories, including changing
14406 the current directory, making new directories, and scanning the files in a
14409 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14410 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14411 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14412 @cindex Directory operations iteration
14415 A child unit of GNAT.Directory_Operations providing additional operations
14416 for iterating through directories.
14418 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14419 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14420 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14421 @cindex Hash tables
14424 A generic implementation of hash tables that can be used to hash arbitrary
14425 data. Provided in two forms, a simple form with built in hash functions,
14426 and a more complex form in which the hash function is supplied.
14429 This package provides a facility similar to that of @code{GNAT.HTable},
14430 except that this package declares a type that can be used to define
14431 dynamic instances of the hash table, while an instantiation of
14432 @code{GNAT.HTable} creates a single instance of the hash table.
14434 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14435 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14436 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14437 @cindex Table implementation
14438 @cindex Arrays, extendable
14441 A generic package providing a single dimension array abstraction where the
14442 length of the array can be dynamically modified.
14445 This package provides a facility similar to that of @code{GNAT.Table},
14446 except that this package declares a type that can be used to define
14447 dynamic instances of the table, while an instantiation of
14448 @code{GNAT.Table} creates a single instance of the table type.
14450 @node GNAT.Encode_String (g-encstr.ads)
14451 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14452 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14453 @cindex Encoding strings
14454 @cindex String encoding
14455 @cindex Wide character encoding
14460 A generic package providing routines for encoding wide character and wide
14461 wide character strings as sequences of 8-bit characters using a specified
14462 encoding method. Useful in conjunction with Unicode character coding.
14463 Note there is a preinstantiation for UTF-8. See next entry.
14465 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14466 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14467 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14468 @cindex Encoding strings
14469 @cindex Encoding UTF-8 strings
14470 @cindex UTF-8 string encoding
14471 @cindex Wide character encoding
14476 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14478 @node GNAT.Exception_Actions (g-excact.ads)
14479 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14480 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14481 @cindex Exception actions
14484 Provides callbacks when an exception is raised. Callbacks can be registered
14485 for specific exceptions, or when any exception is raised. This
14486 can be used for instance to force a core dump to ease debugging.
14488 @node GNAT.Exception_Traces (g-exctra.ads)
14489 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14490 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14491 @cindex Exception traces
14495 Provides an interface allowing to control automatic output upon exception
14498 @node GNAT.Exceptions (g-except.ads)
14499 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14500 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14501 @cindex Exceptions, Pure
14502 @cindex Pure packages, exceptions
14505 Normally it is not possible to raise an exception with
14506 a message from a subprogram in a pure package, since the
14507 necessary types and subprograms are in @code{Ada.Exceptions}
14508 which is not a pure unit. @code{GNAT.Exceptions} provides a
14509 facility for getting around this limitation for a few
14510 predefined exceptions, and for example allow raising
14511 @code{Constraint_Error} with a message from a pure subprogram.
14513 @node GNAT.Expect (g-expect.ads)
14514 @section @code{GNAT.Expect} (@file{g-expect.ads})
14515 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14518 Provides a set of subprograms similar to what is available
14519 with the standard Tcl Expect tool.
14520 It allows you to easily spawn and communicate with an external process.
14521 You can send commands or inputs to the process, and compare the output
14522 with some expected regular expression. Currently @code{GNAT.Expect}
14523 is implemented on all native GNAT ports except for OpenVMS@.
14524 It is not implemented for cross ports, and in particular is not
14525 implemented for VxWorks or LynxOS@.
14527 @node GNAT.Float_Control (g-flocon.ads)
14528 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14529 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14530 @cindex Floating-Point Processor
14533 Provides an interface for resetting the floating-point processor into the
14534 mode required for correct semantic operation in Ada. Some third party
14535 library calls may cause this mode to be modified, and the Reset procedure
14536 in this package can be used to reestablish the required mode.
14538 @node GNAT.Heap_Sort (g-heasor.ads)
14539 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14540 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14544 Provides a general implementation of heap sort usable for sorting arbitrary
14545 data items. Exchange and comparison procedures are provided by passing
14546 access-to-procedure values. The algorithm used is a modified heap sort
14547 that performs approximately N*log(N) comparisons in the worst case.
14549 @node GNAT.Heap_Sort_A (g-hesora.ads)
14550 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14551 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14555 Provides a general implementation of heap sort usable for sorting arbitrary
14556 data items. Move and comparison procedures are provided by passing
14557 access-to-procedure values. The algorithm used is a modified heap sort
14558 that performs approximately N*log(N) comparisons in the worst case.
14559 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14560 interface, but may be slightly more efficient.
14562 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14563 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14564 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14568 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14569 are provided as generic parameters, this improves efficiency, especially
14570 if the procedures can be inlined, at the expense of duplicating code for
14571 multiple instantiations.
14573 @node GNAT.HTable (g-htable.ads)
14574 @section @code{GNAT.HTable} (@file{g-htable.ads})
14575 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14576 @cindex Hash tables
14579 A generic implementation of hash tables that can be used to hash arbitrary
14580 data. Provides two approaches, one a simple static approach, and the other
14581 allowing arbitrary dynamic hash tables.
14583 @node GNAT.IO (g-io.ads)
14584 @section @code{GNAT.IO} (@file{g-io.ads})
14585 @cindex @code{GNAT.IO} (@file{g-io.ads})
14587 @cindex Input/Output facilities
14590 A simple preelaborable input-output package that provides a subset of
14591 simple Text_IO functions for reading characters and strings from
14592 Standard_Input, and writing characters, strings and integers to either
14593 Standard_Output or Standard_Error.
14595 @node GNAT.IO_Aux (g-io_aux.ads)
14596 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14597 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14599 @cindex Input/Output facilities
14601 Provides some auxiliary functions for use with Text_IO, including a test
14602 for whether a file exists, and functions for reading a line of text.
14604 @node GNAT.Lock_Files (g-locfil.ads)
14605 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14606 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14607 @cindex File locking
14608 @cindex Locking using files
14611 Provides a general interface for using files as locks. Can be used for
14612 providing program level synchronization.
14614 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
14615 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14616 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14617 @cindex Random number generation
14620 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
14621 a modified version of the Blum-Blum-Shub generator.
14623 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
14624 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14625 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14626 @cindex Random number generation
14629 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
14630 a modified version of the Blum-Blum-Shub generator.
14632 @node GNAT.MD5 (g-md5.ads)
14633 @section @code{GNAT.MD5} (@file{g-md5.ads})
14634 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14635 @cindex Message Digest MD5
14638 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14640 @node GNAT.Memory_Dump (g-memdum.ads)
14641 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14642 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14643 @cindex Dump Memory
14646 Provides a convenient routine for dumping raw memory to either the
14647 standard output or standard error files. Uses GNAT.IO for actual
14650 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14651 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14652 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14653 @cindex Exception, obtaining most recent
14656 Provides access to the most recently raised exception. Can be used for
14657 various logging purposes, including duplicating functionality of some
14658 Ada 83 implementation dependent extensions.
14660 @node GNAT.OS_Lib (g-os_lib.ads)
14661 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14662 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14663 @cindex Operating System interface
14664 @cindex Spawn capability
14667 Provides a range of target independent operating system interface functions,
14668 including time/date management, file operations, subprocess management,
14669 including a portable spawn procedure, and access to environment variables
14670 and error return codes.
14672 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14673 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14674 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14675 @cindex Hash functions
14678 Provides a generator of static minimal perfect hash functions. No
14679 collisions occur and each item can be retrieved from the table in one
14680 probe (perfect property). The hash table size corresponds to the exact
14681 size of the key set and no larger (minimal property). The key set has to
14682 be know in advance (static property). The hash functions are also order
14683 preserving. If w2 is inserted after w1 in the generator, their
14684 hashcode are in the same order. These hashing functions are very
14685 convenient for use with realtime applications.
14687 @node GNAT.Random_Numbers (g-rannum.ads)
14688 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14689 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14690 @cindex Random number generation
14693 Provides random number capabilities which extend those available in the
14694 standard Ada library and are more convenient to use.
14696 @node GNAT.Regexp (g-regexp.ads)
14697 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14698 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14699 @cindex Regular expressions
14700 @cindex Pattern matching
14703 A simple implementation of regular expressions, using a subset of regular
14704 expression syntax copied from familiar Unix style utilities. This is the
14705 simples of the three pattern matching packages provided, and is particularly
14706 suitable for ``file globbing'' applications.
14708 @node GNAT.Registry (g-regist.ads)
14709 @section @code{GNAT.Registry} (@file{g-regist.ads})
14710 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14711 @cindex Windows Registry
14714 This is a high level binding to the Windows registry. It is possible to
14715 do simple things like reading a key value, creating a new key. For full
14716 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14717 package provided with the Win32Ada binding
14719 @node GNAT.Regpat (g-regpat.ads)
14720 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14721 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14722 @cindex Regular expressions
14723 @cindex Pattern matching
14726 A complete implementation of Unix-style regular expression matching, copied
14727 from the original V7 style regular expression library written in C by
14728 Henry Spencer (and binary compatible with this C library).
14730 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14731 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14732 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14733 @cindex Secondary Stack Info
14736 Provide the capability to query the high water mark of the current task's
14739 @node GNAT.Semaphores (g-semaph.ads)
14740 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14741 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14745 Provides classic counting and binary semaphores using protected types.
14747 @node GNAT.Serial_Communications (g-sercom.ads)
14748 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14749 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14750 @cindex Serial_Communications
14753 Provides a simple interface to send and receive data over a serial
14754 port. This is only supported on GNU/Linux and Windows.
14756 @node GNAT.SHA1 (g-sha1.ads)
14757 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14758 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14759 @cindex Secure Hash Algorithm SHA-1
14762 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14765 @node GNAT.SHA224 (g-sha224.ads)
14766 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
14767 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14768 @cindex Secure Hash Algorithm SHA-224
14771 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14773 @node GNAT.SHA256 (g-sha256.ads)
14774 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
14775 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14776 @cindex Secure Hash Algorithm SHA-256
14779 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14781 @node GNAT.SHA384 (g-sha384.ads)
14782 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
14783 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14784 @cindex Secure Hash Algorithm SHA-384
14787 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14789 @node GNAT.SHA512 (g-sha512.ads)
14790 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
14791 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14792 @cindex Secure Hash Algorithm SHA-512
14795 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14797 @node GNAT.Signals (g-signal.ads)
14798 @section @code{GNAT.Signals} (@file{g-signal.ads})
14799 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14803 Provides the ability to manipulate the blocked status of signals on supported
14806 @node GNAT.Sockets (g-socket.ads)
14807 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14808 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14812 A high level and portable interface to develop sockets based applications.
14813 This package is based on the sockets thin binding found in
14814 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14815 on all native GNAT ports except for OpenVMS@. It is not implemented
14816 for the LynxOS@ cross port.
14818 @node GNAT.Source_Info (g-souinf.ads)
14819 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14820 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14821 @cindex Source Information
14824 Provides subprograms that give access to source code information known at
14825 compile time, such as the current file name and line number.
14827 @node GNAT.Spelling_Checker (g-speche.ads)
14828 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14829 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14830 @cindex Spell checking
14833 Provides a function for determining whether one string is a plausible
14834 near misspelling of another string.
14836 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14837 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14838 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14839 @cindex Spell checking
14842 Provides a generic function that can be instantiated with a string type for
14843 determining whether one string is a plausible near misspelling of another
14846 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14847 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14848 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14849 @cindex SPITBOL pattern matching
14850 @cindex Pattern matching
14853 A complete implementation of SNOBOL4 style pattern matching. This is the
14854 most elaborate of the pattern matching packages provided. It fully duplicates
14855 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14856 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14858 @node GNAT.Spitbol (g-spitbo.ads)
14859 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14860 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14861 @cindex SPITBOL interface
14864 The top level package of the collection of SPITBOL-style functionality, this
14865 package provides basic SNOBOL4 string manipulation functions, such as
14866 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14867 useful for constructing arbitrary mappings from strings in the style of
14868 the SNOBOL4 TABLE function.
14870 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14871 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14872 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14873 @cindex Sets of strings
14874 @cindex SPITBOL Tables
14877 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14878 for type @code{Standard.Boolean}, giving an implementation of sets of
14881 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14882 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14883 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14884 @cindex Integer maps
14886 @cindex SPITBOL Tables
14889 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14890 for type @code{Standard.Integer}, giving an implementation of maps
14891 from string to integer values.
14893 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14894 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14895 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14896 @cindex String maps
14898 @cindex SPITBOL Tables
14901 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14902 a variable length string type, giving an implementation of general
14903 maps from strings to strings.
14905 @node GNAT.SSE (g-sse.ads)
14906 @section @code{GNAT.SSE} (@file{g-sse.ads})
14907 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14910 Root of a set of units aimed at offering Ada bindings to a subset of
14911 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14912 targets. It exposes vector component types together with a general
14913 introduction to the binding contents and use.
14915 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14916 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14917 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14920 SSE vector types for use with SSE related intrinsics.
14922 @node GNAT.Strings (g-string.ads)
14923 @section @code{GNAT.Strings} (@file{g-string.ads})
14924 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14927 Common String access types and related subprograms. Basically it
14928 defines a string access and an array of string access types.
14930 @node GNAT.String_Split (g-strspl.ads)
14931 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14932 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14933 @cindex String splitter
14936 Useful string manipulation routines: given a set of separators, split
14937 a string wherever the separators appear, and provide direct access
14938 to the resulting slices. This package is instantiated from
14939 @code{GNAT.Array_Split}.
14941 @node GNAT.Table (g-table.ads)
14942 @section @code{GNAT.Table} (@file{g-table.ads})
14943 @cindex @code{GNAT.Table} (@file{g-table.ads})
14944 @cindex Table implementation
14945 @cindex Arrays, extendable
14948 A generic package providing a single dimension array abstraction where the
14949 length of the array can be dynamically modified.
14952 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14953 except that this package declares a single instance of the table type,
14954 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14955 used to define dynamic instances of the table.
14957 @node GNAT.Task_Lock (g-tasloc.ads)
14958 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14959 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14960 @cindex Task synchronization
14961 @cindex Task locking
14965 A very simple facility for locking and unlocking sections of code using a
14966 single global task lock. Appropriate for use in situations where contention
14967 between tasks is very rarely expected.
14969 @node GNAT.Time_Stamp (g-timsta.ads)
14970 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14971 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14973 @cindex Current time
14976 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14977 represents the current date and time in ISO 8601 format. This is a very simple
14978 routine with minimal code and there are no dependencies on any other unit.
14980 @node GNAT.Threads (g-thread.ads)
14981 @section @code{GNAT.Threads} (@file{g-thread.ads})
14982 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14983 @cindex Foreign threads
14984 @cindex Threads, foreign
14987 Provides facilities for dealing with foreign threads which need to be known
14988 by the GNAT run-time system. Consult the documentation of this package for
14989 further details if your program has threads that are created by a non-Ada
14990 environment which then accesses Ada code.
14992 @node GNAT.Traceback (g-traceb.ads)
14993 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14994 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14995 @cindex Trace back facilities
14998 Provides a facility for obtaining non-symbolic traceback information, useful
14999 in various debugging situations.
15001 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15002 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15003 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15004 @cindex Trace back facilities
15006 @node GNAT.UTF_32 (g-utf_32.ads)
15007 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15008 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15009 @cindex Wide character codes
15012 This is a package intended to be used in conjunction with the
15013 @code{Wide_Character} type in Ada 95 and the
15014 @code{Wide_Wide_Character} type in Ada 2005 (available
15015 in @code{GNAT} in Ada 2005 mode). This package contains
15016 Unicode categorization routines, as well as lexical
15017 categorization routines corresponding to the Ada 2005
15018 lexical rules for identifiers and strings, and also a
15019 lower case to upper case fold routine corresponding to
15020 the Ada 2005 rules for identifier equivalence.
15022 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15023 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15024 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15025 @cindex Spell checking
15028 Provides a function for determining whether one wide wide string is a plausible
15029 near misspelling of another wide wide string, where the strings are represented
15030 using the UTF_32_String type defined in System.Wch_Cnv.
15032 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15033 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15034 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15035 @cindex Spell checking
15038 Provides a function for determining whether one wide string is a plausible
15039 near misspelling of another wide string.
15041 @node GNAT.Wide_String_Split (g-wistsp.ads)
15042 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15043 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15044 @cindex Wide_String splitter
15047 Useful wide string manipulation routines: given a set of separators, split
15048 a wide string wherever the separators appear, and provide direct access
15049 to the resulting slices. This package is instantiated from
15050 @code{GNAT.Array_Split}.
15052 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15053 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15054 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15055 @cindex Spell checking
15058 Provides a function for determining whether one wide wide string is a plausible
15059 near misspelling of another wide wide string.
15061 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15062 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15063 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15064 @cindex Wide_Wide_String splitter
15067 Useful wide wide string manipulation routines: given a set of separators, split
15068 a wide wide string wherever the separators appear, and provide direct access
15069 to the resulting slices. This package is instantiated from
15070 @code{GNAT.Array_Split}.
15072 @node Interfaces.C.Extensions (i-cexten.ads)
15073 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15074 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15077 This package contains additional C-related definitions, intended
15078 for use with either manually or automatically generated bindings
15081 @node Interfaces.C.Streams (i-cstrea.ads)
15082 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15083 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15084 @cindex C streams, interfacing
15087 This package is a binding for the most commonly used operations
15090 @node Interfaces.CPP (i-cpp.ads)
15091 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15092 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15093 @cindex C++ interfacing
15094 @cindex Interfacing, to C++
15097 This package provides facilities for use in interfacing to C++. It
15098 is primarily intended to be used in connection with automated tools
15099 for the generation of C++ interfaces.
15101 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15102 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15103 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15104 @cindex IBM Packed Format
15105 @cindex Packed Decimal
15108 This package provides a set of routines for conversions to and
15109 from a packed decimal format compatible with that used on IBM
15112 @node Interfaces.VxWorks (i-vxwork.ads)
15113 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15114 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15115 @cindex Interfacing to VxWorks
15116 @cindex VxWorks, interfacing
15119 This package provides a limited binding to the VxWorks API.
15120 In particular, it interfaces with the
15121 VxWorks hardware interrupt facilities.
15123 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15124 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15125 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15126 @cindex Interfacing to VxWorks' I/O
15127 @cindex VxWorks, I/O interfacing
15128 @cindex VxWorks, Get_Immediate
15129 @cindex Get_Immediate, VxWorks
15132 This package provides a binding to the ioctl (IO/Control)
15133 function of VxWorks, defining a set of option values and
15134 function codes. A particular use of this package is
15135 to enable the use of Get_Immediate under VxWorks.
15137 @node System.Address_Image (s-addima.ads)
15138 @section @code{System.Address_Image} (@file{s-addima.ads})
15139 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15140 @cindex Address image
15141 @cindex Image, of an address
15144 This function provides a useful debugging
15145 function that gives an (implementation dependent)
15146 string which identifies an address.
15148 @node System.Assertions (s-assert.ads)
15149 @section @code{System.Assertions} (@file{s-assert.ads})
15150 @cindex @code{System.Assertions} (@file{s-assert.ads})
15152 @cindex Assert_Failure, exception
15155 This package provides the declaration of the exception raised
15156 by an run-time assertion failure, as well as the routine that
15157 is used internally to raise this assertion.
15159 @node System.Memory (s-memory.ads)
15160 @section @code{System.Memory} (@file{s-memory.ads})
15161 @cindex @code{System.Memory} (@file{s-memory.ads})
15162 @cindex Memory allocation
15165 This package provides the interface to the low level routines used
15166 by the generated code for allocation and freeing storage for the
15167 default storage pool (analogous to the C routines malloc and free.
15168 It also provides a reallocation interface analogous to the C routine
15169 realloc. The body of this unit may be modified to provide alternative
15170 allocation mechanisms for the default pool, and in addition, direct
15171 calls to this unit may be made for low level allocation uses (for
15172 example see the body of @code{GNAT.Tables}).
15174 @node System.Partition_Interface (s-parint.ads)
15175 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15176 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15177 @cindex Partition interfacing functions
15180 This package provides facilities for partition interfacing. It
15181 is used primarily in a distribution context when using Annex E
15184 @node System.Pool_Global (s-pooglo.ads)
15185 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15186 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15187 @cindex Storage pool, global
15188 @cindex Global storage pool
15191 This package provides a storage pool that is equivalent to the default
15192 storage pool used for access types for which no pool is specifically
15193 declared. It uses malloc/free to allocate/free and does not attempt to
15194 do any automatic reclamation.
15196 @node System.Pool_Local (s-pooloc.ads)
15197 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15198 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15199 @cindex Storage pool, local
15200 @cindex Local storage pool
15203 This package provides a storage pool that is intended for use with locally
15204 defined access types. It uses malloc/free for allocate/free, and maintains
15205 a list of allocated blocks, so that all storage allocated for the pool can
15206 be freed automatically when the pool is finalized.
15208 @node System.Restrictions (s-restri.ads)
15209 @section @code{System.Restrictions} (@file{s-restri.ads})
15210 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15211 @cindex Run-time restrictions access
15214 This package provides facilities for accessing at run time
15215 the status of restrictions specified at compile time for
15216 the partition. Information is available both with regard
15217 to actual restrictions specified, and with regard to
15218 compiler determined information on which restrictions
15219 are violated by one or more packages in the partition.
15221 @node System.Rident (s-rident.ads)
15222 @section @code{System.Rident} (@file{s-rident.ads})
15223 @cindex @code{System.Rident} (@file{s-rident.ads})
15224 @cindex Restrictions definitions
15227 This package provides definitions of the restrictions
15228 identifiers supported by GNAT, and also the format of
15229 the restrictions provided in package System.Restrictions.
15230 It is not normally necessary to @code{with} this generic package
15231 since the necessary instantiation is included in
15232 package System.Restrictions.
15234 @node System.Strings.Stream_Ops (s-ststop.ads)
15235 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15236 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15237 @cindex Stream operations
15238 @cindex String stream operations
15241 This package provides a set of stream subprograms for standard string types.
15242 It is intended primarily to support implicit use of such subprograms when
15243 stream attributes are applied to string types, but the subprograms in this
15244 package can be used directly by application programs.
15246 @node System.Task_Info (s-tasinf.ads)
15247 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15248 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15249 @cindex Task_Info pragma
15252 This package provides target dependent functionality that is used
15253 to support the @code{Task_Info} pragma
15255 @node System.Wch_Cnv (s-wchcnv.ads)
15256 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15257 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15258 @cindex Wide Character, Representation
15259 @cindex Wide String, Conversion
15260 @cindex Representation of wide characters
15263 This package provides routines for converting between
15264 wide and wide wide characters and a representation as a value of type
15265 @code{Standard.String}, using a specified wide character
15266 encoding method. It uses definitions in
15267 package @code{System.Wch_Con}.
15269 @node System.Wch_Con (s-wchcon.ads)
15270 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15271 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15274 This package provides definitions and descriptions of
15275 the various methods used for encoding wide characters
15276 in ordinary strings. These definitions are used by
15277 the package @code{System.Wch_Cnv}.
15279 @node Interfacing to Other Languages
15280 @chapter Interfacing to Other Languages
15282 The facilities in annex B of the Ada Reference Manual are fully
15283 implemented in GNAT, and in addition, a full interface to C++ is
15287 * Interfacing to C::
15288 * Interfacing to C++::
15289 * Interfacing to COBOL::
15290 * Interfacing to Fortran::
15291 * Interfacing to non-GNAT Ada code::
15294 @node Interfacing to C
15295 @section Interfacing to C
15298 Interfacing to C with GNAT can use one of two approaches:
15302 The types in the package @code{Interfaces.C} may be used.
15304 Standard Ada types may be used directly. This may be less portable to
15305 other compilers, but will work on all GNAT compilers, which guarantee
15306 correspondence between the C and Ada types.
15310 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15311 effect, since this is the default. The following table shows the
15312 correspondence between Ada scalar types and the corresponding C types.
15317 @item Short_Integer
15319 @item Short_Short_Integer
15323 @item Long_Long_Integer
15331 @item Long_Long_Float
15332 This is the longest floating-point type supported by the hardware.
15336 Additionally, there are the following general correspondences between Ada
15340 Ada enumeration types map to C enumeration types directly if pragma
15341 @code{Convention C} is specified, which causes them to have int
15342 length. Without pragma @code{Convention C}, Ada enumeration types map to
15343 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15344 @code{int}, respectively) depending on the number of values passed.
15345 This is the only case in which pragma @code{Convention C} affects the
15346 representation of an Ada type.
15349 Ada access types map to C pointers, except for the case of pointers to
15350 unconstrained types in Ada, which have no direct C equivalent.
15353 Ada arrays map directly to C arrays.
15356 Ada records map directly to C structures.
15359 Packed Ada records map to C structures where all members are bit fields
15360 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15363 @node Interfacing to C++
15364 @section Interfacing to C++
15367 The interface to C++ makes use of the following pragmas, which are
15368 primarily intended to be constructed automatically using a binding generator
15369 tool, although it is possible to construct them by hand. No suitable binding
15370 generator tool is supplied with GNAT though.
15372 Using these pragmas it is possible to achieve complete
15373 inter-operability between Ada tagged types and C++ class definitions.
15374 See @ref{Implementation Defined Pragmas}, for more details.
15377 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15378 The argument denotes an entity in the current declarative region that is
15379 declared as a tagged or untagged record type. It indicates that the type
15380 corresponds to an externally declared C++ class type, and is to be laid
15381 out the same way that C++ would lay out the type.
15383 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15384 for backward compatibility but its functionality is available
15385 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15387 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15388 This pragma identifies an imported function (imported in the usual way
15389 with pragma @code{Import}) as corresponding to a C++ constructor.
15392 @node Interfacing to COBOL
15393 @section Interfacing to COBOL
15396 Interfacing to COBOL is achieved as described in section B.4 of
15397 the Ada Reference Manual.
15399 @node Interfacing to Fortran
15400 @section Interfacing to Fortran
15403 Interfacing to Fortran is achieved as described in section B.5 of the
15404 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15405 multi-dimensional array causes the array to be stored in column-major
15406 order as required for convenient interface to Fortran.
15408 @node Interfacing to non-GNAT Ada code
15409 @section Interfacing to non-GNAT Ada code
15411 It is possible to specify the convention @code{Ada} in a pragma
15412 @code{Import} or pragma @code{Export}. However this refers to
15413 the calling conventions used by GNAT, which may or may not be
15414 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15415 compiler to allow interoperation.
15417 If arguments types are kept simple, and if the foreign compiler generally
15418 follows system calling conventions, then it may be possible to integrate
15419 files compiled by other Ada compilers, provided that the elaboration
15420 issues are adequately addressed (for example by eliminating the
15421 need for any load time elaboration).
15423 In particular, GNAT running on VMS is designed to
15424 be highly compatible with the DEC Ada 83 compiler, so this is one
15425 case in which it is possible to import foreign units of this type,
15426 provided that the data items passed are restricted to simple scalar
15427 values or simple record types without variants, or simple array
15428 types with fixed bounds.
15430 @node Specialized Needs Annexes
15431 @chapter Specialized Needs Annexes
15434 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15435 required in all implementations. However, as described in this chapter,
15436 GNAT implements all of these annexes:
15439 @item Systems Programming (Annex C)
15440 The Systems Programming Annex is fully implemented.
15442 @item Real-Time Systems (Annex D)
15443 The Real-Time Systems Annex is fully implemented.
15445 @item Distributed Systems (Annex E)
15446 Stub generation is fully implemented in the GNAT compiler. In addition,
15447 a complete compatible PCS is available as part of the GLADE system,
15448 a separate product. When the two
15449 products are used in conjunction, this annex is fully implemented.
15451 @item Information Systems (Annex F)
15452 The Information Systems annex is fully implemented.
15454 @item Numerics (Annex G)
15455 The Numerics Annex is fully implemented.
15457 @item Safety and Security / High-Integrity Systems (Annex H)
15458 The Safety and Security Annex (termed the High-Integrity Systems Annex
15459 in Ada 2005) is fully implemented.
15462 @node Implementation of Specific Ada Features
15463 @chapter Implementation of Specific Ada Features
15466 This chapter describes the GNAT implementation of several Ada language
15470 * Machine Code Insertions::
15471 * GNAT Implementation of Tasking::
15472 * GNAT Implementation of Shared Passive Packages::
15473 * Code Generation for Array Aggregates::
15474 * The Size of Discriminated Records with Default Discriminants::
15475 * Strict Conformance to the Ada Reference Manual::
15478 @node Machine Code Insertions
15479 @section Machine Code Insertions
15480 @cindex Machine Code insertions
15483 Package @code{Machine_Code} provides machine code support as described
15484 in the Ada Reference Manual in two separate forms:
15487 Machine code statements, consisting of qualified expressions that
15488 fit the requirements of RM section 13.8.
15490 An intrinsic callable procedure, providing an alternative mechanism of
15491 including machine instructions in a subprogram.
15495 The two features are similar, and both are closely related to the mechanism
15496 provided by the asm instruction in the GNU C compiler. Full understanding
15497 and use of the facilities in this package requires understanding the asm
15498 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15499 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15501 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15502 semantic restrictions and effects as described below. Both are provided so
15503 that the procedure call can be used as a statement, and the function call
15504 can be used to form a code_statement.
15506 The first example given in the GCC documentation is the C @code{asm}
15509 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15513 The equivalent can be written for GNAT as:
15515 @smallexample @c ada
15516 Asm ("fsinx %1 %0",
15517 My_Float'Asm_Output ("=f", result),
15518 My_Float'Asm_Input ("f", angle));
15522 The first argument to @code{Asm} is the assembler template, and is
15523 identical to what is used in GNU C@. This string must be a static
15524 expression. The second argument is the output operand list. It is
15525 either a single @code{Asm_Output} attribute reference, or a list of such
15526 references enclosed in parentheses (technically an array aggregate of
15529 The @code{Asm_Output} attribute denotes a function that takes two
15530 parameters. The first is a string, the second is the name of a variable
15531 of the type designated by the attribute prefix. The first (string)
15532 argument is required to be a static expression and designates the
15533 constraint for the parameter (e.g.@: what kind of register is
15534 required). The second argument is the variable to be updated with the
15535 result. The possible values for constraint are the same as those used in
15536 the RTL, and are dependent on the configuration file used to build the
15537 GCC back end. If there are no output operands, then this argument may
15538 either be omitted, or explicitly given as @code{No_Output_Operands}.
15540 The second argument of @code{@var{my_float}'Asm_Output} functions as
15541 though it were an @code{out} parameter, which is a little curious, but
15542 all names have the form of expressions, so there is no syntactic
15543 irregularity, even though normally functions would not be permitted
15544 @code{out} parameters. The third argument is the list of input
15545 operands. It is either a single @code{Asm_Input} attribute reference, or
15546 a list of such references enclosed in parentheses (technically an array
15547 aggregate of such references).
15549 The @code{Asm_Input} attribute denotes a function that takes two
15550 parameters. The first is a string, the second is an expression of the
15551 type designated by the prefix. The first (string) argument is required
15552 to be a static expression, and is the constraint for the parameter,
15553 (e.g.@: what kind of register is required). The second argument is the
15554 value to be used as the input argument. The possible values for the
15555 constant are the same as those used in the RTL, and are dependent on
15556 the configuration file used to built the GCC back end.
15558 If there are no input operands, this argument may either be omitted, or
15559 explicitly given as @code{No_Input_Operands}. The fourth argument, not
15560 present in the above example, is a list of register names, called the
15561 @dfn{clobber} argument. This argument, if given, must be a static string
15562 expression, and is a space or comma separated list of names of registers
15563 that must be considered destroyed as a result of the @code{Asm} call. If
15564 this argument is the null string (the default value), then the code
15565 generator assumes that no additional registers are destroyed.
15567 The fifth argument, not present in the above example, called the
15568 @dfn{volatile} argument, is by default @code{False}. It can be set to
15569 the literal value @code{True} to indicate to the code generator that all
15570 optimizations with respect to the instruction specified should be
15571 suppressed, and that in particular, for an instruction that has outputs,
15572 the instruction will still be generated, even if none of the outputs are
15573 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15574 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15575 Generally it is strongly advisable to use Volatile for any ASM statement
15576 that is missing either input or output operands, or when two or more ASM
15577 statements appear in sequence, to avoid unwanted optimizations. A warning
15578 is generated if this advice is not followed.
15580 The @code{Asm} subprograms may be used in two ways. First the procedure
15581 forms can be used anywhere a procedure call would be valid, and
15582 correspond to what the RM calls ``intrinsic'' routines. Such calls can
15583 be used to intersperse machine instructions with other Ada statements.
15584 Second, the function forms, which return a dummy value of the limited
15585 private type @code{Asm_Insn}, can be used in code statements, and indeed
15586 this is the only context where such calls are allowed. Code statements
15587 appear as aggregates of the form:
15589 @smallexample @c ada
15590 Asm_Insn'(Asm (@dots{}));
15591 Asm_Insn'(Asm_Volatile (@dots{}));
15595 In accordance with RM rules, such code statements are allowed only
15596 within subprograms whose entire body consists of such statements. It is
15597 not permissible to intermix such statements with other Ada statements.
15599 Typically the form using intrinsic procedure calls is more convenient
15600 and more flexible. The code statement form is provided to meet the RM
15601 suggestion that such a facility should be made available. The following
15602 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15603 is used, the arguments may be given in arbitrary order, following the
15604 normal rules for use of positional and named arguments)
15608 [Template =>] static_string_EXPRESSION
15609 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
15610 [,[Inputs =>] INPUT_OPERAND_LIST ]
15611 [,[Clobber =>] static_string_EXPRESSION ]
15612 [,[Volatile =>] static_boolean_EXPRESSION] )
15614 OUTPUT_OPERAND_LIST ::=
15615 [PREFIX.]No_Output_Operands
15616 | OUTPUT_OPERAND_ATTRIBUTE
15617 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15619 OUTPUT_OPERAND_ATTRIBUTE ::=
15620 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15622 INPUT_OPERAND_LIST ::=
15623 [PREFIX.]No_Input_Operands
15624 | INPUT_OPERAND_ATTRIBUTE
15625 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15627 INPUT_OPERAND_ATTRIBUTE ::=
15628 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15632 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15633 are declared in the package @code{Machine_Code} and must be referenced
15634 according to normal visibility rules. In particular if there is no
15635 @code{use} clause for this package, then appropriate package name
15636 qualification is required.
15638 @node GNAT Implementation of Tasking
15639 @section GNAT Implementation of Tasking
15642 This chapter outlines the basic GNAT approach to tasking (in particular,
15643 a multi-layered library for portability) and discusses issues related
15644 to compliance with the Real-Time Systems Annex.
15647 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15648 * Ensuring Compliance with the Real-Time Annex::
15651 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15652 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15655 GNAT's run-time support comprises two layers:
15658 @item GNARL (GNAT Run-time Layer)
15659 @item GNULL (GNAT Low-level Library)
15663 In GNAT, Ada's tasking services rely on a platform and OS independent
15664 layer known as GNARL@. This code is responsible for implementing the
15665 correct semantics of Ada's task creation, rendezvous, protected
15668 GNARL decomposes Ada's tasking semantics into simpler lower level
15669 operations such as create a thread, set the priority of a thread,
15670 yield, create a lock, lock/unlock, etc. The spec for these low-level
15671 operations constitutes GNULLI, the GNULL Interface. This interface is
15672 directly inspired from the POSIX real-time API@.
15674 If the underlying executive or OS implements the POSIX standard
15675 faithfully, the GNULL Interface maps as is to the services offered by
15676 the underlying kernel. Otherwise, some target dependent glue code maps
15677 the services offered by the underlying kernel to the semantics expected
15680 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
15681 key point is that each Ada task is mapped on a thread in the underlying
15682 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
15684 In addition Ada task priorities map onto the underlying thread priorities.
15685 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15689 The underlying scheduler is used to schedule the Ada tasks. This
15690 makes Ada tasks as efficient as kernel threads from a scheduling
15694 Interaction with code written in C containing threads is eased
15695 since at the lowest level Ada tasks and C threads map onto the same
15696 underlying kernel concept.
15699 When an Ada task is blocked during I/O the remaining Ada tasks are
15703 On multiprocessor systems Ada tasks can execute in parallel.
15707 Some threads libraries offer a mechanism to fork a new process, with the
15708 child process duplicating the threads from the parent.
15710 support this functionality when the parent contains more than one task.
15711 @cindex Forking a new process
15713 @node Ensuring Compliance with the Real-Time Annex
15714 @subsection Ensuring Compliance with the Real-Time Annex
15715 @cindex Real-Time Systems Annex compliance
15718 Although mapping Ada tasks onto
15719 the underlying threads has significant advantages, it does create some
15720 complications when it comes to respecting the scheduling semantics
15721 specified in the real-time annex (Annex D).
15723 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15724 scheduling policy states:
15727 @emph{When the active priority of a ready task that is not running
15728 changes, or the setting of its base priority takes effect, the
15729 task is removed from the ready queue for its old active priority
15730 and is added at the tail of the ready queue for its new active
15731 priority, except in the case where the active priority is lowered
15732 due to the loss of inherited priority, in which case the task is
15733 added at the head of the ready queue for its new active priority.}
15737 While most kernels do put tasks at the end of the priority queue when
15738 a task changes its priority, (which respects the main
15739 FIFO_Within_Priorities requirement), almost none keep a thread at the
15740 beginning of its priority queue when its priority drops from the loss
15741 of inherited priority.
15743 As a result most vendors have provided incomplete Annex D implementations.
15745 The GNAT run-time, has a nice cooperative solution to this problem
15746 which ensures that accurate FIFO_Within_Priorities semantics are
15749 The principle is as follows. When an Ada task T is about to start
15750 running, it checks whether some other Ada task R with the same
15751 priority as T has been suspended due to the loss of priority
15752 inheritance. If this is the case, T yields and is placed at the end of
15753 its priority queue. When R arrives at the front of the queue it
15756 Note that this simple scheme preserves the relative order of the tasks
15757 that were ready to execute in the priority queue where R has been
15760 @node GNAT Implementation of Shared Passive Packages
15761 @section GNAT Implementation of Shared Passive Packages
15762 @cindex Shared passive packages
15765 GNAT fully implements the pragma @code{Shared_Passive} for
15766 @cindex pragma @code{Shared_Passive}
15767 the purpose of designating shared passive packages.
15768 This allows the use of passive partitions in the
15769 context described in the Ada Reference Manual; i.e., for communication
15770 between separate partitions of a distributed application using the
15771 features in Annex E.
15773 @cindex Distribution Systems Annex
15775 However, the implementation approach used by GNAT provides for more
15776 extensive usage as follows:
15779 @item Communication between separate programs
15781 This allows separate programs to access the data in passive
15782 partitions, using protected objects for synchronization where
15783 needed. The only requirement is that the two programs have a
15784 common shared file system. It is even possible for programs
15785 running on different machines with different architectures
15786 (e.g.@: different endianness) to communicate via the data in
15787 a passive partition.
15789 @item Persistence between program runs
15791 The data in a passive package can persist from one run of a
15792 program to another, so that a later program sees the final
15793 values stored by a previous run of the same program.
15798 The implementation approach used is to store the data in files. A
15799 separate stream file is created for each object in the package, and
15800 an access to an object causes the corresponding file to be read or
15803 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15804 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15805 set to the directory to be used for these files.
15806 The files in this directory
15807 have names that correspond to their fully qualified names. For
15808 example, if we have the package
15810 @smallexample @c ada
15812 pragma Shared_Passive (X);
15819 and the environment variable is set to @code{/stemp/}, then the files created
15820 will have the names:
15828 These files are created when a value is initially written to the object, and
15829 the files are retained until manually deleted. This provides the persistence
15830 semantics. If no file exists, it means that no partition has assigned a value
15831 to the variable; in this case the initial value declared in the package
15832 will be used. This model ensures that there are no issues in synchronizing
15833 the elaboration process, since elaboration of passive packages elaborates the
15834 initial values, but does not create the files.
15836 The files are written using normal @code{Stream_IO} access.
15837 If you want to be able
15838 to communicate between programs or partitions running on different
15839 architectures, then you should use the XDR versions of the stream attribute
15840 routines, since these are architecture independent.
15842 If active synchronization is required for access to the variables in the
15843 shared passive package, then as described in the Ada Reference Manual, the
15844 package may contain protected objects used for this purpose. In this case
15845 a lock file (whose name is @file{___lock} (three underscores)
15846 is created in the shared memory directory.
15847 @cindex @file{___lock} file (for shared passive packages)
15848 This is used to provide the required locking
15849 semantics for proper protected object synchronization.
15851 As of January 2003, GNAT supports shared passive packages on all platforms
15852 except for OpenVMS.
15854 @node Code Generation for Array Aggregates
15855 @section Code Generation for Array Aggregates
15858 * Static constant aggregates with static bounds::
15859 * Constant aggregates with unconstrained nominal types::
15860 * Aggregates with static bounds::
15861 * Aggregates with non-static bounds::
15862 * Aggregates in assignment statements::
15866 Aggregates have a rich syntax and allow the user to specify the values of
15867 complex data structures by means of a single construct. As a result, the
15868 code generated for aggregates can be quite complex and involve loops, case
15869 statements and multiple assignments. In the simplest cases, however, the
15870 compiler will recognize aggregates whose components and constraints are
15871 fully static, and in those cases the compiler will generate little or no
15872 executable code. The following is an outline of the code that GNAT generates
15873 for various aggregate constructs. For further details, you will find it
15874 useful to examine the output produced by the -gnatG flag to see the expanded
15875 source that is input to the code generator. You may also want to examine
15876 the assembly code generated at various levels of optimization.
15878 The code generated for aggregates depends on the context, the component values,
15879 and the type. In the context of an object declaration the code generated is
15880 generally simpler than in the case of an assignment. As a general rule, static
15881 component values and static subtypes also lead to simpler code.
15883 @node Static constant aggregates with static bounds
15884 @subsection Static constant aggregates with static bounds
15887 For the declarations:
15888 @smallexample @c ada
15889 type One_Dim is array (1..10) of integer;
15890 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15894 GNAT generates no executable code: the constant ar0 is placed in static memory.
15895 The same is true for constant aggregates with named associations:
15897 @smallexample @c ada
15898 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15899 Cr3 : constant One_Dim := (others => 7777);
15903 The same is true for multidimensional constant arrays such as:
15905 @smallexample @c ada
15906 type two_dim is array (1..3, 1..3) of integer;
15907 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15911 The same is true for arrays of one-dimensional arrays: the following are
15914 @smallexample @c ada
15915 type ar1b is array (1..3) of boolean;
15916 type ar_ar is array (1..3) of ar1b;
15917 None : constant ar1b := (others => false); -- fully static
15918 None2 : constant ar_ar := (1..3 => None); -- fully static
15922 However, for multidimensional aggregates with named associations, GNAT will
15923 generate assignments and loops, even if all associations are static. The
15924 following two declarations generate a loop for the first dimension, and
15925 individual component assignments for the second dimension:
15927 @smallexample @c ada
15928 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15929 Zero2: constant two_dim := (others => (others => 0));
15932 @node Constant aggregates with unconstrained nominal types
15933 @subsection Constant aggregates with unconstrained nominal types
15936 In such cases the aggregate itself establishes the subtype, so that
15937 associations with @code{others} cannot be used. GNAT determines the
15938 bounds for the actual subtype of the aggregate, and allocates the
15939 aggregate statically as well. No code is generated for the following:
15941 @smallexample @c ada
15942 type One_Unc is array (natural range <>) of integer;
15943 Cr_Unc : constant One_Unc := (12,24,36);
15946 @node Aggregates with static bounds
15947 @subsection Aggregates with static bounds
15950 In all previous examples the aggregate was the initial (and immutable) value
15951 of a constant. If the aggregate initializes a variable, then code is generated
15952 for it as a combination of individual assignments and loops over the target
15953 object. The declarations
15955 @smallexample @c ada
15956 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15957 Cr_Var2 : One_Dim := (others > -1);
15961 generate the equivalent of
15963 @smallexample @c ada
15969 for I in Cr_Var2'range loop
15974 @node Aggregates with non-static bounds
15975 @subsection Aggregates with non-static bounds
15978 If the bounds of the aggregate are not statically compatible with the bounds
15979 of the nominal subtype of the target, then constraint checks have to be
15980 generated on the bounds. For a multidimensional array, constraint checks may
15981 have to be applied to sub-arrays individually, if they do not have statically
15982 compatible subtypes.
15984 @node Aggregates in assignment statements
15985 @subsection Aggregates in assignment statements
15988 In general, aggregate assignment requires the construction of a temporary,
15989 and a copy from the temporary to the target of the assignment. This is because
15990 it is not always possible to convert the assignment into a series of individual
15991 component assignments. For example, consider the simple case:
15993 @smallexample @c ada
15998 This cannot be converted into:
16000 @smallexample @c ada
16006 So the aggregate has to be built first in a separate location, and then
16007 copied into the target. GNAT recognizes simple cases where this intermediate
16008 step is not required, and the assignments can be performed in place, directly
16009 into the target. The following sufficient criteria are applied:
16013 The bounds of the aggregate are static, and the associations are static.
16015 The components of the aggregate are static constants, names of
16016 simple variables that are not renamings, or expressions not involving
16017 indexed components whose operands obey these rules.
16021 If any of these conditions are violated, the aggregate will be built in
16022 a temporary (created either by the front-end or the code generator) and then
16023 that temporary will be copied onto the target.
16025 @node The Size of Discriminated Records with Default Discriminants
16026 @section The Size of Discriminated Records with Default Discriminants
16029 If a discriminated type @code{T} has discriminants with default values, it is
16030 possible to declare an object of this type without providing an explicit
16033 @smallexample @c ada
16035 type Size is range 1..100;
16037 type Rec (D : Size := 15) is record
16038 Name : String (1..D);
16046 Such an object is said to be @emph{unconstrained}.
16047 The discriminant of the object
16048 can be modified by a full assignment to the object, as long as it preserves the
16049 relation between the value of the discriminant, and the value of the components
16052 @smallexample @c ada
16054 Word := (3, "yes");
16056 Word := (5, "maybe");
16058 Word := (5, "no"); -- raises Constraint_Error
16063 In order to support this behavior efficiently, an unconstrained object is
16064 given the maximum size that any value of the type requires. In the case
16065 above, @code{Word} has storage for the discriminant and for
16066 a @code{String} of length 100.
16067 It is important to note that unconstrained objects do not require dynamic
16068 allocation. It would be an improper implementation to place on the heap those
16069 components whose size depends on discriminants. (This improper implementation
16070 was used by some Ada83 compilers, where the @code{Name} component above
16072 been stored as a pointer to a dynamic string). Following the principle that
16073 dynamic storage management should never be introduced implicitly,
16074 an Ada compiler should reserve the full size for an unconstrained declared
16075 object, and place it on the stack.
16077 This maximum size approach
16078 has been a source of surprise to some users, who expect the default
16079 values of the discriminants to determine the size reserved for an
16080 unconstrained object: ``If the default is 15, why should the object occupy
16082 The answer, of course, is that the discriminant may be later modified,
16083 and its full range of values must be taken into account. This is why the
16088 type Rec (D : Positive := 15) is record
16089 Name : String (1..D);
16097 is flagged by the compiler with a warning:
16098 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16099 because the required size includes @code{Positive'Last}
16100 bytes. As the first example indicates, the proper approach is to declare an
16101 index type of ``reasonable'' range so that unconstrained objects are not too
16104 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16105 created in the heap by means of an allocator, then it is @emph{not}
16107 it is constrained by the default values of the discriminants, and those values
16108 cannot be modified by full assignment. This is because in the presence of
16109 aliasing all views of the object (which may be manipulated by different tasks,
16110 say) must be consistent, so it is imperative that the object, once created,
16113 @node Strict Conformance to the Ada Reference Manual
16114 @section Strict Conformance to the Ada Reference Manual
16117 The dynamic semantics defined by the Ada Reference Manual impose a set of
16118 run-time checks to be generated. By default, the GNAT compiler will insert many
16119 run-time checks into the compiled code, including most of those required by the
16120 Ada Reference Manual. However, there are three checks that are not enabled
16121 in the default mode for efficiency reasons: arithmetic overflow checking for
16122 integer operations (including division by zero), checks for access before
16123 elaboration on subprogram calls, and stack overflow checking (most operating
16124 systems do not perform this check by default).
16126 Strict conformance to the Ada Reference Manual can be achieved by adding
16127 three compiler options for overflow checking for integer operations
16128 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16129 calls and generic instantiations (@option{-gnatE}), and stack overflow
16130 checking (@option{-fstack-check}).
16132 Note that the result of a floating point arithmetic operation in overflow and
16133 invalid situations, when the @code{Machine_Overflows} attribute of the result
16134 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16135 case for machines compliant with the IEEE floating-point standard, but on
16136 machines that are not fully compliant with this standard, such as Alpha, the
16137 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16138 behavior (although at the cost of a significant performance penalty), so
16139 infinite and and NaN values are properly generated.
16141 @node Obsolescent Features
16142 @chapter Obsolescent Features
16145 This chapter describes features that are provided by GNAT, but are
16146 considered obsolescent since there are preferred ways of achieving
16147 the same effect. These features are provided solely for historical
16148 compatibility purposes.
16151 * pragma No_Run_Time::
16152 * pragma Ravenscar::
16153 * pragma Restricted_Run_Time::
16156 @node pragma No_Run_Time
16157 @section pragma No_Run_Time
16159 The pragma @code{No_Run_Time} is used to achieve an affect similar
16160 to the use of the "Zero Foot Print" configurable run time, but without
16161 requiring a specially configured run time. The result of using this
16162 pragma, which must be used for all units in a partition, is to restrict
16163 the use of any language features requiring run-time support code. The
16164 preferred usage is to use an appropriately configured run-time that
16165 includes just those features that are to be made accessible.
16167 @node pragma Ravenscar
16168 @section pragma Ravenscar
16170 The pragma @code{Ravenscar} has exactly the same effect as pragma
16171 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16172 is part of the new Ada 2005 standard.
16174 @node pragma Restricted_Run_Time
16175 @section pragma Restricted_Run_Time
16177 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16178 pragma @code{Profile (Restricted)}. The latter usage is
16179 preferred since the Ada 2005 pragma @code{Profile} is intended for
16180 this kind of implementation dependent addition.
16183 @c GNU Free Documentation License
16185 @node Index,,GNU Free Documentation License, Top