[multiple changes]
[gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c o
7 @c GNAT DOCUMENTATION o
8 @c o
9 @c G N A T _ RM o
10 @c o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
12 @c o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index::
88
89 --- The Detailed Node Listing ---
90
91 About This Guide
92
93 * What This Reference Manual Contains::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Ada_83::
100 * Pragma Ada_95::
101 * Pragma Ada_05::
102 * Pragma Ada_2005::
103 * Pragma Ada_12::
104 * Pragma Ada_2012::
105 * Pragma Annotate::
106 * Pragma Assert::
107 * Pragma Assertion_Policy::
108 * Pragma Assume_No_Invalid_Values::
109 * Pragma Ast_Entry::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check::
112 * Pragma Check_Name::
113 * Pragma Check_Policy::
114 * Pragma Comment::
115 * Pragma Common_Object::
116 * Pragma Compile_Time_Error::
117 * Pragma Compile_Time_Warning::
118 * Pragma Compiler_Unit::
119 * Pragma Complete_Representation::
120 * Pragma Complex_Representation::
121 * Pragma Component_Alignment::
122 * Pragma Convention_Identifier::
123 * Pragma CPP_Class::
124 * Pragma CPP_Constructor::
125 * Pragma CPP_Virtual::
126 * Pragma CPP_Vtable::
127 * Pragma Debug::
128 * Pragma Debug_Policy::
129 * Pragma Detect_Blocking::
130 * Pragma Elaboration_Checks::
131 * Pragma Eliminate::
132 * Pragma Export_Exception::
133 * Pragma Export_Function::
134 * Pragma Export_Object::
135 * Pragma Export_Procedure::
136 * Pragma Export_Value::
137 * Pragma Export_Valued_Procedure::
138 * Pragma Extend_System::
139 * Pragma Extensions_Allowed::
140 * Pragma External::
141 * Pragma External_Name_Casing::
142 * Pragma Fast_Math::
143 * Pragma Favor_Top_Level::
144 * Pragma Finalize_Storage_Only::
145 * Pragma Float_Representation::
146 * Pragma Ident::
147 * Pragma Implemented::
148 * Pragma Implicit_Packing::
149 * Pragma Import_Exception::
150 * Pragma Import_Function::
151 * Pragma Import_Object::
152 * Pragma Import_Procedure::
153 * Pragma Import_Valued_Procedure::
154 * Pragma Initialize_Scalars::
155 * Pragma Inline_Always::
156 * Pragma Inline_Generic::
157 * Pragma Interface::
158 * Pragma Interface_Name::
159 * Pragma Interrupt_Handler::
160 * Pragma Interrupt_State::
161 * Pragma Invariant::
162 * Pragma Keep_Names::
163 * Pragma License::
164 * Pragma Link_With::
165 * Pragma Linker_Alias::
166 * Pragma Linker_Constructor::
167 * Pragma Linker_Destructor::
168 * Pragma Linker_Section::
169 * Pragma Long_Float::
170 * Pragma Machine_Attribute::
171 * Pragma Main::
172 * Pragma Main_Storage::
173 * Pragma No_Body::
174 * Pragma No_Return::
175 * Pragma No_Strict_Aliasing ::
176 * Pragma Normalize_Scalars::
177 * Pragma Obsolescent::
178 * Pragma Optimize_Alignment::
179 * Pragma Ordered::
180 * Pragma Passive::
181 * Pragma Persistent_BSS::
182 * Pragma Polling::
183 * Pragma Postcondition::
184 * Pragma Precondition::
185 * Pragma Profile (Ravenscar)::
186 * Pragma Profile (Restricted)::
187 * Pragma Psect_Object::
188 * Pragma Pure_Function::
189 * Pragma Restriction_Warnings::
190 * Pragma Shared::
191 * Pragma Short_Circuit_And_Or::
192 * Pragma Short_Descriptors::
193 * Pragma Source_File_Name::
194 * Pragma Source_File_Name_Project::
195 * Pragma Source_Reference::
196 * Pragma Static_Elaboration_Desired::
197 * Pragma Stream_Convert::
198 * Pragma Style_Checks::
199 * Pragma Subtitle::
200 * Pragma Suppress::
201 * Pragma Suppress_All::
202 * Pragma Suppress_Exception_Locations::
203 * Pragma Suppress_Initialization::
204 * Pragma Task_Info::
205 * Pragma Task_Name::
206 * Pragma Task_Storage::
207 * Pragma Test_Case::
208 * Pragma Thread_Local_Storage::
209 * Pragma Time_Slice::
210 * Pragma Title::
211 * Pragma Unchecked_Union::
212 * Pragma Unimplemented_Unit::
213 * Pragma Universal_Aliasing ::
214 * Pragma Universal_Data::
215 * Pragma Unmodified::
216 * Pragma Unreferenced::
217 * Pragma Unreferenced_Objects::
218 * Pragma Unreserve_All_Interrupts::
219 * Pragma Unsuppress::
220 * Pragma Use_VADS_Size::
221 * Pragma Validity_Checks::
222 * Pragma Volatile::
223 * Pragma Warnings::
224 * Pragma Weak_External::
225 * Pragma Wide_Character_Encoding::
226
227 Implementation Defined Attributes
228
229 * Abort_Signal::
230 * Address_Size::
231 * Asm_Input::
232 * Asm_Output::
233 * AST_Entry::
234 * Bit::
235 * Bit_Position::
236 * Compiler_Version::
237 * Code_Address::
238 * Default_Bit_Order::
239 * Descriptor_Size::
240 * Elaborated::
241 * Elab_Body::
242 * Elab_Spec::
243 * Elab_Subp_Body::
244 * Emax::
245 * Enabled::
246 * Enum_Rep::
247 * Enum_Val::
248 * Epsilon::
249 * Fixed_Value::
250 * Has_Access_Values::
251 * Has_Discriminants::
252 * Img::
253 * Integer_Value::
254 * Invalid_Value::
255 * Large::
256 * Machine_Size::
257 * Mantissa::
258 * Max_Interrupt_Priority::
259 * Max_Priority::
260 * Maximum_Alignment::
261 * Mechanism_Code::
262 * Null_Parameter::
263 * Object_Size::
264 * Old::
265 * Passed_By_Reference::
266 * Pool_Address::
267 * Range_Length::
268 * Result::
269 * Safe_Emax::
270 * Safe_Large::
271 * Small::
272 * Storage_Unit::
273 * Stub_Type::
274 * System_Allocator_Alignment::
275 * Target_Name::
276 * Tick::
277 * To_Address::
278 * Type_Class::
279 * UET_Address::
280 * Unconstrained_Array::
281 * Universal_Literal_String::
282 * Unrestricted_Access::
283 * VADS_Size::
284 * Value_Size::
285 * Wchar_T_Size::
286 * Word_Size::
287
288 The Implementation of Standard I/O
289
290 * Standard I/O Packages::
291 * FORM Strings::
292 * Direct_IO::
293 * Sequential_IO::
294 * Text_IO::
295 * Wide_Text_IO::
296 * Wide_Wide_Text_IO::
297 * Stream_IO::
298 * Text Translation::
299 * Shared Files::
300 * Filenames encoding::
301 * Open Modes::
302 * Operations on C Streams::
303 * Interfacing to C Streams::
304
305 The GNAT Library
306
307 * Ada.Characters.Latin_9 (a-chlat9.ads)::
308 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
309 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
310 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
311 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
312 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
313 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
314 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
315 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
316 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
317 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
318 * Ada.Command_Line.Environment (a-colien.ads)::
319 * Ada.Command_Line.Remove (a-colire.ads)::
320 * Ada.Command_Line.Response_File (a-clrefi.ads)::
321 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
322 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
323 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
324 * Ada.Exceptions.Traceback (a-exctra.ads)::
325 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
326 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
327 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
328 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
329 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
330 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
331 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
332 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
333 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
334 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
335 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
336 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
337 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
338 * GNAT.Altivec (g-altive.ads)::
339 * GNAT.Altivec.Conversions (g-altcon.ads)::
340 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
341 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
342 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
343 * GNAT.Array_Split (g-arrspl.ads)::
344 * GNAT.AWK (g-awk.ads)::
345 * GNAT.Bounded_Buffers (g-boubuf.ads)::
346 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
347 * GNAT.Bubble_Sort (g-bubsor.ads)::
348 * GNAT.Bubble_Sort_A (g-busora.ads)::
349 * GNAT.Bubble_Sort_G (g-busorg.ads)::
350 * GNAT.Byte_Order_Mark (g-byorma.ads)::
351 * GNAT.Byte_Swapping (g-bytswa.ads)::
352 * GNAT.Calendar (g-calend.ads)::
353 * GNAT.Calendar.Time_IO (g-catiio.ads)::
354 * GNAT.Case_Util (g-casuti.ads)::
355 * GNAT.CGI (g-cgi.ads)::
356 * GNAT.CGI.Cookie (g-cgicoo.ads)::
357 * GNAT.CGI.Debug (g-cgideb.ads)::
358 * GNAT.Command_Line (g-comlin.ads)::
359 * GNAT.Compiler_Version (g-comver.ads)::
360 * GNAT.Ctrl_C (g-ctrl_c.ads)::
361 * GNAT.CRC32 (g-crc32.ads)::
362 * GNAT.Current_Exception (g-curexc.ads)::
363 * GNAT.Debug_Pools (g-debpoo.ads)::
364 * GNAT.Debug_Utilities (g-debuti.ads)::
365 * GNAT.Decode_String (g-decstr.ads)::
366 * GNAT.Decode_UTF8_String (g-deutst.ads)::
367 * GNAT.Directory_Operations (g-dirope.ads)::
368 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
369 * GNAT.Dynamic_HTables (g-dynhta.ads)::
370 * GNAT.Dynamic_Tables (g-dyntab.ads)::
371 * GNAT.Encode_String (g-encstr.ads)::
372 * GNAT.Encode_UTF8_String (g-enutst.ads)::
373 * GNAT.Exception_Actions (g-excact.ads)::
374 * GNAT.Exception_Traces (g-exctra.ads)::
375 * GNAT.Exceptions (g-except.ads)::
376 * GNAT.Expect (g-expect.ads)::
377 * GNAT.Float_Control (g-flocon.ads)::
378 * GNAT.Heap_Sort (g-heasor.ads)::
379 * GNAT.Heap_Sort_A (g-hesora.ads)::
380 * GNAT.Heap_Sort_G (g-hesorg.ads)::
381 * GNAT.HTable (g-htable.ads)::
382 * GNAT.IO (g-io.ads)::
383 * GNAT.IO_Aux (g-io_aux.ads)::
384 * GNAT.Lock_Files (g-locfil.ads)::
385 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
386 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
387 * GNAT.MD5 (g-md5.ads)::
388 * GNAT.Memory_Dump (g-memdum.ads)::
389 * GNAT.Most_Recent_Exception (g-moreex.ads)::
390 * GNAT.OS_Lib (g-os_lib.ads)::
391 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
392 * GNAT.Random_Numbers (g-rannum.ads)::
393 * GNAT.Regexp (g-regexp.ads)::
394 * GNAT.Registry (g-regist.ads)::
395 * GNAT.Regpat (g-regpat.ads)::
396 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
397 * GNAT.Semaphores (g-semaph.ads)::
398 * GNAT.Serial_Communications (g-sercom.ads)::
399 * GNAT.SHA1 (g-sha1.ads)::
400 * GNAT.SHA224 (g-sha224.ads)::
401 * GNAT.SHA256 (g-sha256.ads)::
402 * GNAT.SHA384 (g-sha384.ads)::
403 * GNAT.SHA512 (g-sha512.ads)::
404 * GNAT.Signals (g-signal.ads)::
405 * GNAT.Sockets (g-socket.ads)::
406 * GNAT.Source_Info (g-souinf.ads)::
407 * GNAT.Spelling_Checker (g-speche.ads)::
408 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
409 * GNAT.Spitbol.Patterns (g-spipat.ads)::
410 * GNAT.Spitbol (g-spitbo.ads)::
411 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
412 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
413 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
414 * GNAT.SSE (g-sse.ads)::
415 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
416 * GNAT.Strings (g-string.ads)::
417 * GNAT.String_Split (g-strspl.ads)::
418 * GNAT.Table (g-table.ads)::
419 * GNAT.Task_Lock (g-tasloc.ads)::
420 * GNAT.Threads (g-thread.ads)::
421 * GNAT.Time_Stamp (g-timsta.ads)::
422 * GNAT.Traceback (g-traceb.ads)::
423 * GNAT.Traceback.Symbolic (g-trasym.ads)::
424 * GNAT.UTF_32 (g-utf_32.ads)::
425 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
426 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
427 * GNAT.Wide_String_Split (g-wistsp.ads)::
428 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
429 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
430 * Interfaces.C.Extensions (i-cexten.ads)::
431 * Interfaces.C.Streams (i-cstrea.ads)::
432 * Interfaces.CPP (i-cpp.ads)::
433 * Interfaces.Packed_Decimal (i-pacdec.ads)::
434 * Interfaces.VxWorks (i-vxwork.ads)::
435 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
436 * System.Address_Image (s-addima.ads)::
437 * System.Assertions (s-assert.ads)::
438 * System.Memory (s-memory.ads)::
439 * System.Partition_Interface (s-parint.ads)::
440 * System.Pool_Global (s-pooglo.ads)::
441 * System.Pool_Local (s-pooloc.ads)::
442 * System.Restrictions (s-restri.ads)::
443 * System.Rident (s-rident.ads)::
444 * System.Strings.Stream_Ops (s-ststop.ads)::
445 * System.Task_Info (s-tasinf.ads)::
446 * System.Wch_Cnv (s-wchcnv.ads)::
447 * System.Wch_Con (s-wchcon.ads)::
448
449 Text_IO
450
451 * Text_IO Stream Pointer Positioning::
452 * Text_IO Reading and Writing Non-Regular Files::
453 * Get_Immediate::
454 * Treating Text_IO Files as Streams::
455 * Text_IO Extensions::
456 * Text_IO Facilities for Unbounded Strings::
457
458 Wide_Text_IO
459
460 * Wide_Text_IO Stream Pointer Positioning::
461 * Wide_Text_IO Reading and Writing Non-Regular Files::
462
463 Wide_Wide_Text_IO
464
465 * Wide_Wide_Text_IO Stream Pointer Positioning::
466 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
467
468 Interfacing to Other Languages
469
470 * Interfacing to C::
471 * Interfacing to C++::
472 * Interfacing to COBOL::
473 * Interfacing to Fortran::
474 * Interfacing to non-GNAT Ada code::
475
476 Specialized Needs Annexes
477
478 Implementation of Specific Ada Features
479 * Machine Code Insertions::
480 * GNAT Implementation of Tasking::
481 * GNAT Implementation of Shared Passive Packages::
482 * Code Generation for Array Aggregates::
483 * The Size of Discriminated Records with Default Discriminants::
484 * Strict Conformance to the Ada Reference Manual::
485
486 Implementation of Ada 2012 Features
487
488 Obsolescent Features
489
490 GNU Free Documentation License
491
492 Index
493 @end menu
494
495 @end ifnottex
496
497 @node About This Guide
498 @unnumbered About This Guide
499
500 @noindent
501 This manual contains useful information in writing programs using the
502 @value{EDITION} compiler. It includes information on implementation dependent
503 characteristics of @value{EDITION}, including all the information required by
504 Annex M of the Ada language standard.
505
506 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
507 Ada 83 compatibility mode.
508 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
509 but you can override with a compiler switch
510 to explicitly specify the language version.
511 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
512 @value{EDITION} User's Guide}, for details on these switches.)
513 Throughout this manual, references to ``Ada'' without a year suffix
514 apply to both the Ada 95 and Ada 2005 versions of the language.
515
516 Ada is designed to be highly portable.
517 In general, a program will have the same effect even when compiled by
518 different compilers on different platforms.
519 However, since Ada is designed to be used in a
520 wide variety of applications, it also contains a number of system
521 dependent features to be used in interfacing to the external world.
522 @cindex Implementation-dependent features
523 @cindex Portability
524
525 Note: Any program that makes use of implementation-dependent features
526 may be non-portable. You should follow good programming practice and
527 isolate and clearly document any sections of your program that make use
528 of these features in a non-portable manner.
529
530 @ifset PROEDITION
531 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
532 ``GNAT'' in the remainder of this document.
533 @end ifset
534
535 @menu
536 * What This Reference Manual Contains::
537 * Conventions::
538 * Related Information::
539 @end menu
540
541 @node What This Reference Manual Contains
542 @unnumberedsec What This Reference Manual Contains
543
544 @noindent
545 This reference manual contains the following chapters:
546
547 @itemize @bullet
548 @item
549 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
550 pragmas, which can be used to extend and enhance the functionality of the
551 compiler.
552
553 @item
554 @ref{Implementation Defined Attributes}, lists GNAT
555 implementation-dependent attributes which can be used to extend and
556 enhance the functionality of the compiler.
557
558 @item
559 @ref{Implementation Advice}, provides information on generally
560 desirable behavior which are not requirements that all compilers must
561 follow since it cannot be provided on all systems, or which may be
562 undesirable on some systems.
563
564 @item
565 @ref{Implementation Defined Characteristics}, provides a guide to
566 minimizing implementation dependent features.
567
568 @item
569 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
570 implemented by GNAT, and how they can be imported into user
571 application programs.
572
573 @item
574 @ref{Representation Clauses and Pragmas}, describes in detail the
575 way that GNAT represents data, and in particular the exact set
576 of representation clauses and pragmas that is accepted.
577
578 @item
579 @ref{Standard Library Routines}, provides a listing of packages and a
580 brief description of the functionality that is provided by Ada's
581 extensive set of standard library routines as implemented by GNAT@.
582
583 @item
584 @ref{The Implementation of Standard I/O}, details how the GNAT
585 implementation of the input-output facilities.
586
587 @item
588 @ref{The GNAT Library}, is a catalog of packages that complement
589 the Ada predefined library.
590
591 @item
592 @ref{Interfacing to Other Languages}, describes how programs
593 written in Ada using GNAT can be interfaced to other programming
594 languages.
595
596 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
597 of the specialized needs annexes.
598
599 @item
600 @ref{Implementation of Specific Ada Features}, discusses issues related
601 to GNAT's implementation of machine code insertions, tasking, and several
602 other features.
603
604 @item
605 @ref{Implementation of Ada 2012 Features}, describes the status of the
606 GNAT implementation of the Ada 2012 language standard.
607
608 @item
609 @ref{Obsolescent Features} documents implementation dependent features,
610 including pragmas and attributes, which are considered obsolescent, since
611 there are other preferred ways of achieving the same results. These
612 obsolescent forms are retained for backwards compatibility.
613
614 @end itemize
615
616 @cindex Ada 95 Language Reference Manual
617 @cindex Ada 2005 Language Reference Manual
618 @noindent
619 This reference manual assumes a basic familiarity with the Ada 95 language, as
620 described in the International Standard ANSI/ISO/IEC-8652:1995,
621 January 1995.
622 It does not require knowledge of the new features introduced by Ada 2005,
623 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
624 and Amendment 1).
625 Both reference manuals are included in the GNAT documentation
626 package.
627
628 @node Conventions
629 @unnumberedsec Conventions
630 @cindex Conventions, typographical
631 @cindex Typographical conventions
632
633 @noindent
634 Following are examples of the typographical and graphic conventions used
635 in this guide:
636
637 @itemize @bullet
638 @item
639 @code{Functions}, @code{utility program names}, @code{standard names},
640 and @code{classes}.
641
642 @item
643 @code{Option flags}
644
645 @item
646 @file{File names}, @samp{button names}, and @samp{field names}.
647
648 @item
649 @code{Variables}, @env{environment variables}, and @var{metasyntactic
650 variables}.
651
652 @item
653 @emph{Emphasis}.
654
655 @item
656 [optional information or parameters]
657
658 @item
659 Examples are described by text
660 @smallexample
661 and then shown this way.
662 @end smallexample
663 @end itemize
664
665 @noindent
666 Commands that are entered by the user are preceded in this manual by the
667 characters @samp{$ } (dollar sign followed by space). If your system uses this
668 sequence as a prompt, then the commands will appear exactly as you see them
669 in the manual. If your system uses some other prompt, then the command will
670 appear with the @samp{$} replaced by whatever prompt character you are using.
671
672 @node Related Information
673 @unnumberedsec Related Information
674 @noindent
675 See the following documents for further information on GNAT:
676
677 @itemize @bullet
678 @item
679 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
680 @value{EDITION} User's Guide}, which provides information on how to use the
681 GNAT compiler system.
682
683 @item
684 @cite{Ada 95 Reference Manual}, which contains all reference
685 material for the Ada 95 programming language.
686
687 @item
688 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
689 of the Ada 95 standard. The annotations describe
690 detailed aspects of the design decision, and in particular contain useful
691 sections on Ada 83 compatibility.
692
693 @item
694 @cite{Ada 2005 Reference Manual}, which contains all reference
695 material for the Ada 2005 programming language.
696
697 @item
698 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
699 of the Ada 2005 standard. The annotations describe
700 detailed aspects of the design decision, and in particular contain useful
701 sections on Ada 83 and Ada 95 compatibility.
702
703 @item
704 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
705 which contains specific information on compatibility between GNAT and
706 DEC Ada 83 systems.
707
708 @item
709 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
710 describes in detail the pragmas and attributes provided by the DEC Ada 83
711 compiler system.
712
713 @end itemize
714
715 @node Implementation Defined Pragmas
716 @chapter Implementation Defined Pragmas
717
718 @noindent
719 Ada defines a set of pragmas that can be used to supply additional
720 information to the compiler. These language defined pragmas are
721 implemented in GNAT and work as described in the Ada Reference Manual.
722
723 In addition, Ada allows implementations to define additional pragmas
724 whose meaning is defined by the implementation. GNAT provides a number
725 of these implementation-defined pragmas, which can be used to extend
726 and enhance the functionality of the compiler. This section of the GNAT
727 Reference Manual describes these additional pragmas.
728
729 Note that any program using these pragmas might not be portable to other
730 compilers (although GNAT implements this set of pragmas on all
731 platforms). Therefore if portability to other compilers is an important
732 consideration, the use of these pragmas should be minimized.
733
734 @menu
735 * Pragma Abort_Defer::
736 * Pragma Ada_83::
737 * Pragma Ada_95::
738 * Pragma Ada_05::
739 * Pragma Ada_2005::
740 * Pragma Ada_12::
741 * Pragma Ada_2012::
742 * Pragma Annotate::
743 * Pragma Assert::
744 * Pragma Assertion_Policy::
745 * Pragma Assume_No_Invalid_Values::
746 * Pragma Ast_Entry::
747 * Pragma C_Pass_By_Copy::
748 * Pragma Check::
749 * Pragma Check_Name::
750 * Pragma Check_Policy::
751 * Pragma Comment::
752 * Pragma Common_Object::
753 * Pragma Compile_Time_Error::
754 * Pragma Compile_Time_Warning::
755 * Pragma Compiler_Unit::
756 * Pragma Complete_Representation::
757 * Pragma Complex_Representation::
758 * Pragma Component_Alignment::
759 * Pragma Convention_Identifier::
760 * Pragma CPP_Class::
761 * Pragma CPP_Constructor::
762 * Pragma CPP_Virtual::
763 * Pragma CPP_Vtable::
764 * Pragma Debug::
765 * Pragma Debug_Policy::
766 * Pragma Detect_Blocking::
767 * Pragma Elaboration_Checks::
768 * Pragma Eliminate::
769 * Pragma Export_Exception::
770 * Pragma Export_Function::
771 * Pragma Export_Object::
772 * Pragma Export_Procedure::
773 * Pragma Export_Value::
774 * Pragma Export_Valued_Procedure::
775 * Pragma Extend_System::
776 * Pragma Extensions_Allowed::
777 * Pragma External::
778 * Pragma External_Name_Casing::
779 * Pragma Fast_Math::
780 * Pragma Favor_Top_Level::
781 * Pragma Finalize_Storage_Only::
782 * Pragma Float_Representation::
783 * Pragma Ident::
784 * Pragma Implemented::
785 * Pragma Implicit_Packing::
786 * Pragma Import_Exception::
787 * Pragma Import_Function::
788 * Pragma Import_Object::
789 * Pragma Import_Procedure::
790 * Pragma Import_Valued_Procedure::
791 * Pragma Initialize_Scalars::
792 * Pragma Inline_Always::
793 * Pragma Inline_Generic::
794 * Pragma Interface::
795 * Pragma Interface_Name::
796 * Pragma Interrupt_Handler::
797 * Pragma Interrupt_State::
798 * Pragma Invariant::
799 * Pragma Keep_Names::
800 * Pragma License::
801 * Pragma Link_With::
802 * Pragma Linker_Alias::
803 * Pragma Linker_Constructor::
804 * Pragma Linker_Destructor::
805 * Pragma Linker_Section::
806 * Pragma Long_Float::
807 * Pragma Machine_Attribute::
808 * Pragma Main::
809 * Pragma Main_Storage::
810 * Pragma No_Body::
811 * Pragma No_Return::
812 * Pragma No_Strict_Aliasing::
813 * Pragma Normalize_Scalars::
814 * Pragma Obsolescent::
815 * Pragma Optimize_Alignment::
816 * Pragma Ordered::
817 * Pragma Passive::
818 * Pragma Persistent_BSS::
819 * Pragma Polling::
820 * Pragma Postcondition::
821 * Pragma Precondition::
822 * Pragma Profile (Ravenscar)::
823 * Pragma Profile (Restricted)::
824 * Pragma Psect_Object::
825 * Pragma Pure_Function::
826 * Pragma Restriction_Warnings::
827 * Pragma Shared::
828 * Pragma Short_Circuit_And_Or::
829 * Pragma Short_Descriptors::
830 * Pragma Source_File_Name::
831 * Pragma Source_File_Name_Project::
832 * Pragma Source_Reference::
833 * Pragma Static_Elaboration_Desired::
834 * Pragma Stream_Convert::
835 * Pragma Style_Checks::
836 * Pragma Subtitle::
837 * Pragma Suppress::
838 * Pragma Suppress_All::
839 * Pragma Suppress_Exception_Locations::
840 * Pragma Suppress_Initialization::
841 * Pragma Task_Info::
842 * Pragma Task_Name::
843 * Pragma Task_Storage::
844 * Pragma Test_Case::
845 * Pragma Thread_Local_Storage::
846 * Pragma Time_Slice::
847 * Pragma Title::
848 * Pragma Unchecked_Union::
849 * Pragma Unimplemented_Unit::
850 * Pragma Universal_Aliasing ::
851 * Pragma Universal_Data::
852 * Pragma Unmodified::
853 * Pragma Unreferenced::
854 * Pragma Unreferenced_Objects::
855 * Pragma Unreserve_All_Interrupts::
856 * Pragma Unsuppress::
857 * Pragma Use_VADS_Size::
858 * Pragma Validity_Checks::
859 * Pragma Volatile::
860 * Pragma Warnings::
861 * Pragma Weak_External::
862 * Pragma Wide_Character_Encoding::
863 @end menu
864
865 @node Pragma Abort_Defer
866 @unnumberedsec Pragma Abort_Defer
867 @findex Abort_Defer
868 @cindex Deferring aborts
869 @noindent
870 Syntax:
871 @smallexample
872 pragma Abort_Defer;
873 @end smallexample
874
875 @noindent
876 This pragma must appear at the start of the statement sequence of a
877 handled sequence of statements (right after the @code{begin}). It has
878 the effect of deferring aborts for the sequence of statements (but not
879 for the declarations or handlers, if any, associated with this statement
880 sequence).
881
882 @node Pragma Ada_83
883 @unnumberedsec Pragma Ada_83
884 @findex Ada_83
885 @noindent
886 Syntax:
887 @smallexample @c ada
888 pragma Ada_83;
889 @end smallexample
890
891 @noindent
892 A configuration pragma that establishes Ada 83 mode for the unit to
893 which it applies, regardless of the mode set by the command line
894 switches. In Ada 83 mode, GNAT attempts to be as compatible with
895 the syntax and semantics of Ada 83, as defined in the original Ada
896 83 Reference Manual as possible. In particular, the keywords added by Ada 95
897 and Ada 2005 are not recognized, optional package bodies are allowed,
898 and generics may name types with unknown discriminants without using
899 the @code{(<>)} notation. In addition, some but not all of the additional
900 restrictions of Ada 83 are enforced.
901
902 Ada 83 mode is intended for two purposes. Firstly, it allows existing
903 Ada 83 code to be compiled and adapted to GNAT with less effort.
904 Secondly, it aids in keeping code backwards compatible with Ada 83.
905 However, there is no guarantee that code that is processed correctly
906 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
907 83 compiler, since GNAT does not enforce all the additional checks
908 required by Ada 83.
909
910 @node Pragma Ada_95
911 @unnumberedsec Pragma Ada_95
912 @findex Ada_95
913 @noindent
914 Syntax:
915 @smallexample @c ada
916 pragma Ada_95;
917 @end smallexample
918
919 @noindent
920 A configuration pragma that establishes Ada 95 mode for the unit to which
921 it applies, regardless of the mode set by the command line switches.
922 This mode is set automatically for the @code{Ada} and @code{System}
923 packages and their children, so you need not specify it in these
924 contexts. This pragma is useful when writing a reusable component that
925 itself uses Ada 95 features, but which is intended to be usable from
926 either Ada 83 or Ada 95 programs.
927
928 @node Pragma Ada_05
929 @unnumberedsec Pragma Ada_05
930 @findex Ada_05
931 @noindent
932 Syntax:
933 @smallexample @c ada
934 pragma Ada_05;
935 @end smallexample
936
937 @noindent
938 A configuration pragma that establishes Ada 2005 mode for the unit to which
939 it applies, regardless of the mode set by the command line switches.
940 This pragma is useful when writing a reusable component that
941 itself uses Ada 2005 features, but which is intended to be usable from
942 either Ada 83 or Ada 95 programs.
943
944 @node Pragma Ada_2005
945 @unnumberedsec Pragma Ada_2005
946 @findex Ada_2005
947 @noindent
948 Syntax:
949 @smallexample @c ada
950 pragma Ada_2005;
951 @end smallexample
952
953 @noindent
954 This configuration pragma is a synonym for pragma Ada_05 and has the
955 same syntax and effect.
956
957 @node Pragma Ada_12
958 @unnumberedsec Pragma Ada_12
959 @findex Ada_12
960 @noindent
961 Syntax:
962 @smallexample @c ada
963 pragma Ada_12;
964 @end smallexample
965
966 @noindent
967 A configuration pragma that establishes Ada 2012 mode for the unit to which
968 it applies, regardless of the mode set by the command line switches.
969 This mode is set automatically for the @code{Ada} and @code{System}
970 packages and their children, so you need not specify it in these
971 contexts. This pragma is useful when writing a reusable component that
972 itself uses Ada 2012 features, but which is intended to be usable from
973 Ada 83, Ada 95, or Ada 2005 programs.
974
975 @node Pragma Ada_2012
976 @unnumberedsec Pragma Ada_2012
977 @findex Ada_2005
978 @noindent
979 Syntax:
980 @smallexample @c ada
981 pragma Ada_2012;
982 @end smallexample
983
984 @noindent
985 This configuration pragma is a synonym for pragma Ada_12 and has the
986 same syntax and effect.
987
988 @node Pragma Annotate
989 @unnumberedsec Pragma Annotate
990 @findex Annotate
991 @noindent
992 Syntax:
993 @smallexample @c ada
994 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
995
996 ARG ::= NAME | EXPRESSION
997 @end smallexample
998
999 @noindent
1000 This pragma is used to annotate programs. @var{identifier} identifies
1001 the type of annotation. GNAT verifies that it is an identifier, but does
1002 not otherwise analyze it. The second optional identifier is also left
1003 unanalyzed, and by convention is used to control the action of the tool to
1004 which the annotation is addressed. The remaining @var{arg} arguments
1005 can be either string literals or more generally expressions.
1006 String literals are assumed to be either of type
1007 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1008 depending on the character literals they contain.
1009 All other kinds of arguments are analyzed as expressions, and must be
1010 unambiguous.
1011
1012 The analyzed pragma is retained in the tree, but not otherwise processed
1013 by any part of the GNAT compiler, except to generate corresponding note
1014 lines in the generated ALI file. For the format of these note lines, see
1015 the compiler source file lib-writ.ads. This pragma is intended for use by
1016 external tools, including ASIS@. The use of pragma Annotate does not
1017 affect the compilation process in any way. This pragma may be used as
1018 a configuration pragma.
1019
1020 @node Pragma Assert
1021 @unnumberedsec Pragma Assert
1022 @findex Assert
1023 @noindent
1024 Syntax:
1025 @smallexample @c ada
1026 pragma Assert (
1027 boolean_EXPRESSION
1028 [, string_EXPRESSION]);
1029 @end smallexample
1030
1031 @noindent
1032 The effect of this pragma depends on whether the corresponding command
1033 line switch is set to activate assertions. The pragma expands into code
1034 equivalent to the following:
1035
1036 @smallexample @c ada
1037 if assertions-enabled then
1038 if not boolean_EXPRESSION then
1039 System.Assertions.Raise_Assert_Failure
1040 (string_EXPRESSION);
1041 end if;
1042 end if;
1043 @end smallexample
1044
1045 @noindent
1046 The string argument, if given, is the message that will be associated
1047 with the exception occurrence if the exception is raised. If no second
1048 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1049 where @var{file} is the name of the source file containing the assert,
1050 and @var{nnn} is the line number of the assert. A pragma is not a
1051 statement, so if a statement sequence contains nothing but a pragma
1052 assert, then a null statement is required in addition, as in:
1053
1054 @smallexample @c ada
1055 @dots{}
1056 if J > 3 then
1057 pragma Assert (K > 3, "Bad value for K");
1058 null;
1059 end if;
1060 @end smallexample
1061
1062 @noindent
1063 Note that, as with the @code{if} statement to which it is equivalent, the
1064 type of the expression is either @code{Standard.Boolean}, or any type derived
1065 from this standard type.
1066
1067 If assertions are disabled (switch @option{-gnata} not used), then there
1068 is no run-time effect (and in particular, any side effects from the
1069 expression will not occur at run time). (The expression is still
1070 analyzed at compile time, and may cause types to be frozen if they are
1071 mentioned here for the first time).
1072
1073 If assertions are enabled, then the given expression is tested, and if
1074 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1075 which results in the raising of @code{Assert_Failure} with the given message.
1076
1077 You should generally avoid side effects in the expression arguments of
1078 this pragma, because these side effects will turn on and off with the
1079 setting of the assertions mode, resulting in assertions that have an
1080 effect on the program. However, the expressions are analyzed for
1081 semantic correctness whether or not assertions are enabled, so turning
1082 assertions on and off cannot affect the legality of a program.
1083
1084 Note that the implementation defined policy @code{DISABLE}, given in a
1085 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1086
1087 Note: this is a standard language-defined pragma in versions
1088 of Ada from 2005 on. In GNAT, it is implemented in all versions
1089 of Ada, and the DISABLE policy is an implementation-defined
1090 addition.
1091
1092
1093 @node Pragma Assertion_Policy
1094 @unnumberedsec Pragma Assertion_Policy
1095 @findex Debug_Policy
1096 @noindent
1097 Syntax:
1098
1099 @smallexample @c ada
1100 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1101 @end smallexample
1102
1103 @noindent
1104 If the argument is @code{CHECK}, then pragma @code{Assert} is enabled.
1105 If the argument is @code{IGNORE}, then pragma @code{Assert} is ignored.
1106 This pragma overrides the effect of the @option{-gnata} switch on the
1107 command line.
1108
1109 The implementation defined policy @code{DISABLE} is like
1110 @code{IGNORE} except that it completely disables semantic
1111 checking of the argument to @code{pragma Assert}. This may
1112 be useful when the pragma argument references subprograms
1113 in a with'ed package which is replaced by a dummy package
1114 for the final build.
1115
1116 Note: this is a standard language-defined pragma in versions
1117 of Ada from 2005 on. In GNAT, it is implemented in all versions
1118 of Ada, and the DISABLE policy is an implementation-defined
1119 addition.
1120
1121 @node Pragma Assume_No_Invalid_Values
1122 @unnumberedsec Pragma Assume_No_Invalid_Values
1123 @findex Assume_No_Invalid_Values
1124 @cindex Invalid representations
1125 @cindex Invalid values
1126 @noindent
1127 Syntax:
1128 @smallexample @c ada
1129 pragma Assume_No_Invalid_Values (On | Off);
1130 @end smallexample
1131
1132 @noindent
1133 This is a configuration pragma that controls the assumptions made by the
1134 compiler about the occurrence of invalid representations (invalid values)
1135 in the code.
1136
1137 The default behavior (corresponding to an Off argument for this pragma), is
1138 to assume that values may in general be invalid unless the compiler can
1139 prove they are valid. Consider the following example:
1140
1141 @smallexample @c ada
1142 V1 : Integer range 1 .. 10;
1143 V2 : Integer range 11 .. 20;
1144 ...
1145 for J in V2 .. V1 loop
1146 ...
1147 end loop;
1148 @end smallexample
1149
1150 @noindent
1151 if V1 and V2 have valid values, then the loop is known at compile
1152 time not to execute since the lower bound must be greater than the
1153 upper bound. However in default mode, no such assumption is made,
1154 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1155 is given, the compiler will assume that any occurrence of a variable
1156 other than in an explicit @code{'Valid} test always has a valid
1157 value, and the loop above will be optimized away.
1158
1159 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1160 you know your code is free of uninitialized variables and other
1161 possible sources of invalid representations, and may result in
1162 more efficient code. A program that accesses an invalid representation
1163 with this pragma in effect is erroneous, so no guarantees can be made
1164 about its behavior.
1165
1166 It is peculiar though permissible to use this pragma in conjunction
1167 with validity checking (-gnatVa). In such cases, accessing invalid
1168 values will generally give an exception, though formally the program
1169 is erroneous so there are no guarantees that this will always be the
1170 case, and it is recommended that these two options not be used together.
1171
1172 @node Pragma Ast_Entry
1173 @unnumberedsec Pragma Ast_Entry
1174 @cindex OpenVMS
1175 @findex Ast_Entry
1176 @noindent
1177 Syntax:
1178 @smallexample @c ada
1179 pragma AST_Entry (entry_IDENTIFIER);
1180 @end smallexample
1181
1182 @noindent
1183 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1184 argument is the simple name of a single entry; at most one @code{AST_Entry}
1185 pragma is allowed for any given entry. This pragma must be used in
1186 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1187 the entry declaration and in the same task type specification or single task
1188 as the entry to which it applies. This pragma specifies that the given entry
1189 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1190 resulting from an OpenVMS system service call. The pragma does not affect
1191 normal use of the entry. For further details on this pragma, see the
1192 DEC Ada Language Reference Manual, section 9.12a.
1193
1194 @node Pragma C_Pass_By_Copy
1195 @unnumberedsec Pragma C_Pass_By_Copy
1196 @cindex Passing by copy
1197 @findex C_Pass_By_Copy
1198 @noindent
1199 Syntax:
1200 @smallexample @c ada
1201 pragma C_Pass_By_Copy
1202 ([Max_Size =>] static_integer_EXPRESSION);
1203 @end smallexample
1204
1205 @noindent
1206 Normally the default mechanism for passing C convention records to C
1207 convention subprograms is to pass them by reference, as suggested by RM
1208 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1209 this default, by requiring that record formal parameters be passed by
1210 copy if all of the following conditions are met:
1211
1212 @itemize @bullet
1213 @item
1214 The size of the record type does not exceed the value specified for
1215 @code{Max_Size}.
1216 @item
1217 The record type has @code{Convention C}.
1218 @item
1219 The formal parameter has this record type, and the subprogram has a
1220 foreign (non-Ada) convention.
1221 @end itemize
1222
1223 @noindent
1224 If these conditions are met the argument is passed by copy, i.e.@: in a
1225 manner consistent with what C expects if the corresponding formal in the
1226 C prototype is a struct (rather than a pointer to a struct).
1227
1228 You can also pass records by copy by specifying the convention
1229 @code{C_Pass_By_Copy} for the record type, or by using the extended
1230 @code{Import} and @code{Export} pragmas, which allow specification of
1231 passing mechanisms on a parameter by parameter basis.
1232
1233 @node Pragma Check
1234 @unnumberedsec Pragma Check
1235 @cindex Assertions
1236 @cindex Named assertions
1237 @findex Check
1238 @noindent
1239 Syntax:
1240 @smallexample @c ada
1241 pragma Check (
1242 [Name =>] Identifier,
1243 [Check =>] Boolean_EXPRESSION
1244 [, [Message =>] string_EXPRESSION] );
1245 @end smallexample
1246
1247 @noindent
1248 This pragma is similar to the predefined pragma @code{Assert} except that an
1249 extra identifier argument is present. In conjunction with pragma
1250 @code{Check_Policy}, this can be used to define groups of assertions that can
1251 be independently controlled. The identifier @code{Assertion} is special, it
1252 refers to the normal set of pragma @code{Assert} statements. The identifiers
1253 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1254 names, so these three names would normally not be used directly in a pragma
1255 @code{Check}.
1256
1257 Checks introduced by this pragma are normally deactivated by default. They can
1258 be activated either by the command line option @option{-gnata}, which turns on
1259 all checks, or individually controlled using pragma @code{Check_Policy}.
1260
1261 @node Pragma Check_Name
1262 @unnumberedsec Pragma Check_Name
1263 @cindex Defining check names
1264 @cindex Check names, defining
1265 @findex Check_Name
1266 @noindent
1267 Syntax:
1268 @smallexample @c ada
1269 pragma Check_Name (check_name_IDENTIFIER);
1270 @end smallexample
1271
1272 @noindent
1273 This is a configuration pragma that defines a new implementation
1274 defined check name (unless IDENTIFIER matches one of the predefined
1275 check names, in which case the pragma has no effect). Check names
1276 are global to a partition, so if two or more configuration pragmas
1277 are present in a partition mentioning the same name, only one new
1278 check name is introduced.
1279
1280 An implementation defined check name introduced with this pragma may
1281 be used in only three contexts: @code{pragma Suppress},
1282 @code{pragma Unsuppress},
1283 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1284 any of these three cases, the check name must be visible. A check
1285 name is visible if it is in the configuration pragmas applying to
1286 the current unit, or if it appears at the start of any unit that
1287 is part of the dependency set of the current unit (e.g., units that
1288 are mentioned in @code{with} clauses).
1289
1290 @node Pragma Check_Policy
1291 @unnumberedsec Pragma Check_Policy
1292 @cindex Controlling assertions
1293 @cindex Assertions, control
1294 @cindex Check pragma control
1295 @cindex Named assertions
1296 @findex Check
1297 @noindent
1298 Syntax:
1299 @smallexample @c ada
1300 pragma Check_Policy
1301 ([Name =>] Identifier,
1302 [Policy =>] POLICY_IDENTIFIER);
1303
1304 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1305 @end smallexample
1306
1307 @noindent
1308 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1309 except that it controls sets of named assertions introduced using the
1310 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1311 @code{Assertion_Policy}) can be used within a declarative part, in which case
1312 it controls the status to the end of the corresponding construct (in a manner
1313 identical to pragma @code{Suppress)}.
1314
1315 The identifier given as the first argument corresponds to a name used in
1316 associated @code{Check} pragmas. For example, if the pragma:
1317
1318 @smallexample @c ada
1319 pragma Check_Policy (Critical_Error, OFF);
1320 @end smallexample
1321
1322 @noindent
1323 is given, then subsequent @code{Check} pragmas whose first argument is also
1324 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1325 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1326 @code{Check_Policy} with this identifier is similar to the normal
1327 @code{Assertion_Policy} pragma except that it can appear within a
1328 declarative part).
1329
1330 The special identifiers @code{Precondition} and @code{Postcondition} control
1331 the status of preconditions and postconditions. If a @code{Precondition} pragma
1332 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1333 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1334 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1335 are recognized.
1336
1337 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1338 to turn on corresponding checks. The default for a set of checks for which no
1339 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1340 @option{-gnata} is given, which turns on all checks by default.
1341
1342 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1343 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1344 compatibility with the standard @code{Assertion_Policy} pragma.
1345
1346 The implementation defined policy @code{DISABLE} is like
1347 @code{OFF} except that it completely disables semantic
1348 checking of the argument to the corresponding class of
1349 pragmas. This may be useful when the pragma arguments reference
1350 subprograms in a with'ed package which is replaced by a dummy package
1351 for the final build.
1352
1353 @node Pragma Comment
1354 @unnumberedsec Pragma Comment
1355 @findex Comment
1356 @noindent
1357 Syntax:
1358
1359 @smallexample @c ada
1360 pragma Comment (static_string_EXPRESSION);
1361 @end smallexample
1362
1363 @noindent
1364 This is almost identical in effect to pragma @code{Ident}. It allows the
1365 placement of a comment into the object file and hence into the
1366 executable file if the operating system permits such usage. The
1367 difference is that @code{Comment}, unlike @code{Ident}, has
1368 no limitations on placement of the pragma (it can be placed
1369 anywhere in the main source unit), and if more than one pragma
1370 is used, all comments are retained.
1371
1372 @node Pragma Common_Object
1373 @unnumberedsec Pragma Common_Object
1374 @findex Common_Object
1375 @noindent
1376 Syntax:
1377
1378 @smallexample @c ada
1379 pragma Common_Object (
1380 [Internal =>] LOCAL_NAME
1381 [, [External =>] EXTERNAL_SYMBOL]
1382 [, [Size =>] EXTERNAL_SYMBOL] );
1383
1384 EXTERNAL_SYMBOL ::=
1385 IDENTIFIER
1386 | static_string_EXPRESSION
1387 @end smallexample
1388
1389 @noindent
1390 This pragma enables the shared use of variables stored in overlaid
1391 linker areas corresponding to the use of @code{COMMON}
1392 in Fortran. The single
1393 object @var{LOCAL_NAME} is assigned to the area designated by
1394 the @var{External} argument.
1395 You may define a record to correspond to a series
1396 of fields. The @var{Size} argument
1397 is syntax checked in GNAT, but otherwise ignored.
1398
1399 @code{Common_Object} is not supported on all platforms. If no
1400 support is available, then the code generator will issue a message
1401 indicating that the necessary attribute for implementation of this
1402 pragma is not available.
1403
1404 @node Pragma Compile_Time_Error
1405 @unnumberedsec Pragma Compile_Time_Error
1406 @findex Compile_Time_Error
1407 @noindent
1408 Syntax:
1409
1410 @smallexample @c ada
1411 pragma Compile_Time_Error
1412 (boolean_EXPRESSION, static_string_EXPRESSION);
1413 @end smallexample
1414
1415 @noindent
1416 This pragma can be used to generate additional compile time
1417 error messages. It
1418 is particularly useful in generics, where errors can be issued for
1419 specific problematic instantiations. The first parameter is a boolean
1420 expression. The pragma is effective only if the value of this expression
1421 is known at compile time, and has the value True. The set of expressions
1422 whose values are known at compile time includes all static boolean
1423 expressions, and also other values which the compiler can determine
1424 at compile time (e.g., the size of a record type set by an explicit
1425 size representation clause, or the value of a variable which was
1426 initialized to a constant and is known not to have been modified).
1427 If these conditions are met, an error message is generated using
1428 the value given as the second argument. This string value may contain
1429 embedded ASCII.LF characters to break the message into multiple lines.
1430
1431 @node Pragma Compile_Time_Warning
1432 @unnumberedsec Pragma Compile_Time_Warning
1433 @findex Compile_Time_Warning
1434 @noindent
1435 Syntax:
1436
1437 @smallexample @c ada
1438 pragma Compile_Time_Warning
1439 (boolean_EXPRESSION, static_string_EXPRESSION);
1440 @end smallexample
1441
1442 @noindent
1443 Same as pragma Compile_Time_Error, except a warning is issued instead
1444 of an error message. Note that if this pragma is used in a package that
1445 is with'ed by a client, the client will get the warning even though it
1446 is issued by a with'ed package (normally warnings in with'ed units are
1447 suppressed, but this is a special exception to that rule).
1448
1449 One typical use is within a generic where compile time known characteristics
1450 of formal parameters are tested, and warnings given appropriately. Another use
1451 with a first parameter of True is to warn a client about use of a package,
1452 for example that it is not fully implemented.
1453
1454 @node Pragma Compiler_Unit
1455 @unnumberedsec Pragma Compiler_Unit
1456 @findex Compiler_Unit
1457 @noindent
1458 Syntax:
1459
1460 @smallexample @c ada
1461 pragma Compiler_Unit;
1462 @end smallexample
1463
1464 @noindent
1465 This pragma is intended only for internal use in the GNAT run-time library.
1466 It indicates that the unit is used as part of the compiler build. The effect
1467 is to disallow constructs (raise with message, conditional expressions etc)
1468 that would cause trouble when bootstrapping using an older version of GNAT.
1469 For the exact list of restrictions, see the compiler sources and references
1470 to Is_Compiler_Unit.
1471
1472 @node Pragma Complete_Representation
1473 @unnumberedsec Pragma Complete_Representation
1474 @findex Complete_Representation
1475 @noindent
1476 Syntax:
1477
1478 @smallexample @c ada
1479 pragma Complete_Representation;
1480 @end smallexample
1481
1482 @noindent
1483 This pragma must appear immediately within a record representation
1484 clause. Typical placements are before the first component clause
1485 or after the last component clause. The effect is to give an error
1486 message if any component is missing a component clause. This pragma
1487 may be used to ensure that a record representation clause is
1488 complete, and that this invariant is maintained if fields are
1489 added to the record in the future.
1490
1491 @node Pragma Complex_Representation
1492 @unnumberedsec Pragma Complex_Representation
1493 @findex Complex_Representation
1494 @noindent
1495 Syntax:
1496
1497 @smallexample @c ada
1498 pragma Complex_Representation
1499 ([Entity =>] LOCAL_NAME);
1500 @end smallexample
1501
1502 @noindent
1503 The @var{Entity} argument must be the name of a record type which has
1504 two fields of the same floating-point type. The effect of this pragma is
1505 to force gcc to use the special internal complex representation form for
1506 this record, which may be more efficient. Note that this may result in
1507 the code for this type not conforming to standard ABI (application
1508 binary interface) requirements for the handling of record types. For
1509 example, in some environments, there is a requirement for passing
1510 records by pointer, and the use of this pragma may result in passing
1511 this type in floating-point registers.
1512
1513 @node Pragma Component_Alignment
1514 @unnumberedsec Pragma Component_Alignment
1515 @cindex Alignments of components
1516 @findex Component_Alignment
1517 @noindent
1518 Syntax:
1519
1520 @smallexample @c ada
1521 pragma Component_Alignment (
1522 [Form =>] ALIGNMENT_CHOICE
1523 [, [Name =>] type_LOCAL_NAME]);
1524
1525 ALIGNMENT_CHOICE ::=
1526 Component_Size
1527 | Component_Size_4
1528 | Storage_Unit
1529 | Default
1530 @end smallexample
1531
1532 @noindent
1533 Specifies the alignment of components in array or record types.
1534 The meaning of the @var{Form} argument is as follows:
1535
1536 @table @code
1537 @findex Component_Size
1538 @item Component_Size
1539 Aligns scalar components and subcomponents of the array or record type
1540 on boundaries appropriate to their inherent size (naturally
1541 aligned). For example, 1-byte components are aligned on byte boundaries,
1542 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1543 integer components are aligned on 4-byte boundaries and so on. These
1544 alignment rules correspond to the normal rules for C compilers on all
1545 machines except the VAX@.
1546
1547 @findex Component_Size_4
1548 @item Component_Size_4
1549 Naturally aligns components with a size of four or fewer
1550 bytes. Components that are larger than 4 bytes are placed on the next
1551 4-byte boundary.
1552
1553 @findex Storage_Unit
1554 @item Storage_Unit
1555 Specifies that array or record components are byte aligned, i.e.@:
1556 aligned on boundaries determined by the value of the constant
1557 @code{System.Storage_Unit}.
1558
1559 @cindex OpenVMS
1560 @item Default
1561 Specifies that array or record components are aligned on default
1562 boundaries, appropriate to the underlying hardware or operating system or
1563 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1564 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1565 the @code{Default} choice is the same as @code{Component_Size} (natural
1566 alignment).
1567 @end table
1568
1569 @noindent
1570 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1571 refer to a local record or array type, and the specified alignment
1572 choice applies to the specified type. The use of
1573 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1574 @code{Component_Alignment} pragma to be ignored. The use of
1575 @code{Component_Alignment} together with a record representation clause
1576 is only effective for fields not specified by the representation clause.
1577
1578 If the @code{Name} parameter is absent, the pragma can be used as either
1579 a configuration pragma, in which case it applies to one or more units in
1580 accordance with the normal rules for configuration pragmas, or it can be
1581 used within a declarative part, in which case it applies to types that
1582 are declared within this declarative part, or within any nested scope
1583 within this declarative part. In either case it specifies the alignment
1584 to be applied to any record or array type which has otherwise standard
1585 representation.
1586
1587 If the alignment for a record or array type is not specified (using
1588 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1589 clause), the GNAT uses the default alignment as described previously.
1590
1591 @node Pragma Convention_Identifier
1592 @unnumberedsec Pragma Convention_Identifier
1593 @findex Convention_Identifier
1594 @cindex Conventions, synonyms
1595 @noindent
1596 Syntax:
1597
1598 @smallexample @c ada
1599 pragma Convention_Identifier (
1600 [Name =>] IDENTIFIER,
1601 [Convention =>] convention_IDENTIFIER);
1602 @end smallexample
1603
1604 @noindent
1605 This pragma provides a mechanism for supplying synonyms for existing
1606 convention identifiers. The @code{Name} identifier can subsequently
1607 be used as a synonym for the given convention in other pragmas (including
1608 for example pragma @code{Import} or another @code{Convention_Identifier}
1609 pragma). As an example of the use of this, suppose you had legacy code
1610 which used Fortran77 as the identifier for Fortran. Then the pragma:
1611
1612 @smallexample @c ada
1613 pragma Convention_Identifier (Fortran77, Fortran);
1614 @end smallexample
1615
1616 @noindent
1617 would allow the use of the convention identifier @code{Fortran77} in
1618 subsequent code, avoiding the need to modify the sources. As another
1619 example, you could use this to parameterize convention requirements
1620 according to systems. Suppose you needed to use @code{Stdcall} on
1621 windows systems, and @code{C} on some other system, then you could
1622 define a convention identifier @code{Library} and use a single
1623 @code{Convention_Identifier} pragma to specify which convention
1624 would be used system-wide.
1625
1626 @node Pragma CPP_Class
1627 @unnumberedsec Pragma CPP_Class
1628 @findex CPP_Class
1629 @cindex Interfacing with C++
1630 @noindent
1631 Syntax:
1632
1633 @smallexample @c ada
1634 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1635 @end smallexample
1636
1637 @noindent
1638 The argument denotes an entity in the current declarative region that is
1639 declared as a record type. It indicates that the type corresponds to an
1640 externally declared C++ class type, and is to be laid out the same way
1641 that C++ would lay out the type. If the C++ class has virtual primitives
1642 then the record must be declared as a tagged record type.
1643
1644 Types for which @code{CPP_Class} is specified do not have assignment or
1645 equality operators defined (such operations can be imported or declared
1646 as subprograms as required). Initialization is allowed only by constructor
1647 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1648 limited if not explicitly declared as limited or derived from a limited
1649 type, and an error is issued in that case.
1650
1651 Pragma @code{CPP_Class} is intended primarily for automatic generation
1652 using an automatic binding generator tool.
1653 See @ref{Interfacing to C++} for related information.
1654
1655 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1656 for backward compatibility but its functionality is available
1657 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1658
1659 @node Pragma CPP_Constructor
1660 @unnumberedsec Pragma CPP_Constructor
1661 @cindex Interfacing with C++
1662 @findex CPP_Constructor
1663 @noindent
1664 Syntax:
1665
1666 @smallexample @c ada
1667 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1668 [, [External_Name =>] static_string_EXPRESSION ]
1669 [, [Link_Name =>] static_string_EXPRESSION ]);
1670 @end smallexample
1671
1672 @noindent
1673 This pragma identifies an imported function (imported in the usual way
1674 with pragma @code{Import}) as corresponding to a C++ constructor. If
1675 @code{External_Name} and @code{Link_Name} are not specified then the
1676 @code{Entity} argument is a name that must have been previously mentioned
1677 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1678 must be of one of the following forms:
1679
1680 @itemize @bullet
1681 @item
1682 @code{function @var{Fname} return @var{T}}
1683
1684 @itemize @bullet
1685 @item
1686 @code{function @var{Fname} return @var{T}'Class}
1687
1688 @item
1689 @code{function @var{Fname} (@dots{}) return @var{T}}
1690 @end itemize
1691
1692 @item
1693 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1694 @end itemize
1695
1696 @noindent
1697 where @var{T} is a limited record type imported from C++ with pragma
1698 @code{Import} and @code{Convention} = @code{CPP}.
1699
1700 The first two forms import the default constructor, used when an object
1701 of type @var{T} is created on the Ada side with no explicit constructor.
1702 The latter two forms cover all the non-default constructors of the type.
1703 See the GNAT users guide for details.
1704
1705 If no constructors are imported, it is impossible to create any objects
1706 on the Ada side and the type is implicitly declared abstract.
1707
1708 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1709 using an automatic binding generator tool.
1710 See @ref{Interfacing to C++} for more related information.
1711
1712 Note: The use of functions returning class-wide types for constructors is
1713 currently obsolete. They are supported for backward compatibility. The
1714 use of functions returning the type T leave the Ada sources more clear
1715 because the imported C++ constructors always return an object of type T;
1716 that is, they never return an object whose type is a descendant of type T.
1717
1718 @node Pragma CPP_Virtual
1719 @unnumberedsec Pragma CPP_Virtual
1720 @cindex Interfacing to C++
1721 @findex CPP_Virtual
1722 @noindent
1723 This pragma is now obsolete has has no effect because GNAT generates
1724 the same object layout than the G++ compiler.
1725
1726 See @ref{Interfacing to C++} for related information.
1727
1728 @node Pragma CPP_Vtable
1729 @unnumberedsec Pragma CPP_Vtable
1730 @cindex Interfacing with C++
1731 @findex CPP_Vtable
1732 @noindent
1733 This pragma is now obsolete has has no effect because GNAT generates
1734 the same object layout than the G++ compiler.
1735
1736 See @ref{Interfacing to C++} for related information.
1737
1738 @node Pragma Debug
1739 @unnumberedsec Pragma Debug
1740 @findex Debug
1741 @noindent
1742 Syntax:
1743
1744 @smallexample @c ada
1745 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1746
1747 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1748 PROCEDURE_NAME
1749 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1750 @end smallexample
1751
1752 @noindent
1753 The procedure call argument has the syntactic form of an expression, meeting
1754 the syntactic requirements for pragmas.
1755
1756 If debug pragmas are not enabled or if the condition is present and evaluates
1757 to False, this pragma has no effect. If debug pragmas are enabled, the
1758 semantics of the pragma is exactly equivalent to the procedure call statement
1759 corresponding to the argument with a terminating semicolon. Pragmas are
1760 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1761 intersperse calls to debug procedures in the middle of declarations. Debug
1762 pragmas can be enabled either by use of the command line switch @option{-gnata}
1763 or by use of the configuration pragma @code{Debug_Policy}.
1764
1765 @node Pragma Debug_Policy
1766 @unnumberedsec Pragma Debug_Policy
1767 @findex Debug_Policy
1768 @noindent
1769 Syntax:
1770
1771 @smallexample @c ada
1772 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1773 @end smallexample
1774
1775 @noindent
1776 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1777 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1778 This pragma overrides the effect of the @option{-gnata} switch on the
1779 command line.
1780
1781 The implementation defined policy @code{DISABLE} is like
1782 @code{IGNORE} except that it completely disables semantic
1783 checking of the argument to @code{pragma Debug}. This may
1784 be useful when the pragma argument references subprograms
1785 in a with'ed package which is replaced by a dummy package
1786 for the final build.
1787
1788 @node Pragma Detect_Blocking
1789 @unnumberedsec Pragma Detect_Blocking
1790 @findex Detect_Blocking
1791 @noindent
1792 Syntax:
1793
1794 @smallexample @c ada
1795 pragma Detect_Blocking;
1796 @end smallexample
1797
1798 @noindent
1799 This is a configuration pragma that forces the detection of potentially
1800 blocking operations within a protected operation, and to raise Program_Error
1801 if that happens.
1802
1803 @node Pragma Elaboration_Checks
1804 @unnumberedsec Pragma Elaboration_Checks
1805 @cindex Elaboration control
1806 @findex Elaboration_Checks
1807 @noindent
1808 Syntax:
1809
1810 @smallexample @c ada
1811 pragma Elaboration_Checks (Dynamic | Static);
1812 @end smallexample
1813
1814 @noindent
1815 This is a configuration pragma that provides control over the
1816 elaboration model used by the compilation affected by the
1817 pragma. If the parameter is @code{Dynamic},
1818 then the dynamic elaboration
1819 model described in the Ada Reference Manual is used, as though
1820 the @option{-gnatE} switch had been specified on the command
1821 line. If the parameter is @code{Static}, then the default GNAT static
1822 model is used. This configuration pragma overrides the setting
1823 of the command line. For full details on the elaboration models
1824 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1825 gnat_ugn, @value{EDITION} User's Guide}.
1826
1827 @node Pragma Eliminate
1828 @unnumberedsec Pragma Eliminate
1829 @cindex Elimination of unused subprograms
1830 @findex Eliminate
1831 @noindent
1832 Syntax:
1833
1834 @smallexample @c ada
1835 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
1836 [Source_Location =>] STRING_LITERAL);
1837 @end smallexample
1838
1839 @noindent
1840 The string literal given for the source location is a string which
1841 specifies the line number of the occurrence of the entity, using
1842 the syntax for SOURCE_TRACE given below:
1843
1844 @smallexample @c ada
1845 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1846
1847 LBRACKET ::= [
1848 RBRACKET ::= ]
1849
1850 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1851
1852 LINE_NUMBER ::= DIGIT @{DIGIT@}
1853 @end smallexample
1854
1855 @noindent
1856 Spaces around the colon in a @code{Source_Reference} are optional.
1857
1858 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1859 explicit subprogram declaration, where the @code{entity} name in this
1860 designator appears on the source line specified by the source location.
1861
1862 The source trace that is given as the @code{Source_Location} shall obey the
1863 following rules. The @code{FILE_NAME} is the short name (with no directory
1864 information) of an Ada source file, given using exactly the required syntax
1865 for the underlying file system (e.g. case is important if the underlying
1866 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1867 number of the occurrence of the @code{entity}
1868 as a decimal literal without an exponent or point. If an @code{entity} is not
1869 declared in a generic instantiation (this includes generic subprogram
1870 instances), the source trace includes only one source reference. If an entity
1871 is declared inside a generic instantiation, its source trace (when parsing
1872 from left to right) starts with the source location of the declaration of the
1873 entity in the generic unit and ends with the source location of the
1874 instantiation (it is given in square brackets). This approach is recursively
1875 used in case of nested instantiations: the rightmost (nested most deeply in
1876 square brackets) element of the source trace is the location of the outermost
1877 instantiation, the next to left element is the location of the next (first
1878 nested) instantiation in the code of the corresponding generic unit, and so
1879 on, and the leftmost element (that is out of any square brackets) is the
1880 location of the declaration of the entity to eliminate in a generic unit.
1881
1882 Note that the @code{Source_Location} argument specifies which of a set of
1883 similarly named entities is being eliminated, dealing both with overloading,
1884 and also appearence of the same entity name in different scopes.
1885
1886 This pragma indicates that the given entity is not used in the program to be
1887 compiled and built. The effect of the pragma is to allow the compiler to
1888 eliminate the code or data associated with the named entity. Any reference to
1889 an eliminated entity causes a compile-time or link-time error.
1890
1891 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1892 in a system-independent manner, with unused entities eliminated, without
1893 needing to modify the source text. Normally the required set of
1894 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1895
1896 Any source file change that removes, splits, or
1897 adds lines may make the set of Eliminate pragmas invalid because their
1898 @code{Source_Location} argument values may get out of date.
1899
1900 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
1901 operation. In this case all the subprograms to which the given operation can
1902 dispatch are considered to be unused (are never called as a result of a direct
1903 or a dispatching call).
1904
1905 @node Pragma Export_Exception
1906 @unnumberedsec Pragma Export_Exception
1907 @cindex OpenVMS
1908 @findex Export_Exception
1909 @noindent
1910 Syntax:
1911
1912 @smallexample @c ada
1913 pragma Export_Exception (
1914 [Internal =>] LOCAL_NAME
1915 [, [External =>] EXTERNAL_SYMBOL]
1916 [, [Form =>] Ada | VMS]
1917 [, [Code =>] static_integer_EXPRESSION]);
1918
1919 EXTERNAL_SYMBOL ::=
1920 IDENTIFIER
1921 | static_string_EXPRESSION
1922 @end smallexample
1923
1924 @noindent
1925 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1926 causes the specified exception to be propagated outside of the Ada program,
1927 so that it can be handled by programs written in other OpenVMS languages.
1928 This pragma establishes an external name for an Ada exception and makes the
1929 name available to the OpenVMS Linker as a global symbol. For further details
1930 on this pragma, see the
1931 DEC Ada Language Reference Manual, section 13.9a3.2.
1932
1933 @node Pragma Export_Function
1934 @unnumberedsec Pragma Export_Function
1935 @cindex Argument passing mechanisms
1936 @findex Export_Function
1937
1938 @noindent
1939 Syntax:
1940
1941 @smallexample @c ada
1942 pragma Export_Function (
1943 [Internal =>] LOCAL_NAME
1944 [, [External =>] EXTERNAL_SYMBOL]
1945 [, [Parameter_Types =>] PARAMETER_TYPES]
1946 [, [Result_Type =>] result_SUBTYPE_MARK]
1947 [, [Mechanism =>] MECHANISM]
1948 [, [Result_Mechanism =>] MECHANISM_NAME]);
1949
1950 EXTERNAL_SYMBOL ::=
1951 IDENTIFIER
1952 | static_string_EXPRESSION
1953 | ""
1954
1955 PARAMETER_TYPES ::=
1956 null
1957 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1958
1959 TYPE_DESIGNATOR ::=
1960 subtype_NAME
1961 | subtype_Name ' Access
1962
1963 MECHANISM ::=
1964 MECHANISM_NAME
1965 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1966
1967 MECHANISM_ASSOCIATION ::=
1968 [formal_parameter_NAME =>] MECHANISM_NAME
1969
1970 MECHANISM_NAME ::=
1971 Value
1972 | Reference
1973 | Descriptor [([Class =>] CLASS_NAME)]
1974 | Short_Descriptor [([Class =>] CLASS_NAME)]
1975
1976 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1977 @end smallexample
1978
1979 @noindent
1980 Use this pragma to make a function externally callable and optionally
1981 provide information on mechanisms to be used for passing parameter and
1982 result values. We recommend, for the purposes of improving portability,
1983 this pragma always be used in conjunction with a separate pragma
1984 @code{Export}, which must precede the pragma @code{Export_Function}.
1985 GNAT does not require a separate pragma @code{Export}, but if none is
1986 present, @code{Convention Ada} is assumed, which is usually
1987 not what is wanted, so it is usually appropriate to use this
1988 pragma in conjunction with a @code{Export} or @code{Convention}
1989 pragma that specifies the desired foreign convention.
1990 Pragma @code{Export_Function}
1991 (and @code{Export}, if present) must appear in the same declarative
1992 region as the function to which they apply.
1993
1994 @var{internal_name} must uniquely designate the function to which the
1995 pragma applies. If more than one function name exists of this name in
1996 the declarative part you must use the @code{Parameter_Types} and
1997 @code{Result_Type} parameters is mandatory to achieve the required
1998 unique designation. @var{subtype_mark}s in these parameters must
1999 exactly match the subtypes in the corresponding function specification,
2000 using positional notation to match parameters with subtype marks.
2001 The form with an @code{'Access} attribute can be used to match an
2002 anonymous access parameter.
2003
2004 @cindex OpenVMS
2005 @cindex Passing by descriptor
2006 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2007 The default behavior for Export_Function is to accept either 64bit or
2008 32bit descriptors unless short_descriptor is specified, then only 32bit
2009 descriptors are accepted.
2010
2011 @cindex Suppressing external name
2012 Special treatment is given if the EXTERNAL is an explicit null
2013 string or a static string expressions that evaluates to the null
2014 string. In this case, no external name is generated. This form
2015 still allows the specification of parameter mechanisms.
2016
2017 @node Pragma Export_Object
2018 @unnumberedsec Pragma Export_Object
2019 @findex Export_Object
2020 @noindent
2021 Syntax:
2022
2023 @smallexample @c ada
2024 pragma Export_Object
2025 [Internal =>] LOCAL_NAME
2026 [, [External =>] EXTERNAL_SYMBOL]
2027 [, [Size =>] EXTERNAL_SYMBOL]
2028
2029 EXTERNAL_SYMBOL ::=
2030 IDENTIFIER
2031 | static_string_EXPRESSION
2032 @end smallexample
2033
2034 @noindent
2035 This pragma designates an object as exported, and apart from the
2036 extended rules for external symbols, is identical in effect to the use of
2037 the normal @code{Export} pragma applied to an object. You may use a
2038 separate Export pragma (and you probably should from the point of view
2039 of portability), but it is not required. @var{Size} is syntax checked,
2040 but otherwise ignored by GNAT@.
2041
2042 @node Pragma Export_Procedure
2043 @unnumberedsec Pragma Export_Procedure
2044 @findex Export_Procedure
2045 @noindent
2046 Syntax:
2047
2048 @smallexample @c ada
2049 pragma Export_Procedure (
2050 [Internal =>] LOCAL_NAME
2051 [, [External =>] EXTERNAL_SYMBOL]
2052 [, [Parameter_Types =>] PARAMETER_TYPES]
2053 [, [Mechanism =>] MECHANISM]);
2054
2055 EXTERNAL_SYMBOL ::=
2056 IDENTIFIER
2057 | static_string_EXPRESSION
2058 | ""
2059
2060 PARAMETER_TYPES ::=
2061 null
2062 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2063
2064 TYPE_DESIGNATOR ::=
2065 subtype_NAME
2066 | subtype_Name ' Access
2067
2068 MECHANISM ::=
2069 MECHANISM_NAME
2070 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2071
2072 MECHANISM_ASSOCIATION ::=
2073 [formal_parameter_NAME =>] MECHANISM_NAME
2074
2075 MECHANISM_NAME ::=
2076 Value
2077 | Reference
2078 | Descriptor [([Class =>] CLASS_NAME)]
2079 | Short_Descriptor [([Class =>] CLASS_NAME)]
2080
2081 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2082 @end smallexample
2083
2084 @noindent
2085 This pragma is identical to @code{Export_Function} except that it
2086 applies to a procedure rather than a function and the parameters
2087 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2088 GNAT does not require a separate pragma @code{Export}, but if none is
2089 present, @code{Convention Ada} is assumed, which is usually
2090 not what is wanted, so it is usually appropriate to use this
2091 pragma in conjunction with a @code{Export} or @code{Convention}
2092 pragma that specifies the desired foreign convention.
2093
2094 @cindex OpenVMS
2095 @cindex Passing by descriptor
2096 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2097 The default behavior for Export_Procedure is to accept either 64bit or
2098 32bit descriptors unless short_descriptor is specified, then only 32bit
2099 descriptors are accepted.
2100
2101 @cindex Suppressing external name
2102 Special treatment is given if the EXTERNAL is an explicit null
2103 string or a static string expressions that evaluates to the null
2104 string. In this case, no external name is generated. This form
2105 still allows the specification of parameter mechanisms.
2106
2107 @node Pragma Export_Value
2108 @unnumberedsec Pragma Export_Value
2109 @findex Export_Value
2110 @noindent
2111 Syntax:
2112
2113 @smallexample @c ada
2114 pragma Export_Value (
2115 [Value =>] static_integer_EXPRESSION,
2116 [Link_Name =>] static_string_EXPRESSION);
2117 @end smallexample
2118
2119 @noindent
2120 This pragma serves to export a static integer value for external use.
2121 The first argument specifies the value to be exported. The Link_Name
2122 argument specifies the symbolic name to be associated with the integer
2123 value. This pragma is useful for defining a named static value in Ada
2124 that can be referenced in assembly language units to be linked with
2125 the application. This pragma is currently supported only for the
2126 AAMP target and is ignored for other targets.
2127
2128 @node Pragma Export_Valued_Procedure
2129 @unnumberedsec Pragma Export_Valued_Procedure
2130 @findex Export_Valued_Procedure
2131 @noindent
2132 Syntax:
2133
2134 @smallexample @c ada
2135 pragma Export_Valued_Procedure (
2136 [Internal =>] LOCAL_NAME
2137 [, [External =>] EXTERNAL_SYMBOL]
2138 [, [Parameter_Types =>] PARAMETER_TYPES]
2139 [, [Mechanism =>] MECHANISM]);
2140
2141 EXTERNAL_SYMBOL ::=
2142 IDENTIFIER
2143 | static_string_EXPRESSION
2144 | ""
2145
2146 PARAMETER_TYPES ::=
2147 null
2148 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2149
2150 TYPE_DESIGNATOR ::=
2151 subtype_NAME
2152 | subtype_Name ' Access
2153
2154 MECHANISM ::=
2155 MECHANISM_NAME
2156 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2157
2158 MECHANISM_ASSOCIATION ::=
2159 [formal_parameter_NAME =>] MECHANISM_NAME
2160
2161 MECHANISM_NAME ::=
2162 Value
2163 | Reference
2164 | Descriptor [([Class =>] CLASS_NAME)]
2165 | Short_Descriptor [([Class =>] CLASS_NAME)]
2166
2167 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2168 @end smallexample
2169
2170 @noindent
2171 This pragma is identical to @code{Export_Procedure} except that the
2172 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2173 mode @code{OUT}, and externally the subprogram is treated as a function
2174 with this parameter as the result of the function. GNAT provides for
2175 this capability to allow the use of @code{OUT} and @code{IN OUT}
2176 parameters in interfacing to external functions (which are not permitted
2177 in Ada functions).
2178 GNAT does not require a separate pragma @code{Export}, but if none is
2179 present, @code{Convention Ada} is assumed, which is almost certainly
2180 not what is wanted since the whole point of this pragma is to interface
2181 with foreign language functions, so it is usually appropriate to use this
2182 pragma in conjunction with a @code{Export} or @code{Convention}
2183 pragma that specifies the desired foreign convention.
2184
2185 @cindex OpenVMS
2186 @cindex Passing by descriptor
2187 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2188 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2189 32bit descriptors unless short_descriptor is specified, then only 32bit
2190 descriptors are accepted.
2191
2192 @cindex Suppressing external name
2193 Special treatment is given if the EXTERNAL is an explicit null
2194 string or a static string expressions that evaluates to the null
2195 string. In this case, no external name is generated. This form
2196 still allows the specification of parameter mechanisms.
2197
2198 @node Pragma Extend_System
2199 @unnumberedsec Pragma Extend_System
2200 @cindex @code{system}, extending
2201 @cindex Dec Ada 83
2202 @findex Extend_System
2203 @noindent
2204 Syntax:
2205
2206 @smallexample @c ada
2207 pragma Extend_System ([Name =>] IDENTIFIER);
2208 @end smallexample
2209
2210 @noindent
2211 This pragma is used to provide backwards compatibility with other
2212 implementations that extend the facilities of package @code{System}. In
2213 GNAT, @code{System} contains only the definitions that are present in
2214 the Ada RM@. However, other implementations, notably the DEC Ada 83
2215 implementation, provide many extensions to package @code{System}.
2216
2217 For each such implementation accommodated by this pragma, GNAT provides a
2218 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2219 implementation, which provides the required additional definitions. You
2220 can use this package in two ways. You can @code{with} it in the normal
2221 way and access entities either by selection or using a @code{use}
2222 clause. In this case no special processing is required.
2223
2224 However, if existing code contains references such as
2225 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2226 definitions provided in package @code{System}, you may use this pragma
2227 to extend visibility in @code{System} in a non-standard way that
2228 provides greater compatibility with the existing code. Pragma
2229 @code{Extend_System} is a configuration pragma whose single argument is
2230 the name of the package containing the extended definition
2231 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2232 control of this pragma will be processed using special visibility
2233 processing that looks in package @code{System.Aux_@var{xxx}} where
2234 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2235 package @code{System}, but not found in package @code{System}.
2236
2237 You can use this pragma either to access a predefined @code{System}
2238 extension supplied with the compiler, for example @code{Aux_DEC} or
2239 you can construct your own extension unit following the above
2240 definition. Note that such a package is a child of @code{System}
2241 and thus is considered part of the implementation. To compile
2242 it you will have to use the appropriate switch for compiling
2243 system units.
2244 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2245 for details.
2246
2247 @node Pragma Extensions_Allowed
2248 @unnumberedsec Pragma Extensions_Allowed
2249 @cindex Ada Extensions
2250 @cindex GNAT Extensions
2251 @findex Extensions_Allowed
2252 @noindent
2253 Syntax:
2254
2255 @smallexample @c ada
2256 pragma Extensions_Allowed (On | Off);
2257 @end smallexample
2258
2259 @noindent
2260 This configuration pragma enables or disables the implementation
2261 extension mode (the use of Off as a parameter cancels the effect
2262 of the @option{-gnatX} command switch).
2263
2264 In extension mode, the latest version of the Ada language is
2265 implemented (currently Ada 2012), and in addition a small number
2266 of GNAT specific extensions are recognized as follows:
2267
2268 @table @asis
2269 @item Constrained attribute for generic objects
2270 The @code{Constrained} attribute is permitted for objects of
2271 generic types. The result indicates if the corresponding actual
2272 is constrained.
2273
2274 @end table
2275
2276 @node Pragma External
2277 @unnumberedsec Pragma External
2278 @findex External
2279 @noindent
2280 Syntax:
2281
2282 @smallexample @c ada
2283 pragma External (
2284 [ Convention =>] convention_IDENTIFIER,
2285 [ Entity =>] LOCAL_NAME
2286 [, [External_Name =>] static_string_EXPRESSION ]
2287 [, [Link_Name =>] static_string_EXPRESSION ]);
2288 @end smallexample
2289
2290 @noindent
2291 This pragma is identical in syntax and semantics to pragma
2292 @code{Export} as defined in the Ada Reference Manual. It is
2293 provided for compatibility with some Ada 83 compilers that
2294 used this pragma for exactly the same purposes as pragma
2295 @code{Export} before the latter was standardized.
2296
2297 @node Pragma External_Name_Casing
2298 @unnumberedsec Pragma External_Name_Casing
2299 @cindex Dec Ada 83 casing compatibility
2300 @cindex External Names, casing
2301 @cindex Casing of External names
2302 @findex External_Name_Casing
2303 @noindent
2304 Syntax:
2305
2306 @smallexample @c ada
2307 pragma External_Name_Casing (
2308 Uppercase | Lowercase
2309 [, Uppercase | Lowercase | As_Is]);
2310 @end smallexample
2311
2312 @noindent
2313 This pragma provides control over the casing of external names associated
2314 with Import and Export pragmas. There are two cases to consider:
2315
2316 @table @asis
2317 @item Implicit external names
2318 Implicit external names are derived from identifiers. The most common case
2319 arises when a standard Ada Import or Export pragma is used with only two
2320 arguments, as in:
2321
2322 @smallexample @c ada
2323 pragma Import (C, C_Routine);
2324 @end smallexample
2325
2326 @noindent
2327 Since Ada is a case-insensitive language, the spelling of the identifier in
2328 the Ada source program does not provide any information on the desired
2329 casing of the external name, and so a convention is needed. In GNAT the
2330 default treatment is that such names are converted to all lower case
2331 letters. This corresponds to the normal C style in many environments.
2332 The first argument of pragma @code{External_Name_Casing} can be used to
2333 control this treatment. If @code{Uppercase} is specified, then the name
2334 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2335 then the normal default of all lower case letters will be used.
2336
2337 This same implicit treatment is also used in the case of extended DEC Ada 83
2338 compatible Import and Export pragmas where an external name is explicitly
2339 specified using an identifier rather than a string.
2340
2341 @item Explicit external names
2342 Explicit external names are given as string literals. The most common case
2343 arises when a standard Ada Import or Export pragma is used with three
2344 arguments, as in:
2345
2346 @smallexample @c ada
2347 pragma Import (C, C_Routine, "C_routine");
2348 @end smallexample
2349
2350 @noindent
2351 In this case, the string literal normally provides the exact casing required
2352 for the external name. The second argument of pragma
2353 @code{External_Name_Casing} may be used to modify this behavior.
2354 If @code{Uppercase} is specified, then the name
2355 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2356 then the name will be forced to all lowercase letters. A specification of
2357 @code{As_Is} provides the normal default behavior in which the casing is
2358 taken from the string provided.
2359 @end table
2360
2361 @noindent
2362 This pragma may appear anywhere that a pragma is valid. In particular, it
2363 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2364 case it applies to all subsequent compilations, or it can be used as a program
2365 unit pragma, in which case it only applies to the current unit, or it can
2366 be used more locally to control individual Import/Export pragmas.
2367
2368 It is primarily intended for use with OpenVMS systems, where many
2369 compilers convert all symbols to upper case by default. For interfacing to
2370 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2371 the pragma:
2372
2373 @smallexample @c ada
2374 pragma External_Name_Casing (Uppercase, Uppercase);
2375 @end smallexample
2376
2377 @noindent
2378 to enforce the upper casing of all external symbols.
2379
2380 @node Pragma Fast_Math
2381 @unnumberedsec Pragma Fast_Math
2382 @findex Fast_Math
2383 @noindent
2384 Syntax:
2385
2386 @smallexample @c ada
2387 pragma Fast_Math;
2388 @end smallexample
2389
2390 @noindent
2391 This is a configuration pragma which activates a mode in which speed is
2392 considered more important for floating-point operations than absolutely
2393 accurate adherence to the requirements of the standard. Currently the
2394 following operations are affected:
2395
2396 @table @asis
2397 @item Complex Multiplication
2398 The normal simple formula for complex multiplication can result in intermediate
2399 overflows for numbers near the end of the range. The Ada standard requires that
2400 this situation be detected and corrected by scaling, but in Fast_Math mode such
2401 cases will simply result in overflow. Note that to take advantage of this you
2402 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2403 under control of the pragma, rather than use the preinstantiated versions.
2404 @end table
2405
2406 @node Pragma Favor_Top_Level
2407 @unnumberedsec Pragma Favor_Top_Level
2408 @findex Favor_Top_Level
2409 @noindent
2410 Syntax:
2411
2412 @smallexample @c ada
2413 pragma Favor_Top_Level (type_NAME);
2414 @end smallexample
2415
2416 @noindent
2417 The named type must be an access-to-subprogram type. This pragma is an
2418 efficiency hint to the compiler, regarding the use of 'Access or
2419 'Unrestricted_Access on nested (non-library-level) subprograms. The
2420 pragma means that nested subprograms are not used with this type, or
2421 are rare, so that the generated code should be efficient in the
2422 top-level case. When this pragma is used, dynamically generated
2423 trampolines may be used on some targets for nested subprograms.
2424 See also the No_Implicit_Dynamic_Code restriction.
2425
2426 @node Pragma Finalize_Storage_Only
2427 @unnumberedsec Pragma Finalize_Storage_Only
2428 @findex Finalize_Storage_Only
2429 @noindent
2430 Syntax:
2431
2432 @smallexample @c ada
2433 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2434 @end smallexample
2435
2436 @noindent
2437 This pragma allows the compiler not to emit a Finalize call for objects
2438 defined at the library level. This is mostly useful for types where
2439 finalization is only used to deal with storage reclamation since in most
2440 environments it is not necessary to reclaim memory just before terminating
2441 execution, hence the name.
2442
2443 @node Pragma Float_Representation
2444 @unnumberedsec Pragma Float_Representation
2445 @cindex OpenVMS
2446 @findex Float_Representation
2447 @noindent
2448 Syntax:
2449
2450 @smallexample @c ada
2451 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2452
2453 FLOAT_REP ::= VAX_Float | IEEE_Float
2454 @end smallexample
2455
2456 @noindent
2457 In the one argument form, this pragma is a configuration pragma which
2458 allows control over the internal representation chosen for the predefined
2459 floating point types declared in the packages @code{Standard} and
2460 @code{System}. On all systems other than OpenVMS, the argument must
2461 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2462 argument may be @code{VAX_Float} to specify the use of the VAX float
2463 format for the floating-point types in Standard. This requires that
2464 the standard runtime libraries be recompiled.
2465
2466 The two argument form specifies the representation to be used for
2467 the specified floating-point type. On all systems other than OpenVMS,
2468 the argument must
2469 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2470 argument may be @code{VAX_Float} to specify the use of the VAX float
2471 format, as follows:
2472
2473 @itemize @bullet
2474 @item
2475 For digits values up to 6, F float format will be used.
2476 @item
2477 For digits values from 7 to 9, D float format will be used.
2478 @item
2479 For digits values from 10 to 15, G float format will be used.
2480 @item
2481 Digits values above 15 are not allowed.
2482 @end itemize
2483
2484 @node Pragma Ident
2485 @unnumberedsec Pragma Ident
2486 @findex Ident
2487 @noindent
2488 Syntax:
2489
2490 @smallexample @c ada
2491 pragma Ident (static_string_EXPRESSION);
2492 @end smallexample
2493
2494 @noindent
2495 This pragma provides a string identification in the generated object file,
2496 if the system supports the concept of this kind of identification string.
2497 This pragma is allowed only in the outermost declarative part or
2498 declarative items of a compilation unit. If more than one @code{Ident}
2499 pragma is given, only the last one processed is effective.
2500 @cindex OpenVMS
2501 On OpenVMS systems, the effect of the pragma is identical to the effect of
2502 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2503 maximum allowed length is 31 characters, so if it is important to
2504 maintain compatibility with this compiler, you should obey this length
2505 limit.
2506
2507 @node Pragma Implemented
2508 @unnumberedsec Pragma Implemented
2509 @findex Implemented
2510 @noindent
2511 Syntax:
2512
2513 @smallexample @c ada
2514 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2515
2516 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2517 @end smallexample
2518
2519 @noindent
2520 This is an Ada 2012 representation pragma which applies to protected, task
2521 and synchronized interface primitives. The use of pragma Implemented provides
2522 a way to impose a static requirement on the overriding operation by adhering
2523 to one of the three implementation kids: entry, protected procedure or any of
2524 the above.
2525
2526 @smallexample @c ada
2527 type Synch_Iface is synchronized interface;
2528 procedure Prim_Op (Obj : in out Iface) is abstract;
2529 pragma Implemented (Prim_Op, By_Protected_Procedure);
2530
2531 protected type Prot_1 is new Synch_Iface with
2532 procedure Prim_Op; -- Legal
2533 end Prot_1;
2534
2535 protected type Prot_2 is new Synch_Iface with
2536 entry Prim_Op; -- Illegal
2537 end Prot_2;
2538
2539 task type Task_Typ is new Synch_Iface with
2540 entry Prim_Op; -- Illegal
2541 end Task_Typ;
2542 @end smallexample
2543
2544 @noindent
2545 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2546 Implemented determines the runtime behavior of the requeue. Implementation kind
2547 By_Entry guarantees that the action of requeueing will proceed from an entry to
2548 another entry. Implementation kind By_Protected_Procedure transforms the
2549 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2550 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2551 the target's overriding subprogram kind.
2552
2553 @node Pragma Implicit_Packing
2554 @unnumberedsec Pragma Implicit_Packing
2555 @findex Implicit_Packing
2556 @noindent
2557 Syntax:
2558
2559 @smallexample @c ada
2560 pragma Implicit_Packing;
2561 @end smallexample
2562
2563 @noindent
2564 This is a configuration pragma that requests implicit packing for packed
2565 arrays for which a size clause is given but no explicit pragma Pack or
2566 specification of Component_Size is present. It also applies to records
2567 where no record representation clause is present. Consider this example:
2568
2569 @smallexample @c ada
2570 type R is array (0 .. 7) of Boolean;
2571 for R'Size use 8;
2572 @end smallexample
2573
2574 @noindent
2575 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2576 does not change the layout of a composite object. So the Size clause in the
2577 above example is normally rejected, since the default layout of the array uses
2578 8-bit components, and thus the array requires a minimum of 64 bits.
2579
2580 If this declaration is compiled in a region of code covered by an occurrence
2581 of the configuration pragma Implicit_Packing, then the Size clause in this
2582 and similar examples will cause implicit packing and thus be accepted. For
2583 this implicit packing to occur, the type in question must be an array of small
2584 components whose size is known at compile time, and the Size clause must
2585 specify the exact size that corresponds to the length of the array multiplied
2586 by the size in bits of the component type.
2587 @cindex Array packing
2588
2589 Similarly, the following example shows the use in the record case
2590
2591 @smallexample @c ada
2592 type r is record
2593 a, b, c, d, e, f, g, h : boolean;
2594 chr : character;
2595 end record;
2596 for r'size use 16;
2597 @end smallexample
2598
2599 @noindent
2600 Without a pragma Pack, each Boolean field requires 8 bits, so the
2601 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2602 sufficient. The use of pragma Implicit_Packing allows this record
2603 declaration to compile without an explicit pragma Pack.
2604 @node Pragma Import_Exception
2605 @unnumberedsec Pragma Import_Exception
2606 @cindex OpenVMS
2607 @findex Import_Exception
2608 @noindent
2609 Syntax:
2610
2611 @smallexample @c ada
2612 pragma Import_Exception (
2613 [Internal =>] LOCAL_NAME
2614 [, [External =>] EXTERNAL_SYMBOL]
2615 [, [Form =>] Ada | VMS]
2616 [, [Code =>] static_integer_EXPRESSION]);
2617
2618 EXTERNAL_SYMBOL ::=
2619 IDENTIFIER
2620 | static_string_EXPRESSION
2621 @end smallexample
2622
2623 @noindent
2624 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2625 It allows OpenVMS conditions (for example, from OpenVMS system services or
2626 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2627 The pragma specifies that the exception associated with an exception
2628 declaration in an Ada program be defined externally (in non-Ada code).
2629 For further details on this pragma, see the
2630 DEC Ada Language Reference Manual, section 13.9a.3.1.
2631
2632 @node Pragma Import_Function
2633 @unnumberedsec Pragma Import_Function
2634 @findex Import_Function
2635 @noindent
2636 Syntax:
2637
2638 @smallexample @c ada
2639 pragma Import_Function (
2640 [Internal =>] LOCAL_NAME,
2641 [, [External =>] EXTERNAL_SYMBOL]
2642 [, [Parameter_Types =>] PARAMETER_TYPES]
2643 [, [Result_Type =>] SUBTYPE_MARK]
2644 [, [Mechanism =>] MECHANISM]
2645 [, [Result_Mechanism =>] MECHANISM_NAME]
2646 [, [First_Optional_Parameter =>] IDENTIFIER]);
2647
2648 EXTERNAL_SYMBOL ::=
2649 IDENTIFIER
2650 | static_string_EXPRESSION
2651
2652 PARAMETER_TYPES ::=
2653 null
2654 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2655
2656 TYPE_DESIGNATOR ::=
2657 subtype_NAME
2658 | subtype_Name ' Access
2659
2660 MECHANISM ::=
2661 MECHANISM_NAME
2662 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2663
2664 MECHANISM_ASSOCIATION ::=
2665 [formal_parameter_NAME =>] MECHANISM_NAME
2666
2667 MECHANISM_NAME ::=
2668 Value
2669 | Reference
2670 | Descriptor [([Class =>] CLASS_NAME)]
2671 | Short_Descriptor [([Class =>] CLASS_NAME)]
2672
2673 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2674 @end smallexample
2675
2676 @noindent
2677 This pragma is used in conjunction with a pragma @code{Import} to
2678 specify additional information for an imported function. The pragma
2679 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2680 @code{Import_Function} pragma and both must appear in the same
2681 declarative part as the function specification.
2682
2683 The @var{Internal} argument must uniquely designate
2684 the function to which the
2685 pragma applies. If more than one function name exists of this name in
2686 the declarative part you must use the @code{Parameter_Types} and
2687 @var{Result_Type} parameters to achieve the required unique
2688 designation. Subtype marks in these parameters must exactly match the
2689 subtypes in the corresponding function specification, using positional
2690 notation to match parameters with subtype marks.
2691 The form with an @code{'Access} attribute can be used to match an
2692 anonymous access parameter.
2693
2694 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2695 parameters to specify passing mechanisms for the
2696 parameters and result. If you specify a single mechanism name, it
2697 applies to all parameters. Otherwise you may specify a mechanism on a
2698 parameter by parameter basis using either positional or named
2699 notation. If the mechanism is not specified, the default mechanism
2700 is used.
2701
2702 @cindex OpenVMS
2703 @cindex Passing by descriptor
2704 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2705 The default behavior for Import_Function is to pass a 64bit descriptor
2706 unless short_descriptor is specified, then a 32bit descriptor is passed.
2707
2708 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2709 It specifies that the designated parameter and all following parameters
2710 are optional, meaning that they are not passed at the generated code
2711 level (this is distinct from the notion of optional parameters in Ada
2712 where the parameters are passed anyway with the designated optional
2713 parameters). All optional parameters must be of mode @code{IN} and have
2714 default parameter values that are either known at compile time
2715 expressions, or uses of the @code{'Null_Parameter} attribute.
2716
2717 @node Pragma Import_Object
2718 @unnumberedsec Pragma Import_Object
2719 @findex Import_Object
2720 @noindent
2721 Syntax:
2722
2723 @smallexample @c ada
2724 pragma Import_Object
2725 [Internal =>] LOCAL_NAME
2726 [, [External =>] EXTERNAL_SYMBOL]
2727 [, [Size =>] EXTERNAL_SYMBOL]);
2728
2729 EXTERNAL_SYMBOL ::=
2730 IDENTIFIER
2731 | static_string_EXPRESSION
2732 @end smallexample
2733
2734 @noindent
2735 This pragma designates an object as imported, and apart from the
2736 extended rules for external symbols, is identical in effect to the use of
2737 the normal @code{Import} pragma applied to an object. Unlike the
2738 subprogram case, you need not use a separate @code{Import} pragma,
2739 although you may do so (and probably should do so from a portability
2740 point of view). @var{size} is syntax checked, but otherwise ignored by
2741 GNAT@.
2742
2743 @node Pragma Import_Procedure
2744 @unnumberedsec Pragma Import_Procedure
2745 @findex Import_Procedure
2746 @noindent
2747 Syntax:
2748
2749 @smallexample @c ada
2750 pragma Import_Procedure (
2751 [Internal =>] LOCAL_NAME
2752 [, [External =>] EXTERNAL_SYMBOL]
2753 [, [Parameter_Types =>] PARAMETER_TYPES]
2754 [, [Mechanism =>] MECHANISM]
2755 [, [First_Optional_Parameter =>] IDENTIFIER]);
2756
2757 EXTERNAL_SYMBOL ::=
2758 IDENTIFIER
2759 | static_string_EXPRESSION
2760
2761 PARAMETER_TYPES ::=
2762 null
2763 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2764
2765 TYPE_DESIGNATOR ::=
2766 subtype_NAME
2767 | subtype_Name ' Access
2768
2769 MECHANISM ::=
2770 MECHANISM_NAME
2771 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2772
2773 MECHANISM_ASSOCIATION ::=
2774 [formal_parameter_NAME =>] MECHANISM_NAME
2775
2776 MECHANISM_NAME ::=
2777 Value
2778 | Reference
2779 | Descriptor [([Class =>] CLASS_NAME)]
2780 | Short_Descriptor [([Class =>] CLASS_NAME)]
2781
2782 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2783 @end smallexample
2784
2785 @noindent
2786 This pragma is identical to @code{Import_Function} except that it
2787 applies to a procedure rather than a function and the parameters
2788 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2789
2790 @node Pragma Import_Valued_Procedure
2791 @unnumberedsec Pragma Import_Valued_Procedure
2792 @findex Import_Valued_Procedure
2793 @noindent
2794 Syntax:
2795
2796 @smallexample @c ada
2797 pragma Import_Valued_Procedure (
2798 [Internal =>] LOCAL_NAME
2799 [, [External =>] EXTERNAL_SYMBOL]
2800 [, [Parameter_Types =>] PARAMETER_TYPES]
2801 [, [Mechanism =>] MECHANISM]
2802 [, [First_Optional_Parameter =>] IDENTIFIER]);
2803
2804 EXTERNAL_SYMBOL ::=
2805 IDENTIFIER
2806 | static_string_EXPRESSION
2807
2808 PARAMETER_TYPES ::=
2809 null
2810 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2811
2812 TYPE_DESIGNATOR ::=
2813 subtype_NAME
2814 | subtype_Name ' Access
2815
2816 MECHANISM ::=
2817 MECHANISM_NAME
2818 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2819
2820 MECHANISM_ASSOCIATION ::=
2821 [formal_parameter_NAME =>] MECHANISM_NAME
2822
2823 MECHANISM_NAME ::=
2824 Value
2825 | Reference
2826 | Descriptor [([Class =>] CLASS_NAME)]
2827 | Short_Descriptor [([Class =>] CLASS_NAME)]
2828
2829 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2830 @end smallexample
2831
2832 @noindent
2833 This pragma is identical to @code{Import_Procedure} except that the
2834 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2835 mode @code{OUT}, and externally the subprogram is treated as a function
2836 with this parameter as the result of the function. The purpose of this
2837 capability is to allow the use of @code{OUT} and @code{IN OUT}
2838 parameters in interfacing to external functions (which are not permitted
2839 in Ada functions). You may optionally use the @code{Mechanism}
2840 parameters to specify passing mechanisms for the parameters.
2841 If you specify a single mechanism name, it applies to all parameters.
2842 Otherwise you may specify a mechanism on a parameter by parameter
2843 basis using either positional or named notation. If the mechanism is not
2844 specified, the default mechanism is used.
2845
2846 Note that it is important to use this pragma in conjunction with a separate
2847 pragma Import that specifies the desired convention, since otherwise the
2848 default convention is Ada, which is almost certainly not what is required.
2849
2850 @node Pragma Initialize_Scalars
2851 @unnumberedsec Pragma Initialize_Scalars
2852 @findex Initialize_Scalars
2853 @cindex debugging with Initialize_Scalars
2854 @noindent
2855 Syntax:
2856
2857 @smallexample @c ada
2858 pragma Initialize_Scalars;
2859 @end smallexample
2860
2861 @noindent
2862 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2863 two important differences. First, there is no requirement for the pragma
2864 to be used uniformly in all units of a partition, in particular, it is fine
2865 to use this just for some or all of the application units of a partition,
2866 without needing to recompile the run-time library.
2867
2868 In the case where some units are compiled with the pragma, and some without,
2869 then a declaration of a variable where the type is defined in package
2870 Standard or is locally declared will always be subject to initialization,
2871 as will any declaration of a scalar variable. For composite variables,
2872 whether the variable is initialized may also depend on whether the package
2873 in which the type of the variable is declared is compiled with the pragma.
2874
2875 The other important difference is that you can control the value used
2876 for initializing scalar objects. At bind time, you can select several
2877 options for initialization. You can
2878 initialize with invalid values (similar to Normalize_Scalars, though for
2879 Initialize_Scalars it is not always possible to determine the invalid
2880 values in complex cases like signed component fields with non-standard
2881 sizes). You can also initialize with high or
2882 low values, or with a specified bit pattern. See the users guide for binder
2883 options for specifying these cases.
2884
2885 This means that you can compile a program, and then without having to
2886 recompile the program, you can run it with different values being used
2887 for initializing otherwise uninitialized values, to test if your program
2888 behavior depends on the choice. Of course the behavior should not change,
2889 and if it does, then most likely you have an erroneous reference to an
2890 uninitialized value.
2891
2892 It is even possible to change the value at execution time eliminating even
2893 the need to rebind with a different switch using an environment variable.
2894 See the GNAT users guide for details.
2895
2896 Note that pragma @code{Initialize_Scalars} is particularly useful in
2897 conjunction with the enhanced validity checking that is now provided
2898 in GNAT, which checks for invalid values under more conditions.
2899 Using this feature (see description of the @option{-gnatV} flag in the
2900 users guide) in conjunction with pragma @code{Initialize_Scalars}
2901 provides a powerful new tool to assist in the detection of problems
2902 caused by uninitialized variables.
2903
2904 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2905 effect on the generated code. This may cause your code to be
2906 substantially larger. It may also cause an increase in the amount
2907 of stack required, so it is probably a good idea to turn on stack
2908 checking (see description of stack checking in the GNAT users guide)
2909 when using this pragma.
2910
2911 @node Pragma Inline_Always
2912 @unnumberedsec Pragma Inline_Always
2913 @findex Inline_Always
2914 @noindent
2915 Syntax:
2916
2917 @smallexample @c ada
2918 pragma Inline_Always (NAME [, NAME]);
2919 @end smallexample
2920
2921 @noindent
2922 Similar to pragma @code{Inline} except that inlining is not subject to
2923 the use of option @option{-gnatn} and the inlining happens regardless of
2924 whether this option is used.
2925
2926 @node Pragma Inline_Generic
2927 @unnumberedsec Pragma Inline_Generic
2928 @findex Inline_Generic
2929 @noindent
2930 Syntax:
2931
2932 @smallexample @c ada
2933 pragma Inline_Generic (generic_package_NAME);
2934 @end smallexample
2935
2936 @noindent
2937 This is implemented for compatibility with DEC Ada 83 and is recognized,
2938 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2939 by default when using GNAT@.
2940
2941 @node Pragma Interface
2942 @unnumberedsec Pragma Interface
2943 @findex Interface
2944 @noindent
2945 Syntax:
2946
2947 @smallexample @c ada
2948 pragma Interface (
2949 [Convention =>] convention_identifier,
2950 [Entity =>] local_NAME
2951 [, [External_Name =>] static_string_expression]
2952 [, [Link_Name =>] static_string_expression]);
2953 @end smallexample
2954
2955 @noindent
2956 This pragma is identical in syntax and semantics to
2957 the standard Ada pragma @code{Import}. It is provided for compatibility
2958 with Ada 83. The definition is upwards compatible both with pragma
2959 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2960 with some extended implementations of this pragma in certain Ada 83
2961 implementations. The only difference between pragma @code{Interface}
2962 and pragma @code{Import} is that there is special circuitry to allow
2963 both pragmas to appear for the same subprogram entity (normally it
2964 is illegal to have multiple @code{Import} pragmas. This is useful in
2965 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2966 Ada 83 compilers.
2967
2968 @node Pragma Interface_Name
2969 @unnumberedsec Pragma Interface_Name
2970 @findex Interface_Name
2971 @noindent
2972 Syntax:
2973
2974 @smallexample @c ada
2975 pragma Interface_Name (
2976 [Entity =>] LOCAL_NAME
2977 [, [External_Name =>] static_string_EXPRESSION]
2978 [, [Link_Name =>] static_string_EXPRESSION]);
2979 @end smallexample
2980
2981 @noindent
2982 This pragma provides an alternative way of specifying the interface name
2983 for an interfaced subprogram, and is provided for compatibility with Ada
2984 83 compilers that use the pragma for this purpose. You must provide at
2985 least one of @var{External_Name} or @var{Link_Name}.
2986
2987 @node Pragma Interrupt_Handler
2988 @unnumberedsec Pragma Interrupt_Handler
2989 @findex Interrupt_Handler
2990 @noindent
2991 Syntax:
2992
2993 @smallexample @c ada
2994 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2995 @end smallexample
2996
2997 @noindent
2998 This program unit pragma is supported for parameterless protected procedures
2999 as described in Annex C of the Ada Reference Manual. On the AAMP target
3000 the pragma can also be specified for nonprotected parameterless procedures
3001 that are declared at the library level (which includes procedures
3002 declared at the top level of a library package). In the case of AAMP,
3003 when this pragma is applied to a nonprotected procedure, the instruction
3004 @code{IERET} is generated for returns from the procedure, enabling
3005 maskable interrupts, in place of the normal return instruction.
3006
3007 @node Pragma Interrupt_State
3008 @unnumberedsec Pragma Interrupt_State
3009 @findex Interrupt_State
3010 @noindent
3011 Syntax:
3012
3013 @smallexample @c ada
3014 pragma Interrupt_State
3015 ([Name =>] value,
3016 [State =>] SYSTEM | RUNTIME | USER);
3017 @end smallexample
3018
3019 @noindent
3020 Normally certain interrupts are reserved to the implementation. Any attempt
3021 to attach an interrupt causes Program_Error to be raised, as described in
3022 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3023 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3024 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3025 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3026 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3027 Ada exceptions, or used to implement run-time functions such as the
3028 @code{abort} statement and stack overflow checking.
3029
3030 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3031 such uses of interrupts. It subsumes the functionality of pragma
3032 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3033 available on Windows or VMS. On all other platforms than VxWorks,
3034 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3035 and may be used to mark interrupts required by the board support package
3036 as reserved.
3037
3038 Interrupts can be in one of three states:
3039 @itemize @bullet
3040 @item System
3041
3042 The interrupt is reserved (no Ada handler can be installed), and the
3043 Ada run-time may not install a handler. As a result you are guaranteed
3044 standard system default action if this interrupt is raised.
3045
3046 @item Runtime
3047
3048 The interrupt is reserved (no Ada handler can be installed). The run time
3049 is allowed to install a handler for internal control purposes, but is
3050 not required to do so.
3051
3052 @item User
3053
3054 The interrupt is unreserved. The user may install a handler to provide
3055 some other action.
3056 @end itemize
3057
3058 @noindent
3059 These states are the allowed values of the @code{State} parameter of the
3060 pragma. The @code{Name} parameter is a value of the type
3061 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3062 @code{Ada.Interrupts.Names}.
3063
3064 This is a configuration pragma, and the binder will check that there
3065 are no inconsistencies between different units in a partition in how a
3066 given interrupt is specified. It may appear anywhere a pragma is legal.
3067
3068 The effect is to move the interrupt to the specified state.
3069
3070 By declaring interrupts to be SYSTEM, you guarantee the standard system
3071 action, such as a core dump.
3072
3073 By declaring interrupts to be USER, you guarantee that you can install
3074 a handler.
3075
3076 Note that certain signals on many operating systems cannot be caught and
3077 handled by applications. In such cases, the pragma is ignored. See the
3078 operating system documentation, or the value of the array @code{Reserved}
3079 declared in the spec of package @code{System.OS_Interface}.
3080
3081 Overriding the default state of signals used by the Ada runtime may interfere
3082 with an application's runtime behavior in the cases of the synchronous signals,
3083 and in the case of the signal used to implement the @code{abort} statement.
3084
3085 @node Pragma Invariant
3086 @unnumberedsec Pragma Invariant
3087 @findex Invariant
3088 @noindent
3089 Syntax:
3090
3091 @smallexample @c ada
3092 pragma Invariant
3093 ([Entity =>] private_type_LOCAL_NAME,
3094 [Check =>] EXPRESSION
3095 [,[Message =>] String_Expression]);
3096 @end smallexample
3097
3098 @noindent
3099 This pragma provides exactly the same capabilities as the Invariant aspect
3100 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3101 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3102 of the aspect syntax, which is not available exception in 2012 mode, it is
3103 not possible to use the Invariant aspect in earlier versions of Ada. However
3104 the Invariant pragma may be used in any version of Ada.
3105
3106 The pragma must appear within the visible part of the package specification,
3107 after the type to which its Entity argument appears. As with the Invariant
3108 aspect, the Check expression is not analyzed until the end of the visible
3109 part of the package, so it may contain forward references. The Message
3110 argument, if present, provides the exception message used if the invariant
3111 is violated. If no Message parameter is provided, a default message that
3112 identifies the line on which the pragma appears is used.
3113
3114 It is permissible to have multiple Invariants for the same type entity, in
3115 which case they are and'ed together. It is permissible to use this pragma
3116 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3117 invariant pragma for the same entity.
3118
3119 For further details on the use of this pragma, see the Ada 2012 documentation
3120 of the Invariant aspect.
3121
3122 @node Pragma Keep_Names
3123 @unnumberedsec Pragma Keep_Names
3124 @findex Keep_Names
3125 @noindent
3126 Syntax:
3127
3128 @smallexample @c ada
3129 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3130 @end smallexample
3131
3132 @noindent
3133 The @var{LOCAL_NAME} argument
3134 must refer to an enumeration first subtype
3135 in the current declarative part. The effect is to retain the enumeration
3136 literal names for use by @code{Image} and @code{Value} even if a global
3137 @code{Discard_Names} pragma applies. This is useful when you want to
3138 generally suppress enumeration literal names and for example you therefore
3139 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3140 want to retain the names for specific enumeration types.
3141
3142 @node Pragma License
3143 @unnumberedsec Pragma License
3144 @findex License
3145 @cindex License checking
3146 @noindent
3147 Syntax:
3148
3149 @smallexample @c ada
3150 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3151 @end smallexample
3152
3153 @noindent
3154 This pragma is provided to allow automated checking for appropriate license
3155 conditions with respect to the standard and modified GPL@. A pragma
3156 @code{License}, which is a configuration pragma that typically appears at
3157 the start of a source file or in a separate @file{gnat.adc} file, specifies
3158 the licensing conditions of a unit as follows:
3159
3160 @itemize @bullet
3161 @item Unrestricted
3162 This is used for a unit that can be freely used with no license restrictions.
3163 Examples of such units are public domain units, and units from the Ada
3164 Reference Manual.
3165
3166 @item GPL
3167 This is used for a unit that is licensed under the unmodified GPL, and which
3168 therefore cannot be @code{with}'ed by a restricted unit.
3169
3170 @item Modified_GPL
3171 This is used for a unit licensed under the GNAT modified GPL that includes
3172 a special exception paragraph that specifically permits the inclusion of
3173 the unit in programs without requiring the entire program to be released
3174 under the GPL@.
3175
3176 @item Restricted
3177 This is used for a unit that is restricted in that it is not permitted to
3178 depend on units that are licensed under the GPL@. Typical examples are
3179 proprietary code that is to be released under more restrictive license
3180 conditions. Note that restricted units are permitted to @code{with} units
3181 which are licensed under the modified GPL (this is the whole point of the
3182 modified GPL).
3183
3184 @end itemize
3185
3186 @noindent
3187 Normally a unit with no @code{License} pragma is considered to have an
3188 unknown license, and no checking is done. However, standard GNAT headers
3189 are recognized, and license information is derived from them as follows.
3190
3191 @itemize @bullet
3192
3193 A GNAT license header starts with a line containing 78 hyphens. The following
3194 comment text is searched for the appearance of any of the following strings.
3195
3196 If the string ``GNU General Public License'' is found, then the unit is assumed
3197 to have GPL license, unless the string ``As a special exception'' follows, in
3198 which case the license is assumed to be modified GPL@.
3199
3200 If one of the strings
3201 ``This specification is adapted from the Ada Semantic Interface'' or
3202 ``This specification is derived from the Ada Reference Manual'' is found
3203 then the unit is assumed to be unrestricted.
3204 @end itemize
3205
3206 @noindent
3207 These default actions means that a program with a restricted license pragma
3208 will automatically get warnings if a GPL unit is inappropriately
3209 @code{with}'ed. For example, the program:
3210
3211 @smallexample @c ada
3212 with Sem_Ch3;
3213 with GNAT.Sockets;
3214 procedure Secret_Stuff is
3215 @dots{}
3216 end Secret_Stuff
3217 @end smallexample
3218
3219 @noindent
3220 if compiled with pragma @code{License} (@code{Restricted}) in a
3221 @file{gnat.adc} file will generate the warning:
3222
3223 @smallexample
3224 1. with Sem_Ch3;
3225 |
3226 >>> license of withed unit "Sem_Ch3" is incompatible
3227
3228 2. with GNAT.Sockets;
3229 3. procedure Secret_Stuff is
3230 @end smallexample
3231
3232 @noindent
3233 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3234 compiler and is licensed under the
3235 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3236 run time, and is therefore licensed under the modified GPL@.
3237
3238 @node Pragma Link_With
3239 @unnumberedsec Pragma Link_With
3240 @findex Link_With
3241 @noindent
3242 Syntax:
3243
3244 @smallexample @c ada
3245 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3246 @end smallexample
3247
3248 @noindent
3249 This pragma is provided for compatibility with certain Ada 83 compilers.
3250 It has exactly the same effect as pragma @code{Linker_Options} except
3251 that spaces occurring within one of the string expressions are treated
3252 as separators. For example, in the following case:
3253
3254 @smallexample @c ada
3255 pragma Link_With ("-labc -ldef");
3256 @end smallexample
3257
3258 @noindent
3259 results in passing the strings @code{-labc} and @code{-ldef} as two
3260 separate arguments to the linker. In addition pragma Link_With allows
3261 multiple arguments, with the same effect as successive pragmas.
3262
3263 @node Pragma Linker_Alias
3264 @unnumberedsec Pragma Linker_Alias
3265 @findex Linker_Alias
3266 @noindent
3267 Syntax:
3268
3269 @smallexample @c ada
3270 pragma Linker_Alias (
3271 [Entity =>] LOCAL_NAME,
3272 [Target =>] static_string_EXPRESSION);
3273 @end smallexample
3274
3275 @noindent
3276 @var{LOCAL_NAME} must refer to an object that is declared at the library
3277 level. This pragma establishes the given entity as a linker alias for the
3278 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3279 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3280 @var{static_string_EXPRESSION} in the object file, that is to say no space
3281 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3282 to the same address as @var{static_string_EXPRESSION} by the linker.
3283
3284 The actual linker name for the target must be used (e.g.@: the fully
3285 encoded name with qualification in Ada, or the mangled name in C++),
3286 or it must be declared using the C convention with @code{pragma Import}
3287 or @code{pragma Export}.
3288
3289 Not all target machines support this pragma. On some of them it is accepted
3290 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3291
3292 @smallexample @c ada
3293 -- Example of the use of pragma Linker_Alias
3294
3295 package p is
3296 i : Integer := 1;
3297 pragma Export (C, i);
3298
3299 new_name_for_i : Integer;
3300 pragma Linker_Alias (new_name_for_i, "i");
3301 end p;
3302 @end smallexample
3303
3304 @node Pragma Linker_Constructor
3305 @unnumberedsec Pragma Linker_Constructor
3306 @findex Linker_Constructor
3307 @noindent
3308 Syntax:
3309
3310 @smallexample @c ada
3311 pragma Linker_Constructor (procedure_LOCAL_NAME);
3312 @end smallexample
3313
3314 @noindent
3315 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3316 is declared at the library level. A procedure to which this pragma is
3317 applied will be treated as an initialization routine by the linker.
3318 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3319 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3320 of the executable is called (or immediately after the shared library is
3321 loaded if the procedure is linked in a shared library), in particular
3322 before the Ada run-time environment is set up.
3323
3324 Because of these specific contexts, the set of operations such a procedure
3325 can perform is very limited and the type of objects it can manipulate is
3326 essentially restricted to the elementary types. In particular, it must only
3327 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3328
3329 This pragma is used by GNAT to implement auto-initialization of shared Stand
3330 Alone Libraries, which provides a related capability without the restrictions
3331 listed above. Where possible, the use of Stand Alone Libraries is preferable
3332 to the use of this pragma.
3333
3334 @node Pragma Linker_Destructor
3335 @unnumberedsec Pragma Linker_Destructor
3336 @findex Linker_Destructor
3337 @noindent
3338 Syntax:
3339
3340 @smallexample @c ada
3341 pragma Linker_Destructor (procedure_LOCAL_NAME);
3342 @end smallexample
3343
3344 @noindent
3345 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3346 is declared at the library level. A procedure to which this pragma is
3347 applied will be treated as a finalization routine by the linker.
3348 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3349 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3350 of the executable has exited (or immediately before the shared library
3351 is unloaded if the procedure is linked in a shared library), in particular
3352 after the Ada run-time environment is shut down.
3353
3354 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3355 because of these specific contexts.
3356
3357 @node Pragma Linker_Section
3358 @unnumberedsec Pragma Linker_Section
3359 @findex Linker_Section
3360 @noindent
3361 Syntax:
3362
3363 @smallexample @c ada
3364 pragma Linker_Section (
3365 [Entity =>] LOCAL_NAME,
3366 [Section =>] static_string_EXPRESSION);
3367 @end smallexample
3368
3369 @noindent
3370 @var{LOCAL_NAME} must refer to an object that is declared at the library
3371 level. This pragma specifies the name of the linker section for the given
3372 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3373 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3374 section of the executable (assuming the linker doesn't rename the section).
3375
3376 The compiler normally places library-level objects in standard sections
3377 depending on their type: procedures and functions generally go in the
3378 @code{.text} section, initialized variables in the @code{.data} section
3379 and uninitialized variables in the @code{.bss} section.
3380
3381 Other, special sections may exist on given target machines to map special
3382 hardware, for example I/O ports or flash memory. This pragma is a means to
3383 defer the final layout of the executable to the linker, thus fully working
3384 at the symbolic level with the compiler.
3385
3386 Some file formats do not support arbitrary sections so not all target
3387 machines support this pragma. The use of this pragma may cause a program
3388 execution to be erroneous if it is used to place an entity into an
3389 inappropriate section (e.g.@: a modified variable into the @code{.text}
3390 section). See also @code{pragma Persistent_BSS}.
3391
3392 @smallexample @c ada
3393 -- Example of the use of pragma Linker_Section
3394
3395 package IO_Card is
3396 Port_A : Integer;
3397 pragma Volatile (Port_A);
3398 pragma Linker_Section (Port_A, ".bss.port_a");
3399
3400 Port_B : Integer;
3401 pragma Volatile (Port_B);
3402 pragma Linker_Section (Port_B, ".bss.port_b");
3403 end IO_Card;
3404 @end smallexample
3405
3406 @node Pragma Long_Float
3407 @unnumberedsec Pragma Long_Float
3408 @cindex OpenVMS
3409 @findex Long_Float
3410 @noindent
3411 Syntax:
3412
3413 @smallexample @c ada
3414 pragma Long_Float (FLOAT_FORMAT);
3415
3416 FLOAT_FORMAT ::= D_Float | G_Float
3417 @end smallexample
3418
3419 @noindent
3420 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3421 It allows control over the internal representation chosen for the predefined
3422 type @code{Long_Float} and for floating point type representations with
3423 @code{digits} specified in the range 7 through 15.
3424 For further details on this pragma, see the
3425 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3426 this pragma, the standard runtime libraries must be recompiled.
3427
3428 @node Pragma Machine_Attribute
3429 @unnumberedsec Pragma Machine_Attribute
3430 @findex Machine_Attribute
3431 @noindent
3432 Syntax:
3433
3434 @smallexample @c ada
3435 pragma Machine_Attribute (
3436 [Entity =>] LOCAL_NAME,
3437 [Attribute_Name =>] static_string_EXPRESSION
3438 [, [Info =>] static_EXPRESSION] );
3439 @end smallexample
3440
3441 @noindent
3442 Machine-dependent attributes can be specified for types and/or
3443 declarations. This pragma is semantically equivalent to
3444 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3445 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3446 in GNU C, where @code{@var{attribute_name}} is recognized by the
3447 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3448 specific macro. A string literal for the optional parameter @var{info}
3449 is transformed into an identifier, which may make this pragma unusable
3450 for some attributes. @xref{Target Attributes,, Defining target-specific
3451 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3452 Internals}, further information.
3453
3454 @node Pragma Main
3455 @unnumberedsec Pragma Main
3456 @cindex OpenVMS
3457 @findex Main
3458 @noindent
3459 Syntax:
3460
3461 @smallexample @c ada
3462 pragma Main
3463 (MAIN_OPTION [, MAIN_OPTION]);
3464
3465 MAIN_OPTION ::=
3466 [Stack_Size =>] static_integer_EXPRESSION
3467 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3468 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3469 @end smallexample
3470
3471 @noindent
3472 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3473 no effect in GNAT, other than being syntax checked.
3474
3475 @node Pragma Main_Storage
3476 @unnumberedsec Pragma Main_Storage
3477 @cindex OpenVMS
3478 @findex Main_Storage
3479 @noindent
3480 Syntax:
3481
3482 @smallexample @c ada
3483 pragma Main_Storage
3484 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3485
3486 MAIN_STORAGE_OPTION ::=
3487 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3488 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3489 @end smallexample
3490
3491 @noindent
3492 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3493 no effect in GNAT, other than being syntax checked. Note that the pragma
3494 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3495
3496 @node Pragma No_Body
3497 @unnumberedsec Pragma No_Body
3498 @findex No_Body
3499 @noindent
3500 Syntax:
3501
3502 @smallexample @c ada
3503 pragma No_Body;
3504 @end smallexample
3505
3506 @noindent
3507 There are a number of cases in which a package spec does not require a body,
3508 and in fact a body is not permitted. GNAT will not permit the spec to be
3509 compiled if there is a body around. The pragma No_Body allows you to provide
3510 a body file, even in a case where no body is allowed. The body file must
3511 contain only comments and a single No_Body pragma. This is recognized by
3512 the compiler as indicating that no body is logically present.
3513
3514 This is particularly useful during maintenance when a package is modified in
3515 such a way that a body needed before is no longer needed. The provision of a
3516 dummy body with a No_Body pragma ensures that there is no interference from
3517 earlier versions of the package body.
3518
3519 @node Pragma No_Return
3520 @unnumberedsec Pragma No_Return
3521 @findex No_Return
3522 @noindent
3523 Syntax:
3524
3525 @smallexample @c ada
3526 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3527 @end smallexample
3528
3529 @noindent
3530 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3531 declarations in the current declarative part. A procedure to which this
3532 pragma is applied may not contain any explicit @code{return} statements.
3533 In addition, if the procedure contains any implicit returns from falling
3534 off the end of a statement sequence, then execution of that implicit
3535 return will cause Program_Error to be raised.
3536
3537 One use of this pragma is to identify procedures whose only purpose is to raise
3538 an exception. Another use of this pragma is to suppress incorrect warnings
3539 about missing returns in functions, where the last statement of a function
3540 statement sequence is a call to such a procedure.
3541
3542 Note that in Ada 2005 mode, this pragma is part of the language, and is
3543 identical in effect to the pragma as implemented in Ada 95 mode.
3544
3545 @node Pragma No_Strict_Aliasing
3546 @unnumberedsec Pragma No_Strict_Aliasing
3547 @findex No_Strict_Aliasing
3548 @noindent
3549 Syntax:
3550
3551 @smallexample @c ada
3552 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3553 @end smallexample
3554
3555 @noindent
3556 @var{type_LOCAL_NAME} must refer to an access type
3557 declaration in the current declarative part. The effect is to inhibit
3558 strict aliasing optimization for the given type. The form with no
3559 arguments is a configuration pragma which applies to all access types
3560 declared in units to which the pragma applies. For a detailed
3561 description of the strict aliasing optimization, and the situations
3562 in which it must be suppressed, see @ref{Optimization and Strict
3563 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3564
3565 This pragma currently has no effects on access to unconstrained array types.
3566
3567 @node Pragma Normalize_Scalars
3568 @unnumberedsec Pragma Normalize_Scalars
3569 @findex Normalize_Scalars
3570 @noindent
3571 Syntax:
3572
3573 @smallexample @c ada
3574 pragma Normalize_Scalars;
3575 @end smallexample
3576
3577 @noindent
3578 This is a language defined pragma which is fully implemented in GNAT@. The
3579 effect is to cause all scalar objects that are not otherwise initialized
3580 to be initialized. The initial values are implementation dependent and
3581 are as follows:
3582
3583 @table @code
3584 @item Standard.Character
3585 @noindent
3586 Objects whose root type is Standard.Character are initialized to
3587 Character'Last unless the subtype range excludes NUL (in which case
3588 NUL is used). This choice will always generate an invalid value if
3589 one exists.
3590
3591 @item Standard.Wide_Character
3592 @noindent
3593 Objects whose root type is Standard.Wide_Character are initialized to
3594 Wide_Character'Last unless the subtype range excludes NUL (in which case
3595 NUL is used). This choice will always generate an invalid value if
3596 one exists.
3597
3598 @item Standard.Wide_Wide_Character
3599 @noindent
3600 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3601 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3602 which case NUL is used). This choice will always generate an invalid value if
3603 one exists.
3604
3605 @item Integer types
3606 @noindent
3607 Objects of an integer type are treated differently depending on whether
3608 negative values are present in the subtype. If no negative values are
3609 present, then all one bits is used as the initial value except in the
3610 special case where zero is excluded from the subtype, in which case
3611 all zero bits are used. This choice will always generate an invalid
3612 value if one exists.
3613
3614 For subtypes with negative values present, the largest negative number
3615 is used, except in the unusual case where this largest negative number
3616 is in the subtype, and the largest positive number is not, in which case
3617 the largest positive value is used. This choice will always generate
3618 an invalid value if one exists.
3619
3620 @item Floating-Point Types
3621 Objects of all floating-point types are initialized to all 1-bits. For
3622 standard IEEE format, this corresponds to a NaN (not a number) which is
3623 indeed an invalid value.
3624
3625 @item Fixed-Point Types
3626 Objects of all fixed-point types are treated as described above for integers,
3627 with the rules applying to the underlying integer value used to represent
3628 the fixed-point value.
3629
3630 @item Modular types
3631 Objects of a modular type are initialized to all one bits, except in
3632 the special case where zero is excluded from the subtype, in which
3633 case all zero bits are used. This choice will always generate an
3634 invalid value if one exists.
3635
3636 @item Enumeration types
3637 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3638 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3639 whose Pos value is zero, in which case a code of zero is used. This choice
3640 will always generate an invalid value if one exists.
3641
3642 @end table
3643
3644 @node Pragma Obsolescent
3645 @unnumberedsec Pragma Obsolescent
3646 @findex Obsolescent
3647 @noindent
3648 Syntax:
3649
3650 @smallexample @c ada
3651 pragma Obsolescent;
3652
3653 pragma Obsolescent (
3654 [Message =>] static_string_EXPRESSION
3655 [,[Version =>] Ada_05]]);
3656
3657 pragma Obsolescent (
3658 [Entity =>] NAME
3659 [,[Message =>] static_string_EXPRESSION
3660 [,[Version =>] Ada_05]] );
3661 @end smallexample
3662
3663 @noindent
3664 This pragma can occur immediately following a declaration of an entity,
3665 including the case of a record component. If no Entity argument is present,
3666 then this declaration is the one to which the pragma applies. If an Entity
3667 parameter is present, it must either match the name of the entity in this
3668 declaration, or alternatively, the pragma can immediately follow an enumeration
3669 type declaration, where the Entity argument names one of the enumeration
3670 literals.
3671
3672 This pragma is used to indicate that the named entity
3673 is considered obsolescent and should not be used. Typically this is
3674 used when an API must be modified by eventually removing or modifying
3675 existing subprograms or other entities. The pragma can be used at an
3676 intermediate stage when the entity is still present, but will be
3677 removed later.
3678
3679 The effect of this pragma is to output a warning message on a reference to
3680 an entity thus marked that the subprogram is obsolescent if the appropriate
3681 warning option in the compiler is activated. If the Message parameter is
3682 present, then a second warning message is given containing this text. In
3683 addition, a reference to the entity is considered to be a violation of pragma
3684 Restrictions (No_Obsolescent_Features).
3685
3686 This pragma can also be used as a program unit pragma for a package,
3687 in which case the entity name is the name of the package, and the
3688 pragma indicates that the entire package is considered
3689 obsolescent. In this case a client @code{with}'ing such a package
3690 violates the restriction, and the @code{with} statement is
3691 flagged with warnings if the warning option is set.
3692
3693 If the Version parameter is present (which must be exactly
3694 the identifier Ada_05, no other argument is allowed), then the
3695 indication of obsolescence applies only when compiling in Ada 2005
3696 mode. This is primarily intended for dealing with the situations
3697 in the predefined library where subprograms or packages
3698 have become defined as obsolescent in Ada 2005
3699 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3700
3701 The following examples show typical uses of this pragma:
3702
3703 @smallexample @c ada
3704 package p is
3705 pragma Obsolescent (p, Message => "use pp instead of p");
3706 end p;
3707
3708 package q is
3709 procedure q2;
3710 pragma Obsolescent ("use q2new instead");
3711
3712 type R is new integer;
3713 pragma Obsolescent
3714 (Entity => R,
3715 Message => "use RR in Ada 2005",
3716 Version => Ada_05);
3717
3718 type M is record
3719 F1 : Integer;
3720 F2 : Integer;
3721 pragma Obsolescent;
3722 F3 : Integer;
3723 end record;
3724
3725 type E is (a, bc, 'd', quack);
3726 pragma Obsolescent (Entity => bc)
3727 pragma Obsolescent (Entity => 'd')
3728
3729 function "+"
3730 (a, b : character) return character;
3731 pragma Obsolescent (Entity => "+");
3732 end;
3733 @end smallexample
3734
3735 @noindent
3736 Note that, as for all pragmas, if you use a pragma argument identifier,
3737 then all subsequent parameters must also use a pragma argument identifier.
3738 So if you specify "Entity =>" for the Entity argument, and a Message
3739 argument is present, it must be preceded by "Message =>".
3740
3741 @node Pragma Optimize_Alignment
3742 @unnumberedsec Pragma Optimize_Alignment
3743 @findex Optimize_Alignment
3744 @cindex Alignment, default settings
3745 @noindent
3746 Syntax:
3747
3748 @smallexample @c ada
3749 pragma Optimize_Alignment (TIME | SPACE | OFF);
3750 @end smallexample
3751
3752 @noindent
3753 This is a configuration pragma which affects the choice of default alignments
3754 for types where no alignment is explicitly specified. There is a time/space
3755 trade-off in the selection of these values. Large alignments result in more
3756 efficient code, at the expense of larger data space, since sizes have to be
3757 increased to match these alignments. Smaller alignments save space, but the
3758 access code is slower. The normal choice of default alignments (which is what
3759 you get if you do not use this pragma, or if you use an argument of OFF),
3760 tries to balance these two requirements.
3761
3762 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3763 First any packed record is given an alignment of 1. Second, if a size is given
3764 for the type, then the alignment is chosen to avoid increasing this size. For
3765 example, consider:
3766
3767 @smallexample @c ada
3768 type R is record
3769 X : Integer;
3770 Y : Character;
3771 end record;
3772
3773 for R'Size use 5*8;
3774 @end smallexample
3775
3776 @noindent
3777 In the default mode, this type gets an alignment of 4, so that access to the
3778 Integer field X are efficient. But this means that objects of the type end up
3779 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3780 allowed to be bigger than the size of the type, but it can waste space if for
3781 example fields of type R appear in an enclosing record. If the above type is
3782 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3783
3784 Specifying TIME causes larger default alignments to be chosen in the case of
3785 small types with sizes that are not a power of 2. For example, consider:
3786
3787 @smallexample @c ada
3788 type R is record
3789 A : Character;
3790 B : Character;
3791 C : Boolean;
3792 end record;
3793
3794 pragma Pack (R);
3795 for R'Size use 17;
3796 @end smallexample
3797
3798 @noindent
3799 The default alignment for this record is normally 1, but if this type is
3800 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3801 to 4, which wastes space for objects of the type, since they are now 4 bytes
3802 long, but results in more efficient access when the whole record is referenced.
3803
3804 As noted above, this is a configuration pragma, and there is a requirement
3805 that all units in a partition be compiled with a consistent setting of the
3806 optimization setting. This would normally be achieved by use of a configuration
3807 pragma file containing the appropriate setting. The exception to this rule is
3808 that units with an explicit configuration pragma in the same file as the source
3809 unit are excluded from the consistency check, as are all predefined units. The
3810 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3811 pragma appears at the start of the file.
3812
3813 @node Pragma Ordered
3814 @unnumberedsec Pragma Ordered
3815 @findex Ordered
3816 @findex pragma @code{Ordered}
3817 @noindent
3818 Syntax:
3819
3820 @smallexample @c ada
3821 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3822 @end smallexample
3823
3824 @noindent
3825 Most enumeration types are from a conceptual point of view unordered.
3826 For example, consider:
3827
3828 @smallexample @c ada
3829 type Color is (Red, Blue, Green, Yellow);
3830 @end smallexample
3831
3832 @noindent
3833 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3834 but really these relations make no sense; the enumeration type merely
3835 specifies a set of possible colors, and the order is unimportant.
3836
3837 For unordered enumeration types, it is generally a good idea if
3838 clients avoid comparisons (other than equality or inequality) and
3839 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3840 other than the unit where the type is declared, its body, and its subunits.)
3841 For example, if code buried in some client says:
3842
3843 @smallexample @c ada
3844 if Current_Color < Yellow then ...
3845 if Current_Color in Blue .. Green then ...
3846 @end smallexample
3847
3848 @noindent
3849 then the client code is relying on the order, which is undesirable.
3850 It makes the code hard to read and creates maintenance difficulties if
3851 entries have to be added to the enumeration type. Instead,
3852 the code in the client should list the possibilities, or an
3853 appropriate subtype should be declared in the unit that declares
3854 the original enumeration type. E.g., the following subtype could
3855 be declared along with the type @code{Color}:
3856
3857 @smallexample @c ada
3858 subtype RBG is Color range Red .. Green;
3859 @end smallexample
3860
3861 @noindent
3862 and then the client could write:
3863
3864 @smallexample @c ada
3865 if Current_Color in RBG then ...
3866 if Current_Color = Blue or Current_Color = Green then ...
3867 @end smallexample
3868
3869 @noindent
3870 However, some enumeration types are legitimately ordered from a conceptual
3871 point of view. For example, if you declare:
3872
3873 @smallexample @c ada
3874 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3875 @end smallexample
3876
3877 @noindent
3878 then the ordering imposed by the language is reasonable, and
3879 clients can depend on it, writing for example:
3880
3881 @smallexample @c ada
3882 if D in Mon .. Fri then ...
3883 if D < Wed then ...
3884 @end smallexample
3885
3886 @noindent
3887 The pragma @option{Ordered} is provided to mark enumeration types that
3888 are conceptually ordered, alerting the reader that clients may depend
3889 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3890 rather than one to mark them as unordered, since in our experience,
3891 the great majority of enumeration types are conceptually unordered.
3892
3893 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3894 and @code{Wide_Wide_Character}
3895 are considered to be ordered types, so each is declared with a
3896 pragma @code{Ordered} in package @code{Standard}.
3897
3898 Normally pragma @code{Ordered} serves only as documentation and a guide for
3899 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3900 requests warnings for inappropriate uses (comparisons and explicit
3901 subranges) for unordered types. If this switch is used, then any
3902 enumeration type not marked with pragma @code{Ordered} will be considered
3903 as unordered, and will generate warnings for inappropriate uses.
3904
3905 For additional information please refer to the description of the
3906 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3907
3908 @node Pragma Passive
3909 @unnumberedsec Pragma Passive
3910 @findex Passive
3911 @noindent
3912 Syntax:
3913
3914 @smallexample @c ada
3915 pragma Passive [(Semaphore | No)];
3916 @end smallexample
3917
3918 @noindent
3919 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3920 compatibility with DEC Ada 83 implementations, where it is used within a
3921 task definition to request that a task be made passive. If the argument
3922 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3923 treats the pragma as an assertion that the containing task is passive
3924 and that optimization of context switch with this task is permitted and
3925 desired. If the argument @code{No} is present, the task must not be
3926 optimized. GNAT does not attempt to optimize any tasks in this manner
3927 (since protected objects are available in place of passive tasks).
3928
3929 @node Pragma Persistent_BSS
3930 @unnumberedsec Pragma Persistent_BSS
3931 @findex Persistent_BSS
3932 @noindent
3933 Syntax:
3934
3935 @smallexample @c ada
3936 pragma Persistent_BSS [(LOCAL_NAME)]
3937 @end smallexample
3938
3939 @noindent
3940 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3941 section. On some targets the linker and loader provide for special
3942 treatment of this section, allowing a program to be reloaded without
3943 affecting the contents of this data (hence the name persistent).
3944
3945 There are two forms of usage. If an argument is given, it must be the
3946 local name of a library level object, with no explicit initialization
3947 and whose type is potentially persistent. If no argument is given, then
3948 the pragma is a configuration pragma, and applies to all library level
3949 objects with no explicit initialization of potentially persistent types.
3950
3951 A potentially persistent type is a scalar type, or a non-tagged,
3952 non-discriminated record, all of whose components have no explicit
3953 initialization and are themselves of a potentially persistent type,
3954 or an array, all of whose constraints are static, and whose component
3955 type is potentially persistent.
3956
3957 If this pragma is used on a target where this feature is not supported,
3958 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3959
3960 @node Pragma Polling
3961 @unnumberedsec Pragma Polling
3962 @findex Polling
3963 @noindent
3964 Syntax:
3965
3966 @smallexample @c ada
3967 pragma Polling (ON | OFF);
3968 @end smallexample
3969
3970 @noindent
3971 This pragma controls the generation of polling code. This is normally off.
3972 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3973 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3974 runtime library, and can be found in file @file{a-excpol.adb}.
3975
3976 Pragma @code{Polling} can appear as a configuration pragma (for example it
3977 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3978 can be used in the statement or declaration sequence to control polling
3979 more locally.
3980
3981 A call to the polling routine is generated at the start of every loop and
3982 at the start of every subprogram call. This guarantees that the @code{Poll}
3983 routine is called frequently, and places an upper bound (determined by
3984 the complexity of the code) on the period between two @code{Poll} calls.
3985
3986 The primary purpose of the polling interface is to enable asynchronous
3987 aborts on targets that cannot otherwise support it (for example Windows
3988 NT), but it may be used for any other purpose requiring periodic polling.
3989 The standard version is null, and can be replaced by a user program. This
3990 will require re-compilation of the @code{Ada.Exceptions} package that can
3991 be found in files @file{a-except.ads} and @file{a-except.adb}.
3992
3993 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3994 distribution) is used to enable the asynchronous abort capability on
3995 targets that do not normally support the capability. The version of
3996 @code{Poll} in this file makes a call to the appropriate runtime routine
3997 to test for an abort condition.
3998
3999 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4000 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4001 details.
4002
4003 @node Pragma Postcondition
4004 @unnumberedsec Pragma Postcondition
4005 @cindex Postconditions
4006 @cindex Checks, postconditions
4007 @findex Postconditions
4008 @noindent
4009 Syntax:
4010
4011 @smallexample @c ada
4012 pragma Postcondition (
4013 [Check =>] Boolean_Expression
4014 [,[Message =>] String_Expression]);
4015 @end smallexample
4016
4017 @noindent
4018 The @code{Postcondition} pragma allows specification of automatic
4019 postcondition checks for subprograms. These checks are similar to
4020 assertions, but are automatically inserted just prior to the return
4021 statements of the subprogram with which they are associated (including
4022 implicit returns at the end of procedure bodies and associated
4023 exception handlers).
4024
4025 In addition, the boolean expression which is the condition which
4026 must be true may contain references to function'Result in the case
4027 of a function to refer to the returned value.
4028
4029 @code{Postcondition} pragmas may appear either immediately following the
4030 (separate) declaration of a subprogram, or at the start of the
4031 declarations of a subprogram body. Only other pragmas may intervene
4032 (that is appear between the subprogram declaration and its
4033 postconditions, or appear before the postcondition in the
4034 declaration sequence in a subprogram body). In the case of a
4035 postcondition appearing after a subprogram declaration, the
4036 formal arguments of the subprogram are visible, and can be
4037 referenced in the postcondition expressions.
4038
4039 The postconditions are collected and automatically tested just
4040 before any return (implicit or explicit) in the subprogram body.
4041 A postcondition is only recognized if postconditions are active
4042 at the time the pragma is encountered. The compiler switch @option{gnata}
4043 turns on all postconditions by default, and pragma @code{Check_Policy}
4044 with an identifier of @code{Postcondition} can also be used to
4045 control whether postconditions are active.
4046
4047 The general approach is that postconditions are placed in the spec
4048 if they represent functional aspects which make sense to the client.
4049 For example we might have:
4050
4051 @smallexample @c ada
4052 function Direction return Integer;
4053 pragma Postcondition
4054 (Direction'Result = +1
4055 or else
4056 Direction'Result = -1);
4057 @end smallexample
4058
4059 @noindent
4060 which serves to document that the result must be +1 or -1, and
4061 will test that this is the case at run time if postcondition
4062 checking is active.
4063
4064 Postconditions within the subprogram body can be used to
4065 check that some internal aspect of the implementation,
4066 not visible to the client, is operating as expected.
4067 For instance if a square root routine keeps an internal
4068 counter of the number of times it is called, then we
4069 might have the following postcondition:
4070
4071 @smallexample @c ada
4072 Sqrt_Calls : Natural := 0;
4073
4074 function Sqrt (Arg : Float) return Float is
4075 pragma Postcondition
4076 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4077 ...
4078 end Sqrt
4079 @end smallexample
4080
4081 @noindent
4082 As this example, shows, the use of the @code{Old} attribute
4083 is often useful in postconditions to refer to the state on
4084 entry to the subprogram.
4085
4086 Note that postconditions are only checked on normal returns
4087 from the subprogram. If an abnormal return results from
4088 raising an exception, then the postconditions are not checked.
4089
4090 If a postcondition fails, then the exception
4091 @code{System.Assertions.Assert_Failure} is raised. If
4092 a message argument was supplied, then the given string
4093 will be used as the exception message. If no message
4094 argument was supplied, then the default message has
4095 the form "Postcondition failed at file:line". The
4096 exception is raised in the context of the subprogram
4097 body, so it is possible to catch postcondition failures
4098 within the subprogram body itself.
4099
4100 Within a package spec, normal visibility rules
4101 in Ada would prevent forward references within a
4102 postcondition pragma to functions defined later in
4103 the same package. This would introduce undesirable
4104 ordering constraints. To avoid this problem, all
4105 postcondition pragmas are analyzed at the end of
4106 the package spec, allowing forward references.
4107
4108 The following example shows that this even allows
4109 mutually recursive postconditions as in:
4110
4111 @smallexample @c ada
4112 package Parity_Functions is
4113 function Odd (X : Natural) return Boolean;
4114 pragma Postcondition
4115 (Odd'Result =
4116 (x = 1
4117 or else
4118 (x /= 0 and then Even (X - 1))));
4119
4120 function Even (X : Natural) return Boolean;
4121 pragma Postcondition
4122 (Even'Result =
4123 (x = 0
4124 or else
4125 (x /= 1 and then Odd (X - 1))));
4126
4127 end Parity_Functions;
4128 @end smallexample
4129
4130 @noindent
4131 There are no restrictions on the complexity or form of
4132 conditions used within @code{Postcondition} pragmas.
4133 The following example shows that it is even possible
4134 to verify performance behavior.
4135
4136 @smallexample @c ada
4137 package Sort is
4138
4139 Performance : constant Float;
4140 -- Performance constant set by implementation
4141 -- to match target architecture behavior.
4142
4143 procedure Treesort (Arg : String);
4144 -- Sorts characters of argument using N*logN sort
4145 pragma Postcondition
4146 (Float (Clock - Clock'Old) <=
4147 Float (Arg'Length) *
4148 log (Float (Arg'Length)) *
4149 Performance);
4150 end Sort;
4151 @end smallexample
4152
4153 @noindent
4154 Note: postcondition pragmas associated with subprograms that are
4155 marked as Inline_Always, or those marked as Inline with front-end
4156 inlining (-gnatN option set) are accepted and legality-checked
4157 by the compiler, but are ignored at run-time even if postcondition
4158 checking is enabled.
4159
4160 @node Pragma Precondition
4161 @unnumberedsec Pragma Precondition
4162 @cindex Preconditions
4163 @cindex Checks, preconditions
4164 @findex Preconditions
4165 @noindent
4166 Syntax:
4167
4168 @smallexample @c ada
4169 pragma Precondition (
4170 [Check =>] Boolean_Expression
4171 [,[Message =>] String_Expression]);
4172 @end smallexample
4173
4174 @noindent
4175 The @code{Precondition} pragma is similar to @code{Postcondition}
4176 except that the corresponding checks take place immediately upon
4177 entry to the subprogram, and if a precondition fails, the exception
4178 is raised in the context of the caller, and the attribute 'Result
4179 cannot be used within the precondition expression.
4180
4181 Otherwise, the placement and visibility rules are identical to those
4182 described for postconditions. The following is an example of use
4183 within a package spec:
4184
4185 @smallexample @c ada
4186 package Math_Functions is
4187 ...
4188 function Sqrt (Arg : Float) return Float;
4189 pragma Precondition (Arg >= 0.0)
4190 ...
4191 end Math_Functions;
4192 @end smallexample
4193
4194 @noindent
4195 @code{Precondition} pragmas may appear either immediately following the
4196 (separate) declaration of a subprogram, or at the start of the
4197 declarations of a subprogram body. Only other pragmas may intervene
4198 (that is appear between the subprogram declaration and its
4199 postconditions, or appear before the postcondition in the
4200 declaration sequence in a subprogram body).
4201
4202 Note: postcondition pragmas associated with subprograms that are
4203 marked as Inline_Always, or those marked as Inline with front-end
4204 inlining (-gnatN option set) are accepted and legality-checked
4205 by the compiler, but are ignored at run-time even if postcondition
4206 checking is enabled.
4207
4208 @node Pragma Profile (Ravenscar)
4209 @unnumberedsec Pragma Profile (Ravenscar)
4210 @findex Ravenscar
4211 @noindent
4212 Syntax:
4213
4214 @smallexample @c ada
4215 pragma Profile (Ravenscar);
4216 @end smallexample
4217
4218 @noindent
4219 A configuration pragma that establishes the following set of configuration
4220 pragmas:
4221
4222 @table @code
4223 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4224 [RM D.2.2] Tasks are dispatched following a preemptive
4225 priority-ordered scheduling policy.
4226
4227 @item Locking_Policy (Ceiling_Locking)
4228 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4229 the ceiling priority of the corresponding protected object.
4230 @c
4231 @c @item Detect_Blocking
4232 @c This pragma forces the detection of potentially blocking operations within a
4233 @c protected operation, and to raise Program_Error if that happens.
4234 @end table
4235 @noindent
4236
4237 plus the following set of restrictions:
4238
4239 @table @code
4240 @item Max_Entry_Queue_Length => 1
4241 Defines the maximum number of calls that are queued on a (protected) entry.
4242 Note that this restrictions is checked at run time. Violation of this
4243 restriction results in the raising of Program_Error exception at the point of
4244 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4245 always 1 and hence no task can be queued on a protected entry.
4246
4247 @item Max_Protected_Entries => 1
4248 [RM D.7] Specifies the maximum number of entries per protected type. The
4249 bounds of every entry family of a protected unit shall be static, or shall be
4250 defined by a discriminant of a subtype whose corresponding bound is static.
4251 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4252
4253 @item Max_Task_Entries => 0
4254 [RM D.7] Specifies the maximum number of entries
4255 per task. The bounds of every entry family
4256 of a task unit shall be static, or shall be
4257 defined by a discriminant of a subtype whose
4258 corresponding bound is static. A value of zero
4259 indicates that no rendezvous are possible. For
4260 the Profile (Ravenscar), the value of Max_Task_Entries is always
4261 0 (zero).
4262
4263 @item No_Abort_Statements
4264 [RM D.7] There are no abort_statements, and there are
4265 no calls to Task_Identification.Abort_Task.
4266
4267 @item No_Dynamic_Attachment
4268 There is no call to any of the operations defined in package Ada.Interrupts
4269 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4270 Detach_Handler, and Reference).
4271
4272 @item No_Dynamic_Priorities
4273 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4274
4275 @item No_Implicit_Heap_Allocations
4276 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4277
4278 @item No_Local_Protected_Objects
4279 Protected objects and access types that designate
4280 such objects shall be declared only at library level.
4281
4282 @item No_Local_Timing_Events
4283 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4284 declared at the library level.
4285
4286 @item No_Protected_Type_Allocators
4287 There are no allocators for protected types or
4288 types containing protected subcomponents.
4289
4290 @item No_Relative_Delay
4291 There are no delay_relative statements.
4292
4293 @item No_Requeue_Statements
4294 Requeue statements are not allowed.
4295
4296 @item No_Select_Statements
4297 There are no select_statements.
4298
4299 @item No_Specific_Termination_Handlers
4300 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4301 or to Ada.Task_Termination.Specific_Handler.
4302
4303 @item No_Task_Allocators
4304 [RM D.7] There are no allocators for task types
4305 or types containing task subcomponents.
4306
4307 @item No_Task_Hierarchy
4308 [RM D.7] All (non-environment) tasks depend
4309 directly on the environment task of the partition.
4310
4311 @item No_Task_Termination
4312 Tasks which terminate are erroneous.
4313
4314 @item Simple_Barriers
4315 Entry barrier condition expressions shall be either static
4316 boolean expressions or boolean objects which are declared in
4317 the protected type which contains the entry.
4318 @end table
4319 @noindent
4320
4321 The Ravenscar profile also includes the following restrictions that specify
4322 that there are no semantic dependences on the corresponding predefined
4323 packages:
4324
4325 @table @code
4326 @item No_Dependence => Ada.Asynchronous_Task_Control
4327 @item No_Dependence => Ada.Calendar
4328 @item No_Dependence => Ada.Execution_Time.Group_Budget
4329 @item No_Dependence => Ada.Execution_Time.Timers
4330 @item No_Dependence => Ada.Task_Attributes
4331 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4332 @end table
4333
4334 @noindent
4335
4336 This set of configuration pragmas and restrictions correspond to the
4337 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4338 published by the @cite{International Real-Time Ada Workshop}, 1997,
4339 and whose most recent description is available at
4340 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4341
4342 The original definition of the profile was revised at subsequent IRTAW
4343 meetings. It has been included in the ISO
4344 @cite{Guide for the Use of the Ada Programming Language in High
4345 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4346 the next revision of the standard. The formal definition given by
4347 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4348 AI-305) available at
4349 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4350 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4351
4352 The above set is a superset of the restrictions provided by pragma
4353 @code{Profile (Restricted)}, it includes six additional restrictions
4354 (@code{Simple_Barriers}, @code{No_Select_Statements},
4355 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4356 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4357 that pragma @code{Profile (Ravenscar)}, like the pragma
4358 @code{Profile (Restricted)},
4359 automatically causes the use of a simplified,
4360 more efficient version of the tasking run-time system.
4361
4362 @node Pragma Profile (Restricted)
4363 @unnumberedsec Pragma Profile (Restricted)
4364 @findex Restricted Run Time
4365 @noindent
4366 Syntax:
4367
4368 @smallexample @c ada
4369 pragma Profile (Restricted);
4370 @end smallexample
4371
4372 @noindent
4373 A configuration pragma that establishes the following set of restrictions:
4374
4375 @itemize @bullet
4376 @item No_Abort_Statements
4377 @item No_Entry_Queue
4378 @item No_Task_Hierarchy
4379 @item No_Task_Allocators
4380 @item No_Dynamic_Priorities
4381 @item No_Terminate_Alternatives
4382 @item No_Dynamic_Attachment
4383 @item No_Protected_Type_Allocators
4384 @item No_Local_Protected_Objects
4385 @item No_Requeue_Statements
4386 @item No_Task_Attributes_Package
4387 @item Max_Asynchronous_Select_Nesting = 0
4388 @item Max_Task_Entries = 0
4389 @item Max_Protected_Entries = 1
4390 @item Max_Select_Alternatives = 0
4391 @end itemize
4392
4393 @noindent
4394 This set of restrictions causes the automatic selection of a simplified
4395 version of the run time that provides improved performance for the
4396 limited set of tasking functionality permitted by this set of restrictions.
4397
4398 @node Pragma Psect_Object
4399 @unnumberedsec Pragma Psect_Object
4400 @findex Psect_Object
4401 @noindent
4402 Syntax:
4403
4404 @smallexample @c ada
4405 pragma Psect_Object (
4406 [Internal =>] LOCAL_NAME,
4407 [, [External =>] EXTERNAL_SYMBOL]
4408 [, [Size =>] EXTERNAL_SYMBOL]);
4409
4410 EXTERNAL_SYMBOL ::=
4411 IDENTIFIER
4412 | static_string_EXPRESSION
4413 @end smallexample
4414
4415 @noindent
4416 This pragma is identical in effect to pragma @code{Common_Object}.
4417
4418 @node Pragma Pure_Function
4419 @unnumberedsec Pragma Pure_Function
4420 @findex Pure_Function
4421 @noindent
4422 Syntax:
4423
4424 @smallexample @c ada
4425 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4426 @end smallexample
4427
4428 @noindent
4429 This pragma appears in the same declarative part as a function
4430 declaration (or a set of function declarations if more than one
4431 overloaded declaration exists, in which case the pragma applies
4432 to all entities). It specifies that the function @code{Entity} is
4433 to be considered pure for the purposes of code generation. This means
4434 that the compiler can assume that there are no side effects, and
4435 in particular that two calls with identical arguments produce the
4436 same result. It also means that the function can be used in an
4437 address clause.
4438
4439 Note that, quite deliberately, there are no static checks to try
4440 to ensure that this promise is met, so @code{Pure_Function} can be used
4441 with functions that are conceptually pure, even if they do modify
4442 global variables. For example, a square root function that is
4443 instrumented to count the number of times it is called is still
4444 conceptually pure, and can still be optimized, even though it
4445 modifies a global variable (the count). Memo functions are another
4446 example (where a table of previous calls is kept and consulted to
4447 avoid re-computation).
4448
4449 Note also that the normal rules excluding optimization of subprograms
4450 in pure units (when parameter types are descended from System.Address,
4451 or when the full view of a parameter type is limited), do not apply
4452 for the Pure_Function case. If you explicitly specify Pure_Function,
4453 the compiler may optimize away calls with identical arguments, and
4454 if that results in unexpected behavior, the proper action is not to
4455 use the pragma for subprograms that are not (conceptually) pure.
4456
4457 @findex Pure
4458 Note: Most functions in a @code{Pure} package are automatically pure, and
4459 there is no need to use pragma @code{Pure_Function} for such functions. One
4460 exception is any function that has at least one formal of type
4461 @code{System.Address} or a type derived from it. Such functions are not
4462 considered pure by default, since the compiler assumes that the
4463 @code{Address} parameter may be functioning as a pointer and that the
4464 referenced data may change even if the address value does not.
4465 Similarly, imported functions are not considered to be pure by default,
4466 since there is no way of checking that they are in fact pure. The use
4467 of pragma @code{Pure_Function} for such a function will override these default
4468 assumption, and cause the compiler to treat a designated subprogram as pure
4469 in these cases.
4470
4471 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4472 applies to the underlying renamed function. This can be used to
4473 disambiguate cases of overloading where some but not all functions
4474 in a set of overloaded functions are to be designated as pure.
4475
4476 If pragma @code{Pure_Function} is applied to a library level function, the
4477 function is also considered pure from an optimization point of view, but the
4478 unit is not a Pure unit in the categorization sense. So for example, a function
4479 thus marked is free to @code{with} non-pure units.
4480
4481 @node Pragma Restriction_Warnings
4482 @unnumberedsec Pragma Restriction_Warnings
4483 @findex Restriction_Warnings
4484 @noindent
4485 Syntax:
4486
4487 @smallexample @c ada
4488 pragma Restriction_Warnings
4489 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4490 @end smallexample
4491
4492 @noindent
4493 This pragma allows a series of restriction identifiers to be
4494 specified (the list of allowed identifiers is the same as for
4495 pragma @code{Restrictions}). For each of these identifiers
4496 the compiler checks for violations of the restriction, but
4497 generates a warning message rather than an error message
4498 if the restriction is violated.
4499
4500 @node Pragma Shared
4501 @unnumberedsec Pragma Shared
4502 @findex Shared
4503
4504 @noindent
4505 This pragma is provided for compatibility with Ada 83. The syntax and
4506 semantics are identical to pragma Atomic.
4507
4508 @node Pragma Short_Circuit_And_Or
4509 @unnumberedsec Pragma Short_Circuit_And_Or
4510 @findex Short_Circuit_And_Or
4511
4512 @noindent
4513 This configuration pragma causes any occurrence of the AND operator applied to
4514 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4515 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4516 may be useful in the context of certification protocols requiring the use of
4517 short-circuited logical operators. If this configuration pragma occurs locally
4518 within the file being compiled, it applies only to the file being compiled.
4519 There is no requirement that all units in a partition use this option.
4520
4521 @node Pragma Short_Descriptors
4522 @unnumberedsec Pragma Short_Descriptors
4523 @findex Short_Descriptors
4524 @noindent
4525 Syntax:
4526
4527 @smallexample @c ada
4528 pragma Short_Descriptors
4529 @end smallexample
4530
4531 @noindent
4532 In VMS versions of the compiler, this configuration pragma causes all
4533 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4534 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4535 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4536 versions.
4537
4538 @node Pragma Source_File_Name
4539 @unnumberedsec Pragma Source_File_Name
4540 @findex Source_File_Name
4541 @noindent
4542 Syntax:
4543
4544 @smallexample @c ada
4545 pragma Source_File_Name (
4546 [Unit_Name =>] unit_NAME,
4547 Spec_File_Name => STRING_LITERAL,
4548 [Index => INTEGER_LITERAL]);
4549
4550 pragma Source_File_Name (
4551 [Unit_Name =>] unit_NAME,
4552 Body_File_Name => STRING_LITERAL,
4553 [Index => INTEGER_LITERAL]);
4554 @end smallexample
4555
4556 @noindent
4557 Use this to override the normal naming convention. It is a configuration
4558 pragma, and so has the usual applicability of configuration pragmas
4559 (i.e.@: it applies to either an entire partition, or to all units in a
4560 compilation, or to a single unit, depending on how it is used.
4561 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4562 the second argument is required, and indicates whether this is the file
4563 name for the spec or for the body.
4564
4565 The optional Index argument should be used when a file contains multiple
4566 units, and when you do not want to use @code{gnatchop} to separate then
4567 into multiple files (which is the recommended procedure to limit the
4568 number of recompilations that are needed when some sources change).
4569 For instance, if the source file @file{source.ada} contains
4570
4571 @smallexample @c ada
4572 package B is
4573 ...
4574 end B;
4575
4576 with B;
4577 procedure A is
4578 begin
4579 ..
4580 end A;
4581 @end smallexample
4582
4583 you could use the following configuration pragmas:
4584
4585 @smallexample @c ada
4586 pragma Source_File_Name
4587 (B, Spec_File_Name => "source.ada", Index => 1);
4588 pragma Source_File_Name
4589 (A, Body_File_Name => "source.ada", Index => 2);
4590 @end smallexample
4591
4592 Note that the @code{gnatname} utility can also be used to generate those
4593 configuration pragmas.
4594
4595 Another form of the @code{Source_File_Name} pragma allows
4596 the specification of patterns defining alternative file naming schemes
4597 to apply to all files.
4598
4599 @smallexample @c ada
4600 pragma Source_File_Name
4601 ( [Spec_File_Name =>] STRING_LITERAL
4602 [,[Casing =>] CASING_SPEC]
4603 [,[Dot_Replacement =>] STRING_LITERAL]);
4604
4605 pragma Source_File_Name
4606 ( [Body_File_Name =>] STRING_LITERAL
4607 [,[Casing =>] CASING_SPEC]
4608 [,[Dot_Replacement =>] STRING_LITERAL]);
4609
4610 pragma Source_File_Name
4611 ( [Subunit_File_Name =>] STRING_LITERAL
4612 [,[Casing =>] CASING_SPEC]
4613 [,[Dot_Replacement =>] STRING_LITERAL]);
4614
4615 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4616 @end smallexample
4617
4618 @noindent
4619 The first argument is a pattern that contains a single asterisk indicating
4620 the point at which the unit name is to be inserted in the pattern string
4621 to form the file name. The second argument is optional. If present it
4622 specifies the casing of the unit name in the resulting file name string.
4623 The default is lower case. Finally the third argument allows for systematic
4624 replacement of any dots in the unit name by the specified string literal.
4625
4626 Note that Source_File_Name pragmas should not be used if you are using
4627 project files. The reason for this rule is that the project manager is not
4628 aware of these pragmas, and so other tools that use the projet file would not
4629 be aware of the intended naming conventions. If you are using project files,
4630 file naming is controlled by Source_File_Name_Project pragmas, which are
4631 usually supplied automatically by the project manager. A pragma
4632 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4633
4634 For more details on the use of the @code{Source_File_Name} pragma,
4635 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4636 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4637 User's Guide}.
4638
4639 @node Pragma Source_File_Name_Project
4640 @unnumberedsec Pragma Source_File_Name_Project
4641 @findex Source_File_Name_Project
4642 @noindent
4643
4644 This pragma has the same syntax and semantics as pragma Source_File_Name.
4645 It is only allowed as a stand alone configuration pragma.
4646 It cannot appear after a @ref{Pragma Source_File_Name}, and
4647 most importantly, once pragma Source_File_Name_Project appears,
4648 no further Source_File_Name pragmas are allowed.
4649
4650 The intention is that Source_File_Name_Project pragmas are always
4651 generated by the Project Manager in a manner consistent with the naming
4652 specified in a project file, and when naming is controlled in this manner,
4653 it is not permissible to attempt to modify this naming scheme using
4654 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4655 known to the project manager).
4656
4657 @node Pragma Source_Reference
4658 @unnumberedsec Pragma Source_Reference
4659 @findex Source_Reference
4660 @noindent
4661 Syntax:
4662
4663 @smallexample @c ada
4664 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4665 @end smallexample
4666
4667 @noindent
4668 This pragma must appear as the first line of a source file.
4669 @var{integer_literal} is the logical line number of the line following
4670 the pragma line (for use in error messages and debugging
4671 information). @var{string_literal} is a static string constant that
4672 specifies the file name to be used in error messages and debugging
4673 information. This is most notably used for the output of @code{gnatchop}
4674 with the @option{-r} switch, to make sure that the original unchopped
4675 source file is the one referred to.
4676
4677 The second argument must be a string literal, it cannot be a static
4678 string expression other than a string literal. This is because its value
4679 is needed for error messages issued by all phases of the compiler.
4680
4681 @node Pragma Static_Elaboration_Desired
4682 @unnumberedsec Pragma Static_Elaboration_Desired
4683 @findex Static_Elaboration_Desired
4684 @noindent
4685 Syntax:
4686
4687 @smallexample @c ada
4688 pragma Static_Elaboration_Desired;
4689 @end smallexample
4690
4691 @noindent
4692 This pragma is used to indicate that the compiler should attempt to initialize
4693 statically the objects declared in the library unit to which the pragma applies,
4694 when these objects are initialized (explicitly or implicitly) by an aggregate.
4695 In the absence of this pragma, aggregates in object declarations are expanded
4696 into assignments and loops, even when the aggregate components are static
4697 constants. When the aggregate is present the compiler builds a static expression
4698 that requires no run-time code, so that the initialized object can be placed in
4699 read-only data space. If the components are not static, or the aggregate has
4700 more that 100 components, the compiler emits a warning that the pragma cannot
4701 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4702 construction of larger aggregates with static components that include an others
4703 choice.)
4704
4705 @node Pragma Stream_Convert
4706 @unnumberedsec Pragma Stream_Convert
4707 @findex Stream_Convert
4708 @noindent
4709 Syntax:
4710
4711 @smallexample @c ada
4712 pragma Stream_Convert (
4713 [Entity =>] type_LOCAL_NAME,
4714 [Read =>] function_NAME,
4715 [Write =>] function_NAME);
4716 @end smallexample
4717
4718 @noindent
4719 This pragma provides an efficient way of providing stream functions for
4720 types defined in packages. Not only is it simpler to use than declaring
4721 the necessary functions with attribute representation clauses, but more
4722 significantly, it allows the declaration to made in such a way that the
4723 stream packages are not loaded unless they are needed. The use of
4724 the Stream_Convert pragma adds no overhead at all, unless the stream
4725 attributes are actually used on the designated type.
4726
4727 The first argument specifies the type for which stream functions are
4728 provided. The second parameter provides a function used to read values
4729 of this type. It must name a function whose argument type may be any
4730 subtype, and whose returned type must be the type given as the first
4731 argument to the pragma.
4732
4733 The meaning of the @var{Read}
4734 parameter is that if a stream attribute directly
4735 or indirectly specifies reading of the type given as the first parameter,
4736 then a value of the type given as the argument to the Read function is
4737 read from the stream, and then the Read function is used to convert this
4738 to the required target type.
4739
4740 Similarly the @var{Write} parameter specifies how to treat write attributes
4741 that directly or indirectly apply to the type given as the first parameter.
4742 It must have an input parameter of the type specified by the first parameter,
4743 and the return type must be the same as the input type of the Read function.
4744 The effect is to first call the Write function to convert to the given stream
4745 type, and then write the result type to the stream.
4746
4747 The Read and Write functions must not be overloaded subprograms. If necessary
4748 renamings can be supplied to meet this requirement.
4749 The usage of this attribute is best illustrated by a simple example, taken
4750 from the GNAT implementation of package Ada.Strings.Unbounded:
4751
4752 @smallexample @c ada
4753 function To_Unbounded (S : String)
4754 return Unbounded_String
4755 renames To_Unbounded_String;
4756
4757 pragma Stream_Convert
4758 (Unbounded_String, To_Unbounded, To_String);
4759 @end smallexample
4760
4761 @noindent
4762 The specifications of the referenced functions, as given in the Ada
4763 Reference Manual are:
4764
4765 @smallexample @c ada
4766 function To_Unbounded_String (Source : String)
4767 return Unbounded_String;
4768
4769 function To_String (Source : Unbounded_String)
4770 return String;
4771 @end smallexample
4772
4773 @noindent
4774 The effect is that if the value of an unbounded string is written to a stream,
4775 then the representation of the item in the stream is in the same format that
4776 would be used for @code{Standard.String'Output}, and this same representation
4777 is expected when a value of this type is read from the stream. Note that the
4778 value written always includes the bounds, even for Unbounded_String'Write,
4779 since Unbounded_String is not an array type.
4780
4781 @node Pragma Style_Checks
4782 @unnumberedsec Pragma Style_Checks
4783 @findex Style_Checks
4784 @noindent
4785 Syntax:
4786
4787 @smallexample @c ada
4788 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4789 On | Off [, LOCAL_NAME]);
4790 @end smallexample
4791
4792 @noindent
4793 This pragma is used in conjunction with compiler switches to control the
4794 built in style checking provided by GNAT@. The compiler switches, if set,
4795 provide an initial setting for the switches, and this pragma may be used
4796 to modify these settings, or the settings may be provided entirely by
4797 the use of the pragma. This pragma can be used anywhere that a pragma
4798 is legal, including use as a configuration pragma (including use in
4799 the @file{gnat.adc} file).
4800
4801 The form with a string literal specifies which style options are to be
4802 activated. These are additive, so they apply in addition to any previously
4803 set style check options. The codes for the options are the same as those
4804 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4805 For example the following two methods can be used to enable
4806 layout checking:
4807
4808 @itemize @bullet
4809 @item
4810 @smallexample @c ada
4811 pragma Style_Checks ("l");
4812 @end smallexample
4813
4814 @item
4815 @smallexample
4816 gcc -c -gnatyl @dots{}
4817 @end smallexample
4818 @end itemize
4819
4820 @noindent
4821 The form ALL_CHECKS activates all standard checks (its use is equivalent
4822 to the use of the @code{gnaty} switch with no options. @xref{Top,
4823 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4824 @value{EDITION} User's Guide}, for details.)
4825
4826 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4827 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4828 options (i.e. equivalent to -gnatyg).
4829
4830 The forms with @code{Off} and @code{On}
4831 can be used to temporarily disable style checks
4832 as shown in the following example:
4833
4834 @smallexample @c ada
4835 @iftex
4836 @leftskip=0cm
4837 @end iftex
4838 pragma Style_Checks ("k"); -- requires keywords in lower case
4839 pragma Style_Checks (Off); -- turn off style checks
4840 NULL; -- this will not generate an error message
4841 pragma Style_Checks (On); -- turn style checks back on
4842 NULL; -- this will generate an error message
4843 @end smallexample
4844
4845 @noindent
4846 Finally the two argument form is allowed only if the first argument is
4847 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4848 for the specified entity, as shown in the following example:
4849
4850 @smallexample @c ada
4851 @iftex
4852 @leftskip=0cm
4853 @end iftex
4854 pragma Style_Checks ("r"); -- require consistency of identifier casing
4855 Arg : Integer;
4856 Rf1 : Integer := ARG; -- incorrect, wrong case
4857 pragma Style_Checks (Off, Arg);
4858 Rf2 : Integer := ARG; -- OK, no error
4859 @end smallexample
4860
4861 @node Pragma Subtitle
4862 @unnumberedsec Pragma Subtitle
4863 @findex Subtitle
4864 @noindent
4865 Syntax:
4866
4867 @smallexample @c ada
4868 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4869 @end smallexample
4870
4871 @noindent
4872 This pragma is recognized for compatibility with other Ada compilers
4873 but is ignored by GNAT@.
4874
4875 @node Pragma Suppress
4876 @unnumberedsec Pragma Suppress
4877 @findex Suppress
4878 @noindent
4879 Syntax:
4880
4881 @smallexample @c ada
4882 pragma Suppress (Identifier [, [On =>] Name]);
4883 @end smallexample
4884
4885 @noindent
4886 This is a standard pragma, and supports all the check names required in
4887 the RM. It is included here because GNAT recognizes one additional check
4888 name: @code{Alignment_Check} which can be used to suppress alignment checks
4889 on addresses used in address clauses. Such checks can also be suppressed
4890 by suppressing range checks, but the specific use of @code{Alignment_Check}
4891 allows suppression of alignment checks without suppressing other range checks.
4892
4893 Note that pragma Suppress gives the compiler permission to omit
4894 checks, but does not require the compiler to omit checks. The compiler
4895 will generate checks if they are essentially free, even when they are
4896 suppressed. In particular, if the compiler can prove that a certain
4897 check will necessarily fail, it will generate code to do an
4898 unconditional ``raise'', even if checks are suppressed. The compiler
4899 warns in this case.
4900
4901 Of course, run-time checks are omitted whenever the compiler can prove
4902 that they will not fail, whether or not checks are suppressed.
4903
4904 @node Pragma Suppress_All
4905 @unnumberedsec Pragma Suppress_All
4906 @findex Suppress_All
4907 @noindent
4908 Syntax:
4909
4910 @smallexample @c ada
4911 pragma Suppress_All;
4912 @end smallexample
4913
4914 @noindent
4915 This pragma can appear anywhere within a unit.
4916 The effect is to apply @code{Suppress (All_Checks)} to the unit
4917 in which it appears. This pragma is implemented for compatibility with DEC
4918 Ada 83 usage where it appears at the end of a unit, and for compatibility
4919 with Rational Ada, where it appears as a program unit pragma.
4920 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4921 as a normal configuration pragma is the preferred usage in GNAT@.
4922
4923 @node Pragma Suppress_Exception_Locations
4924 @unnumberedsec Pragma Suppress_Exception_Locations
4925 @findex Suppress_Exception_Locations
4926 @noindent
4927 Syntax:
4928
4929 @smallexample @c ada
4930 pragma Suppress_Exception_Locations;
4931 @end smallexample
4932
4933 @noindent
4934 In normal mode, a raise statement for an exception by default generates
4935 an exception message giving the file name and line number for the location
4936 of the raise. This is useful for debugging and logging purposes, but this
4937 entails extra space for the strings for the messages. The configuration
4938 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4939 generation of these strings, with the result that space is saved, but the
4940 exception message for such raises is null. This configuration pragma may
4941 appear in a global configuration pragma file, or in a specific unit as
4942 usual. It is not required that this pragma be used consistently within
4943 a partition, so it is fine to have some units within a partition compiled
4944 with this pragma and others compiled in normal mode without it.
4945
4946 @node Pragma Suppress_Initialization
4947 @unnumberedsec Pragma Suppress_Initialization
4948 @findex Suppress_Initialization
4949 @cindex Suppressing initialization
4950 @cindex Initialization, suppression of
4951 @noindent
4952 Syntax:
4953
4954 @smallexample @c ada
4955 pragma Suppress_Initialization ([Entity =>] type_Name);
4956 @end smallexample
4957
4958 @noindent
4959 This pragma suppresses any implicit or explicit initialization
4960 associated with the given type name for all variables of this type,
4961 including initialization resulting from the use of pragmas
4962 Normalize_Scalars or Initialize_Scalars.
4963
4964 This is considered a representation item, so it cannot be given after
4965 the type is frozen. It applies to all subsequent object declarations,
4966 and also any allocator that creates objects of the type.
4967
4968 If the pragma is given for the first subtype, then it is considered
4969 to apply to the base type and all its subtypes. If the pragma is given
4970 for other than a first subtype, then it applies only to the given subtype.
4971 The pragma may not be given after the type is frozen.
4972
4973 @node Pragma Task_Info
4974 @unnumberedsec Pragma Task_Info
4975 @findex Task_Info
4976 @noindent
4977 Syntax
4978
4979 @smallexample @c ada
4980 pragma Task_Info (EXPRESSION);
4981 @end smallexample
4982
4983 @noindent
4984 This pragma appears within a task definition (like pragma
4985 @code{Priority}) and applies to the task in which it appears. The
4986 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4987 The @code{Task_Info} pragma provides system dependent control over
4988 aspects of tasking implementation, for example, the ability to map
4989 tasks to specific processors. For details on the facilities available
4990 for the version of GNAT that you are using, see the documentation
4991 in the spec of package System.Task_Info in the runtime
4992 library.
4993
4994 @node Pragma Task_Name
4995 @unnumberedsec Pragma Task_Name
4996 @findex Task_Name
4997 @noindent
4998 Syntax
4999
5000 @smallexample @c ada
5001 pragma Task_Name (string_EXPRESSION);
5002 @end smallexample
5003
5004 @noindent
5005 This pragma appears within a task definition (like pragma
5006 @code{Priority}) and applies to the task in which it appears. The
5007 argument must be of type String, and provides a name to be used for
5008 the task instance when the task is created. Note that this expression
5009 is not required to be static, and in particular, it can contain
5010 references to task discriminants. This facility can be used to
5011 provide different names for different tasks as they are created,
5012 as illustrated in the example below.
5013
5014 The task name is recorded internally in the run-time structures
5015 and is accessible to tools like the debugger. In addition the
5016 routine @code{Ada.Task_Identification.Image} will return this
5017 string, with a unique task address appended.
5018
5019 @smallexample @c ada
5020 -- Example of the use of pragma Task_Name
5021
5022 with Ada.Task_Identification;
5023 use Ada.Task_Identification;
5024 with Text_IO; use Text_IO;
5025 procedure t3 is
5026
5027 type Astring is access String;
5028
5029 task type Task_Typ (Name : access String) is
5030 pragma Task_Name (Name.all);
5031 end Task_Typ;
5032
5033 task body Task_Typ is
5034 Nam : constant String := Image (Current_Task);
5035 begin
5036 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5037 end Task_Typ;
5038
5039 type Ptr_Task is access Task_Typ;
5040 Task_Var : Ptr_Task;
5041
5042 begin
5043 Task_Var :=
5044 new Task_Typ (new String'("This is task 1"));
5045 Task_Var :=
5046 new Task_Typ (new String'("This is task 2"));
5047 end;
5048 @end smallexample
5049
5050 @node Pragma Task_Storage
5051 @unnumberedsec Pragma Task_Storage
5052 @findex Task_Storage
5053 Syntax:
5054
5055 @smallexample @c ada
5056 pragma Task_Storage (
5057 [Task_Type =>] LOCAL_NAME,
5058 [Top_Guard =>] static_integer_EXPRESSION);
5059 @end smallexample
5060
5061 @noindent
5062 This pragma specifies the length of the guard area for tasks. The guard
5063 area is an additional storage area allocated to a task. A value of zero
5064 means that either no guard area is created or a minimal guard area is
5065 created, depending on the target. This pragma can appear anywhere a
5066 @code{Storage_Size} attribute definition clause is allowed for a task
5067 type.
5068
5069 @node Pragma Test_Case
5070 @unnumberedsec Pragma Test_Case
5071 @cindex Test cases
5072 @findex Test_Case
5073 @noindent
5074 Syntax:
5075
5076 @smallexample @c ada
5077 pragma Test_Case (
5078 [Name =>] static_string_Expression
5079 ,[Mode =>] (Nominal | Robustness)
5080 [, Requires => Boolean_Expression]
5081 [, Ensures => Boolean_Expression]);
5082 @end smallexample
5083
5084 @noindent
5085 The @code{Test_Case} pragma allows defining fine-grain specifications
5086 for use by testing and verification tools. The compiler checks its
5087 validity but the presence of pragma @code{Test_Case} does not lead to
5088 any modification of the code generated by the compiler.
5089
5090 @code{Test_Case} pragmas may only appear immediately following the
5091 (separate) declaration of a subprogram in a package declaration, inside
5092 a package spec unit. Only other pragmas may intervene (that is appear
5093 between the subprogram declaration and a test case).
5094
5095 The compiler checks that boolean expressions given in @code{Requires} and
5096 @code{Ensures} are valid, where the rules for @code{Requires} are the
5097 same as the rule for an expression in @code{Precondition} and the rules
5098 for @code{Ensures} are the same as the rule for an expression in
5099 @code{Postcondition}. In particular, attributes @code{'Old} and
5100 @code{'Result} can only be used within the @code{Ensures}
5101 expression. The following is an example of use within a package spec:
5102
5103 @smallexample @c ada
5104 package Math_Functions is
5105 ...
5106 function Sqrt (Arg : Float) return Float;
5107 pragma Test_Case (Name => "Test 1",
5108 Mode => Nominal,
5109 Requires => Arg < 100,
5110 Ensures => Sqrt'Result < 10);
5111 ...
5112 end Math_Functions;
5113 @end smallexample
5114
5115 @noindent
5116 The meaning of a test case is that, if the associated subprogram is
5117 executed in a context where @code{Requires} holds, then @code{Ensures}
5118 should hold when the subprogram returns. Mode @code{Nominal} indicates
5119 that the input context should satisfy the precondition of the
5120 subprogram, and the output context should then satisfy its
5121 postcondition. More @code{Robustness} indicates that the pre- and
5122 postcondition of the subprogram should be ignored for this test case.
5123
5124 @node Pragma Thread_Local_Storage
5125 @unnumberedsec Pragma Thread_Local_Storage
5126 @findex Thread_Local_Storage
5127 @cindex Task specific storage
5128 @cindex TLS (Thread Local Storage)
5129 Syntax:
5130
5131 @smallexample @c ada
5132 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5133 @end smallexample
5134
5135 @noindent
5136 This pragma specifies that the specified entity, which must be
5137 a variable declared in a library level package, is to be marked as
5138 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5139 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5140 (and hence each Ada task) to see a distinct copy of the variable.
5141
5142 The variable may not have default initialization, and if there is
5143 an explicit initialization, it must be either @code{null} for an
5144 access variable, or a static expression for a scalar variable.
5145 This provides a low level mechanism similar to that provided by
5146 the @code{Ada.Task_Attributes} package, but much more efficient
5147 and is also useful in writing interface code that will interact
5148 with foreign threads.
5149
5150 If this pragma is used on a system where @code{TLS} is not supported,
5151 then an error message will be generated and the program will be rejected.
5152
5153 @node Pragma Time_Slice
5154 @unnumberedsec Pragma Time_Slice
5155 @findex Time_Slice
5156 @noindent
5157 Syntax:
5158
5159 @smallexample @c ada
5160 pragma Time_Slice (static_duration_EXPRESSION);
5161 @end smallexample
5162
5163 @noindent
5164 For implementations of GNAT on operating systems where it is possible
5165 to supply a time slice value, this pragma may be used for this purpose.
5166 It is ignored if it is used in a system that does not allow this control,
5167 or if it appears in other than the main program unit.
5168 @cindex OpenVMS
5169 Note that the effect of this pragma is identical to the effect of the
5170 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5171
5172 @node Pragma Title
5173 @unnumberedsec Pragma Title
5174 @findex Title
5175 @noindent
5176 Syntax:
5177
5178 @smallexample @c ada
5179 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5180
5181 TITLING_OPTION ::=
5182 [Title =>] STRING_LITERAL,
5183 | [Subtitle =>] STRING_LITERAL
5184 @end smallexample
5185
5186 @noindent
5187 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5188 pragma used in DEC Ada 83 implementations to provide a title and/or
5189 subtitle for the program listing. The program listing generated by GNAT
5190 does not have titles or subtitles.
5191
5192 Unlike other pragmas, the full flexibility of named notation is allowed
5193 for this pragma, i.e.@: the parameters may be given in any order if named
5194 notation is used, and named and positional notation can be mixed
5195 following the normal rules for procedure calls in Ada.
5196
5197 @node Pragma Unchecked_Union
5198 @unnumberedsec Pragma Unchecked_Union
5199 @cindex Unions in C
5200 @findex Unchecked_Union
5201 @noindent
5202 Syntax:
5203
5204 @smallexample @c ada
5205 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5206 @end smallexample
5207
5208 @noindent
5209 This pragma is used to specify a representation of a record type that is
5210 equivalent to a C union. It was introduced as a GNAT implementation defined
5211 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5212 pragma, making it language defined, and GNAT fully implements this extended
5213 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5214 details, consult the Ada 2005 Reference Manual, section B.3.3.
5215
5216 @node Pragma Unimplemented_Unit
5217 @unnumberedsec Pragma Unimplemented_Unit
5218 @findex Unimplemented_Unit
5219 @noindent
5220 Syntax:
5221
5222 @smallexample @c ada
5223 pragma Unimplemented_Unit;
5224 @end smallexample
5225
5226 @noindent
5227 If this pragma occurs in a unit that is processed by the compiler, GNAT
5228 aborts with the message @samp{@var{xxx} not implemented}, where
5229 @var{xxx} is the name of the current compilation unit. This pragma is
5230 intended to allow the compiler to handle unimplemented library units in
5231 a clean manner.
5232
5233 The abort only happens if code is being generated. Thus you can use
5234 specs of unimplemented packages in syntax or semantic checking mode.
5235
5236 @node Pragma Universal_Aliasing
5237 @unnumberedsec Pragma Universal_Aliasing
5238 @findex Universal_Aliasing
5239 @noindent
5240 Syntax:
5241
5242 @smallexample @c ada
5243 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5244 @end smallexample
5245
5246 @noindent
5247 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5248 declarative part. The effect is to inhibit strict type-based aliasing
5249 optimization for the given type. In other words, the effect is as though
5250 access types designating this type were subject to pragma No_Strict_Aliasing.
5251 For a detailed description of the strict aliasing optimization, and the
5252 situations in which it must be suppressed, @xref{Optimization and Strict
5253 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5254
5255 @node Pragma Universal_Data
5256 @unnumberedsec Pragma Universal_Data
5257 @findex Universal_Data
5258 @noindent
5259 Syntax:
5260
5261 @smallexample @c ada
5262 pragma Universal_Data [(library_unit_Name)];
5263 @end smallexample
5264
5265 @noindent
5266 This pragma is supported only for the AAMP target and is ignored for
5267 other targets. The pragma specifies that all library-level objects
5268 (Counter 0 data) associated with the library unit are to be accessed
5269 and updated using universal addressing (24-bit addresses for AAMP5)
5270 rather than the default of 16-bit Data Environment (DENV) addressing.
5271 Use of this pragma will generally result in less efficient code for
5272 references to global data associated with the library unit, but
5273 allows such data to be located anywhere in memory. This pragma is
5274 a library unit pragma, but can also be used as a configuration pragma
5275 (including use in the @file{gnat.adc} file). The functionality
5276 of this pragma is also available by applying the -univ switch on the
5277 compilations of units where universal addressing of the data is desired.
5278
5279 @node Pragma Unmodified
5280 @unnumberedsec Pragma Unmodified
5281 @findex Unmodified
5282 @cindex Warnings, unmodified
5283 @noindent
5284 Syntax:
5285
5286 @smallexample @c ada
5287 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5288 @end smallexample
5289
5290 @noindent
5291 This pragma signals that the assignable entities (variables,
5292 @code{out} parameters, @code{in out} parameters) whose names are listed are
5293 deliberately not assigned in the current source unit. This
5294 suppresses warnings about the
5295 entities being referenced but not assigned, and in addition a warning will be
5296 generated if one of these entities is in fact assigned in the
5297 same unit as the pragma (or in the corresponding body, or one
5298 of its subunits).
5299
5300 This is particularly useful for clearly signaling that a particular
5301 parameter is not modified, even though the spec suggests that it might
5302 be.
5303
5304 @node Pragma Unreferenced
5305 @unnumberedsec Pragma Unreferenced
5306 @findex Unreferenced
5307 @cindex Warnings, unreferenced
5308 @noindent
5309 Syntax:
5310
5311 @smallexample @c ada
5312 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5313 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5314 @end smallexample
5315
5316 @noindent
5317 This pragma signals that the entities whose names are listed are
5318 deliberately not referenced in the current source unit. This
5319 suppresses warnings about the
5320 entities being unreferenced, and in addition a warning will be
5321 generated if one of these entities is in fact referenced in the
5322 same unit as the pragma (or in the corresponding body, or one
5323 of its subunits).
5324
5325 This is particularly useful for clearly signaling that a particular
5326 parameter is not referenced in some particular subprogram implementation
5327 and that this is deliberate. It can also be useful in the case of
5328 objects declared only for their initialization or finalization side
5329 effects.
5330
5331 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5332 current scope, then the entity most recently declared is the one to which
5333 the pragma applies. Note that in the case of accept formals, the pragma
5334 Unreferenced may appear immediately after the keyword @code{do} which
5335 allows the indication of whether or not accept formals are referenced
5336 or not to be given individually for each accept statement.
5337
5338 The left hand side of an assignment does not count as a reference for the
5339 purpose of this pragma. Thus it is fine to assign to an entity for which
5340 pragma Unreferenced is given.
5341
5342 Note that if a warning is desired for all calls to a given subprogram,
5343 regardless of whether they occur in the same unit as the subprogram
5344 declaration, then this pragma should not be used (calls from another
5345 unit would not be flagged); pragma Obsolescent can be used instead
5346 for this purpose, see @xref{Pragma Obsolescent}.
5347
5348 The second form of pragma @code{Unreferenced} is used within a context
5349 clause. In this case the arguments must be unit names of units previously
5350 mentioned in @code{with} clauses (similar to the usage of pragma
5351 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5352 units and unreferenced entities within these units.
5353
5354 @node Pragma Unreferenced_Objects
5355 @unnumberedsec Pragma Unreferenced_Objects
5356 @findex Unreferenced_Objects
5357 @cindex Warnings, unreferenced
5358 @noindent
5359 Syntax:
5360
5361 @smallexample @c ada
5362 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5363 @end smallexample
5364
5365 @noindent
5366 This pragma signals that for the types or subtypes whose names are
5367 listed, objects which are declared with one of these types or subtypes may
5368 not be referenced, and if no references appear, no warnings are given.
5369
5370 This is particularly useful for objects which are declared solely for their
5371 initialization and finalization effect. Such variables are sometimes referred
5372 to as RAII variables (Resource Acquisition Is Initialization). Using this
5373 pragma on the relevant type (most typically a limited controlled type), the
5374 compiler will automatically suppress unwanted warnings about these variables
5375 not being referenced.
5376
5377 @node Pragma Unreserve_All_Interrupts
5378 @unnumberedsec Pragma Unreserve_All_Interrupts
5379 @findex Unreserve_All_Interrupts
5380 @noindent
5381 Syntax:
5382
5383 @smallexample @c ada
5384 pragma Unreserve_All_Interrupts;
5385 @end smallexample
5386
5387 @noindent
5388 Normally certain interrupts are reserved to the implementation. Any attempt
5389 to attach an interrupt causes Program_Error to be raised, as described in
5390 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5391 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5392 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5393 interrupt execution.
5394
5395 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5396 a program, then all such interrupts are unreserved. This allows the
5397 program to handle these interrupts, but disables their standard
5398 functions. For example, if this pragma is used, then pressing
5399 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5400 a program can then handle the @code{SIGINT} interrupt as it chooses.
5401
5402 For a full list of the interrupts handled in a specific implementation,
5403 see the source code for the spec of @code{Ada.Interrupts.Names} in
5404 file @file{a-intnam.ads}. This is a target dependent file that contains the
5405 list of interrupts recognized for a given target. The documentation in
5406 this file also specifies what interrupts are affected by the use of
5407 the @code{Unreserve_All_Interrupts} pragma.
5408
5409 For a more general facility for controlling what interrupts can be
5410 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5411 of the @code{Unreserve_All_Interrupts} pragma.
5412
5413 @node Pragma Unsuppress
5414 @unnumberedsec Pragma Unsuppress
5415 @findex Unsuppress
5416 @noindent
5417 Syntax:
5418
5419 @smallexample @c ada
5420 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5421 @end smallexample
5422
5423 @noindent
5424 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5425 there is no corresponding pragma @code{Suppress} in effect, it has no
5426 effect. The range of the effect is the same as for pragma
5427 @code{Suppress}. The meaning of the arguments is identical to that used
5428 in pragma @code{Suppress}.
5429
5430 One important application is to ensure that checks are on in cases where
5431 code depends on the checks for its correct functioning, so that the code
5432 will compile correctly even if the compiler switches are set to suppress
5433 checks.
5434
5435 @node Pragma Use_VADS_Size
5436 @unnumberedsec Pragma Use_VADS_Size
5437 @cindex @code{Size}, VADS compatibility
5438 @findex Use_VADS_Size
5439 @noindent
5440 Syntax:
5441
5442 @smallexample @c ada
5443 pragma Use_VADS_Size;
5444 @end smallexample
5445
5446 @noindent
5447 This is a configuration pragma. In a unit to which it applies, any use
5448 of the 'Size attribute is automatically interpreted as a use of the
5449 'VADS_Size attribute. Note that this may result in incorrect semantic
5450 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5451 the handling of existing code which depends on the interpretation of Size
5452 as implemented in the VADS compiler. See description of the VADS_Size
5453 attribute for further details.
5454
5455 @node Pragma Validity_Checks
5456 @unnumberedsec Pragma Validity_Checks
5457 @findex Validity_Checks
5458 @noindent
5459 Syntax:
5460
5461 @smallexample @c ada
5462 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5463 @end smallexample
5464
5465 @noindent
5466 This pragma is used in conjunction with compiler switches to control the
5467 built-in validity checking provided by GNAT@. The compiler switches, if set
5468 provide an initial setting for the switches, and this pragma may be used
5469 to modify these settings, or the settings may be provided entirely by
5470 the use of the pragma. This pragma can be used anywhere that a pragma
5471 is legal, including use as a configuration pragma (including use in
5472 the @file{gnat.adc} file).
5473
5474 The form with a string literal specifies which validity options are to be
5475 activated. The validity checks are first set to include only the default
5476 reference manual settings, and then a string of letters in the string
5477 specifies the exact set of options required. The form of this string
5478 is exactly as described for the @option{-gnatVx} compiler switch (see the
5479 GNAT users guide for details). For example the following two methods
5480 can be used to enable validity checking for mode @code{in} and
5481 @code{in out} subprogram parameters:
5482
5483 @itemize @bullet
5484 @item
5485 @smallexample @c ada
5486 pragma Validity_Checks ("im");
5487 @end smallexample
5488
5489 @item
5490 @smallexample
5491 gcc -c -gnatVim @dots{}
5492 @end smallexample
5493 @end itemize
5494
5495 @noindent
5496 The form ALL_CHECKS activates all standard checks (its use is equivalent
5497 to the use of the @code{gnatva} switch.
5498
5499 The forms with @code{Off} and @code{On}
5500 can be used to temporarily disable validity checks
5501 as shown in the following example:
5502
5503 @smallexample @c ada
5504 @iftex
5505 @leftskip=0cm
5506 @end iftex
5507 pragma Validity_Checks ("c"); -- validity checks for copies
5508 pragma Validity_Checks (Off); -- turn off validity checks
5509 A := B; -- B will not be validity checked
5510 pragma Validity_Checks (On); -- turn validity checks back on
5511 A := C; -- C will be validity checked
5512 @end smallexample
5513
5514 @node Pragma Volatile
5515 @unnumberedsec Pragma Volatile
5516 @findex Volatile
5517 @noindent
5518 Syntax:
5519
5520 @smallexample @c ada
5521 pragma Volatile (LOCAL_NAME);
5522 @end smallexample
5523
5524 @noindent
5525 This pragma is defined by the Ada Reference Manual, and the GNAT
5526 implementation is fully conformant with this definition. The reason it
5527 is mentioned in this section is that a pragma of the same name was supplied
5528 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5529 implementation of pragma Volatile is upwards compatible with the
5530 implementation in DEC Ada 83.
5531
5532 @node Pragma Warnings
5533 @unnumberedsec Pragma Warnings
5534 @findex Warnings
5535 @noindent
5536 Syntax:
5537
5538 @smallexample @c ada
5539 pragma Warnings (On | Off);
5540 pragma Warnings (On | Off, LOCAL_NAME);
5541 pragma Warnings (static_string_EXPRESSION);
5542 pragma Warnings (On | Off, static_string_EXPRESSION);
5543 @end smallexample
5544
5545 @noindent
5546 Normally warnings are enabled, with the output being controlled by
5547 the command line switch. Warnings (@code{Off}) turns off generation of
5548 warnings until a Warnings (@code{On}) is encountered or the end of the
5549 current unit. If generation of warnings is turned off using this
5550 pragma, then no warning messages are output, regardless of the
5551 setting of the command line switches.
5552
5553 The form with a single argument may be used as a configuration pragma.
5554
5555 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5556 the specified entity. This suppression is effective from the point where
5557 it occurs till the end of the extended scope of the variable (similar to
5558 the scope of @code{Suppress}).
5559
5560 The form with a single static_string_EXPRESSION argument provides more precise
5561 control over which warnings are active. The string is a list of letters
5562 specifying which warnings are to be activated and which deactivated. The
5563 code for these letters is the same as the string used in the command
5564 line switch controlling warnings. For a brief summary, use the gnatmake
5565 command with no arguments, which will generate usage information containing
5566 the list of warnings switches supported. For
5567 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5568 User's Guide}.
5569
5570 @noindent
5571 The specified warnings will be in effect until the end of the program
5572 or another pragma Warnings is encountered. The effect of the pragma is
5573 cumulative. Initially the set of warnings is the standard default set
5574 as possibly modified by compiler switches. Then each pragma Warning
5575 modifies this set of warnings as specified. This form of the pragma may
5576 also be used as a configuration pragma.
5577
5578 The fourth form, with an On|Off parameter and a string, is used to
5579 control individual messages, based on their text. The string argument
5580 is a pattern that is used to match against the text of individual
5581 warning messages (not including the initial "warning: " tag).
5582
5583 The pattern may contain asterisks, which match zero or more characters in
5584 the message. For example, you can use
5585 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5586 message @code{warning: 960 bits of "a" unused}. No other regular
5587 expression notations are permitted. All characters other than asterisk in
5588 these three specific cases are treated as literal characters in the match.
5589
5590 There are two ways to use this pragma. The OFF form can be used as a
5591 configuration pragma. The effect is to suppress all warnings (if any)
5592 that match the pattern string throughout the compilation.
5593
5594 The second usage is to suppress a warning locally, and in this case, two
5595 pragmas must appear in sequence:
5596
5597 @smallexample @c ada
5598 pragma Warnings (Off, Pattern);
5599 @dots{} code where given warning is to be suppressed
5600 pragma Warnings (On, Pattern);
5601 @end smallexample
5602
5603 @noindent
5604 In this usage, the pattern string must match in the Off and On pragmas,
5605 and at least one matching warning must be suppressed.
5606
5607 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5608 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5609 be useful in checking whether obsolete pragmas in existing programs are hiding
5610 real problems.
5611
5612 Note: pragma Warnings does not affect the processing of style messages. See
5613 separate entry for pragma Style_Checks for control of style messages.
5614
5615 @node Pragma Weak_External
5616 @unnumberedsec Pragma Weak_External
5617 @findex Weak_External
5618 @noindent
5619 Syntax:
5620
5621 @smallexample @c ada
5622 pragma Weak_External ([Entity =>] LOCAL_NAME);
5623 @end smallexample
5624
5625 @noindent
5626 @var{LOCAL_NAME} must refer to an object that is declared at the library
5627 level. This pragma specifies that the given entity should be marked as a
5628 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5629 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5630 of a regular symbol, that is to say a symbol that does not have to be
5631 resolved by the linker if used in conjunction with a pragma Import.
5632
5633 When a weak symbol is not resolved by the linker, its address is set to
5634 zero. This is useful in writing interfaces to external modules that may
5635 or may not be linked in the final executable, for example depending on
5636 configuration settings.
5637
5638 If a program references at run time an entity to which this pragma has been
5639 applied, and the corresponding symbol was not resolved at link time, then
5640 the execution of the program is erroneous. It is not erroneous to take the
5641 Address of such an entity, for example to guard potential references,
5642 as shown in the example below.
5643
5644 Some file formats do not support weak symbols so not all target machines
5645 support this pragma.
5646
5647 @smallexample @c ada
5648 -- Example of the use of pragma Weak_External
5649
5650 package External_Module is
5651 key : Integer;
5652 pragma Import (C, key);
5653 pragma Weak_External (key);
5654 function Present return boolean;
5655 end External_Module;
5656
5657 with System; use System;
5658 package body External_Module is
5659 function Present return boolean is
5660 begin
5661 return key'Address /= System.Null_Address;
5662 end Present;
5663 end External_Module;
5664 @end smallexample
5665
5666 @node Pragma Wide_Character_Encoding
5667 @unnumberedsec Pragma Wide_Character_Encoding
5668 @findex Wide_Character_Encoding
5669 @noindent
5670 Syntax:
5671
5672 @smallexample @c ada
5673 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5674 @end smallexample
5675
5676 @noindent
5677 This pragma specifies the wide character encoding to be used in program
5678 source text appearing subsequently. It is a configuration pragma, but may
5679 also be used at any point that a pragma is allowed, and it is permissible
5680 to have more than one such pragma in a file, allowing multiple encodings
5681 to appear within the same file.
5682
5683 The argument can be an identifier or a character literal. In the identifier
5684 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5685 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5686 case it is correspondingly one of the characters @samp{h}, @samp{u},
5687 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5688
5689 Note that when the pragma is used within a file, it affects only the
5690 encoding within that file, and does not affect withed units, specs,
5691 or subunits.
5692
5693 @node Implementation Defined Attributes
5694 @chapter Implementation Defined Attributes
5695 Ada defines (throughout the Ada reference manual,
5696 summarized in Annex K),
5697 a set of attributes that provide useful additional functionality in all
5698 areas of the language. These language defined attributes are implemented
5699 in GNAT and work as described in the Ada Reference Manual.
5700
5701 In addition, Ada allows implementations to define additional
5702 attributes whose meaning is defined by the implementation. GNAT provides
5703 a number of these implementation-dependent attributes which can be used
5704 to extend and enhance the functionality of the compiler. This section of
5705 the GNAT reference manual describes these additional attributes.
5706
5707 Note that any program using these attributes may not be portable to
5708 other compilers (although GNAT implements this set of attributes on all
5709 platforms). Therefore if portability to other compilers is an important
5710 consideration, you should minimize the use of these attributes.
5711
5712 @menu
5713 * Abort_Signal::
5714 * Address_Size::
5715 * Asm_Input::
5716 * Asm_Output::
5717 * AST_Entry::
5718 * Bit::
5719 * Bit_Position::
5720 * Compiler_Version::
5721 * Code_Address::
5722 * Default_Bit_Order::
5723 * Descriptor_Size::
5724 * Elaborated::
5725 * Elab_Body::
5726 * Elab_Spec::
5727 * Elab_Subp_Body::
5728 * Emax::
5729 * Enabled::
5730 * Enum_Rep::
5731 * Enum_Val::
5732 * Epsilon::
5733 * Fixed_Value::
5734 * Has_Access_Values::
5735 * Has_Discriminants::
5736 * Img::
5737 * Integer_Value::
5738 * Invalid_Value::
5739 * Large::
5740 * Machine_Size::
5741 * Mantissa::
5742 * Max_Interrupt_Priority::
5743 * Max_Priority::
5744 * Maximum_Alignment::
5745 * Mechanism_Code::
5746 * Null_Parameter::
5747 * Object_Size::
5748 * Old::
5749 * Passed_By_Reference::
5750 * Pool_Address::
5751 * Range_Length::
5752 * Ref::
5753 * Result::
5754 * Safe_Emax::
5755 * Safe_Large::
5756 * Small::
5757 * Storage_Unit::
5758 * Stub_Type::
5759 * System_Allocator_Alignment::
5760 * Target_Name::
5761 * Tick::
5762 * To_Address::
5763 * Type_Class::
5764 * UET_Address::
5765 * Unconstrained_Array::
5766 * Universal_Literal_String::
5767 * Unrestricted_Access::
5768 * VADS_Size::
5769 * Value_Size::
5770 * Wchar_T_Size::
5771 * Word_Size::
5772 @end menu
5773
5774 @node Abort_Signal
5775 @unnumberedsec Abort_Signal
5776 @findex Abort_Signal
5777 @noindent
5778 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5779 prefix) provides the entity for the special exception used to signal
5780 task abort or asynchronous transfer of control. Normally this attribute
5781 should only be used in the tasking runtime (it is highly peculiar, and
5782 completely outside the normal semantics of Ada, for a user program to
5783 intercept the abort exception).
5784
5785 @node Address_Size
5786 @unnumberedsec Address_Size
5787 @cindex Size of @code{Address}
5788 @findex Address_Size
5789 @noindent
5790 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5791 prefix) is a static constant giving the number of bits in an
5792 @code{Address}. It is the same value as System.Address'Size,
5793 but has the advantage of being static, while a direct
5794 reference to System.Address'Size is non-static because Address
5795 is a private type.
5796
5797 @node Asm_Input
5798 @unnumberedsec Asm_Input
5799 @findex Asm_Input
5800 @noindent
5801 The @code{Asm_Input} attribute denotes a function that takes two
5802 parameters. The first is a string, the second is an expression of the
5803 type designated by the prefix. The first (string) argument is required
5804 to be a static expression, and is the constraint for the parameter,
5805 (e.g.@: what kind of register is required). The second argument is the
5806 value to be used as the input argument. The possible values for the
5807 constant are the same as those used in the RTL, and are dependent on
5808 the configuration file used to built the GCC back end.
5809 @ref{Machine Code Insertions}
5810
5811 @node Asm_Output
5812 @unnumberedsec Asm_Output
5813 @findex Asm_Output
5814 @noindent
5815 The @code{Asm_Output} attribute denotes a function that takes two
5816 parameters. The first is a string, the second is the name of a variable
5817 of the type designated by the attribute prefix. The first (string)
5818 argument is required to be a static expression and designates the
5819 constraint for the parameter (e.g.@: what kind of register is
5820 required). The second argument is the variable to be updated with the
5821 result. The possible values for constraint are the same as those used in
5822 the RTL, and are dependent on the configuration file used to build the
5823 GCC back end. If there are no output operands, then this argument may
5824 either be omitted, or explicitly given as @code{No_Output_Operands}.
5825 @ref{Machine Code Insertions}
5826
5827 @node AST_Entry
5828 @unnumberedsec AST_Entry
5829 @cindex OpenVMS
5830 @findex AST_Entry
5831 @noindent
5832 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5833 the name of an entry, it yields a value of the predefined type AST_Handler
5834 (declared in the predefined package System, as extended by the use of
5835 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5836 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5837 Language Reference Manual}, section 9.12a.
5838
5839 @node Bit
5840 @unnumberedsec Bit
5841 @findex Bit
5842 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5843 offset within the storage unit (byte) that contains the first bit of
5844 storage allocated for the object. The value of this attribute is of the
5845 type @code{Universal_Integer}, and is always a non-negative number not
5846 exceeding the value of @code{System.Storage_Unit}.
5847
5848 For an object that is a variable or a constant allocated in a register,
5849 the value is zero. (The use of this attribute does not force the
5850 allocation of a variable to memory).
5851
5852 For an object that is a formal parameter, this attribute applies
5853 to either the matching actual parameter or to a copy of the
5854 matching actual parameter.
5855
5856 For an access object the value is zero. Note that
5857 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5858 designated object. Similarly for a record component
5859 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5860 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5861 are subject to index checks.
5862
5863 This attribute is designed to be compatible with the DEC Ada 83 definition
5864 and implementation of the @code{Bit} attribute.
5865
5866 @node Bit_Position
5867 @unnumberedsec Bit_Position
5868 @findex Bit_Position
5869 @noindent
5870 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5871 of the fields of the record type, yields the bit
5872 offset within the record contains the first bit of
5873 storage allocated for the object. The value of this attribute is of the
5874 type @code{Universal_Integer}. The value depends only on the field
5875 @var{C} and is independent of the alignment of
5876 the containing record @var{R}.
5877
5878 @node Compiler_Version
5879 @unnumberedsec Compiler_Version
5880 @findex Compiler_Version
5881 @noindent
5882 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5883 prefix) yields a static string identifying the version of the compiler
5884 being used to compile the unit containing the attribute reference. A
5885 typical result would be something like "@value{EDITION} @i{version} (20090221)".
5886
5887 @node Code_Address
5888 @unnumberedsec Code_Address
5889 @findex Code_Address
5890 @cindex Subprogram address
5891 @cindex Address of subprogram code
5892 @noindent
5893 The @code{'Address}
5894 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5895 intended effect seems to be to provide
5896 an address value which can be used to call the subprogram by means of
5897 an address clause as in the following example:
5898
5899 @smallexample @c ada
5900 procedure K is @dots{}
5901
5902 procedure L;
5903 for L'Address use K'Address;
5904 pragma Import (Ada, L);
5905 @end smallexample
5906
5907 @noindent
5908 A call to @code{L} is then expected to result in a call to @code{K}@.
5909 In Ada 83, where there were no access-to-subprogram values, this was
5910 a common work-around for getting the effect of an indirect call.
5911 GNAT implements the above use of @code{Address} and the technique
5912 illustrated by the example code works correctly.
5913
5914 However, for some purposes, it is useful to have the address of the start
5915 of the generated code for the subprogram. On some architectures, this is
5916 not necessarily the same as the @code{Address} value described above.
5917 For example, the @code{Address} value may reference a subprogram
5918 descriptor rather than the subprogram itself.
5919
5920 The @code{'Code_Address} attribute, which can only be applied to
5921 subprogram entities, always returns the address of the start of the
5922 generated code of the specified subprogram, which may or may not be
5923 the same value as is returned by the corresponding @code{'Address}
5924 attribute.
5925
5926 @node Default_Bit_Order
5927 @unnumberedsec Default_Bit_Order
5928 @cindex Big endian
5929 @cindex Little endian
5930 @findex Default_Bit_Order
5931 @noindent
5932 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5933 permissible prefix), provides the value @code{System.Default_Bit_Order}
5934 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5935 @code{Low_Order_First}). This is used to construct the definition of
5936 @code{Default_Bit_Order} in package @code{System}.
5937
5938 @node Descriptor_Size
5939 @unnumberedsec Descriptor_Size
5940 @cindex Descriptor
5941 @cindex Dope vector
5942 @findex Descriptor_Size
5943 @noindent
5944 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
5945 descriptor allocated for a type. The result is non-zero only for unconstrained
5946 array types and the returned value is of type universal integer. In GNAT, an
5947 array descriptor contains bounds information and is located immediately before
5948 the first element of the array.
5949
5950 @smallexample @c ada
5951 type Unconstr_Array is array (Positive range <>) of Boolean;
5952 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
5953 @end smallexample
5954
5955 @noindent
5956 The attribute takes into account any additional padding due to type alignment.
5957 In the example above, the descriptor contains two values of type
5958 @code{Positive} representing the low and high bound. Since @code{Positive} has
5959 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
5960 Positive'Size + 2} or 64 bits.
5961
5962 @node Elaborated
5963 @unnumberedsec Elaborated
5964 @findex Elaborated
5965 @noindent
5966 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5967 value is a Boolean which indicates whether or not the given unit has been
5968 elaborated. This attribute is primarily intended for internal use by the
5969 generated code for dynamic elaboration checking, but it can also be used
5970 in user programs. The value will always be True once elaboration of all
5971 units has been completed. An exception is for units which need no
5972 elaboration, the value is always False for such units.
5973
5974 @node Elab_Body
5975 @unnumberedsec Elab_Body
5976 @findex Elab_Body
5977 @noindent
5978 This attribute can only be applied to a program unit name. It returns
5979 the entity for the corresponding elaboration procedure for elaborating
5980 the body of the referenced unit. This is used in the main generated
5981 elaboration procedure by the binder and is not normally used in any
5982 other context. However, there may be specialized situations in which it
5983 is useful to be able to call this elaboration procedure from Ada code,
5984 e.g.@: if it is necessary to do selective re-elaboration to fix some
5985 error.
5986
5987 @node Elab_Spec
5988 @unnumberedsec Elab_Spec
5989 @findex Elab_Spec
5990 @noindent
5991 This attribute can only be applied to a program unit name. It returns
5992 the entity for the corresponding elaboration procedure for elaborating
5993 the spec of the referenced unit. This is used in the main
5994 generated elaboration procedure by the binder and is not normally used
5995 in any other context. However, there may be specialized situations in
5996 which it is useful to be able to call this elaboration procedure from
5997 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5998 some error.
5999
6000 @node Elab_Subp_Body
6001 @unnumberedsec Elab_Subp_Body
6002 @findex Elab_Subp_Body
6003 @noindent
6004 This attribute can only be applied to a library level subprogram
6005 name and is only allowed in CodePeer mode. It returns the entity
6006 for the corresponding elaboration procedure for elaborating the body
6007 of the referenced subprogram unit. This is used in the main generated
6008 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6009 otherwise.
6010
6011 @node Emax
6012 @unnumberedsec Emax
6013 @cindex Ada 83 attributes
6014 @findex Emax
6015 @noindent
6016 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6017 the Ada 83 reference manual for an exact description of the semantics of
6018 this attribute.
6019
6020 @node Enabled
6021 @unnumberedsec Enabled
6022 @findex Enabled
6023 @noindent
6024 The @code{Enabled} attribute allows an application program to check at compile
6025 time to see if the designated check is currently enabled. The prefix is a
6026 simple identifier, referencing any predefined check name (other than
6027 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6028 no argument is given for the attribute, the check is for the general state
6029 of the check, if an argument is given, then it is an entity name, and the
6030 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6031 given naming the entity (if not, then the argument is ignored).
6032
6033 Note that instantiations inherit the check status at the point of the
6034 instantiation, so a useful idiom is to have a library package that
6035 introduces a check name with @code{pragma Check_Name}, and then contains
6036 generic packages or subprograms which use the @code{Enabled} attribute
6037 to see if the check is enabled. A user of this package can then issue
6038 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6039 the package or subprogram, controlling whether the check will be present.
6040
6041 @node Enum_Rep
6042 @unnumberedsec Enum_Rep
6043 @cindex Representation of enums
6044 @findex Enum_Rep
6045 @noindent
6046 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6047 function with the following spec:
6048
6049 @smallexample @c ada
6050 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6051 return @i{Universal_Integer};
6052 @end smallexample
6053
6054 @noindent
6055 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6056 enumeration type or to a non-overloaded enumeration
6057 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6058 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6059 enumeration literal or object.
6060
6061 The function returns the representation value for the given enumeration
6062 value. This will be equal to value of the @code{Pos} attribute in the
6063 absence of an enumeration representation clause. This is a static
6064 attribute (i.e.@: the result is static if the argument is static).
6065
6066 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6067 in which case it simply returns the integer value. The reason for this
6068 is to allow it to be used for @code{(<>)} discrete formal arguments in
6069 a generic unit that can be instantiated with either enumeration types
6070 or integer types. Note that if @code{Enum_Rep} is used on a modular
6071 type whose upper bound exceeds the upper bound of the largest signed
6072 integer type, and the argument is a variable, so that the universal
6073 integer calculation is done at run time, then the call to @code{Enum_Rep}
6074 may raise @code{Constraint_Error}.
6075
6076 @node Enum_Val
6077 @unnumberedsec Enum_Val
6078 @cindex Representation of enums
6079 @findex Enum_Val
6080 @noindent
6081 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6082 function with the following spec:
6083
6084 @smallexample @c ada
6085 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6086 return @var{S}'Base};
6087 @end smallexample
6088
6089 @noindent
6090 The function returns the enumeration value whose representation matches the
6091 argument, or raises Constraint_Error if no enumeration literal of the type
6092 has the matching value.
6093 This will be equal to value of the @code{Val} attribute in the
6094 absence of an enumeration representation clause. This is a static
6095 attribute (i.e.@: the result is static if the argument is static).
6096
6097 @node Epsilon
6098 @unnumberedsec Epsilon
6099 @cindex Ada 83 attributes
6100 @findex Epsilon
6101 @noindent
6102 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6103 the Ada 83 reference manual for an exact description of the semantics of
6104 this attribute.
6105
6106 @node Fixed_Value
6107 @unnumberedsec Fixed_Value
6108 @findex Fixed_Value
6109 @noindent
6110 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6111 function with the following specification:
6112
6113 @smallexample @c ada
6114 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6115 return @var{S};
6116 @end smallexample
6117
6118 @noindent
6119 The value returned is the fixed-point value @var{V} such that
6120
6121 @smallexample @c ada
6122 @var{V} = Arg * @var{S}'Small
6123 @end smallexample
6124
6125 @noindent
6126 The effect is thus similar to first converting the argument to the
6127 integer type used to represent @var{S}, and then doing an unchecked
6128 conversion to the fixed-point type. The difference is
6129 that there are full range checks, to ensure that the result is in range.
6130 This attribute is primarily intended for use in implementation of the
6131 input-output functions for fixed-point values.
6132
6133 @node Has_Access_Values
6134 @unnumberedsec Has_Access_Values
6135 @cindex Access values, testing for
6136 @findex Has_Access_Values
6137 @noindent
6138 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6139 is a Boolean value which is True if the is an access type, or is a composite
6140 type with a component (at any nesting depth) that is an access type, and is
6141 False otherwise.
6142 The intended use of this attribute is in conjunction with generic
6143 definitions. If the attribute is applied to a generic private type, it
6144 indicates whether or not the corresponding actual type has access values.
6145
6146 @node Has_Discriminants
6147 @unnumberedsec Has_Discriminants
6148 @cindex Discriminants, testing for
6149 @findex Has_Discriminants
6150 @noindent
6151 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6152 is a Boolean value which is True if the type has discriminants, and False
6153 otherwise. The intended use of this attribute is in conjunction with generic
6154 definitions. If the attribute is applied to a generic private type, it
6155 indicates whether or not the corresponding actual type has discriminants.
6156
6157 @node Img
6158 @unnumberedsec Img
6159 @findex Img
6160 @noindent
6161 The @code{Img} attribute differs from @code{Image} in that it may be
6162 applied to objects as well as types, in which case it gives the
6163 @code{Image} for the subtype of the object. This is convenient for
6164 debugging:
6165
6166 @smallexample @c ada
6167 Put_Line ("X = " & X'Img);
6168 @end smallexample
6169
6170 @noindent
6171 has the same meaning as the more verbose:
6172
6173 @smallexample @c ada
6174 Put_Line ("X = " & @var{T}'Image (X));
6175 @end smallexample
6176
6177 @noindent
6178 where @var{T} is the (sub)type of the object @code{X}.
6179
6180 @node Integer_Value
6181 @unnumberedsec Integer_Value
6182 @findex Integer_Value
6183 @noindent
6184 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6185 function with the following spec:
6186
6187 @smallexample @c ada
6188 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6189 return @var{S};
6190 @end smallexample
6191
6192 @noindent
6193 The value returned is the integer value @var{V}, such that
6194
6195 @smallexample @c ada
6196 Arg = @var{V} * @var{T}'Small
6197 @end smallexample
6198
6199 @noindent
6200 where @var{T} is the type of @code{Arg}.
6201 The effect is thus similar to first doing an unchecked conversion from
6202 the fixed-point type to its corresponding implementation type, and then
6203 converting the result to the target integer type. The difference is
6204 that there are full range checks, to ensure that the result is in range.
6205 This attribute is primarily intended for use in implementation of the
6206 standard input-output functions for fixed-point values.
6207
6208 @node Invalid_Value
6209 @unnumberedsec Invalid_Value
6210 @findex Invalid_Value
6211 @noindent
6212 For every scalar type S, S'Invalid_Value returns an undefined value of the
6213 type. If possible this value is an invalid representation for the type. The
6214 value returned is identical to the value used to initialize an otherwise
6215 uninitialized value of the type if pragma Initialize_Scalars is used,
6216 including the ability to modify the value with the binder -Sxx flag and
6217 relevant environment variables at run time.
6218
6219 @node Large
6220 @unnumberedsec Large
6221 @cindex Ada 83 attributes
6222 @findex Large
6223 @noindent
6224 The @code{Large} attribute is provided for compatibility with Ada 83. See
6225 the Ada 83 reference manual for an exact description of the semantics of
6226 this attribute.
6227
6228 @node Machine_Size
6229 @unnumberedsec Machine_Size
6230 @findex Machine_Size
6231 @noindent
6232 This attribute is identical to the @code{Object_Size} attribute. It is
6233 provided for compatibility with the DEC Ada 83 attribute of this name.
6234
6235 @node Mantissa
6236 @unnumberedsec Mantissa
6237 @cindex Ada 83 attributes
6238 @findex Mantissa
6239 @noindent
6240 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6241 the Ada 83 reference manual for an exact description of the semantics of
6242 this attribute.
6243
6244 @node Max_Interrupt_Priority
6245 @unnumberedsec Max_Interrupt_Priority
6246 @cindex Interrupt priority, maximum
6247 @findex Max_Interrupt_Priority
6248 @noindent
6249 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6250 permissible prefix), provides the same value as
6251 @code{System.Max_Interrupt_Priority}.
6252
6253 @node Max_Priority
6254 @unnumberedsec Max_Priority
6255 @cindex Priority, maximum
6256 @findex Max_Priority
6257 @noindent
6258 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6259 prefix) provides the same value as @code{System.Max_Priority}.
6260
6261 @node Maximum_Alignment
6262 @unnumberedsec Maximum_Alignment
6263 @cindex Alignment, maximum
6264 @findex Maximum_Alignment
6265 @noindent
6266 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6267 permissible prefix) provides the maximum useful alignment value for the
6268 target. This is a static value that can be used to specify the alignment
6269 for an object, guaranteeing that it is properly aligned in all
6270 cases.
6271
6272 @node Mechanism_Code
6273 @unnumberedsec Mechanism_Code
6274 @cindex Return values, passing mechanism
6275 @cindex Parameters, passing mechanism
6276 @findex Mechanism_Code
6277 @noindent
6278 @code{@var{function}'Mechanism_Code} yields an integer code for the
6279 mechanism used for the result of function, and
6280 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6281 used for formal parameter number @var{n} (a static integer value with 1
6282 meaning the first parameter) of @var{subprogram}. The code returned is:
6283
6284 @table @asis
6285 @item 1
6286 by copy (value)
6287 @item 2
6288 by reference
6289 @item 3
6290 by descriptor (default descriptor class)
6291 @item 4
6292 by descriptor (UBS: unaligned bit string)
6293 @item 5
6294 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6295 @item 6
6296 by descriptor (UBA: unaligned bit array)
6297 @item 7
6298 by descriptor (S: string, also scalar access type parameter)
6299 @item 8
6300 by descriptor (SB: string with arbitrary bounds)
6301 @item 9
6302 by descriptor (A: contiguous array)
6303 @item 10
6304 by descriptor (NCA: non-contiguous array)
6305 @end table
6306
6307 @noindent
6308 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6309 @cindex OpenVMS
6310
6311 @node Null_Parameter
6312 @unnumberedsec Null_Parameter
6313 @cindex Zero address, passing
6314 @findex Null_Parameter
6315 @noindent
6316 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6317 type or subtype @var{T} allocated at machine address zero. The attribute
6318 is allowed only as the default expression of a formal parameter, or as
6319 an actual expression of a subprogram call. In either case, the
6320 subprogram must be imported.
6321
6322 The identity of the object is represented by the address zero in the
6323 argument list, independent of the passing mechanism (explicit or
6324 default).
6325
6326 This capability is needed to specify that a zero address should be
6327 passed for a record or other composite object passed by reference.
6328 There is no way of indicating this without the @code{Null_Parameter}
6329 attribute.
6330
6331 @node Object_Size
6332 @unnumberedsec Object_Size
6333 @cindex Size, used for objects
6334 @findex Object_Size
6335 @noindent
6336 The size of an object is not necessarily the same as the size of the type
6337 of an object. This is because by default object sizes are increased to be
6338 a multiple of the alignment of the object. For example,
6339 @code{Natural'Size} is
6340 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6341 Similarly, a record containing an integer and a character:
6342
6343 @smallexample @c ada
6344 type Rec is record
6345 I : Integer;
6346 C : Character;
6347 end record;
6348 @end smallexample
6349
6350 @noindent
6351 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6352 alignment will be 4, because of the
6353 integer field, and so the default size of record objects for this type
6354 will be 64 (8 bytes).
6355
6356 @node Old
6357 @unnumberedsec Old
6358 @cindex Capturing Old values
6359 @cindex Postconditions
6360 @noindent
6361 The attribute Prefix'Old can be used within a
6362 subprogram body or within a precondition or
6363 postcondition pragma. The effect is to
6364 refer to the value of the prefix on entry. So for
6365 example if you have an argument of a record type X called Arg1,
6366 you can refer to Arg1.Field'Old which yields the value of
6367 Arg1.Field on entry. The implementation simply involves generating
6368 an object declaration which captures the value on entry. Any
6369 prefix is allowed except one of a limited type (since limited
6370 types cannot be copied to capture their values) or an expression
6371 which references a local variable
6372 (since local variables do not exist at subprogram entry time).
6373
6374 The following example shows the use of 'Old to implement
6375 a test of a postcondition:
6376
6377 @smallexample @c ada
6378 with Old_Pkg;
6379 procedure Old is
6380 begin
6381 Old_Pkg.Incr;
6382 end Old;
6383
6384 package Old_Pkg is
6385 procedure Incr;
6386 end Old_Pkg;
6387
6388 package body Old_Pkg is
6389 Count : Natural := 0;
6390
6391 procedure Incr is
6392 begin
6393 ... code manipulating the value of Count
6394
6395 pragma Assert (Count = Count'Old + 1);
6396 end Incr;
6397 end Old_Pkg;
6398 @end smallexample
6399
6400 @noindent
6401 Note that it is allowed to apply 'Old to a constant entity, but this will
6402 result in a warning, since the old and new values will always be the same.
6403
6404 @node Passed_By_Reference
6405 @unnumberedsec Passed_By_Reference
6406 @cindex Parameters, when passed by reference
6407 @findex Passed_By_Reference
6408 @noindent
6409 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6410 a value of type @code{Boolean} value that is @code{True} if the type is
6411 normally passed by reference and @code{False} if the type is normally
6412 passed by copy in calls. For scalar types, the result is always @code{False}
6413 and is static. For non-scalar types, the result is non-static.
6414
6415 @node Pool_Address
6416 @unnumberedsec Pool_Address
6417 @cindex Parameters, when passed by reference
6418 @findex Pool_Address
6419 @noindent
6420 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6421 of X within its storage pool. This is the same as
6422 @code{@var{X}'Address}, except that for an unconstrained array whose
6423 bounds are allocated just before the first component,
6424 @code{@var{X}'Pool_Address} returns the address of those bounds,
6425 whereas @code{@var{X}'Address} returns the address of the first
6426 component.
6427
6428 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6429 the object is allocated'', which could be a user-defined storage pool,
6430 the global heap, on the stack, or in a static memory area. For an
6431 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6432 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6433
6434 @node Range_Length
6435 @unnumberedsec Range_Length
6436 @findex Range_Length
6437 @noindent
6438 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6439 the number of values represented by the subtype (zero for a null
6440 range). The result is static for static subtypes. @code{Range_Length}
6441 applied to the index subtype of a one dimensional array always gives the
6442 same result as @code{Range} applied to the array itself.
6443
6444 @node Ref
6445 @unnumberedsec Ref
6446 @findex Ref
6447 @noindent
6448 The @code{System.Address'Ref}
6449 (@code{System.Address} is the only permissible prefix)
6450 denotes a function identical to
6451 @code{System.Storage_Elements.To_Address} except that
6452 it is a static attribute. See @ref{To_Address} for more details.
6453
6454 @node Result
6455 @unnumberedsec Result
6456 @findex Result
6457 @noindent
6458 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6459 for a function. The prefix must be the name of the corresponding function. This
6460 is used to refer to the result of the function in the postcondition expression.
6461 For a further discussion of the use of this attribute and examples of its use,
6462 see the description of pragma Postcondition.
6463
6464 @node Safe_Emax
6465 @unnumberedsec Safe_Emax
6466 @cindex Ada 83 attributes
6467 @findex Safe_Emax
6468 @noindent
6469 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6470 the Ada 83 reference manual for an exact description of the semantics of
6471 this attribute.
6472
6473 @node Safe_Large
6474 @unnumberedsec Safe_Large
6475 @cindex Ada 83 attributes
6476 @findex Safe_Large
6477 @noindent
6478 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6479 the Ada 83 reference manual for an exact description of the semantics of
6480 this attribute.
6481
6482 @node Small
6483 @unnumberedsec Small
6484 @cindex Ada 83 attributes
6485 @findex Small
6486 @noindent
6487 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6488 fixed-point types.
6489 GNAT also allows this attribute to be applied to floating-point types
6490 for compatibility with Ada 83. See
6491 the Ada 83 reference manual for an exact description of the semantics of
6492 this attribute when applied to floating-point types.
6493
6494 @node Storage_Unit
6495 @unnumberedsec Storage_Unit
6496 @findex Storage_Unit
6497 @noindent
6498 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6499 prefix) provides the same value as @code{System.Storage_Unit}.
6500
6501 @node Stub_Type
6502 @unnumberedsec Stub_Type
6503 @findex Stub_Type
6504 @noindent
6505 The GNAT implementation of remote access-to-classwide types is
6506 organized as described in AARM section E.4 (20.t): a value of an RACW type
6507 (designating a remote object) is represented as a normal access
6508 value, pointing to a "stub" object which in turn contains the
6509 necessary information to contact the designated remote object. A
6510 call on any dispatching operation of such a stub object does the
6511 remote call, if necessary, using the information in the stub object
6512 to locate the target partition, etc.
6513
6514 For a prefix @code{T} that denotes a remote access-to-classwide type,
6515 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6516
6517 By construction, the layout of @code{T'Stub_Type} is identical to that of
6518 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6519 unit @code{System.Partition_Interface}. Use of this attribute will create
6520 an implicit dependency on this unit.
6521
6522 @node System_Allocator_Alignment
6523 @unnumberedsec System_Allocator_Alignment
6524 @cindex Alignment, allocator
6525 @findex System_Allocator_Alignment
6526 @noindent
6527 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6528 permissible prefix) provides the observable guaranted to be honored by
6529 the system allocator (malloc). This is a static value that can be used
6530 in user storage pools based on malloc either to reject allocation
6531 with alignment too large or to enable a realignment circuitry if the
6532 alignment request is larger than this value.
6533
6534 @node Target_Name
6535 @unnumberedsec Target_Name
6536 @findex Target_Name
6537 @noindent
6538 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6539 prefix) provides a static string value that identifies the target
6540 for the current compilation. For GCC implementations, this is the
6541 standard gcc target name without the terminating slash (for
6542 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6543
6544 @node Tick
6545 @unnumberedsec Tick
6546 @findex Tick
6547 @noindent
6548 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6549 provides the same value as @code{System.Tick},
6550
6551 @node To_Address
6552 @unnumberedsec To_Address
6553 @findex To_Address
6554 @noindent
6555 The @code{System'To_Address}
6556 (@code{System} is the only permissible prefix)
6557 denotes a function identical to
6558 @code{System.Storage_Elements.To_Address} except that
6559 it is a static attribute. This means that if its argument is
6560 a static expression, then the result of the attribute is a
6561 static expression. The result is that such an expression can be
6562 used in contexts (e.g.@: preelaborable packages) which require a
6563 static expression and where the function call could not be used
6564 (since the function call is always non-static, even if its
6565 argument is static).
6566
6567 @node Type_Class
6568 @unnumberedsec Type_Class
6569 @findex Type_Class
6570 @noindent
6571 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6572 the value of the type class for the full type of @var{type}. If
6573 @var{type} is a generic formal type, the value is the value for the
6574 corresponding actual subtype. The value of this attribute is of type
6575 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6576
6577 @smallexample @c ada
6578 type Type_Class is
6579 (Type_Class_Enumeration,
6580 Type_Class_Integer,
6581 Type_Class_Fixed_Point,
6582 Type_Class_Floating_Point,
6583 Type_Class_Array,
6584 Type_Class_Record,
6585 Type_Class_Access,
6586 Type_Class_Task,
6587 Type_Class_Address);
6588 @end smallexample
6589
6590 @noindent
6591 Protected types yield the value @code{Type_Class_Task}, which thus
6592 applies to all concurrent types. This attribute is designed to
6593 be compatible with the DEC Ada 83 attribute of the same name.
6594
6595 @node UET_Address
6596 @unnumberedsec UET_Address
6597 @findex UET_Address
6598 @noindent
6599 The @code{UET_Address} attribute can only be used for a prefix which
6600 denotes a library package. It yields the address of the unit exception
6601 table when zero cost exception handling is used. This attribute is
6602 intended only for use within the GNAT implementation. See the unit
6603 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6604 for details on how this attribute is used in the implementation.
6605
6606 @node Unconstrained_Array
6607 @unnumberedsec Unconstrained_Array
6608 @findex Unconstrained_Array
6609 @noindent
6610 The @code{Unconstrained_Array} attribute can be used with a prefix that
6611 denotes any type or subtype. It is a static attribute that yields
6612 @code{True} if the prefix designates an unconstrained array,
6613 and @code{False} otherwise. In a generic instance, the result is
6614 still static, and yields the result of applying this test to the
6615 generic actual.
6616
6617 @node Universal_Literal_String
6618 @unnumberedsec Universal_Literal_String
6619 @cindex Named numbers, representation of
6620 @findex Universal_Literal_String
6621 @noindent
6622 The prefix of @code{Universal_Literal_String} must be a named
6623 number. The static result is the string consisting of the characters of
6624 the number as defined in the original source. This allows the user
6625 program to access the actual text of named numbers without intermediate
6626 conversions and without the need to enclose the strings in quotes (which
6627 would preclude their use as numbers).
6628
6629 For example, the following program prints the first 50 digits of pi:
6630
6631 @smallexample @c ada
6632 with Text_IO; use Text_IO;
6633 with Ada.Numerics;
6634 procedure Pi is
6635 begin
6636 Put (Ada.Numerics.Pi'Universal_Literal_String);
6637 end;
6638 @end smallexample
6639
6640 @node Unrestricted_Access
6641 @unnumberedsec Unrestricted_Access
6642 @cindex @code{Access}, unrestricted
6643 @findex Unrestricted_Access
6644 @noindent
6645 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6646 except that all accessibility and aliased view checks are omitted. This
6647 is a user-beware attribute. It is similar to
6648 @code{Address}, for which it is a desirable replacement where the value
6649 desired is an access type. In other words, its effect is identical to
6650 first applying the @code{Address} attribute and then doing an unchecked
6651 conversion to a desired access type. In GNAT, but not necessarily in
6652 other implementations, the use of static chains for inner level
6653 subprograms means that @code{Unrestricted_Access} applied to a
6654 subprogram yields a value that can be called as long as the subprogram
6655 is in scope (normal Ada accessibility rules restrict this usage).
6656
6657 It is possible to use @code{Unrestricted_Access} for any type, but care
6658 must be exercised if it is used to create pointers to unconstrained
6659 objects. In this case, the resulting pointer has the same scope as the
6660 context of the attribute, and may not be returned to some enclosing
6661 scope. For instance, a function cannot use @code{Unrestricted_Access}
6662 to create a unconstrained pointer and then return that value to the
6663 caller.
6664
6665 @node VADS_Size
6666 @unnumberedsec VADS_Size
6667 @cindex @code{Size}, VADS compatibility
6668 @findex VADS_Size
6669 @noindent
6670 The @code{'VADS_Size} attribute is intended to make it easier to port
6671 legacy code which relies on the semantics of @code{'Size} as implemented
6672 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6673 same semantic interpretation. In particular, @code{'VADS_Size} applied
6674 to a predefined or other primitive type with no Size clause yields the
6675 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6676 typical machines). In addition @code{'VADS_Size} applied to an object
6677 gives the result that would be obtained by applying the attribute to
6678 the corresponding type.
6679
6680 @node Value_Size
6681 @unnumberedsec Value_Size
6682 @cindex @code{Size}, setting for not-first subtype
6683 @findex Value_Size
6684 @code{@var{type}'Value_Size} is the number of bits required to represent
6685 a value of the given subtype. It is the same as @code{@var{type}'Size},
6686 but, unlike @code{Size}, may be set for non-first subtypes.
6687
6688 @node Wchar_T_Size
6689 @unnumberedsec Wchar_T_Size
6690 @findex Wchar_T_Size
6691 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6692 prefix) provides the size in bits of the C @code{wchar_t} type
6693 primarily for constructing the definition of this type in
6694 package @code{Interfaces.C}.
6695
6696 @node Word_Size
6697 @unnumberedsec Word_Size
6698 @findex Word_Size
6699 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6700 prefix) provides the value @code{System.Word_Size}.
6701
6702 @c ------------------------
6703 @node Implementation Advice
6704 @chapter Implementation Advice
6705 @noindent
6706 The main text of the Ada Reference Manual describes the required
6707 behavior of all Ada compilers, and the GNAT compiler conforms to
6708 these requirements.
6709
6710 In addition, there are sections throughout the Ada Reference Manual headed
6711 by the phrase ``Implementation advice''. These sections are not normative,
6712 i.e., they do not specify requirements that all compilers must
6713 follow. Rather they provide advice on generally desirable behavior. You
6714 may wonder why they are not requirements. The most typical answer is
6715 that they describe behavior that seems generally desirable, but cannot
6716 be provided on all systems, or which may be undesirable on some systems.
6717
6718 As far as practical, GNAT follows the implementation advice sections in
6719 the Ada Reference Manual. This chapter contains a table giving the
6720 reference manual section number, paragraph number and several keywords
6721 for each advice. Each entry consists of the text of the advice followed
6722 by the GNAT interpretation of this advice. Most often, this simply says
6723 ``followed'', which means that GNAT follows the advice. However, in a
6724 number of cases, GNAT deliberately deviates from this advice, in which
6725 case the text describes what GNAT does and why.
6726
6727 @cindex Error detection
6728 @unnumberedsec 1.1.3(20): Error Detection
6729 @sp 1
6730 @cartouche
6731 If an implementation detects the use of an unsupported Specialized Needs
6732 Annex feature at run time, it should raise @code{Program_Error} if
6733 feasible.
6734 @end cartouche
6735 Not relevant. All specialized needs annex features are either supported,
6736 or diagnosed at compile time.
6737
6738 @cindex Child Units
6739 @unnumberedsec 1.1.3(31): Child Units
6740 @sp 1
6741 @cartouche
6742 If an implementation wishes to provide implementation-defined
6743 extensions to the functionality of a language-defined library unit, it
6744 should normally do so by adding children to the library unit.
6745 @end cartouche
6746 Followed.
6747
6748 @cindex Bounded errors
6749 @unnumberedsec 1.1.5(12): Bounded Errors
6750 @sp 1
6751 @cartouche
6752 If an implementation detects a bounded error or erroneous
6753 execution, it should raise @code{Program_Error}.
6754 @end cartouche
6755 Followed in all cases in which the implementation detects a bounded
6756 error or erroneous execution. Not all such situations are detected at
6757 runtime.
6758
6759 @cindex Pragmas
6760 @unnumberedsec 2.8(16): Pragmas
6761 @sp 1
6762 @cartouche
6763 Normally, implementation-defined pragmas should have no semantic effect
6764 for error-free programs; that is, if the implementation-defined pragmas
6765 are removed from a working program, the program should still be legal,
6766 and should still have the same semantics.
6767 @end cartouche
6768 The following implementation defined pragmas are exceptions to this
6769 rule:
6770
6771 @table @code
6772 @item Abort_Defer
6773 Affects semantics
6774 @item Ada_83
6775 Affects legality
6776 @item Assert
6777 Affects semantics
6778 @item CPP_Class
6779 Affects semantics
6780 @item CPP_Constructor
6781 Affects semantics
6782 @item Debug
6783 Affects semantics
6784 @item Interface_Name
6785 Affects semantics
6786 @item Machine_Attribute
6787 Affects semantics
6788 @item Unimplemented_Unit
6789 Affects legality
6790 @item Unchecked_Union
6791 Affects semantics
6792 @end table
6793
6794 @noindent
6795 In each of the above cases, it is essential to the purpose of the pragma
6796 that this advice not be followed. For details see the separate section
6797 on implementation defined pragmas.
6798
6799 @unnumberedsec 2.8(17-19): Pragmas
6800 @sp 1
6801 @cartouche
6802 Normally, an implementation should not define pragmas that can
6803 make an illegal program legal, except as follows:
6804 @end cartouche
6805 @sp 1
6806 @cartouche
6807 A pragma used to complete a declaration, such as a pragma @code{Import};
6808 @end cartouche
6809 @sp 1
6810 @cartouche
6811 A pragma used to configure the environment by adding, removing, or
6812 replacing @code{library_items}.
6813 @end cartouche
6814 See response to paragraph 16 of this same section.
6815
6816 @cindex Character Sets
6817 @cindex Alternative Character Sets
6818 @unnumberedsec 3.5.2(5): Alternative Character Sets
6819 @sp 1
6820 @cartouche
6821 If an implementation supports a mode with alternative interpretations
6822 for @code{Character} and @code{Wide_Character}, the set of graphic
6823 characters of @code{Character} should nevertheless remain a proper
6824 subset of the set of graphic characters of @code{Wide_Character}. Any
6825 character set ``localizations'' should be reflected in the results of
6826 the subprograms defined in the language-defined package
6827 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6828 an alternative interpretation of @code{Character}, the implementation should
6829 also support a corresponding change in what is a legal
6830 @code{identifier_letter}.
6831 @end cartouche
6832 Not all wide character modes follow this advice, in particular the JIS
6833 and IEC modes reflect standard usage in Japan, and in these encoding,
6834 the upper half of the Latin-1 set is not part of the wide-character
6835 subset, since the most significant bit is used for wide character
6836 encoding. However, this only applies to the external forms. Internally
6837 there is no such restriction.
6838
6839 @cindex Integer types
6840 @unnumberedsec 3.5.4(28): Integer Types
6841
6842 @sp 1
6843 @cartouche
6844 An implementation should support @code{Long_Integer} in addition to
6845 @code{Integer} if the target machine supports 32-bit (or longer)
6846 arithmetic. No other named integer subtypes are recommended for package
6847 @code{Standard}. Instead, appropriate named integer subtypes should be
6848 provided in the library package @code{Interfaces} (see B.2).
6849 @end cartouche
6850 @code{Long_Integer} is supported. Other standard integer types are supported
6851 so this advice is not fully followed. These types
6852 are supported for convenient interface to C, and so that all hardware
6853 types of the machine are easily available.
6854 @unnumberedsec 3.5.4(29): Integer Types
6855
6856 @sp 1
6857 @cartouche
6858 An implementation for a two's complement machine should support
6859 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6860 implementation should support a non-binary modules up to @code{Integer'Last}.
6861 @end cartouche
6862 Followed.
6863
6864 @cindex Enumeration values
6865 @unnumberedsec 3.5.5(8): Enumeration Values
6866 @sp 1
6867 @cartouche
6868 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6869 subtype, if the value of the operand does not correspond to the internal
6870 code for any enumeration literal of its type (perhaps due to an
6871 un-initialized variable), then the implementation should raise
6872 @code{Program_Error}. This is particularly important for enumeration
6873 types with noncontiguous internal codes specified by an
6874 enumeration_representation_clause.
6875 @end cartouche
6876 Followed.
6877
6878 @cindex Float types
6879 @unnumberedsec 3.5.7(17): Float Types
6880 @sp 1
6881 @cartouche
6882 An implementation should support @code{Long_Float} in addition to
6883 @code{Float} if the target machine supports 11 or more digits of
6884 precision. No other named floating point subtypes are recommended for
6885 package @code{Standard}. Instead, appropriate named floating point subtypes
6886 should be provided in the library package @code{Interfaces} (see B.2).
6887 @end cartouche
6888 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6889 former provides improved compatibility with other implementations
6890 supporting this type. The latter corresponds to the highest precision
6891 floating-point type supported by the hardware. On most machines, this
6892 will be the same as @code{Long_Float}, but on some machines, it will
6893 correspond to the IEEE extended form. The notable case is all ia32
6894 (x86) implementations, where @code{Long_Long_Float} corresponds to
6895 the 80-bit extended precision format supported in hardware on this
6896 processor. Note that the 128-bit format on SPARC is not supported,
6897 since this is a software rather than a hardware format.
6898
6899 @cindex Multidimensional arrays
6900 @cindex Arrays, multidimensional
6901 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6902 @sp 1
6903 @cartouche
6904 An implementation should normally represent multidimensional arrays in
6905 row-major order, consistent with the notation used for multidimensional
6906 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6907 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6908 column-major order should be used instead (see B.5, ``Interfacing with
6909 Fortran'').
6910 @end cartouche
6911 Followed.
6912
6913 @findex Duration'Small
6914 @unnumberedsec 9.6(30-31): Duration'Small
6915 @sp 1
6916 @cartouche
6917 Whenever possible in an implementation, the value of @code{Duration'Small}
6918 should be no greater than 100 microseconds.
6919 @end cartouche
6920 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6921
6922 @sp 1
6923 @cartouche
6924 The time base for @code{delay_relative_statements} should be monotonic;
6925 it need not be the same time base as used for @code{Calendar.Clock}.
6926 @end cartouche
6927 Followed.
6928
6929 @unnumberedsec 10.2.1(12): Consistent Representation
6930 @sp 1
6931 @cartouche
6932 In an implementation, a type declared in a pre-elaborated package should
6933 have the same representation in every elaboration of a given version of
6934 the package, whether the elaborations occur in distinct executions of
6935 the same program, or in executions of distinct programs or partitions
6936 that include the given version.
6937 @end cartouche
6938 Followed, except in the case of tagged types. Tagged types involve
6939 implicit pointers to a local copy of a dispatch table, and these pointers
6940 have representations which thus depend on a particular elaboration of the
6941 package. It is not easy to see how it would be possible to follow this
6942 advice without severely impacting efficiency of execution.
6943
6944 @cindex Exception information
6945 @unnumberedsec 11.4.1(19): Exception Information
6946 @sp 1
6947 @cartouche
6948 @code{Exception_Message} by default and @code{Exception_Information}
6949 should produce information useful for
6950 debugging. @code{Exception_Message} should be short, about one
6951 line. @code{Exception_Information} can be long. @code{Exception_Message}
6952 should not include the
6953 @code{Exception_Name}. @code{Exception_Information} should include both
6954 the @code{Exception_Name} and the @code{Exception_Message}.
6955 @end cartouche
6956 Followed. For each exception that doesn't have a specified
6957 @code{Exception_Message}, the compiler generates one containing the location
6958 of the raise statement. This location has the form ``file:line'', where
6959 file is the short file name (without path information) and line is the line
6960 number in the file. Note that in the case of the Zero Cost Exception
6961 mechanism, these messages become redundant with the Exception_Information that
6962 contains a full backtrace of the calling sequence, so they are disabled.
6963 To disable explicitly the generation of the source location message, use the
6964 Pragma @code{Discard_Names}.
6965
6966 @cindex Suppression of checks
6967 @cindex Checks, suppression of
6968 @unnumberedsec 11.5(28): Suppression of Checks
6969 @sp 1
6970 @cartouche
6971 The implementation should minimize the code executed for checks that
6972 have been suppressed.
6973 @end cartouche
6974 Followed.
6975
6976 @cindex Representation clauses
6977 @unnumberedsec 13.1 (21-24): Representation Clauses
6978 @sp 1
6979 @cartouche
6980 The recommended level of support for all representation items is
6981 qualified as follows:
6982 @end cartouche
6983 @sp 1
6984 @cartouche
6985 An implementation need not support representation items containing
6986 non-static expressions, except that an implementation should support a
6987 representation item for a given entity if each non-static expression in
6988 the representation item is a name that statically denotes a constant
6989 declared before the entity.
6990 @end cartouche
6991 Followed. In fact, GNAT goes beyond the recommended level of support
6992 by allowing nonstatic expressions in some representation clauses even
6993 without the need to declare constants initialized with the values of
6994 such expressions.
6995 For example:
6996
6997 @smallexample @c ada
6998 X : Integer;
6999 Y : Float;
7000 for Y'Address use X'Address;>>
7001 @end smallexample
7002
7003 @sp 1
7004 @cartouche
7005 An implementation need not support a specification for the @code{Size}
7006 for a given composite subtype, nor the size or storage place for an
7007 object (including a component) of a given composite subtype, unless the
7008 constraints on the subtype and its composite subcomponents (if any) are
7009 all static constraints.
7010 @end cartouche
7011 Followed. Size Clauses are not permitted on non-static components, as
7012 described above.
7013
7014 @sp 1
7015 @cartouche
7016 An aliased component, or a component whose type is by-reference, should
7017 always be allocated at an addressable location.
7018 @end cartouche
7019 Followed.
7020
7021 @cindex Packed types
7022 @unnumberedsec 13.2(6-8): Packed Types
7023 @sp 1
7024 @cartouche
7025 If a type is packed, then the implementation should try to minimize
7026 storage allocated to objects of the type, possibly at the expense of
7027 speed of accessing components, subject to reasonable complexity in
7028 addressing calculations.
7029 @end cartouche
7030 @sp 1
7031 @cartouche
7032 The recommended level of support pragma @code{Pack} is:
7033
7034 For a packed record type, the components should be packed as tightly as
7035 possible subject to the Sizes of the component subtypes, and subject to
7036 any @code{record_representation_clause} that applies to the type; the
7037 implementation may, but need not, reorder components or cross aligned
7038 word boundaries to improve the packing. A component whose @code{Size} is
7039 greater than the word size may be allocated an integral number of words.
7040 @end cartouche
7041 Followed. Tight packing of arrays is supported for all component sizes
7042 up to 64-bits. If the array component size is 1 (that is to say, if
7043 the component is a boolean type or an enumeration type with two values)
7044 then values of the type are implicitly initialized to zero. This
7045 happens both for objects of the packed type, and for objects that have a
7046 subcomponent of the packed type.
7047
7048 @sp 1
7049 @cartouche
7050 An implementation should support Address clauses for imported
7051 subprograms.
7052 @end cartouche
7053 Followed.
7054 @cindex @code{Address} clauses
7055 @unnumberedsec 13.3(14-19): Address Clauses
7056
7057 @sp 1
7058 @cartouche
7059 For an array @var{X}, @code{@var{X}'Address} should point at the first
7060 component of the array, and not at the array bounds.
7061 @end cartouche
7062 Followed.
7063
7064 @sp 1
7065 @cartouche
7066 The recommended level of support for the @code{Address} attribute is:
7067
7068 @code{@var{X}'Address} should produce a useful result if @var{X} is an
7069 object that is aliased or of a by-reference type, or is an entity whose
7070 @code{Address} has been specified.
7071 @end cartouche
7072 Followed. A valid address will be produced even if none of those
7073 conditions have been met. If necessary, the object is forced into
7074 memory to ensure the address is valid.
7075
7076 @sp 1
7077 @cartouche
7078 An implementation should support @code{Address} clauses for imported
7079 subprograms.
7080 @end cartouche
7081 Followed.
7082
7083 @sp 1
7084 @cartouche
7085 Objects (including subcomponents) that are aliased or of a by-reference
7086 type should be allocated on storage element boundaries.
7087 @end cartouche
7088 Followed.
7089
7090 @sp 1
7091 @cartouche
7092 If the @code{Address} of an object is specified, or it is imported or exported,
7093 then the implementation should not perform optimizations based on
7094 assumptions of no aliases.
7095 @end cartouche
7096 Followed.
7097
7098 @cindex @code{Alignment} clauses
7099 @unnumberedsec 13.3(29-35): Alignment Clauses
7100 @sp 1
7101 @cartouche
7102 The recommended level of support for the @code{Alignment} attribute for
7103 subtypes is:
7104
7105 An implementation should support specified Alignments that are factors
7106 and multiples of the number of storage elements per word, subject to the
7107 following:
7108 @end cartouche
7109 Followed.
7110
7111 @sp 1
7112 @cartouche
7113 An implementation need not support specified @code{Alignment}s for
7114 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
7115 loaded and stored by available machine instructions.
7116 @end cartouche
7117 Followed.
7118
7119 @sp 1
7120 @cartouche
7121 An implementation need not support specified @code{Alignment}s that are
7122 greater than the maximum @code{Alignment} the implementation ever returns by
7123 default.
7124 @end cartouche
7125 Followed.
7126
7127 @sp 1
7128 @cartouche
7129 The recommended level of support for the @code{Alignment} attribute for
7130 objects is:
7131
7132 Same as above, for subtypes, but in addition:
7133 @end cartouche
7134 Followed.
7135
7136 @sp 1
7137 @cartouche
7138 For stand-alone library-level objects of statically constrained
7139 subtypes, the implementation should support all @code{Alignment}s
7140 supported by the target linker. For example, page alignment is likely to
7141 be supported for such objects, but not for subtypes.
7142 @end cartouche
7143 Followed.
7144
7145 @cindex @code{Size} clauses
7146 @unnumberedsec 13.3(42-43): Size Clauses
7147 @sp 1
7148 @cartouche
7149 The recommended level of support for the @code{Size} attribute of
7150 objects is:
7151
7152 A @code{Size} clause should be supported for an object if the specified
7153 @code{Size} is at least as large as its subtype's @code{Size}, and
7154 corresponds to a size in storage elements that is a multiple of the
7155 object's @code{Alignment} (if the @code{Alignment} is nonzero).
7156 @end cartouche
7157 Followed.
7158
7159 @unnumberedsec 13.3(50-56): Size Clauses
7160 @sp 1
7161 @cartouche
7162 If the @code{Size} of a subtype is specified, and allows for efficient
7163 independent addressability (see 9.10) on the target architecture, then
7164 the @code{Size} of the following objects of the subtype should equal the
7165 @code{Size} of the subtype:
7166
7167 Aliased objects (including components).
7168 @end cartouche
7169 Followed.
7170
7171 @sp 1
7172 @cartouche
7173 @code{Size} clause on a composite subtype should not affect the
7174 internal layout of components.
7175 @end cartouche
7176 Followed. But note that this can be overridden by use of the implementation
7177 pragma Implicit_Packing in the case of packed arrays.
7178
7179 @sp 1
7180 @cartouche
7181 The recommended level of support for the @code{Size} attribute of subtypes is:
7182 @end cartouche
7183 @sp 1
7184 @cartouche
7185 The @code{Size} (if not specified) of a static discrete or fixed point
7186 subtype should be the number of bits needed to represent each value
7187 belonging to the subtype using an unbiased representation, leaving space
7188 for a sign bit only if the subtype contains negative values. If such a
7189 subtype is a first subtype, then an implementation should support a
7190 specified @code{Size} for it that reflects this representation.
7191 @end cartouche
7192 Followed.
7193
7194 @sp 1
7195 @cartouche
7196 For a subtype implemented with levels of indirection, the @code{Size}
7197 should include the size of the pointers, but not the size of what they
7198 point at.
7199 @end cartouche
7200 Followed.
7201
7202 @cindex @code{Component_Size} clauses
7203 @unnumberedsec 13.3(71-73): Component Size Clauses
7204 @sp 1
7205 @cartouche
7206 The recommended level of support for the @code{Component_Size}
7207 attribute is:
7208 @end cartouche
7209 @sp 1
7210 @cartouche
7211 An implementation need not support specified @code{Component_Sizes} that are
7212 less than the @code{Size} of the component subtype.
7213 @end cartouche
7214 Followed.
7215
7216 @sp 1
7217 @cartouche
7218 An implementation should support specified @code{Component_Size}s that
7219 are factors and multiples of the word size. For such
7220 @code{Component_Size}s, the array should contain no gaps between
7221 components. For other @code{Component_Size}s (if supported), the array
7222 should contain no gaps between components when packing is also
7223 specified; the implementation should forbid this combination in cases
7224 where it cannot support a no-gaps representation.
7225 @end cartouche
7226 Followed.
7227
7228 @cindex Enumeration representation clauses
7229 @cindex Representation clauses, enumeration
7230 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7231 @sp 1
7232 @cartouche
7233 The recommended level of support for enumeration representation clauses
7234 is:
7235
7236 An implementation need not support enumeration representation clauses
7237 for boolean types, but should at minimum support the internal codes in
7238 the range @code{System.Min_Int.System.Max_Int}.
7239 @end cartouche
7240 Followed.
7241
7242 @cindex Record representation clauses
7243 @cindex Representation clauses, records
7244 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7245 @sp 1
7246 @cartouche
7247 The recommended level of support for
7248 @*@code{record_representation_clauses} is:
7249
7250 An implementation should support storage places that can be extracted
7251 with a load, mask, shift sequence of machine code, and set with a load,
7252 shift, mask, store sequence, given the available machine instructions
7253 and run-time model.
7254 @end cartouche
7255 Followed.
7256
7257 @sp 1
7258 @cartouche
7259 A storage place should be supported if its size is equal to the
7260 @code{Size} of the component subtype, and it starts and ends on a
7261 boundary that obeys the @code{Alignment} of the component subtype.
7262 @end cartouche
7263 Followed.
7264
7265 @sp 1
7266 @cartouche
7267 If the default bit ordering applies to the declaration of a given type,
7268 then for a component whose subtype's @code{Size} is less than the word
7269 size, any storage place that does not cross an aligned word boundary
7270 should be supported.
7271 @end cartouche
7272 Followed.
7273
7274 @sp 1
7275 @cartouche
7276 An implementation may reserve a storage place for the tag field of a
7277 tagged type, and disallow other components from overlapping that place.
7278 @end cartouche
7279 Followed. The storage place for the tag field is the beginning of the tagged
7280 record, and its size is Address'Size. GNAT will reject an explicit component
7281 clause for the tag field.
7282
7283 @sp 1
7284 @cartouche
7285 An implementation need not support a @code{component_clause} for a
7286 component of an extension part if the storage place is not after the
7287 storage places of all components of the parent type, whether or not
7288 those storage places had been specified.
7289 @end cartouche
7290 Followed. The above advice on record representation clauses is followed,
7291 and all mentioned features are implemented.
7292
7293 @cindex Storage place attributes
7294 @unnumberedsec 13.5.2(5): Storage Place Attributes
7295 @sp 1
7296 @cartouche
7297 If a component is represented using some form of pointer (such as an
7298 offset) to the actual data of the component, and this data is contiguous
7299 with the rest of the object, then the storage place attributes should
7300 reflect the place of the actual data, not the pointer. If a component is
7301 allocated discontinuously from the rest of the object, then a warning
7302 should be generated upon reference to one of its storage place
7303 attributes.
7304 @end cartouche
7305 Followed. There are no such components in GNAT@.
7306
7307 @cindex Bit ordering
7308 @unnumberedsec 13.5.3(7-8): Bit Ordering
7309 @sp 1
7310 @cartouche
7311 The recommended level of support for the non-default bit ordering is:
7312 @end cartouche
7313 @sp 1
7314 @cartouche
7315 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7316 should support the non-default bit ordering in addition to the default
7317 bit ordering.
7318 @end cartouche
7319 Followed. Word size does not equal storage size in this implementation.
7320 Thus non-default bit ordering is not supported.
7321
7322 @cindex @code{Address}, as private type
7323 @unnumberedsec 13.7(37): Address as Private
7324 @sp 1
7325 @cartouche
7326 @code{Address} should be of a private type.
7327 @end cartouche
7328 Followed.
7329
7330 @cindex Operations, on @code{Address}
7331 @cindex @code{Address}, operations of
7332 @unnumberedsec 13.7.1(16): Address Operations
7333 @sp 1
7334 @cartouche
7335 Operations in @code{System} and its children should reflect the target
7336 environment semantics as closely as is reasonable. For example, on most
7337 machines, it makes sense for address arithmetic to ``wrap around''.
7338 Operations that do not make sense should raise @code{Program_Error}.
7339 @end cartouche
7340 Followed. Address arithmetic is modular arithmetic that wraps around. No
7341 operation raises @code{Program_Error}, since all operations make sense.
7342
7343 @cindex Unchecked conversion
7344 @unnumberedsec 13.9(14-17): Unchecked Conversion
7345 @sp 1
7346 @cartouche
7347 The @code{Size} of an array object should not include its bounds; hence,
7348 the bounds should not be part of the converted data.
7349 @end cartouche
7350 Followed.
7351
7352 @sp 1
7353 @cartouche
7354 The implementation should not generate unnecessary run-time checks to
7355 ensure that the representation of @var{S} is a representation of the
7356 target type. It should take advantage of the permission to return by
7357 reference when possible. Restrictions on unchecked conversions should be
7358 avoided unless required by the target environment.
7359 @end cartouche
7360 Followed. There are no restrictions on unchecked conversion. A warning is
7361 generated if the source and target types do not have the same size since
7362 the semantics in this case may be target dependent.
7363
7364 @sp 1
7365 @cartouche
7366 The recommended level of support for unchecked conversions is:
7367 @end cartouche
7368 @sp 1
7369 @cartouche
7370 Unchecked conversions should be supported and should be reversible in
7371 the cases where this clause defines the result. To enable meaningful use
7372 of unchecked conversion, a contiguous representation should be used for
7373 elementary subtypes, for statically constrained array subtypes whose
7374 component subtype is one of the subtypes described in this paragraph,
7375 and for record subtypes without discriminants whose component subtypes
7376 are described in this paragraph.
7377 @end cartouche
7378 Followed.
7379
7380 @cindex Heap usage, implicit
7381 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7382 @sp 1
7383 @cartouche
7384 An implementation should document any cases in which it dynamically
7385 allocates heap storage for a purpose other than the evaluation of an
7386 allocator.
7387 @end cartouche
7388 Followed, the only other points at which heap storage is dynamically
7389 allocated are as follows:
7390
7391 @itemize @bullet
7392 @item
7393 At initial elaboration time, to allocate dynamically sized global
7394 objects.
7395
7396 @item
7397 To allocate space for a task when a task is created.
7398
7399 @item
7400 To extend the secondary stack dynamically when needed. The secondary
7401 stack is used for returning variable length results.
7402 @end itemize
7403
7404 @sp 1
7405 @cartouche
7406 A default (implementation-provided) storage pool for an
7407 access-to-constant type should not have overhead to support deallocation of
7408 individual objects.
7409 @end cartouche
7410 Followed.
7411
7412 @sp 1
7413 @cartouche
7414 A storage pool for an anonymous access type should be created at the
7415 point of an allocator for the type, and be reclaimed when the designated
7416 object becomes inaccessible.
7417 @end cartouche
7418 Followed.
7419
7420 @cindex Unchecked deallocation
7421 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7422 @sp 1
7423 @cartouche
7424 For a standard storage pool, @code{Free} should actually reclaim the
7425 storage.
7426 @end cartouche
7427 Followed.
7428
7429 @cindex Stream oriented attributes
7430 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7431 @sp 1
7432 @cartouche
7433 If a stream element is the same size as a storage element, then the
7434 normal in-memory representation should be used by @code{Read} and
7435 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7436 should use the smallest number of stream elements needed to represent
7437 all values in the base range of the scalar type.
7438 @end cartouche
7439
7440 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7441 which specifies using the size of the first subtype.
7442 However, such an implementation is based on direct binary
7443 representations and is therefore target- and endianness-dependent.
7444 To address this issue, GNAT also supplies an alternate implementation
7445 of the stream attributes @code{Read} and @code{Write},
7446 which uses the target-independent XDR standard representation
7447 for scalar types.
7448 @cindex XDR representation
7449 @cindex @code{Read} attribute
7450 @cindex @code{Write} attribute
7451 @cindex Stream oriented attributes
7452 The XDR implementation is provided as an alternative body of the
7453 @code{System.Stream_Attributes} package, in the file
7454 @file{s-stratt-xdr.adb} in the GNAT library.
7455 There is no @file{s-stratt-xdr.ads} file.
7456 In order to install the XDR implementation, do the following:
7457 @enumerate
7458 @item Replace the default implementation of the
7459 @code{System.Stream_Attributes} package with the XDR implementation.
7460 For example on a Unix platform issue the commands:
7461 @smallexample
7462 $ mv s-stratt.adb s-stratt-default.adb
7463 $ mv s-stratt-xdr.adb s-stratt.adb
7464 @end smallexample
7465
7466 @item
7467 Rebuild the GNAT run-time library as documented in
7468 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7469 @end enumerate
7470
7471 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7472 @sp 1
7473 @cartouche
7474 If an implementation provides additional named predefined integer types,
7475 then the names should end with @samp{Integer} as in
7476 @samp{Long_Integer}. If an implementation provides additional named
7477 predefined floating point types, then the names should end with
7478 @samp{Float} as in @samp{Long_Float}.
7479 @end cartouche
7480 Followed.
7481
7482 @findex Ada.Characters.Handling
7483 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7484 @sp 1
7485 @cartouche
7486 If an implementation provides a localized definition of @code{Character}
7487 or @code{Wide_Character}, then the effects of the subprograms in
7488 @code{Characters.Handling} should reflect the localizations. See also
7489 3.5.2.
7490 @end cartouche
7491 Followed. GNAT provides no such localized definitions.
7492
7493 @cindex Bounded-length strings
7494 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7495 @sp 1
7496 @cartouche
7497 Bounded string objects should not be implemented by implicit pointers
7498 and dynamic allocation.
7499 @end cartouche
7500 Followed. No implicit pointers or dynamic allocation are used.
7501
7502 @cindex Random number generation
7503 @unnumberedsec A.5.2(46-47): Random Number Generation
7504 @sp 1
7505 @cartouche
7506 Any storage associated with an object of type @code{Generator} should be
7507 reclaimed on exit from the scope of the object.
7508 @end cartouche
7509 Followed.
7510
7511 @sp 1
7512 @cartouche
7513 If the generator period is sufficiently long in relation to the number
7514 of distinct initiator values, then each possible value of
7515 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7516 random numbers that does not, in a practical sense, overlap the sequence
7517 initiated by any other value. If this is not possible, then the mapping
7518 between initiator values and generator states should be a rapidly
7519 varying function of the initiator value.
7520 @end cartouche
7521 Followed. The generator period is sufficiently long for the first
7522 condition here to hold true.
7523
7524 @findex Get_Immediate
7525 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7526 @sp 1
7527 @cartouche
7528 The @code{Get_Immediate} procedures should be implemented with
7529 unbuffered input. For a device such as a keyboard, input should be
7530 @dfn{available} if a key has already been typed, whereas for a disk
7531 file, input should always be available except at end of file. For a file
7532 associated with a keyboard-like device, any line-editing features of the
7533 underlying operating system should be disabled during the execution of
7534 @code{Get_Immediate}.
7535 @end cartouche
7536 Followed on all targets except VxWorks. For VxWorks, there is no way to
7537 provide this functionality that does not result in the input buffer being
7538 flushed before the @code{Get_Immediate} call. A special unit
7539 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7540 this functionality.
7541
7542 @findex Export
7543 @unnumberedsec B.1(39-41): Pragma @code{Export}
7544 @sp 1
7545 @cartouche
7546 If an implementation supports pragma @code{Export} to a given language,
7547 then it should also allow the main subprogram to be written in that
7548 language. It should support some mechanism for invoking the elaboration
7549 of the Ada library units included in the system, and for invoking the
7550 finalization of the environment task. On typical systems, the
7551 recommended mechanism is to provide two subprograms whose link names are
7552 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7553 elaboration code for library units. @code{adafinal} should contain the
7554 finalization code. These subprograms should have no effect the second
7555 and subsequent time they are called.
7556 @end cartouche
7557 Followed.
7558
7559 @sp 1
7560 @cartouche
7561 Automatic elaboration of pre-elaborated packages should be
7562 provided when pragma @code{Export} is supported.
7563 @end cartouche
7564 Followed when the main program is in Ada. If the main program is in a
7565 foreign language, then
7566 @code{adainit} must be called to elaborate pre-elaborated
7567 packages.
7568
7569 @sp 1
7570 @cartouche
7571 For each supported convention @var{L} other than @code{Intrinsic}, an
7572 implementation should support @code{Import} and @code{Export} pragmas
7573 for objects of @var{L}-compatible types and for subprograms, and pragma
7574 @code{Convention} for @var{L}-eligible types and for subprograms,
7575 presuming the other language has corresponding features. Pragma
7576 @code{Convention} need not be supported for scalar types.
7577 @end cartouche
7578 Followed.
7579
7580 @cindex Package @code{Interfaces}
7581 @findex Interfaces
7582 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7583 @sp 1
7584 @cartouche
7585 For each implementation-defined convention identifier, there should be a
7586 child package of package Interfaces with the corresponding name. This
7587 package should contain any declarations that would be useful for
7588 interfacing to the language (implementation) represented by the
7589 convention. Any declarations useful for interfacing to any language on
7590 the given hardware architecture should be provided directly in
7591 @code{Interfaces}.
7592 @end cartouche
7593 Followed. An additional package not defined
7594 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7595 for interfacing to C++.
7596
7597 @sp 1
7598 @cartouche
7599 An implementation supporting an interface to C, COBOL, or Fortran should
7600 provide the corresponding package or packages described in the following
7601 clauses.
7602 @end cartouche
7603 Followed. GNAT provides all the packages described in this section.
7604
7605 @cindex C, interfacing with
7606 @unnumberedsec B.3(63-71): Interfacing with C
7607 @sp 1
7608 @cartouche
7609 An implementation should support the following interface correspondences
7610 between Ada and C@.
7611 @end cartouche
7612 Followed.
7613
7614 @sp 1
7615 @cartouche
7616 An Ada procedure corresponds to a void-returning C function.
7617 @end cartouche
7618 Followed.
7619
7620 @sp 1
7621 @cartouche
7622 An Ada function corresponds to a non-void C function.
7623 @end cartouche
7624 Followed.
7625
7626 @sp 1
7627 @cartouche
7628 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7629 function.
7630 @end cartouche
7631 Followed.
7632
7633 @sp 1
7634 @cartouche
7635 An Ada @code{in} parameter of an access-to-object type with designated
7636 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7637 where @var{t} is the C type corresponding to the Ada type @var{T}.
7638 @end cartouche
7639 Followed.
7640
7641 @sp 1
7642 @cartouche
7643 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7644 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7645 argument to a C function, where @var{t} is the C type corresponding to
7646 the Ada type @var{T}. In the case of an elementary @code{out} or
7647 @code{in out} parameter, a pointer to a temporary copy is used to
7648 preserve by-copy semantics.
7649 @end cartouche
7650 Followed.
7651
7652 @sp 1
7653 @cartouche
7654 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7655 @code{@var{t}*} argument to a C function, where @var{t} is the C
7656 structure corresponding to the Ada type @var{T}.
7657 @end cartouche
7658 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7659 pragma, or Convention, or by explicitly specifying the mechanism for a given
7660 call using an extended import or export pragma.
7661
7662 @sp 1
7663 @cartouche
7664 An Ada parameter of an array type with component type @var{T}, of any
7665 mode, is passed as a @code{@var{t}*} argument to a C function, where
7666 @var{t} is the C type corresponding to the Ada type @var{T}.
7667 @end cartouche
7668 Followed.
7669
7670 @sp 1
7671 @cartouche
7672 An Ada parameter of an access-to-subprogram type is passed as a pointer
7673 to a C function whose prototype corresponds to the designated
7674 subprogram's specification.
7675 @end cartouche
7676 Followed.
7677
7678 @cindex COBOL, interfacing with
7679 @unnumberedsec B.4(95-98): Interfacing with COBOL
7680 @sp 1
7681 @cartouche
7682 An Ada implementation should support the following interface
7683 correspondences between Ada and COBOL@.
7684 @end cartouche
7685 Followed.
7686
7687 @sp 1
7688 @cartouche
7689 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7690 the COBOL type corresponding to @var{T}.
7691 @end cartouche
7692 Followed.
7693
7694 @sp 1
7695 @cartouche
7696 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7697 the corresponding COBOL type.
7698 @end cartouche
7699 Followed.
7700
7701 @sp 1
7702 @cartouche
7703 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7704 COBOL type corresponding to the Ada parameter type; for scalars, a local
7705 copy is used if necessary to ensure by-copy semantics.
7706 @end cartouche
7707 Followed.
7708
7709 @cindex Fortran, interfacing with
7710 @unnumberedsec B.5(22-26): Interfacing with Fortran
7711 @sp 1
7712 @cartouche
7713 An Ada implementation should support the following interface
7714 correspondences between Ada and Fortran:
7715 @end cartouche
7716 Followed.
7717
7718 @sp 1
7719 @cartouche
7720 An Ada procedure corresponds to a Fortran subroutine.
7721 @end cartouche
7722 Followed.
7723
7724 @sp 1
7725 @cartouche
7726 An Ada function corresponds to a Fortran function.
7727 @end cartouche
7728 Followed.
7729
7730 @sp 1
7731 @cartouche
7732 An Ada parameter of an elementary, array, or record type @var{T} is
7733 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7734 the Fortran type corresponding to the Ada type @var{T}, and where the
7735 INTENT attribute of the corresponding dummy argument matches the Ada
7736 formal parameter mode; the Fortran implementation's parameter passing
7737 conventions are used. For elementary types, a local copy is used if
7738 necessary to ensure by-copy semantics.
7739 @end cartouche
7740 Followed.
7741
7742 @sp 1
7743 @cartouche
7744 An Ada parameter of an access-to-subprogram type is passed as a
7745 reference to a Fortran procedure whose interface corresponds to the
7746 designated subprogram's specification.
7747 @end cartouche
7748 Followed.
7749
7750 @cindex Machine operations
7751 @unnumberedsec C.1(3-5): Access to Machine Operations
7752 @sp 1
7753 @cartouche
7754 The machine code or intrinsic support should allow access to all
7755 operations normally available to assembly language programmers for the
7756 target environment, including privileged instructions, if any.
7757 @end cartouche
7758 Followed.
7759
7760 @sp 1
7761 @cartouche
7762 The interfacing pragmas (see Annex B) should support interface to
7763 assembler; the default assembler should be associated with the
7764 convention identifier @code{Assembler}.
7765 @end cartouche
7766 Followed.
7767
7768 @sp 1
7769 @cartouche
7770 If an entity is exported to assembly language, then the implementation
7771 should allocate it at an addressable location, and should ensure that it
7772 is retained by the linking process, even if not otherwise referenced
7773 from the Ada code. The implementation should assume that any call to a
7774 machine code or assembler subprogram is allowed to read or update every
7775 object that is specified as exported.
7776 @end cartouche
7777 Followed.
7778
7779 @unnumberedsec C.1(10-16): Access to Machine Operations
7780 @sp 1
7781 @cartouche
7782 The implementation should ensure that little or no overhead is
7783 associated with calling intrinsic and machine-code subprograms.
7784 @end cartouche
7785 Followed for both intrinsics and machine-code subprograms.
7786
7787 @sp 1
7788 @cartouche
7789 It is recommended that intrinsic subprograms be provided for convenient
7790 access to any machine operations that provide special capabilities or
7791 efficiency and that are not otherwise available through the language
7792 constructs.
7793 @end cartouche
7794 Followed. A full set of machine operation intrinsic subprograms is provided.
7795
7796 @sp 1
7797 @cartouche
7798 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7799 swap, decrement and test, enqueue/dequeue.
7800 @end cartouche
7801 Followed on any target supporting such operations.
7802
7803 @sp 1
7804 @cartouche
7805 Standard numeric functions---e.g.@:, sin, log.
7806 @end cartouche
7807 Followed on any target supporting such operations.
7808
7809 @sp 1
7810 @cartouche
7811 String manipulation operations---e.g.@:, translate and test.
7812 @end cartouche
7813 Followed on any target supporting such operations.
7814
7815 @sp 1
7816 @cartouche
7817 Vector operations---e.g.@:, compare vector against thresholds.
7818 @end cartouche
7819 Followed on any target supporting such operations.
7820
7821 @sp 1
7822 @cartouche
7823 Direct operations on I/O ports.
7824 @end cartouche
7825 Followed on any target supporting such operations.
7826
7827 @cindex Interrupt support
7828 @unnumberedsec C.3(28): Interrupt Support
7829 @sp 1
7830 @cartouche
7831 If the @code{Ceiling_Locking} policy is not in effect, the
7832 implementation should provide means for the application to specify which
7833 interrupts are to be blocked during protected actions, if the underlying
7834 system allows for a finer-grain control of interrupt blocking.
7835 @end cartouche
7836 Followed. The underlying system does not allow for finer-grain control
7837 of interrupt blocking.
7838
7839 @cindex Protected procedure handlers
7840 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7841 @sp 1
7842 @cartouche
7843 Whenever possible, the implementation should allow interrupt handlers to
7844 be called directly by the hardware.
7845 @end cartouche
7846 @c SGI info:
7847 @ignore
7848 This is never possible under IRIX, so this is followed by default.
7849 @end ignore
7850 Followed on any target where the underlying operating system permits
7851 such direct calls.
7852
7853 @sp 1
7854 @cartouche
7855 Whenever practical, violations of any
7856 implementation-defined restrictions should be detected before run time.
7857 @end cartouche
7858 Followed. Compile time warnings are given when possible.
7859
7860 @cindex Package @code{Interrupts}
7861 @findex Interrupts
7862 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7863
7864 @sp 1
7865 @cartouche
7866 If implementation-defined forms of interrupt handler procedures are
7867 supported, such as protected procedures with parameters, then for each
7868 such form of a handler, a type analogous to @code{Parameterless_Handler}
7869 should be specified in a child package of @code{Interrupts}, with the
7870 same operations as in the predefined package Interrupts.
7871 @end cartouche
7872 Followed.
7873
7874 @cindex Pre-elaboration requirements
7875 @unnumberedsec C.4(14): Pre-elaboration Requirements
7876 @sp 1
7877 @cartouche
7878 It is recommended that pre-elaborated packages be implemented in such a
7879 way that there should be little or no code executed at run time for the
7880 elaboration of entities not already covered by the Implementation
7881 Requirements.
7882 @end cartouche
7883 Followed. Executable code is generated in some cases, e.g.@: loops
7884 to initialize large arrays.
7885
7886 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7887 @sp 1
7888 @cartouche
7889 If the pragma applies to an entity, then the implementation should
7890 reduce the amount of storage used for storing names associated with that
7891 entity.
7892 @end cartouche
7893 Followed.
7894
7895 @cindex Package @code{Task_Attributes}
7896 @findex Task_Attributes
7897 @unnumberedsec C.7.2(30): The Package Task_Attributes
7898 @sp 1
7899 @cartouche
7900 Some implementations are targeted to domains in which memory use at run
7901 time must be completely deterministic. For such implementations, it is
7902 recommended that the storage for task attributes will be pre-allocated
7903 statically and not from the heap. This can be accomplished by either
7904 placing restrictions on the number and the size of the task's
7905 attributes, or by using the pre-allocated storage for the first @var{N}
7906 attribute objects, and the heap for the others. In the latter case,
7907 @var{N} should be documented.
7908 @end cartouche
7909 Not followed. This implementation is not targeted to such a domain.
7910
7911 @cindex Locking Policies
7912 @unnumberedsec D.3(17): Locking Policies
7913
7914 @sp 1
7915 @cartouche
7916 The implementation should use names that end with @samp{_Locking} for
7917 locking policies defined by the implementation.
7918 @end cartouche
7919 Followed. A single implementation-defined locking policy is defined,
7920 whose name (@code{Inheritance_Locking}) follows this suggestion.
7921
7922 @cindex Entry queuing policies
7923 @unnumberedsec D.4(16): Entry Queuing Policies
7924 @sp 1
7925 @cartouche
7926 Names that end with @samp{_Queuing} should be used
7927 for all implementation-defined queuing policies.
7928 @end cartouche
7929 Followed. No such implementation-defined queuing policies exist.
7930
7931 @cindex Preemptive abort
7932 @unnumberedsec D.6(9-10): Preemptive Abort
7933 @sp 1
7934 @cartouche
7935 Even though the @code{abort_statement} is included in the list of
7936 potentially blocking operations (see 9.5.1), it is recommended that this
7937 statement be implemented in a way that never requires the task executing
7938 the @code{abort_statement} to block.
7939 @end cartouche
7940 Followed.
7941
7942 @sp 1
7943 @cartouche
7944 On a multi-processor, the delay associated with aborting a task on
7945 another processor should be bounded; the implementation should use
7946 periodic polling, if necessary, to achieve this.
7947 @end cartouche
7948 Followed.
7949
7950 @cindex Tasking restrictions
7951 @unnumberedsec D.7(21): Tasking Restrictions
7952 @sp 1
7953 @cartouche
7954 When feasible, the implementation should take advantage of the specified
7955 restrictions to produce a more efficient implementation.
7956 @end cartouche
7957 GNAT currently takes advantage of these restrictions by providing an optimized
7958 run time when the Ravenscar profile and the GNAT restricted run time set
7959 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7960 pragma @code{Profile (Restricted)} for more details.
7961
7962 @cindex Time, monotonic
7963 @unnumberedsec D.8(47-49): Monotonic Time
7964 @sp 1
7965 @cartouche
7966 When appropriate, implementations should provide configuration
7967 mechanisms to change the value of @code{Tick}.
7968 @end cartouche
7969 Such configuration mechanisms are not appropriate to this implementation
7970 and are thus not supported.
7971
7972 @sp 1
7973 @cartouche
7974 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7975 be implemented as transformations of the same time base.
7976 @end cartouche
7977 Followed.
7978
7979 @sp 1
7980 @cartouche
7981 It is recommended that the @dfn{best} time base which exists in
7982 the underlying system be available to the application through
7983 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7984 @end cartouche
7985 Followed.
7986
7987 @cindex Partition communication subsystem
7988 @cindex PCS
7989 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7990 @sp 1
7991 @cartouche
7992 Whenever possible, the PCS on the called partition should allow for
7993 multiple tasks to call the RPC-receiver with different messages and
7994 should allow them to block until the corresponding subprogram body
7995 returns.
7996 @end cartouche
7997 Followed by GLADE, a separately supplied PCS that can be used with
7998 GNAT.
7999
8000 @sp 1
8001 @cartouche
8002 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
8003 should raise @code{Storage_Error} if it runs out of space trying to
8004 write the @code{Item} into the stream.
8005 @end cartouche
8006 Followed by GLADE, a separately supplied PCS that can be used with
8007 GNAT@.
8008
8009 @cindex COBOL support
8010 @unnumberedsec F(7): COBOL Support
8011 @sp 1
8012 @cartouche
8013 If COBOL (respectively, C) is widely supported in the target
8014 environment, implementations supporting the Information Systems Annex
8015 should provide the child package @code{Interfaces.COBOL} (respectively,
8016 @code{Interfaces.C}) specified in Annex B and should support a
8017 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
8018 pragmas (see Annex B), thus allowing Ada programs to interface with
8019 programs written in that language.
8020 @end cartouche
8021 Followed.
8022
8023 @cindex Decimal radix support
8024 @unnumberedsec F.1(2): Decimal Radix Support
8025 @sp 1
8026 @cartouche
8027 Packed decimal should be used as the internal representation for objects
8028 of subtype @var{S} when @var{S}'Machine_Radix = 10.
8029 @end cartouche
8030 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
8031 representations.
8032
8033 @cindex Numerics
8034 @unnumberedsec G: Numerics
8035 @sp 2
8036 @cartouche
8037 If Fortran (respectively, C) is widely supported in the target
8038 environment, implementations supporting the Numerics Annex
8039 should provide the child package @code{Interfaces.Fortran} (respectively,
8040 @code{Interfaces.C}) specified in Annex B and should support a
8041 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
8042 pragmas (see Annex B), thus allowing Ada programs to interface with
8043 programs written in that language.
8044 @end cartouche
8045 Followed.
8046
8047 @cindex Complex types
8048 @unnumberedsec G.1.1(56-58): Complex Types
8049 @sp 2
8050 @cartouche
8051 Because the usual mathematical meaning of multiplication of a complex
8052 operand and a real operand is that of the scaling of both components of
8053 the former by the latter, an implementation should not perform this
8054 operation by first promoting the real operand to complex type and then
8055 performing a full complex multiplication. In systems that, in the
8056 future, support an Ada binding to IEC 559:1989, the latter technique
8057 will not generate the required result when one of the components of the
8058 complex operand is infinite. (Explicit multiplication of the infinite
8059 component by the zero component obtained during promotion yields a NaN
8060 that propagates into the final result.) Analogous advice applies in the
8061 case of multiplication of a complex operand and a pure-imaginary
8062 operand, and in the case of division of a complex operand by a real or
8063 pure-imaginary operand.
8064 @end cartouche
8065 Not followed.
8066
8067 @sp 1
8068 @cartouche
8069 Similarly, because the usual mathematical meaning of addition of a
8070 complex operand and a real operand is that the imaginary operand remains
8071 unchanged, an implementation should not perform this operation by first
8072 promoting the real operand to complex type and then performing a full
8073 complex addition. In implementations in which the @code{Signed_Zeros}
8074 attribute of the component type is @code{True} (and which therefore
8075 conform to IEC 559:1989 in regard to the handling of the sign of zero in
8076 predefined arithmetic operations), the latter technique will not
8077 generate the required result when the imaginary component of the complex
8078 operand is a negatively signed zero. (Explicit addition of the negative
8079 zero to the zero obtained during promotion yields a positive zero.)
8080 Analogous advice applies in the case of addition of a complex operand
8081 and a pure-imaginary operand, and in the case of subtraction of a
8082 complex operand and a real or pure-imaginary operand.
8083 @end cartouche
8084 Not followed.
8085
8086 @sp 1
8087 @cartouche
8088 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
8089 attempt to provide a rational treatment of the signs of zero results and
8090 result components. As one example, the result of the @code{Argument}
8091 function should have the sign of the imaginary component of the
8092 parameter @code{X} when the point represented by that parameter lies on
8093 the positive real axis; as another, the sign of the imaginary component
8094 of the @code{Compose_From_Polar} function should be the same as
8095 (respectively, the opposite of) that of the @code{Argument} parameter when that
8096 parameter has a value of zero and the @code{Modulus} parameter has a
8097 nonnegative (respectively, negative) value.
8098 @end cartouche
8099 Followed.
8100
8101 @cindex Complex elementary functions
8102 @unnumberedsec G.1.2(49): Complex Elementary Functions
8103 @sp 1
8104 @cartouche
8105 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
8106 @code{True} should attempt to provide a rational treatment of the signs
8107 of zero results and result components. For example, many of the complex
8108 elementary functions have components that are odd functions of one of
8109 the parameter components; in these cases, the result component should
8110 have the sign of the parameter component at the origin. Other complex
8111 elementary functions have zero components whose sign is opposite that of
8112 a parameter component at the origin, or is always positive or always
8113 negative.
8114 @end cartouche
8115 Followed.
8116
8117 @cindex Accuracy requirements
8118 @unnumberedsec G.2.4(19): Accuracy Requirements
8119 @sp 1
8120 @cartouche
8121 The versions of the forward trigonometric functions without a
8122 @code{Cycle} parameter should not be implemented by calling the
8123 corresponding version with a @code{Cycle} parameter of
8124 @code{2.0*Numerics.Pi}, since this will not provide the required
8125 accuracy in some portions of the domain. For the same reason, the
8126 version of @code{Log} without a @code{Base} parameter should not be
8127 implemented by calling the corresponding version with a @code{Base}
8128 parameter of @code{Numerics.e}.
8129 @end cartouche
8130 Followed.
8131
8132 @cindex Complex arithmetic accuracy
8133 @cindex Accuracy, complex arithmetic
8134 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
8135
8136 @sp 1
8137 @cartouche
8138 The version of the @code{Compose_From_Polar} function without a
8139 @code{Cycle} parameter should not be implemented by calling the
8140 corresponding version with a @code{Cycle} parameter of
8141 @code{2.0*Numerics.Pi}, since this will not provide the required
8142 accuracy in some portions of the domain.
8143 @end cartouche
8144 Followed.
8145
8146 @c -----------------------------------------
8147 @node Implementation Defined Characteristics
8148 @chapter Implementation Defined Characteristics
8149
8150 @noindent
8151 In addition to the implementation dependent pragmas and attributes, and the
8152 implementation advice, there are a number of other Ada features that are
8153 potentially implementation dependent and are designated as
8154 implementation-defined. These are mentioned throughout the Ada Reference
8155 Manual, and are summarized in Annex M@.
8156
8157 A requirement for conforming Ada compilers is that they provide
8158 documentation describing how the implementation deals with each of these
8159 issues. In this chapter, you will find each point in Annex M listed
8160 followed by a description in italic font of how GNAT
8161 @c SGI info:
8162 @ignore
8163 in the ProDev Ada
8164 implementation on IRIX 5.3 operating system or greater
8165 @end ignore
8166 handles the implementation dependence.
8167
8168 You can use this chapter as a guide to minimizing implementation
8169 dependent features in your programs if portability to other compilers
8170 and other operating systems is an important consideration. The numbers
8171 in each section below correspond to the paragraph number in the Ada
8172 Reference Manual.
8173
8174 @sp 1
8175 @cartouche
8176 @noindent
8177 @strong{2}. Whether or not each recommendation given in Implementation
8178 Advice is followed. See 1.1.2(37).
8179 @end cartouche
8180 @noindent
8181 @xref{Implementation Advice}.
8182
8183 @sp 1
8184 @cartouche
8185 @noindent
8186 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
8187 @end cartouche
8188 @noindent
8189 The complexity of programs that can be processed is limited only by the
8190 total amount of available virtual memory, and disk space for the
8191 generated object files.
8192
8193 @sp 1
8194 @cartouche
8195 @noindent
8196 @strong{4}. Variations from the standard that are impractical to avoid
8197 given the implementation's execution environment. See 1.1.3(6).
8198 @end cartouche
8199 @noindent
8200 There are no variations from the standard.
8201
8202 @sp 1
8203 @cartouche
8204 @noindent
8205 @strong{5}. Which @code{code_statement}s cause external
8206 interactions. See 1.1.3(10).
8207 @end cartouche
8208 @noindent
8209 Any @code{code_statement} can potentially cause external interactions.
8210
8211 @sp 1
8212 @cartouche
8213 @noindent
8214 @strong{6}. The coded representation for the text of an Ada
8215 program. See 2.1(4).
8216 @end cartouche
8217 @noindent
8218 See separate section on source representation.
8219
8220 @sp 1
8221 @cartouche
8222 @noindent
8223 @strong{7}. The control functions allowed in comments. See 2.1(14).
8224 @end cartouche
8225 @noindent
8226 See separate section on source representation.
8227
8228 @sp 1
8229 @cartouche
8230 @noindent
8231 @strong{8}. The representation for an end of line. See 2.2(2).
8232 @end cartouche
8233 @noindent
8234 See separate section on source representation.
8235
8236 @sp 1
8237 @cartouche
8238 @noindent
8239 @strong{9}. Maximum supported line length and lexical element
8240 length. See 2.2(15).
8241 @end cartouche
8242 @noindent
8243 The maximum line length is 255 characters and the maximum length of a
8244 lexical element is also 255 characters.
8245
8246 @sp 1
8247 @cartouche
8248 @noindent
8249 @strong{10}. Implementation defined pragmas. See 2.8(14).
8250 @end cartouche
8251 @noindent
8252
8253 @xref{Implementation Defined Pragmas}.
8254
8255 @sp 1
8256 @cartouche
8257 @noindent
8258 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
8259 @end cartouche
8260 @noindent
8261 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8262 parameter, checks that the optimization flag is set, and aborts if it is
8263 not.
8264
8265 @sp 1
8266 @cartouche
8267 @noindent
8268 @strong{12}. The sequence of characters of the value returned by
8269 @code{@var{S}'Image} when some of the graphic characters of
8270 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8271 3.5(37).
8272 @end cartouche
8273 @noindent
8274 The sequence of characters is as defined by the wide character encoding
8275 method used for the source. See section on source representation for
8276 further details.
8277
8278 @sp 1
8279 @cartouche
8280 @noindent
8281 @strong{13}. The predefined integer types declared in
8282 @code{Standard}. See 3.5.4(25).
8283 @end cartouche
8284 @noindent
8285 @table @code
8286 @item Short_Short_Integer
8287 8 bit signed
8288 @item Short_Integer
8289 (Short) 16 bit signed
8290 @item Integer
8291 32 bit signed
8292 @item Long_Integer
8293 64 bit signed (on most 64 bit targets, depending on the C definition of long).
8294 32 bit signed (all other targets)
8295 @item Long_Long_Integer
8296 64 bit signed
8297 @end table
8298
8299 @sp 1
8300 @cartouche
8301 @noindent
8302 @strong{14}. Any nonstandard integer types and the operators defined
8303 for them. See 3.5.4(26).
8304 @end cartouche
8305 @noindent
8306 There are no nonstandard integer types.
8307
8308 @sp 1
8309 @cartouche
8310 @noindent
8311 @strong{15}. Any nonstandard real types and the operators defined for
8312 them. See 3.5.6(8).
8313 @end cartouche
8314 @noindent
8315 There are no nonstandard real types.
8316
8317 @sp 1
8318 @cartouche
8319 @noindent
8320 @strong{16}. What combinations of requested decimal precision and range
8321 are supported for floating point types. See 3.5.7(7).
8322 @end cartouche
8323 @noindent
8324 The precision and range is as defined by the IEEE standard.
8325
8326 @sp 1
8327 @cartouche
8328 @noindent
8329 @strong{17}. The predefined floating point types declared in
8330 @code{Standard}. See 3.5.7(16).
8331 @end cartouche
8332 @noindent
8333 @table @code
8334 @item Short_Float
8335 32 bit IEEE short
8336 @item Float
8337 (Short) 32 bit IEEE short
8338 @item Long_Float
8339 64 bit IEEE long
8340 @item Long_Long_Float
8341 64 bit IEEE long (80 bit IEEE long on x86 processors)
8342 @end table
8343
8344 @sp 1
8345 @cartouche
8346 @noindent
8347 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8348 @end cartouche
8349 @noindent
8350 @code{Fine_Delta} is 2**(@minus{}63)
8351
8352 @sp 1
8353 @cartouche
8354 @noindent
8355 @strong{19}. What combinations of small, range, and digits are
8356 supported for fixed point types. See 3.5.9(10).
8357 @end cartouche
8358 @noindent
8359 Any combinations are permitted that do not result in a small less than
8360 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8361 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8362 is 64 bits (true of all architectures except ia32), then the output from
8363 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8364 is because floating-point conversions are used to convert fixed point.
8365
8366 @sp 1
8367 @cartouche
8368 @noindent
8369 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8370 within an unnamed @code{block_statement}. See 3.9(10).
8371 @end cartouche
8372 @noindent
8373 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8374 decimal integer are allocated.
8375
8376 @sp 1
8377 @cartouche
8378 @noindent
8379 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8380 @end cartouche
8381 @noindent
8382 @xref{Implementation Defined Attributes}.
8383
8384 @sp 1
8385 @cartouche
8386 @noindent
8387 @strong{22}. Any implementation-defined time types. See 9.6(6).
8388 @end cartouche
8389 @noindent
8390 There are no implementation-defined time types.
8391
8392 @sp 1
8393 @cartouche
8394 @noindent
8395 @strong{23}. The time base associated with relative delays.
8396 @end cartouche
8397 @noindent
8398 See 9.6(20). The time base used is that provided by the C library
8399 function @code{gettimeofday}.
8400
8401 @sp 1
8402 @cartouche
8403 @noindent
8404 @strong{24}. The time base of the type @code{Calendar.Time}. See
8405 9.6(23).
8406 @end cartouche
8407 @noindent
8408 The time base used is that provided by the C library function
8409 @code{gettimeofday}.
8410
8411 @sp 1
8412 @cartouche
8413 @noindent
8414 @strong{25}. The time zone used for package @code{Calendar}
8415 operations. See 9.6(24).
8416 @end cartouche
8417 @noindent
8418 The time zone used by package @code{Calendar} is the current system time zone
8419 setting for local time, as accessed by the C library function
8420 @code{localtime}.
8421
8422 @sp 1
8423 @cartouche
8424 @noindent
8425 @strong{26}. Any limit on @code{delay_until_statements} of
8426 @code{select_statements}. See 9.6(29).
8427 @end cartouche
8428 @noindent
8429 There are no such limits.
8430
8431 @sp 1
8432 @cartouche
8433 @noindent
8434 @strong{27}. Whether or not two non-overlapping parts of a composite
8435 object are independently addressable, in the case where packing, record
8436 layout, or @code{Component_Size} is specified for the object. See
8437 9.10(1).
8438 @end cartouche
8439 @noindent
8440 Separate components are independently addressable if they do not share
8441 overlapping storage units.
8442
8443 @sp 1
8444 @cartouche
8445 @noindent
8446 @strong{28}. The representation for a compilation. See 10.1(2).
8447 @end cartouche
8448 @noindent
8449 A compilation is represented by a sequence of files presented to the
8450 compiler in a single invocation of the @command{gcc} command.
8451
8452 @sp 1
8453 @cartouche
8454 @noindent
8455 @strong{29}. Any restrictions on compilations that contain multiple
8456 compilation_units. See 10.1(4).
8457 @end cartouche
8458 @noindent
8459 No single file can contain more than one compilation unit, but any
8460 sequence of files can be presented to the compiler as a single
8461 compilation.
8462
8463 @sp 1
8464 @cartouche
8465 @noindent
8466 @strong{30}. The mechanisms for creating an environment and for adding
8467 and replacing compilation units. See 10.1.4(3).
8468 @end cartouche
8469 @noindent
8470 See separate section on compilation model.
8471
8472 @sp 1
8473 @cartouche
8474 @noindent
8475 @strong{31}. The manner of explicitly assigning library units to a
8476 partition. See 10.2(2).
8477 @end cartouche
8478 @noindent
8479 If a unit contains an Ada main program, then the Ada units for the partition
8480 are determined by recursive application of the rules in the Ada Reference
8481 Manual section 10.2(2-6). In other words, the Ada units will be those that
8482 are needed by the main program, and then this definition of need is applied
8483 recursively to those units, and the partition contains the transitive
8484 closure determined by this relationship. In short, all the necessary units
8485 are included, with no need to explicitly specify the list. If additional
8486 units are required, e.g.@: by foreign language units, then all units must be
8487 mentioned in the context clause of one of the needed Ada units.
8488
8489 If the partition contains no main program, or if the main program is in
8490 a language other than Ada, then GNAT
8491 provides the binder options @option{-z} and @option{-n} respectively, and in
8492 this case a list of units can be explicitly supplied to the binder for
8493 inclusion in the partition (all units needed by these units will also
8494 be included automatically). For full details on the use of these
8495 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8496 @value{EDITION} User's Guide}.
8497
8498 @sp 1
8499 @cartouche
8500 @noindent
8501 @strong{32}. The implementation-defined means, if any, of specifying
8502 which compilation units are needed by a given compilation unit. See
8503 10.2(2).
8504 @end cartouche
8505 @noindent
8506 The units needed by a given compilation unit are as defined in
8507 the Ada Reference Manual section 10.2(2-6). There are no
8508 implementation-defined pragmas or other implementation-defined
8509 means for specifying needed units.
8510
8511 @sp 1
8512 @cartouche
8513 @noindent
8514 @strong{33}. The manner of designating the main subprogram of a
8515 partition. See 10.2(7).
8516 @end cartouche
8517 @noindent
8518 The main program is designated by providing the name of the
8519 corresponding @file{ALI} file as the input parameter to the binder.
8520
8521 @sp 1
8522 @cartouche
8523 @noindent
8524 @strong{34}. The order of elaboration of @code{library_items}. See
8525 10.2(18).
8526 @end cartouche
8527 @noindent
8528 The first constraint on ordering is that it meets the requirements of
8529 Chapter 10 of the Ada Reference Manual. This still leaves some
8530 implementation dependent choices, which are resolved by first
8531 elaborating bodies as early as possible (i.e., in preference to specs
8532 where there is a choice), and second by evaluating the immediate with
8533 clauses of a unit to determine the probably best choice, and
8534 third by elaborating in alphabetical order of unit names
8535 where a choice still remains.
8536
8537 @sp 1
8538 @cartouche
8539 @noindent
8540 @strong{35}. Parameter passing and function return for the main
8541 subprogram. See 10.2(21).
8542 @end cartouche
8543 @noindent
8544 The main program has no parameters. It may be a procedure, or a function
8545 returning an integer type. In the latter case, the returned integer
8546 value is the return code of the program (overriding any value that
8547 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8548
8549 @sp 1
8550 @cartouche
8551 @noindent
8552 @strong{36}. The mechanisms for building and running partitions. See
8553 10.2(24).
8554 @end cartouche
8555 @noindent
8556 GNAT itself supports programs with only a single partition. The GNATDIST
8557 tool provided with the GLADE package (which also includes an implementation
8558 of the PCS) provides a completely flexible method for building and running
8559 programs consisting of multiple partitions. See the separate GLADE manual
8560 for details.
8561
8562 @sp 1
8563 @cartouche
8564 @noindent
8565 @strong{37}. The details of program execution, including program
8566 termination. See 10.2(25).
8567 @end cartouche
8568 @noindent
8569 See separate section on compilation model.
8570
8571 @sp 1
8572 @cartouche
8573 @noindent
8574 @strong{38}. The semantics of any non-active partitions supported by the
8575 implementation. See 10.2(28).
8576 @end cartouche
8577 @noindent
8578 Passive partitions are supported on targets where shared memory is
8579 provided by the operating system. See the GLADE reference manual for
8580 further details.
8581
8582 @sp 1
8583 @cartouche
8584 @noindent
8585 @strong{39}. The information returned by @code{Exception_Message}. See
8586 11.4.1(10).
8587 @end cartouche
8588 @noindent
8589 Exception message returns the null string unless a specific message has
8590 been passed by the program.
8591
8592 @sp 1
8593 @cartouche
8594 @noindent
8595 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8596 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8597 @end cartouche
8598 @noindent
8599 Blocks have implementation defined names of the form @code{B@var{nnn}}
8600 where @var{nnn} is an integer.
8601
8602 @sp 1
8603 @cartouche
8604 @noindent
8605 @strong{41}. The information returned by
8606 @code{Exception_Information}. See 11.4.1(13).
8607 @end cartouche
8608 @noindent
8609 @code{Exception_Information} returns a string in the following format:
8610
8611 @smallexample
8612 @emph{Exception_Name:} nnnnn
8613 @emph{Message:} mmmmm
8614 @emph{PID:} ppp
8615 @emph{Call stack traceback locations:}
8616 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8617 @end smallexample
8618
8619 @noindent
8620 where
8621
8622 @itemize @bullet
8623 @item
8624 @code{nnnn} is the fully qualified name of the exception in all upper
8625 case letters. This line is always present.
8626
8627 @item
8628 @code{mmmm} is the message (this line present only if message is non-null)
8629
8630 @item
8631 @code{ppp} is the Process Id value as a decimal integer (this line is
8632 present only if the Process Id is nonzero). Currently we are
8633 not making use of this field.
8634
8635 @item
8636 The Call stack traceback locations line and the following values
8637 are present only if at least one traceback location was recorded.
8638 The values are given in C style format, with lower case letters
8639 for a-f, and only as many digits present as are necessary.
8640 @end itemize
8641
8642 @noindent
8643 The line terminator sequence at the end of each line, including
8644 the last line is a single @code{LF} character (@code{16#0A#}).
8645
8646 @sp 1
8647 @cartouche
8648 @noindent
8649 @strong{42}. Implementation-defined check names. See 11.5(27).
8650 @end cartouche
8651 @noindent
8652 The implementation defined check name Alignment_Check controls checking of
8653 address clause values for proper alignment (that is, the address supplied
8654 must be consistent with the alignment of the type).
8655
8656 In addition, a user program can add implementation-defined check names
8657 by means of the pragma Check_Name.
8658
8659 @sp 1
8660 @cartouche
8661 @noindent
8662 @strong{43}. The interpretation of each aspect of representation. See
8663 13.1(20).
8664 @end cartouche
8665 @noindent
8666 See separate section on data representations.
8667
8668 @sp 1
8669 @cartouche
8670 @noindent
8671 @strong{44}. Any restrictions placed upon representation items. See
8672 13.1(20).
8673 @end cartouche
8674 @noindent
8675 See separate section on data representations.
8676
8677 @sp 1
8678 @cartouche
8679 @noindent
8680 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8681 13.3(48).
8682 @end cartouche
8683 @noindent
8684 Size for an indefinite subtype is the maximum possible size, except that
8685 for the case of a subprogram parameter, the size of the parameter object
8686 is the actual size.
8687
8688 @sp 1
8689 @cartouche
8690 @noindent
8691 @strong{46}. The default external representation for a type tag. See
8692 13.3(75).
8693 @end cartouche
8694 @noindent
8695 The default external representation for a type tag is the fully expanded
8696 name of the type in upper case letters.
8697
8698 @sp 1
8699 @cartouche
8700 @noindent
8701 @strong{47}. What determines whether a compilation unit is the same in
8702 two different partitions. See 13.3(76).
8703 @end cartouche
8704 @noindent
8705 A compilation unit is the same in two different partitions if and only
8706 if it derives from the same source file.
8707
8708 @sp 1
8709 @cartouche
8710 @noindent
8711 @strong{48}. Implementation-defined components. See 13.5.1(15).
8712 @end cartouche
8713 @noindent
8714 The only implementation defined component is the tag for a tagged type,
8715 which contains a pointer to the dispatching table.
8716
8717 @sp 1
8718 @cartouche
8719 @noindent
8720 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8721 ordering. See 13.5.3(5).
8722 @end cartouche
8723 @noindent
8724 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8725 implementation, so no non-default bit ordering is supported. The default
8726 bit ordering corresponds to the natural endianness of the target architecture.
8727
8728 @sp 1
8729 @cartouche
8730 @noindent
8731 @strong{50}. The contents of the visible part of package @code{System}
8732 and its language-defined children. See 13.7(2).
8733 @end cartouche
8734 @noindent
8735 See the definition of these packages in files @file{system.ads} and
8736 @file{s-stoele.ads}.
8737
8738 @sp 1
8739 @cartouche
8740 @noindent
8741 @strong{51}. The contents of the visible part of package
8742 @code{System.Machine_Code}, and the meaning of
8743 @code{code_statements}. See 13.8(7).
8744 @end cartouche
8745 @noindent
8746 See the definition and documentation in file @file{s-maccod.ads}.
8747
8748 @sp 1
8749 @cartouche
8750 @noindent
8751 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8752 @end cartouche
8753 @noindent
8754 Unchecked conversion between types of the same size
8755 results in an uninterpreted transmission of the bits from one type
8756 to the other. If the types are of unequal sizes, then in the case of
8757 discrete types, a shorter source is first zero or sign extended as
8758 necessary, and a shorter target is simply truncated on the left.
8759 For all non-discrete types, the source is first copied if necessary
8760 to ensure that the alignment requirements of the target are met, then
8761 a pointer is constructed to the source value, and the result is obtained
8762 by dereferencing this pointer after converting it to be a pointer to the
8763 target type. Unchecked conversions where the target subtype is an
8764 unconstrained array are not permitted. If the target alignment is
8765 greater than the source alignment, then a copy of the result is
8766 made with appropriate alignment
8767
8768 @sp 1
8769 @cartouche
8770 @noindent
8771 @strong{53}. The semantics of operations on invalid representations.
8772 See 13.9.2(10-11).
8773 @end cartouche
8774 @noindent
8775 For assignments and other operations where the use of invalid values cannot
8776 result in erroneous behavior, the compiler ignores the possibility of invalid
8777 values. An exception is raised at the point where an invalid value would
8778 result in erroneous behavior. For example executing:
8779
8780 @smallexample @c ada
8781 procedure invalidvals is
8782 X : Integer := -1;
8783 Y : Natural range 1 .. 10;
8784 for Y'Address use X'Address;
8785 Z : Natural range 1 .. 10;
8786 A : array (Natural range 1 .. 10) of Integer;
8787 begin
8788 Z := Y; -- no exception
8789 A (Z) := 3; -- exception raised;
8790 end;
8791 @end smallexample
8792
8793 @noindent
8794 As indicated, an exception is raised on the array assignment, but not
8795 on the simple assignment of the invalid negative value from Y to Z.
8796
8797 @sp 1
8798 @cartouche
8799 @noindent
8800 @strong{53}. The manner of choosing a storage pool for an access type
8801 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8802 @end cartouche
8803 @noindent
8804 There are 3 different standard pools used by the compiler when
8805 @code{Storage_Pool} is not specified depending whether the type is local
8806 to a subprogram or defined at the library level and whether
8807 @code{Storage_Size}is specified or not. See documentation in the runtime
8808 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8809 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8810 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8811 default pools used.
8812
8813 @sp 1
8814 @cartouche
8815 @noindent
8816 @strong{54}. Whether or not the implementation provides user-accessible
8817 names for the standard pool type(s). See 13.11(17).
8818 @end cartouche
8819 @noindent
8820
8821 See documentation in the sources of the run time mentioned in paragraph
8822 @strong{53} . All these pools are accessible by means of @code{with}'ing
8823 these units.
8824
8825 @sp 1
8826 @cartouche
8827 @noindent
8828 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8829 @end cartouche
8830 @noindent
8831 @code{Storage_Size} is measured in storage units, and refers to the
8832 total space available for an access type collection, or to the primary
8833 stack space for a task.
8834
8835 @sp 1
8836 @cartouche
8837 @noindent
8838 @strong{56}. Implementation-defined aspects of storage pools. See
8839 13.11(22).
8840 @end cartouche
8841 @noindent
8842 See documentation in the sources of the run time mentioned in paragraph
8843 @strong{53} for details on GNAT-defined aspects of storage pools.
8844
8845 @sp 1
8846 @cartouche
8847 @noindent
8848 @strong{57}. The set of restrictions allowed in a pragma
8849 @code{Restrictions}. See 13.12(7).
8850 @end cartouche
8851 @noindent
8852 All RM defined Restriction identifiers are implemented. The following
8853 additional restriction identifiers are provided. There are two separate
8854 lists of implementation dependent restriction identifiers. The first
8855 set requires consistency throughout a partition (in other words, if the
8856 restriction identifier is used for any compilation unit in the partition,
8857 then all compilation units in the partition must obey the restriction.
8858
8859 @table @code
8860
8861 @item Simple_Barriers
8862 @findex Simple_Barriers
8863 This restriction ensures at compile time that barriers in entry declarations
8864 for protected types are restricted to either static boolean expressions or
8865 references to simple boolean variables defined in the private part of the
8866 protected type. No other form of entry barriers is permitted. This is one
8867 of the restrictions of the Ravenscar profile for limited tasking (see also
8868 pragma @code{Profile (Ravenscar)}).
8869
8870 @item Max_Entry_Queue_Length => Expr
8871 @findex Max_Entry_Queue_Length
8872 This restriction is a declaration that any protected entry compiled in
8873 the scope of the restriction has at most the specified number of
8874 tasks waiting on the entry
8875 at any one time, and so no queue is required. This restriction is not
8876 checked at compile time. A program execution is erroneous if an attempt
8877 is made to queue more than the specified number of tasks on such an entry.
8878
8879 @item No_Calendar
8880 @findex No_Calendar
8881 This restriction ensures at compile time that there is no implicit or
8882 explicit dependence on the package @code{Ada.Calendar}.
8883
8884 @item No_Default_Initialization
8885 @findex No_Default_Initialization
8886
8887 This restriction prohibits any instance of default initialization of variables.
8888 The binder implements a consistency rule which prevents any unit compiled
8889 without the restriction from with'ing a unit with the restriction (this allows
8890 the generation of initialization procedures to be skipped, since you can be
8891 sure that no call is ever generated to an initialization procedure in a unit
8892 with the restriction active). If used in conjunction with Initialize_Scalars or
8893 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8894 without a specific initializer (including the case of OUT scalar parameters).
8895
8896 @item No_Direct_Boolean_Operators
8897 @findex No_Direct_Boolean_Operators
8898 This restriction ensures that no logical (and/or/xor) are used on
8899 operands of type Boolean (or any type derived
8900 from Boolean). This is intended for use in safety critical programs
8901 where the certification protocol requires the use of short-circuit
8902 (and then, or else) forms for all composite boolean operations.
8903
8904 @item No_Dispatching_Calls
8905 @findex No_Dispatching_Calls
8906 This restriction ensures at compile time that the code generated by the
8907 compiler involves no dispatching calls. The use of this restriction allows the
8908 safe use of record extensions, classwide membership tests and other classwide
8909 features not involving implicit dispatching. This restriction ensures that
8910 the code contains no indirect calls through a dispatching mechanism. Note that
8911 this includes internally-generated calls created by the compiler, for example
8912 in the implementation of class-wide objects assignments. The
8913 membership test is allowed in the presence of this restriction, because its
8914 implementation requires no dispatching.
8915 This restriction is comparable to the official Ada restriction
8916 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8917 all classwide constructs that do not imply dispatching.
8918 The following example indicates constructs that violate this restriction.
8919
8920 @smallexample
8921 package Pkg is
8922 type T is tagged record
8923 Data : Natural;
8924 end record;
8925 procedure P (X : T);
8926
8927 type DT is new T with record
8928 More_Data : Natural;
8929 end record;
8930 procedure Q (X : DT);
8931 end Pkg;
8932
8933 with Pkg; use Pkg;
8934 procedure Example is
8935 procedure Test (O : T'Class) is
8936 N : Natural := O'Size;-- Error: Dispatching call
8937 C : T'Class := O; -- Error: implicit Dispatching Call
8938 begin
8939 if O in DT'Class then -- OK : Membership test
8940 Q (DT (O)); -- OK : Type conversion plus direct call
8941 else
8942 P (O); -- Error: Dispatching call
8943 end if;
8944 end Test;
8945
8946 Obj : DT;
8947 begin
8948 P (Obj); -- OK : Direct call
8949 P (T (Obj)); -- OK : Type conversion plus direct call
8950 P (T'Class (Obj)); -- Error: Dispatching call
8951
8952 Test (Obj); -- OK : Type conversion
8953
8954 if Obj in T'Class then -- OK : Membership test
8955 null;
8956 end if;
8957 end Example;
8958 @end smallexample
8959
8960 @item No_Dynamic_Attachment
8961 @findex No_Dynamic_Attachment
8962 This restriction ensures that there is no call to any of the operations
8963 defined in package Ada.Interrupts.
8964
8965 @item No_Enumeration_Maps
8966 @findex No_Enumeration_Maps
8967 This restriction ensures at compile time that no operations requiring
8968 enumeration maps are used (that is Image and Value attributes applied
8969 to enumeration types).
8970
8971 @item No_Entry_Calls_In_Elaboration_Code
8972 @findex No_Entry_Calls_In_Elaboration_Code
8973 This restriction ensures at compile time that no task or protected entry
8974 calls are made during elaboration code. As a result of the use of this
8975 restriction, the compiler can assume that no code past an accept statement
8976 in a task can be executed at elaboration time.
8977
8978 @item No_Exception_Handlers
8979 @findex No_Exception_Handlers
8980 This restriction ensures at compile time that there are no explicit
8981 exception handlers. It also indicates that no exception propagation will
8982 be provided. In this mode, exceptions may be raised but will result in
8983 an immediate call to the last chance handler, a routine that the user
8984 must define with the following profile:
8985
8986 @smallexample @c ada
8987 procedure Last_Chance_Handler
8988 (Source_Location : System.Address; Line : Integer);
8989 pragma Export (C, Last_Chance_Handler,
8990 "__gnat_last_chance_handler");
8991 @end smallexample
8992
8993 The parameter is a C null-terminated string representing a message to be
8994 associated with the exception (typically the source location of the raise
8995 statement generated by the compiler). The Line parameter when nonzero
8996 represents the line number in the source program where the raise occurs.
8997
8998 @item No_Exception_Propagation
8999 @findex No_Exception_Propagation
9000 This restriction guarantees that exceptions are never propagated to an outer
9001 subprogram scope). The only case in which an exception may be raised is when
9002 the handler is statically in the same subprogram, so that the effect of a raise
9003 is essentially like a goto statement. Any other raise statement (implicit or
9004 explicit) will be considered unhandled. Exception handlers are allowed, but may
9005 not contain an exception occurrence identifier (exception choice). In addition
9006 use of the package GNAT.Current_Exception is not permitted, and reraise
9007 statements (raise with no operand) are not permitted.
9008
9009 @item No_Exception_Registration
9010 @findex No_Exception_Registration
9011 This restriction ensures at compile time that no stream operations for
9012 types Exception_Id or Exception_Occurrence are used. This also makes it
9013 impossible to pass exceptions to or from a partition with this restriction
9014 in a distributed environment. If this exception is active, then the generated
9015 code is simplified by omitting the otherwise-required global registration
9016 of exceptions when they are declared.
9017
9018 @item No_Implicit_Aliasing
9019 @findex No_Implicit_Aliasing
9020
9021 This restriction, which is not required to be partition-wide consistent,
9022 requires an explicit aliased keyword for an object to which 'Access,
9023 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9024 the 'Unrestricted_Access attribute for objects. Note: the reason that
9025 Unrestricted_Access is forbidden is that it would require the prefix
9026 to be aliased, and in such cases, it can always be replaced by
9027 the standard attribute Unchecked_Access which is preferable.
9028
9029 @item No_Implicit_Conditionals
9030 @findex No_Implicit_Conditionals
9031 This restriction ensures that the generated code does not contain any
9032 implicit conditionals, either by modifying the generated code where possible,
9033 or by rejecting any construct that would otherwise generate an implicit
9034 conditional. Note that this check does not include run time constraint
9035 checks, which on some targets may generate implicit conditionals as
9036 well. To control the latter, constraint checks can be suppressed in the
9037 normal manner. Constructs generating implicit conditionals include comparisons
9038 of composite objects and the Max/Min attributes.
9039
9040 @item No_Implicit_Dynamic_Code
9041 @findex No_Implicit_Dynamic_Code
9042 @cindex trampoline
9043 This restriction prevents the compiler from building ``trampolines''.
9044 This is a structure that is built on the stack and contains dynamic
9045 code to be executed at run time. On some targets, a trampoline is
9046 built for the following features: @code{Access},
9047 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9048 nested task bodies; primitive operations of nested tagged types.
9049 Trampolines do not work on machines that prevent execution of stack
9050 data. For example, on windows systems, enabling DEP (data execution
9051 protection) will cause trampolines to raise an exception.
9052 Trampolines are also quite slow at run time.
9053
9054 On many targets, trampolines have been largely eliminated. Look at the
9055 version of system.ads for your target --- if it has
9056 Always_Compatible_Rep equal to False, then trampolines are largely
9057 eliminated. In particular, a trampoline is built for the following
9058 features: @code{Address} of a nested subprogram;
9059 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9060 but only if pragma Favor_Top_Level applies, or the access type has a
9061 foreign-language convention; primitive operations of nested tagged
9062 types.
9063
9064 @item No_Implicit_Loops
9065 @findex No_Implicit_Loops
9066 This restriction ensures that the generated code does not contain any
9067 implicit @code{for} loops, either by modifying
9068 the generated code where possible,
9069 or by rejecting any construct that would otherwise generate an implicit
9070 @code{for} loop. If this restriction is active, it is possible to build
9071 large array aggregates with all static components without generating an
9072 intermediate temporary, and without generating a loop to initialize individual
9073 components. Otherwise, a loop is created for arrays larger than about 5000
9074 scalar components.
9075
9076 @item No_Initialize_Scalars
9077 @findex No_Initialize_Scalars
9078 This restriction ensures that no unit in the partition is compiled with
9079 pragma Initialize_Scalars. This allows the generation of more efficient
9080 code, and in particular eliminates dummy null initialization routines that
9081 are otherwise generated for some record and array types.
9082
9083 @item No_Local_Protected_Objects
9084 @findex No_Local_Protected_Objects
9085 This restriction ensures at compile time that protected objects are
9086 only declared at the library level.
9087
9088 @item No_Protected_Type_Allocators
9089 @findex No_Protected_Type_Allocators
9090 This restriction ensures at compile time that there are no allocator
9091 expressions that attempt to allocate protected objects.
9092
9093 @item No_Secondary_Stack
9094 @findex No_Secondary_Stack
9095 This restriction ensures at compile time that the generated code does not
9096 contain any reference to the secondary stack. The secondary stack is used
9097 to implement functions returning unconstrained objects (arrays or records)
9098 on some targets.
9099
9100 @item No_Select_Statements
9101 @findex No_Select_Statements
9102 This restriction ensures at compile time no select statements of any kind
9103 are permitted, that is the keyword @code{select} may not appear.
9104 This is one of the restrictions of the Ravenscar
9105 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
9106
9107 @item No_Standard_Storage_Pools
9108 @findex No_Standard_Storage_Pools
9109 This restriction ensures at compile time that no access types
9110 use the standard default storage pool. Any access type declared must
9111 have an explicit Storage_Pool attribute defined specifying a
9112 user-defined storage pool.
9113
9114 @item No_Streams
9115 @findex No_Streams
9116 This restriction ensures at compile/bind time that there are no
9117 stream objects created and no use of stream attributes.
9118 This restriction does not forbid dependences on the package
9119 @code{Ada.Streams}. So it is permissible to with
9120 @code{Ada.Streams} (or another package that does so itself)
9121 as long as no actual stream objects are created and no
9122 stream attributes are used.
9123
9124 Note that the use of restriction allows optimization of tagged types,
9125 since they do not need to worry about dispatching stream operations.
9126 To take maximum advantage of this space-saving optimization, any
9127 unit declaring a tagged type should be compiled with the restriction,
9128 though this is not required.
9129
9130 @item No_Task_Attributes_Package
9131 @findex No_Task_Attributes_Package
9132 This restriction ensures at compile time that there are no implicit or
9133 explicit dependencies on the package @code{Ada.Task_Attributes}.
9134
9135 @item No_Task_Termination
9136 @findex No_Task_Termination
9137 This restriction ensures at compile time that no terminate alternatives
9138 appear in any task body.
9139
9140 @item No_Tasking
9141 @findex No_Tasking
9142 This restriction prevents the declaration of tasks or task types throughout
9143 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
9144 except that violations are caught at compile time and cause an error message
9145 to be output either by the compiler or binder.
9146
9147 @item Static_Priorities
9148 @findex Static_Priorities
9149 This restriction ensures at compile time that all priority expressions
9150 are static, and that there are no dependencies on the package
9151 @code{Ada.Dynamic_Priorities}.
9152
9153 @item Static_Storage_Size
9154 @findex Static_Storage_Size
9155 This restriction ensures at compile time that any expression appearing
9156 in a Storage_Size pragma or attribute definition clause is static.
9157
9158 @end table
9159
9160 @noindent
9161 The second set of implementation dependent restriction identifiers
9162 does not require partition-wide consistency.
9163 The restriction may be enforced for a single
9164 compilation unit without any effect on any of the
9165 other compilation units in the partition.
9166
9167 @table @code
9168
9169 @item No_Elaboration_Code
9170 @findex No_Elaboration_Code
9171 This restriction ensures at compile time that no elaboration code is
9172 generated. Note that this is not the same condition as is enforced
9173 by pragma @code{Preelaborate}. There are cases in which pragma
9174 @code{Preelaborate} still permits code to be generated (e.g.@: code
9175 to initialize a large array to all zeroes), and there are cases of units
9176 which do not meet the requirements for pragma @code{Preelaborate},
9177 but for which no elaboration code is generated. Generally, it is
9178 the case that preelaborable units will meet the restrictions, with
9179 the exception of large aggregates initialized with an others_clause,
9180 and exception declarations (which generate calls to a run-time
9181 registry procedure). This restriction is enforced on
9182 a unit by unit basis, it need not be obeyed consistently
9183 throughout a partition.
9184
9185 In the case of aggregates with others, if the aggregate has a dynamic
9186 size, there is no way to eliminate the elaboration code (such dynamic
9187 bounds would be incompatible with @code{Preelaborate} in any case). If
9188 the bounds are static, then use of this restriction actually modifies
9189 the code choice of the compiler to avoid generating a loop, and instead
9190 generate the aggregate statically if possible, no matter how many times
9191 the data for the others clause must be repeatedly generated.
9192
9193 It is not possible to precisely document
9194 the constructs which are compatible with this restriction, since,
9195 unlike most other restrictions, this is not a restriction on the
9196 source code, but a restriction on the generated object code. For
9197 example, if the source contains a declaration:
9198
9199 @smallexample
9200 Val : constant Integer := X;
9201 @end smallexample
9202
9203 @noindent
9204 where X is not a static constant, it may be possible, depending
9205 on complex optimization circuitry, for the compiler to figure
9206 out the value of X at compile time, in which case this initialization
9207 can be done by the loader, and requires no initialization code. It
9208 is not possible to document the precise conditions under which the
9209 optimizer can figure this out.
9210
9211 Note that this the implementation of this restriction requires full
9212 code generation. If it is used in conjunction with "semantics only"
9213 checking, then some cases of violations may be missed.
9214
9215 @item No_Entry_Queue
9216 @findex No_Entry_Queue
9217 This restriction is a declaration that any protected entry compiled in
9218 the scope of the restriction has at most one task waiting on the entry
9219 at any one time, and so no queue is required. This restriction is not
9220 checked at compile time. A program execution is erroneous if an attempt
9221 is made to queue a second task on such an entry.
9222
9223 @item No_Implementation_Attributes
9224 @findex No_Implementation_Attributes
9225 This restriction checks at compile time that no GNAT-defined attributes
9226 are present. With this restriction, the only attributes that can be used
9227 are those defined in the Ada Reference Manual.
9228
9229 @item No_Implementation_Pragmas
9230 @findex No_Implementation_Pragmas
9231 This restriction checks at compile time that no GNAT-defined pragmas
9232 are present. With this restriction, the only pragmas that can be used
9233 are those defined in the Ada Reference Manual.
9234
9235 @item No_Implementation_Restrictions
9236 @findex No_Implementation_Restrictions
9237 This restriction checks at compile time that no GNAT-defined restriction
9238 identifiers (other than @code{No_Implementation_Restrictions} itself)
9239 are present. With this restriction, the only other restriction identifiers
9240 that can be used are those defined in the Ada Reference Manual.
9241
9242 @item No_Wide_Characters
9243 @findex No_Wide_Characters
9244 This restriction ensures at compile time that no uses of the types
9245 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9246 wide types
9247 appear, and that no wide or wide wide string or character literals
9248 appear in the program (that is literals representing characters not in
9249 type @code{Character}.
9250
9251 @item SPARK
9252 @findex SPARK
9253 This restriction checks at compile time that some constructs forbidden in
9254 SPARK are not present. The SPARK version used as a reference is the same as
9255 the Ada mode for the unit, so a unit compiled in Ada 95 mode with SPARK
9256 restrictions will be checked for constructs forbidden in SPARK 95.
9257 Error messages related to SPARK restriction have the form:
9258
9259 @smallexample
9260 violation of restriction "Spark" at <file>
9261 <error message>
9262 @end smallexample
9263
9264 This is not a replacement for the semantic checks performed by the
9265 SPARK Examiner tool, as the compiler only deals currently with code,
9266 not at all with SPARK annotations and does not guarantee catching all
9267 cases of constructs forbidden by SPARK.
9268
9269 Thus it may well be the case that code which
9270 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
9271 e.g. due to the different visibility rules of the Examiner based on
9272 SPARK @code{inherit} annotations.
9273
9274 This restriction can be useful in providing an initial filter for
9275 code developed using SPARK, or in examining legacy code to see how far
9276 it is from meeting SPARK restrictions.
9277
9278 @end table
9279
9280 @sp 1
9281 @cartouche
9282 @noindent
9283 @strong{58}. The consequences of violating limitations on
9284 @code{Restrictions} pragmas. See 13.12(9).
9285 @end cartouche
9286 @noindent
9287 Restrictions that can be checked at compile time result in illegalities
9288 if violated. Currently there are no other consequences of violating
9289 restrictions.
9290
9291 @sp 1
9292 @cartouche
9293 @noindent
9294 @strong{59}. The representation used by the @code{Read} and
9295 @code{Write} attributes of elementary types in terms of stream
9296 elements. See 13.13.2(9).
9297 @end cartouche
9298 @noindent
9299 The representation is the in-memory representation of the base type of
9300 the type, using the number of bits corresponding to the
9301 @code{@var{type}'Size} value, and the natural ordering of the machine.
9302
9303 @sp 1
9304 @cartouche
9305 @noindent
9306 @strong{60}. The names and characteristics of the numeric subtypes
9307 declared in the visible part of package @code{Standard}. See A.1(3).
9308 @end cartouche
9309 @noindent
9310 See items describing the integer and floating-point types supported.
9311
9312 @sp 1
9313 @cartouche
9314 @noindent
9315 @strong{61}. The accuracy actually achieved by the elementary
9316 functions. See A.5.1(1).
9317 @end cartouche
9318 @noindent
9319 The elementary functions correspond to the functions available in the C
9320 library. Only fast math mode is implemented.
9321
9322 @sp 1
9323 @cartouche
9324 @noindent
9325 @strong{62}. The sign of a zero result from some of the operators or
9326 functions in @code{Numerics.Generic_Elementary_Functions}, when
9327 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9328 @end cartouche
9329 @noindent
9330 The sign of zeroes follows the requirements of the IEEE 754 standard on
9331 floating-point.
9332
9333 @sp 1
9334 @cartouche
9335 @noindent
9336 @strong{63}. The value of
9337 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9338 @end cartouche
9339 @noindent
9340 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9341
9342 @sp 1
9343 @cartouche
9344 @noindent
9345 @strong{64}. The value of
9346 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9347 @end cartouche
9348 @noindent
9349 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9350
9351 @sp 1
9352 @cartouche
9353 @noindent
9354 @strong{65}. The algorithms for random number generation. See
9355 A.5.2(32).
9356 @end cartouche
9357 @noindent
9358 The algorithm is the Mersenne Twister, as documented in the source file
9359 @file{s-rannum.adb}. This version of the algorithm has a period of
9360 2**19937-1.
9361
9362 @sp 1
9363 @cartouche
9364 @noindent
9365 @strong{66}. The string representation of a random number generator's
9366 state. See A.5.2(38).
9367 @end cartouche
9368 @noindent
9369 The value returned by the Image function is the concatenation of
9370 the fixed-width decimal representations of the 624 32-bit integers
9371 of the state vector.
9372
9373 @sp 1
9374 @cartouche
9375 @noindent
9376 @strong{67}. The minimum time interval between calls to the
9377 time-dependent Reset procedure that are guaranteed to initiate different
9378 random number sequences. See A.5.2(45).
9379 @end cartouche
9380 @noindent
9381 The minimum period between reset calls to guarantee distinct series of
9382 random numbers is one microsecond.
9383
9384 @sp 1
9385 @cartouche
9386 @noindent
9387 @strong{68}. The values of the @code{Model_Mantissa},
9388 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9389 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9390 Annex is not supported. See A.5.3(72).
9391 @end cartouche
9392 @noindent
9393 Run the compiler with @option{-gnatS} to produce a listing of package
9394 @code{Standard}, has the values of all numeric attributes.
9395
9396 @sp 1
9397 @cartouche
9398 @noindent
9399 @strong{69}. Any implementation-defined characteristics of the
9400 input-output packages. See A.7(14).
9401 @end cartouche
9402 @noindent
9403 There are no special implementation defined characteristics for these
9404 packages.
9405
9406 @sp 1
9407 @cartouche
9408 @noindent
9409 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9410 A.9(10).
9411 @end cartouche
9412 @noindent
9413 All type representations are contiguous, and the @code{Buffer_Size} is
9414 the value of @code{@var{type}'Size} rounded up to the next storage unit
9415 boundary.
9416
9417 @sp 1
9418 @cartouche
9419 @noindent
9420 @strong{71}. External files for standard input, standard output, and
9421 standard error See A.10(5).
9422 @end cartouche
9423 @noindent
9424 These files are mapped onto the files provided by the C streams
9425 libraries. See source file @file{i-cstrea.ads} for further details.
9426
9427 @sp 1
9428 @cartouche
9429 @noindent
9430 @strong{72}. The accuracy of the value produced by @code{Put}. See
9431 A.10.9(36).
9432 @end cartouche
9433 @noindent
9434 If more digits are requested in the output than are represented by the
9435 precision of the value, zeroes are output in the corresponding least
9436 significant digit positions.
9437
9438 @sp 1
9439 @cartouche
9440 @noindent
9441 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9442 @code{Command_Name}. See A.15(1).
9443 @end cartouche
9444 @noindent
9445 These are mapped onto the @code{argv} and @code{argc} parameters of the
9446 main program in the natural manner.
9447
9448 @sp 1
9449 @cartouche
9450 @noindent
9451 @strong{74}. The interpretation of the @code{Form} parameter in procedure
9452 @code{Create_Directory}. See A.16(56).
9453 @end cartouche
9454 @noindent
9455 The @code{Form} parameter is not used.
9456
9457 @sp 1
9458 @cartouche
9459 @noindent
9460 @strong{75}. The interpretation of the @code{Form} parameter in procedure
9461 @code{Create_Path}. See A.16(60).
9462 @end cartouche
9463 @noindent
9464 The @code{Form} parameter is not used.
9465
9466 @sp 1
9467 @cartouche
9468 @noindent
9469 @strong{76}. The interpretation of the @code{Form} parameter in procedure
9470 @code{Copy_File}. See A.16(68).
9471 @end cartouche
9472 @noindent
9473 The @code{Form} parameter is case-insensitive.
9474
9475 Two fields are recognized in the @code{Form} parameter:
9476
9477 @table @code
9478
9479 @item preserve=<value>
9480
9481 @item mode=<value>
9482
9483 @end table
9484
9485 @noindent
9486 <value> starts immediately after the character '=' and ends with the
9487 character immediately preceding the next comma (',') or with the last
9488 character of the parameter.
9489
9490 The only possible values for preserve= are:
9491
9492 @table @code
9493
9494 @item no_attributes
9495 Do not try to preserve any file attributes. This is the default if no
9496 preserve= is found in Form.
9497
9498 @item all_attributes
9499 Try to preserve all file attributes (timestamps, access rights).
9500
9501 @item timestamps
9502 Preserve the timestamp of the copied file, but not the other file attributes.
9503
9504 @end table
9505
9506 @noindent
9507 The only possible values for mode= are:
9508
9509 @table @code
9510
9511 @item copy
9512 Only do the copy if the destination file does not already exist. If it already
9513 exists, Copy_File fails.
9514
9515 @item overwrite
9516 Copy the file in all cases. Overwrite an already existing destination file.
9517
9518 @item append
9519 Append the original file to the destination file. If the destination file does
9520 not exist, the destination file is a copy of the source file. When mode=append,
9521 the field preserve=, if it exists, is not taken into account.
9522
9523 @end table
9524
9525 @noindent
9526 If the Form parameter includes one or both of the fields and the value or
9527 values are incorrect, Copy_file fails with Use_Error.
9528
9529 Examples of correct Forms:
9530
9531 @smallexample
9532 Form => "preserve=no_attributes,mode=overwrite" (the default)
9533 Form => "mode=append"
9534 Form => "mode=copy, preserve=all_attributes"
9535 @end smallexample
9536
9537 @noindent
9538 Examples of incorrect Forms
9539
9540 @smallexample
9541 Form => "preserve=junk"
9542 Form => "mode=internal, preserve=timestamps"
9543 @end smallexample
9544
9545 @sp 1
9546 @cartouche
9547 @noindent
9548 @strong{77}. Implementation-defined convention names. See B.1(11).
9549 @end cartouche
9550 @noindent
9551 The following convention names are supported
9552
9553 @table @code
9554 @item Ada
9555 Ada
9556 @item Assembler
9557 Assembly language
9558 @item Asm
9559 Synonym for Assembler
9560 @item Assembly
9561 Synonym for Assembler
9562 @item C
9563 C
9564 @item C_Pass_By_Copy
9565 Allowed only for record types, like C, but also notes that record
9566 is to be passed by copy rather than reference.
9567 @item COBOL
9568 COBOL
9569 @item C_Plus_Plus (or CPP)
9570 C++
9571 @item Default
9572 Treated the same as C
9573 @item External
9574 Treated the same as C
9575 @item Fortran
9576 Fortran
9577 @item Intrinsic
9578 For support of pragma @code{Import} with convention Intrinsic, see
9579 separate section on Intrinsic Subprograms.
9580 @item Stdcall
9581 Stdcall (used for Windows implementations only). This convention correspond
9582 to the WINAPI (previously called Pascal convention) C/C++ convention under
9583 Windows. A function with this convention cleans the stack before exit.
9584 @item DLL
9585 Synonym for Stdcall
9586 @item Win32
9587 Synonym for Stdcall
9588 @item Stubbed
9589 Stubbed is a special convention used to indicate that the body of the
9590 subprogram will be entirely ignored. Any call to the subprogram
9591 is converted into a raise of the @code{Program_Error} exception. If a
9592 pragma @code{Import} specifies convention @code{stubbed} then no body need
9593 be present at all. This convention is useful during development for the
9594 inclusion of subprograms whose body has not yet been written.
9595
9596 @end table
9597 @noindent
9598 In addition, all otherwise unrecognized convention names are also
9599 treated as being synonymous with convention C@. In all implementations
9600 except for VMS, use of such other names results in a warning. In VMS
9601 implementations, these names are accepted silently.
9602
9603 @sp 1
9604 @cartouche
9605 @noindent
9606 @strong{78}. The meaning of link names. See B.1(36).
9607 @end cartouche
9608 @noindent
9609 Link names are the actual names used by the linker.
9610
9611 @sp 1
9612 @cartouche
9613 @noindent
9614 @strong{79}. The manner of choosing link names when neither the link
9615 name nor the address of an imported or exported entity is specified. See
9616 B.1(36).
9617 @end cartouche
9618 @noindent
9619 The default linker name is that which would be assigned by the relevant
9620 external language, interpreting the Ada name as being in all lower case
9621 letters.
9622
9623 @sp 1
9624 @cartouche
9625 @noindent
9626 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
9627 @end cartouche
9628 @noindent
9629 The string passed to @code{Linker_Options} is presented uninterpreted as
9630 an argument to the link command, unless it contains ASCII.NUL characters.
9631 NUL characters if they appear act as argument separators, so for example
9632
9633 @smallexample @c ada
9634 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9635 @end smallexample
9636
9637 @noindent
9638 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9639 linker. The order of linker options is preserved for a given unit. The final
9640 list of options passed to the linker is in reverse order of the elaboration
9641 order. For example, linker options for a body always appear before the options
9642 from the corresponding package spec.
9643
9644 @sp 1
9645 @cartouche
9646 @noindent
9647 @strong{81}. The contents of the visible part of package
9648 @code{Interfaces} and its language-defined descendants. See B.2(1).
9649 @end cartouche
9650 @noindent
9651 See files with prefix @file{i-} in the distributed library.
9652
9653 @sp 1
9654 @cartouche
9655 @noindent
9656 @strong{82}. Implementation-defined children of package
9657 @code{Interfaces}. The contents of the visible part of package
9658 @code{Interfaces}. See B.2(11).
9659 @end cartouche
9660 @noindent
9661 See files with prefix @file{i-} in the distributed library.
9662
9663 @sp 1
9664 @cartouche
9665 @noindent
9666 @strong{83}. The types @code{Floating}, @code{Long_Floating},
9667 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9668 @code{COBOL_Character}; and the initialization of the variables
9669 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9670 @code{Interfaces.COBOL}. See B.4(50).
9671 @end cartouche
9672 @noindent
9673 @table @code
9674 @item Floating
9675 Float
9676 @item Long_Floating
9677 (Floating) Long_Float
9678 @item Binary
9679 Integer
9680 @item Long_Binary
9681 Long_Long_Integer
9682 @item Decimal_Element
9683 Character
9684 @item COBOL_Character
9685 Character
9686 @end table
9687
9688 @noindent
9689 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9690
9691 @sp 1
9692 @cartouche
9693 @noindent
9694 @strong{84}. Support for access to machine instructions. See C.1(1).
9695 @end cartouche
9696 @noindent
9697 See documentation in file @file{s-maccod.ads} in the distributed library.
9698
9699 @sp 1
9700 @cartouche
9701 @noindent
9702 @strong{85}. Implementation-defined aspects of access to machine
9703 operations. See C.1(9).
9704 @end cartouche
9705 @noindent
9706 See documentation in file @file{s-maccod.ads} in the distributed library.
9707
9708 @sp 1
9709 @cartouche
9710 @noindent
9711 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
9712 @end cartouche
9713 @noindent
9714 Interrupts are mapped to signals or conditions as appropriate. See
9715 definition of unit
9716 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9717 on the interrupts supported on a particular target.
9718
9719 @sp 1
9720 @cartouche
9721 @noindent
9722 @strong{87}. Implementation-defined aspects of pre-elaboration. See
9723 C.4(13).
9724 @end cartouche
9725 @noindent
9726 GNAT does not permit a partition to be restarted without reloading,
9727 except under control of the debugger.
9728
9729 @sp 1
9730 @cartouche
9731 @noindent
9732 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9733 @end cartouche
9734 @noindent
9735 Pragma @code{Discard_Names} causes names of enumeration literals to
9736 be suppressed. In the presence of this pragma, the Image attribute
9737 provides the image of the Pos of the literal, and Value accepts
9738 Pos values.
9739
9740 @sp 1
9741 @cartouche
9742 @noindent
9743 @strong{89}. The result of the @code{Task_Identification.Image}
9744 attribute. See C.7.1(7).
9745 @end cartouche
9746 @noindent
9747 The result of this attribute is a string that identifies
9748 the object or component that denotes a given task. If a variable @code{Var}
9749 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9750 where the suffix
9751 is the hexadecimal representation of the virtual address of the corresponding
9752 task control block. If the variable is an array of tasks, the image of each
9753 task will have the form of an indexed component indicating the position of a
9754 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9755 component of a record, the image of the task will have the form of a selected
9756 component. These rules are fully recursive, so that the image of a task that
9757 is a subcomponent of a composite object corresponds to the expression that
9758 designates this task.
9759 @noindent
9760 If a task is created by an allocator, its image depends on the context. If the
9761 allocator is part of an object declaration, the rules described above are used
9762 to construct its image, and this image is not affected by subsequent
9763 assignments. If the allocator appears within an expression, the image
9764 includes only the name of the task type.
9765 @noindent
9766 If the configuration pragma Discard_Names is present, or if the restriction
9767 No_Implicit_Heap_Allocation is in effect, the image reduces to
9768 the numeric suffix, that is to say the hexadecimal representation of the
9769 virtual address of the control block of the task.
9770 @sp 1
9771 @cartouche
9772 @noindent
9773 @strong{90}. The value of @code{Current_Task} when in a protected entry
9774 or interrupt handler. See C.7.1(17).
9775 @end cartouche
9776 @noindent
9777 Protected entries or interrupt handlers can be executed by any
9778 convenient thread, so the value of @code{Current_Task} is undefined.
9779
9780 @sp 1
9781 @cartouche
9782 @noindent
9783 @strong{91}. The effect of calling @code{Current_Task} from an entry
9784 body or interrupt handler. See C.7.1(19).
9785 @end cartouche
9786 @noindent
9787 The effect of calling @code{Current_Task} from an entry body or
9788 interrupt handler is to return the identification of the task currently
9789 executing the code.
9790
9791 @sp 1
9792 @cartouche
9793 @noindent
9794 @strong{92}. Implementation-defined aspects of
9795 @code{Task_Attributes}. See C.7.2(19).
9796 @end cartouche
9797 @noindent
9798 There are no implementation-defined aspects of @code{Task_Attributes}.
9799
9800 @sp 1
9801 @cartouche
9802 @noindent
9803 @strong{93}. Values of all @code{Metrics}. See D(2).
9804 @end cartouche
9805 @noindent
9806 The metrics information for GNAT depends on the performance of the
9807 underlying operating system. The sources of the run-time for tasking
9808 implementation, together with the output from @option{-gnatG} can be
9809 used to determine the exact sequence of operating systems calls made
9810 to implement various tasking constructs. Together with appropriate
9811 information on the performance of the underlying operating system,
9812 on the exact target in use, this information can be used to determine
9813 the required metrics.
9814
9815 @sp 1
9816 @cartouche
9817 @noindent
9818 @strong{94}. The declarations of @code{Any_Priority} and
9819 @code{Priority}. See D.1(11).
9820 @end cartouche
9821 @noindent
9822 See declarations in file @file{system.ads}.
9823
9824 @sp 1
9825 @cartouche
9826 @noindent
9827 @strong{95}. Implementation-defined execution resources. See D.1(15).
9828 @end cartouche
9829 @noindent
9830 There are no implementation-defined execution resources.
9831
9832 @sp 1
9833 @cartouche
9834 @noindent
9835 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
9836 access to a protected object keeps its processor busy. See D.2.1(3).
9837 @end cartouche
9838 @noindent
9839 On a multi-processor, a task that is waiting for access to a protected
9840 object does not keep its processor busy.
9841
9842 @sp 1
9843 @cartouche
9844 @noindent
9845 @strong{97}. The affect of implementation defined execution resources
9846 on task dispatching. See D.2.1(9).
9847 @end cartouche
9848 @noindent
9849 @c SGI info
9850 @ignore
9851 Tasks map to IRIX threads, and the dispatching policy is as defined by
9852 the IRIX implementation of threads.
9853 @end ignore
9854 Tasks map to threads in the threads package used by GNAT@. Where possible
9855 and appropriate, these threads correspond to native threads of the
9856 underlying operating system.
9857
9858 @sp 1
9859 @cartouche
9860 @noindent
9861 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9862 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9863 @end cartouche
9864 @noindent
9865 There are no implementation-defined policy-identifiers allowed in this
9866 pragma.
9867
9868 @sp 1
9869 @cartouche
9870 @noindent
9871 @strong{99}. Implementation-defined aspects of priority inversion. See
9872 D.2.2(16).
9873 @end cartouche
9874 @noindent
9875 Execution of a task cannot be preempted by the implementation processing
9876 of delay expirations for lower priority tasks.
9877
9878 @sp 1
9879 @cartouche
9880 @noindent
9881 @strong{100}. Implementation defined task dispatching. See D.2.2(18).
9882 @end cartouche
9883 @noindent
9884 @c SGI info:
9885 @ignore
9886 Tasks map to IRIX threads, and the dispatching policy is as defined by
9887 the IRIX implementation of threads.
9888 @end ignore
9889 The policy is the same as that of the underlying threads implementation.
9890
9891 @sp 1
9892 @cartouche
9893 @noindent
9894 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
9895 in a pragma @code{Locking_Policy}. See D.3(4).
9896 @end cartouche
9897 @noindent
9898 The only implementation defined policy permitted in GNAT is
9899 @code{Inheritance_Locking}. On targets that support this policy, locking
9900 is implemented by inheritance, i.e.@: the task owning the lock operates
9901 at a priority equal to the highest priority of any task currently
9902 requesting the lock.
9903
9904 @sp 1
9905 @cartouche
9906 @noindent
9907 @strong{102}. Default ceiling priorities. See D.3(10).
9908 @end cartouche
9909 @noindent
9910 The ceiling priority of protected objects of the type
9911 @code{System.Interrupt_Priority'Last} as described in the Ada
9912 Reference Manual D.3(10),
9913
9914 @sp 1
9915 @cartouche
9916 @noindent
9917 @strong{103}. The ceiling of any protected object used internally by
9918 the implementation. See D.3(16).
9919 @end cartouche
9920 @noindent
9921 The ceiling priority of internal protected objects is
9922 @code{System.Priority'Last}.
9923
9924 @sp 1
9925 @cartouche
9926 @noindent
9927 @strong{104}. Implementation-defined queuing policies. See D.4(1).
9928 @end cartouche
9929 @noindent
9930 There are no implementation-defined queuing policies.
9931
9932 @sp 1
9933 @cartouche
9934 @noindent
9935 @strong{105}. On a multiprocessor, any conditions that cause the
9936 completion of an aborted construct to be delayed later than what is
9937 specified for a single processor. See D.6(3).
9938 @end cartouche
9939 @noindent
9940 The semantics for abort on a multi-processor is the same as on a single
9941 processor, there are no further delays.
9942
9943 @sp 1
9944 @cartouche
9945 @noindent
9946 @strong{106}. Any operations that implicitly require heap storage
9947 allocation. See D.7(8).
9948 @end cartouche
9949 @noindent
9950 The only operation that implicitly requires heap storage allocation is
9951 task creation.
9952
9953 @sp 1
9954 @cartouche
9955 @noindent
9956 @strong{107}. Implementation-defined aspects of pragma
9957 @code{Restrictions}. See D.7(20).
9958 @end cartouche
9959 @noindent
9960 There are no such implementation-defined aspects.
9961
9962 @sp 1
9963 @cartouche
9964 @noindent
9965 @strong{108}. Implementation-defined aspects of package
9966 @code{Real_Time}. See D.8(17).
9967 @end cartouche
9968 @noindent
9969 There are no implementation defined aspects of package @code{Real_Time}.
9970
9971 @sp 1
9972 @cartouche
9973 @noindent
9974 @strong{109}. Implementation-defined aspects of
9975 @code{delay_statements}. See D.9(8).
9976 @end cartouche
9977 @noindent
9978 Any difference greater than one microsecond will cause the task to be
9979 delayed (see D.9(7)).
9980
9981 @sp 1
9982 @cartouche
9983 @noindent
9984 @strong{110}. The upper bound on the duration of interrupt blocking
9985 caused by the implementation. See D.12(5).
9986 @end cartouche
9987 @noindent
9988 The upper bound is determined by the underlying operating system. In
9989 no cases is it more than 10 milliseconds.
9990
9991 @sp 1
9992 @cartouche
9993 @noindent
9994 @strong{111}. The means for creating and executing distributed
9995 programs. See E(5).
9996 @end cartouche
9997 @noindent
9998 The GLADE package provides a utility GNATDIST for creating and executing
9999 distributed programs. See the GLADE reference manual for further details.
10000
10001 @sp 1
10002 @cartouche
10003 @noindent
10004 @strong{112}. Any events that can result in a partition becoming
10005 inaccessible. See E.1(7).
10006 @end cartouche
10007 @noindent
10008 See the GLADE reference manual for full details on such events.
10009
10010 @sp 1
10011 @cartouche
10012 @noindent
10013 @strong{113}. The scheduling policies, treatment of priorities, and
10014 management of shared resources between partitions in certain cases. See
10015 E.1(11).
10016 @end cartouche
10017 @noindent
10018 See the GLADE reference manual for full details on these aspects of
10019 multi-partition execution.
10020
10021 @sp 1
10022 @cartouche
10023 @noindent
10024 @strong{114}. Events that cause the version of a compilation unit to
10025 change. See E.3(5).
10026 @end cartouche
10027 @noindent
10028 Editing the source file of a compilation unit, or the source files of
10029 any units on which it is dependent in a significant way cause the version
10030 to change. No other actions cause the version number to change. All changes
10031 are significant except those which affect only layout, capitalization or
10032 comments.
10033
10034 @sp 1
10035 @cartouche
10036 @noindent
10037 @strong{115}. Whether the execution of the remote subprogram is
10038 immediately aborted as a result of cancellation. See E.4(13).
10039 @end cartouche
10040 @noindent
10041 See the GLADE reference manual for details on the effect of abort in
10042 a distributed application.
10043
10044 @sp 1
10045 @cartouche
10046 @noindent
10047 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10048 @end cartouche
10049 @noindent
10050 See the GLADE reference manual for a full description of all implementation
10051 defined aspects of the PCS@.
10052
10053 @sp 1
10054 @cartouche
10055 @noindent
10056 @strong{117}. Implementation-defined interfaces in the PCS@. See
10057 E.5(26).
10058 @end cartouche
10059 @noindent
10060 See the GLADE reference manual for a full description of all
10061 implementation defined interfaces.
10062
10063 @sp 1
10064 @cartouche
10065 @noindent
10066 @strong{118}. The values of named numbers in the package
10067 @code{Decimal}. See F.2(7).
10068 @end cartouche
10069 @noindent
10070 @table @code
10071 @item Max_Scale
10072 +18
10073 @item Min_Scale
10074 -18
10075 @item Min_Delta
10076 1.0E-18
10077 @item Max_Delta
10078 1.0E+18
10079 @item Max_Decimal_Digits
10080 18
10081 @end table
10082
10083 @sp 1
10084 @cartouche
10085 @noindent
10086 @strong{119}. The value of @code{Max_Picture_Length} in the package
10087 @code{Text_IO.Editing}. See F.3.3(16).
10088 @end cartouche
10089 @noindent
10090 64
10091
10092 @sp 1
10093 @cartouche
10094 @noindent
10095 @strong{120}. The value of @code{Max_Picture_Length} in the package
10096 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10097 @end cartouche
10098 @noindent
10099 64
10100
10101 @sp 1
10102 @cartouche
10103 @noindent
10104 @strong{121}. The accuracy actually achieved by the complex elementary
10105 functions and by other complex arithmetic operations. See G.1(1).
10106 @end cartouche
10107 @noindent
10108 Standard library functions are used for the complex arithmetic
10109 operations. Only fast math mode is currently supported.
10110
10111 @sp 1
10112 @cartouche
10113 @noindent
10114 @strong{122}. The sign of a zero result (or a component thereof) from
10115 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10116 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10117 @end cartouche
10118 @noindent
10119 The signs of zero values are as recommended by the relevant
10120 implementation advice.
10121
10122 @sp 1
10123 @cartouche
10124 @noindent
10125 @strong{123}. The sign of a zero result (or a component thereof) from
10126 any operator or function in
10127 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10128 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10129 @end cartouche
10130 @noindent
10131 The signs of zero values are as recommended by the relevant
10132 implementation advice.
10133
10134 @sp 1
10135 @cartouche
10136 @noindent
10137 @strong{124}. Whether the strict mode or the relaxed mode is the
10138 default. See G.2(2).
10139 @end cartouche
10140 @noindent
10141 The strict mode is the default. There is no separate relaxed mode. GNAT
10142 provides a highly efficient implementation of strict mode.
10143
10144 @sp 1
10145 @cartouche
10146 @noindent
10147 @strong{125}. The result interval in certain cases of fixed-to-float
10148 conversion. See G.2.1(10).
10149 @end cartouche
10150 @noindent
10151 For cases where the result interval is implementation dependent, the
10152 accuracy is that provided by performing all operations in 64-bit IEEE
10153 floating-point format.
10154
10155 @sp 1
10156 @cartouche
10157 @noindent
10158 @strong{126}. The result of a floating point arithmetic operation in
10159 overflow situations, when the @code{Machine_Overflows} attribute of the
10160 result type is @code{False}. See G.2.1(13).
10161 @end cartouche
10162 @noindent
10163 Infinite and NaN values are produced as dictated by the IEEE
10164 floating-point standard.
10165
10166 Note that on machines that are not fully compliant with the IEEE
10167 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10168 must be used for achieving IEEE confirming behavior (although at the cost
10169 of a significant performance penalty), so infinite and NaN values are
10170 properly generated.
10171
10172 @sp 1
10173 @cartouche
10174 @noindent
10175 @strong{127}. The result interval for division (or exponentiation by a
10176 negative exponent), when the floating point hardware implements division
10177 as multiplication by a reciprocal. See G.2.1(16).
10178 @end cartouche
10179 @noindent
10180 Not relevant, division is IEEE exact.
10181
10182 @sp 1
10183 @cartouche
10184 @noindent
10185 @strong{128}. The definition of close result set, which determines the
10186 accuracy of certain fixed point multiplications and divisions. See
10187 G.2.3(5).
10188 @end cartouche
10189 @noindent
10190 Operations in the close result set are performed using IEEE long format
10191 floating-point arithmetic. The input operands are converted to
10192 floating-point, the operation is done in floating-point, and the result
10193 is converted to the target type.
10194
10195 @sp 1
10196 @cartouche
10197 @noindent
10198 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10199 point multiplication or division for which the result shall be in the
10200 perfect result set. See G.2.3(22).
10201 @end cartouche
10202 @noindent
10203 The result is only defined to be in the perfect result set if the result
10204 can be computed by a single scaling operation involving a scale factor
10205 representable in 64-bits.
10206
10207 @sp 1
10208 @cartouche
10209 @noindent
10210 @strong{130}. The result of a fixed point arithmetic operation in
10211 overflow situations, when the @code{Machine_Overflows} attribute of the
10212 result type is @code{False}. See G.2.3(27).
10213 @end cartouche
10214 @noindent
10215 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10216 types.
10217
10218 @sp 1
10219 @cartouche
10220 @noindent
10221 @strong{131}. The result of an elementary function reference in
10222 overflow situations, when the @code{Machine_Overflows} attribute of the
10223 result type is @code{False}. See G.2.4(4).
10224 @end cartouche
10225 @noindent
10226 IEEE infinite and Nan values are produced as appropriate.
10227
10228 @sp 1
10229 @cartouche
10230 @noindent
10231 @strong{132}. The value of the angle threshold, within which certain
10232 elementary functions, complex arithmetic operations, and complex
10233 elementary functions yield results conforming to a maximum relative
10234 error bound. See G.2.4(10).
10235 @end cartouche
10236 @noindent
10237 Information on this subject is not yet available.
10238
10239 @sp 1
10240 @cartouche
10241 @noindent
10242 @strong{133}. The accuracy of certain elementary functions for
10243 parameters beyond the angle threshold. See G.2.4(10).
10244 @end cartouche
10245 @noindent
10246 Information on this subject is not yet available.
10247
10248 @sp 1
10249 @cartouche
10250 @noindent
10251 @strong{134}. The result of a complex arithmetic operation or complex
10252 elementary function reference in overflow situations, when the
10253 @code{Machine_Overflows} attribute of the corresponding real type is
10254 @code{False}. See G.2.6(5).
10255 @end cartouche
10256 @noindent
10257 IEEE infinite and Nan values are produced as appropriate.
10258
10259 @sp 1
10260 @cartouche
10261 @noindent
10262 @strong{135}. The accuracy of certain complex arithmetic operations and
10263 certain complex elementary functions for parameters (or components
10264 thereof) beyond the angle threshold. See G.2.6(8).
10265 @end cartouche
10266 @noindent
10267 Information on those subjects is not yet available.
10268
10269 @sp 1
10270 @cartouche
10271 @noindent
10272 @strong{136}. Information regarding bounded errors and erroneous
10273 execution. See H.2(1).
10274 @end cartouche
10275 @noindent
10276 Information on this subject is not yet available.
10277
10278 @sp 1
10279 @cartouche
10280 @noindent
10281 @strong{137}. Implementation-defined aspects of pragma
10282 @code{Inspection_Point}. See H.3.2(8).
10283 @end cartouche
10284 @noindent
10285 Pragma @code{Inspection_Point} ensures that the variable is live and can
10286 be examined by the debugger at the inspection point.
10287
10288 @sp 1
10289 @cartouche
10290 @noindent
10291 @strong{138}. Implementation-defined aspects of pragma
10292 @code{Restrictions}. See H.4(25).
10293 @end cartouche
10294 @noindent
10295 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10296 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10297 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10298
10299 @sp 1
10300 @cartouche
10301 @noindent
10302 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10303 H.4(27).
10304 @end cartouche
10305 @noindent
10306 There are no restrictions on pragma @code{Restrictions}.
10307
10308 @node Intrinsic Subprograms
10309 @chapter Intrinsic Subprograms
10310 @cindex Intrinsic Subprograms
10311
10312 @menu
10313 * Intrinsic Operators::
10314 * Enclosing_Entity::
10315 * Exception_Information::
10316 * Exception_Message::
10317 * Exception_Name::
10318 * File::
10319 * Line::
10320 * Rotate_Left::
10321 * Rotate_Right::
10322 * Shift_Left::
10323 * Shift_Right::
10324 * Shift_Right_Arithmetic::
10325 * Source_Location::
10326 @end menu
10327
10328 @noindent
10329 GNAT allows a user application program to write the declaration:
10330
10331 @smallexample @c ada
10332 pragma Import (Intrinsic, name);
10333 @end smallexample
10334
10335 @noindent
10336 providing that the name corresponds to one of the implemented intrinsic
10337 subprograms in GNAT, and that the parameter profile of the referenced
10338 subprogram meets the requirements. This chapter describes the set of
10339 implemented intrinsic subprograms, and the requirements on parameter profiles.
10340 Note that no body is supplied; as with other uses of pragma Import, the
10341 body is supplied elsewhere (in this case by the compiler itself). Note
10342 that any use of this feature is potentially non-portable, since the
10343 Ada standard does not require Ada compilers to implement this feature.
10344
10345 @node Intrinsic Operators
10346 @section Intrinsic Operators
10347 @cindex Intrinsic operator
10348
10349 @noindent
10350 All the predefined numeric operators in package Standard
10351 in @code{pragma Import (Intrinsic,..)}
10352 declarations. In the binary operator case, the operands must have the same
10353 size. The operand or operands must also be appropriate for
10354 the operator. For example, for addition, the operands must
10355 both be floating-point or both be fixed-point, and the
10356 right operand for @code{"**"} must have a root type of
10357 @code{Standard.Integer'Base}.
10358 You can use an intrinsic operator declaration as in the following example:
10359
10360 @smallexample @c ada
10361 type Int1 is new Integer;
10362 type Int2 is new Integer;
10363
10364 function "+" (X1 : Int1; X2 : Int2) return Int1;
10365 function "+" (X1 : Int1; X2 : Int2) return Int2;
10366 pragma Import (Intrinsic, "+");
10367 @end smallexample
10368
10369 @noindent
10370 This declaration would permit ``mixed mode'' arithmetic on items
10371 of the differing types @code{Int1} and @code{Int2}.
10372 It is also possible to specify such operators for private types, if the
10373 full views are appropriate arithmetic types.
10374
10375 @node Enclosing_Entity
10376 @section Enclosing_Entity
10377 @cindex Enclosing_Entity
10378 @noindent
10379 This intrinsic subprogram is used in the implementation of the
10380 library routine @code{GNAT.Source_Info}. The only useful use of the
10381 intrinsic import in this case is the one in this unit, so an
10382 application program should simply call the function
10383 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10384 the current subprogram, package, task, entry, or protected subprogram.
10385
10386 @node Exception_Information
10387 @section Exception_Information
10388 @cindex Exception_Information'
10389 @noindent
10390 This intrinsic subprogram is used in the implementation of the
10391 library routine @code{GNAT.Current_Exception}. The only useful
10392 use of the intrinsic import in this case is the one in this unit,
10393 so an application program should simply call the function
10394 @code{GNAT.Current_Exception.Exception_Information} to obtain
10395 the exception information associated with the current exception.
10396
10397 @node Exception_Message
10398 @section Exception_Message
10399 @cindex Exception_Message
10400 @noindent
10401 This intrinsic subprogram is used in the implementation of the
10402 library routine @code{GNAT.Current_Exception}. The only useful
10403 use of the intrinsic import in this case is the one in this unit,
10404 so an application program should simply call the function
10405 @code{GNAT.Current_Exception.Exception_Message} to obtain
10406 the message associated with the current exception.
10407
10408 @node Exception_Name
10409 @section Exception_Name
10410 @cindex Exception_Name
10411 @noindent
10412 This intrinsic subprogram is used in the implementation of the
10413 library routine @code{GNAT.Current_Exception}. The only useful
10414 use of the intrinsic import in this case is the one in this unit,
10415 so an application program should simply call the function
10416 @code{GNAT.Current_Exception.Exception_Name} to obtain
10417 the name of the current exception.
10418
10419 @node File
10420 @section File
10421 @cindex File
10422 @noindent
10423 This intrinsic subprogram is used in the implementation of the
10424 library routine @code{GNAT.Source_Info}. The only useful use of the
10425 intrinsic import in this case is the one in this unit, so an
10426 application program should simply call the function
10427 @code{GNAT.Source_Info.File} to obtain the name of the current
10428 file.
10429
10430 @node Line
10431 @section Line
10432 @cindex Line
10433 @noindent
10434 This intrinsic subprogram is used in the implementation of the
10435 library routine @code{GNAT.Source_Info}. The only useful use of the
10436 intrinsic import in this case is the one in this unit, so an
10437 application program should simply call the function
10438 @code{GNAT.Source_Info.Line} to obtain the number of the current
10439 source line.
10440
10441 @node Rotate_Left
10442 @section Rotate_Left
10443 @cindex Rotate_Left
10444 @noindent
10445 In standard Ada, the @code{Rotate_Left} function is available only
10446 for the predefined modular types in package @code{Interfaces}. However, in
10447 GNAT it is possible to define a Rotate_Left function for a user
10448 defined modular type or any signed integer type as in this example:
10449
10450 @smallexample @c ada
10451 function Shift_Left
10452 (Value : My_Modular_Type;
10453 Amount : Natural)
10454 return My_Modular_Type;
10455 @end smallexample
10456
10457 @noindent
10458 The requirements are that the profile be exactly as in the example
10459 above. The only modifications allowed are in the formal parameter
10460 names, and in the type of @code{Value} and the return type, which
10461 must be the same, and must be either a signed integer type, or
10462 a modular integer type with a binary modulus, and the size must
10463 be 8. 16, 32 or 64 bits.
10464
10465 @node Rotate_Right
10466 @section Rotate_Right
10467 @cindex Rotate_Right
10468 @noindent
10469 A @code{Rotate_Right} function can be defined for any user defined
10470 binary modular integer type, or signed integer type, as described
10471 above for @code{Rotate_Left}.
10472
10473 @node Shift_Left
10474 @section Shift_Left
10475 @cindex Shift_Left
10476 @noindent
10477 A @code{Shift_Left} function can be defined for any user defined
10478 binary modular integer type, or signed integer type, as described
10479 above for @code{Rotate_Left}.
10480
10481 @node Shift_Right
10482 @section Shift_Right
10483 @cindex Shift_Right
10484 @noindent
10485 A @code{Shift_Right} function can be defined for any user defined
10486 binary modular integer type, or signed integer type, as described
10487 above for @code{Rotate_Left}.
10488
10489 @node Shift_Right_Arithmetic
10490 @section Shift_Right_Arithmetic
10491 @cindex Shift_Right_Arithmetic
10492 @noindent
10493 A @code{Shift_Right_Arithmetic} function can be defined for any user
10494 defined binary modular integer type, or signed integer type, as described
10495 above for @code{Rotate_Left}.
10496
10497 @node Source_Location
10498 @section Source_Location
10499 @cindex Source_Location
10500 @noindent
10501 This intrinsic subprogram is used in the implementation of the
10502 library routine @code{GNAT.Source_Info}. The only useful use of the
10503 intrinsic import in this case is the one in this unit, so an
10504 application program should simply call the function
10505 @code{GNAT.Source_Info.Source_Location} to obtain the current
10506 source file location.
10507
10508 @node Representation Clauses and Pragmas
10509 @chapter Representation Clauses and Pragmas
10510 @cindex Representation Clauses
10511
10512 @menu
10513 * Alignment Clauses::
10514 * Size Clauses::
10515 * Storage_Size Clauses::
10516 * Size of Variant Record Objects::
10517 * Biased Representation ::
10518 * Value_Size and Object_Size Clauses::
10519 * Component_Size Clauses::
10520 * Bit_Order Clauses::
10521 * Effect of Bit_Order on Byte Ordering::
10522 * Pragma Pack for Arrays::
10523 * Pragma Pack for Records::
10524 * Record Representation Clauses::
10525 * Enumeration Clauses::
10526 * Address Clauses::
10527 * Effect of Convention on Representation::
10528 * Determining the Representations chosen by GNAT::
10529 @end menu
10530
10531 @noindent
10532 @cindex Representation Clause
10533 @cindex Representation Pragma
10534 @cindex Pragma, representation
10535 This section describes the representation clauses accepted by GNAT, and
10536 their effect on the representation of corresponding data objects.
10537
10538 GNAT fully implements Annex C (Systems Programming). This means that all
10539 the implementation advice sections in chapter 13 are fully implemented.
10540 However, these sections only require a minimal level of support for
10541 representation clauses. GNAT provides much more extensive capabilities,
10542 and this section describes the additional capabilities provided.
10543
10544 @node Alignment Clauses
10545 @section Alignment Clauses
10546 @cindex Alignment Clause
10547
10548 @noindent
10549 GNAT requires that all alignment clauses specify a power of 2, and all
10550 default alignments are always a power of 2. The default alignment
10551 values are as follows:
10552
10553 @itemize @bullet
10554 @item @emph{Primitive Types}.
10555 For primitive types, the alignment is the minimum of the actual size of
10556 objects of the type divided by @code{Storage_Unit},
10557 and the maximum alignment supported by the target.
10558 (This maximum alignment is given by the GNAT-specific attribute
10559 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10560 @cindex @code{Maximum_Alignment} attribute
10561 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10562 default alignment will be 8 on any target that supports alignments
10563 this large, but on some targets, the maximum alignment may be smaller
10564 than 8, in which case objects of type @code{Long_Float} will be maximally
10565 aligned.
10566
10567 @item @emph{Arrays}.
10568 For arrays, the alignment is equal to the alignment of the component type
10569 for the normal case where no packing or component size is given. If the
10570 array is packed, and the packing is effective (see separate section on
10571 packed arrays), then the alignment will be one for long packed arrays,
10572 or arrays whose length is not known at compile time. For short packed
10573 arrays, which are handled internally as modular types, the alignment
10574 will be as described for primitive types, e.g.@: a packed array of length
10575 31 bits will have an object size of four bytes, and an alignment of 4.
10576
10577 @item @emph{Records}.
10578 For the normal non-packed case, the alignment of a record is equal to
10579 the maximum alignment of any of its components. For tagged records, this
10580 includes the implicit access type used for the tag. If a pragma @code{Pack}
10581 is used and all components are packable (see separate section on pragma
10582 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10583 record makes it profitable to increase it.
10584
10585 A special case is when:
10586 @itemize @bullet
10587 @item
10588 the size of the record is given explicitly, or a
10589 full record representation clause is given, and
10590 @item
10591 the size of the record is 2, 4, or 8 bytes.
10592 @end itemize
10593 @noindent
10594 In this case, an alignment is chosen to match the
10595 size of the record. For example, if we have:
10596
10597 @smallexample @c ada
10598 type Small is record
10599 A, B : Character;
10600 end record;
10601 for Small'Size use 16;
10602 @end smallexample
10603
10604 @noindent
10605 then the default alignment of the record type @code{Small} is 2, not 1. This
10606 leads to more efficient code when the record is treated as a unit, and also
10607 allows the type to specified as @code{Atomic} on architectures requiring
10608 strict alignment.
10609
10610 @end itemize
10611
10612 @noindent
10613 An alignment clause may specify a larger alignment than the default value
10614 up to some maximum value dependent on the target (obtainable by using the
10615 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10616 a smaller alignment than the default value for enumeration, integer and
10617 fixed point types, as well as for record types, for example
10618
10619 @smallexample @c ada
10620 type V is record
10621 A : Integer;
10622 end record;
10623
10624 for V'alignment use 1;
10625 @end smallexample
10626
10627 @noindent
10628 @cindex Alignment, default
10629 The default alignment for the type @code{V} is 4, as a result of the
10630 Integer field in the record, but it is permissible, as shown, to
10631 override the default alignment of the record with a smaller value.
10632
10633 @node Size Clauses
10634 @section Size Clauses
10635 @cindex Size Clause
10636
10637 @noindent
10638 The default size for a type @code{T} is obtainable through the
10639 language-defined attribute @code{T'Size} and also through the
10640 equivalent GNAT-defined attribute @code{T'Value_Size}.
10641 For objects of type @code{T}, GNAT will generally increase the type size
10642 so that the object size (obtainable through the GNAT-defined attribute
10643 @code{T'Object_Size})
10644 is a multiple of @code{T'Alignment * Storage_Unit}.
10645 For example
10646
10647 @smallexample @c ada
10648 type Smallint is range 1 .. 6;
10649
10650 type Rec is record
10651 Y1 : integer;
10652 Y2 : boolean;
10653 end record;
10654 @end smallexample
10655
10656 @noindent
10657 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10658 as specified by the RM rules,
10659 but objects of this type will have a size of 8
10660 (@code{Smallint'Object_Size} = 8),
10661 since objects by default occupy an integral number
10662 of storage units. On some targets, notably older
10663 versions of the Digital Alpha, the size of stand
10664 alone objects of this type may be 32, reflecting
10665 the inability of the hardware to do byte load/stores.
10666
10667 Similarly, the size of type @code{Rec} is 40 bits
10668 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10669 the alignment is 4, so objects of this type will have
10670 their size increased to 64 bits so that it is a multiple
10671 of the alignment (in bits). This decision is
10672 in accordance with the specific Implementation Advice in RM 13.3(43):
10673
10674 @quotation
10675 A @code{Size} clause should be supported for an object if the specified
10676 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10677 to a size in storage elements that is a multiple of the object's
10678 @code{Alignment} (if the @code{Alignment} is nonzero).
10679 @end quotation
10680
10681 @noindent
10682 An explicit size clause may be used to override the default size by
10683 increasing it. For example, if we have:
10684
10685 @smallexample @c ada
10686 type My_Boolean is new Boolean;
10687 for My_Boolean'Size use 32;
10688 @end smallexample
10689
10690 @noindent
10691 then values of this type will always be 32 bits long. In the case of
10692 discrete types, the size can be increased up to 64 bits, with the effect
10693 that the entire specified field is used to hold the value, sign- or
10694 zero-extended as appropriate. If more than 64 bits is specified, then
10695 padding space is allocated after the value, and a warning is issued that
10696 there are unused bits.
10697
10698 Similarly the size of records and arrays may be increased, and the effect
10699 is to add padding bits after the value. This also causes a warning message
10700 to be generated.
10701
10702 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10703 Size in bits, this corresponds to an object of size 256 megabytes (minus
10704 one). This limitation is true on all targets. The reason for this
10705 limitation is that it improves the quality of the code in many cases
10706 if it is known that a Size value can be accommodated in an object of
10707 type Integer.
10708
10709 @node Storage_Size Clauses
10710 @section Storage_Size Clauses
10711 @cindex Storage_Size Clause
10712
10713 @noindent
10714 For tasks, the @code{Storage_Size} clause specifies the amount of space
10715 to be allocated for the task stack. This cannot be extended, and if the
10716 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10717 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10718 or a @code{Storage_Size} pragma in the task definition to set the
10719 appropriate required size. A useful technique is to include in every
10720 task definition a pragma of the form:
10721
10722 @smallexample @c ada
10723 pragma Storage_Size (Default_Stack_Size);
10724 @end smallexample
10725
10726 @noindent
10727 Then @code{Default_Stack_Size} can be defined in a global package, and
10728 modified as required. Any tasks requiring stack sizes different from the
10729 default can have an appropriate alternative reference in the pragma.
10730
10731 You can also use the @option{-d} binder switch to modify the default stack
10732 size.
10733
10734 For access types, the @code{Storage_Size} clause specifies the maximum
10735 space available for allocation of objects of the type. If this space is
10736 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10737 In the case where the access type is declared local to a subprogram, the
10738 use of a @code{Storage_Size} clause triggers automatic use of a special
10739 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10740 space for the pool is automatically reclaimed on exit from the scope in
10741 which the type is declared.
10742
10743 A special case recognized by the compiler is the specification of a
10744 @code{Storage_Size} of zero for an access type. This means that no
10745 items can be allocated from the pool, and this is recognized at compile
10746 time, and all the overhead normally associated with maintaining a fixed
10747 size storage pool is eliminated. Consider the following example:
10748
10749 @smallexample @c ada
10750 procedure p is
10751 type R is array (Natural) of Character;
10752 type P is access all R;
10753 for P'Storage_Size use 0;
10754 -- Above access type intended only for interfacing purposes
10755
10756 y : P;
10757
10758 procedure g (m : P);
10759 pragma Import (C, g);
10760
10761 -- @dots{}
10762
10763 begin
10764 -- @dots{}
10765 y := new R;
10766 end;
10767 @end smallexample
10768
10769 @noindent
10770 As indicated in this example, these dummy storage pools are often useful in
10771 connection with interfacing where no object will ever be allocated. If you
10772 compile the above example, you get the warning:
10773
10774 @smallexample
10775 p.adb:16:09: warning: allocation from empty storage pool
10776 p.adb:16:09: warning: Storage_Error will be raised at run time
10777 @end smallexample
10778
10779 @noindent
10780 Of course in practice, there will not be any explicit allocators in the
10781 case of such an access declaration.
10782
10783 @node Size of Variant Record Objects
10784 @section Size of Variant Record Objects
10785 @cindex Size, variant record objects
10786 @cindex Variant record objects, size
10787
10788 @noindent
10789 In the case of variant record objects, there is a question whether Size gives
10790 information about a particular variant, or the maximum size required
10791 for any variant. Consider the following program
10792
10793 @smallexample @c ada
10794 with Text_IO; use Text_IO;
10795 procedure q is
10796 type R1 (A : Boolean := False) is record
10797 case A is
10798 when True => X : Character;
10799 when False => null;
10800 end case;
10801 end record;
10802
10803 V1 : R1 (False);
10804 V2 : R1;
10805
10806 begin
10807 Put_Line (Integer'Image (V1'Size));
10808 Put_Line (Integer'Image (V2'Size));
10809 end q;
10810 @end smallexample
10811
10812 @noindent
10813 Here we are dealing with a variant record, where the True variant
10814 requires 16 bits, and the False variant requires 8 bits.
10815 In the above example, both V1 and V2 contain the False variant,
10816 which is only 8 bits long. However, the result of running the
10817 program is:
10818
10819 @smallexample
10820 8
10821 16
10822 @end smallexample
10823
10824 @noindent
10825 The reason for the difference here is that the discriminant value of
10826 V1 is fixed, and will always be False. It is not possible to assign
10827 a True variant value to V1, therefore 8 bits is sufficient. On the
10828 other hand, in the case of V2, the initial discriminant value is
10829 False (from the default), but it is possible to assign a True
10830 variant value to V2, therefore 16 bits must be allocated for V2
10831 in the general case, even fewer bits may be needed at any particular
10832 point during the program execution.
10833
10834 As can be seen from the output of this program, the @code{'Size}
10835 attribute applied to such an object in GNAT gives the actual allocated
10836 size of the variable, which is the largest size of any of the variants.
10837 The Ada Reference Manual is not completely clear on what choice should
10838 be made here, but the GNAT behavior seems most consistent with the
10839 language in the RM@.
10840
10841 In some cases, it may be desirable to obtain the size of the current
10842 variant, rather than the size of the largest variant. This can be
10843 achieved in GNAT by making use of the fact that in the case of a
10844 subprogram parameter, GNAT does indeed return the size of the current
10845 variant (because a subprogram has no way of knowing how much space
10846 is actually allocated for the actual).
10847
10848 Consider the following modified version of the above program:
10849
10850 @smallexample @c ada
10851 with Text_IO; use Text_IO;
10852 procedure q is
10853 type R1 (A : Boolean := False) is record
10854 case A is
10855 when True => X : Character;
10856 when False => null;
10857 end case;
10858 end record;
10859
10860 V2 : R1;
10861
10862 function Size (V : R1) return Integer is
10863 begin
10864 return V'Size;
10865 end Size;
10866
10867 begin
10868 Put_Line (Integer'Image (V2'Size));
10869 Put_Line (Integer'IMage (Size (V2)));
10870 V2 := (True, 'x');
10871 Put_Line (Integer'Image (V2'Size));
10872 Put_Line (Integer'IMage (Size (V2)));
10873 end q;
10874 @end smallexample
10875
10876 @noindent
10877 The output from this program is
10878
10879 @smallexample
10880 16
10881 8
10882 16
10883 16
10884 @end smallexample
10885
10886 @noindent
10887 Here we see that while the @code{'Size} attribute always returns
10888 the maximum size, regardless of the current variant value, the
10889 @code{Size} function does indeed return the size of the current
10890 variant value.
10891
10892 @node Biased Representation
10893 @section Biased Representation
10894 @cindex Size for biased representation
10895 @cindex Biased representation
10896
10897 @noindent
10898 In the case of scalars with a range starting at other than zero, it is
10899 possible in some cases to specify a size smaller than the default minimum
10900 value, and in such cases, GNAT uses an unsigned biased representation,
10901 in which zero is used to represent the lower bound, and successive values
10902 represent successive values of the type.
10903
10904 For example, suppose we have the declaration:
10905
10906 @smallexample @c ada
10907 type Small is range -7 .. -4;
10908 for Small'Size use 2;
10909 @end smallexample
10910
10911 @noindent
10912 Although the default size of type @code{Small} is 4, the @code{Size}
10913 clause is accepted by GNAT and results in the following representation
10914 scheme:
10915
10916 @smallexample
10917 -7 is represented as 2#00#
10918 -6 is represented as 2#01#
10919 -5 is represented as 2#10#
10920 -4 is represented as 2#11#
10921 @end smallexample
10922
10923 @noindent
10924 Biased representation is only used if the specified @code{Size} clause
10925 cannot be accepted in any other manner. These reduced sizes that force
10926 biased representation can be used for all discrete types except for
10927 enumeration types for which a representation clause is given.
10928
10929 @node Value_Size and Object_Size Clauses
10930 @section Value_Size and Object_Size Clauses
10931 @findex Value_Size
10932 @findex Object_Size
10933 @cindex Size, of objects
10934
10935 @noindent
10936 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10937 number of bits required to hold values of type @code{T}.
10938 Although this interpretation was allowed in Ada 83, it was not required,
10939 and this requirement in practice can cause some significant difficulties.
10940 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10941 However, in Ada 95 and Ada 2005,
10942 @code{Natural'Size} is
10943 typically 31. This means that code may change in behavior when moving
10944 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10945
10946 @smallexample @c ada
10947 type Rec is record;
10948 A : Natural;
10949 B : Natural;
10950 end record;
10951
10952 for Rec use record
10953 at 0 range 0 .. Natural'Size - 1;
10954 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10955 end record;
10956 @end smallexample
10957
10958 @noindent
10959 In the above code, since the typical size of @code{Natural} objects
10960 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10961 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10962 there are cases where the fact that the object size can exceed the
10963 size of the type causes surprises.
10964
10965 To help get around this problem GNAT provides two implementation
10966 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10967 applied to a type, these attributes yield the size of the type
10968 (corresponding to the RM defined size attribute), and the size of
10969 objects of the type respectively.
10970
10971 The @code{Object_Size} is used for determining the default size of
10972 objects and components. This size value can be referred to using the
10973 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10974 the basis of the determination of the size. The backend is free to
10975 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10976 character might be stored in 32 bits on a machine with no efficient
10977 byte access instructions such as the Alpha.
10978
10979 The default rules for the value of @code{Object_Size} for
10980 discrete types are as follows:
10981
10982 @itemize @bullet
10983 @item
10984 The @code{Object_Size} for base subtypes reflect the natural hardware
10985 size in bits (run the compiler with @option{-gnatS} to find those values
10986 for numeric types). Enumeration types and fixed-point base subtypes have
10987 8, 16, 32 or 64 bits for this size, depending on the range of values
10988 to be stored.
10989
10990 @item
10991 The @code{Object_Size} of a subtype is the same as the
10992 @code{Object_Size} of
10993 the type from which it is obtained.
10994
10995 @item
10996 The @code{Object_Size} of a derived base type is copied from the parent
10997 base type, and the @code{Object_Size} of a derived first subtype is copied
10998 from the parent first subtype.
10999 @end itemize
11000
11001 @noindent
11002 The @code{Value_Size} attribute
11003 is the (minimum) number of bits required to store a value
11004 of the type.
11005 This value is used to determine how tightly to pack
11006 records or arrays with components of this type, and also affects
11007 the semantics of unchecked conversion (unchecked conversions where
11008 the @code{Value_Size} values differ generate a warning, and are potentially
11009 target dependent).
11010
11011 The default rules for the value of @code{Value_Size} are as follows:
11012
11013 @itemize @bullet
11014 @item
11015 The @code{Value_Size} for a base subtype is the minimum number of bits
11016 required to store all values of the type (including the sign bit
11017 only if negative values are possible).
11018
11019 @item
11020 If a subtype statically matches the first subtype of a given type, then it has
11021 by default the same @code{Value_Size} as the first subtype. This is a
11022 consequence of RM 13.1(14) (``if two subtypes statically match,
11023 then their subtype-specific aspects are the same''.)
11024
11025 @item
11026 All other subtypes have a @code{Value_Size} corresponding to the minimum
11027 number of bits required to store all values of the subtype. For
11028 dynamic bounds, it is assumed that the value can range down or up
11029 to the corresponding bound of the ancestor
11030 @end itemize
11031
11032 @noindent
11033 The RM defined attribute @code{Size} corresponds to the
11034 @code{Value_Size} attribute.
11035
11036 The @code{Size} attribute may be defined for a first-named subtype. This sets
11037 the @code{Value_Size} of
11038 the first-named subtype to the given value, and the
11039 @code{Object_Size} of this first-named subtype to the given value padded up
11040 to an appropriate boundary. It is a consequence of the default rules
11041 above that this @code{Object_Size} will apply to all further subtypes. On the
11042 other hand, @code{Value_Size} is affected only for the first subtype, any
11043 dynamic subtypes obtained from it directly, and any statically matching
11044 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11045
11046 @code{Value_Size} and
11047 @code{Object_Size} may be explicitly set for any subtype using
11048 an attribute definition clause. Note that the use of these attributes
11049 can cause the RM 13.1(14) rule to be violated. If two access types
11050 reference aliased objects whose subtypes have differing @code{Object_Size}
11051 values as a result of explicit attribute definition clauses, then it
11052 is erroneous to convert from one access subtype to the other.
11053
11054 At the implementation level, Esize stores the Object_Size and the
11055 RM_Size field stores the @code{Value_Size} (and hence the value of the
11056 @code{Size} attribute,
11057 which, as noted above, is equivalent to @code{Value_Size}).
11058
11059 To get a feel for the difference, consider the following examples (note
11060 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11061
11062 @smallexample
11063 Object_Size Value_Size
11064
11065 type x1 is range 0 .. 5; 8 3
11066
11067 type x2 is range 0 .. 5;
11068 for x2'size use 12; 16 12
11069
11070 subtype x3 is x2 range 0 .. 3; 16 2
11071
11072 subtype x4 is x2'base range 0 .. 10; 8 4
11073
11074 subtype x5 is x2 range 0 .. dynamic; 16 3*
11075
11076 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11077
11078 @end smallexample
11079
11080 @noindent
11081 Note: the entries marked ``3*'' are not actually specified by the Ada
11082 Reference Manual, but it seems in the spirit of the RM rules to allocate
11083 the minimum number of bits (here 3, given the range for @code{x2})
11084 known to be large enough to hold the given range of values.
11085
11086 So far, so good, but GNAT has to obey the RM rules, so the question is
11087 under what conditions must the RM @code{Size} be used.
11088 The following is a list
11089 of the occasions on which the RM @code{Size} must be used:
11090
11091 @itemize @bullet
11092 @item
11093 Component size for packed arrays or records
11094
11095 @item
11096 Value of the attribute @code{Size} for a type
11097
11098 @item
11099 Warning about sizes not matching for unchecked conversion
11100 @end itemize
11101
11102 @noindent
11103 For record types, the @code{Object_Size} is always a multiple of the
11104 alignment of the type (this is true for all types). In some cases the
11105 @code{Value_Size} can be smaller. Consider:
11106
11107 @smallexample
11108 type R is record
11109 X : Integer;
11110 Y : Character;
11111 end record;
11112 @end smallexample
11113
11114 @noindent
11115 On a typical 32-bit architecture, the X component will be four bytes, and
11116 require four-byte alignment, and the Y component will be one byte. In this
11117 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11118 required to store a value of this type, and for example, it is permissible
11119 to have a component of type R in an outer array whose component size is
11120 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11121 since it must be rounded up so that this value is a multiple of the
11122 alignment (4 bytes = 32 bits).
11123
11124 @noindent
11125 For all other types, the @code{Object_Size}
11126 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11127 Only @code{Size} may be specified for such types.
11128
11129 @node Component_Size Clauses
11130 @section Component_Size Clauses
11131 @cindex Component_Size Clause
11132
11133 @noindent
11134 Normally, the value specified in a component size clause must be consistent
11135 with the subtype of the array component with regard to size and alignment.
11136 In other words, the value specified must be at least equal to the size
11137 of this subtype, and must be a multiple of the alignment value.
11138
11139 In addition, component size clauses are allowed which cause the array
11140 to be packed, by specifying a smaller value. A first case is for
11141 component size values in the range 1 through 63. The value specified
11142 must not be smaller than the Size of the subtype. GNAT will accurately
11143 honor all packing requests in this range. For example, if we have:
11144
11145 @smallexample @c ada
11146 type r is array (1 .. 8) of Natural;
11147 for r'Component_Size use 31;
11148 @end smallexample
11149
11150 @noindent
11151 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11152 Of course access to the components of such an array is considerably
11153 less efficient than if the natural component size of 32 is used.
11154 A second case is when the subtype of the component is a record type
11155 padded because of its default alignment. For example, if we have:
11156
11157 @smallexample @c ada
11158 type r is record
11159 i : Integer;
11160 j : Integer;
11161 b : Boolean;
11162 end record;
11163
11164 type a is array (1 .. 8) of r;
11165 for a'Component_Size use 72;
11166 @end smallexample
11167
11168 @noindent
11169 then the resulting array has a length of 72 bytes, instead of 96 bytes
11170 if the alignment of the record (4) was obeyed.
11171
11172 Note that there is no point in giving both a component size clause
11173 and a pragma Pack for the same array type. if such duplicate
11174 clauses are given, the pragma Pack will be ignored.
11175
11176 @node Bit_Order Clauses
11177 @section Bit_Order Clauses
11178 @cindex Bit_Order Clause
11179 @cindex bit ordering
11180 @cindex ordering, of bits
11181
11182 @noindent
11183 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11184 attribute. The specification may either correspond to the default bit
11185 order for the target, in which case the specification has no effect and
11186 places no additional restrictions, or it may be for the non-standard
11187 setting (that is the opposite of the default).
11188
11189 In the case where the non-standard value is specified, the effect is
11190 to renumber bits within each byte, but the ordering of bytes is not
11191 affected. There are certain
11192 restrictions placed on component clauses as follows:
11193
11194 @itemize @bullet
11195
11196 @item Components fitting within a single storage unit.
11197 @noindent
11198 These are unrestricted, and the effect is merely to renumber bits. For
11199 example if we are on a little-endian machine with @code{Low_Order_First}
11200 being the default, then the following two declarations have exactly
11201 the same effect:
11202
11203 @smallexample @c ada
11204 type R1 is record
11205 A : Boolean;
11206 B : Integer range 1 .. 120;
11207 end record;
11208
11209 for R1 use record
11210 A at 0 range 0 .. 0;
11211 B at 0 range 1 .. 7;
11212 end record;
11213
11214 type R2 is record
11215 A : Boolean;
11216 B : Integer range 1 .. 120;
11217 end record;
11218
11219 for R2'Bit_Order use High_Order_First;
11220
11221 for R2 use record
11222 A at 0 range 7 .. 7;
11223 B at 0 range 0 .. 6;
11224 end record;
11225 @end smallexample
11226
11227 @noindent
11228 The useful application here is to write the second declaration with the
11229 @code{Bit_Order} attribute definition clause, and know that it will be treated
11230 the same, regardless of whether the target is little-endian or big-endian.
11231
11232 @item Components occupying an integral number of bytes.
11233 @noindent
11234 These are components that exactly fit in two or more bytes. Such component
11235 declarations are allowed, but have no effect, since it is important to realize
11236 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11237 In particular, the following attempt at getting an endian-independent integer
11238 does not work:
11239
11240 @smallexample @c ada
11241 type R2 is record
11242 A : Integer;
11243 end record;
11244
11245 for R2'Bit_Order use High_Order_First;
11246
11247 for R2 use record
11248 A at 0 range 0 .. 31;
11249 end record;
11250 @end smallexample
11251
11252 @noindent
11253 This declaration will result in a little-endian integer on a
11254 little-endian machine, and a big-endian integer on a big-endian machine.
11255 If byte flipping is required for interoperability between big- and
11256 little-endian machines, this must be explicitly programmed. This capability
11257 is not provided by @code{Bit_Order}.
11258
11259 @item Components that are positioned across byte boundaries
11260 @noindent
11261 but do not occupy an integral number of bytes. Given that bytes are not
11262 reordered, such fields would occupy a non-contiguous sequence of bits
11263 in memory, requiring non-trivial code to reassemble. They are for this
11264 reason not permitted, and any component clause specifying such a layout
11265 will be flagged as illegal by GNAT@.
11266
11267 @end itemize
11268
11269 @noindent
11270 Since the misconception that Bit_Order automatically deals with all
11271 endian-related incompatibilities is a common one, the specification of
11272 a component field that is an integral number of bytes will always
11273 generate a warning. This warning may be suppressed using @code{pragma
11274 Warnings (Off)} if desired. The following section contains additional
11275 details regarding the issue of byte ordering.
11276
11277 @node Effect of Bit_Order on Byte Ordering
11278 @section Effect of Bit_Order on Byte Ordering
11279 @cindex byte ordering
11280 @cindex ordering, of bytes
11281
11282 @noindent
11283 In this section we will review the effect of the @code{Bit_Order} attribute
11284 definition clause on byte ordering. Briefly, it has no effect at all, but
11285 a detailed example will be helpful. Before giving this
11286 example, let us review the precise
11287 definition of the effect of defining @code{Bit_Order}. The effect of a
11288 non-standard bit order is described in section 15.5.3 of the Ada
11289 Reference Manual:
11290
11291 @quotation
11292 2 A bit ordering is a method of interpreting the meaning of
11293 the storage place attributes.
11294 @end quotation
11295
11296 @noindent
11297 To understand the precise definition of storage place attributes in
11298 this context, we visit section 13.5.1 of the manual:
11299
11300 @quotation
11301 13 A record_representation_clause (without the mod_clause)
11302 specifies the layout. The storage place attributes (see 13.5.2)
11303 are taken from the values of the position, first_bit, and last_bit
11304 expressions after normalizing those values so that first_bit is
11305 less than Storage_Unit.
11306 @end quotation
11307
11308 @noindent
11309 The critical point here is that storage places are taken from
11310 the values after normalization, not before. So the @code{Bit_Order}
11311 interpretation applies to normalized values. The interpretation
11312 is described in the later part of the 15.5.3 paragraph:
11313
11314 @quotation
11315 2 A bit ordering is a method of interpreting the meaning of
11316 the storage place attributes. High_Order_First (known in the
11317 vernacular as ``big endian'') means that the first bit of a
11318 storage element (bit 0) is the most significant bit (interpreting
11319 the sequence of bits that represent a component as an unsigned
11320 integer value). Low_Order_First (known in the vernacular as
11321 ``little endian'') means the opposite: the first bit is the
11322 least significant.
11323 @end quotation
11324
11325 @noindent
11326 Note that the numbering is with respect to the bits of a storage
11327 unit. In other words, the specification affects only the numbering
11328 of bits within a single storage unit.
11329
11330 We can make the effect clearer by giving an example.
11331
11332 Suppose that we have an external device which presents two bytes, the first
11333 byte presented, which is the first (low addressed byte) of the two byte
11334 record is called Master, and the second byte is called Slave.
11335
11336 The left most (most significant bit is called Control for each byte, and
11337 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11338 (least significant) bit.
11339
11340 On a big-endian machine, we can write the following representation clause
11341
11342 @smallexample @c ada
11343 type Data is record
11344 Master_Control : Bit;
11345 Master_V1 : Bit;
11346 Master_V2 : Bit;
11347 Master_V3 : Bit;
11348 Master_V4 : Bit;
11349 Master_V5 : Bit;
11350 Master_V6 : Bit;
11351 Master_V7 : Bit;
11352 Slave_Control : Bit;
11353 Slave_V1 : Bit;
11354 Slave_V2 : Bit;
11355 Slave_V3 : Bit;
11356 Slave_V4 : Bit;
11357 Slave_V5 : Bit;
11358 Slave_V6 : Bit;
11359 Slave_V7 : Bit;
11360 end record;
11361
11362 for Data use record
11363 Master_Control at 0 range 0 .. 0;
11364 Master_V1 at 0 range 1 .. 1;
11365 Master_V2 at 0 range 2 .. 2;
11366 Master_V3 at 0 range 3 .. 3;
11367 Master_V4 at 0 range 4 .. 4;
11368 Master_V5 at 0 range 5 .. 5;
11369 Master_V6 at 0 range 6 .. 6;
11370 Master_V7 at 0 range 7 .. 7;
11371 Slave_Control at 1 range 0 .. 0;
11372 Slave_V1 at 1 range 1 .. 1;
11373 Slave_V2 at 1 range 2 .. 2;
11374 Slave_V3 at 1 range 3 .. 3;
11375 Slave_V4 at 1 range 4 .. 4;
11376 Slave_V5 at 1 range 5 .. 5;
11377 Slave_V6 at 1 range 6 .. 6;
11378 Slave_V7 at 1 range 7 .. 7;
11379 end record;
11380 @end smallexample
11381
11382 @noindent
11383 Now if we move this to a little endian machine, then the bit ordering within
11384 the byte is backwards, so we have to rewrite the record rep clause as:
11385
11386 @smallexample @c ada
11387 for Data use record
11388 Master_Control at 0 range 7 .. 7;
11389 Master_V1 at 0 range 6 .. 6;
11390 Master_V2 at 0 range 5 .. 5;
11391 Master_V3 at 0 range 4 .. 4;
11392 Master_V4 at 0 range 3 .. 3;
11393 Master_V5 at 0 range 2 .. 2;
11394 Master_V6 at 0 range 1 .. 1;
11395 Master_V7 at 0 range 0 .. 0;
11396 Slave_Control at 1 range 7 .. 7;
11397 Slave_V1 at 1 range 6 .. 6;
11398 Slave_V2 at 1 range 5 .. 5;
11399 Slave_V3 at 1 range 4 .. 4;
11400 Slave_V4 at 1 range 3 .. 3;
11401 Slave_V5 at 1 range 2 .. 2;
11402 Slave_V6 at 1 range 1 .. 1;
11403 Slave_V7 at 1 range 0 .. 0;
11404 end record;
11405 @end smallexample
11406
11407 @noindent
11408 It is a nuisance to have to rewrite the clause, especially if
11409 the code has to be maintained on both machines. However,
11410 this is a case that we can handle with the
11411 @code{Bit_Order} attribute if it is implemented.
11412 Note that the implementation is not required on byte addressed
11413 machines, but it is indeed implemented in GNAT.
11414 This means that we can simply use the
11415 first record clause, together with the declaration
11416
11417 @smallexample @c ada
11418 for Data'Bit_Order use High_Order_First;
11419 @end smallexample
11420
11421 @noindent
11422 and the effect is what is desired, namely the layout is exactly the same,
11423 independent of whether the code is compiled on a big-endian or little-endian
11424 machine.
11425
11426 The important point to understand is that byte ordering is not affected.
11427 A @code{Bit_Order} attribute definition never affects which byte a field
11428 ends up in, only where it ends up in that byte.
11429 To make this clear, let us rewrite the record rep clause of the previous
11430 example as:
11431
11432 @smallexample @c ada
11433 for Data'Bit_Order use High_Order_First;
11434 for Data use record
11435 Master_Control at 0 range 0 .. 0;
11436 Master_V1 at 0 range 1 .. 1;
11437 Master_V2 at 0 range 2 .. 2;
11438 Master_V3 at 0 range 3 .. 3;
11439 Master_V4 at 0 range 4 .. 4;
11440 Master_V5 at 0 range 5 .. 5;
11441 Master_V6 at 0 range 6 .. 6;
11442 Master_V7 at 0 range 7 .. 7;
11443 Slave_Control at 0 range 8 .. 8;
11444 Slave_V1 at 0 range 9 .. 9;
11445 Slave_V2 at 0 range 10 .. 10;
11446 Slave_V3 at 0 range 11 .. 11;
11447 Slave_V4 at 0 range 12 .. 12;
11448 Slave_V5 at 0 range 13 .. 13;
11449 Slave_V6 at 0 range 14 .. 14;
11450 Slave_V7 at 0 range 15 .. 15;
11451 end record;
11452 @end smallexample
11453
11454 @noindent
11455 This is exactly equivalent to saying (a repeat of the first example):
11456
11457 @smallexample @c ada
11458 for Data'Bit_Order use High_Order_First;
11459 for Data use record
11460 Master_Control at 0 range 0 .. 0;
11461 Master_V1 at 0 range 1 .. 1;
11462 Master_V2 at 0 range 2 .. 2;
11463 Master_V3 at 0 range 3 .. 3;
11464 Master_V4 at 0 range 4 .. 4;
11465 Master_V5 at 0 range 5 .. 5;
11466 Master_V6 at 0 range 6 .. 6;
11467 Master_V7 at 0 range 7 .. 7;
11468 Slave_Control at 1 range 0 .. 0;
11469 Slave_V1 at 1 range 1 .. 1;
11470 Slave_V2 at 1 range 2 .. 2;
11471 Slave_V3 at 1 range 3 .. 3;
11472 Slave_V4 at 1 range 4 .. 4;
11473 Slave_V5 at 1 range 5 .. 5;
11474 Slave_V6 at 1 range 6 .. 6;
11475 Slave_V7 at 1 range 7 .. 7;
11476 end record;
11477 @end smallexample
11478
11479 @noindent
11480 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11481 field. The storage place attributes are obtained by normalizing the
11482 values given so that the @code{First_Bit} value is less than 8. After
11483 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11484 we specified in the other case.
11485
11486 Now one might expect that the @code{Bit_Order} attribute might affect
11487 bit numbering within the entire record component (two bytes in this
11488 case, thus affecting which byte fields end up in), but that is not
11489 the way this feature is defined, it only affects numbering of bits,
11490 not which byte they end up in.
11491
11492 Consequently it never makes sense to specify a starting bit number
11493 greater than 7 (for a byte addressable field) if an attribute
11494 definition for @code{Bit_Order} has been given, and indeed it
11495 may be actively confusing to specify such a value, so the compiler
11496 generates a warning for such usage.
11497
11498 If you do need to control byte ordering then appropriate conditional
11499 values must be used. If in our example, the slave byte came first on
11500 some machines we might write:
11501
11502 @smallexample @c ada
11503 Master_Byte_First constant Boolean := @dots{};
11504
11505 Master_Byte : constant Natural :=
11506 1 - Boolean'Pos (Master_Byte_First);
11507 Slave_Byte : constant Natural :=
11508 Boolean'Pos (Master_Byte_First);
11509
11510 for Data'Bit_Order use High_Order_First;
11511 for Data use record
11512 Master_Control at Master_Byte range 0 .. 0;
11513 Master_V1 at Master_Byte range 1 .. 1;
11514 Master_V2 at Master_Byte range 2 .. 2;
11515 Master_V3 at Master_Byte range 3 .. 3;
11516 Master_V4 at Master_Byte range 4 .. 4;
11517 Master_V5 at Master_Byte range 5 .. 5;
11518 Master_V6 at Master_Byte range 6 .. 6;
11519 Master_V7 at Master_Byte range 7 .. 7;
11520 Slave_Control at Slave_Byte range 0 .. 0;
11521 Slave_V1 at Slave_Byte range 1 .. 1;
11522 Slave_V2 at Slave_Byte range 2 .. 2;
11523 Slave_V3 at Slave_Byte range 3 .. 3;
11524 Slave_V4 at Slave_Byte range 4 .. 4;
11525 Slave_V5 at Slave_Byte range 5 .. 5;
11526 Slave_V6 at Slave_Byte range 6 .. 6;
11527 Slave_V7 at Slave_Byte range 7 .. 7;
11528 end record;
11529 @end smallexample
11530
11531 @noindent
11532 Now to switch between machines, all that is necessary is
11533 to set the boolean constant @code{Master_Byte_First} in
11534 an appropriate manner.
11535
11536 @node Pragma Pack for Arrays
11537 @section Pragma Pack for Arrays
11538 @cindex Pragma Pack (for arrays)
11539
11540 @noindent
11541 Pragma @code{Pack} applied to an array has no effect unless the component type
11542 is packable. For a component type to be packable, it must be one of the
11543 following cases:
11544
11545 @itemize @bullet
11546 @item
11547 Any scalar type
11548 @item
11549 Any type whose size is specified with a size clause
11550 @item
11551 Any packed array type with a static size
11552 @item
11553 Any record type padded because of its default alignment
11554 @end itemize
11555
11556 @noindent
11557 For all these cases, if the component subtype size is in the range
11558 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11559 component size were specified giving the component subtype size.
11560 For example if we have:
11561
11562 @smallexample @c ada
11563 type r is range 0 .. 17;
11564
11565 type ar is array (1 .. 8) of r;
11566 pragma Pack (ar);
11567 @end smallexample
11568
11569 @noindent
11570 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11571 and the size of the array @code{ar} will be exactly 40 bits.
11572
11573 Note that in some cases this rather fierce approach to packing can produce
11574 unexpected effects. For example, in Ada 95 and Ada 2005,
11575 subtype @code{Natural} typically has a size of 31, meaning that if you
11576 pack an array of @code{Natural}, you get 31-bit
11577 close packing, which saves a few bits, but results in far less efficient
11578 access. Since many other Ada compilers will ignore such a packing request,
11579 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11580 might not be what is intended. You can easily remove this warning by
11581 using an explicit @code{Component_Size} setting instead, which never generates
11582 a warning, since the intention of the programmer is clear in this case.
11583
11584 GNAT treats packed arrays in one of two ways. If the size of the array is
11585 known at compile time and is less than 64 bits, then internally the array
11586 is represented as a single modular type, of exactly the appropriate number
11587 of bits. If the length is greater than 63 bits, or is not known at compile
11588 time, then the packed array is represented as an array of bytes, and the
11589 length is always a multiple of 8 bits.
11590
11591 Note that to represent a packed array as a modular type, the alignment must
11592 be suitable for the modular type involved. For example, on typical machines
11593 a 32-bit packed array will be represented by a 32-bit modular integer with
11594 an alignment of four bytes. If you explicitly override the default alignment
11595 with an alignment clause that is too small, the modular representation
11596 cannot be used. For example, consider the following set of declarations:
11597
11598 @smallexample @c ada
11599 type R is range 1 .. 3;
11600 type S is array (1 .. 31) of R;
11601 for S'Component_Size use 2;
11602 for S'Size use 62;
11603 for S'Alignment use 1;
11604 @end smallexample
11605
11606 @noindent
11607 If the alignment clause were not present, then a 62-bit modular
11608 representation would be chosen (typically with an alignment of 4 or 8
11609 bytes depending on the target). But the default alignment is overridden
11610 with the explicit alignment clause. This means that the modular
11611 representation cannot be used, and instead the array of bytes
11612 representation must be used, meaning that the length must be a multiple
11613 of 8. Thus the above set of declarations will result in a diagnostic
11614 rejecting the size clause and noting that the minimum size allowed is 64.
11615
11616 @cindex Pragma Pack (for type Natural)
11617 @cindex Pragma Pack warning
11618
11619 One special case that is worth noting occurs when the base type of the
11620 component size is 8/16/32 and the subtype is one bit less. Notably this
11621 occurs with subtype @code{Natural}. Consider:
11622
11623 @smallexample @c ada
11624 type Arr is array (1 .. 32) of Natural;
11625 pragma Pack (Arr);
11626 @end smallexample
11627
11628 @noindent
11629 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11630 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11631 Ada 83 compilers did not attempt 31 bit packing.
11632
11633 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11634 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11635 substantial unintended performance penalty when porting legacy Ada 83 code.
11636 To help prevent this, GNAT generates a warning in such cases. If you really
11637 want 31 bit packing in a case like this, you can set the component size
11638 explicitly:
11639
11640 @smallexample @c ada
11641 type Arr is array (1 .. 32) of Natural;
11642 for Arr'Component_Size use 31;
11643 @end smallexample
11644
11645 @noindent
11646 Here 31-bit packing is achieved as required, and no warning is generated,
11647 since in this case the programmer intention is clear.
11648
11649 @node Pragma Pack for Records
11650 @section Pragma Pack for Records
11651 @cindex Pragma Pack (for records)
11652
11653 @noindent
11654 Pragma @code{Pack} applied to a record will pack the components to reduce
11655 wasted space from alignment gaps and by reducing the amount of space
11656 taken by components. We distinguish between @emph{packable} components and
11657 @emph{non-packable} components.
11658 Components of the following types are considered packable:
11659 @itemize @bullet
11660 @item
11661 All primitive types are packable.
11662
11663 @item
11664 Small packed arrays, whose size does not exceed 64 bits, and where the
11665 size is statically known at compile time, are represented internally
11666 as modular integers, and so they are also packable.
11667
11668 @end itemize
11669
11670 @noindent
11671 All packable components occupy the exact number of bits corresponding to
11672 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11673 can start on an arbitrary bit boundary.
11674
11675 All other types are non-packable, they occupy an integral number of
11676 storage units, and
11677 are placed at a boundary corresponding to their alignment requirements.
11678
11679 For example, consider the record
11680
11681 @smallexample @c ada
11682 type Rb1 is array (1 .. 13) of Boolean;
11683 pragma Pack (rb1);
11684
11685 type Rb2 is array (1 .. 65) of Boolean;
11686 pragma Pack (rb2);
11687
11688 type x2 is record
11689 l1 : Boolean;
11690 l2 : Duration;
11691 l3 : Float;
11692 l4 : Boolean;
11693 l5 : Rb1;
11694 l6 : Rb2;
11695 end record;
11696 pragma Pack (x2);
11697 @end smallexample
11698
11699 @noindent
11700 The representation for the record x2 is as follows:
11701
11702 @smallexample @c ada
11703 for x2'Size use 224;
11704 for x2 use record
11705 l1 at 0 range 0 .. 0;
11706 l2 at 0 range 1 .. 64;
11707 l3 at 12 range 0 .. 31;
11708 l4 at 16 range 0 .. 0;
11709 l5 at 16 range 1 .. 13;
11710 l6 at 18 range 0 .. 71;
11711 end record;
11712 @end smallexample
11713
11714 @noindent
11715 Studying this example, we see that the packable fields @code{l1}
11716 and @code{l2} are
11717 of length equal to their sizes, and placed at specific bit boundaries (and
11718 not byte boundaries) to
11719 eliminate padding. But @code{l3} is of a non-packable float type, so
11720 it is on the next appropriate alignment boundary.
11721
11722 The next two fields are fully packable, so @code{l4} and @code{l5} are
11723 minimally packed with no gaps. However, type @code{Rb2} is a packed
11724 array that is longer than 64 bits, so it is itself non-packable. Thus
11725 the @code{l6} field is aligned to the next byte boundary, and takes an
11726 integral number of bytes, i.e.@: 72 bits.
11727
11728 @node Record Representation Clauses
11729 @section Record Representation Clauses
11730 @cindex Record Representation Clause
11731
11732 @noindent
11733 Record representation clauses may be given for all record types, including
11734 types obtained by record extension. Component clauses are allowed for any
11735 static component. The restrictions on component clauses depend on the type
11736 of the component.
11737
11738 @cindex Component Clause
11739 For all components of an elementary type, the only restriction on component
11740 clauses is that the size must be at least the 'Size value of the type
11741 (actually the Value_Size). There are no restrictions due to alignment,
11742 and such components may freely cross storage boundaries.
11743
11744 Packed arrays with a size up to and including 64 bits are represented
11745 internally using a modular type with the appropriate number of bits, and
11746 thus the same lack of restriction applies. For example, if you declare:
11747
11748 @smallexample @c ada
11749 type R is array (1 .. 49) of Boolean;
11750 pragma Pack (R);
11751 for R'Size use 49;
11752 @end smallexample
11753
11754 @noindent
11755 then a component clause for a component of type R may start on any
11756 specified bit boundary, and may specify a value of 49 bits or greater.
11757
11758 For packed bit arrays that are longer than 64 bits, there are two
11759 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11760 including the important case of single bits or boolean values, then
11761 there are no limitations on placement of such components, and they
11762 may start and end at arbitrary bit boundaries.
11763
11764 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11765 an array of this type longer than 64 bits must always be placed on
11766 on a storage unit (byte) boundary and occupy an integral number
11767 of storage units (bytes). Any component clause that does not
11768 meet this requirement will be rejected.
11769
11770 Any aliased component, or component of an aliased type, must
11771 have its normal alignment and size. A component clause that
11772 does not meet this requirement will be rejected.
11773
11774 The tag field of a tagged type always occupies an address sized field at
11775 the start of the record. No component clause may attempt to overlay this
11776 tag. When a tagged type appears as a component, the tag field must have
11777 proper alignment
11778
11779 In the case of a record extension T1, of a type T, no component clause applied
11780 to the type T1 can specify a storage location that would overlap the first
11781 T'Size bytes of the record.
11782
11783 For all other component types, including non-bit-packed arrays,
11784 the component can be placed at an arbitrary bit boundary,
11785 so for example, the following is permitted:
11786
11787 @smallexample @c ada
11788 type R is array (1 .. 10) of Boolean;
11789 for R'Size use 80;
11790
11791 type Q is record
11792 G, H : Boolean;
11793 L, M : R;
11794 end record;
11795
11796 for Q use record
11797 G at 0 range 0 .. 0;
11798 H at 0 range 1 .. 1;
11799 L at 0 range 2 .. 81;
11800 R at 0 range 82 .. 161;
11801 end record;
11802 @end smallexample
11803
11804 @noindent
11805 Note: the above rules apply to recent releases of GNAT 5.
11806 In GNAT 3, there are more severe restrictions on larger components.
11807 For non-primitive types, including packed arrays with a size greater than
11808 64 bits, component clauses must respect the alignment requirement of the
11809 type, in particular, always starting on a byte boundary, and the length
11810 must be a multiple of the storage unit.
11811
11812 @node Enumeration Clauses
11813 @section Enumeration Clauses
11814
11815 The only restriction on enumeration clauses is that the range of values
11816 must be representable. For the signed case, if one or more of the
11817 representation values are negative, all values must be in the range:
11818
11819 @smallexample @c ada
11820 System.Min_Int .. System.Max_Int
11821 @end smallexample
11822
11823 @noindent
11824 For the unsigned case, where all values are nonnegative, the values must
11825 be in the range:
11826
11827 @smallexample @c ada
11828 0 .. System.Max_Binary_Modulus;
11829 @end smallexample
11830
11831 @noindent
11832 A @emph{confirming} representation clause is one in which the values range
11833 from 0 in sequence, i.e.@: a clause that confirms the default representation
11834 for an enumeration type.
11835 Such a confirming representation
11836 is permitted by these rules, and is specially recognized by the compiler so
11837 that no extra overhead results from the use of such a clause.
11838
11839 If an array has an index type which is an enumeration type to which an
11840 enumeration clause has been applied, then the array is stored in a compact
11841 manner. Consider the declarations:
11842
11843 @smallexample @c ada
11844 type r is (A, B, C);
11845 for r use (A => 1, B => 5, C => 10);
11846 type t is array (r) of Character;
11847 @end smallexample
11848
11849 @noindent
11850 The array type t corresponds to a vector with exactly three elements and
11851 has a default size equal to @code{3*Character'Size}. This ensures efficient
11852 use of space, but means that accesses to elements of the array will incur
11853 the overhead of converting representation values to the corresponding
11854 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11855
11856 @node Address Clauses
11857 @section Address Clauses
11858 @cindex Address Clause
11859
11860 The reference manual allows a general restriction on representation clauses,
11861 as found in RM 13.1(22):
11862
11863 @quotation
11864 An implementation need not support representation
11865 items containing nonstatic expressions, except that
11866 an implementation should support a representation item
11867 for a given entity if each nonstatic expression in the
11868 representation item is a name that statically denotes
11869 a constant declared before the entity.
11870 @end quotation
11871
11872 @noindent
11873 In practice this is applicable only to address clauses, since this is the
11874 only case in which a non-static expression is permitted by the syntax. As
11875 the AARM notes in sections 13.1 (22.a-22.h):
11876
11877 @display
11878 22.a Reason: This is to avoid the following sort of thing:
11879
11880 22.b X : Integer := F(@dots{});
11881 Y : Address := G(@dots{});
11882 for X'Address use Y;
11883
11884 22.c In the above, we have to evaluate the
11885 initialization expression for X before we
11886 know where to put the result. This seems
11887 like an unreasonable implementation burden.
11888
11889 22.d The above code should instead be written
11890 like this:
11891
11892 22.e Y : constant Address := G(@dots{});
11893 X : Integer := F(@dots{});
11894 for X'Address use Y;
11895
11896 22.f This allows the expression ``Y'' to be safely
11897 evaluated before X is created.
11898
11899 22.g The constant could be a formal parameter of mode in.
11900
11901 22.h An implementation can support other nonstatic
11902 expressions if it wants to. Expressions of type
11903 Address are hardly ever static, but their value
11904 might be known at compile time anyway in many
11905 cases.
11906 @end display
11907
11908 @noindent
11909 GNAT does indeed permit many additional cases of non-static expressions. In
11910 particular, if the type involved is elementary there are no restrictions
11911 (since in this case, holding a temporary copy of the initialization value,
11912 if one is present, is inexpensive). In addition, if there is no implicit or
11913 explicit initialization, then there are no restrictions. GNAT will reject
11914 only the case where all three of these conditions hold:
11915
11916 @itemize @bullet
11917
11918 @item
11919 The type of the item is non-elementary (e.g.@: a record or array).
11920
11921 @item
11922 There is explicit or implicit initialization required for the object.
11923 Note that access values are always implicitly initialized, and also
11924 in GNAT, certain bit-packed arrays (those having a dynamic length or
11925 a length greater than 64) will also be implicitly initialized to zero.
11926
11927 @item
11928 The address value is non-static. Here GNAT is more permissive than the
11929 RM, and allows the address value to be the address of a previously declared
11930 stand-alone variable, as long as it does not itself have an address clause.
11931
11932 @smallexample @c ada
11933 Anchor : Some_Initialized_Type;
11934 Overlay : Some_Initialized_Type;
11935 for Overlay'Address use Anchor'Address;
11936 @end smallexample
11937
11938 @noindent
11939 However, the prefix of the address clause cannot be an array component, or
11940 a component of a discriminated record.
11941
11942 @end itemize
11943
11944 @noindent
11945 As noted above in section 22.h, address values are typically non-static. In
11946 particular the To_Address function, even if applied to a literal value, is
11947 a non-static function call. To avoid this minor annoyance, GNAT provides
11948 the implementation defined attribute 'To_Address. The following two
11949 expressions have identical values:
11950
11951 @findex Attribute
11952 @findex To_Address
11953 @smallexample @c ada
11954 To_Address (16#1234_0000#)
11955 System'To_Address (16#1234_0000#);
11956 @end smallexample
11957
11958 @noindent
11959 except that the second form is considered to be a static expression, and
11960 thus when used as an address clause value is always permitted.
11961
11962 @noindent
11963 Additionally, GNAT treats as static an address clause that is an
11964 unchecked_conversion of a static integer value. This simplifies the porting
11965 of legacy code, and provides a portable equivalent to the GNAT attribute
11966 @code{To_Address}.
11967
11968 Another issue with address clauses is the interaction with alignment
11969 requirements. When an address clause is given for an object, the address
11970 value must be consistent with the alignment of the object (which is usually
11971 the same as the alignment of the type of the object). If an address clause
11972 is given that specifies an inappropriately aligned address value, then the
11973 program execution is erroneous.
11974
11975 Since this source of erroneous behavior can have unfortunate effects, GNAT
11976 checks (at compile time if possible, generating a warning, or at execution
11977 time with a run-time check) that the alignment is appropriate. If the
11978 run-time check fails, then @code{Program_Error} is raised. This run-time
11979 check is suppressed if range checks are suppressed, or if the special GNAT
11980 check Alignment_Check is suppressed, or if
11981 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11982
11983 Finally, GNAT does not permit overlaying of objects of controlled types or
11984 composite types containing a controlled component. In most cases, the compiler
11985 can detect an attempt at such overlays and will generate a warning at compile
11986 time and a Program_Error exception at run time.
11987
11988 @findex Export
11989 An address clause cannot be given for an exported object. More
11990 understandably the real restriction is that objects with an address
11991 clause cannot be exported. This is because such variables are not
11992 defined by the Ada program, so there is no external object to export.
11993
11994 @findex Import
11995 It is permissible to give an address clause and a pragma Import for the
11996 same object. In this case, the variable is not really defined by the
11997 Ada program, so there is no external symbol to be linked. The link name
11998 and the external name are ignored in this case. The reason that we allow this
11999 combination is that it provides a useful idiom to avoid unwanted
12000 initializations on objects with address clauses.
12001
12002 When an address clause is given for an object that has implicit or
12003 explicit initialization, then by default initialization takes place. This
12004 means that the effect of the object declaration is to overwrite the
12005 memory at the specified address. This is almost always not what the
12006 programmer wants, so GNAT will output a warning:
12007
12008 @smallexample
12009 with System;
12010 package G is
12011 type R is record
12012 M : Integer := 0;
12013 end record;
12014
12015 Ext : R;
12016 for Ext'Address use System'To_Address (16#1234_1234#);
12017 |
12018 >>> warning: implicit initialization of "Ext" may
12019 modify overlaid storage
12020 >>> warning: use pragma Import for "Ext" to suppress
12021 initialization (RM B(24))
12022
12023 end G;
12024 @end smallexample
12025
12026 @noindent
12027 As indicated by the warning message, the solution is to use a (dummy) pragma
12028 Import to suppress this initialization. The pragma tell the compiler that the
12029 object is declared and initialized elsewhere. The following package compiles
12030 without warnings (and the initialization is suppressed):
12031
12032 @smallexample @c ada
12033 with System;
12034 package G is
12035 type R is record
12036 M : Integer := 0;
12037 end record;
12038
12039 Ext : R;
12040 for Ext'Address use System'To_Address (16#1234_1234#);
12041 pragma Import (Ada, Ext);
12042 end G;
12043 @end smallexample
12044
12045 @noindent
12046 A final issue with address clauses involves their use for overlaying
12047 variables, as in the following example:
12048 @cindex Overlaying of objects
12049
12050 @smallexample @c ada
12051 A : Integer;
12052 B : Integer;
12053 for B'Address use A'Address;
12054 @end smallexample
12055
12056 @noindent
12057 or alternatively, using the form recommended by the RM:
12058
12059 @smallexample @c ada
12060 A : Integer;
12061 Addr : constant Address := A'Address;
12062 B : Integer;
12063 for B'Address use Addr;
12064 @end smallexample
12065
12066 @noindent
12067 In both of these cases, @code{A}
12068 and @code{B} become aliased to one another via the
12069 address clause. This use of address clauses to overlay
12070 variables, achieving an effect similar to unchecked
12071 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12072 the effect is implementation defined. Furthermore, the
12073 Ada RM specifically recommends that in a situation
12074 like this, @code{B} should be subject to the following
12075 implementation advice (RM 13.3(19)):
12076
12077 @quotation
12078 19 If the Address of an object is specified, or it is imported
12079 or exported, then the implementation should not perform
12080 optimizations based on assumptions of no aliases.
12081 @end quotation
12082
12083 @noindent
12084 GNAT follows this recommendation, and goes further by also applying
12085 this recommendation to the overlaid variable (@code{A}
12086 in the above example) in this case. This means that the overlay
12087 works "as expected", in that a modification to one of the variables
12088 will affect the value of the other.
12089
12090 @node Effect of Convention on Representation
12091 @section Effect of Convention on Representation
12092 @cindex Convention, effect on representation
12093
12094 @noindent
12095 Normally the specification of a foreign language convention for a type or
12096 an object has no effect on the chosen representation. In particular, the
12097 representation chosen for data in GNAT generally meets the standard system
12098 conventions, and for example records are laid out in a manner that is
12099 consistent with C@. This means that specifying convention C (for example)
12100 has no effect.
12101
12102 There are four exceptions to this general rule:
12103
12104 @itemize @bullet
12105
12106 @item Convention Fortran and array subtypes
12107 If pragma Convention Fortran is specified for an array subtype, then in
12108 accordance with the implementation advice in section 3.6.2(11) of the
12109 Ada Reference Manual, the array will be stored in a Fortran-compatible
12110 column-major manner, instead of the normal default row-major order.
12111
12112 @item Convention C and enumeration types
12113 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12114 to accommodate all values of the type. For example, for the enumeration
12115 type declared by:
12116
12117 @smallexample @c ada
12118 type Color is (Red, Green, Blue);
12119 @end smallexample
12120
12121 @noindent
12122 8 bits is sufficient to store all values of the type, so by default, objects
12123 of type @code{Color} will be represented using 8 bits. However, normal C
12124 convention is to use 32 bits for all enum values in C, since enum values
12125 are essentially of type int. If pragma @code{Convention C} is specified for an
12126 Ada enumeration type, then the size is modified as necessary (usually to
12127 32 bits) to be consistent with the C convention for enum values.
12128
12129 Note that this treatment applies only to types. If Convention C is given for
12130 an enumeration object, where the enumeration type is not Convention C, then
12131 Object_Size bits are allocated. For example, for a normal enumeration type,
12132 with less than 256 elements, only 8 bits will be allocated for the object.
12133 Since this may be a surprise in terms of what C expects, GNAT will issue a
12134 warning in this situation. The warning can be suppressed by giving an explicit
12135 size clause specifying the desired size.
12136
12137 @item Convention C/Fortran and Boolean types
12138 In C, the usual convention for boolean values, that is values used for
12139 conditions, is that zero represents false, and nonzero values represent
12140 true. In Ada, the normal convention is that two specific values, typically
12141 0/1, are used to represent false/true respectively.
12142
12143 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12144 value represents true).
12145
12146 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12147 C or Fortran convention for a derived Boolean, as in the following example:
12148
12149 @smallexample @c ada
12150 type C_Switch is new Boolean;
12151 pragma Convention (C, C_Switch);
12152 @end smallexample
12153
12154 @noindent
12155 then the GNAT generated code will treat any nonzero value as true. For truth
12156 values generated by GNAT, the conventional value 1 will be used for True, but
12157 when one of these values is read, any nonzero value is treated as True.
12158
12159 @item Access types on OpenVMS
12160 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12161 arrays) are 64-bits long. An exception to this rule is for the case of
12162 C-convention access types where there is no explicit size clause present (or
12163 inherited for derived types). In this case, GNAT chooses to make these
12164 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12165 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12166
12167 @end itemize
12168
12169 @node Determining the Representations chosen by GNAT
12170 @section Determining the Representations chosen by GNAT
12171 @cindex Representation, determination of
12172 @cindex @option{-gnatR} switch
12173
12174 @noindent
12175 Although the descriptions in this section are intended to be complete, it is
12176 often easier to simply experiment to see what GNAT accepts and what the
12177 effect is on the layout of types and objects.
12178
12179 As required by the Ada RM, if a representation clause is not accepted, then
12180 it must be rejected as illegal by the compiler. However, when a
12181 representation clause or pragma is accepted, there can still be questions
12182 of what the compiler actually does. For example, if a partial record
12183 representation clause specifies the location of some components and not
12184 others, then where are the non-specified components placed? Or if pragma
12185 @code{Pack} is used on a record, then exactly where are the resulting
12186 fields placed? The section on pragma @code{Pack} in this chapter can be
12187 used to answer the second question, but it is often easier to just see
12188 what the compiler does.
12189
12190 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12191 with this option, then the compiler will output information on the actual
12192 representations chosen, in a format similar to source representation
12193 clauses. For example, if we compile the package:
12194
12195 @smallexample @c ada
12196 package q is
12197 type r (x : boolean) is tagged record
12198 case x is
12199 when True => S : String (1 .. 100);
12200 when False => null;
12201 end case;
12202 end record;
12203
12204 type r2 is new r (false) with record
12205 y2 : integer;
12206 end record;
12207
12208 for r2 use record
12209 y2 at 16 range 0 .. 31;
12210 end record;
12211
12212 type x is record
12213 y : character;
12214 end record;
12215
12216 type x1 is array (1 .. 10) of x;
12217 for x1'component_size use 11;
12218
12219 type ia is access integer;
12220
12221 type Rb1 is array (1 .. 13) of Boolean;
12222 pragma Pack (rb1);
12223
12224 type Rb2 is array (1 .. 65) of Boolean;
12225 pragma Pack (rb2);
12226
12227 type x2 is record
12228 l1 : Boolean;
12229 l2 : Duration;
12230 l3 : Float;
12231 l4 : Boolean;
12232 l5 : Rb1;
12233 l6 : Rb2;
12234 end record;
12235 pragma Pack (x2);
12236 end q;
12237 @end smallexample
12238
12239 @noindent
12240 using the switch @option{-gnatR} we obtain the following output:
12241
12242 @smallexample
12243 Representation information for unit q
12244 -------------------------------------
12245
12246 for r'Size use ??;
12247 for r'Alignment use 4;
12248 for r use record
12249 x at 4 range 0 .. 7;
12250 _tag at 0 range 0 .. 31;
12251 s at 5 range 0 .. 799;
12252 end record;
12253
12254 for r2'Size use 160;
12255 for r2'Alignment use 4;
12256 for r2 use record
12257 x at 4 range 0 .. 7;
12258 _tag at 0 range 0 .. 31;
12259 _parent at 0 range 0 .. 63;
12260 y2 at 16 range 0 .. 31;
12261 end record;
12262
12263 for x'Size use 8;
12264 for x'Alignment use 1;
12265 for x use record
12266 y at 0 range 0 .. 7;
12267 end record;
12268
12269 for x1'Size use 112;
12270 for x1'Alignment use 1;
12271 for x1'Component_Size use 11;
12272
12273 for rb1'Size use 13;
12274 for rb1'Alignment use 2;
12275 for rb1'Component_Size use 1;
12276
12277 for rb2'Size use 72;
12278 for rb2'Alignment use 1;
12279 for rb2'Component_Size use 1;
12280
12281 for x2'Size use 224;
12282 for x2'Alignment use 4;
12283 for x2 use record
12284 l1 at 0 range 0 .. 0;
12285 l2 at 0 range 1 .. 64;
12286 l3 at 12 range 0 .. 31;
12287 l4 at 16 range 0 .. 0;
12288 l5 at 16 range 1 .. 13;
12289 l6 at 18 range 0 .. 71;
12290 end record;
12291 @end smallexample
12292
12293 @noindent
12294 The Size values are actually the Object_Size, i.e.@: the default size that
12295 will be allocated for objects of the type.
12296 The ?? size for type r indicates that we have a variant record, and the
12297 actual size of objects will depend on the discriminant value.
12298
12299 The Alignment values show the actual alignment chosen by the compiler
12300 for each record or array type.
12301
12302 The record representation clause for type r shows where all fields
12303 are placed, including the compiler generated tag field (whose location
12304 cannot be controlled by the programmer).
12305
12306 The record representation clause for the type extension r2 shows all the
12307 fields present, including the parent field, which is a copy of the fields
12308 of the parent type of r2, i.e.@: r1.
12309
12310 The component size and size clauses for types rb1 and rb2 show
12311 the exact effect of pragma @code{Pack} on these arrays, and the record
12312 representation clause for type x2 shows how pragma @code{Pack} affects
12313 this record type.
12314
12315 In some cases, it may be useful to cut and paste the representation clauses
12316 generated by the compiler into the original source to fix and guarantee
12317 the actual representation to be used.
12318
12319 @node Standard Library Routines
12320 @chapter Standard Library Routines
12321
12322 @noindent
12323 The Ada Reference Manual contains in Annex A a full description of an
12324 extensive set of standard library routines that can be used in any Ada
12325 program, and which must be provided by all Ada compilers. They are
12326 analogous to the standard C library used by C programs.
12327
12328 GNAT implements all of the facilities described in annex A, and for most
12329 purposes the description in the Ada Reference Manual, or appropriate Ada
12330 text book, will be sufficient for making use of these facilities.
12331
12332 In the case of the input-output facilities,
12333 @xref{The Implementation of Standard I/O},
12334 gives details on exactly how GNAT interfaces to the
12335 file system. For the remaining packages, the Ada Reference Manual
12336 should be sufficient. The following is a list of the packages included,
12337 together with a brief description of the functionality that is provided.
12338
12339 For completeness, references are included to other predefined library
12340 routines defined in other sections of the Ada Reference Manual (these are
12341 cross-indexed from Annex A).
12342
12343 @table @code
12344 @item Ada (A.2)
12345 This is a parent package for all the standard library packages. It is
12346 usually included implicitly in your program, and itself contains no
12347 useful data or routines.
12348
12349 @item Ada.Calendar (9.6)
12350 @code{Calendar} provides time of day access, and routines for
12351 manipulating times and durations.
12352
12353 @item Ada.Characters (A.3.1)
12354 This is a dummy parent package that contains no useful entities
12355
12356 @item Ada.Characters.Handling (A.3.2)
12357 This package provides some basic character handling capabilities,
12358 including classification functions for classes of characters (e.g.@: test
12359 for letters, or digits).
12360
12361 @item Ada.Characters.Latin_1 (A.3.3)
12362 This package includes a complete set of definitions of the characters
12363 that appear in type CHARACTER@. It is useful for writing programs that
12364 will run in international environments. For example, if you want an
12365 upper case E with an acute accent in a string, it is often better to use
12366 the definition of @code{UC_E_Acute} in this package. Then your program
12367 will print in an understandable manner even if your environment does not
12368 support these extended characters.
12369
12370 @item Ada.Command_Line (A.15)
12371 This package provides access to the command line parameters and the name
12372 of the current program (analogous to the use of @code{argc} and @code{argv}
12373 in C), and also allows the exit status for the program to be set in a
12374 system-independent manner.
12375
12376 @item Ada.Decimal (F.2)
12377 This package provides constants describing the range of decimal numbers
12378 implemented, and also a decimal divide routine (analogous to the COBOL
12379 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12380
12381 @item Ada.Direct_IO (A.8.4)
12382 This package provides input-output using a model of a set of records of
12383 fixed-length, containing an arbitrary definite Ada type, indexed by an
12384 integer record number.
12385
12386 @item Ada.Dynamic_Priorities (D.5)
12387 This package allows the priorities of a task to be adjusted dynamically
12388 as the task is running.
12389
12390 @item Ada.Exceptions (11.4.1)
12391 This package provides additional information on exceptions, and also
12392 contains facilities for treating exceptions as data objects, and raising
12393 exceptions with associated messages.
12394
12395 @item Ada.Finalization (7.6)
12396 This package contains the declarations and subprograms to support the
12397 use of controlled types, providing for automatic initialization and
12398 finalization (analogous to the constructors and destructors of C++)
12399
12400 @item Ada.Interrupts (C.3.2)
12401 This package provides facilities for interfacing to interrupts, which
12402 includes the set of signals or conditions that can be raised and
12403 recognized as interrupts.
12404
12405 @item Ada.Interrupts.Names (C.3.2)
12406 This package provides the set of interrupt names (actually signal
12407 or condition names) that can be handled by GNAT@.
12408
12409 @item Ada.IO_Exceptions (A.13)
12410 This package defines the set of exceptions that can be raised by use of
12411 the standard IO packages.
12412
12413 @item Ada.Numerics
12414 This package contains some standard constants and exceptions used
12415 throughout the numerics packages. Note that the constants pi and e are
12416 defined here, and it is better to use these definitions than rolling
12417 your own.
12418
12419 @item Ada.Numerics.Complex_Elementary_Functions
12420 Provides the implementation of standard elementary functions (such as
12421 log and trigonometric functions) operating on complex numbers using the
12422 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12423 created by the package @code{Numerics.Complex_Types}.
12424
12425 @item Ada.Numerics.Complex_Types
12426 This is a predefined instantiation of
12427 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12428 build the type @code{Complex} and @code{Imaginary}.
12429
12430 @item Ada.Numerics.Discrete_Random
12431 This generic package provides a random number generator suitable for generating
12432 uniformly distributed values of a specified discrete subtype.
12433
12434 @item Ada.Numerics.Float_Random
12435 This package provides a random number generator suitable for generating
12436 uniformly distributed floating point values in the unit interval.
12437
12438 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12439 This is a generic version of the package that provides the
12440 implementation of standard elementary functions (such as log and
12441 trigonometric functions) for an arbitrary complex type.
12442
12443 The following predefined instantiations of this package are provided:
12444
12445 @table @code
12446 @item Short_Float
12447 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12448 @item Float
12449 @code{Ada.Numerics.Complex_Elementary_Functions}
12450 @item Long_Float
12451 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12452 @end table
12453
12454 @item Ada.Numerics.Generic_Complex_Types
12455 This is a generic package that allows the creation of complex types,
12456 with associated complex arithmetic operations.
12457
12458 The following predefined instantiations of this package exist
12459 @table @code
12460 @item Short_Float
12461 @code{Ada.Numerics.Short_Complex_Complex_Types}
12462 @item Float
12463 @code{Ada.Numerics.Complex_Complex_Types}
12464 @item Long_Float
12465 @code{Ada.Numerics.Long_Complex_Complex_Types}
12466 @end table
12467
12468 @item Ada.Numerics.Generic_Elementary_Functions
12469 This is a generic package that provides the implementation of standard
12470 elementary functions (such as log an trigonometric functions) for an
12471 arbitrary float type.
12472
12473 The following predefined instantiations of this package exist
12474
12475 @table @code
12476 @item Short_Float
12477 @code{Ada.Numerics.Short_Elementary_Functions}
12478 @item Float
12479 @code{Ada.Numerics.Elementary_Functions}
12480 @item Long_Float
12481 @code{Ada.Numerics.Long_Elementary_Functions}
12482 @end table
12483
12484 @item Ada.Real_Time (D.8)
12485 This package provides facilities similar to those of @code{Calendar}, but
12486 operating with a finer clock suitable for real time control. Note that
12487 annex D requires that there be no backward clock jumps, and GNAT generally
12488 guarantees this behavior, but of course if the external clock on which
12489 the GNAT runtime depends is deliberately reset by some external event,
12490 then such a backward jump may occur.
12491
12492 @item Ada.Sequential_IO (A.8.1)
12493 This package provides input-output facilities for sequential files,
12494 which can contain a sequence of values of a single type, which can be
12495 any Ada type, including indefinite (unconstrained) types.
12496
12497 @item Ada.Storage_IO (A.9)
12498 This package provides a facility for mapping arbitrary Ada types to and
12499 from a storage buffer. It is primarily intended for the creation of new
12500 IO packages.
12501
12502 @item Ada.Streams (13.13.1)
12503 This is a generic package that provides the basic support for the
12504 concept of streams as used by the stream attributes (@code{Input},
12505 @code{Output}, @code{Read} and @code{Write}).
12506
12507 @item Ada.Streams.Stream_IO (A.12.1)
12508 This package is a specialization of the type @code{Streams} defined in
12509 package @code{Streams} together with a set of operations providing
12510 Stream_IO capability. The Stream_IO model permits both random and
12511 sequential access to a file which can contain an arbitrary set of values
12512 of one or more Ada types.
12513
12514 @item Ada.Strings (A.4.1)
12515 This package provides some basic constants used by the string handling
12516 packages.
12517
12518 @item Ada.Strings.Bounded (A.4.4)
12519 This package provides facilities for handling variable length
12520 strings. The bounded model requires a maximum length. It is thus
12521 somewhat more limited than the unbounded model, but avoids the use of
12522 dynamic allocation or finalization.
12523
12524 @item Ada.Strings.Fixed (A.4.3)
12525 This package provides facilities for handling fixed length strings.
12526
12527 @item Ada.Strings.Maps (A.4.2)
12528 This package provides facilities for handling character mappings and
12529 arbitrarily defined subsets of characters. For instance it is useful in
12530 defining specialized translation tables.
12531
12532 @item Ada.Strings.Maps.Constants (A.4.6)
12533 This package provides a standard set of predefined mappings and
12534 predefined character sets. For example, the standard upper to lower case
12535 conversion table is found in this package. Note that upper to lower case
12536 conversion is non-trivial if you want to take the entire set of
12537 characters, including extended characters like E with an acute accent,
12538 into account. You should use the mappings in this package (rather than
12539 adding 32 yourself) to do case mappings.
12540
12541 @item Ada.Strings.Unbounded (A.4.5)
12542 This package provides facilities for handling variable length
12543 strings. The unbounded model allows arbitrary length strings, but
12544 requires the use of dynamic allocation and finalization.
12545
12546 @item Ada.Strings.Wide_Bounded (A.4.7)
12547 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12548 @itemx Ada.Strings.Wide_Maps (A.4.7)
12549 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12550 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12551 These packages provide analogous capabilities to the corresponding
12552 packages without @samp{Wide_} in the name, but operate with the types
12553 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12554 and @code{Character}.
12555
12556 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12557 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12558 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12559 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12560 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12561 These packages provide analogous capabilities to the corresponding
12562 packages without @samp{Wide_} in the name, but operate with the types
12563 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12564 of @code{String} and @code{Character}.
12565
12566 @item Ada.Synchronous_Task_Control (D.10)
12567 This package provides some standard facilities for controlling task
12568 communication in a synchronous manner.
12569
12570 @item Ada.Tags
12571 This package contains definitions for manipulation of the tags of tagged
12572 values.
12573
12574 @item Ada.Task_Attributes
12575 This package provides the capability of associating arbitrary
12576 task-specific data with separate tasks.
12577
12578 @item Ada.Text_IO
12579 This package provides basic text input-output capabilities for
12580 character, string and numeric data. The subpackages of this
12581 package are listed next.
12582
12583 @item Ada.Text_IO.Decimal_IO
12584 Provides input-output facilities for decimal fixed-point types
12585
12586 @item Ada.Text_IO.Enumeration_IO
12587 Provides input-output facilities for enumeration types.
12588
12589 @item Ada.Text_IO.Fixed_IO
12590 Provides input-output facilities for ordinary fixed-point types.
12591
12592 @item Ada.Text_IO.Float_IO
12593 Provides input-output facilities for float types. The following
12594 predefined instantiations of this generic package are available:
12595
12596 @table @code
12597 @item Short_Float
12598 @code{Short_Float_Text_IO}
12599 @item Float
12600 @code{Float_Text_IO}
12601 @item Long_Float
12602 @code{Long_Float_Text_IO}
12603 @end table
12604
12605 @item Ada.Text_IO.Integer_IO
12606 Provides input-output facilities for integer types. The following
12607 predefined instantiations of this generic package are available:
12608
12609 @table @code
12610 @item Short_Short_Integer
12611 @code{Ada.Short_Short_Integer_Text_IO}
12612 @item Short_Integer
12613 @code{Ada.Short_Integer_Text_IO}
12614 @item Integer
12615 @code{Ada.Integer_Text_IO}
12616 @item Long_Integer
12617 @code{Ada.Long_Integer_Text_IO}
12618 @item Long_Long_Integer
12619 @code{Ada.Long_Long_Integer_Text_IO}
12620 @end table
12621
12622 @item Ada.Text_IO.Modular_IO
12623 Provides input-output facilities for modular (unsigned) types
12624
12625 @item Ada.Text_IO.Complex_IO (G.1.3)
12626 This package provides basic text input-output capabilities for complex
12627 data.
12628
12629 @item Ada.Text_IO.Editing (F.3.3)
12630 This package contains routines for edited output, analogous to the use
12631 of pictures in COBOL@. The picture formats used by this package are a
12632 close copy of the facility in COBOL@.
12633
12634 @item Ada.Text_IO.Text_Streams (A.12.2)
12635 This package provides a facility that allows Text_IO files to be treated
12636 as streams, so that the stream attributes can be used for writing
12637 arbitrary data, including binary data, to Text_IO files.
12638
12639 @item Ada.Unchecked_Conversion (13.9)
12640 This generic package allows arbitrary conversion from one type to
12641 another of the same size, providing for breaking the type safety in
12642 special circumstances.
12643
12644 If the types have the same Size (more accurately the same Value_Size),
12645 then the effect is simply to transfer the bits from the source to the
12646 target type without any modification. This usage is well defined, and
12647 for simple types whose representation is typically the same across
12648 all implementations, gives a portable method of performing such
12649 conversions.
12650
12651 If the types do not have the same size, then the result is implementation
12652 defined, and thus may be non-portable. The following describes how GNAT
12653 handles such unchecked conversion cases.
12654
12655 If the types are of different sizes, and are both discrete types, then
12656 the effect is of a normal type conversion without any constraint checking.
12657 In particular if the result type has a larger size, the result will be
12658 zero or sign extended. If the result type has a smaller size, the result
12659 will be truncated by ignoring high order bits.
12660
12661 If the types are of different sizes, and are not both discrete types,
12662 then the conversion works as though pointers were created to the source
12663 and target, and the pointer value is converted. The effect is that bits
12664 are copied from successive low order storage units and bits of the source
12665 up to the length of the target type.
12666
12667 A warning is issued if the lengths differ, since the effect in this
12668 case is implementation dependent, and the above behavior may not match
12669 that of some other compiler.
12670
12671 A pointer to one type may be converted to a pointer to another type using
12672 unchecked conversion. The only case in which the effect is undefined is
12673 when one or both pointers are pointers to unconstrained array types. In
12674 this case, the bounds information may get incorrectly transferred, and in
12675 particular, GNAT uses double size pointers for such types, and it is
12676 meaningless to convert between such pointer types. GNAT will issue a
12677 warning if the alignment of the target designated type is more strict
12678 than the alignment of the source designated type (since the result may
12679 be unaligned in this case).
12680
12681 A pointer other than a pointer to an unconstrained array type may be
12682 converted to and from System.Address. Such usage is common in Ada 83
12683 programs, but note that Ada.Address_To_Access_Conversions is the
12684 preferred method of performing such conversions in Ada 95 and Ada 2005.
12685 Neither
12686 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12687 used in conjunction with pointers to unconstrained objects, since
12688 the bounds information cannot be handled correctly in this case.
12689
12690 @item Ada.Unchecked_Deallocation (13.11.2)
12691 This generic package allows explicit freeing of storage previously
12692 allocated by use of an allocator.
12693
12694 @item Ada.Wide_Text_IO (A.11)
12695 This package is similar to @code{Ada.Text_IO}, except that the external
12696 file supports wide character representations, and the internal types are
12697 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12698 and @code{String}. It contains generic subpackages listed next.
12699
12700 @item Ada.Wide_Text_IO.Decimal_IO
12701 Provides input-output facilities for decimal fixed-point types
12702
12703 @item Ada.Wide_Text_IO.Enumeration_IO
12704 Provides input-output facilities for enumeration types.
12705
12706 @item Ada.Wide_Text_IO.Fixed_IO
12707 Provides input-output facilities for ordinary fixed-point types.
12708
12709 @item Ada.Wide_Text_IO.Float_IO
12710 Provides input-output facilities for float types. The following
12711 predefined instantiations of this generic package are available:
12712
12713 @table @code
12714 @item Short_Float
12715 @code{Short_Float_Wide_Text_IO}
12716 @item Float
12717 @code{Float_Wide_Text_IO}
12718 @item Long_Float
12719 @code{Long_Float_Wide_Text_IO}
12720 @end table
12721
12722 @item Ada.Wide_Text_IO.Integer_IO
12723 Provides input-output facilities for integer types. The following
12724 predefined instantiations of this generic package are available:
12725
12726 @table @code
12727 @item Short_Short_Integer
12728 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12729 @item Short_Integer
12730 @code{Ada.Short_Integer_Wide_Text_IO}
12731 @item Integer
12732 @code{Ada.Integer_Wide_Text_IO}
12733 @item Long_Integer
12734 @code{Ada.Long_Integer_Wide_Text_IO}
12735 @item Long_Long_Integer
12736 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12737 @end table
12738
12739 @item Ada.Wide_Text_IO.Modular_IO
12740 Provides input-output facilities for modular (unsigned) types
12741
12742 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12743 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12744 external file supports wide character representations.
12745
12746 @item Ada.Wide_Text_IO.Editing (F.3.4)
12747 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12748 types are @code{Wide_Character} and @code{Wide_String} instead of
12749 @code{Character} and @code{String}.
12750
12751 @item Ada.Wide_Text_IO.Streams (A.12.3)
12752 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12753 types are @code{Wide_Character} and @code{Wide_String} instead of
12754 @code{Character} and @code{String}.
12755
12756 @item Ada.Wide_Wide_Text_IO (A.11)
12757 This package is similar to @code{Ada.Text_IO}, except that the external
12758 file supports wide character representations, and the internal types are
12759 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12760 and @code{String}. It contains generic subpackages listed next.
12761
12762 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12763 Provides input-output facilities for decimal fixed-point types
12764
12765 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12766 Provides input-output facilities for enumeration types.
12767
12768 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12769 Provides input-output facilities for ordinary fixed-point types.
12770
12771 @item Ada.Wide_Wide_Text_IO.Float_IO
12772 Provides input-output facilities for float types. The following
12773 predefined instantiations of this generic package are available:
12774
12775 @table @code
12776 @item Short_Float
12777 @code{Short_Float_Wide_Wide_Text_IO}
12778 @item Float
12779 @code{Float_Wide_Wide_Text_IO}
12780 @item Long_Float
12781 @code{Long_Float_Wide_Wide_Text_IO}
12782 @end table
12783
12784 @item Ada.Wide_Wide_Text_IO.Integer_IO
12785 Provides input-output facilities for integer types. The following
12786 predefined instantiations of this generic package are available:
12787
12788 @table @code
12789 @item Short_Short_Integer
12790 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12791 @item Short_Integer
12792 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12793 @item Integer
12794 @code{Ada.Integer_Wide_Wide_Text_IO}
12795 @item Long_Integer
12796 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12797 @item Long_Long_Integer
12798 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12799 @end table
12800
12801 @item Ada.Wide_Wide_Text_IO.Modular_IO
12802 Provides input-output facilities for modular (unsigned) types
12803
12804 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12805 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12806 external file supports wide character representations.
12807
12808 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12809 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12810 types are @code{Wide_Character} and @code{Wide_String} instead of
12811 @code{Character} and @code{String}.
12812
12813 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12814 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12815 types are @code{Wide_Character} and @code{Wide_String} instead of
12816 @code{Character} and @code{String}.
12817 @end table
12818
12819 @node The Implementation of Standard I/O
12820 @chapter The Implementation of Standard I/O
12821
12822 @noindent
12823 GNAT implements all the required input-output facilities described in
12824 A.6 through A.14. These sections of the Ada Reference Manual describe the
12825 required behavior of these packages from the Ada point of view, and if
12826 you are writing a portable Ada program that does not need to know the
12827 exact manner in which Ada maps to the outside world when it comes to
12828 reading or writing external files, then you do not need to read this
12829 chapter. As long as your files are all regular files (not pipes or
12830 devices), and as long as you write and read the files only from Ada, the
12831 description in the Ada Reference Manual is sufficient.
12832
12833 However, if you want to do input-output to pipes or other devices, such
12834 as the keyboard or screen, or if the files you are dealing with are
12835 either generated by some other language, or to be read by some other
12836 language, then you need to know more about the details of how the GNAT
12837 implementation of these input-output facilities behaves.
12838
12839 In this chapter we give a detailed description of exactly how GNAT
12840 interfaces to the file system. As always, the sources of the system are
12841 available to you for answering questions at an even more detailed level,
12842 but for most purposes the information in this chapter will suffice.
12843
12844 Another reason that you may need to know more about how input-output is
12845 implemented arises when you have a program written in mixed languages
12846 where, for example, files are shared between the C and Ada sections of
12847 the same program. GNAT provides some additional facilities, in the form
12848 of additional child library packages, that facilitate this sharing, and
12849 these additional facilities are also described in this chapter.
12850
12851 @menu
12852 * Standard I/O Packages::
12853 * FORM Strings::
12854 * Direct_IO::
12855 * Sequential_IO::
12856 * Text_IO::
12857 * Wide_Text_IO::
12858 * Wide_Wide_Text_IO::
12859 * Stream_IO::
12860 * Text Translation::
12861 * Shared Files::
12862 * Filenames encoding::
12863 * Open Modes::
12864 * Operations on C Streams::
12865 * Interfacing to C Streams::
12866 @end menu
12867
12868 @node Standard I/O Packages
12869 @section Standard I/O Packages
12870
12871 @noindent
12872 The Standard I/O packages described in Annex A for
12873
12874 @itemize @bullet
12875 @item
12876 Ada.Text_IO
12877 @item
12878 Ada.Text_IO.Complex_IO
12879 @item
12880 Ada.Text_IO.Text_Streams
12881 @item
12882 Ada.Wide_Text_IO
12883 @item
12884 Ada.Wide_Text_IO.Complex_IO
12885 @item
12886 Ada.Wide_Text_IO.Text_Streams
12887 @item
12888 Ada.Wide_Wide_Text_IO
12889 @item
12890 Ada.Wide_Wide_Text_IO.Complex_IO
12891 @item
12892 Ada.Wide_Wide_Text_IO.Text_Streams
12893 @item
12894 Ada.Stream_IO
12895 @item
12896 Ada.Sequential_IO
12897 @item
12898 Ada.Direct_IO
12899 @end itemize
12900
12901 @noindent
12902 are implemented using the C
12903 library streams facility; where
12904
12905 @itemize @bullet
12906 @item
12907 All files are opened using @code{fopen}.
12908 @item
12909 All input/output operations use @code{fread}/@code{fwrite}.
12910 @end itemize
12911
12912 @noindent
12913 There is no internal buffering of any kind at the Ada library level. The only
12914 buffering is that provided at the system level in the implementation of the
12915 library routines that support streams. This facilitates shared use of these
12916 streams by mixed language programs. Note though that system level buffering is
12917 explicitly enabled at elaboration of the standard I/O packages and that can
12918 have an impact on mixed language programs, in particular those using I/O before
12919 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12920 the Ada elaboration routine before performing any I/O or when impractical,
12921 flush the common I/O streams and in particular Standard_Output before
12922 elaborating the Ada code.
12923
12924 @node FORM Strings
12925 @section FORM Strings
12926
12927 @noindent
12928 The format of a FORM string in GNAT is:
12929
12930 @smallexample
12931 "keyword=value,keyword=value,@dots{},keyword=value"
12932 @end smallexample
12933
12934 @noindent
12935 where letters may be in upper or lower case, and there are no spaces
12936 between values. The order of the entries is not important. Currently
12937 the following keywords defined.
12938
12939 @smallexample
12940 TEXT_TRANSLATION=[YES|NO]
12941 SHARED=[YES|NO]
12942 WCEM=[n|h|u|s|e|8|b]
12943 ENCODING=[UTF8|8BITS]
12944 @end smallexample
12945
12946 @noindent
12947 The use of these parameters is described later in this section.
12948
12949 @node Direct_IO
12950 @section Direct_IO
12951
12952 @noindent
12953 Direct_IO can only be instantiated for definite types. This is a
12954 restriction of the Ada language, which means that the records are fixed
12955 length (the length being determined by @code{@var{type}'Size}, rounded
12956 up to the next storage unit boundary if necessary).
12957
12958 The records of a Direct_IO file are simply written to the file in index
12959 sequence, with the first record starting at offset zero, and subsequent
12960 records following. There is no control information of any kind. For
12961 example, if 32-bit integers are being written, each record takes
12962 4-bytes, so the record at index @var{K} starts at offset
12963 (@var{K}@minus{}1)*4.
12964
12965 There is no limit on the size of Direct_IO files, they are expanded as
12966 necessary to accommodate whatever records are written to the file.
12967
12968 @node Sequential_IO
12969 @section Sequential_IO
12970
12971 @noindent
12972 Sequential_IO may be instantiated with either a definite (constrained)
12973 or indefinite (unconstrained) type.
12974
12975 For the definite type case, the elements written to the file are simply
12976 the memory images of the data values with no control information of any
12977 kind. The resulting file should be read using the same type, no validity
12978 checking is performed on input.
12979
12980 For the indefinite type case, the elements written consist of two
12981 parts. First is the size of the data item, written as the memory image
12982 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12983 the data value. The resulting file can only be read using the same
12984 (unconstrained) type. Normal assignment checks are performed on these
12985 read operations, and if these checks fail, @code{Data_Error} is
12986 raised. In particular, in the array case, the lengths must match, and in
12987 the variant record case, if the variable for a particular read operation
12988 is constrained, the discriminants must match.
12989
12990 Note that it is not possible to use Sequential_IO to write variable
12991 length array items, and then read the data back into different length
12992 arrays. For example, the following will raise @code{Data_Error}:
12993
12994 @smallexample @c ada
12995 package IO is new Sequential_IO (String);
12996 F : IO.File_Type;
12997 S : String (1..4);
12998 @dots{}
12999 IO.Create (F)
13000 IO.Write (F, "hello!")
13001 IO.Reset (F, Mode=>In_File);
13002 IO.Read (F, S);
13003 Put_Line (S);
13004
13005 @end smallexample
13006
13007 @noindent
13008 On some Ada implementations, this will print @code{hell}, but the program is
13009 clearly incorrect, since there is only one element in the file, and that
13010 element is the string @code{hello!}.
13011
13012 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13013 using Stream_IO, and this is the preferred mechanism. In particular, the
13014 above program fragment rewritten to use Stream_IO will work correctly.
13015
13016 @node Text_IO
13017 @section Text_IO
13018
13019 @noindent
13020 Text_IO files consist of a stream of characters containing the following
13021 special control characters:
13022
13023 @smallexample
13024 LF (line feed, 16#0A#) Line Mark
13025 FF (form feed, 16#0C#) Page Mark
13026 @end smallexample
13027
13028 @noindent
13029 A canonical Text_IO file is defined as one in which the following
13030 conditions are met:
13031
13032 @itemize @bullet
13033 @item
13034 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13035 of the line.
13036
13037 @item
13038 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13039 end of a page and consequently can appear only immediately following a
13040 @code{LF} (line mark) character.
13041
13042 @item
13043 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13044 (line mark, page mark). In the former case, the page mark is implicitly
13045 assumed to be present.
13046 @end itemize
13047
13048 @noindent
13049 A file written using Text_IO will be in canonical form provided that no
13050 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13051 or @code{Put_Line}. There will be no @code{FF} character at the end of
13052 the file unless an explicit @code{New_Page} operation was performed
13053 before closing the file.
13054
13055 A canonical Text_IO file that is a regular file (i.e., not a device or a
13056 pipe) can be read using any of the routines in Text_IO@. The
13057 semantics in this case will be exactly as defined in the Ada Reference
13058 Manual, and all the routines in Text_IO are fully implemented.
13059
13060 A text file that does not meet the requirements for a canonical Text_IO
13061 file has one of the following:
13062
13063 @itemize @bullet
13064 @item
13065 The file contains @code{FF} characters not immediately following a
13066 @code{LF} character.
13067
13068 @item
13069 The file contains @code{LF} or @code{FF} characters written by
13070 @code{Put} or @code{Put_Line}, which are not logically considered to be
13071 line marks or page marks.
13072
13073 @item
13074 The file ends in a character other than @code{LF} or @code{FF},
13075 i.e.@: there is no explicit line mark or page mark at the end of the file.
13076 @end itemize
13077
13078 @noindent
13079 Text_IO can be used to read such non-standard text files but subprograms
13080 to do with line or page numbers do not have defined meanings. In
13081 particular, a @code{FF} character that does not follow a @code{LF}
13082 character may or may not be treated as a page mark from the point of
13083 view of page and line numbering. Every @code{LF} character is considered
13084 to end a line, and there is an implied @code{LF} character at the end of
13085 the file.
13086
13087 @menu
13088 * Text_IO Stream Pointer Positioning::
13089 * Text_IO Reading and Writing Non-Regular Files::
13090 * Get_Immediate::
13091 * Treating Text_IO Files as Streams::
13092 * Text_IO Extensions::
13093 * Text_IO Facilities for Unbounded Strings::
13094 @end menu
13095
13096 @node Text_IO Stream Pointer Positioning
13097 @subsection Stream Pointer Positioning
13098
13099 @noindent
13100 @code{Ada.Text_IO} has a definition of current position for a file that
13101 is being read. No internal buffering occurs in Text_IO, and usually the
13102 physical position in the stream used to implement the file corresponds
13103 to this logical position defined by Text_IO@. There are two exceptions:
13104
13105 @itemize @bullet
13106 @item
13107 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13108 is positioned past the @code{LF} (line mark) that precedes the page
13109 mark. Text_IO maintains an internal flag so that subsequent read
13110 operations properly handle the logical position which is unchanged by
13111 the @code{End_Of_Page} call.
13112
13113 @item
13114 After a call to @code{End_Of_File} that returns @code{True}, if the
13115 Text_IO file was positioned before the line mark at the end of file
13116 before the call, then the logical position is unchanged, but the stream
13117 is physically positioned right at the end of file (past the line mark,
13118 and past a possible page mark following the line mark. Again Text_IO
13119 maintains internal flags so that subsequent read operations properly
13120 handle the logical position.
13121 @end itemize
13122
13123 @noindent
13124 These discrepancies have no effect on the observable behavior of
13125 Text_IO, but if a single Ada stream is shared between a C program and
13126 Ada program, or shared (using @samp{shared=yes} in the form string)
13127 between two Ada files, then the difference may be observable in some
13128 situations.
13129
13130 @node Text_IO Reading and Writing Non-Regular Files
13131 @subsection Reading and Writing Non-Regular Files
13132
13133 @noindent
13134 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13135 can be used for reading and writing. Writing is not affected and the
13136 sequence of characters output is identical to the normal file case, but
13137 for reading, the behavior of Text_IO is modified to avoid undesirable
13138 look-ahead as follows:
13139
13140 An input file that is not a regular file is considered to have no page
13141 marks. Any @code{Ascii.FF} characters (the character normally used for a
13142 page mark) appearing in the file are considered to be data
13143 characters. In particular:
13144
13145 @itemize @bullet
13146 @item
13147 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13148 following a line mark. If a page mark appears, it will be treated as a
13149 data character.
13150
13151 @item
13152 This avoids the need to wait for an extra character to be typed or
13153 entered from the pipe to complete one of these operations.
13154
13155 @item
13156 @code{End_Of_Page} always returns @code{False}
13157
13158 @item
13159 @code{End_Of_File} will return @code{False} if there is a page mark at
13160 the end of the file.
13161 @end itemize
13162
13163 @noindent
13164 Output to non-regular files is the same as for regular files. Page marks
13165 may be written to non-regular files using @code{New_Page}, but as noted
13166 above they will not be treated as page marks on input if the output is
13167 piped to another Ada program.
13168
13169 Another important discrepancy when reading non-regular files is that the end
13170 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13171 pressing the @key{EOT} key,
13172 then end of file
13173 is signaled once (i.e.@: the test @code{End_Of_File}
13174 will yield @code{True}, or a read will
13175 raise @code{End_Error}), but then reading can resume
13176 to read data past that end of
13177 file indication, until another end of file indication is entered.
13178
13179 @node Get_Immediate
13180 @subsection Get_Immediate
13181 @cindex Get_Immediate
13182
13183 @noindent
13184 Get_Immediate returns the next character (including control characters)
13185 from the input file. In particular, Get_Immediate will return LF or FF
13186 characters used as line marks or page marks. Such operations leave the
13187 file positioned past the control character, and it is thus not treated
13188 as having its normal function. This means that page, line and column
13189 counts after this kind of Get_Immediate call are set as though the mark
13190 did not occur. In the case where a Get_Immediate leaves the file
13191 positioned between the line mark and page mark (which is not normally
13192 possible), it is undefined whether the FF character will be treated as a
13193 page mark.
13194
13195 @node Treating Text_IO Files as Streams
13196 @subsection Treating Text_IO Files as Streams
13197 @cindex Stream files
13198
13199 @noindent
13200 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13201 as a stream. Data written to a Text_IO file in this stream mode is
13202 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13203 16#0C# (@code{FF}), the resulting file may have non-standard
13204 format. Similarly if read operations are used to read from a Text_IO
13205 file treated as a stream, then @code{LF} and @code{FF} characters may be
13206 skipped and the effect is similar to that described above for
13207 @code{Get_Immediate}.
13208
13209 @node Text_IO Extensions
13210 @subsection Text_IO Extensions
13211 @cindex Text_IO extensions
13212
13213 @noindent
13214 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13215 to the standard @code{Text_IO} package:
13216
13217 @itemize @bullet
13218 @item function File_Exists (Name : String) return Boolean;
13219 Determines if a file of the given name exists.
13220
13221 @item function Get_Line return String;
13222 Reads a string from the standard input file. The value returned is exactly
13223 the length of the line that was read.
13224
13225 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13226 Similar, except that the parameter File specifies the file from which
13227 the string is to be read.
13228
13229 @end itemize
13230
13231 @node Text_IO Facilities for Unbounded Strings
13232 @subsection Text_IO Facilities for Unbounded Strings
13233 @cindex Text_IO for unbounded strings
13234 @cindex Unbounded_String, Text_IO operations
13235
13236 @noindent
13237 The package @code{Ada.Strings.Unbounded.Text_IO}
13238 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13239 subprograms useful for Text_IO operations on unbounded strings:
13240
13241 @itemize @bullet
13242
13243 @item function Get_Line (File : File_Type) return Unbounded_String;
13244 Reads a line from the specified file
13245 and returns the result as an unbounded string.
13246
13247 @item procedure Put (File : File_Type; U : Unbounded_String);
13248 Writes the value of the given unbounded string to the specified file
13249 Similar to the effect of
13250 @code{Put (To_String (U))} except that an extra copy is avoided.
13251
13252 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13253 Writes the value of the given unbounded string to the specified file,
13254 followed by a @code{New_Line}.
13255 Similar to the effect of @code{Put_Line (To_String (U))} except
13256 that an extra copy is avoided.
13257 @end itemize
13258
13259 @noindent
13260 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13261 and is optional. If the parameter is omitted, then the standard input or
13262 output file is referenced as appropriate.
13263
13264 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13265 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13266 @code{Wide_Text_IO} functionality for unbounded wide strings.
13267
13268 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13269 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13270 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13271
13272 @node Wide_Text_IO
13273 @section Wide_Text_IO
13274
13275 @noindent
13276 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13277 both input and output files may contain special sequences that represent
13278 wide character values. The encoding scheme for a given file may be
13279 specified using a FORM parameter:
13280
13281 @smallexample
13282 WCEM=@var{x}
13283 @end smallexample
13284
13285 @noindent
13286 as part of the FORM string (WCEM = wide character encoding method),
13287 where @var{x} is one of the following characters
13288
13289 @table @samp
13290 @item h
13291 Hex ESC encoding
13292 @item u
13293 Upper half encoding
13294 @item s
13295 Shift-JIS encoding
13296 @item e
13297 EUC Encoding
13298 @item 8
13299 UTF-8 encoding
13300 @item b
13301 Brackets encoding
13302 @end table
13303
13304 @noindent
13305 The encoding methods match those that
13306 can be used in a source
13307 program, but there is no requirement that the encoding method used for
13308 the source program be the same as the encoding method used for files,
13309 and different files may use different encoding methods.
13310
13311 The default encoding method for the standard files, and for opened files
13312 for which no WCEM parameter is given in the FORM string matches the
13313 wide character encoding specified for the main program (the default
13314 being brackets encoding if no coding method was specified with -gnatW).
13315
13316 @table @asis
13317 @item Hex Coding
13318 In this encoding, a wide character is represented by a five character
13319 sequence:
13320
13321 @smallexample
13322 ESC a b c d
13323 @end smallexample
13324
13325 @noindent
13326 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13327 characters (using upper case letters) of the wide character code. For
13328 example, ESC A345 is used to represent the wide character with code
13329 16#A345#. This scheme is compatible with use of the full
13330 @code{Wide_Character} set.
13331
13332 @item Upper Half Coding
13333 The wide character with encoding 16#abcd#, where the upper bit is on
13334 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13335 16#cd#. The second byte may never be a format control character, but is
13336 not required to be in the upper half. This method can be also used for
13337 shift-JIS or EUC where the internal coding matches the external coding.
13338
13339 @item Shift JIS Coding
13340 A wide character is represented by a two character sequence 16#ab# and
13341 16#cd#, with the restrictions described for upper half encoding as
13342 described above. The internal character code is the corresponding JIS
13343 character according to the standard algorithm for Shift-JIS
13344 conversion. Only characters defined in the JIS code set table can be
13345 used with this encoding method.
13346
13347 @item EUC Coding
13348 A wide character is represented by a two character sequence 16#ab# and
13349 16#cd#, with both characters being in the upper half. The internal
13350 character code is the corresponding JIS character according to the EUC
13351 encoding algorithm. Only characters defined in the JIS code set table
13352 can be used with this encoding method.
13353
13354 @item UTF-8 Coding
13355 A wide character is represented using
13356 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13357 10646-1/Am.2. Depending on the character value, the representation
13358 is a one, two, or three byte sequence:
13359
13360 @smallexample
13361 16#0000#-16#007f#: 2#0xxxxxxx#
13362 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13363 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13364 @end smallexample
13365
13366 @noindent
13367 where the @var{xxx} bits correspond to the left-padded bits of the
13368 16-bit character value. Note that all lower half ASCII characters
13369 are represented as ASCII bytes and all upper half characters and
13370 other wide characters are represented as sequences of upper-half
13371 (The full UTF-8 scheme allows for encoding 31-bit characters as
13372 6-byte sequences, but in this implementation, all UTF-8 sequences
13373 of four or more bytes length will raise a Constraint_Error, as
13374 will all invalid UTF-8 sequences.)
13375
13376 @item Brackets Coding
13377 In this encoding, a wide character is represented by the following eight
13378 character sequence:
13379
13380 @smallexample
13381 [ " a b c d " ]
13382 @end smallexample
13383
13384 @noindent
13385 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13386 characters (using uppercase letters) of the wide character code. For
13387 example, @code{["A345"]} is used to represent the wide character with code
13388 @code{16#A345#}.
13389 This scheme is compatible with use of the full Wide_Character set.
13390 On input, brackets coding can also be used for upper half characters,
13391 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13392 is only used for wide characters with a code greater than @code{16#FF#}.
13393
13394 Note that brackets coding is not normally used in the context of
13395 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13396 a portable way of encoding source files. In the context of Wide_Text_IO
13397 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13398 any instance of the left bracket character other than to encode wide
13399 character values using the brackets encoding method. In practice it is
13400 expected that some standard wide character encoding method such
13401 as UTF-8 will be used for text input output.
13402
13403 If brackets notation is used, then any occurrence of a left bracket
13404 in the input file which is not the start of a valid wide character
13405 sequence will cause Constraint_Error to be raised. It is possible to
13406 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13407 input will interpret this as a left bracket.
13408
13409 However, when a left bracket is output, it will be output as a left bracket
13410 and not as ["5B"]. We make this decision because for normal use of
13411 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13412 brackets. For example, if we write:
13413
13414 @smallexample
13415 Put_Line ("Start of output [first run]");
13416 @end smallexample
13417
13418 @noindent
13419 we really do not want to have the left bracket in this message clobbered so
13420 that the output reads:
13421
13422 @smallexample
13423 Start of output ["5B"]first run]
13424 @end smallexample
13425
13426 @noindent
13427 In practice brackets encoding is reasonably useful for normal Put_Line use
13428 since we won't get confused between left brackets and wide character
13429 sequences in the output. But for input, or when files are written out
13430 and read back in, it really makes better sense to use one of the standard
13431 encoding methods such as UTF-8.
13432
13433 @end table
13434
13435 @noindent
13436 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13437 not all wide character
13438 values can be represented. An attempt to output a character that cannot
13439 be represented using the encoding scheme for the file causes
13440 Constraint_Error to be raised. An invalid wide character sequence on
13441 input also causes Constraint_Error to be raised.
13442
13443 @menu
13444 * Wide_Text_IO Stream Pointer Positioning::
13445 * Wide_Text_IO Reading and Writing Non-Regular Files::
13446 @end menu
13447
13448 @node Wide_Text_IO Stream Pointer Positioning
13449 @subsection Stream Pointer Positioning
13450
13451 @noindent
13452 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13453 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13454 case:
13455
13456 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13457 normal lower ASCII set (i.e.@: a character in the range:
13458
13459 @smallexample @c ada
13460 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13461 @end smallexample
13462
13463 @noindent
13464 then although the logical position of the file pointer is unchanged by
13465 the @code{Look_Ahead} call, the stream is physically positioned past the
13466 wide character sequence. Again this is to avoid the need for buffering
13467 or backup, and all @code{Wide_Text_IO} routines check the internal
13468 indication that this situation has occurred so that this is not visible
13469 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13470 can be observed if the wide text file shares a stream with another file.
13471
13472 @node Wide_Text_IO Reading and Writing Non-Regular Files
13473 @subsection Reading and Writing Non-Regular Files
13474
13475 @noindent
13476 As in the case of Text_IO, when a non-regular file is read, it is
13477 assumed that the file contains no page marks (any form characters are
13478 treated as data characters), and @code{End_Of_Page} always returns
13479 @code{False}. Similarly, the end of file indication is not sticky, so
13480 it is possible to read beyond an end of file.
13481
13482 @node Wide_Wide_Text_IO
13483 @section Wide_Wide_Text_IO
13484
13485 @noindent
13486 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13487 both input and output files may contain special sequences that represent
13488 wide wide character values. The encoding scheme for a given file may be
13489 specified using a FORM parameter:
13490
13491 @smallexample
13492 WCEM=@var{x}
13493 @end smallexample
13494
13495 @noindent
13496 as part of the FORM string (WCEM = wide character encoding method),
13497 where @var{x} is one of the following characters
13498
13499 @table @samp
13500 @item h
13501 Hex ESC encoding
13502 @item u
13503 Upper half encoding
13504 @item s
13505 Shift-JIS encoding
13506 @item e
13507 EUC Encoding
13508 @item 8
13509 UTF-8 encoding
13510 @item b
13511 Brackets encoding
13512 @end table
13513
13514 @noindent
13515 The encoding methods match those that
13516 can be used in a source
13517 program, but there is no requirement that the encoding method used for
13518 the source program be the same as the encoding method used for files,
13519 and different files may use different encoding methods.
13520
13521 The default encoding method for the standard files, and for opened files
13522 for which no WCEM parameter is given in the FORM string matches the
13523 wide character encoding specified for the main program (the default
13524 being brackets encoding if no coding method was specified with -gnatW).
13525
13526 @table @asis
13527
13528 @item UTF-8 Coding
13529 A wide character is represented using
13530 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13531 10646-1/Am.2. Depending on the character value, the representation
13532 is a one, two, three, or four byte sequence:
13533
13534 @smallexample
13535 16#000000#-16#00007f#: 2#0xxxxxxx#
13536 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13537 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13538 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13539 @end smallexample
13540
13541 @noindent
13542 where the @var{xxx} bits correspond to the left-padded bits of the
13543 21-bit character value. Note that all lower half ASCII characters
13544 are represented as ASCII bytes and all upper half characters and
13545 other wide characters are represented as sequences of upper-half
13546 characters.
13547
13548 @item Brackets Coding
13549 In this encoding, a wide wide character is represented by the following eight
13550 character sequence if is in wide character range
13551
13552 @smallexample
13553 [ " a b c d " ]
13554 @end smallexample
13555
13556 and by the following ten character sequence if not
13557
13558 @smallexample
13559 [ " a b c d e f " ]
13560 @end smallexample
13561
13562 @noindent
13563 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13564 are the four or six hexadecimal
13565 characters (using uppercase letters) of the wide wide character code. For
13566 example, @code{["01A345"]} is used to represent the wide wide character
13567 with code @code{16#01A345#}.
13568
13569 This scheme is compatible with use of the full Wide_Wide_Character set.
13570 On input, brackets coding can also be used for upper half characters,
13571 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13572 is only used for wide characters with a code greater than @code{16#FF#}.
13573
13574 @end table
13575
13576 @noindent
13577 If is also possible to use the other Wide_Character encoding methods,
13578 such as Shift-JIS, but the other schemes cannot support the full range
13579 of wide wide characters.
13580 An attempt to output a character that cannot
13581 be represented using the encoding scheme for the file causes
13582 Constraint_Error to be raised. An invalid wide character sequence on
13583 input also causes Constraint_Error to be raised.
13584
13585 @menu
13586 * Wide_Wide_Text_IO Stream Pointer Positioning::
13587 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13588 @end menu
13589
13590 @node Wide_Wide_Text_IO Stream Pointer Positioning
13591 @subsection Stream Pointer Positioning
13592
13593 @noindent
13594 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13595 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13596 case:
13597
13598 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13599 normal lower ASCII set (i.e.@: a character in the range:
13600
13601 @smallexample @c ada
13602 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13603 @end smallexample
13604
13605 @noindent
13606 then although the logical position of the file pointer is unchanged by
13607 the @code{Look_Ahead} call, the stream is physically positioned past the
13608 wide character sequence. Again this is to avoid the need for buffering
13609 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13610 indication that this situation has occurred so that this is not visible
13611 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13612 can be observed if the wide text file shares a stream with another file.
13613
13614 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13615 @subsection Reading and Writing Non-Regular Files
13616
13617 @noindent
13618 As in the case of Text_IO, when a non-regular file is read, it is
13619 assumed that the file contains no page marks (any form characters are
13620 treated as data characters), and @code{End_Of_Page} always returns
13621 @code{False}. Similarly, the end of file indication is not sticky, so
13622 it is possible to read beyond an end of file.
13623
13624 @node Stream_IO
13625 @section Stream_IO
13626
13627 @noindent
13628 A stream file is a sequence of bytes, where individual elements are
13629 written to the file as described in the Ada Reference Manual. The type
13630 @code{Stream_Element} is simply a byte. There are two ways to read or
13631 write a stream file.
13632
13633 @itemize @bullet
13634 @item
13635 The operations @code{Read} and @code{Write} directly read or write a
13636 sequence of stream elements with no control information.
13637
13638 @item
13639 The stream attributes applied to a stream file transfer data in the
13640 manner described for stream attributes.
13641 @end itemize
13642
13643 @node Text Translation
13644 @section Text Translation
13645
13646 @noindent
13647 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13648 passed to Text_IO.Create and Text_IO.Open:
13649 @samp{Text_Translation=@var{Yes}} is the default, which means to
13650 translate LF to/from CR/LF on Windows systems.
13651 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13652 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13653 may be used to create Unix-style files on
13654 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13655 systems.
13656
13657 @node Shared Files
13658 @section Shared Files
13659
13660 @noindent
13661 Section A.14 of the Ada Reference Manual allows implementations to
13662 provide a wide variety of behavior if an attempt is made to access the
13663 same external file with two or more internal files.
13664
13665 To provide a full range of functionality, while at the same time
13666 minimizing the problems of portability caused by this implementation
13667 dependence, GNAT handles file sharing as follows:
13668
13669 @itemize @bullet
13670 @item
13671 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13672 to open two or more files with the same full name is considered an error
13673 and is not supported. The exception @code{Use_Error} will be
13674 raised. Note that a file that is not explicitly closed by the program
13675 remains open until the program terminates.
13676
13677 @item
13678 If the form parameter @samp{shared=no} appears in the form string, the
13679 file can be opened or created with its own separate stream identifier,
13680 regardless of whether other files sharing the same external file are
13681 opened. The exact effect depends on how the C stream routines handle
13682 multiple accesses to the same external files using separate streams.
13683
13684 @item
13685 If the form parameter @samp{shared=yes} appears in the form string for
13686 each of two or more files opened using the same full name, the same
13687 stream is shared between these files, and the semantics are as described
13688 in Ada Reference Manual, Section A.14.
13689 @end itemize
13690
13691 @noindent
13692 When a program that opens multiple files with the same name is ported
13693 from another Ada compiler to GNAT, the effect will be that
13694 @code{Use_Error} is raised.
13695
13696 The documentation of the original compiler and the documentation of the
13697 program should then be examined to determine if file sharing was
13698 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13699 and @code{Create} calls as required.
13700
13701 When a program is ported from GNAT to some other Ada compiler, no
13702 special attention is required unless the @samp{shared=@var{xxx}} form
13703 parameter is used in the program. In this case, you must examine the
13704 documentation of the new compiler to see if it supports the required
13705 file sharing semantics, and form strings modified appropriately. Of
13706 course it may be the case that the program cannot be ported if the
13707 target compiler does not support the required functionality. The best
13708 approach in writing portable code is to avoid file sharing (and hence
13709 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13710 completely.
13711
13712 One common use of file sharing in Ada 83 is the use of instantiations of
13713 Sequential_IO on the same file with different types, to achieve
13714 heterogeneous input-output. Although this approach will work in GNAT if
13715 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13716 for this purpose (using the stream attributes)
13717
13718 @node Filenames encoding
13719 @section Filenames encoding
13720
13721 @noindent
13722 An encoding form parameter can be used to specify the filename
13723 encoding @samp{encoding=@var{xxx}}.
13724
13725 @itemize @bullet
13726 @item
13727 If the form parameter @samp{encoding=utf8} appears in the form string, the
13728 filename must be encoded in UTF-8.
13729
13730 @item
13731 If the form parameter @samp{encoding=8bits} appears in the form
13732 string, the filename must be a standard 8bits string.
13733 @end itemize
13734
13735 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13736 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13737 variable. And if not set @samp{utf8} is assumed.
13738
13739 @table @samp
13740 @item CP_ACP
13741 The current system Windows ANSI code page.
13742 @item CP_UTF8
13743 UTF-8 encoding
13744 @end table
13745
13746 This encoding form parameter is only supported on the Windows
13747 platform. On the other Operating Systems the run-time is supporting
13748 UTF-8 natively.
13749
13750 @node Open Modes
13751 @section Open Modes
13752
13753 @noindent
13754 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13755 using the mode shown in the following table:
13756
13757 @sp 2
13758 @center @code{Open} and @code{Create} Call Modes
13759 @smallexample
13760 @b{OPEN } @b{CREATE}
13761 Append_File "r+" "w+"
13762 In_File "r" "w+"
13763 Out_File (Direct_IO) "r+" "w"
13764 Out_File (all other cases) "w" "w"
13765 Inout_File "r+" "w+"
13766 @end smallexample
13767
13768 @noindent
13769 If text file translation is required, then either @samp{b} or @samp{t}
13770 is added to the mode, depending on the setting of Text. Text file
13771 translation refers to the mapping of CR/LF sequences in an external file
13772 to LF characters internally. This mapping only occurs in DOS and
13773 DOS-like systems, and is not relevant to other systems.
13774
13775 A special case occurs with Stream_IO@. As shown in the above table, the
13776 file is initially opened in @samp{r} or @samp{w} mode for the
13777 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13778 subsequently requires switching from reading to writing or vice-versa,
13779 then the file is reopened in @samp{r+} mode to permit the required operation.
13780
13781 @node Operations on C Streams
13782 @section Operations on C Streams
13783 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13784 access to the C library functions for operations on C streams:
13785
13786 @smallexample @c adanocomment
13787 package Interfaces.C_Streams is
13788 -- Note: the reason we do not use the types that are in
13789 -- Interfaces.C is that we want to avoid dragging in the
13790 -- code in this unit if possible.
13791 subtype chars is System.Address;
13792 -- Pointer to null-terminated array of characters
13793 subtype FILEs is System.Address;
13794 -- Corresponds to the C type FILE*
13795 subtype voids is System.Address;
13796 -- Corresponds to the C type void*
13797 subtype int is Integer;
13798 subtype long is Long_Integer;
13799 -- Note: the above types are subtypes deliberately, and it
13800 -- is part of this spec that the above correspondences are
13801 -- guaranteed. This means that it is legitimate to, for
13802 -- example, use Integer instead of int. We provide these
13803 -- synonyms for clarity, but in some cases it may be
13804 -- convenient to use the underlying types (for example to
13805 -- avoid an unnecessary dependency of a spec on the spec
13806 -- of this unit).
13807 type size_t is mod 2 ** Standard'Address_Size;
13808 NULL_Stream : constant FILEs;
13809 -- Value returned (NULL in C) to indicate an
13810 -- fdopen/fopen/tmpfile error
13811 ----------------------------------
13812 -- Constants Defined in stdio.h --
13813 ----------------------------------
13814 EOF : constant int;
13815 -- Used by a number of routines to indicate error or
13816 -- end of file
13817 IOFBF : constant int;
13818 IOLBF : constant int;
13819 IONBF : constant int;
13820 -- Used to indicate buffering mode for setvbuf call
13821 SEEK_CUR : constant int;
13822 SEEK_END : constant int;
13823 SEEK_SET : constant int;
13824 -- Used to indicate origin for fseek call
13825 function stdin return FILEs;
13826 function stdout return FILEs;
13827 function stderr return FILEs;
13828 -- Streams associated with standard files
13829 --------------------------
13830 -- Standard C functions --
13831 --------------------------
13832 -- The functions selected below are ones that are
13833 -- available in UNIX (but not necessarily in ANSI C).
13834 -- These are very thin interfaces
13835 -- which copy exactly the C headers. For more
13836 -- documentation on these functions, see the Microsoft C
13837 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13838 -- ISBN 1-55615-225-6), which includes useful information
13839 -- on system compatibility.
13840 procedure clearerr (stream : FILEs);
13841 function fclose (stream : FILEs) return int;
13842 function fdopen (handle : int; mode : chars) return FILEs;
13843 function feof (stream : FILEs) return int;
13844 function ferror (stream : FILEs) return int;
13845 function fflush (stream : FILEs) return int;
13846 function fgetc (stream : FILEs) return int;
13847 function fgets (strng : chars; n : int; stream : FILEs)
13848 return chars;
13849 function fileno (stream : FILEs) return int;
13850 function fopen (filename : chars; Mode : chars)
13851 return FILEs;
13852 -- Note: to maintain target independence, use
13853 -- text_translation_required, a boolean variable defined in
13854 -- a-sysdep.c to deal with the target dependent text
13855 -- translation requirement. If this variable is set,
13856 -- then b/t should be appended to the standard mode
13857 -- argument to set the text translation mode off or on
13858 -- as required.
13859 function fputc (C : int; stream : FILEs) return int;
13860 function fputs (Strng : chars; Stream : FILEs) return int;
13861 function fread
13862 (buffer : voids;
13863 size : size_t;
13864 count : size_t;
13865 stream : FILEs)
13866 return size_t;
13867 function freopen
13868 (filename : chars;
13869 mode : chars;
13870 stream : FILEs)
13871 return FILEs;
13872 function fseek
13873 (stream : FILEs;
13874 offset : long;
13875 origin : int)
13876 return int;
13877 function ftell (stream : FILEs) return long;
13878 function fwrite
13879 (buffer : voids;
13880 size : size_t;
13881 count : size_t;
13882 stream : FILEs)
13883 return size_t;
13884 function isatty (handle : int) return int;
13885 procedure mktemp (template : chars);
13886 -- The return value (which is just a pointer to template)
13887 -- is discarded
13888 procedure rewind (stream : FILEs);
13889 function rmtmp return int;
13890 function setvbuf
13891 (stream : FILEs;
13892 buffer : chars;
13893 mode : int;
13894 size : size_t)
13895 return int;
13896
13897 function tmpfile return FILEs;
13898 function ungetc (c : int; stream : FILEs) return int;
13899 function unlink (filename : chars) return int;
13900 ---------------------
13901 -- Extra functions --
13902 ---------------------
13903 -- These functions supply slightly thicker bindings than
13904 -- those above. They are derived from functions in the
13905 -- C Run-Time Library, but may do a bit more work than
13906 -- just directly calling one of the Library functions.
13907 function is_regular_file (handle : int) return int;
13908 -- Tests if given handle is for a regular file (result 1)
13909 -- or for a non-regular file (pipe or device, result 0).
13910 ---------------------------------
13911 -- Control of Text/Binary Mode --
13912 ---------------------------------
13913 -- If text_translation_required is true, then the following
13914 -- functions may be used to dynamically switch a file from
13915 -- binary to text mode or vice versa. These functions have
13916 -- no effect if text_translation_required is false (i.e.@: in
13917 -- normal UNIX mode). Use fileno to get a stream handle.
13918 procedure set_binary_mode (handle : int);
13919 procedure set_text_mode (handle : int);
13920 ----------------------------
13921 -- Full Path Name support --
13922 ----------------------------
13923 procedure full_name (nam : chars; buffer : chars);
13924 -- Given a NUL terminated string representing a file
13925 -- name, returns in buffer a NUL terminated string
13926 -- representing the full path name for the file name.
13927 -- On systems where it is relevant the drive is also
13928 -- part of the full path name. It is the responsibility
13929 -- of the caller to pass an actual parameter for buffer
13930 -- that is big enough for any full path name. Use
13931 -- max_path_len given below as the size of buffer.
13932 max_path_len : integer;
13933 -- Maximum length of an allowable full path name on the
13934 -- system, including a terminating NUL character.
13935 end Interfaces.C_Streams;
13936 @end smallexample
13937
13938 @node Interfacing to C Streams
13939 @section Interfacing to C Streams
13940
13941 @noindent
13942 The packages in this section permit interfacing Ada files to C Stream
13943 operations.
13944
13945 @smallexample @c ada
13946 with Interfaces.C_Streams;
13947 package Ada.Sequential_IO.C_Streams is
13948 function C_Stream (F : File_Type)
13949 return Interfaces.C_Streams.FILEs;
13950 procedure Open
13951 (File : in out File_Type;
13952 Mode : in File_Mode;
13953 C_Stream : in Interfaces.C_Streams.FILEs;
13954 Form : in String := "");
13955 end Ada.Sequential_IO.C_Streams;
13956
13957 with Interfaces.C_Streams;
13958 package Ada.Direct_IO.C_Streams is
13959 function C_Stream (F : File_Type)
13960 return Interfaces.C_Streams.FILEs;
13961 procedure Open
13962 (File : in out File_Type;
13963 Mode : in File_Mode;
13964 C_Stream : in Interfaces.C_Streams.FILEs;
13965 Form : in String := "");
13966 end Ada.Direct_IO.C_Streams;
13967
13968 with Interfaces.C_Streams;
13969 package Ada.Text_IO.C_Streams is
13970 function C_Stream (F : File_Type)
13971 return Interfaces.C_Streams.FILEs;
13972 procedure Open
13973 (File : in out File_Type;
13974 Mode : in File_Mode;
13975 C_Stream : in Interfaces.C_Streams.FILEs;
13976 Form : in String := "");
13977 end Ada.Text_IO.C_Streams;
13978
13979 with Interfaces.C_Streams;
13980 package Ada.Wide_Text_IO.C_Streams is
13981 function C_Stream (F : File_Type)
13982 return Interfaces.C_Streams.FILEs;
13983 procedure Open
13984 (File : in out File_Type;
13985 Mode : in File_Mode;
13986 C_Stream : in Interfaces.C_Streams.FILEs;
13987 Form : in String := "");
13988 end Ada.Wide_Text_IO.C_Streams;
13989
13990 with Interfaces.C_Streams;
13991 package Ada.Wide_Wide_Text_IO.C_Streams is
13992 function C_Stream (F : File_Type)
13993 return Interfaces.C_Streams.FILEs;
13994 procedure Open
13995 (File : in out File_Type;
13996 Mode : in File_Mode;
13997 C_Stream : in Interfaces.C_Streams.FILEs;
13998 Form : in String := "");
13999 end Ada.Wide_Wide_Text_IO.C_Streams;
14000
14001 with Interfaces.C_Streams;
14002 package Ada.Stream_IO.C_Streams is
14003 function C_Stream (F : File_Type)
14004 return Interfaces.C_Streams.FILEs;
14005 procedure Open
14006 (File : in out File_Type;
14007 Mode : in File_Mode;
14008 C_Stream : in Interfaces.C_Streams.FILEs;
14009 Form : in String := "");
14010 end Ada.Stream_IO.C_Streams;
14011 @end smallexample
14012
14013 @noindent
14014 In each of these six packages, the @code{C_Stream} function obtains the
14015 @code{FILE} pointer from a currently opened Ada file. It is then
14016 possible to use the @code{Interfaces.C_Streams} package to operate on
14017 this stream, or the stream can be passed to a C program which can
14018 operate on it directly. Of course the program is responsible for
14019 ensuring that only appropriate sequences of operations are executed.
14020
14021 One particular use of relevance to an Ada program is that the
14022 @code{setvbuf} function can be used to control the buffering of the
14023 stream used by an Ada file. In the absence of such a call the standard
14024 default buffering is used.
14025
14026 The @code{Open} procedures in these packages open a file giving an
14027 existing C Stream instead of a file name. Typically this stream is
14028 imported from a C program, allowing an Ada file to operate on an
14029 existing C file.
14030
14031 @node The GNAT Library
14032 @chapter The GNAT Library
14033
14034 @noindent
14035 The GNAT library contains a number of general and special purpose packages.
14036 It represents functionality that the GNAT developers have found useful, and
14037 which is made available to GNAT users. The packages described here are fully
14038 supported, and upwards compatibility will be maintained in future releases,
14039 so you can use these facilities with the confidence that the same functionality
14040 will be available in future releases.
14041
14042 The chapter here simply gives a brief summary of the facilities available.
14043 The full documentation is found in the spec file for the package. The full
14044 sources of these library packages, including both spec and body, are provided
14045 with all GNAT releases. For example, to find out the full specifications of
14046 the SPITBOL pattern matching capability, including a full tutorial and
14047 extensive examples, look in the @file{g-spipat.ads} file in the library.
14048
14049 For each entry here, the package name (as it would appear in a @code{with}
14050 clause) is given, followed by the name of the corresponding spec file in
14051 parentheses. The packages are children in four hierarchies, @code{Ada},
14052 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14053 GNAT-specific hierarchy.
14054
14055 Note that an application program should only use packages in one of these
14056 four hierarchies if the package is defined in the Ada Reference Manual,
14057 or is listed in this section of the GNAT Programmers Reference Manual.
14058 All other units should be considered internal implementation units and
14059 should not be directly @code{with}'ed by application code. The use of
14060 a @code{with} statement that references one of these internal implementation
14061 units makes an application potentially dependent on changes in versions
14062 of GNAT, and will generate a warning message.
14063
14064 @menu
14065 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14066 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14067 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14068 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14069 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14070 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14071 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14072 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14073 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14074 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14075 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14076 * Ada.Command_Line.Environment (a-colien.ads)::
14077 * Ada.Command_Line.Remove (a-colire.ads)::
14078 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14079 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14080 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14081 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14082 * Ada.Exceptions.Traceback (a-exctra.ads)::
14083 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14084 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14085 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14086 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14087 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14088 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14089 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14090 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14091 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14092 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14093 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14094 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14095 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14096 * GNAT.Altivec (g-altive.ads)::
14097 * GNAT.Altivec.Conversions (g-altcon.ads)::
14098 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14099 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14100 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14101 * GNAT.Array_Split (g-arrspl.ads)::
14102 * GNAT.AWK (g-awk.ads)::
14103 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14104 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14105 * GNAT.Bubble_Sort (g-bubsor.ads)::
14106 * GNAT.Bubble_Sort_A (g-busora.ads)::
14107 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14108 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14109 * GNAT.Byte_Swapping (g-bytswa.ads)::
14110 * GNAT.Calendar (g-calend.ads)::
14111 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14112 * GNAT.Case_Util (g-casuti.ads)::
14113 * GNAT.CGI (g-cgi.ads)::
14114 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14115 * GNAT.CGI.Debug (g-cgideb.ads)::
14116 * GNAT.Command_Line (g-comlin.ads)::
14117 * GNAT.Compiler_Version (g-comver.ads)::
14118 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14119 * GNAT.CRC32 (g-crc32.ads)::
14120 * GNAT.Current_Exception (g-curexc.ads)::
14121 * GNAT.Debug_Pools (g-debpoo.ads)::
14122 * GNAT.Debug_Utilities (g-debuti.ads)::
14123 * GNAT.Decode_String (g-decstr.ads)::
14124 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14125 * GNAT.Directory_Operations (g-dirope.ads)::
14126 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14127 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14128 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14129 * GNAT.Encode_String (g-encstr.ads)::
14130 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14131 * GNAT.Exception_Actions (g-excact.ads)::
14132 * GNAT.Exception_Traces (g-exctra.ads)::
14133 * GNAT.Exceptions (g-except.ads)::
14134 * GNAT.Expect (g-expect.ads)::
14135 * GNAT.Float_Control (g-flocon.ads)::
14136 * GNAT.Heap_Sort (g-heasor.ads)::
14137 * GNAT.Heap_Sort_A (g-hesora.ads)::
14138 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14139 * GNAT.HTable (g-htable.ads)::
14140 * GNAT.IO (g-io.ads)::
14141 * GNAT.IO_Aux (g-io_aux.ads)::
14142 * GNAT.Lock_Files (g-locfil.ads)::
14143 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14144 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14145 * GNAT.MD5 (g-md5.ads)::
14146 * GNAT.Memory_Dump (g-memdum.ads)::
14147 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14148 * GNAT.OS_Lib (g-os_lib.ads)::
14149 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14150 * GNAT.Random_Numbers (g-rannum.ads)::
14151 * GNAT.Regexp (g-regexp.ads)::
14152 * GNAT.Registry (g-regist.ads)::
14153 * GNAT.Regpat (g-regpat.ads)::
14154 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14155 * GNAT.Semaphores (g-semaph.ads)::
14156 * GNAT.Serial_Communications (g-sercom.ads)::
14157 * GNAT.SHA1 (g-sha1.ads)::
14158 * GNAT.SHA224 (g-sha224.ads)::
14159 * GNAT.SHA256 (g-sha256.ads)::
14160 * GNAT.SHA384 (g-sha384.ads)::
14161 * GNAT.SHA512 (g-sha512.ads)::
14162 * GNAT.Signals (g-signal.ads)::
14163 * GNAT.Sockets (g-socket.ads)::
14164 * GNAT.Source_Info (g-souinf.ads)::
14165 * GNAT.Spelling_Checker (g-speche.ads)::
14166 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14167 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14168 * GNAT.Spitbol (g-spitbo.ads)::
14169 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14170 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14171 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14172 * GNAT.SSE (g-sse.ads)::
14173 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14174 * GNAT.Strings (g-string.ads)::
14175 * GNAT.String_Split (g-strspl.ads)::
14176 * GNAT.Table (g-table.ads)::
14177 * GNAT.Task_Lock (g-tasloc.ads)::
14178 * GNAT.Threads (g-thread.ads)::
14179 * GNAT.Time_Stamp (g-timsta.ads)::
14180 * GNAT.Traceback (g-traceb.ads)::
14181 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14182 * GNAT.UTF_32 (g-utf_32.ads)::
14183 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14184 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14185 * GNAT.Wide_String_Split (g-wistsp.ads)::
14186 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14187 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14188 * Interfaces.C.Extensions (i-cexten.ads)::
14189 * Interfaces.C.Streams (i-cstrea.ads)::
14190 * Interfaces.CPP (i-cpp.ads)::
14191 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14192 * Interfaces.VxWorks (i-vxwork.ads)::
14193 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14194 * System.Address_Image (s-addima.ads)::
14195 * System.Assertions (s-assert.ads)::
14196 * System.Memory (s-memory.ads)::
14197 * System.Partition_Interface (s-parint.ads)::
14198 * System.Pool_Global (s-pooglo.ads)::
14199 * System.Pool_Local (s-pooloc.ads)::
14200 * System.Restrictions (s-restri.ads)::
14201 * System.Rident (s-rident.ads)::
14202 * System.Strings.Stream_Ops (s-ststop.ads)::
14203 * System.Task_Info (s-tasinf.ads)::
14204 * System.Wch_Cnv (s-wchcnv.ads)::
14205 * System.Wch_Con (s-wchcon.ads)::
14206 @end menu
14207
14208 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14209 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14210 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14211 @cindex Latin_9 constants for Character
14212
14213 @noindent
14214 This child of @code{Ada.Characters}
14215 provides a set of definitions corresponding to those in the
14216 RM-defined package @code{Ada.Characters.Latin_1} but with the
14217 few modifications required for @code{Latin-9}
14218 The provision of such a package
14219 is specifically authorized by the Ada Reference Manual
14220 (RM A.3.3(27)).
14221
14222 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14223 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14224 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14225 @cindex Latin_1 constants for Wide_Character
14226
14227 @noindent
14228 This child of @code{Ada.Characters}
14229 provides a set of definitions corresponding to those in the
14230 RM-defined package @code{Ada.Characters.Latin_1} but with the
14231 types of the constants being @code{Wide_Character}
14232 instead of @code{Character}. The provision of such a package
14233 is specifically authorized by the Ada Reference Manual
14234 (RM A.3.3(27)).
14235
14236 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14237 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14238 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14239 @cindex Latin_9 constants for Wide_Character
14240
14241 @noindent
14242 This child of @code{Ada.Characters}
14243 provides a set of definitions corresponding to those in the
14244 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14245 types of the constants being @code{Wide_Character}
14246 instead of @code{Character}. The provision of such a package
14247 is specifically authorized by the Ada Reference Manual
14248 (RM A.3.3(27)).
14249
14250 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14251 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14252 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14253 @cindex Latin_1 constants for Wide_Wide_Character
14254
14255 @noindent
14256 This child of @code{Ada.Characters}
14257 provides a set of definitions corresponding to those in the
14258 RM-defined package @code{Ada.Characters.Latin_1} but with the
14259 types of the constants being @code{Wide_Wide_Character}
14260 instead of @code{Character}. The provision of such a package
14261 is specifically authorized by the Ada Reference Manual
14262 (RM A.3.3(27)).
14263
14264 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14265 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14266 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14267 @cindex Latin_9 constants for Wide_Wide_Character
14268
14269 @noindent
14270 This child of @code{Ada.Characters}
14271 provides a set of definitions corresponding to those in the
14272 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14273 types of the constants being @code{Wide_Wide_Character}
14274 instead of @code{Character}. The provision of such a package
14275 is specifically authorized by the Ada Reference Manual
14276 (RM A.3.3(27)).
14277
14278 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14279 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14280 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14281 @cindex Formal container for doubly linked lists
14282
14283 @noindent
14284 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14285 container for doubly linked lists, meant to facilitate formal verification of
14286 code using such containers.
14287
14288 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14289 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14290 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14291 @cindex Formal container for hashed maps
14292
14293 @noindent
14294 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14295 container for hashed maps, meant to facilitate formal verification of
14296 code using such containers.
14297
14298 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14299 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14300 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14301 @cindex Formal container for hashed sets
14302
14303 @noindent
14304 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14305 container for hashed sets, meant to facilitate formal verification of
14306 code using such containers.
14307
14308 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14309 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14310 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14311 @cindex Formal container for ordered maps
14312
14313 @noindent
14314 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14315 container for ordered maps, meant to facilitate formal verification of
14316 code using such containers.
14317
14318 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14319 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14320 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14321 @cindex Formal container for ordered sets
14322
14323 @noindent
14324 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14325 container for ordered sets, meant to facilitate formal verification of
14326 code using such containers.
14327
14328 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14329 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14330 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14331 @cindex Formal container for vectors
14332
14333 @noindent
14334 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14335 container for vectors, meant to facilitate formal verification of
14336 code using such containers.
14337
14338 @node Ada.Command_Line.Environment (a-colien.ads)
14339 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14340 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14341 @cindex Environment entries
14342
14343 @noindent
14344 This child of @code{Ada.Command_Line}
14345 provides a mechanism for obtaining environment values on systems
14346 where this concept makes sense.
14347
14348 @node Ada.Command_Line.Remove (a-colire.ads)
14349 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14350 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14351 @cindex Removing command line arguments
14352 @cindex Command line, argument removal
14353
14354 @noindent
14355 This child of @code{Ada.Command_Line}
14356 provides a mechanism for logically removing
14357 arguments from the argument list. Once removed, an argument is not visible
14358 to further calls on the subprograms in @code{Ada.Command_Line} will not
14359 see the removed argument.
14360
14361 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14362 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14363 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14364 @cindex Response file for command line
14365 @cindex Command line, response file
14366 @cindex Command line, handling long command lines
14367
14368 @noindent
14369 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14370 getting command line arguments from a text file, called a "response file".
14371 Using a response file allow passing a set of arguments to an executable longer
14372 than the maximum allowed by the system on the command line.
14373
14374 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14375 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14376 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14377 @cindex C Streams, Interfacing with Direct_IO
14378
14379 @noindent
14380 This package provides subprograms that allow interfacing between
14381 C streams and @code{Direct_IO}. The stream identifier can be
14382 extracted from a file opened on the Ada side, and an Ada file
14383 can be constructed from a stream opened on the C side.
14384
14385 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14386 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14387 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14388 @cindex Null_Occurrence, testing for
14389
14390 @noindent
14391 This child subprogram provides a way of testing for the null
14392 exception occurrence (@code{Null_Occurrence}) without raising
14393 an exception.
14394
14395 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14396 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14397 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14398 @cindex Null_Occurrence, testing for
14399
14400 @noindent
14401 This child subprogram is used for handling otherwise unhandled
14402 exceptions (hence the name last chance), and perform clean ups before
14403 terminating the program. Note that this subprogram never returns.
14404
14405 @node Ada.Exceptions.Traceback (a-exctra.ads)
14406 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14407 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14408 @cindex Traceback for Exception Occurrence
14409
14410 @noindent
14411 This child package provides the subprogram (@code{Tracebacks}) to
14412 give a traceback array of addresses based on an exception
14413 occurrence.
14414
14415 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14416 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14417 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14418 @cindex C Streams, Interfacing with Sequential_IO
14419
14420 @noindent
14421 This package provides subprograms that allow interfacing between
14422 C streams and @code{Sequential_IO}. The stream identifier can be
14423 extracted from a file opened on the Ada side, and an Ada file
14424 can be constructed from a stream opened on the C side.
14425
14426 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14427 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14428 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14429 @cindex C Streams, Interfacing with Stream_IO
14430
14431 @noindent
14432 This package provides subprograms that allow interfacing between
14433 C streams and @code{Stream_IO}. The stream identifier can be
14434 extracted from a file opened on the Ada side, and an Ada file
14435 can be constructed from a stream opened on the C side.
14436
14437 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14438 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14439 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14440 @cindex @code{Unbounded_String}, IO support
14441 @cindex @code{Text_IO}, extensions for unbounded strings
14442
14443 @noindent
14444 This package provides subprograms for Text_IO for unbounded
14445 strings, avoiding the necessity for an intermediate operation
14446 with ordinary strings.
14447
14448 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14449 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14450 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14451 @cindex @code{Unbounded_Wide_String}, IO support
14452 @cindex @code{Text_IO}, extensions for unbounded wide strings
14453
14454 @noindent
14455 This package provides subprograms for Text_IO for unbounded
14456 wide strings, avoiding the necessity for an intermediate operation
14457 with ordinary wide strings.
14458
14459 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14460 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14461 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14462 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14463 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14464
14465 @noindent
14466 This package provides subprograms for Text_IO for unbounded
14467 wide wide strings, avoiding the necessity for an intermediate operation
14468 with ordinary wide wide strings.
14469
14470 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14471 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14472 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14473 @cindex C Streams, Interfacing with @code{Text_IO}
14474
14475 @noindent
14476 This package provides subprograms that allow interfacing between
14477 C streams and @code{Text_IO}. The stream identifier can be
14478 extracted from a file opened on the Ada side, and an Ada file
14479 can be constructed from a stream opened on the C side.
14480
14481 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14482 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14483 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14484 @cindex @code{Text_IO} resetting standard files
14485
14486 @noindent
14487 This procedure is used to reset the status of the standard files used
14488 by Ada.Text_IO. This is useful in a situation (such as a restart in an
14489 embedded application) where the status of the files may change during
14490 execution (for example a standard input file may be redefined to be
14491 interactive).
14492
14493 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14494 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14495 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14496 @cindex Unicode categorization, Wide_Character
14497
14498 @noindent
14499 This package provides subprograms that allow categorization of
14500 Wide_Character values according to Unicode categories.
14501
14502 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14503 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14504 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14505 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14506
14507 @noindent
14508 This package provides subprograms that allow interfacing between
14509 C streams and @code{Wide_Text_IO}. The stream identifier can be
14510 extracted from a file opened on the Ada side, and an Ada file
14511 can be constructed from a stream opened on the C side.
14512
14513 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14514 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14515 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14516 @cindex @code{Wide_Text_IO} resetting standard files
14517
14518 @noindent
14519 This procedure is used to reset the status of the standard files used
14520 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14521 embedded application) where the status of the files may change during
14522 execution (for example a standard input file may be redefined to be
14523 interactive).
14524
14525 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14526 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14527 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14528 @cindex Unicode categorization, Wide_Wide_Character
14529
14530 @noindent
14531 This package provides subprograms that allow categorization of
14532 Wide_Wide_Character values according to Unicode categories.
14533
14534 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14535 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14536 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14537 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14538
14539 @noindent
14540 This package provides subprograms that allow interfacing between
14541 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14542 extracted from a file opened on the Ada side, and an Ada file
14543 can be constructed from a stream opened on the C side.
14544
14545 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14546 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14547 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14548 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14549
14550 @noindent
14551 This procedure is used to reset the status of the standard files used
14552 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14553 restart in an embedded application) where the status of the files may
14554 change during execution (for example a standard input file may be
14555 redefined to be interactive).
14556
14557 @node GNAT.Altivec (g-altive.ads)
14558 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14559 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14560 @cindex AltiVec
14561
14562 @noindent
14563 This is the root package of the GNAT AltiVec binding. It provides
14564 definitions of constants and types common to all the versions of the
14565 binding.
14566
14567 @node GNAT.Altivec.Conversions (g-altcon.ads)
14568 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14569 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14570 @cindex AltiVec
14571
14572 @noindent
14573 This package provides the Vector/View conversion routines.
14574
14575 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14576 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14577 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14578 @cindex AltiVec
14579
14580 @noindent
14581 This package exposes the Ada interface to the AltiVec operations on
14582 vector objects. A soft emulation is included by default in the GNAT
14583 library. The hard binding is provided as a separate package. This unit
14584 is common to both bindings.
14585
14586 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14587 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14588 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14589 @cindex AltiVec
14590
14591 @noindent
14592 This package exposes the various vector types part of the Ada binding
14593 to AltiVec facilities.
14594
14595 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14596 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14597 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14598 @cindex AltiVec
14599
14600 @noindent
14601 This package provides public 'View' data types from/to which private
14602 vector representations can be converted via
14603 GNAT.Altivec.Conversions. This allows convenient access to individual
14604 vector elements and provides a simple way to initialize vector
14605 objects.
14606
14607 @node GNAT.Array_Split (g-arrspl.ads)
14608 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14609 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14610 @cindex Array splitter
14611
14612 @noindent
14613 Useful array-manipulation routines: given a set of separators, split
14614 an array wherever the separators appear, and provide direct access
14615 to the resulting slices.
14616
14617 @node GNAT.AWK (g-awk.ads)
14618 @section @code{GNAT.AWK} (@file{g-awk.ads})
14619 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14620 @cindex Parsing
14621 @cindex AWK
14622
14623 @noindent
14624 Provides AWK-like parsing functions, with an easy interface for parsing one
14625 or more files containing formatted data. The file is viewed as a database
14626 where each record is a line and a field is a data element in this line.
14627
14628 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14629 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14630 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14631 @cindex Parsing
14632 @cindex Bounded Buffers
14633
14634 @noindent
14635 Provides a concurrent generic bounded buffer abstraction. Instances are
14636 useful directly or as parts of the implementations of other abstractions,
14637 such as mailboxes.
14638
14639 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14640 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14641 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14642 @cindex Parsing
14643 @cindex Mailboxes
14644
14645 @noindent
14646 Provides a thread-safe asynchronous intertask mailbox communication facility.
14647
14648 @node GNAT.Bubble_Sort (g-bubsor.ads)
14649 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14650 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14651 @cindex Sorting
14652 @cindex Bubble sort
14653
14654 @noindent
14655 Provides a general implementation of bubble sort usable for sorting arbitrary
14656 data items. Exchange and comparison procedures are provided by passing
14657 access-to-procedure values.
14658
14659 @node GNAT.Bubble_Sort_A (g-busora.ads)
14660 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14661 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14662 @cindex Sorting
14663 @cindex Bubble sort
14664
14665 @noindent
14666 Provides a general implementation of bubble sort usable for sorting arbitrary
14667 data items. Move and comparison procedures are provided by passing
14668 access-to-procedure values. This is an older version, retained for
14669 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14670
14671 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14672 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14673 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14674 @cindex Sorting
14675 @cindex Bubble sort
14676
14677 @noindent
14678 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14679 are provided as generic parameters, this improves efficiency, especially
14680 if the procedures can be inlined, at the expense of duplicating code for
14681 multiple instantiations.
14682
14683 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14684 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14685 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14686 @cindex UTF-8 representation
14687 @cindex Wide characte representations
14688
14689 @noindent
14690 Provides a routine which given a string, reads the start of the string to
14691 see whether it is one of the standard byte order marks (BOM's) which signal
14692 the encoding of the string. The routine includes detection of special XML
14693 sequences for various UCS input formats.
14694
14695 @node GNAT.Byte_Swapping (g-bytswa.ads)
14696 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14697 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14698 @cindex Byte swapping
14699 @cindex Endian
14700
14701 @noindent
14702 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14703 Machine-specific implementations are available in some cases.
14704
14705 @node GNAT.Calendar (g-calend.ads)
14706 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14707 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14708 @cindex @code{Calendar}
14709
14710 @noindent
14711 Extends the facilities provided by @code{Ada.Calendar} to include handling
14712 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14713 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14714 C @code{timeval} format.
14715
14716 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14717 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14718 @cindex @code{Calendar}
14719 @cindex Time
14720 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14721
14722 @node GNAT.CRC32 (g-crc32.ads)
14723 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14724 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14725 @cindex CRC32
14726 @cindex Cyclic Redundancy Check
14727
14728 @noindent
14729 This package implements the CRC-32 algorithm. For a full description
14730 of this algorithm see
14731 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14732 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14733 Aug.@: 1988. Sarwate, D.V@.
14734
14735 @node GNAT.Case_Util (g-casuti.ads)
14736 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14737 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14738 @cindex Casing utilities
14739 @cindex Character handling (@code{GNAT.Case_Util})
14740
14741 @noindent
14742 A set of simple routines for handling upper and lower casing of strings
14743 without the overhead of the full casing tables
14744 in @code{Ada.Characters.Handling}.
14745
14746 @node GNAT.CGI (g-cgi.ads)
14747 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14748 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14749 @cindex CGI (Common Gateway Interface)
14750
14751 @noindent
14752 This is a package for interfacing a GNAT program with a Web server via the
14753 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14754 parameters, which are a set of key/value pairs sent by the Web server. It
14755 builds a table whose index is the key and provides some services to deal
14756 with this table.
14757
14758 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14759 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14760 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14761 @cindex CGI (Common Gateway Interface) cookie support
14762 @cindex Cookie support in CGI
14763
14764 @noindent
14765 This is a package to interface a GNAT program with a Web server via the
14766 Common Gateway Interface (CGI). It exports services to deal with Web
14767 cookies (piece of information kept in the Web client software).
14768
14769 @node GNAT.CGI.Debug (g-cgideb.ads)
14770 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14771 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14772 @cindex CGI (Common Gateway Interface) debugging
14773
14774 @noindent
14775 This is a package to help debugging CGI (Common Gateway Interface)
14776 programs written in Ada.
14777
14778 @node GNAT.Command_Line (g-comlin.ads)
14779 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14780 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14781 @cindex Command line
14782
14783 @noindent
14784 Provides a high level interface to @code{Ada.Command_Line} facilities,
14785 including the ability to scan for named switches with optional parameters
14786 and expand file names using wild card notations.
14787
14788 @node GNAT.Compiler_Version (g-comver.ads)
14789 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14790 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14791 @cindex Compiler Version
14792 @cindex Version, of compiler
14793
14794 @noindent
14795 Provides a routine for obtaining the version of the compiler used to
14796 compile the program. More accurately this is the version of the binder
14797 used to bind the program (this will normally be the same as the version
14798 of the compiler if a consistent tool set is used to compile all units
14799 of a partition).
14800
14801 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14802 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14803 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14804 @cindex Interrupt
14805
14806 @noindent
14807 Provides a simple interface to handle Ctrl-C keyboard events.
14808
14809 @node GNAT.Current_Exception (g-curexc.ads)
14810 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14811 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14812 @cindex Current exception
14813 @cindex Exception retrieval
14814
14815 @noindent
14816 Provides access to information on the current exception that has been raised
14817 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14818 specification syntax.
14819 This is particularly useful in simulating typical facilities for
14820 obtaining information about exceptions provided by Ada 83 compilers.
14821
14822 @node GNAT.Debug_Pools (g-debpoo.ads)
14823 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14824 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14825 @cindex Debugging
14826 @cindex Debug pools
14827 @cindex Memory corruption debugging
14828
14829 @noindent
14830 Provide a debugging storage pools that helps tracking memory corruption
14831 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14832 @value{EDITION} User's Guide}.
14833
14834 @node GNAT.Debug_Utilities (g-debuti.ads)
14835 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14836 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14837 @cindex Debugging
14838
14839 @noindent
14840 Provides a few useful utilities for debugging purposes, including conversion
14841 to and from string images of address values. Supports both C and Ada formats
14842 for hexadecimal literals.
14843
14844 @node GNAT.Decode_String (g-decstr.ads)
14845 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14846 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14847 @cindex Decoding strings
14848 @cindex String decoding
14849 @cindex Wide character encoding
14850 @cindex UTF-8
14851 @cindex Unicode
14852
14853 @noindent
14854 A generic package providing routines for decoding wide character and wide wide
14855 character strings encoded as sequences of 8-bit characters using a specified
14856 encoding method. Includes validation routines, and also routines for stepping
14857 to next or previous encoded character in an encoded string.
14858 Useful in conjunction with Unicode character coding. Note there is a
14859 preinstantiation for UTF-8. See next entry.
14860
14861 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14862 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14863 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14864 @cindex Decoding strings
14865 @cindex Decoding UTF-8 strings
14866 @cindex UTF-8 string decoding
14867 @cindex Wide character decoding
14868 @cindex UTF-8
14869 @cindex Unicode
14870
14871 @noindent
14872 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14873
14874 @node GNAT.Directory_Operations (g-dirope.ads)
14875 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14876 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14877 @cindex Directory operations
14878
14879 @noindent
14880 Provides a set of routines for manipulating directories, including changing
14881 the current directory, making new directories, and scanning the files in a
14882 directory.
14883
14884 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14885 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14886 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14887 @cindex Directory operations iteration
14888
14889 @noindent
14890 A child unit of GNAT.Directory_Operations providing additional operations
14891 for iterating through directories.
14892
14893 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14894 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14895 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14896 @cindex Hash tables
14897
14898 @noindent
14899 A generic implementation of hash tables that can be used to hash arbitrary
14900 data. Provided in two forms, a simple form with built in hash functions,
14901 and a more complex form in which the hash function is supplied.
14902
14903 @noindent
14904 This package provides a facility similar to that of @code{GNAT.HTable},
14905 except that this package declares a type that can be used to define
14906 dynamic instances of the hash table, while an instantiation of
14907 @code{GNAT.HTable} creates a single instance of the hash table.
14908
14909 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14910 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14911 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14912 @cindex Table implementation
14913 @cindex Arrays, extendable
14914
14915 @noindent
14916 A generic package providing a single dimension array abstraction where the
14917 length of the array can be dynamically modified.
14918
14919 @noindent
14920 This package provides a facility similar to that of @code{GNAT.Table},
14921 except that this package declares a type that can be used to define
14922 dynamic instances of the table, while an instantiation of
14923 @code{GNAT.Table} creates a single instance of the table type.
14924
14925 @node GNAT.Encode_String (g-encstr.ads)
14926 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14927 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14928 @cindex Encoding strings
14929 @cindex String encoding
14930 @cindex Wide character encoding
14931 @cindex UTF-8
14932 @cindex Unicode
14933
14934 @noindent
14935 A generic package providing routines for encoding wide character and wide
14936 wide character strings as sequences of 8-bit characters using a specified
14937 encoding method. Useful in conjunction with Unicode character coding.
14938 Note there is a preinstantiation for UTF-8. See next entry.
14939
14940 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14941 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14942 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14943 @cindex Encoding strings
14944 @cindex Encoding UTF-8 strings
14945 @cindex UTF-8 string encoding
14946 @cindex Wide character encoding
14947 @cindex UTF-8
14948 @cindex Unicode
14949
14950 @noindent
14951 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14952
14953 @node GNAT.Exception_Actions (g-excact.ads)
14954 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14955 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14956 @cindex Exception actions
14957
14958 @noindent
14959 Provides callbacks when an exception is raised. Callbacks can be registered
14960 for specific exceptions, or when any exception is raised. This
14961 can be used for instance to force a core dump to ease debugging.
14962
14963 @node GNAT.Exception_Traces (g-exctra.ads)
14964 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14965 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14966 @cindex Exception traces
14967 @cindex Debugging
14968
14969 @noindent
14970 Provides an interface allowing to control automatic output upon exception
14971 occurrences.
14972
14973 @node GNAT.Exceptions (g-except.ads)
14974 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14975 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14976 @cindex Exceptions, Pure
14977 @cindex Pure packages, exceptions
14978
14979 @noindent
14980 Normally it is not possible to raise an exception with
14981 a message from a subprogram in a pure package, since the
14982 necessary types and subprograms are in @code{Ada.Exceptions}
14983 which is not a pure unit. @code{GNAT.Exceptions} provides a
14984 facility for getting around this limitation for a few
14985 predefined exceptions, and for example allow raising
14986 @code{Constraint_Error} with a message from a pure subprogram.
14987
14988 @node GNAT.Expect (g-expect.ads)
14989 @section @code{GNAT.Expect} (@file{g-expect.ads})
14990 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14991
14992 @noindent
14993 Provides a set of subprograms similar to what is available
14994 with the standard Tcl Expect tool.
14995 It allows you to easily spawn and communicate with an external process.
14996 You can send commands or inputs to the process, and compare the output
14997 with some expected regular expression. Currently @code{GNAT.Expect}
14998 is implemented on all native GNAT ports except for OpenVMS@.
14999 It is not implemented for cross ports, and in particular is not
15000 implemented for VxWorks or LynxOS@.
15001
15002 @node GNAT.Float_Control (g-flocon.ads)
15003 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15004 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15005 @cindex Floating-Point Processor
15006
15007 @noindent
15008 Provides an interface for resetting the floating-point processor into the
15009 mode required for correct semantic operation in Ada. Some third party
15010 library calls may cause this mode to be modified, and the Reset procedure
15011 in this package can be used to reestablish the required mode.
15012
15013 @node GNAT.Heap_Sort (g-heasor.ads)
15014 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15015 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15016 @cindex Sorting
15017
15018 @noindent
15019 Provides a general implementation of heap sort usable for sorting arbitrary
15020 data items. Exchange and comparison procedures are provided by passing
15021 access-to-procedure values. The algorithm used is a modified heap sort
15022 that performs approximately N*log(N) comparisons in the worst case.
15023
15024 @node GNAT.Heap_Sort_A (g-hesora.ads)
15025 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15026 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15027 @cindex Sorting
15028
15029 @noindent
15030 Provides a general implementation of heap sort usable for sorting arbitrary
15031 data items. Move and comparison procedures are provided by passing
15032 access-to-procedure values. The algorithm used is a modified heap sort
15033 that performs approximately N*log(N) comparisons in the worst case.
15034 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15035 interface, but may be slightly more efficient.
15036
15037 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15038 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15039 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15040 @cindex Sorting
15041
15042 @noindent
15043 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15044 are provided as generic parameters, this improves efficiency, especially
15045 if the procedures can be inlined, at the expense of duplicating code for
15046 multiple instantiations.
15047
15048 @node GNAT.HTable (g-htable.ads)
15049 @section @code{GNAT.HTable} (@file{g-htable.ads})
15050 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15051 @cindex Hash tables
15052
15053 @noindent
15054 A generic implementation of hash tables that can be used to hash arbitrary
15055 data. Provides two approaches, one a simple static approach, and the other
15056 allowing arbitrary dynamic hash tables.
15057
15058 @node GNAT.IO (g-io.ads)
15059 @section @code{GNAT.IO} (@file{g-io.ads})
15060 @cindex @code{GNAT.IO} (@file{g-io.ads})
15061 @cindex Simple I/O
15062 @cindex Input/Output facilities
15063
15064 @noindent
15065 A simple preelaborable input-output package that provides a subset of
15066 simple Text_IO functions for reading characters and strings from
15067 Standard_Input, and writing characters, strings and integers to either
15068 Standard_Output or Standard_Error.
15069
15070 @node GNAT.IO_Aux (g-io_aux.ads)
15071 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15072 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15073 @cindex Text_IO
15074 @cindex Input/Output facilities
15075
15076 Provides some auxiliary functions for use with Text_IO, including a test
15077 for whether a file exists, and functions for reading a line of text.
15078
15079 @node GNAT.Lock_Files (g-locfil.ads)
15080 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15081 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15082 @cindex File locking
15083 @cindex Locking using files
15084
15085 @noindent
15086 Provides a general interface for using files as locks. Can be used for
15087 providing program level synchronization.
15088
15089 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15090 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15091 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15092 @cindex Random number generation
15093
15094 @noindent
15095 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15096 a modified version of the Blum-Blum-Shub generator.
15097
15098 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15099 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15100 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15101 @cindex Random number generation
15102
15103 @noindent
15104 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15105 a modified version of the Blum-Blum-Shub generator.
15106
15107 @node GNAT.MD5 (g-md5.ads)
15108 @section @code{GNAT.MD5} (@file{g-md5.ads})
15109 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15110 @cindex Message Digest MD5
15111
15112 @noindent
15113 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15114
15115 @node GNAT.Memory_Dump (g-memdum.ads)
15116 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15117 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15118 @cindex Dump Memory
15119
15120 @noindent
15121 Provides a convenient routine for dumping raw memory to either the
15122 standard output or standard error files. Uses GNAT.IO for actual
15123 output.
15124
15125 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15126 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15127 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15128 @cindex Exception, obtaining most recent
15129
15130 @noindent
15131 Provides access to the most recently raised exception. Can be used for
15132 various logging purposes, including duplicating functionality of some
15133 Ada 83 implementation dependent extensions.
15134
15135 @node GNAT.OS_Lib (g-os_lib.ads)
15136 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15137 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15138 @cindex Operating System interface
15139 @cindex Spawn capability
15140
15141 @noindent
15142 Provides a range of target independent operating system interface functions,
15143 including time/date management, file operations, subprocess management,
15144 including a portable spawn procedure, and access to environment variables
15145 and error return codes.
15146
15147 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15148 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15149 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15150 @cindex Hash functions
15151
15152 @noindent
15153 Provides a generator of static minimal perfect hash functions. No
15154 collisions occur and each item can be retrieved from the table in one
15155 probe (perfect property). The hash table size corresponds to the exact
15156 size of the key set and no larger (minimal property). The key set has to
15157 be know in advance (static property). The hash functions are also order
15158 preserving. If w2 is inserted after w1 in the generator, their
15159 hashcode are in the same order. These hashing functions are very
15160 convenient for use with realtime applications.
15161
15162 @node GNAT.Random_Numbers (g-rannum.ads)
15163 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15164 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15165 @cindex Random number generation
15166
15167 @noindent
15168 Provides random number capabilities which extend those available in the
15169 standard Ada library and are more convenient to use.
15170
15171 @node GNAT.Regexp (g-regexp.ads)
15172 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15173 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15174 @cindex Regular expressions
15175 @cindex Pattern matching
15176
15177 @noindent
15178 A simple implementation of regular expressions, using a subset of regular
15179 expression syntax copied from familiar Unix style utilities. This is the
15180 simples of the three pattern matching packages provided, and is particularly
15181 suitable for ``file globbing'' applications.
15182
15183 @node GNAT.Registry (g-regist.ads)
15184 @section @code{GNAT.Registry} (@file{g-regist.ads})
15185 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15186 @cindex Windows Registry
15187
15188 @noindent
15189 This is a high level binding to the Windows registry. It is possible to
15190 do simple things like reading a key value, creating a new key. For full
15191 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15192 package provided with the Win32Ada binding
15193
15194 @node GNAT.Regpat (g-regpat.ads)
15195 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15196 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15197 @cindex Regular expressions
15198 @cindex Pattern matching
15199
15200 @noindent
15201 A complete implementation of Unix-style regular expression matching, copied
15202 from the original V7 style regular expression library written in C by
15203 Henry Spencer (and binary compatible with this C library).
15204
15205 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15206 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15207 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15208 @cindex Secondary Stack Info
15209
15210 @noindent
15211 Provide the capability to query the high water mark of the current task's
15212 secondary stack.
15213
15214 @node GNAT.Semaphores (g-semaph.ads)
15215 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15216 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15217 @cindex Semaphores
15218
15219 @noindent
15220 Provides classic counting and binary semaphores using protected types.
15221
15222 @node GNAT.Serial_Communications (g-sercom.ads)
15223 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15224 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15225 @cindex Serial_Communications
15226
15227 @noindent
15228 Provides a simple interface to send and receive data over a serial
15229 port. This is only supported on GNU/Linux and Windows.
15230
15231 @node GNAT.SHA1 (g-sha1.ads)
15232 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15233 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15234 @cindex Secure Hash Algorithm SHA-1
15235
15236 @noindent
15237 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15238 and RFC 3174.
15239
15240 @node GNAT.SHA224 (g-sha224.ads)
15241 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15242 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15243 @cindex Secure Hash Algorithm SHA-224
15244
15245 @noindent
15246 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15247
15248 @node GNAT.SHA256 (g-sha256.ads)
15249 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15250 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15251 @cindex Secure Hash Algorithm SHA-256
15252
15253 @noindent
15254 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15255
15256 @node GNAT.SHA384 (g-sha384.ads)
15257 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15258 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15259 @cindex Secure Hash Algorithm SHA-384
15260
15261 @noindent
15262 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15263
15264 @node GNAT.SHA512 (g-sha512.ads)
15265 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15266 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15267 @cindex Secure Hash Algorithm SHA-512
15268
15269 @noindent
15270 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15271
15272 @node GNAT.Signals (g-signal.ads)
15273 @section @code{GNAT.Signals} (@file{g-signal.ads})
15274 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15275 @cindex Signals
15276
15277 @noindent
15278 Provides the ability to manipulate the blocked status of signals on supported
15279 targets.
15280
15281 @node GNAT.Sockets (g-socket.ads)
15282 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15283 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15284 @cindex Sockets
15285
15286 @noindent
15287 A high level and portable interface to develop sockets based applications.
15288 This package is based on the sockets thin binding found in
15289 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15290 on all native GNAT ports except for OpenVMS@. It is not implemented
15291 for the LynxOS@ cross port.
15292
15293 @node GNAT.Source_Info (g-souinf.ads)
15294 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15295 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15296 @cindex Source Information
15297
15298 @noindent
15299 Provides subprograms that give access to source code information known at
15300 compile time, such as the current file name and line number.
15301
15302 @node GNAT.Spelling_Checker (g-speche.ads)
15303 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15304 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15305 @cindex Spell checking
15306
15307 @noindent
15308 Provides a function for determining whether one string is a plausible
15309 near misspelling of another string.
15310
15311 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15312 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15313 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15314 @cindex Spell checking
15315
15316 @noindent
15317 Provides a generic function that can be instantiated with a string type for
15318 determining whether one string is a plausible near misspelling of another
15319 string.
15320
15321 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15322 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15323 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15324 @cindex SPITBOL pattern matching
15325 @cindex Pattern matching
15326
15327 @noindent
15328 A complete implementation of SNOBOL4 style pattern matching. This is the
15329 most elaborate of the pattern matching packages provided. It fully duplicates
15330 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15331 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15332
15333 @node GNAT.Spitbol (g-spitbo.ads)
15334 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15335 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15336 @cindex SPITBOL interface
15337
15338 @noindent
15339 The top level package of the collection of SPITBOL-style functionality, this
15340 package provides basic SNOBOL4 string manipulation functions, such as
15341 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15342 useful for constructing arbitrary mappings from strings in the style of
15343 the SNOBOL4 TABLE function.
15344
15345 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15346 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15347 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15348 @cindex Sets of strings
15349 @cindex SPITBOL Tables
15350
15351 @noindent
15352 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15353 for type @code{Standard.Boolean}, giving an implementation of sets of
15354 string values.
15355
15356 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15357 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15358 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15359 @cindex Integer maps
15360 @cindex Maps
15361 @cindex SPITBOL Tables
15362
15363 @noindent
15364 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15365 for type @code{Standard.Integer}, giving an implementation of maps
15366 from string to integer values.
15367
15368 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15369 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15370 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15371 @cindex String maps
15372 @cindex Maps
15373 @cindex SPITBOL Tables
15374
15375 @noindent
15376 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15377 a variable length string type, giving an implementation of general
15378 maps from strings to strings.
15379
15380 @node GNAT.SSE (g-sse.ads)
15381 @section @code{GNAT.SSE} (@file{g-sse.ads})
15382 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15383
15384 @noindent
15385 Root of a set of units aimed at offering Ada bindings to a subset of
15386 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15387 targets. It exposes vector component types together with a general
15388 introduction to the binding contents and use.
15389
15390 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15391 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15392 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15393
15394 @noindent
15395 SSE vector types for use with SSE related intrinsics.
15396
15397 @node GNAT.Strings (g-string.ads)
15398 @section @code{GNAT.Strings} (@file{g-string.ads})
15399 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15400
15401 @noindent
15402 Common String access types and related subprograms. Basically it
15403 defines a string access and an array of string access types.
15404
15405 @node GNAT.String_Split (g-strspl.ads)
15406 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15407 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15408 @cindex String splitter
15409
15410 @noindent
15411 Useful string manipulation routines: given a set of separators, split
15412 a string wherever the separators appear, and provide direct access
15413 to the resulting slices. This package is instantiated from
15414 @code{GNAT.Array_Split}.
15415
15416 @node GNAT.Table (g-table.ads)
15417 @section @code{GNAT.Table} (@file{g-table.ads})
15418 @cindex @code{GNAT.Table} (@file{g-table.ads})
15419 @cindex Table implementation
15420 @cindex Arrays, extendable
15421
15422 @noindent
15423 A generic package providing a single dimension array abstraction where the
15424 length of the array can be dynamically modified.
15425
15426 @noindent
15427 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15428 except that this package declares a single instance of the table type,
15429 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15430 used to define dynamic instances of the table.
15431
15432 @node GNAT.Task_Lock (g-tasloc.ads)
15433 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15434 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15435 @cindex Task synchronization
15436 @cindex Task locking
15437 @cindex Locking
15438
15439 @noindent
15440 A very simple facility for locking and unlocking sections of code using a
15441 single global task lock. Appropriate for use in situations where contention
15442 between tasks is very rarely expected.
15443
15444 @node GNAT.Time_Stamp (g-timsta.ads)
15445 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15446 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15447 @cindex Time stamp
15448 @cindex Current time
15449
15450 @noindent
15451 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15452 represents the current date and time in ISO 8601 format. This is a very simple
15453 routine with minimal code and there are no dependencies on any other unit.
15454
15455 @node GNAT.Threads (g-thread.ads)
15456 @section @code{GNAT.Threads} (@file{g-thread.ads})
15457 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15458 @cindex Foreign threads
15459 @cindex Threads, foreign
15460
15461 @noindent
15462 Provides facilities for dealing with foreign threads which need to be known
15463 by the GNAT run-time system. Consult the documentation of this package for
15464 further details if your program has threads that are created by a non-Ada
15465 environment which then accesses Ada code.
15466
15467 @node GNAT.Traceback (g-traceb.ads)
15468 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15469 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15470 @cindex Trace back facilities
15471
15472 @noindent
15473 Provides a facility for obtaining non-symbolic traceback information, useful
15474 in various debugging situations.
15475
15476 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15477 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15478 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15479 @cindex Trace back facilities
15480
15481 @node GNAT.UTF_32 (g-utf_32.ads)
15482 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15483 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15484 @cindex Wide character codes
15485
15486 @noindent
15487 This is a package intended to be used in conjunction with the
15488 @code{Wide_Character} type in Ada 95 and the
15489 @code{Wide_Wide_Character} type in Ada 2005 (available
15490 in @code{GNAT} in Ada 2005 mode). This package contains
15491 Unicode categorization routines, as well as lexical
15492 categorization routines corresponding to the Ada 2005
15493 lexical rules for identifiers and strings, and also a
15494 lower case to upper case fold routine corresponding to
15495 the Ada 2005 rules for identifier equivalence.
15496
15497 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15498 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15499 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15500 @cindex Spell checking
15501
15502 @noindent
15503 Provides a function for determining whether one wide wide string is a plausible
15504 near misspelling of another wide wide string, where the strings are represented
15505 using the UTF_32_String type defined in System.Wch_Cnv.
15506
15507 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15508 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15509 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15510 @cindex Spell checking
15511
15512 @noindent
15513 Provides a function for determining whether one wide string is a plausible
15514 near misspelling of another wide string.
15515
15516 @node GNAT.Wide_String_Split (g-wistsp.ads)
15517 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15518 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15519 @cindex Wide_String splitter
15520
15521 @noindent
15522 Useful wide string manipulation routines: given a set of separators, split
15523 a wide string wherever the separators appear, and provide direct access
15524 to the resulting slices. This package is instantiated from
15525 @code{GNAT.Array_Split}.
15526
15527 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15528 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15529 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15530 @cindex Spell checking
15531
15532 @noindent
15533 Provides a function for determining whether one wide wide string is a plausible
15534 near misspelling of another wide wide string.
15535
15536 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15537 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15538 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15539 @cindex Wide_Wide_String splitter
15540
15541 @noindent
15542 Useful wide wide string manipulation routines: given a set of separators, split
15543 a wide wide string wherever the separators appear, and provide direct access
15544 to the resulting slices. This package is instantiated from
15545 @code{GNAT.Array_Split}.
15546
15547 @node Interfaces.C.Extensions (i-cexten.ads)
15548 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15549 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15550
15551 @noindent
15552 This package contains additional C-related definitions, intended
15553 for use with either manually or automatically generated bindings
15554 to C libraries.
15555
15556 @node Interfaces.C.Streams (i-cstrea.ads)
15557 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15558 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15559 @cindex C streams, interfacing
15560
15561 @noindent
15562 This package is a binding for the most commonly used operations
15563 on C streams.
15564
15565 @node Interfaces.CPP (i-cpp.ads)
15566 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15567 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15568 @cindex C++ interfacing
15569 @cindex Interfacing, to C++
15570
15571 @noindent
15572 This package provides facilities for use in interfacing to C++. It
15573 is primarily intended to be used in connection with automated tools
15574 for the generation of C++ interfaces.
15575
15576 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15577 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15578 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15579 @cindex IBM Packed Format
15580 @cindex Packed Decimal
15581
15582 @noindent
15583 This package provides a set of routines for conversions to and
15584 from a packed decimal format compatible with that used on IBM
15585 mainframes.
15586
15587 @node Interfaces.VxWorks (i-vxwork.ads)
15588 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15589 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15590 @cindex Interfacing to VxWorks
15591 @cindex VxWorks, interfacing
15592
15593 @noindent
15594 This package provides a limited binding to the VxWorks API.
15595 In particular, it interfaces with the
15596 VxWorks hardware interrupt facilities.
15597
15598 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15599 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15600 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15601 @cindex Interfacing to VxWorks' I/O
15602 @cindex VxWorks, I/O interfacing
15603 @cindex VxWorks, Get_Immediate
15604 @cindex Get_Immediate, VxWorks
15605
15606 @noindent
15607 This package provides a binding to the ioctl (IO/Control)
15608 function of VxWorks, defining a set of option values and
15609 function codes. A particular use of this package is
15610 to enable the use of Get_Immediate under VxWorks.
15611
15612 @node System.Address_Image (s-addima.ads)
15613 @section @code{System.Address_Image} (@file{s-addima.ads})
15614 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15615 @cindex Address image
15616 @cindex Image, of an address
15617
15618 @noindent
15619 This function provides a useful debugging
15620 function that gives an (implementation dependent)
15621 string which identifies an address.
15622
15623 @node System.Assertions (s-assert.ads)
15624 @section @code{System.Assertions} (@file{s-assert.ads})
15625 @cindex @code{System.Assertions} (@file{s-assert.ads})
15626 @cindex Assertions
15627 @cindex Assert_Failure, exception
15628
15629 @noindent
15630 This package provides the declaration of the exception raised
15631 by an run-time assertion failure, as well as the routine that
15632 is used internally to raise this assertion.
15633
15634 @node System.Memory (s-memory.ads)
15635 @section @code{System.Memory} (@file{s-memory.ads})
15636 @cindex @code{System.Memory} (@file{s-memory.ads})
15637 @cindex Memory allocation
15638
15639 @noindent
15640 This package provides the interface to the low level routines used
15641 by the generated code for allocation and freeing storage for the
15642 default storage pool (analogous to the C routines malloc and free.
15643 It also provides a reallocation interface analogous to the C routine
15644 realloc. The body of this unit may be modified to provide alternative
15645 allocation mechanisms for the default pool, and in addition, direct
15646 calls to this unit may be made for low level allocation uses (for
15647 example see the body of @code{GNAT.Tables}).
15648
15649 @node System.Partition_Interface (s-parint.ads)
15650 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15651 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15652 @cindex Partition interfacing functions
15653
15654 @noindent
15655 This package provides facilities for partition interfacing. It
15656 is used primarily in a distribution context when using Annex E
15657 with @code{GLADE}.
15658
15659 @node System.Pool_Global (s-pooglo.ads)
15660 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15661 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15662 @cindex Storage pool, global
15663 @cindex Global storage pool
15664
15665 @noindent
15666 This package provides a storage pool that is equivalent to the default
15667 storage pool used for access types for which no pool is specifically
15668 declared. It uses malloc/free to allocate/free and does not attempt to
15669 do any automatic reclamation.
15670
15671 @node System.Pool_Local (s-pooloc.ads)
15672 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15673 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15674 @cindex Storage pool, local
15675 @cindex Local storage pool
15676
15677 @noindent
15678 This package provides a storage pool that is intended for use with locally
15679 defined access types. It uses malloc/free for allocate/free, and maintains
15680 a list of allocated blocks, so that all storage allocated for the pool can
15681 be freed automatically when the pool is finalized.
15682
15683 @node System.Restrictions (s-restri.ads)
15684 @section @code{System.Restrictions} (@file{s-restri.ads})
15685 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15686 @cindex Run-time restrictions access
15687
15688 @noindent
15689 This package provides facilities for accessing at run time
15690 the status of restrictions specified at compile time for
15691 the partition. Information is available both with regard
15692 to actual restrictions specified, and with regard to
15693 compiler determined information on which restrictions
15694 are violated by one or more packages in the partition.
15695
15696 @node System.Rident (s-rident.ads)
15697 @section @code{System.Rident} (@file{s-rident.ads})
15698 @cindex @code{System.Rident} (@file{s-rident.ads})
15699 @cindex Restrictions definitions
15700
15701 @noindent
15702 This package provides definitions of the restrictions
15703 identifiers supported by GNAT, and also the format of
15704 the restrictions provided in package System.Restrictions.
15705 It is not normally necessary to @code{with} this generic package
15706 since the necessary instantiation is included in
15707 package System.Restrictions.
15708
15709 @node System.Strings.Stream_Ops (s-ststop.ads)
15710 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15711 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15712 @cindex Stream operations
15713 @cindex String stream operations
15714
15715 @noindent
15716 This package provides a set of stream subprograms for standard string types.
15717 It is intended primarily to support implicit use of such subprograms when
15718 stream attributes are applied to string types, but the subprograms in this
15719 package can be used directly by application programs.
15720
15721 @node System.Task_Info (s-tasinf.ads)
15722 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15723 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15724 @cindex Task_Info pragma
15725
15726 @noindent
15727 This package provides target dependent functionality that is used
15728 to support the @code{Task_Info} pragma
15729
15730 @node System.Wch_Cnv (s-wchcnv.ads)
15731 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15732 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15733 @cindex Wide Character, Representation
15734 @cindex Wide String, Conversion
15735 @cindex Representation of wide characters
15736
15737 @noindent
15738 This package provides routines for converting between
15739 wide and wide wide characters and a representation as a value of type
15740 @code{Standard.String}, using a specified wide character
15741 encoding method. It uses definitions in
15742 package @code{System.Wch_Con}.
15743
15744 @node System.Wch_Con (s-wchcon.ads)
15745 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15746 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15747
15748 @noindent
15749 This package provides definitions and descriptions of
15750 the various methods used for encoding wide characters
15751 in ordinary strings. These definitions are used by
15752 the package @code{System.Wch_Cnv}.
15753
15754 @node Interfacing to Other Languages
15755 @chapter Interfacing to Other Languages
15756 @noindent
15757 The facilities in annex B of the Ada Reference Manual are fully
15758 implemented in GNAT, and in addition, a full interface to C++ is
15759 provided.
15760
15761 @menu
15762 * Interfacing to C::
15763 * Interfacing to C++::
15764 * Interfacing to COBOL::
15765 * Interfacing to Fortran::
15766 * Interfacing to non-GNAT Ada code::
15767 @end menu
15768
15769 @node Interfacing to C
15770 @section Interfacing to C
15771
15772 @noindent
15773 Interfacing to C with GNAT can use one of two approaches:
15774
15775 @itemize @bullet
15776 @item
15777 The types in the package @code{Interfaces.C} may be used.
15778 @item
15779 Standard Ada types may be used directly. This may be less portable to
15780 other compilers, but will work on all GNAT compilers, which guarantee
15781 correspondence between the C and Ada types.
15782 @end itemize
15783
15784 @noindent
15785 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15786 effect, since this is the default. The following table shows the
15787 correspondence between Ada scalar types and the corresponding C types.
15788
15789 @table @code
15790 @item Integer
15791 @code{int}
15792 @item Short_Integer
15793 @code{short}
15794 @item Short_Short_Integer
15795 @code{signed char}
15796 @item Long_Integer
15797 @code{long}
15798 @item Long_Long_Integer
15799 @code{long long}
15800 @item Short_Float
15801 @code{float}
15802 @item Float
15803 @code{float}
15804 @item Long_Float
15805 @code{double}
15806 @item Long_Long_Float
15807 This is the longest floating-point type supported by the hardware.
15808 @end table
15809
15810 @noindent
15811 Additionally, there are the following general correspondences between Ada
15812 and C types:
15813 @itemize @bullet
15814 @item
15815 Ada enumeration types map to C enumeration types directly if pragma
15816 @code{Convention C} is specified, which causes them to have int
15817 length. Without pragma @code{Convention C}, Ada enumeration types map to
15818 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15819 @code{int}, respectively) depending on the number of values passed.
15820 This is the only case in which pragma @code{Convention C} affects the
15821 representation of an Ada type.
15822
15823 @item
15824 Ada access types map to C pointers, except for the case of pointers to
15825 unconstrained types in Ada, which have no direct C equivalent.
15826
15827 @item
15828 Ada arrays map directly to C arrays.
15829
15830 @item
15831 Ada records map directly to C structures.
15832
15833 @item
15834 Packed Ada records map to C structures where all members are bit fields
15835 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15836 @end itemize
15837
15838 @node Interfacing to C++
15839 @section Interfacing to C++
15840
15841 @noindent
15842 The interface to C++ makes use of the following pragmas, which are
15843 primarily intended to be constructed automatically using a binding generator
15844 tool, although it is possible to construct them by hand. No suitable binding
15845 generator tool is supplied with GNAT though.
15846
15847 Using these pragmas it is possible to achieve complete
15848 inter-operability between Ada tagged types and C++ class definitions.
15849 See @ref{Implementation Defined Pragmas}, for more details.
15850
15851 @table @code
15852 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15853 The argument denotes an entity in the current declarative region that is
15854 declared as a tagged or untagged record type. It indicates that the type
15855 corresponds to an externally declared C++ class type, and is to be laid
15856 out the same way that C++ would lay out the type.
15857
15858 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15859 for backward compatibility but its functionality is available
15860 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15861
15862 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15863 This pragma identifies an imported function (imported in the usual way
15864 with pragma @code{Import}) as corresponding to a C++ constructor.
15865 @end table
15866
15867 @node Interfacing to COBOL
15868 @section Interfacing to COBOL
15869
15870 @noindent
15871 Interfacing to COBOL is achieved as described in section B.4 of
15872 the Ada Reference Manual.
15873
15874 @node Interfacing to Fortran
15875 @section Interfacing to Fortran
15876
15877 @noindent
15878 Interfacing to Fortran is achieved as described in section B.5 of the
15879 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15880 multi-dimensional array causes the array to be stored in column-major
15881 order as required for convenient interface to Fortran.
15882
15883 @node Interfacing to non-GNAT Ada code
15884 @section Interfacing to non-GNAT Ada code
15885
15886 It is possible to specify the convention @code{Ada} in a pragma
15887 @code{Import} or pragma @code{Export}. However this refers to
15888 the calling conventions used by GNAT, which may or may not be
15889 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15890 compiler to allow interoperation.
15891
15892 If arguments types are kept simple, and if the foreign compiler generally
15893 follows system calling conventions, then it may be possible to integrate
15894 files compiled by other Ada compilers, provided that the elaboration
15895 issues are adequately addressed (for example by eliminating the
15896 need for any load time elaboration).
15897
15898 In particular, GNAT running on VMS is designed to
15899 be highly compatible with the DEC Ada 83 compiler, so this is one
15900 case in which it is possible to import foreign units of this type,
15901 provided that the data items passed are restricted to simple scalar
15902 values or simple record types without variants, or simple array
15903 types with fixed bounds.
15904
15905 @node Specialized Needs Annexes
15906 @chapter Specialized Needs Annexes
15907
15908 @noindent
15909 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15910 required in all implementations. However, as described in this chapter,
15911 GNAT implements all of these annexes:
15912
15913 @table @asis
15914 @item Systems Programming (Annex C)
15915 The Systems Programming Annex is fully implemented.
15916
15917 @item Real-Time Systems (Annex D)
15918 The Real-Time Systems Annex is fully implemented.
15919
15920 @item Distributed Systems (Annex E)
15921 Stub generation is fully implemented in the GNAT compiler. In addition,
15922 a complete compatible PCS is available as part of the GLADE system,
15923 a separate product. When the two
15924 products are used in conjunction, this annex is fully implemented.
15925
15926 @item Information Systems (Annex F)
15927 The Information Systems annex is fully implemented.
15928
15929 @item Numerics (Annex G)
15930 The Numerics Annex is fully implemented.
15931
15932 @item Safety and Security / High-Integrity Systems (Annex H)
15933 The Safety and Security Annex (termed the High-Integrity Systems Annex
15934 in Ada 2005) is fully implemented.
15935 @end table
15936
15937 @node Implementation of Specific Ada Features
15938 @chapter Implementation of Specific Ada Features
15939
15940 @noindent
15941 This chapter describes the GNAT implementation of several Ada language
15942 facilities.
15943
15944 @menu
15945 * Machine Code Insertions::
15946 * GNAT Implementation of Tasking::
15947 * GNAT Implementation of Shared Passive Packages::
15948 * Code Generation for Array Aggregates::
15949 * The Size of Discriminated Records with Default Discriminants::
15950 * Strict Conformance to the Ada Reference Manual::
15951 @end menu
15952
15953 @node Machine Code Insertions
15954 @section Machine Code Insertions
15955 @cindex Machine Code insertions
15956
15957 @noindent
15958 Package @code{Machine_Code} provides machine code support as described
15959 in the Ada Reference Manual in two separate forms:
15960 @itemize @bullet
15961 @item
15962 Machine code statements, consisting of qualified expressions that
15963 fit the requirements of RM section 13.8.
15964 @item
15965 An intrinsic callable procedure, providing an alternative mechanism of
15966 including machine instructions in a subprogram.
15967 @end itemize
15968
15969 @noindent
15970 The two features are similar, and both are closely related to the mechanism
15971 provided by the asm instruction in the GNU C compiler. Full understanding
15972 and use of the facilities in this package requires understanding the asm
15973 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15974 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15975
15976 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15977 semantic restrictions and effects as described below. Both are provided so
15978 that the procedure call can be used as a statement, and the function call
15979 can be used to form a code_statement.
15980
15981 The first example given in the GCC documentation is the C @code{asm}
15982 instruction:
15983 @smallexample
15984 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15985 @end smallexample
15986
15987 @noindent
15988 The equivalent can be written for GNAT as:
15989
15990 @smallexample @c ada
15991 Asm ("fsinx %1 %0",
15992 My_Float'Asm_Output ("=f", result),
15993 My_Float'Asm_Input ("f", angle));
15994 @end smallexample
15995
15996 @noindent
15997 The first argument to @code{Asm} is the assembler template, and is
15998 identical to what is used in GNU C@. This string must be a static
15999 expression. The second argument is the output operand list. It is
16000 either a single @code{Asm_Output} attribute reference, or a list of such
16001 references enclosed in parentheses (technically an array aggregate of
16002 such references).
16003
16004 The @code{Asm_Output} attribute denotes a function that takes two
16005 parameters. The first is a string, the second is the name of a variable
16006 of the type designated by the attribute prefix. The first (string)
16007 argument is required to be a static expression and designates the
16008 constraint for the parameter (e.g.@: what kind of register is
16009 required). The second argument is the variable to be updated with the
16010 result. The possible values for constraint are the same as those used in
16011 the RTL, and are dependent on the configuration file used to build the
16012 GCC back end. If there are no output operands, then this argument may
16013 either be omitted, or explicitly given as @code{No_Output_Operands}.
16014
16015 The second argument of @code{@var{my_float}'Asm_Output} functions as
16016 though it were an @code{out} parameter, which is a little curious, but
16017 all names have the form of expressions, so there is no syntactic
16018 irregularity, even though normally functions would not be permitted
16019 @code{out} parameters. The third argument is the list of input
16020 operands. It is either a single @code{Asm_Input} attribute reference, or
16021 a list of such references enclosed in parentheses (technically an array
16022 aggregate of such references).
16023
16024 The @code{Asm_Input} attribute denotes a function that takes two
16025 parameters. The first is a string, the second is an expression of the
16026 type designated by the prefix. The first (string) argument is required
16027 to be a static expression, and is the constraint for the parameter,
16028 (e.g.@: what kind of register is required). The second argument is the
16029 value to be used as the input argument. The possible values for the
16030 constant are the same as those used in the RTL, and are dependent on
16031 the configuration file used to built the GCC back end.
16032
16033 If there are no input operands, this argument may either be omitted, or
16034 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16035 present in the above example, is a list of register names, called the
16036 @dfn{clobber} argument. This argument, if given, must be a static string
16037 expression, and is a space or comma separated list of names of registers
16038 that must be considered destroyed as a result of the @code{Asm} call. If
16039 this argument is the null string (the default value), then the code
16040 generator assumes that no additional registers are destroyed.
16041
16042 The fifth argument, not present in the above example, called the
16043 @dfn{volatile} argument, is by default @code{False}. It can be set to
16044 the literal value @code{True} to indicate to the code generator that all
16045 optimizations with respect to the instruction specified should be
16046 suppressed, and that in particular, for an instruction that has outputs,
16047 the instruction will still be generated, even if none of the outputs are
16048 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16049 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16050 Generally it is strongly advisable to use Volatile for any ASM statement
16051 that is missing either input or output operands, or when two or more ASM
16052 statements appear in sequence, to avoid unwanted optimizations. A warning
16053 is generated if this advice is not followed.
16054
16055 The @code{Asm} subprograms may be used in two ways. First the procedure
16056 forms can be used anywhere a procedure call would be valid, and
16057 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16058 be used to intersperse machine instructions with other Ada statements.
16059 Second, the function forms, which return a dummy value of the limited
16060 private type @code{Asm_Insn}, can be used in code statements, and indeed
16061 this is the only context where such calls are allowed. Code statements
16062 appear as aggregates of the form:
16063
16064 @smallexample @c ada
16065 Asm_Insn'(Asm (@dots{}));
16066 Asm_Insn'(Asm_Volatile (@dots{}));
16067 @end smallexample
16068
16069 @noindent
16070 In accordance with RM rules, such code statements are allowed only
16071 within subprograms whose entire body consists of such statements. It is
16072 not permissible to intermix such statements with other Ada statements.
16073
16074 Typically the form using intrinsic procedure calls is more convenient
16075 and more flexible. The code statement form is provided to meet the RM
16076 suggestion that such a facility should be made available. The following
16077 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16078 is used, the arguments may be given in arbitrary order, following the
16079 normal rules for use of positional and named arguments)
16080
16081 @smallexample
16082 ASM_CALL ::= Asm (
16083 [Template =>] static_string_EXPRESSION
16084 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16085 [,[Inputs =>] INPUT_OPERAND_LIST ]
16086 [,[Clobber =>] static_string_EXPRESSION ]
16087 [,[Volatile =>] static_boolean_EXPRESSION] )
16088
16089 OUTPUT_OPERAND_LIST ::=
16090 [PREFIX.]No_Output_Operands
16091 | OUTPUT_OPERAND_ATTRIBUTE
16092 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16093
16094 OUTPUT_OPERAND_ATTRIBUTE ::=
16095 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16096
16097 INPUT_OPERAND_LIST ::=
16098 [PREFIX.]No_Input_Operands
16099 | INPUT_OPERAND_ATTRIBUTE
16100 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16101
16102 INPUT_OPERAND_ATTRIBUTE ::=
16103 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16104 @end smallexample
16105
16106 @noindent
16107 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16108 are declared in the package @code{Machine_Code} and must be referenced
16109 according to normal visibility rules. In particular if there is no
16110 @code{use} clause for this package, then appropriate package name
16111 qualification is required.
16112
16113 @node GNAT Implementation of Tasking
16114 @section GNAT Implementation of Tasking
16115
16116 @noindent
16117 This chapter outlines the basic GNAT approach to tasking (in particular,
16118 a multi-layered library for portability) and discusses issues related
16119 to compliance with the Real-Time Systems Annex.
16120
16121 @menu
16122 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16123 * Ensuring Compliance with the Real-Time Annex::
16124 @end menu
16125
16126 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16127 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16128
16129 @noindent
16130 GNAT's run-time support comprises two layers:
16131
16132 @itemize @bullet
16133 @item GNARL (GNAT Run-time Layer)
16134 @item GNULL (GNAT Low-level Library)
16135 @end itemize
16136
16137 @noindent
16138 In GNAT, Ada's tasking services rely on a platform and OS independent
16139 layer known as GNARL@. This code is responsible for implementing the
16140 correct semantics of Ada's task creation, rendezvous, protected
16141 operations etc.
16142
16143 GNARL decomposes Ada's tasking semantics into simpler lower level
16144 operations such as create a thread, set the priority of a thread,
16145 yield, create a lock, lock/unlock, etc. The spec for these low-level
16146 operations constitutes GNULLI, the GNULL Interface. This interface is
16147 directly inspired from the POSIX real-time API@.
16148
16149 If the underlying executive or OS implements the POSIX standard
16150 faithfully, the GNULL Interface maps as is to the services offered by
16151 the underlying kernel. Otherwise, some target dependent glue code maps
16152 the services offered by the underlying kernel to the semantics expected
16153 by GNARL@.
16154
16155 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16156 key point is that each Ada task is mapped on a thread in the underlying
16157 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16158
16159 In addition Ada task priorities map onto the underlying thread priorities.
16160 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16161
16162 @itemize @bullet
16163 @item
16164 The underlying scheduler is used to schedule the Ada tasks. This
16165 makes Ada tasks as efficient as kernel threads from a scheduling
16166 standpoint.
16167
16168 @item
16169 Interaction with code written in C containing threads is eased
16170 since at the lowest level Ada tasks and C threads map onto the same
16171 underlying kernel concept.
16172
16173 @item
16174 When an Ada task is blocked during I/O the remaining Ada tasks are
16175 able to proceed.
16176
16177 @item
16178 On multiprocessor systems Ada tasks can execute in parallel.
16179 @end itemize
16180
16181 @noindent
16182 Some threads libraries offer a mechanism to fork a new process, with the
16183 child process duplicating the threads from the parent.
16184 GNAT does not
16185 support this functionality when the parent contains more than one task.
16186 @cindex Forking a new process
16187
16188 @node Ensuring Compliance with the Real-Time Annex
16189 @subsection Ensuring Compliance with the Real-Time Annex
16190 @cindex Real-Time Systems Annex compliance
16191
16192 @noindent
16193 Although mapping Ada tasks onto
16194 the underlying threads has significant advantages, it does create some
16195 complications when it comes to respecting the scheduling semantics
16196 specified in the real-time annex (Annex D).
16197
16198 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16199 scheduling policy states:
16200
16201 @quotation
16202 @emph{When the active priority of a ready task that is not running
16203 changes, or the setting of its base priority takes effect, the
16204 task is removed from the ready queue for its old active priority
16205 and is added at the tail of the ready queue for its new active
16206 priority, except in the case where the active priority is lowered
16207 due to the loss of inherited priority, in which case the task is
16208 added at the head of the ready queue for its new active priority.}
16209 @end quotation
16210
16211 @noindent
16212 While most kernels do put tasks at the end of the priority queue when
16213 a task changes its priority, (which respects the main
16214 FIFO_Within_Priorities requirement), almost none keep a thread at the
16215 beginning of its priority queue when its priority drops from the loss
16216 of inherited priority.
16217
16218 As a result most vendors have provided incomplete Annex D implementations.
16219
16220 The GNAT run-time, has a nice cooperative solution to this problem
16221 which ensures that accurate FIFO_Within_Priorities semantics are
16222 respected.
16223
16224 The principle is as follows. When an Ada task T is about to start
16225 running, it checks whether some other Ada task R with the same
16226 priority as T has been suspended due to the loss of priority
16227 inheritance. If this is the case, T yields and is placed at the end of
16228 its priority queue. When R arrives at the front of the queue it
16229 executes.
16230
16231 Note that this simple scheme preserves the relative order of the tasks
16232 that were ready to execute in the priority queue where R has been
16233 placed at the end.
16234
16235 @node GNAT Implementation of Shared Passive Packages
16236 @section GNAT Implementation of Shared Passive Packages
16237 @cindex Shared passive packages
16238
16239 @noindent
16240 GNAT fully implements the pragma @code{Shared_Passive} for
16241 @cindex pragma @code{Shared_Passive}
16242 the purpose of designating shared passive packages.
16243 This allows the use of passive partitions in the
16244 context described in the Ada Reference Manual; i.e., for communication
16245 between separate partitions of a distributed application using the
16246 features in Annex E.
16247 @cindex Annex E
16248 @cindex Distribution Systems Annex
16249
16250 However, the implementation approach used by GNAT provides for more
16251 extensive usage as follows:
16252
16253 @table @emph
16254 @item Communication between separate programs
16255
16256 This allows separate programs to access the data in passive
16257 partitions, using protected objects for synchronization where
16258 needed. The only requirement is that the two programs have a
16259 common shared file system. It is even possible for programs
16260 running on different machines with different architectures
16261 (e.g.@: different endianness) to communicate via the data in
16262 a passive partition.
16263
16264 @item Persistence between program runs
16265
16266 The data in a passive package can persist from one run of a
16267 program to another, so that a later program sees the final
16268 values stored by a previous run of the same program.
16269
16270 @end table
16271
16272 @noindent
16273 The implementation approach used is to store the data in files. A
16274 separate stream file is created for each object in the package, and
16275 an access to an object causes the corresponding file to be read or
16276 written.
16277
16278 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16279 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16280 set to the directory to be used for these files.
16281 The files in this directory
16282 have names that correspond to their fully qualified names. For
16283 example, if we have the package
16284
16285 @smallexample @c ada
16286 package X is
16287 pragma Shared_Passive (X);
16288 Y : Integer;
16289 Z : Float;
16290 end X;
16291 @end smallexample
16292
16293 @noindent
16294 and the environment variable is set to @code{/stemp/}, then the files created
16295 will have the names:
16296
16297 @smallexample
16298 /stemp/x.y
16299 /stemp/x.z
16300 @end smallexample
16301
16302 @noindent
16303 These files are created when a value is initially written to the object, and
16304 the files are retained until manually deleted. This provides the persistence
16305 semantics. If no file exists, it means that no partition has assigned a value
16306 to the variable; in this case the initial value declared in the package
16307 will be used. This model ensures that there are no issues in synchronizing
16308 the elaboration process, since elaboration of passive packages elaborates the
16309 initial values, but does not create the files.
16310
16311 The files are written using normal @code{Stream_IO} access.
16312 If you want to be able
16313 to communicate between programs or partitions running on different
16314 architectures, then you should use the XDR versions of the stream attribute
16315 routines, since these are architecture independent.
16316
16317 If active synchronization is required for access to the variables in the
16318 shared passive package, then as described in the Ada Reference Manual, the
16319 package may contain protected objects used for this purpose. In this case
16320 a lock file (whose name is @file{___lock} (three underscores)
16321 is created in the shared memory directory.
16322 @cindex @file{___lock} file (for shared passive packages)
16323 This is used to provide the required locking
16324 semantics for proper protected object synchronization.
16325
16326 As of January 2003, GNAT supports shared passive packages on all platforms
16327 except for OpenVMS.
16328
16329 @node Code Generation for Array Aggregates
16330 @section Code Generation for Array Aggregates
16331
16332 @menu
16333 * Static constant aggregates with static bounds::
16334 * Constant aggregates with unconstrained nominal types::
16335 * Aggregates with static bounds::
16336 * Aggregates with non-static bounds::
16337 * Aggregates in assignment statements::
16338 @end menu
16339
16340 @noindent
16341 Aggregates have a rich syntax and allow the user to specify the values of
16342 complex data structures by means of a single construct. As a result, the
16343 code generated for aggregates can be quite complex and involve loops, case
16344 statements and multiple assignments. In the simplest cases, however, the
16345 compiler will recognize aggregates whose components and constraints are
16346 fully static, and in those cases the compiler will generate little or no
16347 executable code. The following is an outline of the code that GNAT generates
16348 for various aggregate constructs. For further details, you will find it
16349 useful to examine the output produced by the -gnatG flag to see the expanded
16350 source that is input to the code generator. You may also want to examine
16351 the assembly code generated at various levels of optimization.
16352
16353 The code generated for aggregates depends on the context, the component values,
16354 and the type. In the context of an object declaration the code generated is
16355 generally simpler than in the case of an assignment. As a general rule, static
16356 component values and static subtypes also lead to simpler code.
16357
16358 @node Static constant aggregates with static bounds
16359 @subsection Static constant aggregates with static bounds
16360
16361 @noindent
16362 For the declarations:
16363 @smallexample @c ada
16364 type One_Dim is array (1..10) of integer;
16365 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16366 @end smallexample
16367
16368 @noindent
16369 GNAT generates no executable code: the constant ar0 is placed in static memory.
16370 The same is true for constant aggregates with named associations:
16371
16372 @smallexample @c ada
16373 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16374 Cr3 : constant One_Dim := (others => 7777);
16375 @end smallexample
16376
16377 @noindent
16378 The same is true for multidimensional constant arrays such as:
16379
16380 @smallexample @c ada
16381 type two_dim is array (1..3, 1..3) of integer;
16382 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16383 @end smallexample
16384
16385 @noindent
16386 The same is true for arrays of one-dimensional arrays: the following are
16387 static:
16388
16389 @smallexample @c ada
16390 type ar1b is array (1..3) of boolean;
16391 type ar_ar is array (1..3) of ar1b;
16392 None : constant ar1b := (others => false); -- fully static
16393 None2 : constant ar_ar := (1..3 => None); -- fully static
16394 @end smallexample
16395
16396 @noindent
16397 However, for multidimensional aggregates with named associations, GNAT will
16398 generate assignments and loops, even if all associations are static. The
16399 following two declarations generate a loop for the first dimension, and
16400 individual component assignments for the second dimension:
16401
16402 @smallexample @c ada
16403 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16404 Zero2: constant two_dim := (others => (others => 0));
16405 @end smallexample
16406
16407 @node Constant aggregates with unconstrained nominal types
16408 @subsection Constant aggregates with unconstrained nominal types
16409
16410 @noindent
16411 In such cases the aggregate itself establishes the subtype, so that
16412 associations with @code{others} cannot be used. GNAT determines the
16413 bounds for the actual subtype of the aggregate, and allocates the
16414 aggregate statically as well. No code is generated for the following:
16415
16416 @smallexample @c ada
16417 type One_Unc is array (natural range <>) of integer;
16418 Cr_Unc : constant One_Unc := (12,24,36);
16419 @end smallexample
16420
16421 @node Aggregates with static bounds
16422 @subsection Aggregates with static bounds
16423
16424 @noindent
16425 In all previous examples the aggregate was the initial (and immutable) value
16426 of a constant. If the aggregate initializes a variable, then code is generated
16427 for it as a combination of individual assignments and loops over the target
16428 object. The declarations
16429
16430 @smallexample @c ada
16431 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16432 Cr_Var2 : One_Dim := (others > -1);
16433 @end smallexample
16434
16435 @noindent
16436 generate the equivalent of
16437
16438 @smallexample @c ada
16439 Cr_Var1 (1) := 2;
16440 Cr_Var1 (2) := 3;
16441 Cr_Var1 (3) := 5;
16442 Cr_Var1 (4) := 11;
16443
16444 for I in Cr_Var2'range loop
16445 Cr_Var2 (I) := -1;
16446 end loop;
16447 @end smallexample
16448
16449 @node Aggregates with non-static bounds
16450 @subsection Aggregates with non-static bounds
16451
16452 @noindent
16453 If the bounds of the aggregate are not statically compatible with the bounds
16454 of the nominal subtype of the target, then constraint checks have to be
16455 generated on the bounds. For a multidimensional array, constraint checks may
16456 have to be applied to sub-arrays individually, if they do not have statically
16457 compatible subtypes.
16458
16459 @node Aggregates in assignment statements
16460 @subsection Aggregates in assignment statements
16461
16462 @noindent
16463 In general, aggregate assignment requires the construction of a temporary,
16464 and a copy from the temporary to the target of the assignment. This is because
16465 it is not always possible to convert the assignment into a series of individual
16466 component assignments. For example, consider the simple case:
16467
16468 @smallexample @c ada
16469 A := (A(2), A(1));
16470 @end smallexample
16471
16472 @noindent
16473 This cannot be converted into:
16474
16475 @smallexample @c ada
16476 A(1) := A(2);
16477 A(2) := A(1);
16478 @end smallexample
16479
16480 @noindent
16481 So the aggregate has to be built first in a separate location, and then
16482 copied into the target. GNAT recognizes simple cases where this intermediate
16483 step is not required, and the assignments can be performed in place, directly
16484 into the target. The following sufficient criteria are applied:
16485
16486 @itemize @bullet
16487 @item
16488 The bounds of the aggregate are static, and the associations are static.
16489 @item
16490 The components of the aggregate are static constants, names of
16491 simple variables that are not renamings, or expressions not involving
16492 indexed components whose operands obey these rules.
16493 @end itemize
16494
16495 @noindent
16496 If any of these conditions are violated, the aggregate will be built in
16497 a temporary (created either by the front-end or the code generator) and then
16498 that temporary will be copied onto the target.
16499
16500 @node The Size of Discriminated Records with Default Discriminants
16501 @section The Size of Discriminated Records with Default Discriminants
16502
16503 @noindent
16504 If a discriminated type @code{T} has discriminants with default values, it is
16505 possible to declare an object of this type without providing an explicit
16506 constraint:
16507
16508 @smallexample @c ada
16509 @group
16510 type Size is range 1..100;
16511
16512 type Rec (D : Size := 15) is record
16513 Name : String (1..D);
16514 end T;
16515
16516 Word : Rec;
16517 @end group
16518 @end smallexample
16519
16520 @noindent
16521 Such an object is said to be @emph{unconstrained}.
16522 The discriminant of the object
16523 can be modified by a full assignment to the object, as long as it preserves the
16524 relation between the value of the discriminant, and the value of the components
16525 that depend on it:
16526
16527 @smallexample @c ada
16528 @group
16529 Word := (3, "yes");
16530
16531 Word := (5, "maybe");
16532
16533 Word := (5, "no"); -- raises Constraint_Error
16534 @end group
16535 @end smallexample
16536
16537 @noindent
16538 In order to support this behavior efficiently, an unconstrained object is
16539 given the maximum size that any value of the type requires. In the case
16540 above, @code{Word} has storage for the discriminant and for
16541 a @code{String} of length 100.
16542 It is important to note that unconstrained objects do not require dynamic
16543 allocation. It would be an improper implementation to place on the heap those
16544 components whose size depends on discriminants. (This improper implementation
16545 was used by some Ada83 compilers, where the @code{Name} component above
16546 would have
16547 been stored as a pointer to a dynamic string). Following the principle that
16548 dynamic storage management should never be introduced implicitly,
16549 an Ada compiler should reserve the full size for an unconstrained declared
16550 object, and place it on the stack.
16551
16552 This maximum size approach
16553 has been a source of surprise to some users, who expect the default
16554 values of the discriminants to determine the size reserved for an
16555 unconstrained object: ``If the default is 15, why should the object occupy
16556 a larger size?''
16557 The answer, of course, is that the discriminant may be later modified,
16558 and its full range of values must be taken into account. This is why the
16559 declaration:
16560
16561 @smallexample
16562 @group
16563 type Rec (D : Positive := 15) is record
16564 Name : String (1..D);
16565 end record;
16566
16567 Too_Large : Rec;
16568 @end group
16569 @end smallexample
16570
16571 @noindent
16572 is flagged by the compiler with a warning:
16573 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16574 because the required size includes @code{Positive'Last}
16575 bytes. As the first example indicates, the proper approach is to declare an
16576 index type of ``reasonable'' range so that unconstrained objects are not too
16577 large.
16578
16579 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16580 created in the heap by means of an allocator, then it is @emph{not}
16581 unconstrained:
16582 it is constrained by the default values of the discriminants, and those values
16583 cannot be modified by full assignment. This is because in the presence of
16584 aliasing all views of the object (which may be manipulated by different tasks,
16585 say) must be consistent, so it is imperative that the object, once created,
16586 remain invariant.
16587
16588 @node Strict Conformance to the Ada Reference Manual
16589 @section Strict Conformance to the Ada Reference Manual
16590
16591 @noindent
16592 The dynamic semantics defined by the Ada Reference Manual impose a set of
16593 run-time checks to be generated. By default, the GNAT compiler will insert many
16594 run-time checks into the compiled code, including most of those required by the
16595 Ada Reference Manual. However, there are three checks that are not enabled
16596 in the default mode for efficiency reasons: arithmetic overflow checking for
16597 integer operations (including division by zero), checks for access before
16598 elaboration on subprogram calls, and stack overflow checking (most operating
16599 systems do not perform this check by default).
16600
16601 Strict conformance to the Ada Reference Manual can be achieved by adding
16602 three compiler options for overflow checking for integer operations
16603 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16604 calls and generic instantiations (@option{-gnatE}), and stack overflow
16605 checking (@option{-fstack-check}).
16606
16607 Note that the result of a floating point arithmetic operation in overflow and
16608 invalid situations, when the @code{Machine_Overflows} attribute of the result
16609 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16610 case for machines compliant with the IEEE floating-point standard, but on
16611 machines that are not fully compliant with this standard, such as Alpha, the
16612 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16613 behavior (although at the cost of a significant performance penalty), so
16614 infinite and NaN values are properly generated.
16615
16616
16617 @node Implementation of Ada 2012 Features
16618 @chapter Implementation of Ada 2012 Features
16619 @cindex Ada 2012 implementation status
16620
16621 This chapter contains a complete list of Ada 2012 features that have been
16622 implemented as of GNAT version 6.4. Generally, these features are only
16623 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16624 @cindex @option{-gnat12} option
16625 or if the configuration pragma @code{Ada_2012} is used.
16626 @cindex pragma @code{Ada_2012}
16627 @cindex configuration pragma @code{Ada_2012}
16628 @cindex @code{Ada_2012} configuration pragma
16629 However, new pragmas, attributes, and restrictions are
16630 unconditionally available, since the Ada 95 standard allows the addition of
16631 new pragmas, attributes, and restrictions (there are exceptions, which are
16632 documented in the individual descriptions), and also certain packages
16633 were made available in earlier versions of Ada.
16634
16635 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16636 This date shows the implementation date of the feature. Any wavefront
16637 subsequent to this date will contain the indicated feature, as will any
16638 subsequent releases. A date of 0000-00-00 means that GNAT has always
16639 implemented the feature, or implemented it as soon as it appeared as a
16640 binding interpretation.
16641
16642 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16643 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16644 The features are ordered based on the relevant sections of the Ada
16645 Reference Manual (``RM''). When a given AI relates to multiple points
16646 in the RM, the earliest is used.
16647
16648 A complete description of the AIs may be found in
16649 @url{www.ada-auth.org/ai05-summary.html}.
16650
16651 @itemize @bullet
16652
16653 @item
16654 @emph{AI-0176 Quantified expressions (2010-09-29)}
16655 @cindex AI-0176 (Ada 2012 feature)
16656
16657 @noindent
16658 Both universally and existentially quantified expressions are implemented.
16659 They use the new syntax for iterators proposed in AI05-139-2, as well as
16660 the standard Ada loop syntax.
16661
16662 @noindent
16663 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
16664
16665 @item
16666 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16667 @cindex AI-0079 (Ada 2012 feature)
16668
16669 @noindent
16670 Wide characters in the unicode category @i{other_format} are now allowed in
16671 source programs between tokens, but not within a token such as an identifier.
16672
16673 @noindent
16674 RM References: 2.01 (4/2) 2.02 (7)
16675
16676 @item
16677 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16678 @cindex AI-0091 (Ada 2012 feature)
16679
16680 @noindent
16681 Wide characters in the unicode category @i{other_format} are not permitted
16682 within an identifier, since this can be a security problem. The error
16683 message for this case has been improved to be more specific, but GNAT has
16684 never allowed such characters to appear in identifiers.
16685
16686 @noindent
16687 RM References: 2.03 (3.1/2) 2.03 (4/2) 2.03 (5/2) 2.03 (5.1/2) 2.03 (5.2/2) 2.03 (5.3/2) 2.09 (2/2)
16688
16689 @item
16690 @emph{AI-0100 Placement of pragmas (2010-07-01)}
16691 @cindex AI-0100 (Ada 2012 feature)
16692
16693 @noindent
16694 This AI is an earlier version of AI-163. It simplifies the rules
16695 for legal placement of pragmas. In the case of lists that allow pragmas, if
16696 the list may have no elements, then the list may consist solely of pragmas.
16697
16698 @noindent
16699 RM References: 2.08 (7)
16700
16701 @item
16702 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16703 @cindex AI-0163 (Ada 2012 feature)
16704
16705 @noindent
16706 A statement sequence may be composed entirely of pragmas. It is no longer
16707 necessary to add a dummy @code{null} statement to make the sequence legal.
16708
16709 @noindent
16710 RM References: 2.08 (7) 2.08 (16)
16711
16712
16713 @item
16714 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16715 @cindex AI-0080 (Ada 2012 feature)
16716
16717 @noindent
16718 This is an editorial change only, described as non-testable in the AI.
16719
16720 @noindent
16721 RM References: 3.01 (7)
16722
16723
16724 @item
16725 @emph{AI-0183 Aspect specifications (2010-08-16)}
16726 @cindex AI-0183 (Ada 2012 feature)
16727
16728 @noindent
16729 Aspect specifications have been fully implemented except for pre and post-
16730 conditions, and type invariants, which have their own separate AI's. All
16731 forms of declarations listed in the AI are supported. The following is a
16732 list of the aspects supported (with GNAT implementation aspects marked)
16733
16734 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16735 @item @code{Ada_2005} @tab -- GNAT
16736 @item @code{Ada_2012} @tab -- GNAT
16737 @item @code{Address} @tab
16738 @item @code{Alignment} @tab
16739 @item @code{Atomic} @tab
16740 @item @code{Atomic_Components} @tab
16741 @item @code{Bit_Order} @tab
16742 @item @code{Component_Size} @tab
16743 @item @code{Discard_Names} @tab
16744 @item @code{External_Tag} @tab
16745 @item @code{Favor_Top_Level} @tab -- GNAT
16746 @item @code{Inline} @tab
16747 @item @code{Inline_Always} @tab -- GNAT
16748 @item @code{Invariant} @tab
16749 @item @code{Machine_Radix} @tab
16750 @item @code{No_Return} @tab
16751 @item @code{Object_Size} @tab -- GNAT
16752 @item @code{Pack} @tab
16753 @item @code{Persistent_BSS} @tab -- GNAT
16754 @item @code{Post} @tab
16755 @item @code{Pre} @tab
16756 @item @code{Predicate} @tab
16757 @item @code{Preelaborable_Initialization} @tab
16758 @item @code{Pure_Function} @tab -- GNAT
16759 @item @code{Shared} @tab -- GNAT
16760 @item @code{Size} @tab
16761 @item @code{Storage_Pool} @tab
16762 @item @code{Storage_Size} @tab
16763 @item @code{Stream_Size} @tab
16764 @item @code{Suppress} @tab
16765 @item @code{Suppress_Debug_Info} @tab -- GNAT
16766 @item @code{Test_Case} @tab -- GNAT
16767 @item @code{Unchecked_Union} @tab
16768 @item @code{Universal_Aliasing} @tab -- GNAT
16769 @item @code{Unmodified} @tab -- GNAT
16770 @item @code{Unreferenced} @tab -- GNAT
16771 @item @code{Unreferenced_Objects} @tab -- GNAT
16772 @item @code{Unsuppress} @tab
16773 @item @code{Value_Size} @tab -- GNAT
16774 @item @code{Volatile} @tab
16775 @item @code{Volatile_Components}
16776 @item @code{Warnings} @tab -- GNAT
16777 @end multitable
16778
16779 @noindent
16780 Note that for aspects with an expression, e.g. @code{Size}, the expression is
16781 treated like a default expression (visibility is analyzed at the point of
16782 occurrence of the aspect, but evaluation of the expression occurs at the
16783 freeze point of the entity involved.
16784
16785 @noindent
16786 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
16787 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
16788 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
16789 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
16790 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
16791 13.03.01 (0)
16792
16793
16794 @item
16795 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16796 @cindex AI-0128 (Ada 2012 feature)
16797
16798 @noindent
16799 If an equality operator ("=") is declared for a type, then the implicitly
16800 declared inequality operator ("/=") is a primitive operation of the type.
16801 This is the only reasonable interpretation, and is the one always implemented
16802 by GNAT, but the RM was not entirely clear in making this point.
16803
16804 @noindent
16805 RM References: 3.02.03 (6) 6.06 (6)
16806
16807 @item
16808 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16809 @cindex AI-0003 (Ada 2012 feature)
16810
16811 @noindent
16812 In Ada 2012, a qualified expression is considered to be syntactically a name,
16813 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16814 useful in disambiguating some cases of overloading.
16815
16816 @noindent
16817 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
16818 5.04 (7)
16819
16820 @item
16821 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16822 @cindex AI-0120 (Ada 2012 feature)
16823
16824 @noindent
16825 This is an RM editorial change only. The section that lists objects that are
16826 constant failed to include the current instance of a protected object
16827 within a protected function. This has always been treated as a constant
16828 in GNAT.
16829
16830 @noindent
16831 RM References: 3.03 (21)
16832
16833 @item
16834 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16835 @cindex AI-0008 (Ada 2012 feature)
16836
16837 @noindent
16838 The wording in the RM implied that if you have a general access to a
16839 constrained object, it could be used to modify the discriminants. This was
16840 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16841 has always done so in this situation.
16842
16843 @noindent
16844 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
16845
16846
16847 @item
16848 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16849 @cindex AI-0093 (Ada 2012 feature)
16850
16851 @noindent
16852 This is an editorial change only, to make more widespread use of the Ada 2012
16853 ``immutably limited''.
16854
16855 @noindent
16856 RM References: 3.03 (23.4/3)
16857
16858
16859
16860 @item
16861 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16862 @cindex AI-0096 (Ada 2012 feature)
16863
16864 @noindent
16865 In general it is illegal for a type derived from a formal limited type to be
16866 nonlimited. This AI makes an exception to this rule: derivation is legal
16867 if it appears in the private part of the generic, and the formal type is not
16868 tagged. If the type is tagged, the legality check must be applied to the
16869 private part of the package.
16870
16871 @noindent
16872 RM References: 3.04 (5.1/2) 6.02 (7)
16873
16874
16875 @item
16876 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16877 @cindex AI-0181 (Ada 2012 feature)
16878
16879 @noindent
16880 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16881 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16882 @code{Image} and @code{Value} attributes for the character types. Strictly
16883 speaking this is an inconsistency with Ada 95, but in practice the use of
16884 these attributes is so obscure that it will not cause problems.
16885
16886 @noindent
16887 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
16888
16889
16890 @item
16891 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16892 @cindex AI-0182 (Ada 2012 feature)
16893
16894 @noindent
16895 This AI allows @code{Character'Value} to accept the string @code{'?'} where
16896 @code{?} is any character including non-graphic control characters. GNAT has
16897 always accepted such strings. It also allows strings such as
16898 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16899 permission and raises @code{Constraint_Error}, as is certainly still
16900 permitted.
16901
16902 @noindent
16903 RM References: 3.05 (56/2)
16904
16905
16906 @item
16907 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16908 @cindex AI-0214 (Ada 2012 feature)
16909
16910 @noindent
16911 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16912 to have default expressions by allowing them when the type is limited. It
16913 is often useful to define a default value for a discriminant even though
16914 it can't be changed by assignment.
16915
16916 @noindent
16917 RM References: 3.07 (9.1/2) 3.07.02 (3)
16918
16919
16920 @item
16921 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16922 @cindex AI-0102 (Ada 2012 feature)
16923
16924 @noindent
16925 It is illegal to assign an anonymous access constant to an anonymous access
16926 variable. The RM did not have a clear rule to prevent this, but GNAT has
16927 always generated an error for this usage.
16928
16929 @noindent
16930 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
16931
16932
16933 @item
16934 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16935 @cindex AI-0158 (Ada 2012 feature)
16936
16937 @noindent
16938 This AI extends the syntax of membership tests to simplify complex conditions
16939 that can be expressed as membership in a subset of values of any type. It
16940 introduces syntax for a list of expressions that may be used in loop contexts
16941 as well.
16942
16943 @noindent
16944 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
16945
16946
16947 @item
16948 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16949 @cindex AI-0173 (Ada 2012 feature)
16950
16951 @noindent
16952 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
16953 with the tag of an abstract type, and @code{False} otherwise.
16954
16955 @noindent
16956 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
16957
16958
16959
16960 @item
16961 @emph{AI-0076 function with controlling result (0000-00-00)}
16962 @cindex AI-0076 (Ada 2012 feature)
16963
16964 @noindent
16965 This is an editorial change only. The RM defines calls with controlling
16966 results, but uses the term ``function with controlling result'' without an
16967 explicit definition.
16968
16969 @noindent
16970 RM References: 3.09.02 (2/2)
16971
16972
16973 @item
16974 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
16975 @cindex AI-0126 (Ada 2012 feature)
16976
16977 @noindent
16978 This AI clarifies dispatching rules, and simply confirms that dispatching
16979 executes the operation of the parent type when there is no explicitly or
16980 implicitly declared operation for the descendant type. This has always been
16981 the case in all versions of GNAT.
16982
16983 @noindent
16984 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
16985
16986
16987 @item
16988 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
16989 @cindex AI-0097 (Ada 2012 feature)
16990
16991 @noindent
16992 The RM as written implied that in some cases it was possible to create an
16993 object of an abstract type, by having an abstract extension inherit a non-
16994 abstract constructor from its parent type. This mistake has been corrected
16995 in GNAT and in the RM, and this construct is now illegal.
16996
16997 @noindent
16998 RM References: 3.09.03 (4/2)
16999
17000
17001 @item
17002 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17003 @cindex AI-0203 (Ada 2012 feature)
17004
17005 @noindent
17006 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17007 permitted such usage.
17008
17009 @noindent
17010 RM References: 3.09.03 (8/3)
17011
17012
17013 @item
17014 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17015 @cindex AI-0198 (Ada 2012 feature)
17016
17017 @noindent
17018 This AI resolves a conflict between two rules involving inherited abstract
17019 operations and predefined operators. If a derived numeric type inherits
17020 an abstract operator, it overrides the predefined one. This interpretation
17021 was always the one implemented in GNAT.
17022
17023 @noindent
17024 RM References: 3.09.03 (4/3)
17025
17026 @item
17027 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17028 @cindex AI-0073 (Ada 2012 feature)
17029
17030 @noindent
17031 This AI covers a number of issues regarding returning abstract types. In
17032 particular generic functions cannot have abstract result types or access
17033 result types designated an abstract type. There are some other cases which
17034 are detailed in the AI. Note that this binding interpretation has not been
17035 retrofitted to operate before Ada 2012 mode, since it caused a significant
17036 number of regressions.
17037
17038 @noindent
17039 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17040
17041
17042 @item
17043 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17044 @cindex AI-0070 (Ada 2012 feature)
17045
17046 @noindent
17047 This is an editorial change only, there are no testable consequences short of
17048 checking for the absence of generated code for an interface declaration.
17049
17050 @noindent
17051 RM References: 3.09.04 (18/2)
17052
17053
17054 @item
17055 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17056 @cindex AI-0208 (Ada 2012 feature)
17057
17058 @noindent
17059 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17060 was incorrect and implied that some programs intended to be legal were now
17061 illegal. GNAT had never considered such programs illegal, so it has always
17062 implemented the intent of this AI.
17063
17064 @noindent
17065 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17066
17067
17068 @item
17069 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17070 @cindex AI-0162 (Ada 2012 feature)
17071
17072 @noindent
17073 Incomplete types are made more useful by allowing them to be completed by
17074 private types and private extensions.
17075
17076 @noindent
17077 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17078
17079
17080
17081 @item
17082 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17083 @cindex AI-0098 (Ada 2012 feature)
17084
17085 @noindent
17086 An unintentional omission in the RM implied some inconsistent restrictions on
17087 the use of anonymous access to subprogram values. These restrictions were not
17088 intentional, and have never been enforced by GNAT.
17089
17090 @noindent
17091 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17092
17093
17094 @item
17095 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17096 @cindex AI-0199 (Ada 2012 feature)
17097
17098 @noindent
17099 A choice list in a record aggregate can include several components of
17100 (distinct) anonymous access types as long as they have matching designated
17101 subtypes.
17102
17103 @noindent
17104 RM References: 4.03.01 (16)
17105
17106
17107 @item
17108 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17109 @cindex AI-0220 (Ada 2012 feature)
17110
17111 @noindent
17112 This AI addresses a wording problem in the RM that appears to permit some
17113 complex cases of aggregates with non-static discriminants. GNAT has always
17114 implemented the intended semantics.
17115
17116 @noindent
17117 RM References: 4.03.01 (17)
17118
17119 @item
17120 @emph{AI-0147 Conditional expressions (2009-03-29)}
17121 @cindex AI-0147 (Ada 2012 feature)
17122
17123 @noindent
17124 Conditional expressions are permitted. The form of such an expression is:
17125
17126 @smallexample
17127 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17128 @end smallexample
17129
17130 The parentheses can be omitted in contexts where parentheses are present
17131 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17132 clause is omitted, @b{else True} is assumed;
17133 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17134 @emph{(A implies B)} in standard logic.
17135
17136 @noindent
17137 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17138 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17139
17140
17141 @item
17142 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17143 @cindex AI-0037 (Ada 2012 feature)
17144
17145 @noindent
17146 This AI confirms that an association of the form @code{Indx => <>} in an
17147 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17148 is out of range. The RM specified a range check on other associations, but
17149 not when the value of the association was defaulted. GNAT has always inserted
17150 a constraint check on the index value.
17151
17152 @noindent
17153 RM References: 4.03.03 (29)
17154
17155
17156 @item
17157 @emph{AI-0123 Composability of equality (2010-04-13)}
17158 @cindex AI-0123 (Ada 2012 feature)
17159
17160 @noindent
17161 Equality of untagged record composes, so that the predefined equality for a
17162 composite type that includes a component of some untagged record type
17163 @code{R} uses the equality operation of @code{R} (which may be user-defined
17164 or predefined). This makes the behavior of untagged records identical to that
17165 of tagged types in this respect.
17166
17167 This change is an incompatibility with previous versions of Ada, but it
17168 corrects a non-uniformity that was often a source of confusion. Analysis of
17169 a large number of industrial programs indicates that in those rare cases
17170 where a composite type had an untagged record component with a user-defined
17171 equality, either there was no use of the composite equality, or else the code
17172 expected the same composability as for tagged types, and thus had a bug that
17173 would be fixed by this change.
17174
17175 @noindent
17176 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17177 8.05.04 (8)
17178
17179
17180 @item
17181 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17182 @cindex AI-0088 (Ada 2012 feature)
17183
17184 @noindent
17185 This AI clarifies the equivalence rule given for the dynamic semantics of
17186 exponentiation: the value of the operation can be obtained by repeated
17187 multiplication, but the operation can be implemented otherwise (for example
17188 using the familiar divide-by-two-and-square algorithm, even if this is less
17189 accurate), and does not imply repeated reads of a volatile base.
17190
17191 @noindent
17192 RM References: 4.05.06 (11)
17193
17194 @item
17195 @emph{AI-0188 Case expressions (2010-01-09)}
17196 @cindex AI-0188 (Ada 2012 feature)
17197
17198 @noindent
17199 Case expressions are permitted. This allows use of constructs such as:
17200 @smallexample
17201 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17202 @end smallexample
17203
17204 @noindent
17205 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17206
17207 @item
17208 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17209 @cindex AI-0104 (Ada 2012 feature)
17210
17211 @noindent
17212 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17213 @code{Constraint_Error} because the default value of the allocated object is
17214 @b{null}. This useless construct is illegal in Ada 2012.
17215
17216 @noindent
17217 RM References: 4.08 (2)
17218
17219 @item
17220 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17221 @cindex AI-0157 (Ada 2012 feature)
17222
17223 @noindent
17224 Allocation and Deallocation from an empty storage pool (i.e. allocation or
17225 deallocation of a pointer for which a static storage size clause of zero
17226 has been given) is now illegal and is detected as such. GNAT
17227 previously gave a warning but not an error.
17228
17229 @noindent
17230 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
17231
17232 @item
17233 @emph{AI-0179 Statement not required after label (2010-04-10)}
17234 @cindex AI-0179 (Ada 2012 feature)
17235
17236 @noindent
17237 It is not necessary to have a statement following a label, so a label
17238 can appear at the end of a statement sequence without the need for putting a
17239 null statement afterwards, but it is not allowable to have only labels and
17240 no real statements in a statement sequence.
17241
17242 @noindent
17243 RM References: 5.01 (2)
17244
17245
17246 @item
17247 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17248 @cindex AI-139-2 (Ada 2012 feature)
17249
17250 @noindent
17251 The new syntax for iterating over arrays and containers is now implemented.
17252 Iteration over containers is for now limited to read-only iterators. Only
17253 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
17254
17255 @noindent
17256 RM References: 5.05
17257
17258 @item
17259 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17260 @cindex AI-0134 (Ada 2012 feature)
17261
17262 @noindent
17263 For full conformance, the profiles of anonymous-access-to-subprogram
17264 parameters must match. GNAT has always enforced this rule.
17265
17266 @noindent
17267 RM References: 6.03.01 (18)
17268
17269 @item
17270 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17271 @cindex AI-0207 (Ada 2012 feature)
17272
17273 @noindent
17274 This AI confirms that access_to_constant indication must match for mode
17275 conformance. This was implemented in GNAT when the qualifier was originally
17276 introduced in Ada 2005.
17277
17278 @noindent
17279 RM References: 6.03.01 (16/2)
17280
17281
17282 @item
17283 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17284 @cindex AI-0046 (Ada 2012 feature)
17285
17286 @noindent
17287 For full conformance, in the case of access parameters, the null exclusion
17288 must match (either both or neither must have @code{@b{not null}}).
17289
17290 @noindent
17291 RM References: 6.03.02 (18)
17292
17293
17294 @item
17295 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17296 @cindex AI-0118 (Ada 2012 feature)
17297
17298 @noindent
17299 This AI clarifies the rules for named associations in subprogram calls and
17300 generic instantiations. The rules have been in place since Ada 83.
17301
17302 @noindent
17303 RM References: 6.04.01 (2) 12.03 (9)
17304
17305
17306 @item
17307 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17308 @cindex AI-0196 (Ada 2012 feature)
17309
17310 @noindent
17311 Null exclusion checks are not made for @code{@b{out}} parameters when
17312 evaluating the actual parameters. GNAT has never generated these checks.
17313
17314 @noindent
17315 RM References: 6.04.01 (13)
17316
17317 @item
17318 @emph{AI-0015 Constant return objects (0000-00-00)}
17319 @cindex AI-0015 (Ada 2012 feature)
17320
17321 @noindent
17322 The return object declared in an @i{extended_return_statement} may be
17323 declared constant. This was always intended, and GNAT has always allowed it.
17324
17325 @noindent
17326 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17327 6.05 (5.7/2)
17328
17329
17330 @item
17331 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17332 @cindex AI-0032 (Ada 2012 feature)
17333
17334 @noindent
17335 If a function returns a class-wide type, the object of an extended return
17336 statement can be declared with a specific type that is covered by the class-
17337 wide type. This has been implemented in GNAT since the introduction of
17338 extended returns. Note AI-0103 complements this AI by imposing matching
17339 rules for constrained return types.
17340
17341 @noindent
17342 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17343 6.05 (8/2)
17344
17345 @item
17346 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17347 @cindex AI-0103 (Ada 2012 feature)
17348
17349 @noindent
17350 If the return subtype of a function is an elementary type or a constrained
17351 type, the subtype indication in an extended return statement must match
17352 statically this return subtype.
17353
17354 @noindent
17355 RM References: 6.05 (5.2/2)
17356
17357
17358 @item
17359 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17360 @cindex AI-0058 (Ada 2012 feature)
17361
17362 @noindent
17363 The RM had some incorrect wording implying wrong treatment of abnormal
17364 completion in an extended return. GNAT has always implemented the intended
17365 correct semantics as described by this AI.
17366
17367 @noindent
17368 RM References: 6.05 (22/2)
17369
17370
17371 @item
17372 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
17373 @cindex AI-0050 (Ada 2012 feature)
17374
17375 @noindent
17376 The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
17377 not take advantage of these incorrect permissions in any case.
17378
17379 @noindent
17380 RM References: 6.05 (24/2)
17381
17382
17383 @item
17384 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17385 @cindex AI-0125 (Ada 2012 feature)
17386
17387 @noindent
17388 In Ada 2012, the declaration of a primitive operation of a type extension
17389 or private extension can also override an inherited primitive that is not
17390 visible at the point of this declaration.
17391
17392 @noindent
17393 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
17394
17395 @item
17396 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17397 @cindex AI-0062 (Ada 2012 feature)
17398
17399 @noindent
17400 A full constant may have a null exclusion even if its associated deferred
17401 constant does not. GNAT has always allowed this.
17402
17403 @noindent
17404 RM References: 7.04 (6/2) 7.04 (7.1/2)
17405
17406
17407 @item
17408 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17409 @cindex AI-0178 (Ada 2012 feature)
17410
17411 @noindent
17412 This AI clarifies the role of incomplete views and plugs an omission in the
17413 RM. GNAT always correctly restricted the use of incomplete views and types.
17414
17415 @noindent
17416 RM References: 7.05 (3/2) 7.05 (6/2)
17417
17418 @item
17419 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17420 @cindex AI-0087 (Ada 2012 feature)
17421
17422 @noindent
17423 The actual for a formal nonlimited derived type cannot be limited. In
17424 particular, a formal derived type that extends a limited interface but which
17425 is not explicitly limited cannot be instantiated with a limited type.
17426
17427 @noindent
17428 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
17429
17430 @item
17431 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17432 @cindex AI-0099 (Ada 2012 feature)
17433
17434 @noindent
17435 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17436 and therefore depends on the run-time characteristics of an object (i.e. its
17437 tag) and not on its nominal type. As the AI indicates: ``we do not expect
17438 this to affect any implementation''.
17439
17440 @noindent
17441 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
17442
17443
17444
17445 @item
17446 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17447 @cindex AI-0064 (Ada 2012 feature)
17448
17449 @noindent
17450 This is an editorial change only. The intended behavior is already checked
17451 by an existing ACATS test, which GNAT has always executed correctly.
17452
17453 @noindent
17454 RM References: 7.06.01 (17.1/1)
17455
17456 @item
17457 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17458 @cindex AI-0026 (Ada 2012 feature)
17459
17460 @noindent
17461 Record representation clauses concerning Unchecked_Union types cannot mention
17462 the discriminant of the type. The type of a component declared in the variant
17463 part of an Unchecked_Union cannot be controlled, have controlled components,
17464 nor have protected or task parts. If an Unchecked_Union type is declared
17465 within the body of a generic unit or its descendants, then the type of a
17466 component declared in the variant part cannot be a formal private type or a
17467 formal private extension declared within the same generic unit.
17468
17469 @noindent
17470 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
17471
17472
17473 @item
17474 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17475 @cindex AI-0205 (Ada 2012 feature)
17476
17477 @noindent
17478 This AI corrects a simple omission in the RM. Return objects have always
17479 been visible within an extended return statement.
17480
17481 @noindent
17482 RM References: 8.03 (17)
17483
17484
17485 @item
17486 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17487 @cindex AI-0042 (Ada 2012 feature)
17488
17489 @noindent
17490 This AI fixes a wording gap in the RM. An operation of a synchronized
17491 interface can be implemented by a protected or task entry, but the abstract
17492 operation is not being overridden in the usual sense, and it must be stated
17493 separately that this implementation is legal. This has always been the case
17494 in GNAT.
17495
17496 @noindent
17497 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
17498
17499 @item
17500 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17501 @cindex AI-0030 (Ada 2012 feature)
17502
17503 @noindent
17504 Requeue is permitted to a protected, synchronized or task interface primitive
17505 providing it is known that the overriding operation is an entry. Otherwise
17506 the requeue statement has the same effect as a procedure call. Use of pragma
17507 @code{Implemented} provides a way to impose a static requirement on the
17508 overriding operation by adhering to one of the implementation kinds: entry,
17509 protected procedure or any of the above.
17510
17511 @noindent
17512 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
17513 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
17514
17515
17516 @item
17517 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17518 @cindex AI-0201 (Ada 2012 feature)
17519
17520 @noindent
17521 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17522 attribute, then individual components may not be addressable by independent
17523 tasks. However, if the representation clause has no effect (is confirming),
17524 then independence is not compromised. Furthermore, in GNAT, specification of
17525 other appropriately addressable component sizes (e.g. 16 for 8-bit
17526 characters) also preserves independence. GNAT now gives very clear warnings
17527 both for the declaration of such a type, and for any assignment to its components.
17528
17529 @noindent
17530 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
17531
17532 @item
17533 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17534 @cindex AI-0009 (Ada 2012 feature)
17535
17536 @noindent
17537 This AI introduces the new pragmas @code{Independent} and
17538 @code{Independent_Components},
17539 which control guaranteeing independence of access to objects and components.
17540 The AI also requires independence not unaffected by confirming rep clauses.
17541
17542 @noindent
17543 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
17544 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
17545
17546
17547 @item
17548 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17549 @cindex AI-0072 (Ada 2012 feature)
17550
17551 @noindent
17552 This AI clarifies that task signalling for reading @code{'Terminated} only
17553 occurs if the result is True. GNAT semantics has always been consistent with
17554 this notion of task signalling.
17555
17556 @noindent
17557 RM References: 9.10 (6.1/1)
17558
17559 @item
17560 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17561 @cindex AI-0108 (Ada 2012 feature)
17562
17563 @noindent
17564 This AI confirms that an incomplete type from a limited view does not have
17565 discriminants. This has always been the case in GNAT.
17566
17567 @noindent
17568 RM References: 10.01.01 (12.3/2)
17569
17570 @item
17571 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17572 @cindex AI-0129 (Ada 2012 feature)
17573
17574 @noindent
17575 This AI clarifies the description of limited views: a limited view of a
17576 package includes only one view of a type that has an incomplete declaration
17577 and a full declaration (there is no possible ambiguity in a client package).
17578 This AI also fixes an omission: a nested package in the private part has no
17579 limited view. GNAT always implemented this correctly.
17580
17581 @noindent
17582 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
17583
17584
17585
17586 @item
17587 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17588 @cindex AI-0077 (Ada 2012 feature)
17589
17590 @noindent
17591 This AI clarifies that a declaration does not include a context clause,
17592 and confirms that it is illegal to have a context in which both a limited
17593 and a nonlimited view of a package are accessible. Such double visibility
17594 was always rejected by GNAT.
17595
17596 @noindent
17597 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
17598
17599 @item
17600 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17601 @cindex AI-0122 (Ada 2012 feature)
17602
17603 @noindent
17604 This AI clarifies the visibility of private children of generic units within
17605 instantiations of a parent. GNAT has always handled this correctly.
17606
17607 @noindent
17608 RM References: 10.01.02 (12/2)
17609
17610
17611
17612 @item
17613 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17614 @cindex AI-0040 (Ada 2012 feature)
17615
17616 @noindent
17617 This AI confirms that a limited with clause in a child unit cannot name
17618 an ancestor of the unit. This has always been checked in GNAT.
17619
17620 @noindent
17621 RM References: 10.01.02 (20/2)
17622
17623 @item
17624 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17625 @cindex AI-0132 (Ada 2012 feature)
17626
17627 @noindent
17628 This AI fills a gap in the description of library unit pragmas. The pragma
17629 clearly must apply to a library unit, even if it does not carry the name
17630 of the enclosing unit. GNAT has always enforced the required check.
17631
17632 @noindent
17633 RM References: 10.01.05 (7)
17634
17635
17636 @item
17637 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17638 @cindex AI-0034 (Ada 2012 feature)
17639
17640 @noindent
17641 The RM makes certain limited with clauses illegal because of categorization
17642 considerations, when the corresponding normal with would be legal. This is
17643 not intended, and GNAT has always implemented the recommended behavior.
17644
17645 @noindent
17646 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
17647
17648
17649 @item
17650 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17651 @cindex AI-0035 (Ada 2012 feature)
17652
17653 @noindent
17654 This AI remedies some inconsistencies in the legality rules for Pure units.
17655 Derived access types are legal in a pure unit (on the assumption that the
17656 rule for a zero storage pool size has been enforced on the ancestor type).
17657 The rules are enforced in generic instances and in subunits. GNAT has always
17658 implemented the recommended behavior.
17659
17660 @noindent
17661 RM References: 10.02.01 (15.1/2) 10.02.01 (15.4/2) 10.02.01 (15.5/2) 10.02.01 (17/2)
17662
17663
17664 @item
17665 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17666 @cindex AI-0219 (Ada 2012 feature)
17667
17668 @noindent
17669 This AI refines the rules for the cases with limited parameters which do not
17670 allow the implementations to omit ``redundant''. GNAT now properly conforms
17671 to the requirements of this binding interpretation.
17672
17673 @noindent
17674 RM References: 10.02.01 (18/2)
17675
17676 @item
17677 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17678 @cindex AI-0043 (Ada 2012 feature)
17679
17680 @noindent
17681 This AI covers various omissions in the RM regarding the raising of
17682 exceptions. GNAT has always implemented the intended semantics.
17683
17684 @noindent
17685 RM References: 11.04.01 (10.1/2) 11 (2)
17686
17687
17688 @item
17689 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17690 @cindex AI-0200 (Ada 2012 feature)
17691
17692 @noindent
17693 This AI plugs a gap in the RM which appeared to allow some obviously intended
17694 illegal instantiations. GNAT has never allowed these instantiations.
17695
17696 @noindent
17697 RM References: 12.07 (16)
17698
17699
17700 @item
17701 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17702 @cindex AI-0112 (Ada 2012 feature)
17703
17704 @noindent
17705 This AI concerns giving names to various representation aspects, but the
17706 practical effect is simply to make the use of duplicate
17707 @code{Atomic}[@code{_Components}],
17708 @code{Volatile}[@code{_Components}] and
17709 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17710 now performs this required check.
17711
17712 @noindent
17713 RM References: 13.01 (8)
17714
17715 @item
17716 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17717 @cindex AI-0106 (Ada 2012 feature)
17718
17719 @noindent
17720 The RM appeared to allow representation pragmas on generic formal parameters,
17721 but this was not intended, and GNAT has never permitted this usage.
17722
17723 @noindent
17724 RM References: 13.01 (9.1/1)
17725
17726
17727 @item
17728 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17729 @cindex AI-0012 (Ada 2012 feature)
17730
17731 @noindent
17732 It is now illegal to give an inappropriate component size or a pragma
17733 @code{Pack} that attempts to change the component size in the case of atomic
17734 or aliased components. Previously GNAT ignored such an attempt with a
17735 warning.
17736
17737 @noindent
17738 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
17739
17740
17741 @item
17742 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17743 @cindex AI-0039 (Ada 2012 feature)
17744
17745 @noindent
17746 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17747 for stream attributes, but these were never useful and are now illegal. GNAT
17748 has always regarded such expressions as illegal.
17749
17750 @noindent
17751 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
17752
17753
17754 @item
17755 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17756 @cindex AI-0095 (Ada 2012 feature)
17757
17758 @noindent
17759 The prefix of @code{'Address} cannot statically denote a subprogram with
17760 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17761 @code{Program_Error} if the prefix denotes a subprogram with convention
17762 @code{Intrinsic}.
17763
17764 @noindent
17765 RM References: 13.03 (11/1)
17766
17767
17768 @item
17769 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17770 @cindex AI-0116 (Ada 2012 feature)
17771
17772 @noindent
17773 This AI requires that the alignment of a class-wide object be no greater
17774 than the alignment of any type in the class. GNAT has always followed this
17775 recommendation.
17776
17777 @noindent
17778 RM References: 13.03 (29) 13.11 (16)
17779
17780
17781 @item
17782 @emph{AI-0146 Type invariants (2009-09-21)}
17783 @cindex AI-0146 (Ada 2012 feature)
17784
17785 @noindent
17786 Type invariants may be specified for private types using the aspect notation.
17787 Aspect @code{Invariant} may be specified for any private type,
17788 @code{Invariant'Class} can
17789 only be specified for tagged types, and is inherited by any descendent of the
17790 tagged types. The invariant is a boolean expression that is tested for being
17791 true in the following situations: conversions to the private type, object
17792 declarations for the private type that are default initialized, and
17793 [@b{in}] @b{out}
17794 parameters and returned result on return from any primitive operation for
17795 the type that is visible to a client.
17796
17797 @noindent
17798 RM References: 13.03.03 (00)
17799
17800 @item
17801 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17802 @cindex AI-0078 (Ada 2012 feature)
17803
17804 @noindent
17805 In Ada 2012, compilers are required to support unchecked conversion where the
17806 target alignment is a multiple of the source alignment. GNAT always supported
17807 this case (and indeed all cases of differing alignments, doing copies where
17808 required if the alignment was reduced).
17809
17810 @noindent
17811 RM References: 13.09 (7)
17812
17813
17814 @item
17815 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17816 @cindex AI-0195 (Ada 2012 feature)
17817
17818 @noindent
17819 The handling of invalid values is now designated to be implementation
17820 defined. This is a documentation change only, requiring Annex M in the GNAT
17821 Reference Manual to document this handling.
17822 In GNAT, checks for invalid values are made
17823 only when necessary to avoid erroneous behavior. Operations like assignments
17824 which cannot cause erroneous behavior ignore the possibility of invalid
17825 values and do not do a check. The date given above applies only to the
17826 documentation change, this behavior has always been implemented by GNAT.
17827
17828 @noindent
17829 RM References: 13.09.01 (10)
17830
17831 @item
17832 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17833 @cindex AI-0193 (Ada 2012 feature)
17834
17835 @noindent
17836 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17837 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17838 of size.
17839
17840 @noindent
17841 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
17842 13.11.01 (2) 13.11.01 (3)
17843
17844
17845 @item
17846 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17847 @cindex AI-0177 (Ada 2012 feature)
17848
17849 @noindent
17850 The new Ada 2012 notion of parameterized expressions is implemented. The form
17851 is:
17852 @smallexample
17853 @i{function specification} @b{is} (@i{expression})
17854 @end smallexample
17855
17856 @noindent
17857 This is exactly equivalent to the
17858 corresponding function body that returns the expression, but it can appear
17859 in a package spec. Note that the expression must be parenthesized.
17860
17861 @noindent
17862 RM References: 13.11.01 (3/2)
17863
17864 @item
17865 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17866 @cindex AI-0033 (Ada 2012 feature)
17867
17868 @noindent
17869 Neither of these two pragmas may appear within a generic template, because
17870 the generic might be instantiated at other than the library level.
17871
17872 @noindent
17873 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
17874
17875
17876 @item
17877 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17878 @cindex AI-0161 (Ada 2012 feature)
17879
17880 @noindent
17881 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17882 of the default stream attributes for elementary types. If this restriction is
17883 in force, then it is necessary to provide explicit subprograms for any
17884 stream attributes used.
17885
17886 @noindent
17887 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
17888
17889 @item
17890 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17891 @cindex AI-0194 (Ada 2012 feature)
17892
17893 @noindent
17894 The @code{Stream_Size} attribute returns the default number of bits in the
17895 stream representation of the given type.
17896 This value is not affected by the presence
17897 of stream subprogram attributes for the type. GNAT has always implemented
17898 this interpretation.
17899
17900 @noindent
17901 RM References: 13.13.02 (1.2/2)
17902
17903 @item
17904 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17905 @cindex AI-0109 (Ada 2012 feature)
17906
17907 @noindent
17908 This AI is an editorial change only. It removes the need for a tag check
17909 that can never fail.
17910
17911 @noindent
17912 RM References: 13.13.02 (34/2)
17913
17914 @item
17915 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17916 @cindex AI-0007 (Ada 2012 feature)
17917
17918 @noindent
17919 The RM as written appeared to limit the possibilities of declaring read
17920 attribute procedures for private scalar types. This limitation was not
17921 intended, and has never been enforced by GNAT.
17922
17923 @noindent
17924 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
17925
17926
17927 @item
17928 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17929 @cindex AI-0065 (Ada 2012 feature)
17930
17931 @noindent
17932 This AI clarifies the fact that all remote access types support external
17933 streaming. This fixes an obvious oversight in the definition of the
17934 language, and GNAT always implemented the intended correct rules.
17935
17936 @noindent
17937 RM References: 13.13.02 (52/2)
17938
17939 @item
17940 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17941 @cindex AI-0019 (Ada 2012 feature)
17942
17943 @noindent
17944 The RM suggests that primitive subprograms of a specific tagged type are
17945 frozen when the tagged type is frozen. This would be an incompatible change
17946 and is not intended. GNAT has never attempted this kind of freezing and its
17947 behavior is consistent with the recommendation of this AI.
17948
17949 @noindent
17950 RM References: 13.14 (2) 13.14 (3/1) 13.14 (8.1/1) 13.14 (10) 13.14 (14) 13.14 (15.1/2)
17951
17952 @item
17953 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
17954 @cindex AI-0017 (Ada 2012 feature)
17955
17956 @noindent
17957 So-called ``Taft-amendment types'' (i.e., types that are completed in package
17958 bodies) are not frozen by the occurrence of bodies in the
17959 enclosing declarative part. GNAT always implemented this properly.
17960
17961 @noindent
17962 RM References: 13.14 (3/1)
17963
17964
17965 @item
17966 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
17967 @cindex AI-0060 (Ada 2012 feature)
17968
17969 @noindent
17970 This AI extends the definition of remote access types to include access
17971 to limited, synchronized, protected or task class-wide interface types.
17972 GNAT already implemented this extension.
17973
17974 @noindent
17975 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
17976
17977 @item
17978 @emph{AI-0114 Classification of letters (0000-00-00)}
17979 @cindex AI-0114 (Ada 2012 feature)
17980
17981 @noindent
17982 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
17983 181 (@code{MICRO SIGN}), and
17984 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
17985 lower case letters by Unicode.
17986 However, they are not allowed in identifiers, and they
17987 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
17988 This behavior is consistent with that defined in Ada 95.
17989
17990 @noindent
17991 RM References: A.03.02 (59) A.04.06 (7)
17992
17993
17994 @item
17995 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
17996 @cindex AI-0185 (Ada 2012 feature)
17997
17998 @noindent
17999 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18000 classification functions for @code{Wide_Character} and
18001 @code{Wide_Wide_Character}, as well as providing
18002 case folding routines for @code{Wide_[Wide_]Character} and
18003 @code{Wide_[Wide_]String}.
18004
18005 @noindent
18006 RM References: A.03.05 (0) A.03.06 (0)
18007
18008
18009 @item
18010 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18011 @cindex AI-0031 (Ada 2012 feature)
18012
18013 @noindent
18014 A new version of @code{Find_Token} is added to all relevant string packages,
18015 with an extra parameter @code{From}. Instead of starting at the first
18016 character of the string, the search for a matching Token starts at the
18017 character indexed by the value of @code{From}.
18018 These procedures are available in all versions of Ada
18019 but if used in versions earlier than Ada 2012 they will generate a warning
18020 that an Ada 2012 subprogram is being used.
18021
18022 @noindent
18023 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18024 A.04.05 (46)
18025
18026
18027 @item
18028 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18029 @cindex AI-0056 (Ada 2012 feature)
18030
18031 @noindent
18032 The wording in the Ada 2005 RM implied an incompatible handling of the
18033 @code{Index} functions, resulting in raising an exception instead of
18034 returning zero in some situations.
18035 This was not intended and has been corrected.
18036 GNAT always returned zero, and is thus consistent with this AI.
18037
18038 @noindent
18039 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18040
18041
18042 @item
18043 @emph{AI-0137 String encoding package (2010-03-25)}
18044 @cindex AI-0137 (Ada 2012 feature)
18045
18046 @noindent
18047 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18048 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18049 and @code{Wide_Wide_Strings} have been
18050 implemented. These packages (whose documentation can be found in the spec
18051 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18052 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18053 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18054 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18055 UTF-16), as well as conversions between the different UTF encodings. With
18056 the exception of @code{Wide_Wide_Strings}, these packages are available in
18057 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18058 The @code{Wide_Wide_Strings package}
18059 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18060 mode since it uses @code{Wide_Wide_Character}).
18061
18062 @noindent
18063 RM References: A.04.11
18064
18065 @item
18066 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18067 @cindex AI-0038 (Ada 2012 feature)
18068
18069 @noindent
18070 These are minor errors in the description on three points. The intent on
18071 all these points has always been clear, and GNAT has always implemented the
18072 correct intended semantics.
18073
18074 @noindent
18075 RM References: A.10.05 (37) A.10.07 (8/1) A.10.07 (10) A.10.07 (12) A.10.08 (10) A.10.08 (24)
18076
18077 @item
18078 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18079 @cindex AI-0044 (Ada 2012 feature)
18080
18081 @noindent
18082 This AI places restrictions on allowed instantiations of generic containers.
18083 These restrictions are not checked by the compiler, so there is nothing to
18084 change in the implementation. This affects only the RM documentation.
18085
18086 @noindent
18087 RM References: A.18 (4/2) A.18.02 (231/2) A.18.03 (145/2) A.18.06 (56/2) A.18.08 (66/2) A.18.09 (79/2) A.18.26 (5/2) A.18.26 (9/2)
18088
18089 @item
18090 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18091 @cindex AI-0127 (Ada 2012 feature)
18092
18093 @noindent
18094 This package provides an interface for identifying the current locale.
18095
18096 @noindent
18097 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18098 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18099
18100
18101
18102 @item
18103 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18104 @cindex AI-0002 (Ada 2012 feature)
18105
18106 @noindent
18107 The compiler is not required to support exporting an Ada subprogram with
18108 convention C if there are parameters or a return type of an unconstrained
18109 array type (such as @code{String}). GNAT allows such declarations but
18110 generates warnings. It is possible, but complicated, to write the
18111 corresponding C code and certainly such code would be specific to GNAT and
18112 non-portable.
18113
18114 @noindent
18115 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18116
18117
18118 @item
18119 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18120 @cindex AI05-0216 (Ada 2012 feature)
18121
18122 @noindent
18123 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18124 forbid tasks declared locally within subprograms, or functions returning task
18125 objects, and that is the implementation that GNAT has always provided.
18126 However the language in the RM was not sufficiently clear on this point.
18127 Thus this is a documentation change in the RM only.
18128
18129 @noindent
18130 RM References: D.07 (3/3)
18131
18132 @item
18133 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18134 @cindex AI-0211 (Ada 2012 feature)
18135
18136 @noindent
18137 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18138 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18139
18140 @noindent
18141 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18142
18143 @item
18144 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18145 @cindex AI-0190 (Ada 2012 feature)
18146
18147 @noindent
18148 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18149 used to control storage pools globally.
18150 In particular, you can force every access
18151 type that is used for allocation (@b{new}) to have an explicit storage pool,
18152 or you can declare a pool globally to be used for all access types that lack
18153 an explicit one.
18154
18155 @noindent
18156 RM References: D.07 (8)
18157
18158 @item
18159 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18160 @cindex AI-0189 (Ada 2012 feature)
18161
18162 @noindent
18163 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18164 which says that no dynamic allocation will occur once elaboration is
18165 completed.
18166 In general this requires a run-time check, which is not required, and which
18167 GNAT does not attempt. But the static cases of allocators in a task body or
18168 in the body of the main program are detected and flagged at compile or bind
18169 time.
18170
18171 @noindent
18172 RM References: D.07 (19.1/2) H.04 (23.3/2)
18173
18174 @item
18175 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18176 @cindex AI-0171 (Ada 2012 feature)
18177
18178 @noindent
18179 A new package @code{System.Multiprocessors} is added, together with the
18180 definition of pragma @code{CPU} for controlling task affinity. A new no
18181 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18182 is added to the Ravenscar profile.
18183
18184 @noindent
18185 RM References: D.13.01 (4/2) D.16
18186
18187
18188 @item
18189 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18190 @cindex AI-0210 (Ada 2012 feature)
18191
18192 @noindent
18193 This is a documentation only issue regarding wording of metric requirements,
18194 that does not affect the implementation of the compiler.
18195
18196 @noindent
18197 RM References: D.15 (24/2)
18198
18199
18200 @item
18201 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18202 @cindex AI-0206 (Ada 2012 feature)
18203
18204 @noindent
18205 Remote types packages are now allowed to depend on preelaborated packages.
18206 This was formerly considered illegal.
18207
18208 @noindent
18209 RM References: E.02.02 (6)
18210
18211
18212
18213 @item
18214 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18215 @cindex AI-0152 (Ada 2012 feature)
18216
18217 @noindent
18218 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18219 where the type of the returned value is an anonymous access type.
18220
18221 @noindent
18222 RM References: H.04 (8/1)
18223 @end itemize
18224
18225
18226 @node Obsolescent Features
18227 @chapter Obsolescent Features
18228
18229 @noindent
18230 This chapter describes features that are provided by GNAT, but are
18231 considered obsolescent since there are preferred ways of achieving
18232 the same effect. These features are provided solely for historical
18233 compatibility purposes.
18234
18235 @menu
18236 * pragma No_Run_Time::
18237 * pragma Ravenscar::
18238 * pragma Restricted_Run_Time::
18239 @end menu
18240
18241 @node pragma No_Run_Time
18242 @section pragma No_Run_Time
18243
18244 The pragma @code{No_Run_Time} is used to achieve an affect similar
18245 to the use of the "Zero Foot Print" configurable run time, but without
18246 requiring a specially configured run time. The result of using this
18247 pragma, which must be used for all units in a partition, is to restrict
18248 the use of any language features requiring run-time support code. The
18249 preferred usage is to use an appropriately configured run-time that
18250 includes just those features that are to be made accessible.
18251
18252 @node pragma Ravenscar
18253 @section pragma Ravenscar
18254
18255 The pragma @code{Ravenscar} has exactly the same effect as pragma
18256 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18257 is part of the new Ada 2005 standard.
18258
18259 @node pragma Restricted_Run_Time
18260 @section pragma Restricted_Run_Time
18261
18262 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18263 pragma @code{Profile (Restricted)}. The latter usage is
18264 preferred since the Ada 2005 pragma @code{Profile} is intended for
18265 this kind of implementation dependent addition.
18266
18267 @include fdl.texi
18268 @c GNU Free Documentation License
18269
18270 @node Index,,GNU Free Documentation License, Top
18271 @unnumbered Index
18272
18273 @printindex cp
18274
18275 @contents
18276
18277 @bye