666d251273d91642c6eaaabb7c6c969765e31d8a
[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.
1018
1019 @node Pragma Assert
1020 @unnumberedsec Pragma Assert
1021 @findex Assert
1022 @noindent
1023 Syntax:
1024 @smallexample @c ada
1025 pragma Assert (
1026 boolean_EXPRESSION
1027 [, string_EXPRESSION]);
1028 @end smallexample
1029
1030 @noindent
1031 The effect of this pragma depends on whether the corresponding command
1032 line switch is set to activate assertions. The pragma expands into code
1033 equivalent to the following:
1034
1035 @smallexample @c ada
1036 if assertions-enabled then
1037 if not boolean_EXPRESSION then
1038 System.Assertions.Raise_Assert_Failure
1039 (string_EXPRESSION);
1040 end if;
1041 end if;
1042 @end smallexample
1043
1044 @noindent
1045 The string argument, if given, is the message that will be associated
1046 with the exception occurrence if the exception is raised. If no second
1047 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1048 where @var{file} is the name of the source file containing the assert,
1049 and @var{nnn} is the line number of the assert. A pragma is not a
1050 statement, so if a statement sequence contains nothing but a pragma
1051 assert, then a null statement is required in addition, as in:
1052
1053 @smallexample @c ada
1054 @dots{}
1055 if J > 3 then
1056 pragma Assert (K > 3, "Bad value for K");
1057 null;
1058 end if;
1059 @end smallexample
1060
1061 @noindent
1062 Note that, as with the @code{if} statement to which it is equivalent, the
1063 type of the expression is either @code{Standard.Boolean}, or any type derived
1064 from this standard type.
1065
1066 If assertions are disabled (switch @option{-gnata} not used), then there
1067 is no run-time effect (and in particular, any side effects from the
1068 expression will not occur at run time). (The expression is still
1069 analyzed at compile time, and may cause types to be frozen if they are
1070 mentioned here for the first time).
1071
1072 If assertions are enabled, then the given expression is tested, and if
1073 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1074 which results in the raising of @code{Assert_Failure} with the given message.
1075
1076 You should generally avoid side effects in the expression arguments of
1077 this pragma, because these side effects will turn on and off with the
1078 setting of the assertions mode, resulting in assertions that have an
1079 effect on the program. However, the expressions are analyzed for
1080 semantic correctness whether or not assertions are enabled, so turning
1081 assertions on and off cannot affect the legality of a program.
1082
1083 Note that the implementation defined policy @code{DISABLE}, given in a
1084 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1085
1086 Note: this is a standard language-defined pragma in versions
1087 of Ada from 2005 on. In GNAT, it is implemented in all versions
1088 of Ada, and the DISABLE policy is an implementation-defined
1089 addition.
1090
1091
1092 @node Pragma Assertion_Policy
1093 @unnumberedsec Pragma Assertion_Policy
1094 @findex Debug_Policy
1095 @noindent
1096 Syntax:
1097
1098 @smallexample @c ada
1099 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1100 @end smallexample
1101
1102 @noindent
1103 If the argument is @code{CHECK}, then pragma @code{Assert} is enabled.
1104 If the argument is @code{IGNORE}, then pragma @code{Assert} is ignored.
1105 This pragma overrides the effect of the @option{-gnata} switch on the
1106 command line.
1107
1108 The implementation defined policy @code{DISABLE} is like
1109 @code{IGNORE} except that it completely disables semantic
1110 checking of the argument to @code{pragma Assert}. This may
1111 be useful when the pragma argument references subprograms
1112 in a with'ed package which is replaced by a dummy package
1113 for the final build.
1114
1115 Note: this is a standard language-defined pragma in versions
1116 of Ada from 2005 on. In GNAT, it is implemented in all versions
1117 of Ada, and the DISABLE policy is an implementation-defined
1118 addition.
1119
1120 @node Pragma Assume_No_Invalid_Values
1121 @unnumberedsec Pragma Assume_No_Invalid_Values
1122 @findex Assume_No_Invalid_Values
1123 @cindex Invalid representations
1124 @cindex Invalid values
1125 @noindent
1126 Syntax:
1127 @smallexample @c ada
1128 pragma Assume_No_Invalid_Values (On | Off);
1129 @end smallexample
1130
1131 @noindent
1132 This is a configuration pragma that controls the assumptions made by the
1133 compiler about the occurrence of invalid representations (invalid values)
1134 in the code.
1135
1136 The default behavior (corresponding to an Off argument for this pragma), is
1137 to assume that values may in general be invalid unless the compiler can
1138 prove they are valid. Consider the following example:
1139
1140 @smallexample @c ada
1141 V1 : Integer range 1 .. 10;
1142 V2 : Integer range 11 .. 20;
1143 ...
1144 for J in V2 .. V1 loop
1145 ...
1146 end loop;
1147 @end smallexample
1148
1149 @noindent
1150 if V1 and V2 have valid values, then the loop is known at compile
1151 time not to execute since the lower bound must be greater than the
1152 upper bound. However in default mode, no such assumption is made,
1153 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1154 is given, the compiler will assume that any occurrence of a variable
1155 other than in an explicit @code{'Valid} test always has a valid
1156 value, and the loop above will be optimized away.
1157
1158 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1159 you know your code is free of uninitialized variables and other
1160 possible sources of invalid representations, and may result in
1161 more efficient code. A program that accesses an invalid representation
1162 with this pragma in effect is erroneous, so no guarantees can be made
1163 about its behavior.
1164
1165 It is peculiar though permissible to use this pragma in conjunction
1166 with validity checking (-gnatVa). In such cases, accessing invalid
1167 values will generally give an exception, though formally the program
1168 is erroneous so there are no guarantees that this will always be the
1169 case, and it is recommended that these two options not be used together.
1170
1171 @node Pragma Ast_Entry
1172 @unnumberedsec Pragma Ast_Entry
1173 @cindex OpenVMS
1174 @findex Ast_Entry
1175 @noindent
1176 Syntax:
1177 @smallexample @c ada
1178 pragma AST_Entry (entry_IDENTIFIER);
1179 @end smallexample
1180
1181 @noindent
1182 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1183 argument is the simple name of a single entry; at most one @code{AST_Entry}
1184 pragma is allowed for any given entry. This pragma must be used in
1185 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1186 the entry declaration and in the same task type specification or single task
1187 as the entry to which it applies. This pragma specifies that the given entry
1188 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1189 resulting from an OpenVMS system service call. The pragma does not affect
1190 normal use of the entry. For further details on this pragma, see the
1191 DEC Ada Language Reference Manual, section 9.12a.
1192
1193 @node Pragma C_Pass_By_Copy
1194 @unnumberedsec Pragma C_Pass_By_Copy
1195 @cindex Passing by copy
1196 @findex C_Pass_By_Copy
1197 @noindent
1198 Syntax:
1199 @smallexample @c ada
1200 pragma C_Pass_By_Copy
1201 ([Max_Size =>] static_integer_EXPRESSION);
1202 @end smallexample
1203
1204 @noindent
1205 Normally the default mechanism for passing C convention records to C
1206 convention subprograms is to pass them by reference, as suggested by RM
1207 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1208 this default, by requiring that record formal parameters be passed by
1209 copy if all of the following conditions are met:
1210
1211 @itemize @bullet
1212 @item
1213 The size of the record type does not exceed the value specified for
1214 @code{Max_Size}.
1215 @item
1216 The record type has @code{Convention C}.
1217 @item
1218 The formal parameter has this record type, and the subprogram has a
1219 foreign (non-Ada) convention.
1220 @end itemize
1221
1222 @noindent
1223 If these conditions are met the argument is passed by copy, i.e.@: in a
1224 manner consistent with what C expects if the corresponding formal in the
1225 C prototype is a struct (rather than a pointer to a struct).
1226
1227 You can also pass records by copy by specifying the convention
1228 @code{C_Pass_By_Copy} for the record type, or by using the extended
1229 @code{Import} and @code{Export} pragmas, which allow specification of
1230 passing mechanisms on a parameter by parameter basis.
1231
1232 @node Pragma Check
1233 @unnumberedsec Pragma Check
1234 @cindex Assertions
1235 @cindex Named assertions
1236 @findex Check
1237 @noindent
1238 Syntax:
1239 @smallexample @c ada
1240 pragma Check (
1241 [Name =>] Identifier,
1242 [Check =>] Boolean_EXPRESSION
1243 [, [Message =>] string_EXPRESSION] );
1244 @end smallexample
1245
1246 @noindent
1247 This pragma is similar to the predefined pragma @code{Assert} except that an
1248 extra identifier argument is present. In conjunction with pragma
1249 @code{Check_Policy}, this can be used to define groups of assertions that can
1250 be independently controlled. The identifier @code{Assertion} is special, it
1251 refers to the normal set of pragma @code{Assert} statements. The identifiers
1252 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1253 names, so these three names would normally not be used directly in a pragma
1254 @code{Check}.
1255
1256 Checks introduced by this pragma are normally deactivated by default. They can
1257 be activated either by the command line option @option{-gnata}, which turns on
1258 all checks, or individually controlled using pragma @code{Check_Policy}.
1259
1260 @node Pragma Check_Name
1261 @unnumberedsec Pragma Check_Name
1262 @cindex Defining check names
1263 @cindex Check names, defining
1264 @findex Check_Name
1265 @noindent
1266 Syntax:
1267 @smallexample @c ada
1268 pragma Check_Name (check_name_IDENTIFIER);
1269 @end smallexample
1270
1271 @noindent
1272 This is a configuration pragma that defines a new implementation
1273 defined check name (unless IDENTIFIER matches one of the predefined
1274 check names, in which case the pragma has no effect). Check names
1275 are global to a partition, so if two or more configuration pragmas
1276 are present in a partition mentioning the same name, only one new
1277 check name is introduced.
1278
1279 An implementation defined check name introduced with this pragma may
1280 be used in only three contexts: @code{pragma Suppress},
1281 @code{pragma Unsuppress},
1282 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1283 any of these three cases, the check name must be visible. A check
1284 name is visible if it is in the configuration pragmas applying to
1285 the current unit, or if it appears at the start of any unit that
1286 is part of the dependency set of the current unit (e.g., units that
1287 are mentioned in @code{with} clauses).
1288
1289 @node Pragma Check_Policy
1290 @unnumberedsec Pragma Check_Policy
1291 @cindex Controlling assertions
1292 @cindex Assertions, control
1293 @cindex Check pragma control
1294 @cindex Named assertions
1295 @findex Check
1296 @noindent
1297 Syntax:
1298 @smallexample @c ada
1299 pragma Check_Policy
1300 ([Name =>] Identifier,
1301 [Policy =>] POLICY_IDENTIFIER);
1302
1303 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1304 @end smallexample
1305
1306 @noindent
1307 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1308 except that it controls sets of named assertions introduced using the
1309 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1310 @code{Assertion_Policy}) can be used within a declarative part, in which case
1311 it controls the status to the end of the corresponding construct (in a manner
1312 identical to pragma @code{Suppress)}.
1313
1314 The identifier given as the first argument corresponds to a name used in
1315 associated @code{Check} pragmas. For example, if the pragma:
1316
1317 @smallexample @c ada
1318 pragma Check_Policy (Critical_Error, OFF);
1319 @end smallexample
1320
1321 @noindent
1322 is given, then subsequent @code{Check} pragmas whose first argument is also
1323 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1324 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1325 @code{Check_Policy} with this identifier is similar to the normal
1326 @code{Assertion_Policy} pragma except that it can appear within a
1327 declarative part).
1328
1329 The special identifiers @code{Precondition} and @code{Postcondition} control
1330 the status of preconditions and postconditions. If a @code{Precondition} pragma
1331 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1332 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1333 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1334 are recognized.
1335
1336 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1337 to turn on corresponding checks. The default for a set of checks for which no
1338 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1339 @option{-gnata} is given, which turns on all checks by default.
1340
1341 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1342 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1343 compatibility with the standard @code{Assertion_Policy} pragma.
1344
1345 The implementation defined policy @code{DISABLE} is like
1346 @code{OFF} except that it completely disables semantic
1347 checking of the argument to the corresponding class of
1348 pragmas. This may be useful when the pragma arguments reference
1349 subprograms in a with'ed package which is replaced by a dummy package
1350 for the final build.
1351
1352 @node Pragma Comment
1353 @unnumberedsec Pragma Comment
1354 @findex Comment
1355 @noindent
1356 Syntax:
1357
1358 @smallexample @c ada
1359 pragma Comment (static_string_EXPRESSION);
1360 @end smallexample
1361
1362 @noindent
1363 This is almost identical in effect to pragma @code{Ident}. It allows the
1364 placement of a comment into the object file and hence into the
1365 executable file if the operating system permits such usage. The
1366 difference is that @code{Comment}, unlike @code{Ident}, has
1367 no limitations on placement of the pragma (it can be placed
1368 anywhere in the main source unit), and if more than one pragma
1369 is used, all comments are retained.
1370
1371 @node Pragma Common_Object
1372 @unnumberedsec Pragma Common_Object
1373 @findex Common_Object
1374 @noindent
1375 Syntax:
1376
1377 @smallexample @c ada
1378 pragma Common_Object (
1379 [Internal =>] LOCAL_NAME
1380 [, [External =>] EXTERNAL_SYMBOL]
1381 [, [Size =>] EXTERNAL_SYMBOL] );
1382
1383 EXTERNAL_SYMBOL ::=
1384 IDENTIFIER
1385 | static_string_EXPRESSION
1386 @end smallexample
1387
1388 @noindent
1389 This pragma enables the shared use of variables stored in overlaid
1390 linker areas corresponding to the use of @code{COMMON}
1391 in Fortran. The single
1392 object @var{LOCAL_NAME} is assigned to the area designated by
1393 the @var{External} argument.
1394 You may define a record to correspond to a series
1395 of fields. The @var{Size} argument
1396 is syntax checked in GNAT, but otherwise ignored.
1397
1398 @code{Common_Object} is not supported on all platforms. If no
1399 support is available, then the code generator will issue a message
1400 indicating that the necessary attribute for implementation of this
1401 pragma is not available.
1402
1403 @node Pragma Compile_Time_Error
1404 @unnumberedsec Pragma Compile_Time_Error
1405 @findex Compile_Time_Error
1406 @noindent
1407 Syntax:
1408
1409 @smallexample @c ada
1410 pragma Compile_Time_Error
1411 (boolean_EXPRESSION, static_string_EXPRESSION);
1412 @end smallexample
1413
1414 @noindent
1415 This pragma can be used to generate additional compile time
1416 error messages. It
1417 is particularly useful in generics, where errors can be issued for
1418 specific problematic instantiations. The first parameter is a boolean
1419 expression. The pragma is effective only if the value of this expression
1420 is known at compile time, and has the value True. The set of expressions
1421 whose values are known at compile time includes all static boolean
1422 expressions, and also other values which the compiler can determine
1423 at compile time (e.g., the size of a record type set by an explicit
1424 size representation clause, or the value of a variable which was
1425 initialized to a constant and is known not to have been modified).
1426 If these conditions are met, an error message is generated using
1427 the value given as the second argument. This string value may contain
1428 embedded ASCII.LF characters to break the message into multiple lines.
1429
1430 @node Pragma Compile_Time_Warning
1431 @unnumberedsec Pragma Compile_Time_Warning
1432 @findex Compile_Time_Warning
1433 @noindent
1434 Syntax:
1435
1436 @smallexample @c ada
1437 pragma Compile_Time_Warning
1438 (boolean_EXPRESSION, static_string_EXPRESSION);
1439 @end smallexample
1440
1441 @noindent
1442 Same as pragma Compile_Time_Error, except a warning is issued instead
1443 of an error message. Note that if this pragma is used in a package that
1444 is with'ed by a client, the client will get the warning even though it
1445 is issued by a with'ed package (normally warnings in with'ed units are
1446 suppressed, but this is a special exception to that rule).
1447
1448 One typical use is within a generic where compile time known characteristics
1449 of formal parameters are tested, and warnings given appropriately. Another use
1450 with a first parameter of True is to warn a client about use of a package,
1451 for example that it is not fully implemented.
1452
1453 @node Pragma Compiler_Unit
1454 @unnumberedsec Pragma Compiler_Unit
1455 @findex Compiler_Unit
1456 @noindent
1457 Syntax:
1458
1459 @smallexample @c ada
1460 pragma Compiler_Unit;
1461 @end smallexample
1462
1463 @noindent
1464 This pragma is intended only for internal use in the GNAT run-time library.
1465 It indicates that the unit is used as part of the compiler build. The effect
1466 is to disallow constructs (raise with message, conditional expressions etc)
1467 that would cause trouble when bootstrapping using an older version of GNAT.
1468 For the exact list of restrictions, see the compiler sources and references
1469 to Is_Compiler_Unit.
1470
1471 @node Pragma Complete_Representation
1472 @unnumberedsec Pragma Complete_Representation
1473 @findex Complete_Representation
1474 @noindent
1475 Syntax:
1476
1477 @smallexample @c ada
1478 pragma Complete_Representation;
1479 @end smallexample
1480
1481 @noindent
1482 This pragma must appear immediately within a record representation
1483 clause. Typical placements are before the first component clause
1484 or after the last component clause. The effect is to give an error
1485 message if any component is missing a component clause. This pragma
1486 may be used to ensure that a record representation clause is
1487 complete, and that this invariant is maintained if fields are
1488 added to the record in the future.
1489
1490 @node Pragma Complex_Representation
1491 @unnumberedsec Pragma Complex_Representation
1492 @findex Complex_Representation
1493 @noindent
1494 Syntax:
1495
1496 @smallexample @c ada
1497 pragma Complex_Representation
1498 ([Entity =>] LOCAL_NAME);
1499 @end smallexample
1500
1501 @noindent
1502 The @var{Entity} argument must be the name of a record type which has
1503 two fields of the same floating-point type. The effect of this pragma is
1504 to force gcc to use the special internal complex representation form for
1505 this record, which may be more efficient. Note that this may result in
1506 the code for this type not conforming to standard ABI (application
1507 binary interface) requirements for the handling of record types. For
1508 example, in some environments, there is a requirement for passing
1509 records by pointer, and the use of this pragma may result in passing
1510 this type in floating-point registers.
1511
1512 @node Pragma Component_Alignment
1513 @unnumberedsec Pragma Component_Alignment
1514 @cindex Alignments of components
1515 @findex Component_Alignment
1516 @noindent
1517 Syntax:
1518
1519 @smallexample @c ada
1520 pragma Component_Alignment (
1521 [Form =>] ALIGNMENT_CHOICE
1522 [, [Name =>] type_LOCAL_NAME]);
1523
1524 ALIGNMENT_CHOICE ::=
1525 Component_Size
1526 | Component_Size_4
1527 | Storage_Unit
1528 | Default
1529 @end smallexample
1530
1531 @noindent
1532 Specifies the alignment of components in array or record types.
1533 The meaning of the @var{Form} argument is as follows:
1534
1535 @table @code
1536 @findex Component_Size
1537 @item Component_Size
1538 Aligns scalar components and subcomponents of the array or record type
1539 on boundaries appropriate to their inherent size (naturally
1540 aligned). For example, 1-byte components are aligned on byte boundaries,
1541 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1542 integer components are aligned on 4-byte boundaries and so on. These
1543 alignment rules correspond to the normal rules for C compilers on all
1544 machines except the VAX@.
1545
1546 @findex Component_Size_4
1547 @item Component_Size_4
1548 Naturally aligns components with a size of four or fewer
1549 bytes. Components that are larger than 4 bytes are placed on the next
1550 4-byte boundary.
1551
1552 @findex Storage_Unit
1553 @item Storage_Unit
1554 Specifies that array or record components are byte aligned, i.e.@:
1555 aligned on boundaries determined by the value of the constant
1556 @code{System.Storage_Unit}.
1557
1558 @cindex OpenVMS
1559 @item Default
1560 Specifies that array or record components are aligned on default
1561 boundaries, appropriate to the underlying hardware or operating system or
1562 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1563 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1564 the @code{Default} choice is the same as @code{Component_Size} (natural
1565 alignment).
1566 @end table
1567
1568 @noindent
1569 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1570 refer to a local record or array type, and the specified alignment
1571 choice applies to the specified type. The use of
1572 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1573 @code{Component_Alignment} pragma to be ignored. The use of
1574 @code{Component_Alignment} together with a record representation clause
1575 is only effective for fields not specified by the representation clause.
1576
1577 If the @code{Name} parameter is absent, the pragma can be used as either
1578 a configuration pragma, in which case it applies to one or more units in
1579 accordance with the normal rules for configuration pragmas, or it can be
1580 used within a declarative part, in which case it applies to types that
1581 are declared within this declarative part, or within any nested scope
1582 within this declarative part. In either case it specifies the alignment
1583 to be applied to any record or array type which has otherwise standard
1584 representation.
1585
1586 If the alignment for a record or array type is not specified (using
1587 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1588 clause), the GNAT uses the default alignment as described previously.
1589
1590 @node Pragma Convention_Identifier
1591 @unnumberedsec Pragma Convention_Identifier
1592 @findex Convention_Identifier
1593 @cindex Conventions, synonyms
1594 @noindent
1595 Syntax:
1596
1597 @smallexample @c ada
1598 pragma Convention_Identifier (
1599 [Name =>] IDENTIFIER,
1600 [Convention =>] convention_IDENTIFIER);
1601 @end smallexample
1602
1603 @noindent
1604 This pragma provides a mechanism for supplying synonyms for existing
1605 convention identifiers. The @code{Name} identifier can subsequently
1606 be used as a synonym for the given convention in other pragmas (including
1607 for example pragma @code{Import} or another @code{Convention_Identifier}
1608 pragma). As an example of the use of this, suppose you had legacy code
1609 which used Fortran77 as the identifier for Fortran. Then the pragma:
1610
1611 @smallexample @c ada
1612 pragma Convention_Identifier (Fortran77, Fortran);
1613 @end smallexample
1614
1615 @noindent
1616 would allow the use of the convention identifier @code{Fortran77} in
1617 subsequent code, avoiding the need to modify the sources. As another
1618 example, you could use this to parameterize convention requirements
1619 according to systems. Suppose you needed to use @code{Stdcall} on
1620 windows systems, and @code{C} on some other system, then you could
1621 define a convention identifier @code{Library} and use a single
1622 @code{Convention_Identifier} pragma to specify which convention
1623 would be used system-wide.
1624
1625 @node Pragma CPP_Class
1626 @unnumberedsec Pragma CPP_Class
1627 @findex CPP_Class
1628 @cindex Interfacing with C++
1629 @noindent
1630 Syntax:
1631
1632 @smallexample @c ada
1633 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1634 @end smallexample
1635
1636 @noindent
1637 The argument denotes an entity in the current declarative region that is
1638 declared as a record type. It indicates that the type corresponds to an
1639 externally declared C++ class type, and is to be laid out the same way
1640 that C++ would lay out the type. If the C++ class has virtual primitives
1641 then the record must be declared as a tagged record type.
1642
1643 Types for which @code{CPP_Class} is specified do not have assignment or
1644 equality operators defined (such operations can be imported or declared
1645 as subprograms as required). Initialization is allowed only by constructor
1646 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1647 limited if not explicitly declared as limited or derived from a limited
1648 type, and an error is issued in that case.
1649
1650 Pragma @code{CPP_Class} is intended primarily for automatic generation
1651 using an automatic binding generator tool.
1652 See @ref{Interfacing to C++} for related information.
1653
1654 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1655 for backward compatibility but its functionality is available
1656 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1657
1658 @node Pragma CPP_Constructor
1659 @unnumberedsec Pragma CPP_Constructor
1660 @cindex Interfacing with C++
1661 @findex CPP_Constructor
1662 @noindent
1663 Syntax:
1664
1665 @smallexample @c ada
1666 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1667 [, [External_Name =>] static_string_EXPRESSION ]
1668 [, [Link_Name =>] static_string_EXPRESSION ]);
1669 @end smallexample
1670
1671 @noindent
1672 This pragma identifies an imported function (imported in the usual way
1673 with pragma @code{Import}) as corresponding to a C++ constructor. If
1674 @code{External_Name} and @code{Link_Name} are not specified then the
1675 @code{Entity} argument is a name that must have been previously mentioned
1676 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1677 must be of one of the following forms:
1678
1679 @itemize @bullet
1680 @item
1681 @code{function @var{Fname} return @var{T}}
1682
1683 @itemize @bullet
1684 @item
1685 @code{function @var{Fname} return @var{T}'Class}
1686
1687 @item
1688 @code{function @var{Fname} (@dots{}) return @var{T}}
1689 @end itemize
1690
1691 @item
1692 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1693 @end itemize
1694
1695 @noindent
1696 where @var{T} is a limited record type imported from C++ with pragma
1697 @code{Import} and @code{Convention} = @code{CPP}.
1698
1699 The first two forms import the default constructor, used when an object
1700 of type @var{T} is created on the Ada side with no explicit constructor.
1701 The latter two forms cover all the non-default constructors of the type.
1702 See the GNAT users guide for details.
1703
1704 If no constructors are imported, it is impossible to create any objects
1705 on the Ada side and the type is implicitly declared abstract.
1706
1707 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1708 using an automatic binding generator tool.
1709 See @ref{Interfacing to C++} for more related information.
1710
1711 Note: The use of functions returning class-wide types for constructors is
1712 currently obsolete. They are supported for backward compatibility. The
1713 use of functions returning the type T leave the Ada sources more clear
1714 because the imported C++ constructors always return an object of type T;
1715 that is, they never return an object whose type is a descendant of type T.
1716
1717 @node Pragma CPP_Virtual
1718 @unnumberedsec Pragma CPP_Virtual
1719 @cindex Interfacing to C++
1720 @findex CPP_Virtual
1721 @noindent
1722 This pragma is now obsolete has has no effect because GNAT generates
1723 the same object layout than the G++ compiler.
1724
1725 See @ref{Interfacing to C++} for related information.
1726
1727 @node Pragma CPP_Vtable
1728 @unnumberedsec Pragma CPP_Vtable
1729 @cindex Interfacing with C++
1730 @findex CPP_Vtable
1731 @noindent
1732 This pragma is now obsolete has has no effect because GNAT generates
1733 the same object layout than the G++ compiler.
1734
1735 See @ref{Interfacing to C++} for related information.
1736
1737 @node Pragma Debug
1738 @unnumberedsec Pragma Debug
1739 @findex Debug
1740 @noindent
1741 Syntax:
1742
1743 @smallexample @c ada
1744 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1745
1746 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1747 PROCEDURE_NAME
1748 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1749 @end smallexample
1750
1751 @noindent
1752 The procedure call argument has the syntactic form of an expression, meeting
1753 the syntactic requirements for pragmas.
1754
1755 If debug pragmas are not enabled or if the condition is present and evaluates
1756 to False, this pragma has no effect. If debug pragmas are enabled, the
1757 semantics of the pragma is exactly equivalent to the procedure call statement
1758 corresponding to the argument with a terminating semicolon. Pragmas are
1759 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1760 intersperse calls to debug procedures in the middle of declarations. Debug
1761 pragmas can be enabled either by use of the command line switch @option{-gnata}
1762 or by use of the configuration pragma @code{Debug_Policy}.
1763
1764 @node Pragma Debug_Policy
1765 @unnumberedsec Pragma Debug_Policy
1766 @findex Debug_Policy
1767 @noindent
1768 Syntax:
1769
1770 @smallexample @c ada
1771 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1772 @end smallexample
1773
1774 @noindent
1775 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1776 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1777 This pragma overrides the effect of the @option{-gnata} switch on the
1778 command line.
1779
1780 The implementation defined policy @code{DISABLE} is like
1781 @code{IGNORE} except that it completely disables semantic
1782 checking of the argument to @code{pragma Debug}. This may
1783 be useful when the pragma argument references subprograms
1784 in a with'ed package which is replaced by a dummy package
1785 for the final build.
1786
1787 @node Pragma Detect_Blocking
1788 @unnumberedsec Pragma Detect_Blocking
1789 @findex Detect_Blocking
1790 @noindent
1791 Syntax:
1792
1793 @smallexample @c ada
1794 pragma Detect_Blocking;
1795 @end smallexample
1796
1797 @noindent
1798 This is a configuration pragma that forces the detection of potentially
1799 blocking operations within a protected operation, and to raise Program_Error
1800 if that happens.
1801
1802 @node Pragma Elaboration_Checks
1803 @unnumberedsec Pragma Elaboration_Checks
1804 @cindex Elaboration control
1805 @findex Elaboration_Checks
1806 @noindent
1807 Syntax:
1808
1809 @smallexample @c ada
1810 pragma Elaboration_Checks (Dynamic | Static);
1811 @end smallexample
1812
1813 @noindent
1814 This is a configuration pragma that provides control over the
1815 elaboration model used by the compilation affected by the
1816 pragma. If the parameter is @code{Dynamic},
1817 then the dynamic elaboration
1818 model described in the Ada Reference Manual is used, as though
1819 the @option{-gnatE} switch had been specified on the command
1820 line. If the parameter is @code{Static}, then the default GNAT static
1821 model is used. This configuration pragma overrides the setting
1822 of the command line. For full details on the elaboration models
1823 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1824 gnat_ugn, @value{EDITION} User's Guide}.
1825
1826 @node Pragma Eliminate
1827 @unnumberedsec Pragma Eliminate
1828 @cindex Elimination of unused subprograms
1829 @findex Eliminate
1830 @noindent
1831 Syntax:
1832
1833 @smallexample @c ada
1834 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
1835 [Source_Location =>] STRING_LITERAL);
1836 @end smallexample
1837
1838 @noindent
1839 The string literal given for the source location is a string which
1840 specifies the line number of the occurrence of the entity, using
1841 the syntax for SOURCE_TRACE given below:
1842
1843 @smallexample @c ada
1844 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1845
1846 LBRACKET ::= [
1847 RBRACKET ::= ]
1848
1849 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1850
1851 LINE_NUMBER ::= DIGIT @{DIGIT@}
1852 @end smallexample
1853
1854 @noindent
1855 Spaces around the colon in a @code{Source_Reference} are optional.
1856
1857 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1858 explicit subprogram declaration, where the @code{entity} name in this
1859 designator appears on the source line specified by the source location.
1860
1861 The source trace that is given as the @code{Source_Location} shall obey the
1862 following rules. The @code{FILE_NAME} is the short name (with no directory
1863 information) of an Ada source file, given using exactly the required syntax
1864 for the underlying file system (e.g. case is important if the underlying
1865 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1866 number of the occurrence of the @code{entity}
1867 as a decimal literal without an exponent or point. If an @code{entity} is not
1868 declared in a generic instantiation (this includes generic subprogram
1869 instances), the source trace includes only one source reference. If an entity
1870 is declared inside a generic instantiation, its source trace (when parsing
1871 from left to right) starts with the source location of the declaration of the
1872 entity in the generic unit and ends with the source location of the
1873 instantiation (it is given in square brackets). This approach is recursively
1874 used in case of nested instantiations: the rightmost (nested most deeply in
1875 square brackets) element of the source trace is the location of the outermost
1876 instantiation, the next to left element is the location of the next (first
1877 nested) instantiation in the code of the corresponding generic unit, and so
1878 on, and the leftmost element (that is out of any square brackets) is the
1879 location of the declaration of the entity to eliminate in a generic unit.
1880
1881 Note that the @code{Source_Location} argument specifies which of a set of
1882 similarly named entities is being eliminated, dealing both with overloading,
1883 and also appearence of the same entity name in different scopes.
1884
1885 This pragma indicates that the given entity is not used in the program to be
1886 compiled and built. The effect of the pragma is to allow the compiler to
1887 eliminate the code or data associated with the named entity. Any reference to
1888 an eliminated entity causes a compile-time or link-time error.
1889
1890 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1891 in a system-independent manner, with unused entities eliminated, without
1892 needing to modify the source text. Normally the required set of
1893 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1894
1895 Any source file change that removes, splits, or
1896 adds lines may make the set of Eliminate pragmas invalid because their
1897 @code{Source_Location} argument values may get out of date.
1898
1899 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
1900 operation. In this case all the subprograms to which the given operation can
1901 dispatch are considered to be unused (are never called as a result of a direct
1902 or a dispatching call).
1903
1904 @node Pragma Export_Exception
1905 @unnumberedsec Pragma Export_Exception
1906 @cindex OpenVMS
1907 @findex Export_Exception
1908 @noindent
1909 Syntax:
1910
1911 @smallexample @c ada
1912 pragma Export_Exception (
1913 [Internal =>] LOCAL_NAME
1914 [, [External =>] EXTERNAL_SYMBOL]
1915 [, [Form =>] Ada | VMS]
1916 [, [Code =>] static_integer_EXPRESSION]);
1917
1918 EXTERNAL_SYMBOL ::=
1919 IDENTIFIER
1920 | static_string_EXPRESSION
1921 @end smallexample
1922
1923 @noindent
1924 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
1925 causes the specified exception to be propagated outside of the Ada program,
1926 so that it can be handled by programs written in other OpenVMS languages.
1927 This pragma establishes an external name for an Ada exception and makes the
1928 name available to the OpenVMS Linker as a global symbol. For further details
1929 on this pragma, see the
1930 DEC Ada Language Reference Manual, section 13.9a3.2.
1931
1932 @node Pragma Export_Function
1933 @unnumberedsec Pragma Export_Function
1934 @cindex Argument passing mechanisms
1935 @findex Export_Function
1936
1937 @noindent
1938 Syntax:
1939
1940 @smallexample @c ada
1941 pragma Export_Function (
1942 [Internal =>] LOCAL_NAME
1943 [, [External =>] EXTERNAL_SYMBOL]
1944 [, [Parameter_Types =>] PARAMETER_TYPES]
1945 [, [Result_Type =>] result_SUBTYPE_MARK]
1946 [, [Mechanism =>] MECHANISM]
1947 [, [Result_Mechanism =>] MECHANISM_NAME]);
1948
1949 EXTERNAL_SYMBOL ::=
1950 IDENTIFIER
1951 | static_string_EXPRESSION
1952 | ""
1953
1954 PARAMETER_TYPES ::=
1955 null
1956 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1957
1958 TYPE_DESIGNATOR ::=
1959 subtype_NAME
1960 | subtype_Name ' Access
1961
1962 MECHANISM ::=
1963 MECHANISM_NAME
1964 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1965
1966 MECHANISM_ASSOCIATION ::=
1967 [formal_parameter_NAME =>] MECHANISM_NAME
1968
1969 MECHANISM_NAME ::=
1970 Value
1971 | Reference
1972 | Descriptor [([Class =>] CLASS_NAME)]
1973 | Short_Descriptor [([Class =>] CLASS_NAME)]
1974
1975 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1976 @end smallexample
1977
1978 @noindent
1979 Use this pragma to make a function externally callable and optionally
1980 provide information on mechanisms to be used for passing parameter and
1981 result values. We recommend, for the purposes of improving portability,
1982 this pragma always be used in conjunction with a separate pragma
1983 @code{Export}, which must precede the pragma @code{Export_Function}.
1984 GNAT does not require a separate pragma @code{Export}, but if none is
1985 present, @code{Convention Ada} is assumed, which is usually
1986 not what is wanted, so it is usually appropriate to use this
1987 pragma in conjunction with a @code{Export} or @code{Convention}
1988 pragma that specifies the desired foreign convention.
1989 Pragma @code{Export_Function}
1990 (and @code{Export}, if present) must appear in the same declarative
1991 region as the function to which they apply.
1992
1993 @var{internal_name} must uniquely designate the function to which the
1994 pragma applies. If more than one function name exists of this name in
1995 the declarative part you must use the @code{Parameter_Types} and
1996 @code{Result_Type} parameters is mandatory to achieve the required
1997 unique designation. @var{subtype_mark}s in these parameters must
1998 exactly match the subtypes in the corresponding function specification,
1999 using positional notation to match parameters with subtype marks.
2000 The form with an @code{'Access} attribute can be used to match an
2001 anonymous access parameter.
2002
2003 @cindex OpenVMS
2004 @cindex Passing by descriptor
2005 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2006 The default behavior for Export_Function is to accept either 64bit or
2007 32bit descriptors unless short_descriptor is specified, then only 32bit
2008 descriptors are accepted.
2009
2010 @cindex Suppressing external name
2011 Special treatment is given if the EXTERNAL is an explicit null
2012 string or a static string expressions that evaluates to the null
2013 string. In this case, no external name is generated. This form
2014 still allows the specification of parameter mechanisms.
2015
2016 @node Pragma Export_Object
2017 @unnumberedsec Pragma Export_Object
2018 @findex Export_Object
2019 @noindent
2020 Syntax:
2021
2022 @smallexample @c ada
2023 pragma Export_Object
2024 [Internal =>] LOCAL_NAME
2025 [, [External =>] EXTERNAL_SYMBOL]
2026 [, [Size =>] EXTERNAL_SYMBOL]
2027
2028 EXTERNAL_SYMBOL ::=
2029 IDENTIFIER
2030 | static_string_EXPRESSION
2031 @end smallexample
2032
2033 @noindent
2034 This pragma designates an object as exported, and apart from the
2035 extended rules for external symbols, is identical in effect to the use of
2036 the normal @code{Export} pragma applied to an object. You may use a
2037 separate Export pragma (and you probably should from the point of view
2038 of portability), but it is not required. @var{Size} is syntax checked,
2039 but otherwise ignored by GNAT@.
2040
2041 @node Pragma Export_Procedure
2042 @unnumberedsec Pragma Export_Procedure
2043 @findex Export_Procedure
2044 @noindent
2045 Syntax:
2046
2047 @smallexample @c ada
2048 pragma Export_Procedure (
2049 [Internal =>] LOCAL_NAME
2050 [, [External =>] EXTERNAL_SYMBOL]
2051 [, [Parameter_Types =>] PARAMETER_TYPES]
2052 [, [Mechanism =>] MECHANISM]);
2053
2054 EXTERNAL_SYMBOL ::=
2055 IDENTIFIER
2056 | static_string_EXPRESSION
2057 | ""
2058
2059 PARAMETER_TYPES ::=
2060 null
2061 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2062
2063 TYPE_DESIGNATOR ::=
2064 subtype_NAME
2065 | subtype_Name ' Access
2066
2067 MECHANISM ::=
2068 MECHANISM_NAME
2069 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2070
2071 MECHANISM_ASSOCIATION ::=
2072 [formal_parameter_NAME =>] MECHANISM_NAME
2073
2074 MECHANISM_NAME ::=
2075 Value
2076 | Reference
2077 | Descriptor [([Class =>] CLASS_NAME)]
2078 | Short_Descriptor [([Class =>] CLASS_NAME)]
2079
2080 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2081 @end smallexample
2082
2083 @noindent
2084 This pragma is identical to @code{Export_Function} except that it
2085 applies to a procedure rather than a function and the parameters
2086 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2087 GNAT does not require a separate pragma @code{Export}, but if none is
2088 present, @code{Convention Ada} is assumed, which is usually
2089 not what is wanted, so it is usually appropriate to use this
2090 pragma in conjunction with a @code{Export} or @code{Convention}
2091 pragma that specifies the desired foreign convention.
2092
2093 @cindex OpenVMS
2094 @cindex Passing by descriptor
2095 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2096 The default behavior for Export_Procedure is to accept either 64bit or
2097 32bit descriptors unless short_descriptor is specified, then only 32bit
2098 descriptors are accepted.
2099
2100 @cindex Suppressing external name
2101 Special treatment is given if the EXTERNAL is an explicit null
2102 string or a static string expressions that evaluates to the null
2103 string. In this case, no external name is generated. This form
2104 still allows the specification of parameter mechanisms.
2105
2106 @node Pragma Export_Value
2107 @unnumberedsec Pragma Export_Value
2108 @findex Export_Value
2109 @noindent
2110 Syntax:
2111
2112 @smallexample @c ada
2113 pragma Export_Value (
2114 [Value =>] static_integer_EXPRESSION,
2115 [Link_Name =>] static_string_EXPRESSION);
2116 @end smallexample
2117
2118 @noindent
2119 This pragma serves to export a static integer value for external use.
2120 The first argument specifies the value to be exported. The Link_Name
2121 argument specifies the symbolic name to be associated with the integer
2122 value. This pragma is useful for defining a named static value in Ada
2123 that can be referenced in assembly language units to be linked with
2124 the application. This pragma is currently supported only for the
2125 AAMP target and is ignored for other targets.
2126
2127 @node Pragma Export_Valued_Procedure
2128 @unnumberedsec Pragma Export_Valued_Procedure
2129 @findex Export_Valued_Procedure
2130 @noindent
2131 Syntax:
2132
2133 @smallexample @c ada
2134 pragma Export_Valued_Procedure (
2135 [Internal =>] LOCAL_NAME
2136 [, [External =>] EXTERNAL_SYMBOL]
2137 [, [Parameter_Types =>] PARAMETER_TYPES]
2138 [, [Mechanism =>] MECHANISM]);
2139
2140 EXTERNAL_SYMBOL ::=
2141 IDENTIFIER
2142 | static_string_EXPRESSION
2143 | ""
2144
2145 PARAMETER_TYPES ::=
2146 null
2147 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2148
2149 TYPE_DESIGNATOR ::=
2150 subtype_NAME
2151 | subtype_Name ' Access
2152
2153 MECHANISM ::=
2154 MECHANISM_NAME
2155 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2156
2157 MECHANISM_ASSOCIATION ::=
2158 [formal_parameter_NAME =>] MECHANISM_NAME
2159
2160 MECHANISM_NAME ::=
2161 Value
2162 | Reference
2163 | Descriptor [([Class =>] CLASS_NAME)]
2164 | Short_Descriptor [([Class =>] CLASS_NAME)]
2165
2166 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2167 @end smallexample
2168
2169 @noindent
2170 This pragma is identical to @code{Export_Procedure} except that the
2171 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2172 mode @code{OUT}, and externally the subprogram is treated as a function
2173 with this parameter as the result of the function. GNAT provides for
2174 this capability to allow the use of @code{OUT} and @code{IN OUT}
2175 parameters in interfacing to external functions (which are not permitted
2176 in Ada functions).
2177 GNAT does not require a separate pragma @code{Export}, but if none is
2178 present, @code{Convention Ada} is assumed, which is almost certainly
2179 not what is wanted since the whole point of this pragma is to interface
2180 with foreign language functions, so it is usually appropriate to use this
2181 pragma in conjunction with a @code{Export} or @code{Convention}
2182 pragma that specifies the desired foreign convention.
2183
2184 @cindex OpenVMS
2185 @cindex Passing by descriptor
2186 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2187 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2188 32bit descriptors unless short_descriptor is specified, then only 32bit
2189 descriptors are accepted.
2190
2191 @cindex Suppressing external name
2192 Special treatment is given if the EXTERNAL is an explicit null
2193 string or a static string expressions that evaluates to the null
2194 string. In this case, no external name is generated. This form
2195 still allows the specification of parameter mechanisms.
2196
2197 @node Pragma Extend_System
2198 @unnumberedsec Pragma Extend_System
2199 @cindex @code{system}, extending
2200 @cindex Dec Ada 83
2201 @findex Extend_System
2202 @noindent
2203 Syntax:
2204
2205 @smallexample @c ada
2206 pragma Extend_System ([Name =>] IDENTIFIER);
2207 @end smallexample
2208
2209 @noindent
2210 This pragma is used to provide backwards compatibility with other
2211 implementations that extend the facilities of package @code{System}. In
2212 GNAT, @code{System} contains only the definitions that are present in
2213 the Ada RM@. However, other implementations, notably the DEC Ada 83
2214 implementation, provide many extensions to package @code{System}.
2215
2216 For each such implementation accommodated by this pragma, GNAT provides a
2217 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2218 implementation, which provides the required additional definitions. You
2219 can use this package in two ways. You can @code{with} it in the normal
2220 way and access entities either by selection or using a @code{use}
2221 clause. In this case no special processing is required.
2222
2223 However, if existing code contains references such as
2224 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2225 definitions provided in package @code{System}, you may use this pragma
2226 to extend visibility in @code{System} in a non-standard way that
2227 provides greater compatibility with the existing code. Pragma
2228 @code{Extend_System} is a configuration pragma whose single argument is
2229 the name of the package containing the extended definition
2230 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2231 control of this pragma will be processed using special visibility
2232 processing that looks in package @code{System.Aux_@var{xxx}} where
2233 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2234 package @code{System}, but not found in package @code{System}.
2235
2236 You can use this pragma either to access a predefined @code{System}
2237 extension supplied with the compiler, for example @code{Aux_DEC} or
2238 you can construct your own extension unit following the above
2239 definition. Note that such a package is a child of @code{System}
2240 and thus is considered part of the implementation. To compile
2241 it you will have to use the appropriate switch for compiling
2242 system units.
2243 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2244 for details.
2245
2246 @node Pragma Extensions_Allowed
2247 @unnumberedsec Pragma Extensions_Allowed
2248 @cindex Ada Extensions
2249 @cindex GNAT Extensions
2250 @findex Extensions_Allowed
2251 @noindent
2252 Syntax:
2253
2254 @smallexample @c ada
2255 pragma Extensions_Allowed (On | Off);
2256 @end smallexample
2257
2258 @noindent
2259 This configuration pragma enables or disables the implementation
2260 extension mode (the use of Off as a parameter cancels the effect
2261 of the @option{-gnatX} command switch).
2262
2263 In extension mode, the latest version of the Ada language is
2264 implemented (currently Ada 2012), and in addition a small number
2265 of GNAT specific extensions are recognized as follows:
2266
2267 @table @asis
2268 @item Constrained attribute for generic objects
2269 The @code{Constrained} attribute is permitted for objects of
2270 generic types. The result indicates if the corresponding actual
2271 is constrained.
2272
2273 @end table
2274
2275 @node Pragma External
2276 @unnumberedsec Pragma External
2277 @findex External
2278 @noindent
2279 Syntax:
2280
2281 @smallexample @c ada
2282 pragma External (
2283 [ Convention =>] convention_IDENTIFIER,
2284 [ Entity =>] LOCAL_NAME
2285 [, [External_Name =>] static_string_EXPRESSION ]
2286 [, [Link_Name =>] static_string_EXPRESSION ]);
2287 @end smallexample
2288
2289 @noindent
2290 This pragma is identical in syntax and semantics to pragma
2291 @code{Export} as defined in the Ada Reference Manual. It is
2292 provided for compatibility with some Ada 83 compilers that
2293 used this pragma for exactly the same purposes as pragma
2294 @code{Export} before the latter was standardized.
2295
2296 @node Pragma External_Name_Casing
2297 @unnumberedsec Pragma External_Name_Casing
2298 @cindex Dec Ada 83 casing compatibility
2299 @cindex External Names, casing
2300 @cindex Casing of External names
2301 @findex External_Name_Casing
2302 @noindent
2303 Syntax:
2304
2305 @smallexample @c ada
2306 pragma External_Name_Casing (
2307 Uppercase | Lowercase
2308 [, Uppercase | Lowercase | As_Is]);
2309 @end smallexample
2310
2311 @noindent
2312 This pragma provides control over the casing of external names associated
2313 with Import and Export pragmas. There are two cases to consider:
2314
2315 @table @asis
2316 @item Implicit external names
2317 Implicit external names are derived from identifiers. The most common case
2318 arises when a standard Ada Import or Export pragma is used with only two
2319 arguments, as in:
2320
2321 @smallexample @c ada
2322 pragma Import (C, C_Routine);
2323 @end smallexample
2324
2325 @noindent
2326 Since Ada is a case-insensitive language, the spelling of the identifier in
2327 the Ada source program does not provide any information on the desired
2328 casing of the external name, and so a convention is needed. In GNAT the
2329 default treatment is that such names are converted to all lower case
2330 letters. This corresponds to the normal C style in many environments.
2331 The first argument of pragma @code{External_Name_Casing} can be used to
2332 control this treatment. If @code{Uppercase} is specified, then the name
2333 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2334 then the normal default of all lower case letters will be used.
2335
2336 This same implicit treatment is also used in the case of extended DEC Ada 83
2337 compatible Import and Export pragmas where an external name is explicitly
2338 specified using an identifier rather than a string.
2339
2340 @item Explicit external names
2341 Explicit external names are given as string literals. The most common case
2342 arises when a standard Ada Import or Export pragma is used with three
2343 arguments, as in:
2344
2345 @smallexample @c ada
2346 pragma Import (C, C_Routine, "C_routine");
2347 @end smallexample
2348
2349 @noindent
2350 In this case, the string literal normally provides the exact casing required
2351 for the external name. The second argument of pragma
2352 @code{External_Name_Casing} may be used to modify this behavior.
2353 If @code{Uppercase} is specified, then the name
2354 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2355 then the name will be forced to all lowercase letters. A specification of
2356 @code{As_Is} provides the normal default behavior in which the casing is
2357 taken from the string provided.
2358 @end table
2359
2360 @noindent
2361 This pragma may appear anywhere that a pragma is valid. In particular, it
2362 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2363 case it applies to all subsequent compilations, or it can be used as a program
2364 unit pragma, in which case it only applies to the current unit, or it can
2365 be used more locally to control individual Import/Export pragmas.
2366
2367 It is primarily intended for use with OpenVMS systems, where many
2368 compilers convert all symbols to upper case by default. For interfacing to
2369 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2370 the pragma:
2371
2372 @smallexample @c ada
2373 pragma External_Name_Casing (Uppercase, Uppercase);
2374 @end smallexample
2375
2376 @noindent
2377 to enforce the upper casing of all external symbols.
2378
2379 @node Pragma Fast_Math
2380 @unnumberedsec Pragma Fast_Math
2381 @findex Fast_Math
2382 @noindent
2383 Syntax:
2384
2385 @smallexample @c ada
2386 pragma Fast_Math;
2387 @end smallexample
2388
2389 @noindent
2390 This is a configuration pragma which activates a mode in which speed is
2391 considered more important for floating-point operations than absolutely
2392 accurate adherence to the requirements of the standard. Currently the
2393 following operations are affected:
2394
2395 @table @asis
2396 @item Complex Multiplication
2397 The normal simple formula for complex multiplication can result in intermediate
2398 overflows for numbers near the end of the range. The Ada standard requires that
2399 this situation be detected and corrected by scaling, but in Fast_Math mode such
2400 cases will simply result in overflow. Note that to take advantage of this you
2401 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2402 under control of the pragma, rather than use the preinstantiated versions.
2403 @end table
2404
2405 @node Pragma Favor_Top_Level
2406 @unnumberedsec Pragma Favor_Top_Level
2407 @findex Favor_Top_Level
2408 @noindent
2409 Syntax:
2410
2411 @smallexample @c ada
2412 pragma Favor_Top_Level (type_NAME);
2413 @end smallexample
2414
2415 @noindent
2416 The named type must be an access-to-subprogram type. This pragma is an
2417 efficiency hint to the compiler, regarding the use of 'Access or
2418 'Unrestricted_Access on nested (non-library-level) subprograms. The
2419 pragma means that nested subprograms are not used with this type, or
2420 are rare, so that the generated code should be efficient in the
2421 top-level case. When this pragma is used, dynamically generated
2422 trampolines may be used on some targets for nested subprograms.
2423 See also the No_Implicit_Dynamic_Code restriction.
2424
2425 @node Pragma Finalize_Storage_Only
2426 @unnumberedsec Pragma Finalize_Storage_Only
2427 @findex Finalize_Storage_Only
2428 @noindent
2429 Syntax:
2430
2431 @smallexample @c ada
2432 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2433 @end smallexample
2434
2435 @noindent
2436 This pragma allows the compiler not to emit a Finalize call for objects
2437 defined at the library level. This is mostly useful for types where
2438 finalization is only used to deal with storage reclamation since in most
2439 environments it is not necessary to reclaim memory just before terminating
2440 execution, hence the name.
2441
2442 @node Pragma Float_Representation
2443 @unnumberedsec Pragma Float_Representation
2444 @cindex OpenVMS
2445 @findex Float_Representation
2446 @noindent
2447 Syntax:
2448
2449 @smallexample @c ada
2450 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2451
2452 FLOAT_REP ::= VAX_Float | IEEE_Float
2453 @end smallexample
2454
2455 @noindent
2456 In the one argument form, this pragma is a configuration pragma which
2457 allows control over the internal representation chosen for the predefined
2458 floating point types declared in the packages @code{Standard} and
2459 @code{System}. On all systems other than OpenVMS, the argument must
2460 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2461 argument may be @code{VAX_Float} to specify the use of the VAX float
2462 format for the floating-point types in Standard. This requires that
2463 the standard runtime libraries be recompiled.
2464
2465 The two argument form specifies the representation to be used for
2466 the specified floating-point type. On all systems other than OpenVMS,
2467 the argument must
2468 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2469 argument may be @code{VAX_Float} to specify the use of the VAX float
2470 format, as follows:
2471
2472 @itemize @bullet
2473 @item
2474 For digits values up to 6, F float format will be used.
2475 @item
2476 For digits values from 7 to 9, D float format will be used.
2477 @item
2478 For digits values from 10 to 15, G float format will be used.
2479 @item
2480 Digits values above 15 are not allowed.
2481 @end itemize
2482
2483 @node Pragma Ident
2484 @unnumberedsec Pragma Ident
2485 @findex Ident
2486 @noindent
2487 Syntax:
2488
2489 @smallexample @c ada
2490 pragma Ident (static_string_EXPRESSION);
2491 @end smallexample
2492
2493 @noindent
2494 This pragma provides a string identification in the generated object file,
2495 if the system supports the concept of this kind of identification string.
2496 This pragma is allowed only in the outermost declarative part or
2497 declarative items of a compilation unit. If more than one @code{Ident}
2498 pragma is given, only the last one processed is effective.
2499 @cindex OpenVMS
2500 On OpenVMS systems, the effect of the pragma is identical to the effect of
2501 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2502 maximum allowed length is 31 characters, so if it is important to
2503 maintain compatibility with this compiler, you should obey this length
2504 limit.
2505
2506 @node Pragma Implemented
2507 @unnumberedsec Pragma Implemented
2508 @findex Implemented
2509 @noindent
2510 Syntax:
2511
2512 @smallexample @c ada
2513 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2514
2515 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2516 @end smallexample
2517
2518 @noindent
2519 This is an Ada 2012 representation pragma which applies to protected, task
2520 and synchronized interface primitives. The use of pragma Implemented provides
2521 a way to impose a static requirement on the overriding operation by adhering
2522 to one of the three implementation kids: entry, protected procedure or any of
2523 the above.
2524
2525 @smallexample @c ada
2526 type Synch_Iface is synchronized interface;
2527 procedure Prim_Op (Obj : in out Iface) is abstract;
2528 pragma Implemented (Prim_Op, By_Protected_Procedure);
2529
2530 protected type Prot_1 is new Synch_Iface with
2531 procedure Prim_Op; -- Legal
2532 end Prot_1;
2533
2534 protected type Prot_2 is new Synch_Iface with
2535 entry Prim_Op; -- Illegal
2536 end Prot_2;
2537
2538 task type Task_Typ is new Synch_Iface with
2539 entry Prim_Op; -- Illegal
2540 end Task_Typ;
2541 @end smallexample
2542
2543 @noindent
2544 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2545 Implemented determines the runtime behavior of the requeue. Implementation kind
2546 By_Entry guarantees that the action of requeueing will proceed from an entry to
2547 another entry. Implementation kind By_Protected_Procedure transforms the
2548 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2549 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2550 the target's overriding subprogram kind.
2551
2552 @node Pragma Implicit_Packing
2553 @unnumberedsec Pragma Implicit_Packing
2554 @findex Implicit_Packing
2555 @noindent
2556 Syntax:
2557
2558 @smallexample @c ada
2559 pragma Implicit_Packing;
2560 @end smallexample
2561
2562 @noindent
2563 This is a configuration pragma that requests implicit packing for packed
2564 arrays for which a size clause is given but no explicit pragma Pack or
2565 specification of Component_Size is present. It also applies to records
2566 where no record representation clause is present. Consider this example:
2567
2568 @smallexample @c ada
2569 type R is array (0 .. 7) of Boolean;
2570 for R'Size use 8;
2571 @end smallexample
2572
2573 @noindent
2574 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2575 does not change the layout of a composite object. So the Size clause in the
2576 above example is normally rejected, since the default layout of the array uses
2577 8-bit components, and thus the array requires a minimum of 64 bits.
2578
2579 If this declaration is compiled in a region of code covered by an occurrence
2580 of the configuration pragma Implicit_Packing, then the Size clause in this
2581 and similar examples will cause implicit packing and thus be accepted. For
2582 this implicit packing to occur, the type in question must be an array of small
2583 components whose size is known at compile time, and the Size clause must
2584 specify the exact size that corresponds to the length of the array multiplied
2585 by the size in bits of the component type.
2586 @cindex Array packing
2587
2588 Similarly, the following example shows the use in the record case
2589
2590 @smallexample @c ada
2591 type r is record
2592 a, b, c, d, e, f, g, h : boolean;
2593 chr : character;
2594 end record;
2595 for r'size use 16;
2596 @end smallexample
2597
2598 @noindent
2599 Without a pragma Pack, each Boolean field requires 8 bits, so the
2600 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2601 sufficient. The use of pragma Implicit_Packing allows this record
2602 declaration to compile without an explicit pragma Pack.
2603 @node Pragma Import_Exception
2604 @unnumberedsec Pragma Import_Exception
2605 @cindex OpenVMS
2606 @findex Import_Exception
2607 @noindent
2608 Syntax:
2609
2610 @smallexample @c ada
2611 pragma Import_Exception (
2612 [Internal =>] LOCAL_NAME
2613 [, [External =>] EXTERNAL_SYMBOL]
2614 [, [Form =>] Ada | VMS]
2615 [, [Code =>] static_integer_EXPRESSION]);
2616
2617 EXTERNAL_SYMBOL ::=
2618 IDENTIFIER
2619 | static_string_EXPRESSION
2620 @end smallexample
2621
2622 @noindent
2623 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2624 It allows OpenVMS conditions (for example, from OpenVMS system services or
2625 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2626 The pragma specifies that the exception associated with an exception
2627 declaration in an Ada program be defined externally (in non-Ada code).
2628 For further details on this pragma, see the
2629 DEC Ada Language Reference Manual, section 13.9a.3.1.
2630
2631 @node Pragma Import_Function
2632 @unnumberedsec Pragma Import_Function
2633 @findex Import_Function
2634 @noindent
2635 Syntax:
2636
2637 @smallexample @c ada
2638 pragma Import_Function (
2639 [Internal =>] LOCAL_NAME,
2640 [, [External =>] EXTERNAL_SYMBOL]
2641 [, [Parameter_Types =>] PARAMETER_TYPES]
2642 [, [Result_Type =>] SUBTYPE_MARK]
2643 [, [Mechanism =>] MECHANISM]
2644 [, [Result_Mechanism =>] MECHANISM_NAME]
2645 [, [First_Optional_Parameter =>] IDENTIFIER]);
2646
2647 EXTERNAL_SYMBOL ::=
2648 IDENTIFIER
2649 | static_string_EXPRESSION
2650
2651 PARAMETER_TYPES ::=
2652 null
2653 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2654
2655 TYPE_DESIGNATOR ::=
2656 subtype_NAME
2657 | subtype_Name ' Access
2658
2659 MECHANISM ::=
2660 MECHANISM_NAME
2661 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2662
2663 MECHANISM_ASSOCIATION ::=
2664 [formal_parameter_NAME =>] MECHANISM_NAME
2665
2666 MECHANISM_NAME ::=
2667 Value
2668 | Reference
2669 | Descriptor [([Class =>] CLASS_NAME)]
2670 | Short_Descriptor [([Class =>] CLASS_NAME)]
2671
2672 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2673 @end smallexample
2674
2675 @noindent
2676 This pragma is used in conjunction with a pragma @code{Import} to
2677 specify additional information for an imported function. The pragma
2678 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2679 @code{Import_Function} pragma and both must appear in the same
2680 declarative part as the function specification.
2681
2682 The @var{Internal} argument must uniquely designate
2683 the function to which the
2684 pragma applies. If more than one function name exists of this name in
2685 the declarative part you must use the @code{Parameter_Types} and
2686 @var{Result_Type} parameters to achieve the required unique
2687 designation. Subtype marks in these parameters must exactly match the
2688 subtypes in the corresponding function specification, using positional
2689 notation to match parameters with subtype marks.
2690 The form with an @code{'Access} attribute can be used to match an
2691 anonymous access parameter.
2692
2693 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2694 parameters to specify passing mechanisms for the
2695 parameters and result. If you specify a single mechanism name, it
2696 applies to all parameters. Otherwise you may specify a mechanism on a
2697 parameter by parameter basis using either positional or named
2698 notation. If the mechanism is not specified, the default mechanism
2699 is used.
2700
2701 @cindex OpenVMS
2702 @cindex Passing by descriptor
2703 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2704 The default behavior for Import_Function is to pass a 64bit descriptor
2705 unless short_descriptor is specified, then a 32bit descriptor is passed.
2706
2707 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2708 It specifies that the designated parameter and all following parameters
2709 are optional, meaning that they are not passed at the generated code
2710 level (this is distinct from the notion of optional parameters in Ada
2711 where the parameters are passed anyway with the designated optional
2712 parameters). All optional parameters must be of mode @code{IN} and have
2713 default parameter values that are either known at compile time
2714 expressions, or uses of the @code{'Null_Parameter} attribute.
2715
2716 @node Pragma Import_Object
2717 @unnumberedsec Pragma Import_Object
2718 @findex Import_Object
2719 @noindent
2720 Syntax:
2721
2722 @smallexample @c ada
2723 pragma Import_Object
2724 [Internal =>] LOCAL_NAME
2725 [, [External =>] EXTERNAL_SYMBOL]
2726 [, [Size =>] EXTERNAL_SYMBOL]);
2727
2728 EXTERNAL_SYMBOL ::=
2729 IDENTIFIER
2730 | static_string_EXPRESSION
2731 @end smallexample
2732
2733 @noindent
2734 This pragma designates an object as imported, and apart from the
2735 extended rules for external symbols, is identical in effect to the use of
2736 the normal @code{Import} pragma applied to an object. Unlike the
2737 subprogram case, you need not use a separate @code{Import} pragma,
2738 although you may do so (and probably should do so from a portability
2739 point of view). @var{size} is syntax checked, but otherwise ignored by
2740 GNAT@.
2741
2742 @node Pragma Import_Procedure
2743 @unnumberedsec Pragma Import_Procedure
2744 @findex Import_Procedure
2745 @noindent
2746 Syntax:
2747
2748 @smallexample @c ada
2749 pragma Import_Procedure (
2750 [Internal =>] LOCAL_NAME
2751 [, [External =>] EXTERNAL_SYMBOL]
2752 [, [Parameter_Types =>] PARAMETER_TYPES]
2753 [, [Mechanism =>] MECHANISM]
2754 [, [First_Optional_Parameter =>] IDENTIFIER]);
2755
2756 EXTERNAL_SYMBOL ::=
2757 IDENTIFIER
2758 | static_string_EXPRESSION
2759
2760 PARAMETER_TYPES ::=
2761 null
2762 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2763
2764 TYPE_DESIGNATOR ::=
2765 subtype_NAME
2766 | subtype_Name ' Access
2767
2768 MECHANISM ::=
2769 MECHANISM_NAME
2770 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2771
2772 MECHANISM_ASSOCIATION ::=
2773 [formal_parameter_NAME =>] MECHANISM_NAME
2774
2775 MECHANISM_NAME ::=
2776 Value
2777 | Reference
2778 | Descriptor [([Class =>] CLASS_NAME)]
2779 | Short_Descriptor [([Class =>] CLASS_NAME)]
2780
2781 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2782 @end smallexample
2783
2784 @noindent
2785 This pragma is identical to @code{Import_Function} except that it
2786 applies to a procedure rather than a function and the parameters
2787 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2788
2789 @node Pragma Import_Valued_Procedure
2790 @unnumberedsec Pragma Import_Valued_Procedure
2791 @findex Import_Valued_Procedure
2792 @noindent
2793 Syntax:
2794
2795 @smallexample @c ada
2796 pragma Import_Valued_Procedure (
2797 [Internal =>] LOCAL_NAME
2798 [, [External =>] EXTERNAL_SYMBOL]
2799 [, [Parameter_Types =>] PARAMETER_TYPES]
2800 [, [Mechanism =>] MECHANISM]
2801 [, [First_Optional_Parameter =>] IDENTIFIER]);
2802
2803 EXTERNAL_SYMBOL ::=
2804 IDENTIFIER
2805 | static_string_EXPRESSION
2806
2807 PARAMETER_TYPES ::=
2808 null
2809 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2810
2811 TYPE_DESIGNATOR ::=
2812 subtype_NAME
2813 | subtype_Name ' Access
2814
2815 MECHANISM ::=
2816 MECHANISM_NAME
2817 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2818
2819 MECHANISM_ASSOCIATION ::=
2820 [formal_parameter_NAME =>] MECHANISM_NAME
2821
2822 MECHANISM_NAME ::=
2823 Value
2824 | Reference
2825 | Descriptor [([Class =>] CLASS_NAME)]
2826 | Short_Descriptor [([Class =>] CLASS_NAME)]
2827
2828 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2829 @end smallexample
2830
2831 @noindent
2832 This pragma is identical to @code{Import_Procedure} except that the
2833 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2834 mode @code{OUT}, and externally the subprogram is treated as a function
2835 with this parameter as the result of the function. The purpose of this
2836 capability is to allow the use of @code{OUT} and @code{IN OUT}
2837 parameters in interfacing to external functions (which are not permitted
2838 in Ada functions). You may optionally use the @code{Mechanism}
2839 parameters to specify passing mechanisms for the parameters.
2840 If you specify a single mechanism name, it applies to all parameters.
2841 Otherwise you may specify a mechanism on a parameter by parameter
2842 basis using either positional or named notation. If the mechanism is not
2843 specified, the default mechanism is used.
2844
2845 Note that it is important to use this pragma in conjunction with a separate
2846 pragma Import that specifies the desired convention, since otherwise the
2847 default convention is Ada, which is almost certainly not what is required.
2848
2849 @node Pragma Initialize_Scalars
2850 @unnumberedsec Pragma Initialize_Scalars
2851 @findex Initialize_Scalars
2852 @cindex debugging with Initialize_Scalars
2853 @noindent
2854 Syntax:
2855
2856 @smallexample @c ada
2857 pragma Initialize_Scalars;
2858 @end smallexample
2859
2860 @noindent
2861 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2862 two important differences. First, there is no requirement for the pragma
2863 to be used uniformly in all units of a partition, in particular, it is fine
2864 to use this just for some or all of the application units of a partition,
2865 without needing to recompile the run-time library.
2866
2867 In the case where some units are compiled with the pragma, and some without,
2868 then a declaration of a variable where the type is defined in package
2869 Standard or is locally declared will always be subject to initialization,
2870 as will any declaration of a scalar variable. For composite variables,
2871 whether the variable is initialized may also depend on whether the package
2872 in which the type of the variable is declared is compiled with the pragma.
2873
2874 The other important difference is that you can control the value used
2875 for initializing scalar objects. At bind time, you can select several
2876 options for initialization. You can
2877 initialize with invalid values (similar to Normalize_Scalars, though for
2878 Initialize_Scalars it is not always possible to determine the invalid
2879 values in complex cases like signed component fields with non-standard
2880 sizes). You can also initialize with high or
2881 low values, or with a specified bit pattern. See the users guide for binder
2882 options for specifying these cases.
2883
2884 This means that you can compile a program, and then without having to
2885 recompile the program, you can run it with different values being used
2886 for initializing otherwise uninitialized values, to test if your program
2887 behavior depends on the choice. Of course the behavior should not change,
2888 and if it does, then most likely you have an erroneous reference to an
2889 uninitialized value.
2890
2891 It is even possible to change the value at execution time eliminating even
2892 the need to rebind with a different switch using an environment variable.
2893 See the GNAT users guide for details.
2894
2895 Note that pragma @code{Initialize_Scalars} is particularly useful in
2896 conjunction with the enhanced validity checking that is now provided
2897 in GNAT, which checks for invalid values under more conditions.
2898 Using this feature (see description of the @option{-gnatV} flag in the
2899 users guide) in conjunction with pragma @code{Initialize_Scalars}
2900 provides a powerful new tool to assist in the detection of problems
2901 caused by uninitialized variables.
2902
2903 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2904 effect on the generated code. This may cause your code to be
2905 substantially larger. It may also cause an increase in the amount
2906 of stack required, so it is probably a good idea to turn on stack
2907 checking (see description of stack checking in the GNAT users guide)
2908 when using this pragma.
2909
2910 @node Pragma Inline_Always
2911 @unnumberedsec Pragma Inline_Always
2912 @findex Inline_Always
2913 @noindent
2914 Syntax:
2915
2916 @smallexample @c ada
2917 pragma Inline_Always (NAME [, NAME]);
2918 @end smallexample
2919
2920 @noindent
2921 Similar to pragma @code{Inline} except that inlining is not subject to
2922 the use of option @option{-gnatn} and the inlining happens regardless of
2923 whether this option is used.
2924
2925 @node Pragma Inline_Generic
2926 @unnumberedsec Pragma Inline_Generic
2927 @findex Inline_Generic
2928 @noindent
2929 Syntax:
2930
2931 @smallexample @c ada
2932 pragma Inline_Generic (generic_package_NAME);
2933 @end smallexample
2934
2935 @noindent
2936 This is implemented for compatibility with DEC Ada 83 and is recognized,
2937 but otherwise ignored, by GNAT@. All generic instantiations are inlined
2938 by default when using GNAT@.
2939
2940 @node Pragma Interface
2941 @unnumberedsec Pragma Interface
2942 @findex Interface
2943 @noindent
2944 Syntax:
2945
2946 @smallexample @c ada
2947 pragma Interface (
2948 [Convention =>] convention_identifier,
2949 [Entity =>] local_NAME
2950 [, [External_Name =>] static_string_expression]
2951 [, [Link_Name =>] static_string_expression]);
2952 @end smallexample
2953
2954 @noindent
2955 This pragma is identical in syntax and semantics to
2956 the standard Ada pragma @code{Import}. It is provided for compatibility
2957 with Ada 83. The definition is upwards compatible both with pragma
2958 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2959 with some extended implementations of this pragma in certain Ada 83
2960 implementations. The only difference between pragma @code{Interface}
2961 and pragma @code{Import} is that there is special circuitry to allow
2962 both pragmas to appear for the same subprogram entity (normally it
2963 is illegal to have multiple @code{Import} pragmas. This is useful in
2964 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2965 Ada 83 compilers.
2966
2967 @node Pragma Interface_Name
2968 @unnumberedsec Pragma Interface_Name
2969 @findex Interface_Name
2970 @noindent
2971 Syntax:
2972
2973 @smallexample @c ada
2974 pragma Interface_Name (
2975 [Entity =>] LOCAL_NAME
2976 [, [External_Name =>] static_string_EXPRESSION]
2977 [, [Link_Name =>] static_string_EXPRESSION]);
2978 @end smallexample
2979
2980 @noindent
2981 This pragma provides an alternative way of specifying the interface name
2982 for an interfaced subprogram, and is provided for compatibility with Ada
2983 83 compilers that use the pragma for this purpose. You must provide at
2984 least one of @var{External_Name} or @var{Link_Name}.
2985
2986 @node Pragma Interrupt_Handler
2987 @unnumberedsec Pragma Interrupt_Handler
2988 @findex Interrupt_Handler
2989 @noindent
2990 Syntax:
2991
2992 @smallexample @c ada
2993 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2994 @end smallexample
2995
2996 @noindent
2997 This program unit pragma is supported for parameterless protected procedures
2998 as described in Annex C of the Ada Reference Manual. On the AAMP target
2999 the pragma can also be specified for nonprotected parameterless procedures
3000 that are declared at the library level (which includes procedures
3001 declared at the top level of a library package). In the case of AAMP,
3002 when this pragma is applied to a nonprotected procedure, the instruction
3003 @code{IERET} is generated for returns from the procedure, enabling
3004 maskable interrupts, in place of the normal return instruction.
3005
3006 @node Pragma Interrupt_State
3007 @unnumberedsec Pragma Interrupt_State
3008 @findex Interrupt_State
3009 @noindent
3010 Syntax:
3011
3012 @smallexample @c ada
3013 pragma Interrupt_State
3014 ([Name =>] value,
3015 [State =>] SYSTEM | RUNTIME | USER);
3016 @end smallexample
3017
3018 @noindent
3019 Normally certain interrupts are reserved to the implementation. Any attempt
3020 to attach an interrupt causes Program_Error to be raised, as described in
3021 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3022 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3023 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3024 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3025 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3026 Ada exceptions, or used to implement run-time functions such as the
3027 @code{abort} statement and stack overflow checking.
3028
3029 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3030 such uses of interrupts. It subsumes the functionality of pragma
3031 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3032 available on Windows or VMS. On all other platforms than VxWorks,
3033 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3034 and may be used to mark interrupts required by the board support package
3035 as reserved.
3036
3037 Interrupts can be in one of three states:
3038 @itemize @bullet
3039 @item System
3040
3041 The interrupt is reserved (no Ada handler can be installed), and the
3042 Ada run-time may not install a handler. As a result you are guaranteed
3043 standard system default action if this interrupt is raised.
3044
3045 @item Runtime
3046
3047 The interrupt is reserved (no Ada handler can be installed). The run time
3048 is allowed to install a handler for internal control purposes, but is
3049 not required to do so.
3050
3051 @item User
3052
3053 The interrupt is unreserved. The user may install a handler to provide
3054 some other action.
3055 @end itemize
3056
3057 @noindent
3058 These states are the allowed values of the @code{State} parameter of the
3059 pragma. The @code{Name} parameter is a value of the type
3060 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3061 @code{Ada.Interrupts.Names}.
3062
3063 This is a configuration pragma, and the binder will check that there
3064 are no inconsistencies between different units in a partition in how a
3065 given interrupt is specified. It may appear anywhere a pragma is legal.
3066
3067 The effect is to move the interrupt to the specified state.
3068
3069 By declaring interrupts to be SYSTEM, you guarantee the standard system
3070 action, such as a core dump.
3071
3072 By declaring interrupts to be USER, you guarantee that you can install
3073 a handler.
3074
3075 Note that certain signals on many operating systems cannot be caught and
3076 handled by applications. In such cases, the pragma is ignored. See the
3077 operating system documentation, or the value of the array @code{Reserved}
3078 declared in the spec of package @code{System.OS_Interface}.
3079
3080 Overriding the default state of signals used by the Ada runtime may interfere
3081 with an application's runtime behavior in the cases of the synchronous signals,
3082 and in the case of the signal used to implement the @code{abort} statement.
3083
3084 @node Pragma Invariant
3085 @unnumberedsec Pragma Invariant
3086 @findex Invariant
3087 @noindent
3088 Syntax:
3089
3090 @smallexample @c ada
3091 pragma Invariant
3092 ([Entity =>] private_type_LOCAL_NAME,
3093 [Check =>] EXPRESSION
3094 [,[Message =>] String_Expression]);
3095 @end smallexample
3096
3097 @noindent
3098 This pragma provides exactly the same capabilities as the Invariant aspect
3099 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3100 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3101 of the aspect syntax, which is not available exception in 2012 mode, it is
3102 not possible to use the Invariant aspect in earlier versions of Ada. However
3103 the Invariant pragma may be used in any version of Ada.
3104
3105 The pragma must appear within the visible part of the package specification,
3106 after the type to which its Entity argument appears. As with the Invariant
3107 aspect, the Check expression is not analyzed until the end of the visible
3108 part of the package, so it may contain forward references. The Message
3109 argument, if present, provides the exception message used if the invariant
3110 is violated. If no Message parameter is provided, a default message that
3111 identifies the line on which the pragma appears is used.
3112
3113 It is permissible to have multiple Invariants for the same type entity, in
3114 which case they are and'ed together. It is permissible to use this pragma
3115 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3116 invariant pragma for the same entity.
3117
3118 For further details on the use of this pragma, see the Ada 2012 documentation
3119 of the Invariant aspect.
3120
3121 @node Pragma Keep_Names
3122 @unnumberedsec Pragma Keep_Names
3123 @findex Keep_Names
3124 @noindent
3125 Syntax:
3126
3127 @smallexample @c ada
3128 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3129 @end smallexample
3130
3131 @noindent
3132 The @var{LOCAL_NAME} argument
3133 must refer to an enumeration first subtype
3134 in the current declarative part. The effect is to retain the enumeration
3135 literal names for use by @code{Image} and @code{Value} even if a global
3136 @code{Discard_Names} pragma applies. This is useful when you want to
3137 generally suppress enumeration literal names and for example you therefore
3138 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3139 want to retain the names for specific enumeration types.
3140
3141 @node Pragma License
3142 @unnumberedsec Pragma License
3143 @findex License
3144 @cindex License checking
3145 @noindent
3146 Syntax:
3147
3148 @smallexample @c ada
3149 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3150 @end smallexample
3151
3152 @noindent
3153 This pragma is provided to allow automated checking for appropriate license
3154 conditions with respect to the standard and modified GPL@. A pragma
3155 @code{License}, which is a configuration pragma that typically appears at
3156 the start of a source file or in a separate @file{gnat.adc} file, specifies
3157 the licensing conditions of a unit as follows:
3158
3159 @itemize @bullet
3160 @item Unrestricted
3161 This is used for a unit that can be freely used with no license restrictions.
3162 Examples of such units are public domain units, and units from the Ada
3163 Reference Manual.
3164
3165 @item GPL
3166 This is used for a unit that is licensed under the unmodified GPL, and which
3167 therefore cannot be @code{with}'ed by a restricted unit.
3168
3169 @item Modified_GPL
3170 This is used for a unit licensed under the GNAT modified GPL that includes
3171 a special exception paragraph that specifically permits the inclusion of
3172 the unit in programs without requiring the entire program to be released
3173 under the GPL@.
3174
3175 @item Restricted
3176 This is used for a unit that is restricted in that it is not permitted to
3177 depend on units that are licensed under the GPL@. Typical examples are
3178 proprietary code that is to be released under more restrictive license
3179 conditions. Note that restricted units are permitted to @code{with} units
3180 which are licensed under the modified GPL (this is the whole point of the
3181 modified GPL).
3182
3183 @end itemize
3184
3185 @noindent
3186 Normally a unit with no @code{License} pragma is considered to have an
3187 unknown license, and no checking is done. However, standard GNAT headers
3188 are recognized, and license information is derived from them as follows.
3189
3190 @itemize @bullet
3191
3192 A GNAT license header starts with a line containing 78 hyphens. The following
3193 comment text is searched for the appearance of any of the following strings.
3194
3195 If the string ``GNU General Public License'' is found, then the unit is assumed
3196 to have GPL license, unless the string ``As a special exception'' follows, in
3197 which case the license is assumed to be modified GPL@.
3198
3199 If one of the strings
3200 ``This specification is adapted from the Ada Semantic Interface'' or
3201 ``This specification is derived from the Ada Reference Manual'' is found
3202 then the unit is assumed to be unrestricted.
3203 @end itemize
3204
3205 @noindent
3206 These default actions means that a program with a restricted license pragma
3207 will automatically get warnings if a GPL unit is inappropriately
3208 @code{with}'ed. For example, the program:
3209
3210 @smallexample @c ada
3211 with Sem_Ch3;
3212 with GNAT.Sockets;
3213 procedure Secret_Stuff is
3214 @dots{}
3215 end Secret_Stuff
3216 @end smallexample
3217
3218 @noindent
3219 if compiled with pragma @code{License} (@code{Restricted}) in a
3220 @file{gnat.adc} file will generate the warning:
3221
3222 @smallexample
3223 1. with Sem_Ch3;
3224 |
3225 >>> license of withed unit "Sem_Ch3" is incompatible
3226
3227 2. with GNAT.Sockets;
3228 3. procedure Secret_Stuff is
3229 @end smallexample
3230
3231 @noindent
3232 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3233 compiler and is licensed under the
3234 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3235 run time, and is therefore licensed under the modified GPL@.
3236
3237 @node Pragma Link_With
3238 @unnumberedsec Pragma Link_With
3239 @findex Link_With
3240 @noindent
3241 Syntax:
3242
3243 @smallexample @c ada
3244 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3245 @end smallexample
3246
3247 @noindent
3248 This pragma is provided for compatibility with certain Ada 83 compilers.
3249 It has exactly the same effect as pragma @code{Linker_Options} except
3250 that spaces occurring within one of the string expressions are treated
3251 as separators. For example, in the following case:
3252
3253 @smallexample @c ada
3254 pragma Link_With ("-labc -ldef");
3255 @end smallexample
3256
3257 @noindent
3258 results in passing the strings @code{-labc} and @code{-ldef} as two
3259 separate arguments to the linker. In addition pragma Link_With allows
3260 multiple arguments, with the same effect as successive pragmas.
3261
3262 @node Pragma Linker_Alias
3263 @unnumberedsec Pragma Linker_Alias
3264 @findex Linker_Alias
3265 @noindent
3266 Syntax:
3267
3268 @smallexample @c ada
3269 pragma Linker_Alias (
3270 [Entity =>] LOCAL_NAME,
3271 [Target =>] static_string_EXPRESSION);
3272 @end smallexample
3273
3274 @noindent
3275 @var{LOCAL_NAME} must refer to an object that is declared at the library
3276 level. This pragma establishes the given entity as a linker alias for the
3277 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3278 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3279 @var{static_string_EXPRESSION} in the object file, that is to say no space
3280 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3281 to the same address as @var{static_string_EXPRESSION} by the linker.
3282
3283 The actual linker name for the target must be used (e.g.@: the fully
3284 encoded name with qualification in Ada, or the mangled name in C++),
3285 or it must be declared using the C convention with @code{pragma Import}
3286 or @code{pragma Export}.
3287
3288 Not all target machines support this pragma. On some of them it is accepted
3289 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3290
3291 @smallexample @c ada
3292 -- Example of the use of pragma Linker_Alias
3293
3294 package p is
3295 i : Integer := 1;
3296 pragma Export (C, i);
3297
3298 new_name_for_i : Integer;
3299 pragma Linker_Alias (new_name_for_i, "i");
3300 end p;
3301 @end smallexample
3302
3303 @node Pragma Linker_Constructor
3304 @unnumberedsec Pragma Linker_Constructor
3305 @findex Linker_Constructor
3306 @noindent
3307 Syntax:
3308
3309 @smallexample @c ada
3310 pragma Linker_Constructor (procedure_LOCAL_NAME);
3311 @end smallexample
3312
3313 @noindent
3314 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3315 is declared at the library level. A procedure to which this pragma is
3316 applied will be treated as an initialization routine by the linker.
3317 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3318 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3319 of the executable is called (or immediately after the shared library is
3320 loaded if the procedure is linked in a shared library), in particular
3321 before the Ada run-time environment is set up.
3322
3323 Because of these specific contexts, the set of operations such a procedure
3324 can perform is very limited and the type of objects it can manipulate is
3325 essentially restricted to the elementary types. In particular, it must only
3326 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3327
3328 This pragma is used by GNAT to implement auto-initialization of shared Stand
3329 Alone Libraries, which provides a related capability without the restrictions
3330 listed above. Where possible, the use of Stand Alone Libraries is preferable
3331 to the use of this pragma.
3332
3333 @node Pragma Linker_Destructor
3334 @unnumberedsec Pragma Linker_Destructor
3335 @findex Linker_Destructor
3336 @noindent
3337 Syntax:
3338
3339 @smallexample @c ada
3340 pragma Linker_Destructor (procedure_LOCAL_NAME);
3341 @end smallexample
3342
3343 @noindent
3344 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3345 is declared at the library level. A procedure to which this pragma is
3346 applied will be treated as a finalization routine by the linker.
3347 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3348 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3349 of the executable has exited (or immediately before the shared library
3350 is unloaded if the procedure is linked in a shared library), in particular
3351 after the Ada run-time environment is shut down.
3352
3353 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3354 because of these specific contexts.
3355
3356 @node Pragma Linker_Section
3357 @unnumberedsec Pragma Linker_Section
3358 @findex Linker_Section
3359 @noindent
3360 Syntax:
3361
3362 @smallexample @c ada
3363 pragma Linker_Section (
3364 [Entity =>] LOCAL_NAME,
3365 [Section =>] static_string_EXPRESSION);
3366 @end smallexample
3367
3368 @noindent
3369 @var{LOCAL_NAME} must refer to an object that is declared at the library
3370 level. This pragma specifies the name of the linker section for the given
3371 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3372 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3373 section of the executable (assuming the linker doesn't rename the section).
3374
3375 The compiler normally places library-level objects in standard sections
3376 depending on their type: procedures and functions generally go in the
3377 @code{.text} section, initialized variables in the @code{.data} section
3378 and uninitialized variables in the @code{.bss} section.
3379
3380 Other, special sections may exist on given target machines to map special
3381 hardware, for example I/O ports or flash memory. This pragma is a means to
3382 defer the final layout of the executable to the linker, thus fully working
3383 at the symbolic level with the compiler.
3384
3385 Some file formats do not support arbitrary sections so not all target
3386 machines support this pragma. The use of this pragma may cause a program
3387 execution to be erroneous if it is used to place an entity into an
3388 inappropriate section (e.g.@: a modified variable into the @code{.text}
3389 section). See also @code{pragma Persistent_BSS}.
3390
3391 @smallexample @c ada
3392 -- Example of the use of pragma Linker_Section
3393
3394 package IO_Card is
3395 Port_A : Integer;
3396 pragma Volatile (Port_A);
3397 pragma Linker_Section (Port_A, ".bss.port_a");
3398
3399 Port_B : Integer;
3400 pragma Volatile (Port_B);
3401 pragma Linker_Section (Port_B, ".bss.port_b");
3402 end IO_Card;
3403 @end smallexample
3404
3405 @node Pragma Long_Float
3406 @unnumberedsec Pragma Long_Float
3407 @cindex OpenVMS
3408 @findex Long_Float
3409 @noindent
3410 Syntax:
3411
3412 @smallexample @c ada
3413 pragma Long_Float (FLOAT_FORMAT);
3414
3415 FLOAT_FORMAT ::= D_Float | G_Float
3416 @end smallexample
3417
3418 @noindent
3419 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3420 It allows control over the internal representation chosen for the predefined
3421 type @code{Long_Float} and for floating point type representations with
3422 @code{digits} specified in the range 7 through 15.
3423 For further details on this pragma, see the
3424 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3425 this pragma, the standard runtime libraries must be recompiled.
3426
3427 @node Pragma Machine_Attribute
3428 @unnumberedsec Pragma Machine_Attribute
3429 @findex Machine_Attribute
3430 @noindent
3431 Syntax:
3432
3433 @smallexample @c ada
3434 pragma Machine_Attribute (
3435 [Entity =>] LOCAL_NAME,
3436 [Attribute_Name =>] static_string_EXPRESSION
3437 [, [Info =>] static_EXPRESSION] );
3438 @end smallexample
3439
3440 @noindent
3441 Machine-dependent attributes can be specified for types and/or
3442 declarations. This pragma is semantically equivalent to
3443 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3444 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3445 in GNU C, where @code{@var{attribute_name}} is recognized by the
3446 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3447 specific macro. A string literal for the optional parameter @var{info}
3448 is transformed into an identifier, which may make this pragma unusable
3449 for some attributes. @xref{Target Attributes,, Defining target-specific
3450 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3451 Internals}, further information.
3452
3453 @node Pragma Main
3454 @unnumberedsec Pragma Main
3455 @cindex OpenVMS
3456 @findex Main
3457 @noindent
3458 Syntax:
3459
3460 @smallexample @c ada
3461 pragma Main
3462 (MAIN_OPTION [, MAIN_OPTION]);
3463
3464 MAIN_OPTION ::=
3465 [Stack_Size =>] static_integer_EXPRESSION
3466 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3467 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3468 @end smallexample
3469
3470 @noindent
3471 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3472 no effect in GNAT, other than being syntax checked.
3473
3474 @node Pragma Main_Storage
3475 @unnumberedsec Pragma Main_Storage
3476 @cindex OpenVMS
3477 @findex Main_Storage
3478 @noindent
3479 Syntax:
3480
3481 @smallexample @c ada
3482 pragma Main_Storage
3483 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3484
3485 MAIN_STORAGE_OPTION ::=
3486 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3487 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3488 @end smallexample
3489
3490 @noindent
3491 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3492 no effect in GNAT, other than being syntax checked. Note that the pragma
3493 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3494
3495 @node Pragma No_Body
3496 @unnumberedsec Pragma No_Body
3497 @findex No_Body
3498 @noindent
3499 Syntax:
3500
3501 @smallexample @c ada
3502 pragma No_Body;
3503 @end smallexample
3504
3505 @noindent
3506 There are a number of cases in which a package spec does not require a body,
3507 and in fact a body is not permitted. GNAT will not permit the spec to be
3508 compiled if there is a body around. The pragma No_Body allows you to provide
3509 a body file, even in a case where no body is allowed. The body file must
3510 contain only comments and a single No_Body pragma. This is recognized by
3511 the compiler as indicating that no body is logically present.
3512
3513 This is particularly useful during maintenance when a package is modified in
3514 such a way that a body needed before is no longer needed. The provision of a
3515 dummy body with a No_Body pragma ensures that there is no interference from
3516 earlier versions of the package body.
3517
3518 @node Pragma No_Return
3519 @unnumberedsec Pragma No_Return
3520 @findex No_Return
3521 @noindent
3522 Syntax:
3523
3524 @smallexample @c ada
3525 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3526 @end smallexample
3527
3528 @noindent
3529 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3530 declarations in the current declarative part. A procedure to which this
3531 pragma is applied may not contain any explicit @code{return} statements.
3532 In addition, if the procedure contains any implicit returns from falling
3533 off the end of a statement sequence, then execution of that implicit
3534 return will cause Program_Error to be raised.
3535
3536 One use of this pragma is to identify procedures whose only purpose is to raise
3537 an exception. Another use of this pragma is to suppress incorrect warnings
3538 about missing returns in functions, where the last statement of a function
3539 statement sequence is a call to such a procedure.
3540
3541 Note that in Ada 2005 mode, this pragma is part of the language, and is
3542 identical in effect to the pragma as implemented in Ada 95 mode.
3543
3544 @node Pragma No_Strict_Aliasing
3545 @unnumberedsec Pragma No_Strict_Aliasing
3546 @findex No_Strict_Aliasing
3547 @noindent
3548 Syntax:
3549
3550 @smallexample @c ada
3551 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3552 @end smallexample
3553
3554 @noindent
3555 @var{type_LOCAL_NAME} must refer to an access type
3556 declaration in the current declarative part. The effect is to inhibit
3557 strict aliasing optimization for the given type. The form with no
3558 arguments is a configuration pragma which applies to all access types
3559 declared in units to which the pragma applies. For a detailed
3560 description of the strict aliasing optimization, and the situations
3561 in which it must be suppressed, see @ref{Optimization and Strict
3562 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3563
3564 This pragma currently has no effects on access to unconstrained array types.
3565
3566 @node Pragma Normalize_Scalars
3567 @unnumberedsec Pragma Normalize_Scalars
3568 @findex Normalize_Scalars
3569 @noindent
3570 Syntax:
3571
3572 @smallexample @c ada
3573 pragma Normalize_Scalars;
3574 @end smallexample
3575
3576 @noindent
3577 This is a language defined pragma which is fully implemented in GNAT@. The
3578 effect is to cause all scalar objects that are not otherwise initialized
3579 to be initialized. The initial values are implementation dependent and
3580 are as follows:
3581
3582 @table @code
3583 @item Standard.Character
3584 @noindent
3585 Objects whose root type is Standard.Character are initialized to
3586 Character'Last unless the subtype range excludes NUL (in which case
3587 NUL is used). This choice will always generate an invalid value if
3588 one exists.
3589
3590 @item Standard.Wide_Character
3591 @noindent
3592 Objects whose root type is Standard.Wide_Character are initialized to
3593 Wide_Character'Last unless the subtype range excludes NUL (in which case
3594 NUL is used). This choice will always generate an invalid value if
3595 one exists.
3596
3597 @item Standard.Wide_Wide_Character
3598 @noindent
3599 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3600 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3601 which case NUL is used). This choice will always generate an invalid value if
3602 one exists.
3603
3604 @item Integer types
3605 @noindent
3606 Objects of an integer type are treated differently depending on whether
3607 negative values are present in the subtype. If no negative values are
3608 present, then all one bits is used as the initial value except in the
3609 special case where zero is excluded from the subtype, in which case
3610 all zero bits are used. This choice will always generate an invalid
3611 value if one exists.
3612
3613 For subtypes with negative values present, the largest negative number
3614 is used, except in the unusual case where this largest negative number
3615 is in the subtype, and the largest positive number is not, in which case
3616 the largest positive value is used. This choice will always generate
3617 an invalid value if one exists.
3618
3619 @item Floating-Point Types
3620 Objects of all floating-point types are initialized to all 1-bits. For
3621 standard IEEE format, this corresponds to a NaN (not a number) which is
3622 indeed an invalid value.
3623
3624 @item Fixed-Point Types
3625 Objects of all fixed-point types are treated as described above for integers,
3626 with the rules applying to the underlying integer value used to represent
3627 the fixed-point value.
3628
3629 @item Modular types
3630 Objects of a modular type are initialized to all one bits, except in
3631 the special case where zero is excluded from the subtype, in which
3632 case all zero bits are used. This choice will always generate an
3633 invalid value if one exists.
3634
3635 @item Enumeration types
3636 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3637 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3638 whose Pos value is zero, in which case a code of zero is used. This choice
3639 will always generate an invalid value if one exists.
3640
3641 @end table
3642
3643 @node Pragma Obsolescent
3644 @unnumberedsec Pragma Obsolescent
3645 @findex Obsolescent
3646 @noindent
3647 Syntax:
3648
3649 @smallexample @c ada
3650 pragma Obsolescent;
3651
3652 pragma Obsolescent (
3653 [Message =>] static_string_EXPRESSION
3654 [,[Version =>] Ada_05]]);
3655
3656 pragma Obsolescent (
3657 [Entity =>] NAME
3658 [,[Message =>] static_string_EXPRESSION
3659 [,[Version =>] Ada_05]] );
3660 @end smallexample
3661
3662 @noindent
3663 This pragma can occur immediately following a declaration of an entity,
3664 including the case of a record component. If no Entity argument is present,
3665 then this declaration is the one to which the pragma applies. If an Entity
3666 parameter is present, it must either match the name of the entity in this
3667 declaration, or alternatively, the pragma can immediately follow an enumeration
3668 type declaration, where the Entity argument names one of the enumeration
3669 literals.
3670
3671 This pragma is used to indicate that the named entity
3672 is considered obsolescent and should not be used. Typically this is
3673 used when an API must be modified by eventually removing or modifying
3674 existing subprograms or other entities. The pragma can be used at an
3675 intermediate stage when the entity is still present, but will be
3676 removed later.
3677
3678 The effect of this pragma is to output a warning message on a reference to
3679 an entity thus marked that the subprogram is obsolescent if the appropriate
3680 warning option in the compiler is activated. If the Message parameter is
3681 present, then a second warning message is given containing this text. In
3682 addition, a reference to the entity is considered to be a violation of pragma
3683 Restrictions (No_Obsolescent_Features).
3684
3685 This pragma can also be used as a program unit pragma for a package,
3686 in which case the entity name is the name of the package, and the
3687 pragma indicates that the entire package is considered
3688 obsolescent. In this case a client @code{with}'ing such a package
3689 violates the restriction, and the @code{with} statement is
3690 flagged with warnings if the warning option is set.
3691
3692 If the Version parameter is present (which must be exactly
3693 the identifier Ada_05, no other argument is allowed), then the
3694 indication of obsolescence applies only when compiling in Ada 2005
3695 mode. This is primarily intended for dealing with the situations
3696 in the predefined library where subprograms or packages
3697 have become defined as obsolescent in Ada 2005
3698 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3699
3700 The following examples show typical uses of this pragma:
3701
3702 @smallexample @c ada
3703 package p is
3704 pragma Obsolescent (p, Message => "use pp instead of p");
3705 end p;
3706
3707 package q is
3708 procedure q2;
3709 pragma Obsolescent ("use q2new instead");
3710
3711 type R is new integer;
3712 pragma Obsolescent
3713 (Entity => R,
3714 Message => "use RR in Ada 2005",
3715 Version => Ada_05);
3716
3717 type M is record
3718 F1 : Integer;
3719 F2 : Integer;
3720 pragma Obsolescent;
3721 F3 : Integer;
3722 end record;
3723
3724 type E is (a, bc, 'd', quack);
3725 pragma Obsolescent (Entity => bc)
3726 pragma Obsolescent (Entity => 'd')
3727
3728 function "+"
3729 (a, b : character) return character;
3730 pragma Obsolescent (Entity => "+");
3731 end;
3732 @end smallexample
3733
3734 @noindent
3735 Note that, as for all pragmas, if you use a pragma argument identifier,
3736 then all subsequent parameters must also use a pragma argument identifier.
3737 So if you specify "Entity =>" for the Entity argument, and a Message
3738 argument is present, it must be preceded by "Message =>".
3739
3740 @node Pragma Optimize_Alignment
3741 @unnumberedsec Pragma Optimize_Alignment
3742 @findex Optimize_Alignment
3743 @cindex Alignment, default settings
3744 @noindent
3745 Syntax:
3746
3747 @smallexample @c ada
3748 pragma Optimize_Alignment (TIME | SPACE | OFF);
3749 @end smallexample
3750
3751 @noindent
3752 This is a configuration pragma which affects the choice of default alignments
3753 for types where no alignment is explicitly specified. There is a time/space
3754 trade-off in the selection of these values. Large alignments result in more
3755 efficient code, at the expense of larger data space, since sizes have to be
3756 increased to match these alignments. Smaller alignments save space, but the
3757 access code is slower. The normal choice of default alignments (which is what
3758 you get if you do not use this pragma, or if you use an argument of OFF),
3759 tries to balance these two requirements.
3760
3761 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3762 First any packed record is given an alignment of 1. Second, if a size is given
3763 for the type, then the alignment is chosen to avoid increasing this size. For
3764 example, consider:
3765
3766 @smallexample @c ada
3767 type R is record
3768 X : Integer;
3769 Y : Character;
3770 end record;
3771
3772 for R'Size use 5*8;
3773 @end smallexample
3774
3775 @noindent
3776 In the default mode, this type gets an alignment of 4, so that access to the
3777 Integer field X are efficient. But this means that objects of the type end up
3778 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3779 allowed to be bigger than the size of the type, but it can waste space if for
3780 example fields of type R appear in an enclosing record. If the above type is
3781 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3782
3783 Specifying TIME causes larger default alignments to be chosen in the case of
3784 small types with sizes that are not a power of 2. For example, consider:
3785
3786 @smallexample @c ada
3787 type R is record
3788 A : Character;
3789 B : Character;
3790 C : Boolean;
3791 end record;
3792
3793 pragma Pack (R);
3794 for R'Size use 17;
3795 @end smallexample
3796
3797 @noindent
3798 The default alignment for this record is normally 1, but if this type is
3799 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3800 to 4, which wastes space for objects of the type, since they are now 4 bytes
3801 long, but results in more efficient access when the whole record is referenced.
3802
3803 As noted above, this is a configuration pragma, and there is a requirement
3804 that all units in a partition be compiled with a consistent setting of the
3805 optimization setting. This would normally be achieved by use of a configuration
3806 pragma file containing the appropriate setting. The exception to this rule is
3807 that units with an explicit configuration pragma in the same file as the source
3808 unit are excluded from the consistency check, as are all predefined units. The
3809 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3810 pragma appears at the start of the file.
3811
3812 @node Pragma Ordered
3813 @unnumberedsec Pragma Ordered
3814 @findex Ordered
3815 @findex pragma @code{Ordered}
3816 @noindent
3817 Syntax:
3818
3819 @smallexample @c ada
3820 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3821 @end smallexample
3822
3823 @noindent
3824 Most enumeration types are from a conceptual point of view unordered.
3825 For example, consider:
3826
3827 @smallexample @c ada
3828 type Color is (Red, Blue, Green, Yellow);
3829 @end smallexample
3830
3831 @noindent
3832 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3833 but really these relations make no sense; the enumeration type merely
3834 specifies a set of possible colors, and the order is unimportant.
3835
3836 For unordered enumeration types, it is generally a good idea if
3837 clients avoid comparisons (other than equality or inequality) and
3838 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3839 other than the unit where the type is declared, its body, and its subunits.)
3840 For example, if code buried in some client says:
3841
3842 @smallexample @c ada
3843 if Current_Color < Yellow then ...
3844 if Current_Color in Blue .. Green then ...
3845 @end smallexample
3846
3847 @noindent
3848 then the client code is relying on the order, which is undesirable.
3849 It makes the code hard to read and creates maintenance difficulties if
3850 entries have to be added to the enumeration type. Instead,
3851 the code in the client should list the possibilities, or an
3852 appropriate subtype should be declared in the unit that declares
3853 the original enumeration type. E.g., the following subtype could
3854 be declared along with the type @code{Color}:
3855
3856 @smallexample @c ada
3857 subtype RBG is Color range Red .. Green;
3858 @end smallexample
3859
3860 @noindent
3861 and then the client could write:
3862
3863 @smallexample @c ada
3864 if Current_Color in RBG then ...
3865 if Current_Color = Blue or Current_Color = Green then ...
3866 @end smallexample
3867
3868 @noindent
3869 However, some enumeration types are legitimately ordered from a conceptual
3870 point of view. For example, if you declare:
3871
3872 @smallexample @c ada
3873 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3874 @end smallexample
3875
3876 @noindent
3877 then the ordering imposed by the language is reasonable, and
3878 clients can depend on it, writing for example:
3879
3880 @smallexample @c ada
3881 if D in Mon .. Fri then ...
3882 if D < Wed then ...
3883 @end smallexample
3884
3885 @noindent
3886 The pragma @option{Ordered} is provided to mark enumeration types that
3887 are conceptually ordered, alerting the reader that clients may depend
3888 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3889 rather than one to mark them as unordered, since in our experience,
3890 the great majority of enumeration types are conceptually unordered.
3891
3892 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3893 and @code{Wide_Wide_Character}
3894 are considered to be ordered types, so each is declared with a
3895 pragma @code{Ordered} in package @code{Standard}.
3896
3897 Normally pragma @code{Ordered} serves only as documentation and a guide for
3898 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3899 requests warnings for inappropriate uses (comparisons and explicit
3900 subranges) for unordered types. If this switch is used, then any
3901 enumeration type not marked with pragma @code{Ordered} will be considered
3902 as unordered, and will generate warnings for inappropriate uses.
3903
3904 For additional information please refer to the description of the
3905 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3906
3907 @node Pragma Passive
3908 @unnumberedsec Pragma Passive
3909 @findex Passive
3910 @noindent
3911 Syntax:
3912
3913 @smallexample @c ada
3914 pragma Passive [(Semaphore | No)];
3915 @end smallexample
3916
3917 @noindent
3918 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
3919 compatibility with DEC Ada 83 implementations, where it is used within a
3920 task definition to request that a task be made passive. If the argument
3921 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3922 treats the pragma as an assertion that the containing task is passive
3923 and that optimization of context switch with this task is permitted and
3924 desired. If the argument @code{No} is present, the task must not be
3925 optimized. GNAT does not attempt to optimize any tasks in this manner
3926 (since protected objects are available in place of passive tasks).
3927
3928 @node Pragma Persistent_BSS
3929 @unnumberedsec Pragma Persistent_BSS
3930 @findex Persistent_BSS
3931 @noindent
3932 Syntax:
3933
3934 @smallexample @c ada
3935 pragma Persistent_BSS [(LOCAL_NAME)]
3936 @end smallexample
3937
3938 @noindent
3939 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3940 section. On some targets the linker and loader provide for special
3941 treatment of this section, allowing a program to be reloaded without
3942 affecting the contents of this data (hence the name persistent).
3943
3944 There are two forms of usage. If an argument is given, it must be the
3945 local name of a library level object, with no explicit initialization
3946 and whose type is potentially persistent. If no argument is given, then
3947 the pragma is a configuration pragma, and applies to all library level
3948 objects with no explicit initialization of potentially persistent types.
3949
3950 A potentially persistent type is a scalar type, or a non-tagged,
3951 non-discriminated record, all of whose components have no explicit
3952 initialization and are themselves of a potentially persistent type,
3953 or an array, all of whose constraints are static, and whose component
3954 type is potentially persistent.
3955
3956 If this pragma is used on a target where this feature is not supported,
3957 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3958
3959 @node Pragma Polling
3960 @unnumberedsec Pragma Polling
3961 @findex Polling
3962 @noindent
3963 Syntax:
3964
3965 @smallexample @c ada
3966 pragma Polling (ON | OFF);
3967 @end smallexample
3968
3969 @noindent
3970 This pragma controls the generation of polling code. This is normally off.
3971 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3972 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
3973 runtime library, and can be found in file @file{a-excpol.adb}.
3974
3975 Pragma @code{Polling} can appear as a configuration pragma (for example it
3976 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3977 can be used in the statement or declaration sequence to control polling
3978 more locally.
3979
3980 A call to the polling routine is generated at the start of every loop and
3981 at the start of every subprogram call. This guarantees that the @code{Poll}
3982 routine is called frequently, and places an upper bound (determined by
3983 the complexity of the code) on the period between two @code{Poll} calls.
3984
3985 The primary purpose of the polling interface is to enable asynchronous
3986 aborts on targets that cannot otherwise support it (for example Windows
3987 NT), but it may be used for any other purpose requiring periodic polling.
3988 The standard version is null, and can be replaced by a user program. This
3989 will require re-compilation of the @code{Ada.Exceptions} package that can
3990 be found in files @file{a-except.ads} and @file{a-except.adb}.
3991
3992 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3993 distribution) is used to enable the asynchronous abort capability on
3994 targets that do not normally support the capability. The version of
3995 @code{Poll} in this file makes a call to the appropriate runtime routine
3996 to test for an abort condition.
3997
3998 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3999 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4000 details.
4001
4002 @node Pragma Postcondition
4003 @unnumberedsec Pragma Postcondition
4004 @cindex Postconditions
4005 @cindex Checks, postconditions
4006 @findex Postconditions
4007 @noindent
4008 Syntax:
4009
4010 @smallexample @c ada
4011 pragma Postcondition (
4012 [Check =>] Boolean_Expression
4013 [,[Message =>] String_Expression]);
4014 @end smallexample
4015
4016 @noindent
4017 The @code{Postcondition} pragma allows specification of automatic
4018 postcondition checks for subprograms. These checks are similar to
4019 assertions, but are automatically inserted just prior to the return
4020 statements of the subprogram with which they are associated (including
4021 implicit returns at the end of procedure bodies and associated
4022 exception handlers).
4023
4024 In addition, the boolean expression which is the condition which
4025 must be true may contain references to function'Result in the case
4026 of a function to refer to the returned value.
4027
4028 @code{Postcondition} pragmas may appear either immediately following the
4029 (separate) declaration of a subprogram, or at the start of the
4030 declarations of a subprogram body. Only other pragmas may intervene
4031 (that is appear between the subprogram declaration and its
4032 postconditions, or appear before the postcondition in the
4033 declaration sequence in a subprogram body). In the case of a
4034 postcondition appearing after a subprogram declaration, the
4035 formal arguments of the subprogram are visible, and can be
4036 referenced in the postcondition expressions.
4037
4038 The postconditions are collected and automatically tested just
4039 before any return (implicit or explicit) in the subprogram body.
4040 A postcondition is only recognized if postconditions are active
4041 at the time the pragma is encountered. The compiler switch @option{gnata}
4042 turns on all postconditions by default, and pragma @code{Check_Policy}
4043 with an identifier of @code{Postcondition} can also be used to
4044 control whether postconditions are active.
4045
4046 The general approach is that postconditions are placed in the spec
4047 if they represent functional aspects which make sense to the client.
4048 For example we might have:
4049
4050 @smallexample @c ada
4051 function Direction return Integer;
4052 pragma Postcondition
4053 (Direction'Result = +1
4054 or else
4055 Direction'Result = -1);
4056 @end smallexample
4057
4058 @noindent
4059 which serves to document that the result must be +1 or -1, and
4060 will test that this is the case at run time if postcondition
4061 checking is active.
4062
4063 Postconditions within the subprogram body can be used to
4064 check that some internal aspect of the implementation,
4065 not visible to the client, is operating as expected.
4066 For instance if a square root routine keeps an internal
4067 counter of the number of times it is called, then we
4068 might have the following postcondition:
4069
4070 @smallexample @c ada
4071 Sqrt_Calls : Natural := 0;
4072
4073 function Sqrt (Arg : Float) return Float is
4074 pragma Postcondition
4075 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4076 ...
4077 end Sqrt
4078 @end smallexample
4079
4080 @noindent
4081 As this example, shows, the use of the @code{Old} attribute
4082 is often useful in postconditions to refer to the state on
4083 entry to the subprogram.
4084
4085 Note that postconditions are only checked on normal returns
4086 from the subprogram. If an abnormal return results from
4087 raising an exception, then the postconditions are not checked.
4088
4089 If a postcondition fails, then the exception
4090 @code{System.Assertions.Assert_Failure} is raised. If
4091 a message argument was supplied, then the given string
4092 will be used as the exception message. If no message
4093 argument was supplied, then the default message has
4094 the form "Postcondition failed at file:line". The
4095 exception is raised in the context of the subprogram
4096 body, so it is possible to catch postcondition failures
4097 within the subprogram body itself.
4098
4099 Within a package spec, normal visibility rules
4100 in Ada would prevent forward references within a
4101 postcondition pragma to functions defined later in
4102 the same package. This would introduce undesirable
4103 ordering constraints. To avoid this problem, all
4104 postcondition pragmas are analyzed at the end of
4105 the package spec, allowing forward references.
4106
4107 The following example shows that this even allows
4108 mutually recursive postconditions as in:
4109
4110 @smallexample @c ada
4111 package Parity_Functions is
4112 function Odd (X : Natural) return Boolean;
4113 pragma Postcondition
4114 (Odd'Result =
4115 (x = 1
4116 or else
4117 (x /= 0 and then Even (X - 1))));
4118
4119 function Even (X : Natural) return Boolean;
4120 pragma Postcondition
4121 (Even'Result =
4122 (x = 0
4123 or else
4124 (x /= 1 and then Odd (X - 1))));
4125
4126 end Parity_Functions;
4127 @end smallexample
4128
4129 @noindent
4130 There are no restrictions on the complexity or form of
4131 conditions used within @code{Postcondition} pragmas.
4132 The following example shows that it is even possible
4133 to verify performance behavior.
4134
4135 @smallexample @c ada
4136 package Sort is
4137
4138 Performance : constant Float;
4139 -- Performance constant set by implementation
4140 -- to match target architecture behavior.
4141
4142 procedure Treesort (Arg : String);
4143 -- Sorts characters of argument using N*logN sort
4144 pragma Postcondition
4145 (Float (Clock - Clock'Old) <=
4146 Float (Arg'Length) *
4147 log (Float (Arg'Length)) *
4148 Performance);
4149 end Sort;
4150 @end smallexample
4151
4152 @noindent
4153 Note: postcondition pragmas associated with subprograms that are
4154 marked as Inline_Always, or those marked as Inline with front-end
4155 inlining (-gnatN option set) are accepted and legality-checked
4156 by the compiler, but are ignored at run-time even if postcondition
4157 checking is enabled.
4158
4159 @node Pragma Precondition
4160 @unnumberedsec Pragma Precondition
4161 @cindex Preconditions
4162 @cindex Checks, preconditions
4163 @findex Preconditions
4164 @noindent
4165 Syntax:
4166
4167 @smallexample @c ada
4168 pragma Precondition (
4169 [Check =>] Boolean_Expression
4170 [,[Message =>] String_Expression]);
4171 @end smallexample
4172
4173 @noindent
4174 The @code{Precondition} pragma is similar to @code{Postcondition}
4175 except that the corresponding checks take place immediately upon
4176 entry to the subprogram, and if a precondition fails, the exception
4177 is raised in the context of the caller, and the attribute 'Result
4178 cannot be used within the precondition expression.
4179
4180 Otherwise, the placement and visibility rules are identical to those
4181 described for postconditions. The following is an example of use
4182 within a package spec:
4183
4184 @smallexample @c ada
4185 package Math_Functions is
4186 ...
4187 function Sqrt (Arg : Float) return Float;
4188 pragma Precondition (Arg >= 0.0)
4189 ...
4190 end Math_Functions;
4191 @end smallexample
4192
4193 @noindent
4194 @code{Precondition} pragmas may appear either immediately following the
4195 (separate) declaration of a subprogram, or at the start of the
4196 declarations of a subprogram body. Only other pragmas may intervene
4197 (that is appear between the subprogram declaration and its
4198 postconditions, or appear before the postcondition in the
4199 declaration sequence in a subprogram body).
4200
4201 Note: postcondition pragmas associated with subprograms that are
4202 marked as Inline_Always, or those marked as Inline with front-end
4203 inlining (-gnatN option set) are accepted and legality-checked
4204 by the compiler, but are ignored at run-time even if postcondition
4205 checking is enabled.
4206
4207 @node Pragma Profile (Ravenscar)
4208 @unnumberedsec Pragma Profile (Ravenscar)
4209 @findex Ravenscar
4210 @noindent
4211 Syntax:
4212
4213 @smallexample @c ada
4214 pragma Profile (Ravenscar);
4215 @end smallexample
4216
4217 @noindent
4218 A configuration pragma that establishes the following set of configuration
4219 pragmas:
4220
4221 @table @code
4222 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4223 [RM D.2.2] Tasks are dispatched following a preemptive
4224 priority-ordered scheduling policy.
4225
4226 @item Locking_Policy (Ceiling_Locking)
4227 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4228 the ceiling priority of the corresponding protected object.
4229 @c
4230 @c @item Detect_Blocking
4231 @c This pragma forces the detection of potentially blocking operations within a
4232 @c protected operation, and to raise Program_Error if that happens.
4233 @end table
4234 @noindent
4235
4236 plus the following set of restrictions:
4237
4238 @table @code
4239 @item Max_Entry_Queue_Length => 1
4240 Defines the maximum number of calls that are queued on a (protected) entry.
4241 Note that this restrictions is checked at run time. Violation of this
4242 restriction results in the raising of Program_Error exception at the point of
4243 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4244 always 1 and hence no task can be queued on a protected entry.
4245
4246 @item Max_Protected_Entries => 1
4247 [RM D.7] Specifies the maximum number of entries per protected type. The
4248 bounds of every entry family of a protected unit shall be static, or shall be
4249 defined by a discriminant of a subtype whose corresponding bound is static.
4250 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4251
4252 @item Max_Task_Entries => 0
4253 [RM D.7] Specifies the maximum number of entries
4254 per task. The bounds of every entry family
4255 of a task unit shall be static, or shall be
4256 defined by a discriminant of a subtype whose
4257 corresponding bound is static. A value of zero
4258 indicates that no rendezvous are possible. For
4259 the Profile (Ravenscar), the value of Max_Task_Entries is always
4260 0 (zero).
4261
4262 @item No_Abort_Statements
4263 [RM D.7] There are no abort_statements, and there are
4264 no calls to Task_Identification.Abort_Task.
4265
4266 @item No_Dynamic_Attachment
4267 There is no call to any of the operations defined in package Ada.Interrupts
4268 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4269 Detach_Handler, and Reference).
4270
4271 @item No_Dynamic_Priorities
4272 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4273
4274 @item No_Implicit_Heap_Allocations
4275 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4276
4277 @item No_Local_Protected_Objects
4278 Protected objects and access types that designate
4279 such objects shall be declared only at library level.
4280
4281 @item No_Local_Timing_Events
4282 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4283 declared at the library level.
4284
4285 @item No_Protected_Type_Allocators
4286 There are no allocators for protected types or
4287 types containing protected subcomponents.
4288
4289 @item No_Relative_Delay
4290 There are no delay_relative statements.
4291
4292 @item No_Requeue_Statements
4293 Requeue statements are not allowed.
4294
4295 @item No_Select_Statements
4296 There are no select_statements.
4297
4298 @item No_Specific_Termination_Handlers
4299 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4300 or to Ada.Task_Termination.Specific_Handler.
4301
4302 @item No_Task_Allocators
4303 [RM D.7] There are no allocators for task types
4304 or types containing task subcomponents.
4305
4306 @item No_Task_Hierarchy
4307 [RM D.7] All (non-environment) tasks depend
4308 directly on the environment task of the partition.
4309
4310 @item No_Task_Termination
4311 Tasks which terminate are erroneous.
4312
4313 @item Simple_Barriers
4314 Entry barrier condition expressions shall be either static
4315 boolean expressions or boolean objects which are declared in
4316 the protected type which contains the entry.
4317 @end table
4318 @noindent
4319
4320 The Ravenscar profile also includes the following restrictions that specify
4321 that there are no semantic dependences on the corresponding predefined
4322 packages:
4323
4324 @table @code
4325 @item No_Dependence => Ada.Asynchronous_Task_Control
4326 @item No_Dependence => Ada.Calendar
4327 @item No_Dependence => Ada.Execution_Time.Group_Budget
4328 @item No_Dependence => Ada.Execution_Time.Timers
4329 @item No_Dependence => Ada.Task_Attributes
4330 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4331 @end table
4332
4333 @noindent
4334
4335 This set of configuration pragmas and restrictions correspond to the
4336 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4337 published by the @cite{International Real-Time Ada Workshop}, 1997,
4338 and whose most recent description is available at
4339 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4340
4341 The original definition of the profile was revised at subsequent IRTAW
4342 meetings. It has been included in the ISO
4343 @cite{Guide for the Use of the Ada Programming Language in High
4344 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4345 the next revision of the standard. The formal definition given by
4346 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4347 AI-305) available at
4348 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4349 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4350
4351 The above set is a superset of the restrictions provided by pragma
4352 @code{Profile (Restricted)}, it includes six additional restrictions
4353 (@code{Simple_Barriers}, @code{No_Select_Statements},
4354 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4355 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4356 that pragma @code{Profile (Ravenscar)}, like the pragma
4357 @code{Profile (Restricted)},
4358 automatically causes the use of a simplified,
4359 more efficient version of the tasking run-time system.
4360
4361 @node Pragma Profile (Restricted)
4362 @unnumberedsec Pragma Profile (Restricted)
4363 @findex Restricted Run Time
4364 @noindent
4365 Syntax:
4366
4367 @smallexample @c ada
4368 pragma Profile (Restricted);
4369 @end smallexample
4370
4371 @noindent
4372 A configuration pragma that establishes the following set of restrictions:
4373
4374 @itemize @bullet
4375 @item No_Abort_Statements
4376 @item No_Entry_Queue
4377 @item No_Task_Hierarchy
4378 @item No_Task_Allocators
4379 @item No_Dynamic_Priorities
4380 @item No_Terminate_Alternatives
4381 @item No_Dynamic_Attachment
4382 @item No_Protected_Type_Allocators
4383 @item No_Local_Protected_Objects
4384 @item No_Requeue_Statements
4385 @item No_Task_Attributes_Package
4386 @item Max_Asynchronous_Select_Nesting = 0
4387 @item Max_Task_Entries = 0
4388 @item Max_Protected_Entries = 1
4389 @item Max_Select_Alternatives = 0
4390 @end itemize
4391
4392 @noindent
4393 This set of restrictions causes the automatic selection of a simplified
4394 version of the run time that provides improved performance for the
4395 limited set of tasking functionality permitted by this set of restrictions.
4396
4397 @node Pragma Psect_Object
4398 @unnumberedsec Pragma Psect_Object
4399 @findex Psect_Object
4400 @noindent
4401 Syntax:
4402
4403 @smallexample @c ada
4404 pragma Psect_Object (
4405 [Internal =>] LOCAL_NAME,
4406 [, [External =>] EXTERNAL_SYMBOL]
4407 [, [Size =>] EXTERNAL_SYMBOL]);
4408
4409 EXTERNAL_SYMBOL ::=
4410 IDENTIFIER
4411 | static_string_EXPRESSION
4412 @end smallexample
4413
4414 @noindent
4415 This pragma is identical in effect to pragma @code{Common_Object}.
4416
4417 @node Pragma Pure_Function
4418 @unnumberedsec Pragma Pure_Function
4419 @findex Pure_Function
4420 @noindent
4421 Syntax:
4422
4423 @smallexample @c ada
4424 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4425 @end smallexample
4426
4427 @noindent
4428 This pragma appears in the same declarative part as a function
4429 declaration (or a set of function declarations if more than one
4430 overloaded declaration exists, in which case the pragma applies
4431 to all entities). It specifies that the function @code{Entity} is
4432 to be considered pure for the purposes of code generation. This means
4433 that the compiler can assume that there are no side effects, and
4434 in particular that two calls with identical arguments produce the
4435 same result. It also means that the function can be used in an
4436 address clause.
4437
4438 Note that, quite deliberately, there are no static checks to try
4439 to ensure that this promise is met, so @code{Pure_Function} can be used
4440 with functions that are conceptually pure, even if they do modify
4441 global variables. For example, a square root function that is
4442 instrumented to count the number of times it is called is still
4443 conceptually pure, and can still be optimized, even though it
4444 modifies a global variable (the count). Memo functions are another
4445 example (where a table of previous calls is kept and consulted to
4446 avoid re-computation).
4447
4448 Note also that the normal rules excluding optimization of subprograms
4449 in pure units (when parameter types are descended from System.Address,
4450 or when the full view of a parameter type is limited), do not apply
4451 for the Pure_Function case. If you explicitly specify Pure_Function,
4452 the compiler may optimize away calls with identical arguments, and
4453 if that results in unexpected behavior, the proper action is not to
4454 use the pragma for subprograms that are not (conceptually) pure.
4455
4456 @findex Pure
4457 Note: Most functions in a @code{Pure} package are automatically pure, and
4458 there is no need to use pragma @code{Pure_Function} for such functions. One
4459 exception is any function that has at least one formal of type
4460 @code{System.Address} or a type derived from it. Such functions are not
4461 considered pure by default, since the compiler assumes that the
4462 @code{Address} parameter may be functioning as a pointer and that the
4463 referenced data may change even if the address value does not.
4464 Similarly, imported functions are not considered to be pure by default,
4465 since there is no way of checking that they are in fact pure. The use
4466 of pragma @code{Pure_Function} for such a function will override these default
4467 assumption, and cause the compiler to treat a designated subprogram as pure
4468 in these cases.
4469
4470 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4471 applies to the underlying renamed function. This can be used to
4472 disambiguate cases of overloading where some but not all functions
4473 in a set of overloaded functions are to be designated as pure.
4474
4475 If pragma @code{Pure_Function} is applied to a library level function, the
4476 function is also considered pure from an optimization point of view, but the
4477 unit is not a Pure unit in the categorization sense. So for example, a function
4478 thus marked is free to @code{with} non-pure units.
4479
4480 @node Pragma Restriction_Warnings
4481 @unnumberedsec Pragma Restriction_Warnings
4482 @findex Restriction_Warnings
4483 @noindent
4484 Syntax:
4485
4486 @smallexample @c ada
4487 pragma Restriction_Warnings
4488 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4489 @end smallexample
4490
4491 @noindent
4492 This pragma allows a series of restriction identifiers to be
4493 specified (the list of allowed identifiers is the same as for
4494 pragma @code{Restrictions}). For each of these identifiers
4495 the compiler checks for violations of the restriction, but
4496 generates a warning message rather than an error message
4497 if the restriction is violated.
4498
4499 @node Pragma Shared
4500 @unnumberedsec Pragma Shared
4501 @findex Shared
4502
4503 @noindent
4504 This pragma is provided for compatibility with Ada 83. The syntax and
4505 semantics are identical to pragma Atomic.
4506
4507 @node Pragma Short_Circuit_And_Or
4508 @unnumberedsec Pragma Short_Circuit_And_Or
4509 @findex Short_Circuit_And_Or
4510
4511 @noindent
4512 This configuration pragma causes any occurrence of the AND operator applied to
4513 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4514 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4515 may be useful in the context of certification protocols requiring the use of
4516 short-circuited logical operators. If this configuration pragma occurs locally
4517 within the file being compiled, it applies only to the file being compiled.
4518 There is no requirement that all units in a partition use this option.
4519
4520 @node Pragma Short_Descriptors
4521 @unnumberedsec Pragma Short_Descriptors
4522 @findex Short_Descriptors
4523 @noindent
4524 Syntax:
4525
4526 @smallexample @c ada
4527 pragma Short_Descriptors
4528 @end smallexample
4529
4530 @noindent
4531 In VMS versions of the compiler, this configuration pragma causes all
4532 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4533 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4534 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4535 versions.
4536
4537 @node Pragma Source_File_Name
4538 @unnumberedsec Pragma Source_File_Name
4539 @findex Source_File_Name
4540 @noindent
4541 Syntax:
4542
4543 @smallexample @c ada
4544 pragma Source_File_Name (
4545 [Unit_Name =>] unit_NAME,
4546 Spec_File_Name => STRING_LITERAL,
4547 [Index => INTEGER_LITERAL]);
4548
4549 pragma Source_File_Name (
4550 [Unit_Name =>] unit_NAME,
4551 Body_File_Name => STRING_LITERAL,
4552 [Index => INTEGER_LITERAL]);
4553 @end smallexample
4554
4555 @noindent
4556 Use this to override the normal naming convention. It is a configuration
4557 pragma, and so has the usual applicability of configuration pragmas
4558 (i.e.@: it applies to either an entire partition, or to all units in a
4559 compilation, or to a single unit, depending on how it is used.
4560 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4561 the second argument is required, and indicates whether this is the file
4562 name for the spec or for the body.
4563
4564 The optional Index argument should be used when a file contains multiple
4565 units, and when you do not want to use @code{gnatchop} to separate then
4566 into multiple files (which is the recommended procedure to limit the
4567 number of recompilations that are needed when some sources change).
4568 For instance, if the source file @file{source.ada} contains
4569
4570 @smallexample @c ada
4571 package B is
4572 ...
4573 end B;
4574
4575 with B;
4576 procedure A is
4577 begin
4578 ..
4579 end A;
4580 @end smallexample
4581
4582 you could use the following configuration pragmas:
4583
4584 @smallexample @c ada
4585 pragma Source_File_Name
4586 (B, Spec_File_Name => "source.ada", Index => 1);
4587 pragma Source_File_Name
4588 (A, Body_File_Name => "source.ada", Index => 2);
4589 @end smallexample
4590
4591 Note that the @code{gnatname} utility can also be used to generate those
4592 configuration pragmas.
4593
4594 Another form of the @code{Source_File_Name} pragma allows
4595 the specification of patterns defining alternative file naming schemes
4596 to apply to all files.
4597
4598 @smallexample @c ada
4599 pragma Source_File_Name
4600 ( [Spec_File_Name =>] STRING_LITERAL
4601 [,[Casing =>] CASING_SPEC]
4602 [,[Dot_Replacement =>] STRING_LITERAL]);
4603
4604 pragma Source_File_Name
4605 ( [Body_File_Name =>] STRING_LITERAL
4606 [,[Casing =>] CASING_SPEC]
4607 [,[Dot_Replacement =>] STRING_LITERAL]);
4608
4609 pragma Source_File_Name
4610 ( [Subunit_File_Name =>] STRING_LITERAL
4611 [,[Casing =>] CASING_SPEC]
4612 [,[Dot_Replacement =>] STRING_LITERAL]);
4613
4614 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4615 @end smallexample
4616
4617 @noindent
4618 The first argument is a pattern that contains a single asterisk indicating
4619 the point at which the unit name is to be inserted in the pattern string
4620 to form the file name. The second argument is optional. If present it
4621 specifies the casing of the unit name in the resulting file name string.
4622 The default is lower case. Finally the third argument allows for systematic
4623 replacement of any dots in the unit name by the specified string literal.
4624
4625 Note that Source_File_Name pragmas should not be used if you are using
4626 project files. The reason for this rule is that the project manager is not
4627 aware of these pragmas, and so other tools that use the projet file would not
4628 be aware of the intended naming conventions. If you are using project files,
4629 file naming is controlled by Source_File_Name_Project pragmas, which are
4630 usually supplied automatically by the project manager. A pragma
4631 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4632
4633 For more details on the use of the @code{Source_File_Name} pragma,
4634 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4635 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4636 User's Guide}.
4637
4638 @node Pragma Source_File_Name_Project
4639 @unnumberedsec Pragma Source_File_Name_Project
4640 @findex Source_File_Name_Project
4641 @noindent
4642
4643 This pragma has the same syntax and semantics as pragma Source_File_Name.
4644 It is only allowed as a stand alone configuration pragma.
4645 It cannot appear after a @ref{Pragma Source_File_Name}, and
4646 most importantly, once pragma Source_File_Name_Project appears,
4647 no further Source_File_Name pragmas are allowed.
4648
4649 The intention is that Source_File_Name_Project pragmas are always
4650 generated by the Project Manager in a manner consistent with the naming
4651 specified in a project file, and when naming is controlled in this manner,
4652 it is not permissible to attempt to modify this naming scheme using
4653 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4654 known to the project manager).
4655
4656 @node Pragma Source_Reference
4657 @unnumberedsec Pragma Source_Reference
4658 @findex Source_Reference
4659 @noindent
4660 Syntax:
4661
4662 @smallexample @c ada
4663 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4664 @end smallexample
4665
4666 @noindent
4667 This pragma must appear as the first line of a source file.
4668 @var{integer_literal} is the logical line number of the line following
4669 the pragma line (for use in error messages and debugging
4670 information). @var{string_literal} is a static string constant that
4671 specifies the file name to be used in error messages and debugging
4672 information. This is most notably used for the output of @code{gnatchop}
4673 with the @option{-r} switch, to make sure that the original unchopped
4674 source file is the one referred to.
4675
4676 The second argument must be a string literal, it cannot be a static
4677 string expression other than a string literal. This is because its value
4678 is needed for error messages issued by all phases of the compiler.
4679
4680 @node Pragma Static_Elaboration_Desired
4681 @unnumberedsec Pragma Static_Elaboration_Desired
4682 @findex Static_Elaboration_Desired
4683 @noindent
4684 Syntax:
4685
4686 @smallexample @c ada
4687 pragma Static_Elaboration_Desired;
4688 @end smallexample
4689
4690 @noindent
4691 This pragma is used to indicate that the compiler should attempt to initialize
4692 statically the objects declared in the library unit to which the pragma applies,
4693 when these objects are initialized (explicitly or implicitly) by an aggregate.
4694 In the absence of this pragma, aggregates in object declarations are expanded
4695 into assignments and loops, even when the aggregate components are static
4696 constants. When the aggregate is present the compiler builds a static expression
4697 that requires no run-time code, so that the initialized object can be placed in
4698 read-only data space. If the components are not static, or the aggregate has
4699 more that 100 components, the compiler emits a warning that the pragma cannot
4700 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4701 construction of larger aggregates with static components that include an others
4702 choice.)
4703
4704 @node Pragma Stream_Convert
4705 @unnumberedsec Pragma Stream_Convert
4706 @findex Stream_Convert
4707 @noindent
4708 Syntax:
4709
4710 @smallexample @c ada
4711 pragma Stream_Convert (
4712 [Entity =>] type_LOCAL_NAME,
4713 [Read =>] function_NAME,
4714 [Write =>] function_NAME);
4715 @end smallexample
4716
4717 @noindent
4718 This pragma provides an efficient way of providing stream functions for
4719 types defined in packages. Not only is it simpler to use than declaring
4720 the necessary functions with attribute representation clauses, but more
4721 significantly, it allows the declaration to made in such a way that the
4722 stream packages are not loaded unless they are needed. The use of
4723 the Stream_Convert pragma adds no overhead at all, unless the stream
4724 attributes are actually used on the designated type.
4725
4726 The first argument specifies the type for which stream functions are
4727 provided. The second parameter provides a function used to read values
4728 of this type. It must name a function whose argument type may be any
4729 subtype, and whose returned type must be the type given as the first
4730 argument to the pragma.
4731
4732 The meaning of the @var{Read}
4733 parameter is that if a stream attribute directly
4734 or indirectly specifies reading of the type given as the first parameter,
4735 then a value of the type given as the argument to the Read function is
4736 read from the stream, and then the Read function is used to convert this
4737 to the required target type.
4738
4739 Similarly the @var{Write} parameter specifies how to treat write attributes
4740 that directly or indirectly apply to the type given as the first parameter.
4741 It must have an input parameter of the type specified by the first parameter,
4742 and the return type must be the same as the input type of the Read function.
4743 The effect is to first call the Write function to convert to the given stream
4744 type, and then write the result type to the stream.
4745
4746 The Read and Write functions must not be overloaded subprograms. If necessary
4747 renamings can be supplied to meet this requirement.
4748 The usage of this attribute is best illustrated by a simple example, taken
4749 from the GNAT implementation of package Ada.Strings.Unbounded:
4750
4751 @smallexample @c ada
4752 function To_Unbounded (S : String)
4753 return Unbounded_String
4754 renames To_Unbounded_String;
4755
4756 pragma Stream_Convert
4757 (Unbounded_String, To_Unbounded, To_String);
4758 @end smallexample
4759
4760 @noindent
4761 The specifications of the referenced functions, as given in the Ada
4762 Reference Manual are:
4763
4764 @smallexample @c ada
4765 function To_Unbounded_String (Source : String)
4766 return Unbounded_String;
4767
4768 function To_String (Source : Unbounded_String)
4769 return String;
4770 @end smallexample
4771
4772 @noindent
4773 The effect is that if the value of an unbounded string is written to a stream,
4774 then the representation of the item in the stream is in the same format that
4775 would be used for @code{Standard.String'Output}, and this same representation
4776 is expected when a value of this type is read from the stream. Note that the
4777 value written always includes the bounds, even for Unbounded_String'Write,
4778 since Unbounded_String is not an array type.
4779
4780 @node Pragma Style_Checks
4781 @unnumberedsec Pragma Style_Checks
4782 @findex Style_Checks
4783 @noindent
4784 Syntax:
4785
4786 @smallexample @c ada
4787 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4788 On | Off [, LOCAL_NAME]);
4789 @end smallexample
4790
4791 @noindent
4792 This pragma is used in conjunction with compiler switches to control the
4793 built in style checking provided by GNAT@. The compiler switches, if set,
4794 provide an initial setting for the switches, and this pragma may be used
4795 to modify these settings, or the settings may be provided entirely by
4796 the use of the pragma. This pragma can be used anywhere that a pragma
4797 is legal, including use as a configuration pragma (including use in
4798 the @file{gnat.adc} file).
4799
4800 The form with a string literal specifies which style options are to be
4801 activated. These are additive, so they apply in addition to any previously
4802 set style check options. The codes for the options are the same as those
4803 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4804 For example the following two methods can be used to enable
4805 layout checking:
4806
4807 @itemize @bullet
4808 @item
4809 @smallexample @c ada
4810 pragma Style_Checks ("l");
4811 @end smallexample
4812
4813 @item
4814 @smallexample
4815 gcc -c -gnatyl @dots{}
4816 @end smallexample
4817 @end itemize
4818
4819 @noindent
4820 The form ALL_CHECKS activates all standard checks (its use is equivalent
4821 to the use of the @code{gnaty} switch with no options. @xref{Top,
4822 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4823 @value{EDITION} User's Guide}, for details.)
4824
4825 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4826 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4827 options (i.e. equivalent to -gnatyg).
4828
4829 The forms with @code{Off} and @code{On}
4830 can be used to temporarily disable style checks
4831 as shown in the following example:
4832
4833 @smallexample @c ada
4834 @iftex
4835 @leftskip=0cm
4836 @end iftex
4837 pragma Style_Checks ("k"); -- requires keywords in lower case
4838 pragma Style_Checks (Off); -- turn off style checks
4839 NULL; -- this will not generate an error message
4840 pragma Style_Checks (On); -- turn style checks back on
4841 NULL; -- this will generate an error message
4842 @end smallexample
4843
4844 @noindent
4845 Finally the two argument form is allowed only if the first argument is
4846 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4847 for the specified entity, as shown in the following example:
4848
4849 @smallexample @c ada
4850 @iftex
4851 @leftskip=0cm
4852 @end iftex
4853 pragma Style_Checks ("r"); -- require consistency of identifier casing
4854 Arg : Integer;
4855 Rf1 : Integer := ARG; -- incorrect, wrong case
4856 pragma Style_Checks (Off, Arg);
4857 Rf2 : Integer := ARG; -- OK, no error
4858 @end smallexample
4859
4860 @node Pragma Subtitle
4861 @unnumberedsec Pragma Subtitle
4862 @findex Subtitle
4863 @noindent
4864 Syntax:
4865
4866 @smallexample @c ada
4867 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4868 @end smallexample
4869
4870 @noindent
4871 This pragma is recognized for compatibility with other Ada compilers
4872 but is ignored by GNAT@.
4873
4874 @node Pragma Suppress
4875 @unnumberedsec Pragma Suppress
4876 @findex Suppress
4877 @noindent
4878 Syntax:
4879
4880 @smallexample @c ada
4881 pragma Suppress (Identifier [, [On =>] Name]);
4882 @end smallexample
4883
4884 @noindent
4885 This is a standard pragma, and supports all the check names required in
4886 the RM. It is included here because GNAT recognizes one additional check
4887 name: @code{Alignment_Check} which can be used to suppress alignment checks
4888 on addresses used in address clauses. Such checks can also be suppressed
4889 by suppressing range checks, but the specific use of @code{Alignment_Check}
4890 allows suppression of alignment checks without suppressing other range checks.
4891
4892 Note that pragma Suppress gives the compiler permission to omit
4893 checks, but does not require the compiler to omit checks. The compiler
4894 will generate checks if they are essentially free, even when they are
4895 suppressed. In particular, if the compiler can prove that a certain
4896 check will necessarily fail, it will generate code to do an
4897 unconditional ``raise'', even if checks are suppressed. The compiler
4898 warns in this case.
4899
4900 Of course, run-time checks are omitted whenever the compiler can prove
4901 that they will not fail, whether or not checks are suppressed.
4902
4903 @node Pragma Suppress_All
4904 @unnumberedsec Pragma Suppress_All
4905 @findex Suppress_All
4906 @noindent
4907 Syntax:
4908
4909 @smallexample @c ada
4910 pragma Suppress_All;
4911 @end smallexample
4912
4913 @noindent
4914 This pragma can appear anywhere within a unit.
4915 The effect is to apply @code{Suppress (All_Checks)} to the unit
4916 in which it appears. This pragma is implemented for compatibility with DEC
4917 Ada 83 usage where it appears at the end of a unit, and for compatibility
4918 with Rational Ada, where it appears as a program unit pragma.
4919 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4920 as a normal configuration pragma is the preferred usage in GNAT@.
4921
4922 @node Pragma Suppress_Exception_Locations
4923 @unnumberedsec Pragma Suppress_Exception_Locations
4924 @findex Suppress_Exception_Locations
4925 @noindent
4926 Syntax:
4927
4928 @smallexample @c ada
4929 pragma Suppress_Exception_Locations;
4930 @end smallexample
4931
4932 @noindent
4933 In normal mode, a raise statement for an exception by default generates
4934 an exception message giving the file name and line number for the location
4935 of the raise. This is useful for debugging and logging purposes, but this
4936 entails extra space for the strings for the messages. The configuration
4937 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4938 generation of these strings, with the result that space is saved, but the
4939 exception message for such raises is null. This configuration pragma may
4940 appear in a global configuration pragma file, or in a specific unit as
4941 usual. It is not required that this pragma be used consistently within
4942 a partition, so it is fine to have some units within a partition compiled
4943 with this pragma and others compiled in normal mode without it.
4944
4945 @node Pragma Suppress_Initialization
4946 @unnumberedsec Pragma Suppress_Initialization
4947 @findex Suppress_Initialization
4948 @cindex Suppressing initialization
4949 @cindex Initialization, suppression of
4950 @noindent
4951 Syntax:
4952
4953 @smallexample @c ada
4954 pragma Suppress_Initialization ([Entity =>] type_Name);
4955 @end smallexample
4956
4957 @noindent
4958 This pragma suppresses any implicit or explicit initialization
4959 associated with the given type name for all variables of this type,
4960 including initialization resulting from the use of pragmas
4961 Normalize_Scalars or Initialize_Scalars.
4962
4963 This is considered a representation item, so it cannot be given after
4964 the type is frozen. It applies to all subsequent object declarations,
4965 and also any allocator that creates objects of the type.
4966
4967 If the pragma is given for the first subtype, then it is considered
4968 to apply to the base type and all its subtypes. If the pragma is given
4969 for other than a first subtype, then it applies only to the given subtype.
4970 The pragma may not be given after the type is frozen.
4971
4972 @node Pragma Task_Info
4973 @unnumberedsec Pragma Task_Info
4974 @findex Task_Info
4975 @noindent
4976 Syntax
4977
4978 @smallexample @c ada
4979 pragma Task_Info (EXPRESSION);
4980 @end smallexample
4981
4982 @noindent
4983 This pragma appears within a task definition (like pragma
4984 @code{Priority}) and applies to the task in which it appears. The
4985 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4986 The @code{Task_Info} pragma provides system dependent control over
4987 aspects of tasking implementation, for example, the ability to map
4988 tasks to specific processors. For details on the facilities available
4989 for the version of GNAT that you are using, see the documentation
4990 in the spec of package System.Task_Info in the runtime
4991 library.
4992
4993 @node Pragma Task_Name
4994 @unnumberedsec Pragma Task_Name
4995 @findex Task_Name
4996 @noindent
4997 Syntax
4998
4999 @smallexample @c ada
5000 pragma Task_Name (string_EXPRESSION);
5001 @end smallexample
5002
5003 @noindent
5004 This pragma appears within a task definition (like pragma
5005 @code{Priority}) and applies to the task in which it appears. The
5006 argument must be of type String, and provides a name to be used for
5007 the task instance when the task is created. Note that this expression
5008 is not required to be static, and in particular, it can contain
5009 references to task discriminants. This facility can be used to
5010 provide different names for different tasks as they are created,
5011 as illustrated in the example below.
5012
5013 The task name is recorded internally in the run-time structures
5014 and is accessible to tools like the debugger. In addition the
5015 routine @code{Ada.Task_Identification.Image} will return this
5016 string, with a unique task address appended.
5017
5018 @smallexample @c ada
5019 -- Example of the use of pragma Task_Name
5020
5021 with Ada.Task_Identification;
5022 use Ada.Task_Identification;
5023 with Text_IO; use Text_IO;
5024 procedure t3 is
5025
5026 type Astring is access String;
5027
5028 task type Task_Typ (Name : access String) is
5029 pragma Task_Name (Name.all);
5030 end Task_Typ;
5031
5032 task body Task_Typ is
5033 Nam : constant String := Image (Current_Task);
5034 begin
5035 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5036 end Task_Typ;
5037
5038 type Ptr_Task is access Task_Typ;
5039 Task_Var : Ptr_Task;
5040
5041 begin
5042 Task_Var :=
5043 new Task_Typ (new String'("This is task 1"));
5044 Task_Var :=
5045 new Task_Typ (new String'("This is task 2"));
5046 end;
5047 @end smallexample
5048
5049 @node Pragma Task_Storage
5050 @unnumberedsec Pragma Task_Storage
5051 @findex Task_Storage
5052 Syntax:
5053
5054 @smallexample @c ada
5055 pragma Task_Storage (
5056 [Task_Type =>] LOCAL_NAME,
5057 [Top_Guard =>] static_integer_EXPRESSION);
5058 @end smallexample
5059
5060 @noindent
5061 This pragma specifies the length of the guard area for tasks. The guard
5062 area is an additional storage area allocated to a task. A value of zero
5063 means that either no guard area is created or a minimal guard area is
5064 created, depending on the target. This pragma can appear anywhere a
5065 @code{Storage_Size} attribute definition clause is allowed for a task
5066 type.
5067
5068 @node Pragma Test_Case
5069 @unnumberedsec Pragma Test_Case
5070 @cindex Test cases
5071 @findex Test_Case
5072 @noindent
5073 Syntax:
5074
5075 @smallexample @c ada
5076 pragma Test_Case (
5077 [Name =>] static_string_Expression
5078 ,[Mode =>] (Nominal | Robustness)
5079 [, Requires => Boolean_Expression]
5080 [, Ensures => Boolean_Expression]);
5081 @end smallexample
5082
5083 @noindent
5084 The @code{Test_Case} pragma allows defining fine-grain specifications
5085 for use by testing and verification tools. The compiler checks its
5086 validity but the presence of pragma @code{Test_Case} does not lead to
5087 any modification of the code generated by the compiler.
5088
5089 @code{Test_Case} pragmas may only appear immediately following the
5090 (separate) declaration of a subprogram in a package declaration, inside
5091 a package spec unit. Only other pragmas may intervene (that is appear
5092 between the subprogram declaration and a test case).
5093
5094 The compiler checks that boolean expressions given in @code{Requires} and
5095 @code{Ensures} are valid, where the rules for @code{Requires} are the
5096 same as the rule for an expression in @code{Precondition} and the rules
5097 for @code{Ensures} are the same as the rule for an expression in
5098 @code{Postcondition}. In particular, attributes @code{'Old} and
5099 @code{'Result} can only be used within the @code{Ensures}
5100 expression. The following is an example of use within a package spec:
5101
5102 @smallexample @c ada
5103 package Math_Functions is
5104 ...
5105 function Sqrt (Arg : Float) return Float;
5106 pragma Test_Case (Name => "Test 1",
5107 Mode => Nominal,
5108 Requires => Arg < 100,
5109 Ensures => Sqrt'Result < 10);
5110 ...
5111 end Math_Functions;
5112 @end smallexample
5113
5114 @noindent
5115 The meaning of a test case is that, if the associated subprogram is
5116 executed in a context where @code{Requires} holds, then @code{Ensures}
5117 should hold when the subprogram returns. Mode @code{Nominal} indicates
5118 that the input context should satisfy the precondition of the
5119 subprogram, and the output context should then satisfy its
5120 postcondition. More @code{Robustness} indicates that the pre- and
5121 postcondition of the subprogram should be ignored for this test case.
5122
5123 @node Pragma Thread_Local_Storage
5124 @unnumberedsec Pragma Thread_Local_Storage
5125 @findex Thread_Local_Storage
5126 @cindex Task specific storage
5127 @cindex TLS (Thread Local Storage)
5128 Syntax:
5129
5130 @smallexample @c ada
5131 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5132 @end smallexample
5133
5134 @noindent
5135 This pragma specifies that the specified entity, which must be
5136 a variable declared in a library level package, is to be marked as
5137 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5138 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5139 (and hence each Ada task) to see a distinct copy of the variable.
5140
5141 The variable may not have default initialization, and if there is
5142 an explicit initialization, it must be either @code{null} for an
5143 access variable, or a static expression for a scalar variable.
5144 This provides a low level mechanism similar to that provided by
5145 the @code{Ada.Task_Attributes} package, but much more efficient
5146 and is also useful in writing interface code that will interact
5147 with foreign threads.
5148
5149 If this pragma is used on a system where @code{TLS} is not supported,
5150 then an error message will be generated and the program will be rejected.
5151
5152 @node Pragma Time_Slice
5153 @unnumberedsec Pragma Time_Slice
5154 @findex Time_Slice
5155 @noindent
5156 Syntax:
5157
5158 @smallexample @c ada
5159 pragma Time_Slice (static_duration_EXPRESSION);
5160 @end smallexample
5161
5162 @noindent
5163 For implementations of GNAT on operating systems where it is possible
5164 to supply a time slice value, this pragma may be used for this purpose.
5165 It is ignored if it is used in a system that does not allow this control,
5166 or if it appears in other than the main program unit.
5167 @cindex OpenVMS
5168 Note that the effect of this pragma is identical to the effect of the
5169 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5170
5171 @node Pragma Title
5172 @unnumberedsec Pragma Title
5173 @findex Title
5174 @noindent
5175 Syntax:
5176
5177 @smallexample @c ada
5178 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5179
5180 TITLING_OPTION ::=
5181 [Title =>] STRING_LITERAL,
5182 | [Subtitle =>] STRING_LITERAL
5183 @end smallexample
5184
5185 @noindent
5186 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5187 pragma used in DEC Ada 83 implementations to provide a title and/or
5188 subtitle for the program listing. The program listing generated by GNAT
5189 does not have titles or subtitles.
5190
5191 Unlike other pragmas, the full flexibility of named notation is allowed
5192 for this pragma, i.e.@: the parameters may be given in any order if named
5193 notation is used, and named and positional notation can be mixed
5194 following the normal rules for procedure calls in Ada.
5195
5196 @node Pragma Unchecked_Union
5197 @unnumberedsec Pragma Unchecked_Union
5198 @cindex Unions in C
5199 @findex Unchecked_Union
5200 @noindent
5201 Syntax:
5202
5203 @smallexample @c ada
5204 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5205 @end smallexample
5206
5207 @noindent
5208 This pragma is used to specify a representation of a record type that is
5209 equivalent to a C union. It was introduced as a GNAT implementation defined
5210 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5211 pragma, making it language defined, and GNAT fully implements this extended
5212 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5213 details, consult the Ada 2005 Reference Manual, section B.3.3.
5214
5215 @node Pragma Unimplemented_Unit
5216 @unnumberedsec Pragma Unimplemented_Unit
5217 @findex Unimplemented_Unit
5218 @noindent
5219 Syntax:
5220
5221 @smallexample @c ada
5222 pragma Unimplemented_Unit;
5223 @end smallexample
5224
5225 @noindent
5226 If this pragma occurs in a unit that is processed by the compiler, GNAT
5227 aborts with the message @samp{@var{xxx} not implemented}, where
5228 @var{xxx} is the name of the current compilation unit. This pragma is
5229 intended to allow the compiler to handle unimplemented library units in
5230 a clean manner.
5231
5232 The abort only happens if code is being generated. Thus you can use
5233 specs of unimplemented packages in syntax or semantic checking mode.
5234
5235 @node Pragma Universal_Aliasing
5236 @unnumberedsec Pragma Universal_Aliasing
5237 @findex Universal_Aliasing
5238 @noindent
5239 Syntax:
5240
5241 @smallexample @c ada
5242 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5243 @end smallexample
5244
5245 @noindent
5246 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5247 declarative part. The effect is to inhibit strict type-based aliasing
5248 optimization for the given type. In other words, the effect is as though
5249 access types designating this type were subject to pragma No_Strict_Aliasing.
5250 For a detailed description of the strict aliasing optimization, and the
5251 situations in which it must be suppressed, @xref{Optimization and Strict
5252 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5253
5254 @node Pragma Universal_Data
5255 @unnumberedsec Pragma Universal_Data
5256 @findex Universal_Data
5257 @noindent
5258 Syntax:
5259
5260 @smallexample @c ada
5261 pragma Universal_Data [(library_unit_Name)];
5262 @end smallexample
5263
5264 @noindent
5265 This pragma is supported only for the AAMP target and is ignored for
5266 other targets. The pragma specifies that all library-level objects
5267 (Counter 0 data) associated with the library unit are to be accessed
5268 and updated using universal addressing (24-bit addresses for AAMP5)
5269 rather than the default of 16-bit Data Environment (DENV) addressing.
5270 Use of this pragma will generally result in less efficient code for
5271 references to global data associated with the library unit, but
5272 allows such data to be located anywhere in memory. This pragma is
5273 a library unit pragma, but can also be used as a configuration pragma
5274 (including use in the @file{gnat.adc} file). The functionality
5275 of this pragma is also available by applying the -univ switch on the
5276 compilations of units where universal addressing of the data is desired.
5277
5278 @node Pragma Unmodified
5279 @unnumberedsec Pragma Unmodified
5280 @findex Unmodified
5281 @cindex Warnings, unmodified
5282 @noindent
5283 Syntax:
5284
5285 @smallexample @c ada
5286 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5287 @end smallexample
5288
5289 @noindent
5290 This pragma signals that the assignable entities (variables,
5291 @code{out} parameters, @code{in out} parameters) whose names are listed are
5292 deliberately not assigned in the current source unit. This
5293 suppresses warnings about the
5294 entities being referenced but not assigned, and in addition a warning will be
5295 generated if one of these entities is in fact assigned in the
5296 same unit as the pragma (or in the corresponding body, or one
5297 of its subunits).
5298
5299 This is particularly useful for clearly signaling that a particular
5300 parameter is not modified, even though the spec suggests that it might
5301 be.
5302
5303 @node Pragma Unreferenced
5304 @unnumberedsec Pragma Unreferenced
5305 @findex Unreferenced
5306 @cindex Warnings, unreferenced
5307 @noindent
5308 Syntax:
5309
5310 @smallexample @c ada
5311 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5312 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5313 @end smallexample
5314
5315 @noindent
5316 This pragma signals that the entities whose names are listed are
5317 deliberately not referenced in the current source unit. This
5318 suppresses warnings about the
5319 entities being unreferenced, and in addition a warning will be
5320 generated if one of these entities is in fact referenced in the
5321 same unit as the pragma (or in the corresponding body, or one
5322 of its subunits).
5323
5324 This is particularly useful for clearly signaling that a particular
5325 parameter is not referenced in some particular subprogram implementation
5326 and that this is deliberate. It can also be useful in the case of
5327 objects declared only for their initialization or finalization side
5328 effects.
5329
5330 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5331 current scope, then the entity most recently declared is the one to which
5332 the pragma applies. Note that in the case of accept formals, the pragma
5333 Unreferenced may appear immediately after the keyword @code{do} which
5334 allows the indication of whether or not accept formals are referenced
5335 or not to be given individually for each accept statement.
5336
5337 The left hand side of an assignment does not count as a reference for the
5338 purpose of this pragma. Thus it is fine to assign to an entity for which
5339 pragma Unreferenced is given.
5340
5341 Note that if a warning is desired for all calls to a given subprogram,
5342 regardless of whether they occur in the same unit as the subprogram
5343 declaration, then this pragma should not be used (calls from another
5344 unit would not be flagged); pragma Obsolescent can be used instead
5345 for this purpose, see @xref{Pragma Obsolescent}.
5346
5347 The second form of pragma @code{Unreferenced} is used within a context
5348 clause. In this case the arguments must be unit names of units previously
5349 mentioned in @code{with} clauses (similar to the usage of pragma
5350 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5351 units and unreferenced entities within these units.
5352
5353 @node Pragma Unreferenced_Objects
5354 @unnumberedsec Pragma Unreferenced_Objects
5355 @findex Unreferenced_Objects
5356 @cindex Warnings, unreferenced
5357 @noindent
5358 Syntax:
5359
5360 @smallexample @c ada
5361 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5362 @end smallexample
5363
5364 @noindent
5365 This pragma signals that for the types or subtypes whose names are
5366 listed, objects which are declared with one of these types or subtypes may
5367 not be referenced, and if no references appear, no warnings are given.
5368
5369 This is particularly useful for objects which are declared solely for their
5370 initialization and finalization effect. Such variables are sometimes referred
5371 to as RAII variables (Resource Acquisition Is Initialization). Using this
5372 pragma on the relevant type (most typically a limited controlled type), the
5373 compiler will automatically suppress unwanted warnings about these variables
5374 not being referenced.
5375
5376 @node Pragma Unreserve_All_Interrupts
5377 @unnumberedsec Pragma Unreserve_All_Interrupts
5378 @findex Unreserve_All_Interrupts
5379 @noindent
5380 Syntax:
5381
5382 @smallexample @c ada
5383 pragma Unreserve_All_Interrupts;
5384 @end smallexample
5385
5386 @noindent
5387 Normally certain interrupts are reserved to the implementation. Any attempt
5388 to attach an interrupt causes Program_Error to be raised, as described in
5389 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5390 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5391 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5392 interrupt execution.
5393
5394 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5395 a program, then all such interrupts are unreserved. This allows the
5396 program to handle these interrupts, but disables their standard
5397 functions. For example, if this pragma is used, then pressing
5398 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5399 a program can then handle the @code{SIGINT} interrupt as it chooses.
5400
5401 For a full list of the interrupts handled in a specific implementation,
5402 see the source code for the spec of @code{Ada.Interrupts.Names} in
5403 file @file{a-intnam.ads}. This is a target dependent file that contains the
5404 list of interrupts recognized for a given target. The documentation in
5405 this file also specifies what interrupts are affected by the use of
5406 the @code{Unreserve_All_Interrupts} pragma.
5407
5408 For a more general facility for controlling what interrupts can be
5409 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5410 of the @code{Unreserve_All_Interrupts} pragma.
5411
5412 @node Pragma Unsuppress
5413 @unnumberedsec Pragma Unsuppress
5414 @findex Unsuppress
5415 @noindent
5416 Syntax:
5417
5418 @smallexample @c ada
5419 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5420 @end smallexample
5421
5422 @noindent
5423 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5424 there is no corresponding pragma @code{Suppress} in effect, it has no
5425 effect. The range of the effect is the same as for pragma
5426 @code{Suppress}. The meaning of the arguments is identical to that used
5427 in pragma @code{Suppress}.
5428
5429 One important application is to ensure that checks are on in cases where
5430 code depends on the checks for its correct functioning, so that the code
5431 will compile correctly even if the compiler switches are set to suppress
5432 checks.
5433
5434 @node Pragma Use_VADS_Size
5435 @unnumberedsec Pragma Use_VADS_Size
5436 @cindex @code{Size}, VADS compatibility
5437 @findex Use_VADS_Size
5438 @noindent
5439 Syntax:
5440
5441 @smallexample @c ada
5442 pragma Use_VADS_Size;
5443 @end smallexample
5444
5445 @noindent
5446 This is a configuration pragma. In a unit to which it applies, any use
5447 of the 'Size attribute is automatically interpreted as a use of the
5448 'VADS_Size attribute. Note that this may result in incorrect semantic
5449 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5450 the handling of existing code which depends on the interpretation of Size
5451 as implemented in the VADS compiler. See description of the VADS_Size
5452 attribute for further details.
5453
5454 @node Pragma Validity_Checks
5455 @unnumberedsec Pragma Validity_Checks
5456 @findex Validity_Checks
5457 @noindent
5458 Syntax:
5459
5460 @smallexample @c ada
5461 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5462 @end smallexample
5463
5464 @noindent
5465 This pragma is used in conjunction with compiler switches to control the
5466 built-in validity checking provided by GNAT@. The compiler switches, if set
5467 provide an initial setting for the switches, and this pragma may be used
5468 to modify these settings, or the settings may be provided entirely by
5469 the use of the pragma. This pragma can be used anywhere that a pragma
5470 is legal, including use as a configuration pragma (including use in
5471 the @file{gnat.adc} file).
5472
5473 The form with a string literal specifies which validity options are to be
5474 activated. The validity checks are first set to include only the default
5475 reference manual settings, and then a string of letters in the string
5476 specifies the exact set of options required. The form of this string
5477 is exactly as described for the @option{-gnatVx} compiler switch (see the
5478 GNAT users guide for details). For example the following two methods
5479 can be used to enable validity checking for mode @code{in} and
5480 @code{in out} subprogram parameters:
5481
5482 @itemize @bullet
5483 @item
5484 @smallexample @c ada
5485 pragma Validity_Checks ("im");
5486 @end smallexample
5487
5488 @item
5489 @smallexample
5490 gcc -c -gnatVim @dots{}
5491 @end smallexample
5492 @end itemize
5493
5494 @noindent
5495 The form ALL_CHECKS activates all standard checks (its use is equivalent
5496 to the use of the @code{gnatva} switch.
5497
5498 The forms with @code{Off} and @code{On}
5499 can be used to temporarily disable validity checks
5500 as shown in the following example:
5501
5502 @smallexample @c ada
5503 @iftex
5504 @leftskip=0cm
5505 @end iftex
5506 pragma Validity_Checks ("c"); -- validity checks for copies
5507 pragma Validity_Checks (Off); -- turn off validity checks
5508 A := B; -- B will not be validity checked
5509 pragma Validity_Checks (On); -- turn validity checks back on
5510 A := C; -- C will be validity checked
5511 @end smallexample
5512
5513 @node Pragma Volatile
5514 @unnumberedsec Pragma Volatile
5515 @findex Volatile
5516 @noindent
5517 Syntax:
5518
5519 @smallexample @c ada
5520 pragma Volatile (LOCAL_NAME);
5521 @end smallexample
5522
5523 @noindent
5524 This pragma is defined by the Ada Reference Manual, and the GNAT
5525 implementation is fully conformant with this definition. The reason it
5526 is mentioned in this section is that a pragma of the same name was supplied
5527 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5528 implementation of pragma Volatile is upwards compatible with the
5529 implementation in DEC Ada 83.
5530
5531 @node Pragma Warnings
5532 @unnumberedsec Pragma Warnings
5533 @findex Warnings
5534 @noindent
5535 Syntax:
5536
5537 @smallexample @c ada
5538 pragma Warnings (On | Off);
5539 pragma Warnings (On | Off, LOCAL_NAME);
5540 pragma Warnings (static_string_EXPRESSION);
5541 pragma Warnings (On | Off, static_string_EXPRESSION);
5542 @end smallexample
5543
5544 @noindent
5545 Normally warnings are enabled, with the output being controlled by
5546 the command line switch. Warnings (@code{Off}) turns off generation of
5547 warnings until a Warnings (@code{On}) is encountered or the end of the
5548 current unit. If generation of warnings is turned off using this
5549 pragma, then no warning messages are output, regardless of the
5550 setting of the command line switches.
5551
5552 The form with a single argument may be used as a configuration pragma.
5553
5554 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5555 the specified entity. This suppression is effective from the point where
5556 it occurs till the end of the extended scope of the variable (similar to
5557 the scope of @code{Suppress}).
5558
5559 The form with a single static_string_EXPRESSION argument provides more precise
5560 control over which warnings are active. The string is a list of letters
5561 specifying which warnings are to be activated and which deactivated. The
5562 code for these letters is the same as the string used in the command
5563 line switch controlling warnings. For a brief summary, use the gnatmake
5564 command with no arguments, which will generate usage information containing
5565 the list of warnings switches supported. For
5566 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5567 User's Guide}.
5568
5569 @noindent
5570 The specified warnings will be in effect until the end of the program
5571 or another pragma Warnings is encountered. The effect of the pragma is
5572 cumulative. Initially the set of warnings is the standard default set
5573 as possibly modified by compiler switches. Then each pragma Warning
5574 modifies this set of warnings as specified. This form of the pragma may
5575 also be used as a configuration pragma.
5576
5577 The fourth form, with an On|Off parameter and a string, is used to
5578 control individual messages, based on their text. The string argument
5579 is a pattern that is used to match against the text of individual
5580 warning messages (not including the initial "warning: " tag).
5581
5582 The pattern may contain asterisks, which match zero or more characters in
5583 the message. For example, you can use
5584 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5585 message @code{warning: 960 bits of "a" unused}. No other regular
5586 expression notations are permitted. All characters other than asterisk in
5587 these three specific cases are treated as literal characters in the match.
5588
5589 There are two ways to use this pragma. The OFF form can be used as a
5590 configuration pragma. The effect is to suppress all warnings (if any)
5591 that match the pattern string throughout the compilation.
5592
5593 The second usage is to suppress a warning locally, and in this case, two
5594 pragmas must appear in sequence:
5595
5596 @smallexample @c ada
5597 pragma Warnings (Off, Pattern);
5598 @dots{} code where given warning is to be suppressed
5599 pragma Warnings (On, Pattern);
5600 @end smallexample
5601
5602 @noindent
5603 In this usage, the pattern string must match in the Off and On pragmas,
5604 and at least one matching warning must be suppressed.
5605
5606 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5607 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5608 be useful in checking whether obsolete pragmas in existing programs are hiding
5609 real problems.
5610
5611 Note: pragma Warnings does not affect the processing of style messages. See
5612 separate entry for pragma Style_Checks for control of style messages.
5613
5614 @node Pragma Weak_External
5615 @unnumberedsec Pragma Weak_External
5616 @findex Weak_External
5617 @noindent
5618 Syntax:
5619
5620 @smallexample @c ada
5621 pragma Weak_External ([Entity =>] LOCAL_NAME);
5622 @end smallexample
5623
5624 @noindent
5625 @var{LOCAL_NAME} must refer to an object that is declared at the library
5626 level. This pragma specifies that the given entity should be marked as a
5627 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5628 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5629 of a regular symbol, that is to say a symbol that does not have to be
5630 resolved by the linker if used in conjunction with a pragma Import.
5631
5632 When a weak symbol is not resolved by the linker, its address is set to
5633 zero. This is useful in writing interfaces to external modules that may
5634 or may not be linked in the final executable, for example depending on
5635 configuration settings.
5636
5637 If a program references at run time an entity to which this pragma has been
5638 applied, and the corresponding symbol was not resolved at link time, then
5639 the execution of the program is erroneous. It is not erroneous to take the
5640 Address of such an entity, for example to guard potential references,
5641 as shown in the example below.
5642
5643 Some file formats do not support weak symbols so not all target machines
5644 support this pragma.
5645
5646 @smallexample @c ada
5647 -- Example of the use of pragma Weak_External
5648
5649 package External_Module is
5650 key : Integer;
5651 pragma Import (C, key);
5652 pragma Weak_External (key);
5653 function Present return boolean;
5654 end External_Module;
5655
5656 with System; use System;
5657 package body External_Module is
5658 function Present return boolean is
5659 begin
5660 return key'Address /= System.Null_Address;
5661 end Present;
5662 end External_Module;
5663 @end smallexample
5664
5665 @node Pragma Wide_Character_Encoding
5666 @unnumberedsec Pragma Wide_Character_Encoding
5667 @findex Wide_Character_Encoding
5668 @noindent
5669 Syntax:
5670
5671 @smallexample @c ada
5672 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5673 @end smallexample
5674
5675 @noindent
5676 This pragma specifies the wide character encoding to be used in program
5677 source text appearing subsequently. It is a configuration pragma, but may
5678 also be used at any point that a pragma is allowed, and it is permissible
5679 to have more than one such pragma in a file, allowing multiple encodings
5680 to appear within the same file.
5681
5682 The argument can be an identifier or a character literal. In the identifier
5683 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5684 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5685 case it is correspondingly one of the characters @samp{h}, @samp{u},
5686 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5687
5688 Note that when the pragma is used within a file, it affects only the
5689 encoding within that file, and does not affect withed units, specs,
5690 or subunits.
5691
5692 @node Implementation Defined Attributes
5693 @chapter Implementation Defined Attributes
5694 Ada defines (throughout the Ada reference manual,
5695 summarized in Annex K),
5696 a set of attributes that provide useful additional functionality in all
5697 areas of the language. These language defined attributes are implemented
5698 in GNAT and work as described in the Ada Reference Manual.
5699
5700 In addition, Ada allows implementations to define additional
5701 attributes whose meaning is defined by the implementation. GNAT provides
5702 a number of these implementation-dependent attributes which can be used
5703 to extend and enhance the functionality of the compiler. This section of
5704 the GNAT reference manual describes these additional attributes.
5705
5706 Note that any program using these attributes may not be portable to
5707 other compilers (although GNAT implements this set of attributes on all
5708 platforms). Therefore if portability to other compilers is an important
5709 consideration, you should minimize the use of these attributes.
5710
5711 @menu
5712 * Abort_Signal::
5713 * Address_Size::
5714 * Asm_Input::
5715 * Asm_Output::
5716 * AST_Entry::
5717 * Bit::
5718 * Bit_Position::
5719 * Compiler_Version::
5720 * Code_Address::
5721 * Default_Bit_Order::
5722 * Descriptor_Size::
5723 * Elaborated::
5724 * Elab_Body::
5725 * Elab_Spec::
5726 * Elab_Subp_Body::
5727 * Emax::
5728 * Enabled::
5729 * Enum_Rep::
5730 * Enum_Val::
5731 * Epsilon::
5732 * Fixed_Value::
5733 * Has_Access_Values::
5734 * Has_Discriminants::
5735 * Img::
5736 * Integer_Value::
5737 * Invalid_Value::
5738 * Large::
5739 * Machine_Size::
5740 * Mantissa::
5741 * Max_Interrupt_Priority::
5742 * Max_Priority::
5743 * Maximum_Alignment::
5744 * Mechanism_Code::
5745 * Null_Parameter::
5746 * Object_Size::
5747 * Old::
5748 * Passed_By_Reference::
5749 * Pool_Address::
5750 * Range_Length::
5751 * Ref::
5752 * Result::
5753 * Safe_Emax::
5754 * Safe_Large::
5755 * Small::
5756 * Storage_Unit::
5757 * Stub_Type::
5758 * System_Allocator_Alignment::
5759 * Target_Name::
5760 * Tick::
5761 * To_Address::
5762 * Type_Class::
5763 * UET_Address::
5764 * Unconstrained_Array::
5765 * Universal_Literal_String::
5766 * Unrestricted_Access::
5767 * VADS_Size::
5768 * Value_Size::
5769 * Wchar_T_Size::
5770 * Word_Size::
5771 @end menu
5772
5773 @node Abort_Signal
5774 @unnumberedsec Abort_Signal
5775 @findex Abort_Signal
5776 @noindent
5777 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5778 prefix) provides the entity for the special exception used to signal
5779 task abort or asynchronous transfer of control. Normally this attribute
5780 should only be used in the tasking runtime (it is highly peculiar, and
5781 completely outside the normal semantics of Ada, for a user program to
5782 intercept the abort exception).
5783
5784 @node Address_Size
5785 @unnumberedsec Address_Size
5786 @cindex Size of @code{Address}
5787 @findex Address_Size
5788 @noindent
5789 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5790 prefix) is a static constant giving the number of bits in an
5791 @code{Address}. It is the same value as System.Address'Size,
5792 but has the advantage of being static, while a direct
5793 reference to System.Address'Size is non-static because Address
5794 is a private type.
5795
5796 @node Asm_Input
5797 @unnumberedsec Asm_Input
5798 @findex Asm_Input
5799 @noindent
5800 The @code{Asm_Input} attribute denotes a function that takes two
5801 parameters. The first is a string, the second is an expression of the
5802 type designated by the prefix. The first (string) argument is required
5803 to be a static expression, and is the constraint for the parameter,
5804 (e.g.@: what kind of register is required). The second argument is the
5805 value to be used as the input argument. The possible values for the
5806 constant are the same as those used in the RTL, and are dependent on
5807 the configuration file used to built the GCC back end.
5808 @ref{Machine Code Insertions}
5809
5810 @node Asm_Output
5811 @unnumberedsec Asm_Output
5812 @findex Asm_Output
5813 @noindent
5814 The @code{Asm_Output} attribute denotes a function that takes two
5815 parameters. The first is a string, the second is the name of a variable
5816 of the type designated by the attribute prefix. The first (string)
5817 argument is required to be a static expression and designates the
5818 constraint for the parameter (e.g.@: what kind of register is
5819 required). The second argument is the variable to be updated with the
5820 result. The possible values for constraint are the same as those used in
5821 the RTL, and are dependent on the configuration file used to build the
5822 GCC back end. If there are no output operands, then this argument may
5823 either be omitted, or explicitly given as @code{No_Output_Operands}.
5824 @ref{Machine Code Insertions}
5825
5826 @node AST_Entry
5827 @unnumberedsec AST_Entry
5828 @cindex OpenVMS
5829 @findex AST_Entry
5830 @noindent
5831 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5832 the name of an entry, it yields a value of the predefined type AST_Handler
5833 (declared in the predefined package System, as extended by the use of
5834 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5835 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5836 Language Reference Manual}, section 9.12a.
5837
5838 @node Bit
5839 @unnumberedsec Bit
5840 @findex Bit
5841 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5842 offset within the storage unit (byte) that contains the first bit of
5843 storage allocated for the object. The value of this attribute is of the
5844 type @code{Universal_Integer}, and is always a non-negative number not
5845 exceeding the value of @code{System.Storage_Unit}.
5846
5847 For an object that is a variable or a constant allocated in a register,
5848 the value is zero. (The use of this attribute does not force the
5849 allocation of a variable to memory).
5850
5851 For an object that is a formal parameter, this attribute applies
5852 to either the matching actual parameter or to a copy of the
5853 matching actual parameter.
5854
5855 For an access object the value is zero. Note that
5856 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5857 designated object. Similarly for a record component
5858 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5859 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5860 are subject to index checks.
5861
5862 This attribute is designed to be compatible with the DEC Ada 83 definition
5863 and implementation of the @code{Bit} attribute.
5864
5865 @node Bit_Position
5866 @unnumberedsec Bit_Position
5867 @findex Bit_Position
5868 @noindent
5869 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5870 of the fields of the record type, yields the bit
5871 offset within the record contains the first bit of
5872 storage allocated for the object. The value of this attribute is of the
5873 type @code{Universal_Integer}. The value depends only on the field
5874 @var{C} and is independent of the alignment of
5875 the containing record @var{R}.
5876
5877 @node Compiler_Version
5878 @unnumberedsec Compiler_Version
5879 @findex Compiler_Version
5880 @noindent
5881 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5882 prefix) yields a static string identifying the version of the compiler
5883 being used to compile the unit containing the attribute reference. A
5884 typical result would be something like "@value{EDITION} @i{version} (20090221)".
5885
5886 @node Code_Address
5887 @unnumberedsec Code_Address
5888 @findex Code_Address
5889 @cindex Subprogram address
5890 @cindex Address of subprogram code
5891 @noindent
5892 The @code{'Address}
5893 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5894 intended effect seems to be to provide
5895 an address value which can be used to call the subprogram by means of
5896 an address clause as in the following example:
5897
5898 @smallexample @c ada
5899 procedure K is @dots{}
5900
5901 procedure L;
5902 for L'Address use K'Address;
5903 pragma Import (Ada, L);
5904 @end smallexample
5905
5906 @noindent
5907 A call to @code{L} is then expected to result in a call to @code{K}@.
5908 In Ada 83, where there were no access-to-subprogram values, this was
5909 a common work-around for getting the effect of an indirect call.
5910 GNAT implements the above use of @code{Address} and the technique
5911 illustrated by the example code works correctly.
5912
5913 However, for some purposes, it is useful to have the address of the start
5914 of the generated code for the subprogram. On some architectures, this is
5915 not necessarily the same as the @code{Address} value described above.
5916 For example, the @code{Address} value may reference a subprogram
5917 descriptor rather than the subprogram itself.
5918
5919 The @code{'Code_Address} attribute, which can only be applied to
5920 subprogram entities, always returns the address of the start of the
5921 generated code of the specified subprogram, which may or may not be
5922 the same value as is returned by the corresponding @code{'Address}
5923 attribute.
5924
5925 @node Default_Bit_Order
5926 @unnumberedsec Default_Bit_Order
5927 @cindex Big endian
5928 @cindex Little endian
5929 @findex Default_Bit_Order
5930 @noindent
5931 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5932 permissible prefix), provides the value @code{System.Default_Bit_Order}
5933 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5934 @code{Low_Order_First}). This is used to construct the definition of
5935 @code{Default_Bit_Order} in package @code{System}.
5936
5937 @node Descriptor_Size
5938 @unnumberedsec Descriptor_Size
5939 @cindex Descriptor
5940 @cindex Dope vector
5941 @findex Descriptor_Size
5942 @noindent
5943 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
5944 descriptor allocated for a type. The result is non-zero only for unconstrained
5945 array types and the returned value is of type universal integer. In GNAT, an
5946 array descriptor contains bounds information and is located immediately before
5947 the first element of the array.
5948
5949 @smallexample @c ada
5950 type Unconstr_Array is array (Positive range <>) of Boolean;
5951 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
5952 @end smallexample
5953
5954 @noindent
5955 The attribute takes into account any additional padding due to type alignment.
5956 In the example above, the descriptor contains two values of type
5957 @code{Positive} representing the low and high bound. Since @code{Positive} has
5958 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
5959 Positive'Size + 2} or 64 bits.
5960
5961 @node Elaborated
5962 @unnumberedsec Elaborated
5963 @findex Elaborated
5964 @noindent
5965 The prefix of the @code{'Elaborated} attribute must be a unit name. The
5966 value is a Boolean which indicates whether or not the given unit has been
5967 elaborated. This attribute is primarily intended for internal use by the
5968 generated code for dynamic elaboration checking, but it can also be used
5969 in user programs. The value will always be True once elaboration of all
5970 units has been completed. An exception is for units which need no
5971 elaboration, the value is always False for such units.
5972
5973 @node Elab_Body
5974 @unnumberedsec Elab_Body
5975 @findex Elab_Body
5976 @noindent
5977 This attribute can only be applied to a program unit name. It returns
5978 the entity for the corresponding elaboration procedure for elaborating
5979 the body of the referenced unit. This is used in the main generated
5980 elaboration procedure by the binder and is not normally used in any
5981 other context. However, there may be specialized situations in which it
5982 is useful to be able to call this elaboration procedure from Ada code,
5983 e.g.@: if it is necessary to do selective re-elaboration to fix some
5984 error.
5985
5986 @node Elab_Spec
5987 @unnumberedsec Elab_Spec
5988 @findex Elab_Spec
5989 @noindent
5990 This attribute can only be applied to a program unit name. It returns
5991 the entity for the corresponding elaboration procedure for elaborating
5992 the spec of the referenced unit. This is used in the main
5993 generated elaboration procedure by the binder and is not normally used
5994 in any other context. However, there may be specialized situations in
5995 which it is useful to be able to call this elaboration procedure from
5996 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5997 some error.
5998
5999 @node Elab_Subp_Body
6000 @unnumberedsec Elab_Subp_Body
6001 @findex Elab_Subp_Body
6002 @noindent
6003 This attribute can only be applied to a library level subprogram
6004 name and is only allowed in CodePeer mode. It returns the entity
6005 for the corresponding elaboration procedure for elaborating the body
6006 of the referenced subprogram unit. This is used in the main generated
6007 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6008 otherwise.
6009
6010 @node Emax
6011 @unnumberedsec Emax
6012 @cindex Ada 83 attributes
6013 @findex Emax
6014 @noindent
6015 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6016 the Ada 83 reference manual for an exact description of the semantics of
6017 this attribute.
6018
6019 @node Enabled
6020 @unnumberedsec Enabled
6021 @findex Enabled
6022 @noindent
6023 The @code{Enabled} attribute allows an application program to check at compile
6024 time to see if the designated check is currently enabled. The prefix is a
6025 simple identifier, referencing any predefined check name (other than
6026 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6027 no argument is given for the attribute, the check is for the general state
6028 of the check, if an argument is given, then it is an entity name, and the
6029 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6030 given naming the entity (if not, then the argument is ignored).
6031
6032 Note that instantiations inherit the check status at the point of the
6033 instantiation, so a useful idiom is to have a library package that
6034 introduces a check name with @code{pragma Check_Name}, and then contains
6035 generic packages or subprograms which use the @code{Enabled} attribute
6036 to see if the check is enabled. A user of this package can then issue
6037 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6038 the package or subprogram, controlling whether the check will be present.
6039
6040 @node Enum_Rep
6041 @unnumberedsec Enum_Rep
6042 @cindex Representation of enums
6043 @findex Enum_Rep
6044 @noindent
6045 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6046 function with the following spec:
6047
6048 @smallexample @c ada
6049 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6050 return @i{Universal_Integer};
6051 @end smallexample
6052
6053 @noindent
6054 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6055 enumeration type or to a non-overloaded enumeration
6056 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6057 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6058 enumeration literal or object.
6059
6060 The function returns the representation value for the given enumeration
6061 value. This will be equal to value of the @code{Pos} attribute in the
6062 absence of an enumeration representation clause. This is a static
6063 attribute (i.e.@: the result is static if the argument is static).
6064
6065 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6066 in which case it simply returns the integer value. The reason for this
6067 is to allow it to be used for @code{(<>)} discrete formal arguments in
6068 a generic unit that can be instantiated with either enumeration types
6069 or integer types. Note that if @code{Enum_Rep} is used on a modular
6070 type whose upper bound exceeds the upper bound of the largest signed
6071 integer type, and the argument is a variable, so that the universal
6072 integer calculation is done at run time, then the call to @code{Enum_Rep}
6073 may raise @code{Constraint_Error}.
6074
6075 @node Enum_Val
6076 @unnumberedsec Enum_Val
6077 @cindex Representation of enums
6078 @findex Enum_Val
6079 @noindent
6080 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6081 function with the following spec:
6082
6083 @smallexample @c ada
6084 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6085 return @var{S}'Base};
6086 @end smallexample
6087
6088 @noindent
6089 The function returns the enumeration value whose representation matches the
6090 argument, or raises Constraint_Error if no enumeration literal of the type
6091 has the matching value.
6092 This will be equal to value of the @code{Val} attribute in the
6093 absence of an enumeration representation clause. This is a static
6094 attribute (i.e.@: the result is static if the argument is static).
6095
6096 @node Epsilon
6097 @unnumberedsec Epsilon
6098 @cindex Ada 83 attributes
6099 @findex Epsilon
6100 @noindent
6101 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6102 the Ada 83 reference manual for an exact description of the semantics of
6103 this attribute.
6104
6105 @node Fixed_Value
6106 @unnumberedsec Fixed_Value
6107 @findex Fixed_Value
6108 @noindent
6109 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6110 function with the following specification:
6111
6112 @smallexample @c ada
6113 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6114 return @var{S};
6115 @end smallexample
6116
6117 @noindent
6118 The value returned is the fixed-point value @var{V} such that
6119
6120 @smallexample @c ada
6121 @var{V} = Arg * @var{S}'Small
6122 @end smallexample
6123
6124 @noindent
6125 The effect is thus similar to first converting the argument to the
6126 integer type used to represent @var{S}, and then doing an unchecked
6127 conversion to the fixed-point type. The difference is
6128 that there are full range checks, to ensure that the result is in range.
6129 This attribute is primarily intended for use in implementation of the
6130 input-output functions for fixed-point values.
6131
6132 @node Has_Access_Values
6133 @unnumberedsec Has_Access_Values
6134 @cindex Access values, testing for
6135 @findex Has_Access_Values
6136 @noindent
6137 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6138 is a Boolean value which is True if the is an access type, or is a composite
6139 type with a component (at any nesting depth) that is an access type, and is
6140 False otherwise.
6141 The intended use of this attribute is in conjunction with generic
6142 definitions. If the attribute is applied to a generic private type, it
6143 indicates whether or not the corresponding actual type has access values.
6144
6145 @node Has_Discriminants
6146 @unnumberedsec Has_Discriminants
6147 @cindex Discriminants, testing for
6148 @findex Has_Discriminants
6149 @noindent
6150 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6151 is a Boolean value which is True if the type has discriminants, and False
6152 otherwise. The intended use of this attribute is in conjunction with generic
6153 definitions. If the attribute is applied to a generic private type, it
6154 indicates whether or not the corresponding actual type has discriminants.
6155
6156 @node Img
6157 @unnumberedsec Img
6158 @findex Img
6159 @noindent
6160 The @code{Img} attribute differs from @code{Image} in that it may be
6161 applied to objects as well as types, in which case it gives the
6162 @code{Image} for the subtype of the object. This is convenient for
6163 debugging:
6164
6165 @smallexample @c ada
6166 Put_Line ("X = " & X'Img);
6167 @end smallexample
6168
6169 @noindent
6170 has the same meaning as the more verbose:
6171
6172 @smallexample @c ada
6173 Put_Line ("X = " & @var{T}'Image (X));
6174 @end smallexample
6175
6176 @noindent
6177 where @var{T} is the (sub)type of the object @code{X}.
6178
6179 @node Integer_Value
6180 @unnumberedsec Integer_Value
6181 @findex Integer_Value
6182 @noindent
6183 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6184 function with the following spec:
6185
6186 @smallexample @c ada
6187 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6188 return @var{S};
6189 @end smallexample
6190
6191 @noindent
6192 The value returned is the integer value @var{V}, such that
6193
6194 @smallexample @c ada
6195 Arg = @var{V} * @var{T}'Small
6196 @end smallexample
6197
6198 @noindent
6199 where @var{T} is the type of @code{Arg}.
6200 The effect is thus similar to first doing an unchecked conversion from
6201 the fixed-point type to its corresponding implementation type, and then
6202 converting the result to the target integer type. The difference is
6203 that there are full range checks, to ensure that the result is in range.
6204 This attribute is primarily intended for use in implementation of the
6205 standard input-output functions for fixed-point values.
6206
6207 @node Invalid_Value
6208 @unnumberedsec Invalid_Value
6209 @findex Invalid_Value
6210 @noindent
6211 For every scalar type S, S'Invalid_Value returns an undefined value of the
6212 type. If possible this value is an invalid representation for the type. The
6213 value returned is identical to the value used to initialize an otherwise
6214 uninitialized value of the type if pragma Initialize_Scalars is used,
6215 including the ability to modify the value with the binder -Sxx flag and
6216 relevant environment variables at run time.
6217
6218 @node Large
6219 @unnumberedsec Large
6220 @cindex Ada 83 attributes
6221 @findex Large
6222 @noindent
6223 The @code{Large} attribute is provided for compatibility with Ada 83. See
6224 the Ada 83 reference manual for an exact description of the semantics of
6225 this attribute.
6226
6227 @node Machine_Size
6228 @unnumberedsec Machine_Size
6229 @findex Machine_Size
6230 @noindent
6231 This attribute is identical to the @code{Object_Size} attribute. It is
6232 provided for compatibility with the DEC Ada 83 attribute of this name.
6233
6234 @node Mantissa
6235 @unnumberedsec Mantissa
6236 @cindex Ada 83 attributes
6237 @findex Mantissa
6238 @noindent
6239 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6240 the Ada 83 reference manual for an exact description of the semantics of
6241 this attribute.
6242
6243 @node Max_Interrupt_Priority
6244 @unnumberedsec Max_Interrupt_Priority
6245 @cindex Interrupt priority, maximum
6246 @findex Max_Interrupt_Priority
6247 @noindent
6248 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6249 permissible prefix), provides the same value as
6250 @code{System.Max_Interrupt_Priority}.
6251
6252 @node Max_Priority
6253 @unnumberedsec Max_Priority
6254 @cindex Priority, maximum
6255 @findex Max_Priority
6256 @noindent
6257 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6258 prefix) provides the same value as @code{System.Max_Priority}.
6259
6260 @node Maximum_Alignment
6261 @unnumberedsec Maximum_Alignment
6262 @cindex Alignment, maximum
6263 @findex Maximum_Alignment
6264 @noindent
6265 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6266 permissible prefix) provides the maximum useful alignment value for the
6267 target. This is a static value that can be used to specify the alignment
6268 for an object, guaranteeing that it is properly aligned in all
6269 cases.
6270
6271 @node Mechanism_Code
6272 @unnumberedsec Mechanism_Code
6273 @cindex Return values, passing mechanism
6274 @cindex Parameters, passing mechanism
6275 @findex Mechanism_Code
6276 @noindent
6277 @code{@var{function}'Mechanism_Code} yields an integer code for the
6278 mechanism used for the result of function, and
6279 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6280 used for formal parameter number @var{n} (a static integer value with 1
6281 meaning the first parameter) of @var{subprogram}. The code returned is:
6282
6283 @table @asis
6284 @item 1
6285 by copy (value)
6286 @item 2
6287 by reference
6288 @item 3
6289 by descriptor (default descriptor class)
6290 @item 4
6291 by descriptor (UBS: unaligned bit string)
6292 @item 5
6293 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6294 @item 6
6295 by descriptor (UBA: unaligned bit array)
6296 @item 7
6297 by descriptor (S: string, also scalar access type parameter)
6298 @item 8
6299 by descriptor (SB: string with arbitrary bounds)
6300 @item 9
6301 by descriptor (A: contiguous array)
6302 @item 10
6303 by descriptor (NCA: non-contiguous array)
6304 @end table
6305
6306 @noindent
6307 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6308 @cindex OpenVMS
6309
6310 @node Null_Parameter
6311 @unnumberedsec Null_Parameter
6312 @cindex Zero address, passing
6313 @findex Null_Parameter
6314 @noindent
6315 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6316 type or subtype @var{T} allocated at machine address zero. The attribute
6317 is allowed only as the default expression of a formal parameter, or as
6318 an actual expression of a subprogram call. In either case, the
6319 subprogram must be imported.
6320
6321 The identity of the object is represented by the address zero in the
6322 argument list, independent of the passing mechanism (explicit or
6323 default).
6324
6325 This capability is needed to specify that a zero address should be
6326 passed for a record or other composite object passed by reference.
6327 There is no way of indicating this without the @code{Null_Parameter}
6328 attribute.
6329
6330 @node Object_Size
6331 @unnumberedsec Object_Size
6332 @cindex Size, used for objects
6333 @findex Object_Size
6334 @noindent
6335 The size of an object is not necessarily the same as the size of the type
6336 of an object. This is because by default object sizes are increased to be
6337 a multiple of the alignment of the object. For example,
6338 @code{Natural'Size} is
6339 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6340 Similarly, a record containing an integer and a character:
6341
6342 @smallexample @c ada
6343 type Rec is record
6344 I : Integer;
6345 C : Character;
6346 end record;
6347 @end smallexample
6348
6349 @noindent
6350 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6351 alignment will be 4, because of the
6352 integer field, and so the default size of record objects for this type
6353 will be 64 (8 bytes).
6354
6355 @node Old
6356 @unnumberedsec Old
6357 @cindex Capturing Old values
6358 @cindex Postconditions
6359 @noindent
6360 The attribute Prefix'Old can be used within a
6361 subprogram body or within a precondition or
6362 postcondition pragma. The effect is to
6363 refer to the value of the prefix on entry. So for
6364 example if you have an argument of a record type X called Arg1,
6365 you can refer to Arg1.Field'Old which yields the value of
6366 Arg1.Field on entry. The implementation simply involves generating
6367 an object declaration which captures the value on entry. Any
6368 prefix is allowed except one of a limited type (since limited
6369 types cannot be copied to capture their values) or an expression
6370 which references a local variable
6371 (since local variables do not exist at subprogram entry time).
6372
6373 The following example shows the use of 'Old to implement
6374 a test of a postcondition:
6375
6376 @smallexample @c ada
6377 with Old_Pkg;
6378 procedure Old is
6379 begin
6380 Old_Pkg.Incr;
6381 end Old;
6382
6383 package Old_Pkg is
6384 procedure Incr;
6385 end Old_Pkg;
6386
6387 package body Old_Pkg is
6388 Count : Natural := 0;
6389
6390 procedure Incr is
6391 begin
6392 ... code manipulating the value of Count
6393
6394 pragma Assert (Count = Count'Old + 1);
6395 end Incr;
6396 end Old_Pkg;
6397 @end smallexample
6398
6399 @noindent
6400 Note that it is allowed to apply 'Old to a constant entity, but this will
6401 result in a warning, since the old and new values will always be the same.
6402
6403 @node Passed_By_Reference
6404 @unnumberedsec Passed_By_Reference
6405 @cindex Parameters, when passed by reference
6406 @findex Passed_By_Reference
6407 @noindent
6408 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6409 a value of type @code{Boolean} value that is @code{True} if the type is
6410 normally passed by reference and @code{False} if the type is normally
6411 passed by copy in calls. For scalar types, the result is always @code{False}
6412 and is static. For non-scalar types, the result is non-static.
6413
6414 @node Pool_Address
6415 @unnumberedsec Pool_Address
6416 @cindex Parameters, when passed by reference
6417 @findex Pool_Address
6418 @noindent
6419 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6420 of X within its storage pool. This is the same as
6421 @code{@var{X}'Address}, except that for an unconstrained array whose
6422 bounds are allocated just before the first component,
6423 @code{@var{X}'Pool_Address} returns the address of those bounds,
6424 whereas @code{@var{X}'Address} returns the address of the first
6425 component.
6426
6427 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6428 the object is allocated'', which could be a user-defined storage pool,
6429 the global heap, on the stack, or in a static memory area. For an
6430 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6431 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6432
6433 @node Range_Length
6434 @unnumberedsec Range_Length
6435 @findex Range_Length
6436 @noindent
6437 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6438 the number of values represented by the subtype (zero for a null
6439 range). The result is static for static subtypes. @code{Range_Length}
6440 applied to the index subtype of a one dimensional array always gives the
6441 same result as @code{Range} applied to the array itself.
6442
6443 @node Ref
6444 @unnumberedsec Ref
6445 @findex Ref
6446 @noindent
6447 The @code{System.Address'Ref}
6448 (@code{System.Address} is the only permissible prefix)
6449 denotes a function identical to
6450 @code{System.Storage_Elements.To_Address} except that
6451 it is a static attribute. See @ref{To_Address} for more details.
6452
6453 @node Result
6454 @unnumberedsec Result
6455 @findex Result
6456 @noindent
6457 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6458 for a function. The prefix must be the name of the corresponding function. This
6459 is used to refer to the result of the function in the postcondition expression.
6460 For a further discussion of the use of this attribute and examples of its use,
6461 see the description of pragma Postcondition.
6462
6463 @node Safe_Emax
6464 @unnumberedsec Safe_Emax
6465 @cindex Ada 83 attributes
6466 @findex Safe_Emax
6467 @noindent
6468 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6469 the Ada 83 reference manual for an exact description of the semantics of
6470 this attribute.
6471
6472 @node Safe_Large
6473 @unnumberedsec Safe_Large
6474 @cindex Ada 83 attributes
6475 @findex Safe_Large
6476 @noindent
6477 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6478 the Ada 83 reference manual for an exact description of the semantics of
6479 this attribute.
6480
6481 @node Small
6482 @unnumberedsec Small
6483 @cindex Ada 83 attributes
6484 @findex Small
6485 @noindent
6486 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6487 fixed-point types.
6488 GNAT also allows this attribute to be applied to floating-point types
6489 for compatibility with Ada 83. See
6490 the Ada 83 reference manual for an exact description of the semantics of
6491 this attribute when applied to floating-point types.
6492
6493 @node Storage_Unit
6494 @unnumberedsec Storage_Unit
6495 @findex Storage_Unit
6496 @noindent
6497 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6498 prefix) provides the same value as @code{System.Storage_Unit}.
6499
6500 @node Stub_Type
6501 @unnumberedsec Stub_Type
6502 @findex Stub_Type
6503 @noindent
6504 The GNAT implementation of remote access-to-classwide types is
6505 organized as described in AARM section E.4 (20.t): a value of an RACW type
6506 (designating a remote object) is represented as a normal access
6507 value, pointing to a "stub" object which in turn contains the
6508 necessary information to contact the designated remote object. A
6509 call on any dispatching operation of such a stub object does the
6510 remote call, if necessary, using the information in the stub object
6511 to locate the target partition, etc.
6512
6513 For a prefix @code{T} that denotes a remote access-to-classwide type,
6514 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6515
6516 By construction, the layout of @code{T'Stub_Type} is identical to that of
6517 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6518 unit @code{System.Partition_Interface}. Use of this attribute will create
6519 an implicit dependency on this unit.
6520
6521 @node System_Allocator_Alignment
6522 @unnumberedsec System_Allocator_Alignment
6523 @cindex Alignment, allocator
6524 @findex System_Allocator_Alignment
6525 @noindent
6526 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6527 permissible prefix) provides the observable guaranted to be honored by
6528 the system allocator (malloc). This is a static value that can be used
6529 in user storage pools based on malloc either to reject allocation
6530 with alignment too large or to enable a realignment circuitry if the
6531 alignment request is larger than this value.
6532
6533 @node Target_Name
6534 @unnumberedsec Target_Name
6535 @findex Target_Name
6536 @noindent
6537 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6538 prefix) provides a static string value that identifies the target
6539 for the current compilation. For GCC implementations, this is the
6540 standard gcc target name without the terminating slash (for
6541 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6542
6543 @node Tick
6544 @unnumberedsec Tick
6545 @findex Tick
6546 @noindent
6547 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6548 provides the same value as @code{System.Tick},
6549
6550 @node To_Address
6551 @unnumberedsec To_Address
6552 @findex To_Address
6553 @noindent
6554 The @code{System'To_Address}
6555 (@code{System} is the only permissible prefix)
6556 denotes a function identical to
6557 @code{System.Storage_Elements.To_Address} except that
6558 it is a static attribute. This means that if its argument is
6559 a static expression, then the result of the attribute is a
6560 static expression. The result is that such an expression can be
6561 used in contexts (e.g.@: preelaborable packages) which require a
6562 static expression and where the function call could not be used
6563 (since the function call is always non-static, even if its
6564 argument is static).
6565
6566 @node Type_Class
6567 @unnumberedsec Type_Class
6568 @findex Type_Class
6569 @noindent
6570 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6571 the value of the type class for the full type of @var{type}. If
6572 @var{type} is a generic formal type, the value is the value for the
6573 corresponding actual subtype. The value of this attribute is of type
6574 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6575
6576 @smallexample @c ada
6577 type Type_Class is
6578 (Type_Class_Enumeration,
6579 Type_Class_Integer,
6580 Type_Class_Fixed_Point,
6581 Type_Class_Floating_Point,
6582 Type_Class_Array,
6583 Type_Class_Record,
6584 Type_Class_Access,
6585 Type_Class_Task,
6586 Type_Class_Address);
6587 @end smallexample
6588
6589 @noindent
6590 Protected types yield the value @code{Type_Class_Task}, which thus
6591 applies to all concurrent types. This attribute is designed to
6592 be compatible with the DEC Ada 83 attribute of the same name.
6593
6594 @node UET_Address
6595 @unnumberedsec UET_Address
6596 @findex UET_Address
6597 @noindent
6598 The @code{UET_Address} attribute can only be used for a prefix which
6599 denotes a library package. It yields the address of the unit exception
6600 table when zero cost exception handling is used. This attribute is
6601 intended only for use within the GNAT implementation. See the unit
6602 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6603 for details on how this attribute is used in the implementation.
6604
6605 @node Unconstrained_Array
6606 @unnumberedsec Unconstrained_Array
6607 @findex Unconstrained_Array
6608 @noindent
6609 The @code{Unconstrained_Array} attribute can be used with a prefix that
6610 denotes any type or subtype. It is a static attribute that yields
6611 @code{True} if the prefix designates an unconstrained array,
6612 and @code{False} otherwise. In a generic instance, the result is
6613 still static, and yields the result of applying this test to the
6614 generic actual.
6615
6616 @node Universal_Literal_String
6617 @unnumberedsec Universal_Literal_String
6618 @cindex Named numbers, representation of
6619 @findex Universal_Literal_String
6620 @noindent
6621 The prefix of @code{Universal_Literal_String} must be a named
6622 number. The static result is the string consisting of the characters of
6623 the number as defined in the original source. This allows the user
6624 program to access the actual text of named numbers without intermediate
6625 conversions and without the need to enclose the strings in quotes (which
6626 would preclude their use as numbers).
6627
6628 For example, the following program prints the first 50 digits of pi:
6629
6630 @smallexample @c ada
6631 with Text_IO; use Text_IO;
6632 with Ada.Numerics;
6633 procedure Pi is
6634 begin
6635 Put (Ada.Numerics.Pi'Universal_Literal_String);
6636 end;
6637 @end smallexample
6638
6639 @node Unrestricted_Access
6640 @unnumberedsec Unrestricted_Access
6641 @cindex @code{Access}, unrestricted
6642 @findex Unrestricted_Access
6643 @noindent
6644 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6645 except that all accessibility and aliased view checks are omitted. This
6646 is a user-beware attribute. It is similar to
6647 @code{Address}, for which it is a desirable replacement where the value
6648 desired is an access type. In other words, its effect is identical to
6649 first applying the @code{Address} attribute and then doing an unchecked
6650 conversion to a desired access type. In GNAT, but not necessarily in
6651 other implementations, the use of static chains for inner level
6652 subprograms means that @code{Unrestricted_Access} applied to a
6653 subprogram yields a value that can be called as long as the subprogram
6654 is in scope (normal Ada accessibility rules restrict this usage).
6655
6656 It is possible to use @code{Unrestricted_Access} for any type, but care
6657 must be exercised if it is used to create pointers to unconstrained
6658 objects. In this case, the resulting pointer has the same scope as the
6659 context of the attribute, and may not be returned to some enclosing
6660 scope. For instance, a function cannot use @code{Unrestricted_Access}
6661 to create a unconstrained pointer and then return that value to the
6662 caller.
6663
6664 @node VADS_Size
6665 @unnumberedsec VADS_Size
6666 @cindex @code{Size}, VADS compatibility
6667 @findex VADS_Size
6668 @noindent
6669 The @code{'VADS_Size} attribute is intended to make it easier to port
6670 legacy code which relies on the semantics of @code{'Size} as implemented
6671 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6672 same semantic interpretation. In particular, @code{'VADS_Size} applied
6673 to a predefined or other primitive type with no Size clause yields the
6674 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6675 typical machines). In addition @code{'VADS_Size} applied to an object
6676 gives the result that would be obtained by applying the attribute to
6677 the corresponding type.
6678
6679 @node Value_Size
6680 @unnumberedsec Value_Size
6681 @cindex @code{Size}, setting for not-first subtype
6682 @findex Value_Size
6683 @code{@var{type}'Value_Size} is the number of bits required to represent
6684 a value of the given subtype. It is the same as @code{@var{type}'Size},
6685 but, unlike @code{Size}, may be set for non-first subtypes.
6686
6687 @node Wchar_T_Size
6688 @unnumberedsec Wchar_T_Size
6689 @findex Wchar_T_Size
6690 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6691 prefix) provides the size in bits of the C @code{wchar_t} type
6692 primarily for constructing the definition of this type in
6693 package @code{Interfaces.C}.
6694
6695 @node Word_Size
6696 @unnumberedsec Word_Size
6697 @findex Word_Size
6698 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6699 prefix) provides the value @code{System.Word_Size}.
6700
6701 @c ------------------------
6702 @node Implementation Advice
6703 @chapter Implementation Advice
6704 @noindent
6705 The main text of the Ada Reference Manual describes the required
6706 behavior of all Ada compilers, and the GNAT compiler conforms to
6707 these requirements.
6708
6709 In addition, there are sections throughout the Ada Reference Manual headed
6710 by the phrase ``Implementation advice''. These sections are not normative,
6711 i.e., they do not specify requirements that all compilers must
6712 follow. Rather they provide advice on generally desirable behavior. You
6713 may wonder why they are not requirements. The most typical answer is
6714 that they describe behavior that seems generally desirable, but cannot
6715 be provided on all systems, or which may be undesirable on some systems.
6716
6717 As far as practical, GNAT follows the implementation advice sections in
6718 the Ada Reference Manual. This chapter contains a table giving the
6719 reference manual section number, paragraph number and several keywords
6720 for each advice. Each entry consists of the text of the advice followed
6721 by the GNAT interpretation of this advice. Most often, this simply says
6722 ``followed'', which means that GNAT follows the advice. However, in a
6723 number of cases, GNAT deliberately deviates from this advice, in which
6724 case the text describes what GNAT does and why.
6725
6726 @cindex Error detection
6727 @unnumberedsec 1.1.3(20): Error Detection
6728 @sp 1
6729 @cartouche
6730 If an implementation detects the use of an unsupported Specialized Needs
6731 Annex feature at run time, it should raise @code{Program_Error} if
6732 feasible.
6733 @end cartouche
6734 Not relevant. All specialized needs annex features are either supported,
6735 or diagnosed at compile time.
6736
6737 @cindex Child Units
6738 @unnumberedsec 1.1.3(31): Child Units
6739 @sp 1
6740 @cartouche
6741 If an implementation wishes to provide implementation-defined
6742 extensions to the functionality of a language-defined library unit, it
6743 should normally do so by adding children to the library unit.
6744 @end cartouche
6745 Followed.
6746
6747 @cindex Bounded errors
6748 @unnumberedsec 1.1.5(12): Bounded Errors
6749 @sp 1
6750 @cartouche
6751 If an implementation detects a bounded error or erroneous
6752 execution, it should raise @code{Program_Error}.
6753 @end cartouche
6754 Followed in all cases in which the implementation detects a bounded
6755 error or erroneous execution. Not all such situations are detected at
6756 runtime.
6757
6758 @cindex Pragmas
6759 @unnumberedsec 2.8(16): Pragmas
6760 @sp 1
6761 @cartouche
6762 Normally, implementation-defined pragmas should have no semantic effect
6763 for error-free programs; that is, if the implementation-defined pragmas
6764 are removed from a working program, the program should still be legal,
6765 and should still have the same semantics.
6766 @end cartouche
6767 The following implementation defined pragmas are exceptions to this
6768 rule:
6769
6770 @table @code
6771 @item Abort_Defer
6772 Affects semantics
6773 @item Ada_83
6774 Affects legality
6775 @item Assert
6776 Affects semantics
6777 @item CPP_Class
6778 Affects semantics
6779 @item CPP_Constructor
6780 Affects semantics
6781 @item Debug
6782 Affects semantics
6783 @item Interface_Name
6784 Affects semantics
6785 @item Machine_Attribute
6786 Affects semantics
6787 @item Unimplemented_Unit
6788 Affects legality
6789 @item Unchecked_Union
6790 Affects semantics
6791 @end table
6792
6793 @noindent
6794 In each of the above cases, it is essential to the purpose of the pragma
6795 that this advice not be followed. For details see the separate section
6796 on implementation defined pragmas.
6797
6798 @unnumberedsec 2.8(17-19): Pragmas
6799 @sp 1
6800 @cartouche
6801 Normally, an implementation should not define pragmas that can
6802 make an illegal program legal, except as follows:
6803 @end cartouche
6804 @sp 1
6805 @cartouche
6806 A pragma used to complete a declaration, such as a pragma @code{Import};
6807 @end cartouche
6808 @sp 1
6809 @cartouche
6810 A pragma used to configure the environment by adding, removing, or
6811 replacing @code{library_items}.
6812 @end cartouche
6813 See response to paragraph 16 of this same section.
6814
6815 @cindex Character Sets
6816 @cindex Alternative Character Sets
6817 @unnumberedsec 3.5.2(5): Alternative Character Sets
6818 @sp 1
6819 @cartouche
6820 If an implementation supports a mode with alternative interpretations
6821 for @code{Character} and @code{Wide_Character}, the set of graphic
6822 characters of @code{Character} should nevertheless remain a proper
6823 subset of the set of graphic characters of @code{Wide_Character}. Any
6824 character set ``localizations'' should be reflected in the results of
6825 the subprograms defined in the language-defined package
6826 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
6827 an alternative interpretation of @code{Character}, the implementation should
6828 also support a corresponding change in what is a legal
6829 @code{identifier_letter}.
6830 @end cartouche
6831 Not all wide character modes follow this advice, in particular the JIS
6832 and IEC modes reflect standard usage in Japan, and in these encoding,
6833 the upper half of the Latin-1 set is not part of the wide-character
6834 subset, since the most significant bit is used for wide character
6835 encoding. However, this only applies to the external forms. Internally
6836 there is no such restriction.
6837
6838 @cindex Integer types
6839 @unnumberedsec 3.5.4(28): Integer Types
6840
6841 @sp 1
6842 @cartouche
6843 An implementation should support @code{Long_Integer} in addition to
6844 @code{Integer} if the target machine supports 32-bit (or longer)
6845 arithmetic. No other named integer subtypes are recommended for package
6846 @code{Standard}. Instead, appropriate named integer subtypes should be
6847 provided in the library package @code{Interfaces} (see B.2).
6848 @end cartouche
6849 @code{Long_Integer} is supported. Other standard integer types are supported
6850 so this advice is not fully followed. These types
6851 are supported for convenient interface to C, and so that all hardware
6852 types of the machine are easily available.
6853 @unnumberedsec 3.5.4(29): Integer Types
6854
6855 @sp 1
6856 @cartouche
6857 An implementation for a two's complement machine should support
6858 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
6859 implementation should support a non-binary modules up to @code{Integer'Last}.
6860 @end cartouche
6861 Followed.
6862
6863 @cindex Enumeration values
6864 @unnumberedsec 3.5.5(8): Enumeration Values
6865 @sp 1
6866 @cartouche
6867 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6868 subtype, if the value of the operand does not correspond to the internal
6869 code for any enumeration literal of its type (perhaps due to an
6870 un-initialized variable), then the implementation should raise
6871 @code{Program_Error}. This is particularly important for enumeration
6872 types with noncontiguous internal codes specified by an
6873 enumeration_representation_clause.
6874 @end cartouche
6875 Followed.
6876
6877 @cindex Float types
6878 @unnumberedsec 3.5.7(17): Float Types
6879 @sp 1
6880 @cartouche
6881 An implementation should support @code{Long_Float} in addition to
6882 @code{Float} if the target machine supports 11 or more digits of
6883 precision. No other named floating point subtypes are recommended for
6884 package @code{Standard}. Instead, appropriate named floating point subtypes
6885 should be provided in the library package @code{Interfaces} (see B.2).
6886 @end cartouche
6887 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
6888 former provides improved compatibility with other implementations
6889 supporting this type. The latter corresponds to the highest precision
6890 floating-point type supported by the hardware. On most machines, this
6891 will be the same as @code{Long_Float}, but on some machines, it will
6892 correspond to the IEEE extended form. The notable case is all ia32
6893 (x86) implementations, where @code{Long_Long_Float} corresponds to
6894 the 80-bit extended precision format supported in hardware on this
6895 processor. Note that the 128-bit format on SPARC is not supported,
6896 since this is a software rather than a hardware format.
6897
6898 @cindex Multidimensional arrays
6899 @cindex Arrays, multidimensional
6900 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6901 @sp 1
6902 @cartouche
6903 An implementation should normally represent multidimensional arrays in
6904 row-major order, consistent with the notation used for multidimensional
6905 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
6906 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6907 column-major order should be used instead (see B.5, ``Interfacing with
6908 Fortran'').
6909 @end cartouche
6910 Followed.
6911
6912 @findex Duration'Small
6913 @unnumberedsec 9.6(30-31): Duration'Small
6914 @sp 1
6915 @cartouche
6916 Whenever possible in an implementation, the value of @code{Duration'Small}
6917 should be no greater than 100 microseconds.
6918 @end cartouche
6919 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
6920
6921 @sp 1
6922 @cartouche
6923 The time base for @code{delay_relative_statements} should be monotonic;
6924 it need not be the same time base as used for @code{Calendar.Clock}.
6925 @end cartouche
6926 Followed.
6927
6928 @unnumberedsec 10.2.1(12): Consistent Representation
6929 @sp 1
6930 @cartouche
6931 In an implementation, a type declared in a pre-elaborated package should
6932 have the same representation in every elaboration of a given version of
6933 the package, whether the elaborations occur in distinct executions of
6934 the same program, or in executions of distinct programs or partitions
6935 that include the given version.
6936 @end cartouche
6937 Followed, except in the case of tagged types. Tagged types involve
6938 implicit pointers to a local copy of a dispatch table, and these pointers
6939 have representations which thus depend on a particular elaboration of the
6940 package. It is not easy to see how it would be possible to follow this
6941 advice without severely impacting efficiency of execution.
6942
6943 @cindex Exception information
6944 @unnumberedsec 11.4.1(19): Exception Information
6945 @sp 1
6946 @cartouche
6947 @code{Exception_Message} by default and @code{Exception_Information}
6948 should produce information useful for
6949 debugging. @code{Exception_Message} should be short, about one
6950 line. @code{Exception_Information} can be long. @code{Exception_Message}
6951 should not include the
6952 @code{Exception_Name}. @code{Exception_Information} should include both
6953 the @code{Exception_Name} and the @code{Exception_Message}.
6954 @end cartouche
6955 Followed. For each exception that doesn't have a specified
6956 @code{Exception_Message}, the compiler generates one containing the location
6957 of the raise statement. This location has the form ``file:line'', where
6958 file is the short file name (without path information) and line is the line
6959 number in the file. Note that in the case of the Zero Cost Exception
6960 mechanism, these messages become redundant with the Exception_Information that
6961 contains a full backtrace of the calling sequence, so they are disabled.
6962 To disable explicitly the generation of the source location message, use the
6963 Pragma @code{Discard_Names}.
6964
6965 @cindex Suppression of checks
6966 @cindex Checks, suppression of
6967 @unnumberedsec 11.5(28): Suppression of Checks
6968 @sp 1
6969 @cartouche
6970 The implementation should minimize the code executed for checks that
6971 have been suppressed.
6972 @end cartouche
6973 Followed.
6974
6975 @cindex Representation clauses
6976 @unnumberedsec 13.1 (21-24): Representation Clauses
6977 @sp 1
6978 @cartouche
6979 The recommended level of support for all representation items is
6980 qualified as follows:
6981 @end cartouche
6982 @sp 1
6983 @cartouche
6984 An implementation need not support representation items containing
6985 non-static expressions, except that an implementation should support a
6986 representation item for a given entity if each non-static expression in
6987 the representation item is a name that statically denotes a constant
6988 declared before the entity.
6989 @end cartouche
6990 Followed. In fact, GNAT goes beyond the recommended level of support
6991 by allowing nonstatic expressions in some representation clauses even
6992 without the need to declare constants initialized with the values of
6993 such expressions.
6994 For example:
6995
6996 @smallexample @c ada
6997 X : Integer;
6998 Y : Float;
6999 for Y'Address use X'Address;>>
7000 @end smallexample
7001
7002 @sp 1
7003 @cartouche
7004 An implementation need not support a specification for the @code{Size}
7005 for a given composite subtype, nor the size or storage place for an
7006 object (including a component) of a given composite subtype, unless the
7007 constraints on the subtype and its composite subcomponents (if any) are
7008 all static constraints.
7009 @end cartouche
7010 Followed. Size Clauses are not permitted on non-static components, as
7011 described above.
7012
7013 @sp 1
7014 @cartouche
7015 An aliased component, or a component whose type is by-reference, should
7016 always be allocated at an addressable location.
7017 @end cartouche
7018 Followed.
7019
7020 @cindex Packed types
7021 @unnumberedsec 13.2(6-8): Packed Types
7022 @sp 1
7023 @cartouche
7024 If a type is packed, then the implementation should try to minimize
7025 storage allocated to objects of the type, possibly at the expense of
7026 speed of accessing components, subject to reasonable complexity in
7027 addressing calculations.
7028 @end cartouche
7029 @sp 1
7030 @cartouche
7031 The recommended level of support pragma @code{Pack} is:
7032
7033 For a packed record type, the components should be packed as tightly as
7034 possible subject to the Sizes of the component subtypes, and subject to
7035 any @code{record_representation_clause} that applies to the type; the
7036 implementation may, but need not, reorder components or cross aligned
7037 word boundaries to improve the packing. A component whose @code{Size} is
7038 greater than the word size may be allocated an integral number of words.
7039 @end cartouche
7040 Followed. Tight packing of arrays is supported for all component sizes
7041 up to 64-bits. If the array component size is 1 (that is to say, if
7042 the component is a boolean type or an enumeration type with two values)
7043 then values of the type are implicitly initialized to zero. This
7044 happens both for objects of the packed type, and for objects that have a
7045 subcomponent of the packed type.
7046
7047 @sp 1
7048 @cartouche
7049 An implementation should support Address clauses for imported
7050 subprograms.
7051 @end cartouche
7052 Followed.
7053 @cindex @code{Address} clauses
7054 @unnumberedsec 13.3(14-19): Address Clauses
7055
7056 @sp 1
7057 @cartouche
7058 For an array @var{X}, @code{@var{X}'Address} should point at the first
7059 component of the array, and not at the array bounds.
7060 @end cartouche
7061 Followed.
7062
7063 @sp 1
7064 @cartouche
7065 The recommended level of support for the @code{Address} attribute is:
7066
7067 @code{@var{X}'Address} should produce a useful result if @var{X} is an
7068 object that is aliased or of a by-reference type, or is an entity whose
7069 @code{Address} has been specified.
7070 @end cartouche
7071 Followed. A valid address will be produced even if none of those
7072 conditions have been met. If necessary, the object is forced into
7073 memory to ensure the address is valid.
7074
7075 @sp 1
7076 @cartouche
7077 An implementation should support @code{Address} clauses for imported
7078 subprograms.
7079 @end cartouche
7080 Followed.
7081
7082 @sp 1
7083 @cartouche
7084 Objects (including subcomponents) that are aliased or of a by-reference
7085 type should be allocated on storage element boundaries.
7086 @end cartouche
7087 Followed.
7088
7089 @sp 1
7090 @cartouche
7091 If the @code{Address} of an object is specified, or it is imported or exported,
7092 then the implementation should not perform optimizations based on
7093 assumptions of no aliases.
7094 @end cartouche
7095 Followed.
7096
7097 @cindex @code{Alignment} clauses
7098 @unnumberedsec 13.3(29-35): Alignment Clauses
7099 @sp 1
7100 @cartouche
7101 The recommended level of support for the @code{Alignment} attribute for
7102 subtypes is:
7103
7104 An implementation should support specified Alignments that are factors
7105 and multiples of the number of storage elements per word, subject to the
7106 following:
7107 @end cartouche
7108 Followed.
7109
7110 @sp 1
7111 @cartouche
7112 An implementation need not support specified @code{Alignment}s for
7113 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
7114 loaded and stored by available machine instructions.
7115 @end cartouche
7116 Followed.
7117
7118 @sp 1
7119 @cartouche
7120 An implementation need not support specified @code{Alignment}s that are
7121 greater than the maximum @code{Alignment} the implementation ever returns by
7122 default.
7123 @end cartouche
7124 Followed.
7125
7126 @sp 1
7127 @cartouche
7128 The recommended level of support for the @code{Alignment} attribute for
7129 objects is:
7130
7131 Same as above, for subtypes, but in addition:
7132 @end cartouche
7133 Followed.
7134
7135 @sp 1
7136 @cartouche
7137 For stand-alone library-level objects of statically constrained
7138 subtypes, the implementation should support all @code{Alignment}s
7139 supported by the target linker. For example, page alignment is likely to
7140 be supported for such objects, but not for subtypes.
7141 @end cartouche
7142 Followed.
7143
7144 @cindex @code{Size} clauses
7145 @unnumberedsec 13.3(42-43): Size Clauses
7146 @sp 1
7147 @cartouche
7148 The recommended level of support for the @code{Size} attribute of
7149 objects is:
7150
7151 A @code{Size} clause should be supported for an object if the specified
7152 @code{Size} is at least as large as its subtype's @code{Size}, and
7153 corresponds to a size in storage elements that is a multiple of the
7154 object's @code{Alignment} (if the @code{Alignment} is nonzero).
7155 @end cartouche
7156 Followed.
7157
7158 @unnumberedsec 13.3(50-56): Size Clauses
7159 @sp 1
7160 @cartouche
7161 If the @code{Size} of a subtype is specified, and allows for efficient
7162 independent addressability (see 9.10) on the target architecture, then
7163 the @code{Size} of the following objects of the subtype should equal the
7164 @code{Size} of the subtype:
7165
7166 Aliased objects (including components).
7167 @end cartouche
7168 Followed.
7169
7170 @sp 1
7171 @cartouche
7172 @code{Size} clause on a composite subtype should not affect the
7173 internal layout of components.
7174 @end cartouche
7175 Followed. But note that this can be overridden by use of the implementation
7176 pragma Implicit_Packing in the case of packed arrays.
7177
7178 @sp 1
7179 @cartouche
7180 The recommended level of support for the @code{Size} attribute of subtypes is:
7181 @end cartouche
7182 @sp 1
7183 @cartouche
7184 The @code{Size} (if not specified) of a static discrete or fixed point
7185 subtype should be the number of bits needed to represent each value
7186 belonging to the subtype using an unbiased representation, leaving space
7187 for a sign bit only if the subtype contains negative values. If such a
7188 subtype is a first subtype, then an implementation should support a
7189 specified @code{Size} for it that reflects this representation.
7190 @end cartouche
7191 Followed.
7192
7193 @sp 1
7194 @cartouche
7195 For a subtype implemented with levels of indirection, the @code{Size}
7196 should include the size of the pointers, but not the size of what they
7197 point at.
7198 @end cartouche
7199 Followed.
7200
7201 @cindex @code{Component_Size} clauses
7202 @unnumberedsec 13.3(71-73): Component Size Clauses
7203 @sp 1
7204 @cartouche
7205 The recommended level of support for the @code{Component_Size}
7206 attribute is:
7207 @end cartouche
7208 @sp 1
7209 @cartouche
7210 An implementation need not support specified @code{Component_Sizes} that are
7211 less than the @code{Size} of the component subtype.
7212 @end cartouche
7213 Followed.
7214
7215 @sp 1
7216 @cartouche
7217 An implementation should support specified @code{Component_Size}s that
7218 are factors and multiples of the word size. For such
7219 @code{Component_Size}s, the array should contain no gaps between
7220 components. For other @code{Component_Size}s (if supported), the array
7221 should contain no gaps between components when packing is also
7222 specified; the implementation should forbid this combination in cases
7223 where it cannot support a no-gaps representation.
7224 @end cartouche
7225 Followed.
7226
7227 @cindex Enumeration representation clauses
7228 @cindex Representation clauses, enumeration
7229 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7230 @sp 1
7231 @cartouche
7232 The recommended level of support for enumeration representation clauses
7233 is:
7234
7235 An implementation need not support enumeration representation clauses
7236 for boolean types, but should at minimum support the internal codes in
7237 the range @code{System.Min_Int.System.Max_Int}.
7238 @end cartouche
7239 Followed.
7240
7241 @cindex Record representation clauses
7242 @cindex Representation clauses, records
7243 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7244 @sp 1
7245 @cartouche
7246 The recommended level of support for
7247 @*@code{record_representation_clauses} is:
7248
7249 An implementation should support storage places that can be extracted
7250 with a load, mask, shift sequence of machine code, and set with a load,
7251 shift, mask, store sequence, given the available machine instructions
7252 and run-time model.
7253 @end cartouche
7254 Followed.
7255
7256 @sp 1
7257 @cartouche
7258 A storage place should be supported if its size is equal to the
7259 @code{Size} of the component subtype, and it starts and ends on a
7260 boundary that obeys the @code{Alignment} of the component subtype.
7261 @end cartouche
7262 Followed.
7263
7264 @sp 1
7265 @cartouche
7266 If the default bit ordering applies to the declaration of a given type,
7267 then for a component whose subtype's @code{Size} is less than the word
7268 size, any storage place that does not cross an aligned word boundary
7269 should be supported.
7270 @end cartouche
7271 Followed.
7272
7273 @sp 1
7274 @cartouche
7275 An implementation may reserve a storage place for the tag field of a
7276 tagged type, and disallow other components from overlapping that place.
7277 @end cartouche
7278 Followed. The storage place for the tag field is the beginning of the tagged
7279 record, and its size is Address'Size. GNAT will reject an explicit component
7280 clause for the tag field.
7281
7282 @sp 1
7283 @cartouche
7284 An implementation need not support a @code{component_clause} for a
7285 component of an extension part if the storage place is not after the
7286 storage places of all components of the parent type, whether or not
7287 those storage places had been specified.
7288 @end cartouche
7289 Followed. The above advice on record representation clauses is followed,
7290 and all mentioned features are implemented.
7291
7292 @cindex Storage place attributes
7293 @unnumberedsec 13.5.2(5): Storage Place Attributes
7294 @sp 1
7295 @cartouche
7296 If a component is represented using some form of pointer (such as an
7297 offset) to the actual data of the component, and this data is contiguous
7298 with the rest of the object, then the storage place attributes should
7299 reflect the place of the actual data, not the pointer. If a component is
7300 allocated discontinuously from the rest of the object, then a warning
7301 should be generated upon reference to one of its storage place
7302 attributes.
7303 @end cartouche
7304 Followed. There are no such components in GNAT@.
7305
7306 @cindex Bit ordering
7307 @unnumberedsec 13.5.3(7-8): Bit Ordering
7308 @sp 1
7309 @cartouche
7310 The recommended level of support for the non-default bit ordering is:
7311 @end cartouche
7312 @sp 1
7313 @cartouche
7314 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7315 should support the non-default bit ordering in addition to the default
7316 bit ordering.
7317 @end cartouche
7318 Followed. Word size does not equal storage size in this implementation.
7319 Thus non-default bit ordering is not supported.
7320
7321 @cindex @code{Address}, as private type
7322 @unnumberedsec 13.7(37): Address as Private
7323 @sp 1
7324 @cartouche
7325 @code{Address} should be of a private type.
7326 @end cartouche
7327 Followed.
7328
7329 @cindex Operations, on @code{Address}
7330 @cindex @code{Address}, operations of
7331 @unnumberedsec 13.7.1(16): Address Operations
7332 @sp 1
7333 @cartouche
7334 Operations in @code{System} and its children should reflect the target
7335 environment semantics as closely as is reasonable. For example, on most
7336 machines, it makes sense for address arithmetic to ``wrap around''.
7337 Operations that do not make sense should raise @code{Program_Error}.
7338 @end cartouche
7339 Followed. Address arithmetic is modular arithmetic that wraps around. No
7340 operation raises @code{Program_Error}, since all operations make sense.
7341
7342 @cindex Unchecked conversion
7343 @unnumberedsec 13.9(14-17): Unchecked Conversion
7344 @sp 1
7345 @cartouche
7346 The @code{Size} of an array object should not include its bounds; hence,
7347 the bounds should not be part of the converted data.
7348 @end cartouche
7349 Followed.
7350
7351 @sp 1
7352 @cartouche
7353 The implementation should not generate unnecessary run-time checks to
7354 ensure that the representation of @var{S} is a representation of the
7355 target type. It should take advantage of the permission to return by
7356 reference when possible. Restrictions on unchecked conversions should be
7357 avoided unless required by the target environment.
7358 @end cartouche
7359 Followed. There are no restrictions on unchecked conversion. A warning is
7360 generated if the source and target types do not have the same size since
7361 the semantics in this case may be target dependent.
7362
7363 @sp 1
7364 @cartouche
7365 The recommended level of support for unchecked conversions is:
7366 @end cartouche
7367 @sp 1
7368 @cartouche
7369 Unchecked conversions should be supported and should be reversible in
7370 the cases where this clause defines the result. To enable meaningful use
7371 of unchecked conversion, a contiguous representation should be used for
7372 elementary subtypes, for statically constrained array subtypes whose
7373 component subtype is one of the subtypes described in this paragraph,
7374 and for record subtypes without discriminants whose component subtypes
7375 are described in this paragraph.
7376 @end cartouche
7377 Followed.
7378
7379 @cindex Heap usage, implicit
7380 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7381 @sp 1
7382 @cartouche
7383 An implementation should document any cases in which it dynamically
7384 allocates heap storage for a purpose other than the evaluation of an
7385 allocator.
7386 @end cartouche
7387 Followed, the only other points at which heap storage is dynamically
7388 allocated are as follows:
7389
7390 @itemize @bullet
7391 @item
7392 At initial elaboration time, to allocate dynamically sized global
7393 objects.
7394
7395 @item
7396 To allocate space for a task when a task is created.
7397
7398 @item
7399 To extend the secondary stack dynamically when needed. The secondary
7400 stack is used for returning variable length results.
7401 @end itemize
7402
7403 @sp 1
7404 @cartouche
7405 A default (implementation-provided) storage pool for an
7406 access-to-constant type should not have overhead to support deallocation of
7407 individual objects.
7408 @end cartouche
7409 Followed.
7410
7411 @sp 1
7412 @cartouche
7413 A storage pool for an anonymous access type should be created at the
7414 point of an allocator for the type, and be reclaimed when the designated
7415 object becomes inaccessible.
7416 @end cartouche
7417 Followed.
7418
7419 @cindex Unchecked deallocation
7420 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7421 @sp 1
7422 @cartouche
7423 For a standard storage pool, @code{Free} should actually reclaim the
7424 storage.
7425 @end cartouche
7426 Followed.
7427
7428 @cindex Stream oriented attributes
7429 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7430 @sp 1
7431 @cartouche
7432 If a stream element is the same size as a storage element, then the
7433 normal in-memory representation should be used by @code{Read} and
7434 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
7435 should use the smallest number of stream elements needed to represent
7436 all values in the base range of the scalar type.
7437 @end cartouche
7438
7439 Followed. By default, GNAT uses the interpretation suggested by AI-195,
7440 which specifies using the size of the first subtype.
7441 However, such an implementation is based on direct binary
7442 representations and is therefore target- and endianness-dependent.
7443 To address this issue, GNAT also supplies an alternate implementation
7444 of the stream attributes @code{Read} and @code{Write},
7445 which uses the target-independent XDR standard representation
7446 for scalar types.
7447 @cindex XDR representation
7448 @cindex @code{Read} attribute
7449 @cindex @code{Write} attribute
7450 @cindex Stream oriented attributes
7451 The XDR implementation is provided as an alternative body of the
7452 @code{System.Stream_Attributes} package, in the file
7453 @file{s-stratt-xdr.adb} in the GNAT library.
7454 There is no @file{s-stratt-xdr.ads} file.
7455 In order to install the XDR implementation, do the following:
7456 @enumerate
7457 @item Replace the default implementation of the
7458 @code{System.Stream_Attributes} package with the XDR implementation.
7459 For example on a Unix platform issue the commands:
7460 @smallexample
7461 $ mv s-stratt.adb s-stratt-default.adb
7462 $ mv s-stratt-xdr.adb s-stratt.adb
7463 @end smallexample
7464
7465 @item
7466 Rebuild the GNAT run-time library as documented in
7467 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7468 @end enumerate
7469
7470 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7471 @sp 1
7472 @cartouche
7473 If an implementation provides additional named predefined integer types,
7474 then the names should end with @samp{Integer} as in
7475 @samp{Long_Integer}. If an implementation provides additional named
7476 predefined floating point types, then the names should end with
7477 @samp{Float} as in @samp{Long_Float}.
7478 @end cartouche
7479 Followed.
7480
7481 @findex Ada.Characters.Handling
7482 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7483 @sp 1
7484 @cartouche
7485 If an implementation provides a localized definition of @code{Character}
7486 or @code{Wide_Character}, then the effects of the subprograms in
7487 @code{Characters.Handling} should reflect the localizations. See also
7488 3.5.2.
7489 @end cartouche
7490 Followed. GNAT provides no such localized definitions.
7491
7492 @cindex Bounded-length strings
7493 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7494 @sp 1
7495 @cartouche
7496 Bounded string objects should not be implemented by implicit pointers
7497 and dynamic allocation.
7498 @end cartouche
7499 Followed. No implicit pointers or dynamic allocation are used.
7500
7501 @cindex Random number generation
7502 @unnumberedsec A.5.2(46-47): Random Number Generation
7503 @sp 1
7504 @cartouche
7505 Any storage associated with an object of type @code{Generator} should be
7506 reclaimed on exit from the scope of the object.
7507 @end cartouche
7508 Followed.
7509
7510 @sp 1
7511 @cartouche
7512 If the generator period is sufficiently long in relation to the number
7513 of distinct initiator values, then each possible value of
7514 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7515 random numbers that does not, in a practical sense, overlap the sequence
7516 initiated by any other value. If this is not possible, then the mapping
7517 between initiator values and generator states should be a rapidly
7518 varying function of the initiator value.
7519 @end cartouche
7520 Followed. The generator period is sufficiently long for the first
7521 condition here to hold true.
7522
7523 @findex Get_Immediate
7524 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7525 @sp 1
7526 @cartouche
7527 The @code{Get_Immediate} procedures should be implemented with
7528 unbuffered input. For a device such as a keyboard, input should be
7529 @dfn{available} if a key has already been typed, whereas for a disk
7530 file, input should always be available except at end of file. For a file
7531 associated with a keyboard-like device, any line-editing features of the
7532 underlying operating system should be disabled during the execution of
7533 @code{Get_Immediate}.
7534 @end cartouche
7535 Followed on all targets except VxWorks. For VxWorks, there is no way to
7536 provide this functionality that does not result in the input buffer being
7537 flushed before the @code{Get_Immediate} call. A special unit
7538 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7539 this functionality.
7540
7541 @findex Export
7542 @unnumberedsec B.1(39-41): Pragma @code{Export}
7543 @sp 1
7544 @cartouche
7545 If an implementation supports pragma @code{Export} to a given language,
7546 then it should also allow the main subprogram to be written in that
7547 language. It should support some mechanism for invoking the elaboration
7548 of the Ada library units included in the system, and for invoking the
7549 finalization of the environment task. On typical systems, the
7550 recommended mechanism is to provide two subprograms whose link names are
7551 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
7552 elaboration code for library units. @code{adafinal} should contain the
7553 finalization code. These subprograms should have no effect the second
7554 and subsequent time they are called.
7555 @end cartouche
7556 Followed.
7557
7558 @sp 1
7559 @cartouche
7560 Automatic elaboration of pre-elaborated packages should be
7561 provided when pragma @code{Export} is supported.
7562 @end cartouche
7563 Followed when the main program is in Ada. If the main program is in a
7564 foreign language, then
7565 @code{adainit} must be called to elaborate pre-elaborated
7566 packages.
7567
7568 @sp 1
7569 @cartouche
7570 For each supported convention @var{L} other than @code{Intrinsic}, an
7571 implementation should support @code{Import} and @code{Export} pragmas
7572 for objects of @var{L}-compatible types and for subprograms, and pragma
7573 @code{Convention} for @var{L}-eligible types and for subprograms,
7574 presuming the other language has corresponding features. Pragma
7575 @code{Convention} need not be supported for scalar types.
7576 @end cartouche
7577 Followed.
7578
7579 @cindex Package @code{Interfaces}
7580 @findex Interfaces
7581 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7582 @sp 1
7583 @cartouche
7584 For each implementation-defined convention identifier, there should be a
7585 child package of package Interfaces with the corresponding name. This
7586 package should contain any declarations that would be useful for
7587 interfacing to the language (implementation) represented by the
7588 convention. Any declarations useful for interfacing to any language on
7589 the given hardware architecture should be provided directly in
7590 @code{Interfaces}.
7591 @end cartouche
7592 Followed. An additional package not defined
7593 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7594 for interfacing to C++.
7595
7596 @sp 1
7597 @cartouche
7598 An implementation supporting an interface to C, COBOL, or Fortran should
7599 provide the corresponding package or packages described in the following
7600 clauses.
7601 @end cartouche
7602 Followed. GNAT provides all the packages described in this section.
7603
7604 @cindex C, interfacing with
7605 @unnumberedsec B.3(63-71): Interfacing with C
7606 @sp 1
7607 @cartouche
7608 An implementation should support the following interface correspondences
7609 between Ada and C@.
7610 @end cartouche
7611 Followed.
7612
7613 @sp 1
7614 @cartouche
7615 An Ada procedure corresponds to a void-returning C function.
7616 @end cartouche
7617 Followed.
7618
7619 @sp 1
7620 @cartouche
7621 An Ada function corresponds to a non-void C function.
7622 @end cartouche
7623 Followed.
7624
7625 @sp 1
7626 @cartouche
7627 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7628 function.
7629 @end cartouche
7630 Followed.
7631
7632 @sp 1
7633 @cartouche
7634 An Ada @code{in} parameter of an access-to-object type with designated
7635 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7636 where @var{t} is the C type corresponding to the Ada type @var{T}.
7637 @end cartouche
7638 Followed.
7639
7640 @sp 1
7641 @cartouche
7642 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7643 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7644 argument to a C function, where @var{t} is the C type corresponding to
7645 the Ada type @var{T}. In the case of an elementary @code{out} or
7646 @code{in out} parameter, a pointer to a temporary copy is used to
7647 preserve by-copy semantics.
7648 @end cartouche
7649 Followed.
7650
7651 @sp 1
7652 @cartouche
7653 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7654 @code{@var{t}*} argument to a C function, where @var{t} is the C
7655 structure corresponding to the Ada type @var{T}.
7656 @end cartouche
7657 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
7658 pragma, or Convention, or by explicitly specifying the mechanism for a given
7659 call using an extended import or export pragma.
7660
7661 @sp 1
7662 @cartouche
7663 An Ada parameter of an array type with component type @var{T}, of any
7664 mode, is passed as a @code{@var{t}*} argument to a C function, where
7665 @var{t} is the C type corresponding to the Ada type @var{T}.
7666 @end cartouche
7667 Followed.
7668
7669 @sp 1
7670 @cartouche
7671 An Ada parameter of an access-to-subprogram type is passed as a pointer
7672 to a C function whose prototype corresponds to the designated
7673 subprogram's specification.
7674 @end cartouche
7675 Followed.
7676
7677 @cindex COBOL, interfacing with
7678 @unnumberedsec B.4(95-98): Interfacing with COBOL
7679 @sp 1
7680 @cartouche
7681 An Ada implementation should support the following interface
7682 correspondences between Ada and COBOL@.
7683 @end cartouche
7684 Followed.
7685
7686 @sp 1
7687 @cartouche
7688 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7689 the COBOL type corresponding to @var{T}.
7690 @end cartouche
7691 Followed.
7692
7693 @sp 1
7694 @cartouche
7695 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7696 the corresponding COBOL type.
7697 @end cartouche
7698 Followed.
7699
7700 @sp 1
7701 @cartouche
7702 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7703 COBOL type corresponding to the Ada parameter type; for scalars, a local
7704 copy is used if necessary to ensure by-copy semantics.
7705 @end cartouche
7706 Followed.
7707
7708 @cindex Fortran, interfacing with
7709 @unnumberedsec B.5(22-26): Interfacing with Fortran
7710 @sp 1
7711 @cartouche
7712 An Ada implementation should support the following interface
7713 correspondences between Ada and Fortran:
7714 @end cartouche
7715 Followed.
7716
7717 @sp 1
7718 @cartouche
7719 An Ada procedure corresponds to a Fortran subroutine.
7720 @end cartouche
7721 Followed.
7722
7723 @sp 1
7724 @cartouche
7725 An Ada function corresponds to a Fortran function.
7726 @end cartouche
7727 Followed.
7728
7729 @sp 1
7730 @cartouche
7731 An Ada parameter of an elementary, array, or record type @var{T} is
7732 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7733 the Fortran type corresponding to the Ada type @var{T}, and where the
7734 INTENT attribute of the corresponding dummy argument matches the Ada
7735 formal parameter mode; the Fortran implementation's parameter passing
7736 conventions are used. For elementary types, a local copy is used if
7737 necessary to ensure by-copy semantics.
7738 @end cartouche
7739 Followed.
7740
7741 @sp 1
7742 @cartouche
7743 An Ada parameter of an access-to-subprogram type is passed as a
7744 reference to a Fortran procedure whose interface corresponds to the
7745 designated subprogram's specification.
7746 @end cartouche
7747 Followed.
7748
7749 @cindex Machine operations
7750 @unnumberedsec C.1(3-5): Access to Machine Operations
7751 @sp 1
7752 @cartouche
7753 The machine code or intrinsic support should allow access to all
7754 operations normally available to assembly language programmers for the
7755 target environment, including privileged instructions, if any.
7756 @end cartouche
7757 Followed.
7758
7759 @sp 1
7760 @cartouche
7761 The interfacing pragmas (see Annex B) should support interface to
7762 assembler; the default assembler should be associated with the
7763 convention identifier @code{Assembler}.
7764 @end cartouche
7765 Followed.
7766
7767 @sp 1
7768 @cartouche
7769 If an entity is exported to assembly language, then the implementation
7770 should allocate it at an addressable location, and should ensure that it
7771 is retained by the linking process, even if not otherwise referenced
7772 from the Ada code. The implementation should assume that any call to a
7773 machine code or assembler subprogram is allowed to read or update every
7774 object that is specified as exported.
7775 @end cartouche
7776 Followed.
7777
7778 @unnumberedsec C.1(10-16): Access to Machine Operations
7779 @sp 1
7780 @cartouche
7781 The implementation should ensure that little or no overhead is
7782 associated with calling intrinsic and machine-code subprograms.
7783 @end cartouche
7784 Followed for both intrinsics and machine-code subprograms.
7785
7786 @sp 1
7787 @cartouche
7788 It is recommended that intrinsic subprograms be provided for convenient
7789 access to any machine operations that provide special capabilities or
7790 efficiency and that are not otherwise available through the language
7791 constructs.
7792 @end cartouche
7793 Followed. A full set of machine operation intrinsic subprograms is provided.
7794
7795 @sp 1
7796 @cartouche
7797 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7798 swap, decrement and test, enqueue/dequeue.
7799 @end cartouche
7800 Followed on any target supporting such operations.
7801
7802 @sp 1
7803 @cartouche
7804 Standard numeric functions---e.g.@:, sin, log.
7805 @end cartouche
7806 Followed on any target supporting such operations.
7807
7808 @sp 1
7809 @cartouche
7810 String manipulation operations---e.g.@:, translate and test.
7811 @end cartouche
7812 Followed on any target supporting such operations.
7813
7814 @sp 1
7815 @cartouche
7816 Vector operations---e.g.@:, compare vector against thresholds.
7817 @end cartouche
7818 Followed on any target supporting such operations.
7819
7820 @sp 1
7821 @cartouche
7822 Direct operations on I/O ports.
7823 @end cartouche
7824 Followed on any target supporting such operations.
7825
7826 @cindex Interrupt support
7827 @unnumberedsec C.3(28): Interrupt Support
7828 @sp 1
7829 @cartouche
7830 If the @code{Ceiling_Locking} policy is not in effect, the
7831 implementation should provide means for the application to specify which
7832 interrupts are to be blocked during protected actions, if the underlying
7833 system allows for a finer-grain control of interrupt blocking.
7834 @end cartouche
7835 Followed. The underlying system does not allow for finer-grain control
7836 of interrupt blocking.
7837
7838 @cindex Protected procedure handlers
7839 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7840 @sp 1
7841 @cartouche
7842 Whenever possible, the implementation should allow interrupt handlers to
7843 be called directly by the hardware.
7844 @end cartouche
7845 @c SGI info:
7846 @ignore
7847 This is never possible under IRIX, so this is followed by default.
7848 @end ignore
7849 Followed on any target where the underlying operating system permits
7850 such direct calls.
7851
7852 @sp 1
7853 @cartouche
7854 Whenever practical, violations of any
7855 implementation-defined restrictions should be detected before run time.
7856 @end cartouche
7857 Followed. Compile time warnings are given when possible.
7858
7859 @cindex Package @code{Interrupts}
7860 @findex Interrupts
7861 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7862
7863 @sp 1
7864 @cartouche
7865 If implementation-defined forms of interrupt handler procedures are
7866 supported, such as protected procedures with parameters, then for each
7867 such form of a handler, a type analogous to @code{Parameterless_Handler}
7868 should be specified in a child package of @code{Interrupts}, with the
7869 same operations as in the predefined package Interrupts.
7870 @end cartouche
7871 Followed.
7872
7873 @cindex Pre-elaboration requirements
7874 @unnumberedsec C.4(14): Pre-elaboration Requirements
7875 @sp 1
7876 @cartouche
7877 It is recommended that pre-elaborated packages be implemented in such a
7878 way that there should be little or no code executed at run time for the
7879 elaboration of entities not already covered by the Implementation
7880 Requirements.
7881 @end cartouche
7882 Followed. Executable code is generated in some cases, e.g.@: loops
7883 to initialize large arrays.
7884
7885 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7886 @sp 1
7887 @cartouche
7888 If the pragma applies to an entity, then the implementation should
7889 reduce the amount of storage used for storing names associated with that
7890 entity.
7891 @end cartouche
7892 Followed.
7893
7894 @cindex Package @code{Task_Attributes}
7895 @findex Task_Attributes
7896 @unnumberedsec C.7.2(30): The Package Task_Attributes
7897 @sp 1
7898 @cartouche
7899 Some implementations are targeted to domains in which memory use at run
7900 time must be completely deterministic. For such implementations, it is
7901 recommended that the storage for task attributes will be pre-allocated
7902 statically and not from the heap. This can be accomplished by either
7903 placing restrictions on the number and the size of the task's
7904 attributes, or by using the pre-allocated storage for the first @var{N}
7905 attribute objects, and the heap for the others. In the latter case,
7906 @var{N} should be documented.
7907 @end cartouche
7908 Not followed. This implementation is not targeted to such a domain.
7909
7910 @cindex Locking Policies
7911 @unnumberedsec D.3(17): Locking Policies
7912
7913 @sp 1
7914 @cartouche
7915 The implementation should use names that end with @samp{_Locking} for
7916 locking policies defined by the implementation.
7917 @end cartouche
7918 Followed. A single implementation-defined locking policy is defined,
7919 whose name (@code{Inheritance_Locking}) follows this suggestion.
7920
7921 @cindex Entry queuing policies
7922 @unnumberedsec D.4(16): Entry Queuing Policies
7923 @sp 1
7924 @cartouche
7925 Names that end with @samp{_Queuing} should be used
7926 for all implementation-defined queuing policies.
7927 @end cartouche
7928 Followed. No such implementation-defined queuing policies exist.
7929
7930 @cindex Preemptive abort
7931 @unnumberedsec D.6(9-10): Preemptive Abort
7932 @sp 1
7933 @cartouche
7934 Even though the @code{abort_statement} is included in the list of
7935 potentially blocking operations (see 9.5.1), it is recommended that this
7936 statement be implemented in a way that never requires the task executing
7937 the @code{abort_statement} to block.
7938 @end cartouche
7939 Followed.
7940
7941 @sp 1
7942 @cartouche
7943 On a multi-processor, the delay associated with aborting a task on
7944 another processor should be bounded; the implementation should use
7945 periodic polling, if necessary, to achieve this.
7946 @end cartouche
7947 Followed.
7948
7949 @cindex Tasking restrictions
7950 @unnumberedsec D.7(21): Tasking Restrictions
7951 @sp 1
7952 @cartouche
7953 When feasible, the implementation should take advantage of the specified
7954 restrictions to produce a more efficient implementation.
7955 @end cartouche
7956 GNAT currently takes advantage of these restrictions by providing an optimized
7957 run time when the Ravenscar profile and the GNAT restricted run time set
7958 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
7959 pragma @code{Profile (Restricted)} for more details.
7960
7961 @cindex Time, monotonic
7962 @unnumberedsec D.8(47-49): Monotonic Time
7963 @sp 1
7964 @cartouche
7965 When appropriate, implementations should provide configuration
7966 mechanisms to change the value of @code{Tick}.
7967 @end cartouche
7968 Such configuration mechanisms are not appropriate to this implementation
7969 and are thus not supported.
7970
7971 @sp 1
7972 @cartouche
7973 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7974 be implemented as transformations of the same time base.
7975 @end cartouche
7976 Followed.
7977
7978 @sp 1
7979 @cartouche
7980 It is recommended that the @dfn{best} time base which exists in
7981 the underlying system be available to the application through
7982 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
7983 @end cartouche
7984 Followed.
7985
7986 @cindex Partition communication subsystem
7987 @cindex PCS
7988 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7989 @sp 1
7990 @cartouche
7991 Whenever possible, the PCS on the called partition should allow for
7992 multiple tasks to call the RPC-receiver with different messages and
7993 should allow them to block until the corresponding subprogram body
7994 returns.
7995 @end cartouche
7996 Followed by GLADE, a separately supplied PCS that can be used with
7997 GNAT.
7998
7999 @sp 1
8000 @cartouche
8001 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
8002 should raise @code{Storage_Error} if it runs out of space trying to
8003 write the @code{Item} into the stream.
8004 @end cartouche
8005 Followed by GLADE, a separately supplied PCS that can be used with
8006 GNAT@.
8007
8008 @cindex COBOL support
8009 @unnumberedsec F(7): COBOL Support
8010 @sp 1
8011 @cartouche
8012 If COBOL (respectively, C) is widely supported in the target
8013 environment, implementations supporting the Information Systems Annex
8014 should provide the child package @code{Interfaces.COBOL} (respectively,
8015 @code{Interfaces.C}) specified in Annex B and should support a
8016 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
8017 pragmas (see Annex B), thus allowing Ada programs to interface with
8018 programs written in that language.
8019 @end cartouche
8020 Followed.
8021
8022 @cindex Decimal radix support
8023 @unnumberedsec F.1(2): Decimal Radix Support
8024 @sp 1
8025 @cartouche
8026 Packed decimal should be used as the internal representation for objects
8027 of subtype @var{S} when @var{S}'Machine_Radix = 10.
8028 @end cartouche
8029 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
8030 representations.
8031
8032 @cindex Numerics
8033 @unnumberedsec G: Numerics
8034 @sp 2
8035 @cartouche
8036 If Fortran (respectively, C) is widely supported in the target
8037 environment, implementations supporting the Numerics Annex
8038 should provide the child package @code{Interfaces.Fortran} (respectively,
8039 @code{Interfaces.C}) specified in Annex B and should support a
8040 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
8041 pragmas (see Annex B), thus allowing Ada programs to interface with
8042 programs written in that language.
8043 @end cartouche
8044 Followed.
8045
8046 @cindex Complex types
8047 @unnumberedsec G.1.1(56-58): Complex Types
8048 @sp 2
8049 @cartouche
8050 Because the usual mathematical meaning of multiplication of a complex
8051 operand and a real operand is that of the scaling of both components of
8052 the former by the latter, an implementation should not perform this
8053 operation by first promoting the real operand to complex type and then
8054 performing a full complex multiplication. In systems that, in the
8055 future, support an Ada binding to IEC 559:1989, the latter technique
8056 will not generate the required result when one of the components of the
8057 complex operand is infinite. (Explicit multiplication of the infinite
8058 component by the zero component obtained during promotion yields a NaN
8059 that propagates into the final result.) Analogous advice applies in the
8060 case of multiplication of a complex operand and a pure-imaginary
8061 operand, and in the case of division of a complex operand by a real or
8062 pure-imaginary operand.
8063 @end cartouche
8064 Not followed.
8065
8066 @sp 1
8067 @cartouche
8068 Similarly, because the usual mathematical meaning of addition of a
8069 complex operand and a real operand is that the imaginary operand remains
8070 unchanged, an implementation should not perform this operation by first
8071 promoting the real operand to complex type and then performing a full
8072 complex addition. In implementations in which the @code{Signed_Zeros}
8073 attribute of the component type is @code{True} (and which therefore
8074 conform to IEC 559:1989 in regard to the handling of the sign of zero in
8075 predefined arithmetic operations), the latter technique will not
8076 generate the required result when the imaginary component of the complex
8077 operand is a negatively signed zero. (Explicit addition of the negative
8078 zero to the zero obtained during promotion yields a positive zero.)
8079 Analogous advice applies in the case of addition of a complex operand
8080 and a pure-imaginary operand, and in the case of subtraction of a
8081 complex operand and a real or pure-imaginary operand.
8082 @end cartouche
8083 Not followed.
8084
8085 @sp 1
8086 @cartouche
8087 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
8088 attempt to provide a rational treatment of the signs of zero results and
8089 result components. As one example, the result of the @code{Argument}
8090 function should have the sign of the imaginary component of the
8091 parameter @code{X} when the point represented by that parameter lies on
8092 the positive real axis; as another, the sign of the imaginary component
8093 of the @code{Compose_From_Polar} function should be the same as
8094 (respectively, the opposite of) that of the @code{Argument} parameter when that
8095 parameter has a value of zero and the @code{Modulus} parameter has a
8096 nonnegative (respectively, negative) value.
8097 @end cartouche
8098 Followed.
8099
8100 @cindex Complex elementary functions
8101 @unnumberedsec G.1.2(49): Complex Elementary Functions
8102 @sp 1
8103 @cartouche
8104 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
8105 @code{True} should attempt to provide a rational treatment of the signs
8106 of zero results and result components. For example, many of the complex
8107 elementary functions have components that are odd functions of one of
8108 the parameter components; in these cases, the result component should
8109 have the sign of the parameter component at the origin. Other complex
8110 elementary functions have zero components whose sign is opposite that of
8111 a parameter component at the origin, or is always positive or always
8112 negative.
8113 @end cartouche
8114 Followed.
8115
8116 @cindex Accuracy requirements
8117 @unnumberedsec G.2.4(19): Accuracy Requirements
8118 @sp 1
8119 @cartouche
8120 The versions of the forward trigonometric functions without a
8121 @code{Cycle} parameter should not be implemented by calling the
8122 corresponding version with a @code{Cycle} parameter of
8123 @code{2.0*Numerics.Pi}, since this will not provide the required
8124 accuracy in some portions of the domain. For the same reason, the
8125 version of @code{Log} without a @code{Base} parameter should not be
8126 implemented by calling the corresponding version with a @code{Base}
8127 parameter of @code{Numerics.e}.
8128 @end cartouche
8129 Followed.
8130
8131 @cindex Complex arithmetic accuracy
8132 @cindex Accuracy, complex arithmetic
8133 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
8134
8135 @sp 1
8136 @cartouche
8137 The version of the @code{Compose_From_Polar} function without a
8138 @code{Cycle} parameter should not be implemented by calling the
8139 corresponding version with a @code{Cycle} parameter of
8140 @code{2.0*Numerics.Pi}, since this will not provide the required
8141 accuracy in some portions of the domain.
8142 @end cartouche
8143 Followed.
8144
8145 @c -----------------------------------------
8146 @node Implementation Defined Characteristics
8147 @chapter Implementation Defined Characteristics
8148
8149 @noindent
8150 In addition to the implementation dependent pragmas and attributes, and the
8151 implementation advice, there are a number of other Ada features that are
8152 potentially implementation dependent and are designated as
8153 implementation-defined. These are mentioned throughout the Ada Reference
8154 Manual, and are summarized in Annex M@.
8155
8156 A requirement for conforming Ada compilers is that they provide
8157 documentation describing how the implementation deals with each of these
8158 issues. In this chapter, you will find each point in Annex M listed
8159 followed by a description in italic font of how GNAT
8160 @c SGI info:
8161 @ignore
8162 in the ProDev Ada
8163 implementation on IRIX 5.3 operating system or greater
8164 @end ignore
8165 handles the implementation dependence.
8166
8167 You can use this chapter as a guide to minimizing implementation
8168 dependent features in your programs if portability to other compilers
8169 and other operating systems is an important consideration. The numbers
8170 in each section below correspond to the paragraph number in the Ada
8171 Reference Manual.
8172
8173 @sp 1
8174 @cartouche
8175 @noindent
8176 @strong{2}. Whether or not each recommendation given in Implementation
8177 Advice is followed. See 1.1.2(37).
8178 @end cartouche
8179 @noindent
8180 @xref{Implementation Advice}.
8181
8182 @sp 1
8183 @cartouche
8184 @noindent
8185 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
8186 @end cartouche
8187 @noindent
8188 The complexity of programs that can be processed is limited only by the
8189 total amount of available virtual memory, and disk space for the
8190 generated object files.
8191
8192 @sp 1
8193 @cartouche
8194 @noindent
8195 @strong{4}. Variations from the standard that are impractical to avoid
8196 given the implementation's execution environment. See 1.1.3(6).
8197 @end cartouche
8198 @noindent
8199 There are no variations from the standard.
8200
8201 @sp 1
8202 @cartouche
8203 @noindent
8204 @strong{5}. Which @code{code_statement}s cause external
8205 interactions. See 1.1.3(10).
8206 @end cartouche
8207 @noindent
8208 Any @code{code_statement} can potentially cause external interactions.
8209
8210 @sp 1
8211 @cartouche
8212 @noindent
8213 @strong{6}. The coded representation for the text of an Ada
8214 program. See 2.1(4).
8215 @end cartouche
8216 @noindent
8217 See separate section on source representation.
8218
8219 @sp 1
8220 @cartouche
8221 @noindent
8222 @strong{7}. The control functions allowed in comments. See 2.1(14).
8223 @end cartouche
8224 @noindent
8225 See separate section on source representation.
8226
8227 @sp 1
8228 @cartouche
8229 @noindent
8230 @strong{8}. The representation for an end of line. See 2.2(2).
8231 @end cartouche
8232 @noindent
8233 See separate section on source representation.
8234
8235 @sp 1
8236 @cartouche
8237 @noindent
8238 @strong{9}. Maximum supported line length and lexical element
8239 length. See 2.2(15).
8240 @end cartouche
8241 @noindent
8242 The maximum line length is 255 characters and the maximum length of a
8243 lexical element is also 255 characters.
8244
8245 @sp 1
8246 @cartouche
8247 @noindent
8248 @strong{10}. Implementation defined pragmas. See 2.8(14).
8249 @end cartouche
8250 @noindent
8251
8252 @xref{Implementation Defined Pragmas}.
8253
8254 @sp 1
8255 @cartouche
8256 @noindent
8257 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
8258 @end cartouche
8259 @noindent
8260 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8261 parameter, checks that the optimization flag is set, and aborts if it is
8262 not.
8263
8264 @sp 1
8265 @cartouche
8266 @noindent
8267 @strong{12}. The sequence of characters of the value returned by
8268 @code{@var{S}'Image} when some of the graphic characters of
8269 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
8270 3.5(37).
8271 @end cartouche
8272 @noindent
8273 The sequence of characters is as defined by the wide character encoding
8274 method used for the source. See section on source representation for
8275 further details.
8276
8277 @sp 1
8278 @cartouche
8279 @noindent
8280 @strong{13}. The predefined integer types declared in
8281 @code{Standard}. See 3.5.4(25).
8282 @end cartouche
8283 @noindent
8284 @table @code
8285 @item Short_Short_Integer
8286 8 bit signed
8287 @item Short_Integer
8288 (Short) 16 bit signed
8289 @item Integer
8290 32 bit signed
8291 @item Long_Integer
8292 64 bit signed (on most 64 bit targets, depending on the C definition of long).
8293 32 bit signed (all other targets)
8294 @item Long_Long_Integer
8295 64 bit signed
8296 @end table
8297
8298 @sp 1
8299 @cartouche
8300 @noindent
8301 @strong{14}. Any nonstandard integer types and the operators defined
8302 for them. See 3.5.4(26).
8303 @end cartouche
8304 @noindent
8305 There are no nonstandard integer types.
8306
8307 @sp 1
8308 @cartouche
8309 @noindent
8310 @strong{15}. Any nonstandard real types and the operators defined for
8311 them. See 3.5.6(8).
8312 @end cartouche
8313 @noindent
8314 There are no nonstandard real types.
8315
8316 @sp 1
8317 @cartouche
8318 @noindent
8319 @strong{16}. What combinations of requested decimal precision and range
8320 are supported for floating point types. See 3.5.7(7).
8321 @end cartouche
8322 @noindent
8323 The precision and range is as defined by the IEEE standard.
8324
8325 @sp 1
8326 @cartouche
8327 @noindent
8328 @strong{17}. The predefined floating point types declared in
8329 @code{Standard}. See 3.5.7(16).
8330 @end cartouche
8331 @noindent
8332 @table @code
8333 @item Short_Float
8334 32 bit IEEE short
8335 @item Float
8336 (Short) 32 bit IEEE short
8337 @item Long_Float
8338 64 bit IEEE long
8339 @item Long_Long_Float
8340 64 bit IEEE long (80 bit IEEE long on x86 processors)
8341 @end table
8342
8343 @sp 1
8344 @cartouche
8345 @noindent
8346 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
8347 @end cartouche
8348 @noindent
8349 @code{Fine_Delta} is 2**(@minus{}63)
8350
8351 @sp 1
8352 @cartouche
8353 @noindent
8354 @strong{19}. What combinations of small, range, and digits are
8355 supported for fixed point types. See 3.5.9(10).
8356 @end cartouche
8357 @noindent
8358 Any combinations are permitted that do not result in a small less than
8359 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8360 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8361 is 64 bits (true of all architectures except ia32), then the output from
8362 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
8363 is because floating-point conversions are used to convert fixed point.
8364
8365 @sp 1
8366 @cartouche
8367 @noindent
8368 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
8369 within an unnamed @code{block_statement}. See 3.9(10).
8370 @end cartouche
8371 @noindent
8372 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8373 decimal integer are allocated.
8374
8375 @sp 1
8376 @cartouche
8377 @noindent
8378 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
8379 @end cartouche
8380 @noindent
8381 @xref{Implementation Defined Attributes}.
8382
8383 @sp 1
8384 @cartouche
8385 @noindent
8386 @strong{22}. Any implementation-defined time types. See 9.6(6).
8387 @end cartouche
8388 @noindent
8389 There are no implementation-defined time types.
8390
8391 @sp 1
8392 @cartouche
8393 @noindent
8394 @strong{23}. The time base associated with relative delays.
8395 @end cartouche
8396 @noindent
8397 See 9.6(20). The time base used is that provided by the C library
8398 function @code{gettimeofday}.
8399
8400 @sp 1
8401 @cartouche
8402 @noindent
8403 @strong{24}. The time base of the type @code{Calendar.Time}. See
8404 9.6(23).
8405 @end cartouche
8406 @noindent
8407 The time base used is that provided by the C library function
8408 @code{gettimeofday}.
8409
8410 @sp 1
8411 @cartouche
8412 @noindent
8413 @strong{25}. The time zone used for package @code{Calendar}
8414 operations. See 9.6(24).
8415 @end cartouche
8416 @noindent
8417 The time zone used by package @code{Calendar} is the current system time zone
8418 setting for local time, as accessed by the C library function
8419 @code{localtime}.
8420
8421 @sp 1
8422 @cartouche
8423 @noindent
8424 @strong{26}. Any limit on @code{delay_until_statements} of
8425 @code{select_statements}. See 9.6(29).
8426 @end cartouche
8427 @noindent
8428 There are no such limits.
8429
8430 @sp 1
8431 @cartouche
8432 @noindent
8433 @strong{27}. Whether or not two non-overlapping parts of a composite
8434 object are independently addressable, in the case where packing, record
8435 layout, or @code{Component_Size} is specified for the object. See
8436 9.10(1).
8437 @end cartouche
8438 @noindent
8439 Separate components are independently addressable if they do not share
8440 overlapping storage units.
8441
8442 @sp 1
8443 @cartouche
8444 @noindent
8445 @strong{28}. The representation for a compilation. See 10.1(2).
8446 @end cartouche
8447 @noindent
8448 A compilation is represented by a sequence of files presented to the
8449 compiler in a single invocation of the @command{gcc} command.
8450
8451 @sp 1
8452 @cartouche
8453 @noindent
8454 @strong{29}. Any restrictions on compilations that contain multiple
8455 compilation_units. See 10.1(4).
8456 @end cartouche
8457 @noindent
8458 No single file can contain more than one compilation unit, but any
8459 sequence of files can be presented to the compiler as a single
8460 compilation.
8461
8462 @sp 1
8463 @cartouche
8464 @noindent
8465 @strong{30}. The mechanisms for creating an environment and for adding
8466 and replacing compilation units. See 10.1.4(3).
8467 @end cartouche
8468 @noindent
8469 See separate section on compilation model.
8470
8471 @sp 1
8472 @cartouche
8473 @noindent
8474 @strong{31}. The manner of explicitly assigning library units to a
8475 partition. See 10.2(2).
8476 @end cartouche
8477 @noindent
8478 If a unit contains an Ada main program, then the Ada units for the partition
8479 are determined by recursive application of the rules in the Ada Reference
8480 Manual section 10.2(2-6). In other words, the Ada units will be those that
8481 are needed by the main program, and then this definition of need is applied
8482 recursively to those units, and the partition contains the transitive
8483 closure determined by this relationship. In short, all the necessary units
8484 are included, with no need to explicitly specify the list. If additional
8485 units are required, e.g.@: by foreign language units, then all units must be
8486 mentioned in the context clause of one of the needed Ada units.
8487
8488 If the partition contains no main program, or if the main program is in
8489 a language other than Ada, then GNAT
8490 provides the binder options @option{-z} and @option{-n} respectively, and in
8491 this case a list of units can be explicitly supplied to the binder for
8492 inclusion in the partition (all units needed by these units will also
8493 be included automatically). For full details on the use of these
8494 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8495 @value{EDITION} User's Guide}.
8496
8497 @sp 1
8498 @cartouche
8499 @noindent
8500 @strong{32}. The implementation-defined means, if any, of specifying
8501 which compilation units are needed by a given compilation unit. See
8502 10.2(2).
8503 @end cartouche
8504 @noindent
8505 The units needed by a given compilation unit are as defined in
8506 the Ada Reference Manual section 10.2(2-6). There are no
8507 implementation-defined pragmas or other implementation-defined
8508 means for specifying needed units.
8509
8510 @sp 1
8511 @cartouche
8512 @noindent
8513 @strong{33}. The manner of designating the main subprogram of a
8514 partition. See 10.2(7).
8515 @end cartouche
8516 @noindent
8517 The main program is designated by providing the name of the
8518 corresponding @file{ALI} file as the input parameter to the binder.
8519
8520 @sp 1
8521 @cartouche
8522 @noindent
8523 @strong{34}. The order of elaboration of @code{library_items}. See
8524 10.2(18).
8525 @end cartouche
8526 @noindent
8527 The first constraint on ordering is that it meets the requirements of
8528 Chapter 10 of the Ada Reference Manual. This still leaves some
8529 implementation dependent choices, which are resolved by first
8530 elaborating bodies as early as possible (i.e., in preference to specs
8531 where there is a choice), and second by evaluating the immediate with
8532 clauses of a unit to determine the probably best choice, and
8533 third by elaborating in alphabetical order of unit names
8534 where a choice still remains.
8535
8536 @sp 1
8537 @cartouche
8538 @noindent
8539 @strong{35}. Parameter passing and function return for the main
8540 subprogram. See 10.2(21).
8541 @end cartouche
8542 @noindent
8543 The main program has no parameters. It may be a procedure, or a function
8544 returning an integer type. In the latter case, the returned integer
8545 value is the return code of the program (overriding any value that
8546 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8547
8548 @sp 1
8549 @cartouche
8550 @noindent
8551 @strong{36}. The mechanisms for building and running partitions. See
8552 10.2(24).
8553 @end cartouche
8554 @noindent
8555 GNAT itself supports programs with only a single partition. The GNATDIST
8556 tool provided with the GLADE package (which also includes an implementation
8557 of the PCS) provides a completely flexible method for building and running
8558 programs consisting of multiple partitions. See the separate GLADE manual
8559 for details.
8560
8561 @sp 1
8562 @cartouche
8563 @noindent
8564 @strong{37}. The details of program execution, including program
8565 termination. See 10.2(25).
8566 @end cartouche
8567 @noindent
8568 See separate section on compilation model.
8569
8570 @sp 1
8571 @cartouche
8572 @noindent
8573 @strong{38}. The semantics of any non-active partitions supported by the
8574 implementation. See 10.2(28).
8575 @end cartouche
8576 @noindent
8577 Passive partitions are supported on targets where shared memory is
8578 provided by the operating system. See the GLADE reference manual for
8579 further details.
8580
8581 @sp 1
8582 @cartouche
8583 @noindent
8584 @strong{39}. The information returned by @code{Exception_Message}. See
8585 11.4.1(10).
8586 @end cartouche
8587 @noindent
8588 Exception message returns the null string unless a specific message has
8589 been passed by the program.
8590
8591 @sp 1
8592 @cartouche
8593 @noindent
8594 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
8595 declared within an unnamed @code{block_statement}. See 11.4.1(12).
8596 @end cartouche
8597 @noindent
8598 Blocks have implementation defined names of the form @code{B@var{nnn}}
8599 where @var{nnn} is an integer.
8600
8601 @sp 1
8602 @cartouche
8603 @noindent
8604 @strong{41}. The information returned by
8605 @code{Exception_Information}. See 11.4.1(13).
8606 @end cartouche
8607 @noindent
8608 @code{Exception_Information} returns a string in the following format:
8609
8610 @smallexample
8611 @emph{Exception_Name:} nnnnn
8612 @emph{Message:} mmmmm
8613 @emph{PID:} ppp
8614 @emph{Call stack traceback locations:}
8615 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8616 @end smallexample
8617
8618 @noindent
8619 where
8620
8621 @itemize @bullet
8622 @item
8623 @code{nnnn} is the fully qualified name of the exception in all upper
8624 case letters. This line is always present.
8625
8626 @item
8627 @code{mmmm} is the message (this line present only if message is non-null)
8628
8629 @item
8630 @code{ppp} is the Process Id value as a decimal integer (this line is
8631 present only if the Process Id is nonzero). Currently we are
8632 not making use of this field.
8633
8634 @item
8635 The Call stack traceback locations line and the following values
8636 are present only if at least one traceback location was recorded.
8637 The values are given in C style format, with lower case letters
8638 for a-f, and only as many digits present as are necessary.
8639 @end itemize
8640
8641 @noindent
8642 The line terminator sequence at the end of each line, including
8643 the last line is a single @code{LF} character (@code{16#0A#}).
8644
8645 @sp 1
8646 @cartouche
8647 @noindent
8648 @strong{42}. Implementation-defined check names. See 11.5(27).
8649 @end cartouche
8650 @noindent
8651 The implementation defined check name Alignment_Check controls checking of
8652 address clause values for proper alignment (that is, the address supplied
8653 must be consistent with the alignment of the type).
8654
8655 In addition, a user program can add implementation-defined check names
8656 by means of the pragma Check_Name.
8657
8658 @sp 1
8659 @cartouche
8660 @noindent
8661 @strong{43}. The interpretation of each aspect of representation. See
8662 13.1(20).
8663 @end cartouche
8664 @noindent
8665 See separate section on data representations.
8666
8667 @sp 1
8668 @cartouche
8669 @noindent
8670 @strong{44}. Any restrictions placed upon representation items. See
8671 13.1(20).
8672 @end cartouche
8673 @noindent
8674 See separate section on data representations.
8675
8676 @sp 1
8677 @cartouche
8678 @noindent
8679 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
8680 13.3(48).
8681 @end cartouche
8682 @noindent
8683 Size for an indefinite subtype is the maximum possible size, except that
8684 for the case of a subprogram parameter, the size of the parameter object
8685 is the actual size.
8686
8687 @sp 1
8688 @cartouche
8689 @noindent
8690 @strong{46}. The default external representation for a type tag. See
8691 13.3(75).
8692 @end cartouche
8693 @noindent
8694 The default external representation for a type tag is the fully expanded
8695 name of the type in upper case letters.
8696
8697 @sp 1
8698 @cartouche
8699 @noindent
8700 @strong{47}. What determines whether a compilation unit is the same in
8701 two different partitions. See 13.3(76).
8702 @end cartouche
8703 @noindent
8704 A compilation unit is the same in two different partitions if and only
8705 if it derives from the same source file.
8706
8707 @sp 1
8708 @cartouche
8709 @noindent
8710 @strong{48}. Implementation-defined components. See 13.5.1(15).
8711 @end cartouche
8712 @noindent
8713 The only implementation defined component is the tag for a tagged type,
8714 which contains a pointer to the dispatching table.
8715
8716 @sp 1
8717 @cartouche
8718 @noindent
8719 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
8720 ordering. See 13.5.3(5).
8721 @end cartouche
8722 @noindent
8723 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8724 implementation, so no non-default bit ordering is supported. The default
8725 bit ordering corresponds to the natural endianness of the target architecture.
8726
8727 @sp 1
8728 @cartouche
8729 @noindent
8730 @strong{50}. The contents of the visible part of package @code{System}
8731 and its language-defined children. See 13.7(2).
8732 @end cartouche
8733 @noindent
8734 See the definition of these packages in files @file{system.ads} and
8735 @file{s-stoele.ads}.
8736
8737 @sp 1
8738 @cartouche
8739 @noindent
8740 @strong{51}. The contents of the visible part of package
8741 @code{System.Machine_Code}, and the meaning of
8742 @code{code_statements}. See 13.8(7).
8743 @end cartouche
8744 @noindent
8745 See the definition and documentation in file @file{s-maccod.ads}.
8746
8747 @sp 1
8748 @cartouche
8749 @noindent
8750 @strong{52}. The effect of unchecked conversion. See 13.9(11).
8751 @end cartouche
8752 @noindent
8753 Unchecked conversion between types of the same size
8754 results in an uninterpreted transmission of the bits from one type
8755 to the other. If the types are of unequal sizes, then in the case of
8756 discrete types, a shorter source is first zero or sign extended as
8757 necessary, and a shorter target is simply truncated on the left.
8758 For all non-discrete types, the source is first copied if necessary
8759 to ensure that the alignment requirements of the target are met, then
8760 a pointer is constructed to the source value, and the result is obtained
8761 by dereferencing this pointer after converting it to be a pointer to the
8762 target type. Unchecked conversions where the target subtype is an
8763 unconstrained array are not permitted. If the target alignment is
8764 greater than the source alignment, then a copy of the result is
8765 made with appropriate alignment
8766
8767 @sp 1
8768 @cartouche
8769 @noindent
8770 @strong{53}. The semantics of operations on invalid representations.
8771 See 13.9.2(10-11).
8772 @end cartouche
8773 @noindent
8774 For assignments and other operations where the use of invalid values cannot
8775 result in erroneous behavior, the compiler ignores the possibility of invalid
8776 values. An exception is raised at the point where an invalid value would
8777 result in erroneous behavior. For example executing:
8778
8779 @smallexample @c ada
8780 procedure invalidvals is
8781 X : Integer := -1;
8782 Y : Natural range 1 .. 10;
8783 for Y'Address use X'Address;
8784 Z : Natural range 1 .. 10;
8785 A : array (Natural range 1 .. 10) of Integer;
8786 begin
8787 Z := Y; -- no exception
8788 A (Z) := 3; -- exception raised;
8789 end;
8790 @end smallexample
8791
8792 @noindent
8793 As indicated, an exception is raised on the array assignment, but not
8794 on the simple assignment of the invalid negative value from Y to Z.
8795
8796 @sp 1
8797 @cartouche
8798 @noindent
8799 @strong{53}. The manner of choosing a storage pool for an access type
8800 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
8801 @end cartouche
8802 @noindent
8803 There are 3 different standard pools used by the compiler when
8804 @code{Storage_Pool} is not specified depending whether the type is local
8805 to a subprogram or defined at the library level and whether
8806 @code{Storage_Size}is specified or not. See documentation in the runtime
8807 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8808 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8809 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8810 default pools used.
8811
8812 @sp 1
8813 @cartouche
8814 @noindent
8815 @strong{54}. Whether or not the implementation provides user-accessible
8816 names for the standard pool type(s). See 13.11(17).
8817 @end cartouche
8818 @noindent
8819
8820 See documentation in the sources of the run time mentioned in paragraph
8821 @strong{53} . All these pools are accessible by means of @code{with}'ing
8822 these units.
8823
8824 @sp 1
8825 @cartouche
8826 @noindent
8827 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
8828 @end cartouche
8829 @noindent
8830 @code{Storage_Size} is measured in storage units, and refers to the
8831 total space available for an access type collection, or to the primary
8832 stack space for a task.
8833
8834 @sp 1
8835 @cartouche
8836 @noindent
8837 @strong{56}. Implementation-defined aspects of storage pools. See
8838 13.11(22).
8839 @end cartouche
8840 @noindent
8841 See documentation in the sources of the run time mentioned in paragraph
8842 @strong{53} for details on GNAT-defined aspects of storage pools.
8843
8844 @sp 1
8845 @cartouche
8846 @noindent
8847 @strong{57}. The set of restrictions allowed in a pragma
8848 @code{Restrictions}. See 13.12(7).
8849 @end cartouche
8850 @noindent
8851 All RM defined Restriction identifiers are implemented. The following
8852 additional restriction identifiers are provided. There are two separate
8853 lists of implementation dependent restriction identifiers. The first
8854 set requires consistency throughout a partition (in other words, if the
8855 restriction identifier is used for any compilation unit in the partition,
8856 then all compilation units in the partition must obey the restriction.
8857
8858 @table @code
8859
8860 @item Simple_Barriers
8861 @findex Simple_Barriers
8862 This restriction ensures at compile time that barriers in entry declarations
8863 for protected types are restricted to either static boolean expressions or
8864 references to simple boolean variables defined in the private part of the
8865 protected type. No other form of entry barriers is permitted. This is one
8866 of the restrictions of the Ravenscar profile for limited tasking (see also
8867 pragma @code{Profile (Ravenscar)}).
8868
8869 @item Max_Entry_Queue_Length => Expr
8870 @findex Max_Entry_Queue_Length
8871 This restriction is a declaration that any protected entry compiled in
8872 the scope of the restriction has at most the specified number of
8873 tasks waiting on the entry
8874 at any one time, and so no queue is required. This restriction is not
8875 checked at compile time. A program execution is erroneous if an attempt
8876 is made to queue more than the specified number of tasks on such an entry.
8877
8878 @item No_Calendar
8879 @findex No_Calendar
8880 This restriction ensures at compile time that there is no implicit or
8881 explicit dependence on the package @code{Ada.Calendar}.
8882
8883 @item No_Default_Initialization
8884 @findex No_Default_Initialization
8885
8886 This restriction prohibits any instance of default initialization of variables.
8887 The binder implements a consistency rule which prevents any unit compiled
8888 without the restriction from with'ing a unit with the restriction (this allows
8889 the generation of initialization procedures to be skipped, since you can be
8890 sure that no call is ever generated to an initialization procedure in a unit
8891 with the restriction active). If used in conjunction with Initialize_Scalars or
8892 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8893 without a specific initializer (including the case of OUT scalar parameters).
8894
8895 @item No_Direct_Boolean_Operators
8896 @findex No_Direct_Boolean_Operators
8897 This restriction ensures that no logical (and/or/xor) are used on
8898 operands of type Boolean (or any type derived
8899 from Boolean). This is intended for use in safety critical programs
8900 where the certification protocol requires the use of short-circuit
8901 (and then, or else) forms for all composite boolean operations.
8902
8903 @item No_Dispatching_Calls
8904 @findex No_Dispatching_Calls
8905 This restriction ensures at compile time that the code generated by the
8906 compiler involves no dispatching calls. The use of this restriction allows the
8907 safe use of record extensions, classwide membership tests and other classwide
8908 features not involving implicit dispatching. This restriction ensures that
8909 the code contains no indirect calls through a dispatching mechanism. Note that
8910 this includes internally-generated calls created by the compiler, for example
8911 in the implementation of class-wide objects assignments. The
8912 membership test is allowed in the presence of this restriction, because its
8913 implementation requires no dispatching.
8914 This restriction is comparable to the official Ada restriction
8915 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8916 all classwide constructs that do not imply dispatching.
8917 The following example indicates constructs that violate this restriction.
8918
8919 @smallexample
8920 package Pkg is
8921 type T is tagged record
8922 Data : Natural;
8923 end record;
8924 procedure P (X : T);
8925
8926 type DT is new T with record
8927 More_Data : Natural;
8928 end record;
8929 procedure Q (X : DT);
8930 end Pkg;
8931
8932 with Pkg; use Pkg;
8933 procedure Example is
8934 procedure Test (O : T'Class) is
8935 N : Natural := O'Size;-- Error: Dispatching call
8936 C : T'Class := O; -- Error: implicit Dispatching Call
8937 begin
8938 if O in DT'Class then -- OK : Membership test
8939 Q (DT (O)); -- OK : Type conversion plus direct call
8940 else
8941 P (O); -- Error: Dispatching call
8942 end if;
8943 end Test;
8944
8945 Obj : DT;
8946 begin
8947 P (Obj); -- OK : Direct call
8948 P (T (Obj)); -- OK : Type conversion plus direct call
8949 P (T'Class (Obj)); -- Error: Dispatching call
8950
8951 Test (Obj); -- OK : Type conversion
8952
8953 if Obj in T'Class then -- OK : Membership test
8954 null;
8955 end if;
8956 end Example;
8957 @end smallexample
8958
8959 @item No_Dynamic_Attachment
8960 @findex No_Dynamic_Attachment
8961 This restriction ensures that there is no call to any of the operations
8962 defined in package Ada.Interrupts.
8963
8964 @item No_Enumeration_Maps
8965 @findex No_Enumeration_Maps
8966 This restriction ensures at compile time that no operations requiring
8967 enumeration maps are used (that is Image and Value attributes applied
8968 to enumeration types).
8969
8970 @item No_Entry_Calls_In_Elaboration_Code
8971 @findex No_Entry_Calls_In_Elaboration_Code
8972 This restriction ensures at compile time that no task or protected entry
8973 calls are made during elaboration code. As a result of the use of this
8974 restriction, the compiler can assume that no code past an accept statement
8975 in a task can be executed at elaboration time.
8976
8977 @item No_Exception_Handlers
8978 @findex No_Exception_Handlers
8979 This restriction ensures at compile time that there are no explicit
8980 exception handlers. It also indicates that no exception propagation will
8981 be provided. In this mode, exceptions may be raised but will result in
8982 an immediate call to the last chance handler, a routine that the user
8983 must define with the following profile:
8984
8985 @smallexample @c ada
8986 procedure Last_Chance_Handler
8987 (Source_Location : System.Address; Line : Integer);
8988 pragma Export (C, Last_Chance_Handler,
8989 "__gnat_last_chance_handler");
8990 @end smallexample
8991
8992 The parameter is a C null-terminated string representing a message to be
8993 associated with the exception (typically the source location of the raise
8994 statement generated by the compiler). The Line parameter when nonzero
8995 represents the line number in the source program where the raise occurs.
8996
8997 @item No_Exception_Propagation
8998 @findex No_Exception_Propagation
8999 This restriction guarantees that exceptions are never propagated to an outer
9000 subprogram scope). The only case in which an exception may be raised is when
9001 the handler is statically in the same subprogram, so that the effect of a raise
9002 is essentially like a goto statement. Any other raise statement (implicit or
9003 explicit) will be considered unhandled. Exception handlers are allowed, but may
9004 not contain an exception occurrence identifier (exception choice). In addition
9005 use of the package GNAT.Current_Exception is not permitted, and reraise
9006 statements (raise with no operand) are not permitted.
9007
9008 @item No_Exception_Registration
9009 @findex No_Exception_Registration
9010 This restriction ensures at compile time that no stream operations for
9011 types Exception_Id or Exception_Occurrence are used. This also makes it
9012 impossible to pass exceptions to or from a partition with this restriction
9013 in a distributed environment. If this exception is active, then the generated
9014 code is simplified by omitting the otherwise-required global registration
9015 of exceptions when they are declared.
9016
9017 @item No_Implicit_Aliasing
9018 @findex No_Implicit_Aliasing
9019
9020 This restriction, which is not required to be partition-wide consistent,
9021 requires an explicit aliased keyword for an object to which 'Access,
9022 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9023 the 'Unrestricted_Access attribute for objects. Note: the reason that
9024 Unrestricted_Access is forbidden is that it would require the prefix
9025 to be aliased, and in such cases, it can always be replaced by
9026 the standard attribute Unchecked_Access which is preferable.
9027
9028 @item No_Implicit_Conditionals
9029 @findex No_Implicit_Conditionals
9030 This restriction ensures that the generated code does not contain any
9031 implicit conditionals, either by modifying the generated code where possible,
9032 or by rejecting any construct that would otherwise generate an implicit
9033 conditional. Note that this check does not include run time constraint
9034 checks, which on some targets may generate implicit conditionals as
9035 well. To control the latter, constraint checks can be suppressed in the
9036 normal manner. Constructs generating implicit conditionals include comparisons
9037 of composite objects and the Max/Min attributes.
9038
9039 @item No_Implicit_Dynamic_Code
9040 @findex No_Implicit_Dynamic_Code
9041 @cindex trampoline
9042 This restriction prevents the compiler from building ``trampolines''.
9043 This is a structure that is built on the stack and contains dynamic
9044 code to be executed at run time. On some targets, a trampoline is
9045 built for the following features: @code{Access},
9046 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9047 nested task bodies; primitive operations of nested tagged types.
9048 Trampolines do not work on machines that prevent execution of stack
9049 data. For example, on windows systems, enabling DEP (data execution
9050 protection) will cause trampolines to raise an exception.
9051 Trampolines are also quite slow at run time.
9052
9053 On many targets, trampolines have been largely eliminated. Look at the
9054 version of system.ads for your target --- if it has
9055 Always_Compatible_Rep equal to False, then trampolines are largely
9056 eliminated. In particular, a trampoline is built for the following
9057 features: @code{Address} of a nested subprogram;
9058 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9059 but only if pragma Favor_Top_Level applies, or the access type has a
9060 foreign-language convention; primitive operations of nested tagged
9061 types.
9062
9063 @item No_Implicit_Loops
9064 @findex No_Implicit_Loops
9065 This restriction ensures that the generated code does not contain any
9066 implicit @code{for} loops, either by modifying
9067 the generated code where possible,
9068 or by rejecting any construct that would otherwise generate an implicit
9069 @code{for} loop. If this restriction is active, it is possible to build
9070 large array aggregates with all static components without generating an
9071 intermediate temporary, and without generating a loop to initialize individual
9072 components. Otherwise, a loop is created for arrays larger than about 5000
9073 scalar components.
9074
9075 @item No_Initialize_Scalars
9076 @findex No_Initialize_Scalars
9077 This restriction ensures that no unit in the partition is compiled with
9078 pragma Initialize_Scalars. This allows the generation of more efficient
9079 code, and in particular eliminates dummy null initialization routines that
9080 are otherwise generated for some record and array types.
9081
9082 @item No_Local_Protected_Objects
9083 @findex No_Local_Protected_Objects
9084 This restriction ensures at compile time that protected objects are
9085 only declared at the library level.
9086
9087 @item No_Protected_Type_Allocators
9088 @findex No_Protected_Type_Allocators
9089 This restriction ensures at compile time that there are no allocator
9090 expressions that attempt to allocate protected objects.
9091
9092 @item No_Secondary_Stack
9093 @findex No_Secondary_Stack
9094 This restriction ensures at compile time that the generated code does not
9095 contain any reference to the secondary stack. The secondary stack is used
9096 to implement functions returning unconstrained objects (arrays or records)
9097 on some targets.
9098
9099 @item No_Select_Statements
9100 @findex No_Select_Statements
9101 This restriction ensures at compile time no select statements of any kind
9102 are permitted, that is the keyword @code{select} may not appear.
9103 This is one of the restrictions of the Ravenscar
9104 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
9105
9106 @item No_Standard_Storage_Pools
9107 @findex No_Standard_Storage_Pools
9108 This restriction ensures at compile time that no access types
9109 use the standard default storage pool. Any access type declared must
9110 have an explicit Storage_Pool attribute defined specifying a
9111 user-defined storage pool.
9112
9113 @item No_Streams
9114 @findex No_Streams
9115 This restriction ensures at compile/bind time that there are no
9116 stream objects created and no use of stream attributes.
9117 This restriction does not forbid dependences on the package
9118 @code{Ada.Streams}. So it is permissible to with
9119 @code{Ada.Streams} (or another package that does so itself)
9120 as long as no actual stream objects are created and no
9121 stream attributes are used.
9122
9123 Note that the use of restriction allows optimization of tagged types,
9124 since they do not need to worry about dispatching stream operations.
9125 To take maximum advantage of this space-saving optimization, any
9126 unit declaring a tagged type should be compiled with the restriction,
9127 though this is not required.
9128
9129 @item No_Task_Attributes_Package
9130 @findex No_Task_Attributes_Package
9131 This restriction ensures at compile time that there are no implicit or
9132 explicit dependencies on the package @code{Ada.Task_Attributes}.
9133
9134 @item No_Task_Termination
9135 @findex No_Task_Termination
9136 This restriction ensures at compile time that no terminate alternatives
9137 appear in any task body.
9138
9139 @item No_Tasking
9140 @findex No_Tasking
9141 This restriction prevents the declaration of tasks or task types throughout
9142 the partition. It is similar in effect to the use of @code{Max_Tasks => 0}
9143 except that violations are caught at compile time and cause an error message
9144 to be output either by the compiler or binder.
9145
9146 @item Static_Priorities
9147 @findex Static_Priorities
9148 This restriction ensures at compile time that all priority expressions
9149 are static, and that there are no dependencies on the package
9150 @code{Ada.Dynamic_Priorities}.
9151
9152 @item Static_Storage_Size
9153 @findex Static_Storage_Size
9154 This restriction ensures at compile time that any expression appearing
9155 in a Storage_Size pragma or attribute definition clause is static.
9156
9157 @end table
9158
9159 @noindent
9160 The second set of implementation dependent restriction identifiers
9161 does not require partition-wide consistency.
9162 The restriction may be enforced for a single
9163 compilation unit without any effect on any of the
9164 other compilation units in the partition.
9165
9166 @table @code
9167
9168 @item No_Elaboration_Code
9169 @findex No_Elaboration_Code
9170 This restriction ensures at compile time that no elaboration code is
9171 generated. Note that this is not the same condition as is enforced
9172 by pragma @code{Preelaborate}. There are cases in which pragma
9173 @code{Preelaborate} still permits code to be generated (e.g.@: code
9174 to initialize a large array to all zeroes), and there are cases of units
9175 which do not meet the requirements for pragma @code{Preelaborate},
9176 but for which no elaboration code is generated. Generally, it is
9177 the case that preelaborable units will meet the restrictions, with
9178 the exception of large aggregates initialized with an others_clause,
9179 and exception declarations (which generate calls to a run-time
9180 registry procedure). This restriction is enforced on
9181 a unit by unit basis, it need not be obeyed consistently
9182 throughout a partition.
9183
9184 In the case of aggregates with others, if the aggregate has a dynamic
9185 size, there is no way to eliminate the elaboration code (such dynamic
9186 bounds would be incompatible with @code{Preelaborate} in any case). If
9187 the bounds are static, then use of this restriction actually modifies
9188 the code choice of the compiler to avoid generating a loop, and instead
9189 generate the aggregate statically if possible, no matter how many times
9190 the data for the others clause must be repeatedly generated.
9191
9192 It is not possible to precisely document
9193 the constructs which are compatible with this restriction, since,
9194 unlike most other restrictions, this is not a restriction on the
9195 source code, but a restriction on the generated object code. For
9196 example, if the source contains a declaration:
9197
9198 @smallexample
9199 Val : constant Integer := X;
9200 @end smallexample
9201
9202 @noindent
9203 where X is not a static constant, it may be possible, depending
9204 on complex optimization circuitry, for the compiler to figure
9205 out the value of X at compile time, in which case this initialization
9206 can be done by the loader, and requires no initialization code. It
9207 is not possible to document the precise conditions under which the
9208 optimizer can figure this out.
9209
9210 Note that this the implementation of this restriction requires full
9211 code generation. If it is used in conjunction with "semantics only"
9212 checking, then some cases of violations may be missed.
9213
9214 @item No_Entry_Queue
9215 @findex No_Entry_Queue
9216 This restriction is a declaration that any protected entry compiled in
9217 the scope of the restriction has at most one task waiting on the entry
9218 at any one time, and so no queue is required. This restriction is not
9219 checked at compile time. A program execution is erroneous if an attempt
9220 is made to queue a second task on such an entry.
9221
9222 @item No_Implementation_Attributes
9223 @findex No_Implementation_Attributes
9224 This restriction checks at compile time that no GNAT-defined attributes
9225 are present. With this restriction, the only attributes that can be used
9226 are those defined in the Ada Reference Manual.
9227
9228 @item No_Implementation_Pragmas
9229 @findex No_Implementation_Pragmas
9230 This restriction checks at compile time that no GNAT-defined pragmas
9231 are present. With this restriction, the only pragmas that can be used
9232 are those defined in the Ada Reference Manual.
9233
9234 @item No_Implementation_Restrictions
9235 @findex No_Implementation_Restrictions
9236 This restriction checks at compile time that no GNAT-defined restriction
9237 identifiers (other than @code{No_Implementation_Restrictions} itself)
9238 are present. With this restriction, the only other restriction identifiers
9239 that can be used are those defined in the Ada Reference Manual.
9240
9241 @item No_Wide_Characters
9242 @findex No_Wide_Characters
9243 This restriction ensures at compile time that no uses of the types
9244 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9245 wide types
9246 appear, and that no wide or wide wide string or character literals
9247 appear in the program (that is literals representing characters not in
9248 type @code{Character}.
9249
9250 @item SPARK
9251 @findex SPARK
9252 This restriction checks at compile time that some constructs forbidden in
9253 SPARK are not present. The SPARK version used as a reference is the same as
9254 the Ada mode for the unit, so a unit compiled in Ada 95 mode with SPARK
9255 restrictions will be checked for constructs forbidden in SPARK 95.
9256 Error messages related to SPARK restriction have the form:
9257
9258 @smallexample
9259 violation of restriction "Spark" at <file>
9260 <error message>
9261 @end smallexample
9262
9263 This is not a replacement for the semantic checks performed by the
9264 SPARK Examiner tool, as the compiler only deals currently with code,
9265 not at all with SPARK annotations and does not guarantee catching all
9266 cases of constructs forbidden by SPARK.
9267
9268 Thus it may well be the case that code which
9269 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
9270 e.g. due to the different visibility rules of the Examiner based on
9271 SPARK @code{inherit} annotations.
9272
9273 This restriction can be useful in providing an initial filter for
9274 code developed using SPARK, or in examining legacy code to see how far
9275 it is from meeting SPARK restrictions.
9276
9277 @end table
9278
9279 @sp 1
9280 @cartouche
9281 @noindent
9282 @strong{58}. The consequences of violating limitations on
9283 @code{Restrictions} pragmas. See 13.12(9).
9284 @end cartouche
9285 @noindent
9286 Restrictions that can be checked at compile time result in illegalities
9287 if violated. Currently there are no other consequences of violating
9288 restrictions.
9289
9290 @sp 1
9291 @cartouche
9292 @noindent
9293 @strong{59}. The representation used by the @code{Read} and
9294 @code{Write} attributes of elementary types in terms of stream
9295 elements. See 13.13.2(9).
9296 @end cartouche
9297 @noindent
9298 The representation is the in-memory representation of the base type of
9299 the type, using the number of bits corresponding to the
9300 @code{@var{type}'Size} value, and the natural ordering of the machine.
9301
9302 @sp 1
9303 @cartouche
9304 @noindent
9305 @strong{60}. The names and characteristics of the numeric subtypes
9306 declared in the visible part of package @code{Standard}. See A.1(3).
9307 @end cartouche
9308 @noindent
9309 See items describing the integer and floating-point types supported.
9310
9311 @sp 1
9312 @cartouche
9313 @noindent
9314 @strong{61}. The accuracy actually achieved by the elementary
9315 functions. See A.5.1(1).
9316 @end cartouche
9317 @noindent
9318 The elementary functions correspond to the functions available in the C
9319 library. Only fast math mode is implemented.
9320
9321 @sp 1
9322 @cartouche
9323 @noindent
9324 @strong{62}. The sign of a zero result from some of the operators or
9325 functions in @code{Numerics.Generic_Elementary_Functions}, when
9326 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9327 @end cartouche
9328 @noindent
9329 The sign of zeroes follows the requirements of the IEEE 754 standard on
9330 floating-point.
9331
9332 @sp 1
9333 @cartouche
9334 @noindent
9335 @strong{63}. The value of
9336 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9337 @end cartouche
9338 @noindent
9339 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9340
9341 @sp 1
9342 @cartouche
9343 @noindent
9344 @strong{64}. The value of
9345 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
9346 @end cartouche
9347 @noindent
9348 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9349
9350 @sp 1
9351 @cartouche
9352 @noindent
9353 @strong{65}. The algorithms for random number generation. See
9354 A.5.2(32).
9355 @end cartouche
9356 @noindent
9357 The algorithm is the Mersenne Twister, as documented in the source file
9358 @file{s-rannum.adb}. This version of the algorithm has a period of
9359 2**19937-1.
9360
9361 @sp 1
9362 @cartouche
9363 @noindent
9364 @strong{66}. The string representation of a random number generator's
9365 state. See A.5.2(38).
9366 @end cartouche
9367 @noindent
9368 The value returned by the Image function is the concatenation of
9369 the fixed-width decimal representations of the 624 32-bit integers
9370 of the state vector.
9371
9372 @sp 1
9373 @cartouche
9374 @noindent
9375 @strong{67}. The minimum time interval between calls to the
9376 time-dependent Reset procedure that are guaranteed to initiate different
9377 random number sequences. See A.5.2(45).
9378 @end cartouche
9379 @noindent
9380 The minimum period between reset calls to guarantee distinct series of
9381 random numbers is one microsecond.
9382
9383 @sp 1
9384 @cartouche
9385 @noindent
9386 @strong{68}. The values of the @code{Model_Mantissa},
9387 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9388 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9389 Annex is not supported. See A.5.3(72).
9390 @end cartouche
9391 @noindent
9392 Run the compiler with @option{-gnatS} to produce a listing of package
9393 @code{Standard}, has the values of all numeric attributes.
9394
9395 @sp 1
9396 @cartouche
9397 @noindent
9398 @strong{69}. Any implementation-defined characteristics of the
9399 input-output packages. See A.7(14).
9400 @end cartouche
9401 @noindent
9402 There are no special implementation defined characteristics for these
9403 packages.
9404
9405 @sp 1
9406 @cartouche
9407 @noindent
9408 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
9409 A.9(10).
9410 @end cartouche
9411 @noindent
9412 All type representations are contiguous, and the @code{Buffer_Size} is
9413 the value of @code{@var{type}'Size} rounded up to the next storage unit
9414 boundary.
9415
9416 @sp 1
9417 @cartouche
9418 @noindent
9419 @strong{71}. External files for standard input, standard output, and
9420 standard error See A.10(5).
9421 @end cartouche
9422 @noindent
9423 These files are mapped onto the files provided by the C streams
9424 libraries. See source file @file{i-cstrea.ads} for further details.
9425
9426 @sp 1
9427 @cartouche
9428 @noindent
9429 @strong{72}. The accuracy of the value produced by @code{Put}. See
9430 A.10.9(36).
9431 @end cartouche
9432 @noindent
9433 If more digits are requested in the output than are represented by the
9434 precision of the value, zeroes are output in the corresponding least
9435 significant digit positions.
9436
9437 @sp 1
9438 @cartouche
9439 @noindent
9440 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
9441 @code{Command_Name}. See A.15(1).
9442 @end cartouche
9443 @noindent
9444 These are mapped onto the @code{argv} and @code{argc} parameters of the
9445 main program in the natural manner.
9446
9447 @sp 1
9448 @cartouche
9449 @noindent
9450 @strong{74}. The interpretation of the @code{Form} parameter in procedure
9451 @code{Create_Directory}. See A.16(56).
9452 @end cartouche
9453 @noindent
9454 The @code{Form} parameter is not used.
9455
9456 @sp 1
9457 @cartouche
9458 @noindent
9459 @strong{75}. The interpretation of the @code{Form} parameter in procedure
9460 @code{Create_Path}. See A.16(60).
9461 @end cartouche
9462 @noindent
9463 The @code{Form} parameter is not used.
9464
9465 @sp 1
9466 @cartouche
9467 @noindent
9468 @strong{76}. The interpretation of the @code{Form} parameter in procedure
9469 @code{Copy_File}. See A.16(68).
9470 @end cartouche
9471 @noindent
9472 The @code{Form} parameter is case-insensitive.
9473
9474 Two fields are recognized in the @code{Form} parameter:
9475
9476 @table @code
9477
9478 @item preserve=<value>
9479
9480 @item mode=<value>
9481
9482 @end table
9483
9484 @noindent
9485 <value> starts immediately after the character '=' and ends with the
9486 character immediately preceding the next comma (',') or with the last
9487 character of the parameter.
9488
9489 The only possible values for preserve= are:
9490
9491 @table @code
9492
9493 @item no_attributes
9494 Do not try to preserve any file attributes. This is the default if no
9495 preserve= is found in Form.
9496
9497 @item all_attributes
9498 Try to preserve all file attributes (timestamps, access rights).
9499
9500 @item timestamps
9501 Preserve the timestamp of the copied file, but not the other file attributes.
9502
9503 @end table
9504
9505 @noindent
9506 The only possible values for mode= are:
9507
9508 @table @code
9509
9510 @item copy
9511 Only do the copy if the destination file does not already exist. If it already
9512 exists, Copy_File fails.
9513
9514 @item overwrite
9515 Copy the file in all cases. Overwrite an already existing destination file.
9516
9517 @item append
9518 Append the original file to the destination file. If the destination file does
9519 not exist, the destination file is a copy of the source file. When mode=append,
9520 the field preserve=, if it exists, is not taken into account.
9521
9522 @end table
9523
9524 @noindent
9525 If the Form parameter includes one or both of the fields and the value or
9526 values are incorrect, Copy_file fails with Use_Error.
9527
9528 Examples of correct Forms:
9529
9530 @smallexample
9531 Form => "preserve=no_attributes,mode=overwrite" (the default)
9532 Form => "mode=append"
9533 Form => "mode=copy, preserve=all_attributes"
9534 @end smallexample
9535
9536 @noindent
9537 Examples of incorrect Forms
9538
9539 @smallexample
9540 Form => "preserve=junk"
9541 Form => "mode=internal, preserve=timestamps"
9542 @end smallexample
9543
9544 @sp 1
9545 @cartouche
9546 @noindent
9547 @strong{77}. Implementation-defined convention names. See B.1(11).
9548 @end cartouche
9549 @noindent
9550 The following convention names are supported
9551
9552 @table @code
9553 @item Ada
9554 Ada
9555 @item Assembler
9556 Assembly language
9557 @item Asm
9558 Synonym for Assembler
9559 @item Assembly
9560 Synonym for Assembler
9561 @item C
9562 C
9563 @item C_Pass_By_Copy
9564 Allowed only for record types, like C, but also notes that record
9565 is to be passed by copy rather than reference.
9566 @item COBOL
9567 COBOL
9568 @item C_Plus_Plus (or CPP)
9569 C++
9570 @item Default
9571 Treated the same as C
9572 @item External
9573 Treated the same as C
9574 @item Fortran
9575 Fortran
9576 @item Intrinsic
9577 For support of pragma @code{Import} with convention Intrinsic, see
9578 separate section on Intrinsic Subprograms.
9579 @item Stdcall
9580 Stdcall (used for Windows implementations only). This convention correspond
9581 to the WINAPI (previously called Pascal convention) C/C++ convention under
9582 Windows. A function with this convention cleans the stack before exit.
9583 @item DLL
9584 Synonym for Stdcall
9585 @item Win32
9586 Synonym for Stdcall
9587 @item Stubbed
9588 Stubbed is a special convention used to indicate that the body of the
9589 subprogram will be entirely ignored. Any call to the subprogram
9590 is converted into a raise of the @code{Program_Error} exception. If a
9591 pragma @code{Import} specifies convention @code{stubbed} then no body need
9592 be present at all. This convention is useful during development for the
9593 inclusion of subprograms whose body has not yet been written.
9594
9595 @end table
9596 @noindent
9597 In addition, all otherwise unrecognized convention names are also
9598 treated as being synonymous with convention C@. In all implementations
9599 except for VMS, use of such other names results in a warning. In VMS
9600 implementations, these names are accepted silently.
9601
9602 @sp 1
9603 @cartouche
9604 @noindent
9605 @strong{78}. The meaning of link names. See B.1(36).
9606 @end cartouche
9607 @noindent
9608 Link names are the actual names used by the linker.
9609
9610 @sp 1
9611 @cartouche
9612 @noindent
9613 @strong{79}. The manner of choosing link names when neither the link
9614 name nor the address of an imported or exported entity is specified. See
9615 B.1(36).
9616 @end cartouche
9617 @noindent
9618 The default linker name is that which would be assigned by the relevant
9619 external language, interpreting the Ada name as being in all lower case
9620 letters.
9621
9622 @sp 1
9623 @cartouche
9624 @noindent
9625 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
9626 @end cartouche
9627 @noindent
9628 The string passed to @code{Linker_Options} is presented uninterpreted as
9629 an argument to the link command, unless it contains ASCII.NUL characters.
9630 NUL characters if they appear act as argument separators, so for example
9631
9632 @smallexample @c ada
9633 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9634 @end smallexample
9635
9636 @noindent
9637 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9638 linker. The order of linker options is preserved for a given unit. The final
9639 list of options passed to the linker is in reverse order of the elaboration
9640 order. For example, linker options for a body always appear before the options
9641 from the corresponding package spec.
9642
9643 @sp 1
9644 @cartouche
9645 @noindent
9646 @strong{81}. The contents of the visible part of package
9647 @code{Interfaces} and its language-defined descendants. See B.2(1).
9648 @end cartouche
9649 @noindent
9650 See files with prefix @file{i-} in the distributed library.
9651
9652 @sp 1
9653 @cartouche
9654 @noindent
9655 @strong{82}. Implementation-defined children of package
9656 @code{Interfaces}. The contents of the visible part of package
9657 @code{Interfaces}. See B.2(11).
9658 @end cartouche
9659 @noindent
9660 See files with prefix @file{i-} in the distributed library.
9661
9662 @sp 1
9663 @cartouche
9664 @noindent
9665 @strong{83}. The types @code{Floating}, @code{Long_Floating},
9666 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9667 @code{COBOL_Character}; and the initialization of the variables
9668 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9669 @code{Interfaces.COBOL}. See B.4(50).
9670 @end cartouche
9671 @noindent
9672 @table @code
9673 @item Floating
9674 Float
9675 @item Long_Floating
9676 (Floating) Long_Float
9677 @item Binary
9678 Integer
9679 @item Long_Binary
9680 Long_Long_Integer
9681 @item Decimal_Element
9682 Character
9683 @item COBOL_Character
9684 Character
9685 @end table
9686
9687 @noindent
9688 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9689
9690 @sp 1
9691 @cartouche
9692 @noindent
9693 @strong{84}. Support for access to machine instructions. See C.1(1).
9694 @end cartouche
9695 @noindent
9696 See documentation in file @file{s-maccod.ads} in the distributed library.
9697
9698 @sp 1
9699 @cartouche
9700 @noindent
9701 @strong{85}. Implementation-defined aspects of access to machine
9702 operations. See C.1(9).
9703 @end cartouche
9704 @noindent
9705 See documentation in file @file{s-maccod.ads} in the distributed library.
9706
9707 @sp 1
9708 @cartouche
9709 @noindent
9710 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
9711 @end cartouche
9712 @noindent
9713 Interrupts are mapped to signals or conditions as appropriate. See
9714 definition of unit
9715 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9716 on the interrupts supported on a particular target.
9717
9718 @sp 1
9719 @cartouche
9720 @noindent
9721 @strong{87}. Implementation-defined aspects of pre-elaboration. See
9722 C.4(13).
9723 @end cartouche
9724 @noindent
9725 GNAT does not permit a partition to be restarted without reloading,
9726 except under control of the debugger.
9727
9728 @sp 1
9729 @cartouche
9730 @noindent
9731 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
9732 @end cartouche
9733 @noindent
9734 Pragma @code{Discard_Names} causes names of enumeration literals to
9735 be suppressed. In the presence of this pragma, the Image attribute
9736 provides the image of the Pos of the literal, and Value accepts
9737 Pos values.
9738
9739 @sp 1
9740 @cartouche
9741 @noindent
9742 @strong{89}. The result of the @code{Task_Identification.Image}
9743 attribute. See C.7.1(7).
9744 @end cartouche
9745 @noindent
9746 The result of this attribute is a string that identifies
9747 the object or component that denotes a given task. If a variable @code{Var}
9748 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9749 where the suffix
9750 is the hexadecimal representation of the virtual address of the corresponding
9751 task control block. If the variable is an array of tasks, the image of each
9752 task will have the form of an indexed component indicating the position of a
9753 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9754 component of a record, the image of the task will have the form of a selected
9755 component. These rules are fully recursive, so that the image of a task that
9756 is a subcomponent of a composite object corresponds to the expression that
9757 designates this task.
9758 @noindent
9759 If a task is created by an allocator, its image depends on the context. If the
9760 allocator is part of an object declaration, the rules described above are used
9761 to construct its image, and this image is not affected by subsequent
9762 assignments. If the allocator appears within an expression, the image
9763 includes only the name of the task type.
9764 @noindent
9765 If the configuration pragma Discard_Names is present, or if the restriction
9766 No_Implicit_Heap_Allocation is in effect, the image reduces to
9767 the numeric suffix, that is to say the hexadecimal representation of the
9768 virtual address of the control block of the task.
9769 @sp 1
9770 @cartouche
9771 @noindent
9772 @strong{90}. The value of @code{Current_Task} when in a protected entry
9773 or interrupt handler. See C.7.1(17).
9774 @end cartouche
9775 @noindent
9776 Protected entries or interrupt handlers can be executed by any
9777 convenient thread, so the value of @code{Current_Task} is undefined.
9778
9779 @sp 1
9780 @cartouche
9781 @noindent
9782 @strong{91}. The effect of calling @code{Current_Task} from an entry
9783 body or interrupt handler. See C.7.1(19).
9784 @end cartouche
9785 @noindent
9786 The effect of calling @code{Current_Task} from an entry body or
9787 interrupt handler is to return the identification of the task currently
9788 executing the code.
9789
9790 @sp 1
9791 @cartouche
9792 @noindent
9793 @strong{92}. Implementation-defined aspects of
9794 @code{Task_Attributes}. See C.7.2(19).
9795 @end cartouche
9796 @noindent
9797 There are no implementation-defined aspects of @code{Task_Attributes}.
9798
9799 @sp 1
9800 @cartouche
9801 @noindent
9802 @strong{93}. Values of all @code{Metrics}. See D(2).
9803 @end cartouche
9804 @noindent
9805 The metrics information for GNAT depends on the performance of the
9806 underlying operating system. The sources of the run-time for tasking
9807 implementation, together with the output from @option{-gnatG} can be
9808 used to determine the exact sequence of operating systems calls made
9809 to implement various tasking constructs. Together with appropriate
9810 information on the performance of the underlying operating system,
9811 on the exact target in use, this information can be used to determine
9812 the required metrics.
9813
9814 @sp 1
9815 @cartouche
9816 @noindent
9817 @strong{94}. The declarations of @code{Any_Priority} and
9818 @code{Priority}. See D.1(11).
9819 @end cartouche
9820 @noindent
9821 See declarations in file @file{system.ads}.
9822
9823 @sp 1
9824 @cartouche
9825 @noindent
9826 @strong{95}. Implementation-defined execution resources. See D.1(15).
9827 @end cartouche
9828 @noindent
9829 There are no implementation-defined execution resources.
9830
9831 @sp 1
9832 @cartouche
9833 @noindent
9834 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
9835 access to a protected object keeps its processor busy. See D.2.1(3).
9836 @end cartouche
9837 @noindent
9838 On a multi-processor, a task that is waiting for access to a protected
9839 object does not keep its processor busy.
9840
9841 @sp 1
9842 @cartouche
9843 @noindent
9844 @strong{97}. The affect of implementation defined execution resources
9845 on task dispatching. See D.2.1(9).
9846 @end cartouche
9847 @noindent
9848 @c SGI info
9849 @ignore
9850 Tasks map to IRIX threads, and the dispatching policy is as defined by
9851 the IRIX implementation of threads.
9852 @end ignore
9853 Tasks map to threads in the threads package used by GNAT@. Where possible
9854 and appropriate, these threads correspond to native threads of the
9855 underlying operating system.
9856
9857 @sp 1
9858 @cartouche
9859 @noindent
9860 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
9861 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
9862 @end cartouche
9863 @noindent
9864 There are no implementation-defined policy-identifiers allowed in this
9865 pragma.
9866
9867 @sp 1
9868 @cartouche
9869 @noindent
9870 @strong{99}. Implementation-defined aspects of priority inversion. See
9871 D.2.2(16).
9872 @end cartouche
9873 @noindent
9874 Execution of a task cannot be preempted by the implementation processing
9875 of delay expirations for lower priority tasks.
9876
9877 @sp 1
9878 @cartouche
9879 @noindent
9880 @strong{100}. Implementation defined task dispatching. See D.2.2(18).
9881 @end cartouche
9882 @noindent
9883 @c SGI info:
9884 @ignore
9885 Tasks map to IRIX threads, and the dispatching policy is as defined by
9886 the IRIX implementation of threads.
9887 @end ignore
9888 The policy is the same as that of the underlying threads implementation.
9889
9890 @sp 1
9891 @cartouche
9892 @noindent
9893 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
9894 in a pragma @code{Locking_Policy}. See D.3(4).
9895 @end cartouche
9896 @noindent
9897 The only implementation defined policy permitted in GNAT is
9898 @code{Inheritance_Locking}. On targets that support this policy, locking
9899 is implemented by inheritance, i.e.@: the task owning the lock operates
9900 at a priority equal to the highest priority of any task currently
9901 requesting the lock.
9902
9903 @sp 1
9904 @cartouche
9905 @noindent
9906 @strong{102}. Default ceiling priorities. See D.3(10).
9907 @end cartouche
9908 @noindent
9909 The ceiling priority of protected objects of the type
9910 @code{System.Interrupt_Priority'Last} as described in the Ada
9911 Reference Manual D.3(10),
9912
9913 @sp 1
9914 @cartouche
9915 @noindent
9916 @strong{103}. The ceiling of any protected object used internally by
9917 the implementation. See D.3(16).
9918 @end cartouche
9919 @noindent
9920 The ceiling priority of internal protected objects is
9921 @code{System.Priority'Last}.
9922
9923 @sp 1
9924 @cartouche
9925 @noindent
9926 @strong{104}. Implementation-defined queuing policies. See D.4(1).
9927 @end cartouche
9928 @noindent
9929 There are no implementation-defined queuing policies.
9930
9931 @sp 1
9932 @cartouche
9933 @noindent
9934 @strong{105}. On a multiprocessor, any conditions that cause the
9935 completion of an aborted construct to be delayed later than what is
9936 specified for a single processor. See D.6(3).
9937 @end cartouche
9938 @noindent
9939 The semantics for abort on a multi-processor is the same as on a single
9940 processor, there are no further delays.
9941
9942 @sp 1
9943 @cartouche
9944 @noindent
9945 @strong{106}. Any operations that implicitly require heap storage
9946 allocation. See D.7(8).
9947 @end cartouche
9948 @noindent
9949 The only operation that implicitly requires heap storage allocation is
9950 task creation.
9951
9952 @sp 1
9953 @cartouche
9954 @noindent
9955 @strong{107}. Implementation-defined aspects of pragma
9956 @code{Restrictions}. See D.7(20).
9957 @end cartouche
9958 @noindent
9959 There are no such implementation-defined aspects.
9960
9961 @sp 1
9962 @cartouche
9963 @noindent
9964 @strong{108}. Implementation-defined aspects of package
9965 @code{Real_Time}. See D.8(17).
9966 @end cartouche
9967 @noindent
9968 There are no implementation defined aspects of package @code{Real_Time}.
9969
9970 @sp 1
9971 @cartouche
9972 @noindent
9973 @strong{109}. Implementation-defined aspects of
9974 @code{delay_statements}. See D.9(8).
9975 @end cartouche
9976 @noindent
9977 Any difference greater than one microsecond will cause the task to be
9978 delayed (see D.9(7)).
9979
9980 @sp 1
9981 @cartouche
9982 @noindent
9983 @strong{110}. The upper bound on the duration of interrupt blocking
9984 caused by the implementation. See D.12(5).
9985 @end cartouche
9986 @noindent
9987 The upper bound is determined by the underlying operating system. In
9988 no cases is it more than 10 milliseconds.
9989
9990 @sp 1
9991 @cartouche
9992 @noindent
9993 @strong{111}. The means for creating and executing distributed
9994 programs. See E(5).
9995 @end cartouche
9996 @noindent
9997 The GLADE package provides a utility GNATDIST for creating and executing
9998 distributed programs. See the GLADE reference manual for further details.
9999
10000 @sp 1
10001 @cartouche
10002 @noindent
10003 @strong{112}. Any events that can result in a partition becoming
10004 inaccessible. See E.1(7).
10005 @end cartouche
10006 @noindent
10007 See the GLADE reference manual for full details on such events.
10008
10009 @sp 1
10010 @cartouche
10011 @noindent
10012 @strong{113}. The scheduling policies, treatment of priorities, and
10013 management of shared resources between partitions in certain cases. See
10014 E.1(11).
10015 @end cartouche
10016 @noindent
10017 See the GLADE reference manual for full details on these aspects of
10018 multi-partition execution.
10019
10020 @sp 1
10021 @cartouche
10022 @noindent
10023 @strong{114}. Events that cause the version of a compilation unit to
10024 change. See E.3(5).
10025 @end cartouche
10026 @noindent
10027 Editing the source file of a compilation unit, or the source files of
10028 any units on which it is dependent in a significant way cause the version
10029 to change. No other actions cause the version number to change. All changes
10030 are significant except those which affect only layout, capitalization or
10031 comments.
10032
10033 @sp 1
10034 @cartouche
10035 @noindent
10036 @strong{115}. Whether the execution of the remote subprogram is
10037 immediately aborted as a result of cancellation. See E.4(13).
10038 @end cartouche
10039 @noindent
10040 See the GLADE reference manual for details on the effect of abort in
10041 a distributed application.
10042
10043 @sp 1
10044 @cartouche
10045 @noindent
10046 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10047 @end cartouche
10048 @noindent
10049 See the GLADE reference manual for a full description of all implementation
10050 defined aspects of the PCS@.
10051
10052 @sp 1
10053 @cartouche
10054 @noindent
10055 @strong{117}. Implementation-defined interfaces in the PCS@. See
10056 E.5(26).
10057 @end cartouche
10058 @noindent
10059 See the GLADE reference manual for a full description of all
10060 implementation defined interfaces.
10061
10062 @sp 1
10063 @cartouche
10064 @noindent
10065 @strong{118}. The values of named numbers in the package
10066 @code{Decimal}. See F.2(7).
10067 @end cartouche
10068 @noindent
10069 @table @code
10070 @item Max_Scale
10071 +18
10072 @item Min_Scale
10073 -18
10074 @item Min_Delta
10075 1.0E-18
10076 @item Max_Delta
10077 1.0E+18
10078 @item Max_Decimal_Digits
10079 18
10080 @end table
10081
10082 @sp 1
10083 @cartouche
10084 @noindent
10085 @strong{119}. The value of @code{Max_Picture_Length} in the package
10086 @code{Text_IO.Editing}. See F.3.3(16).
10087 @end cartouche
10088 @noindent
10089 64
10090
10091 @sp 1
10092 @cartouche
10093 @noindent
10094 @strong{120}. The value of @code{Max_Picture_Length} in the package
10095 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10096 @end cartouche
10097 @noindent
10098 64
10099
10100 @sp 1
10101 @cartouche
10102 @noindent
10103 @strong{121}. The accuracy actually achieved by the complex elementary
10104 functions and by other complex arithmetic operations. See G.1(1).
10105 @end cartouche
10106 @noindent
10107 Standard library functions are used for the complex arithmetic
10108 operations. Only fast math mode is currently supported.
10109
10110 @sp 1
10111 @cartouche
10112 @noindent
10113 @strong{122}. The sign of a zero result (or a component thereof) from
10114 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10115 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10116 @end cartouche
10117 @noindent
10118 The signs of zero values are as recommended by the relevant
10119 implementation advice.
10120
10121 @sp 1
10122 @cartouche
10123 @noindent
10124 @strong{123}. The sign of a zero result (or a component thereof) from
10125 any operator or function in
10126 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10127 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10128 @end cartouche
10129 @noindent
10130 The signs of zero values are as recommended by the relevant
10131 implementation advice.
10132
10133 @sp 1
10134 @cartouche
10135 @noindent
10136 @strong{124}. Whether the strict mode or the relaxed mode is the
10137 default. See G.2(2).
10138 @end cartouche
10139 @noindent
10140 The strict mode is the default. There is no separate relaxed mode. GNAT
10141 provides a highly efficient implementation of strict mode.
10142
10143 @sp 1
10144 @cartouche
10145 @noindent
10146 @strong{125}. The result interval in certain cases of fixed-to-float
10147 conversion. See G.2.1(10).
10148 @end cartouche
10149 @noindent
10150 For cases where the result interval is implementation dependent, the
10151 accuracy is that provided by performing all operations in 64-bit IEEE
10152 floating-point format.
10153
10154 @sp 1
10155 @cartouche
10156 @noindent
10157 @strong{126}. The result of a floating point arithmetic operation in
10158 overflow situations, when the @code{Machine_Overflows} attribute of the
10159 result type is @code{False}. See G.2.1(13).
10160 @end cartouche
10161 @noindent
10162 Infinite and NaN values are produced as dictated by the IEEE
10163 floating-point standard.
10164
10165 Note that on machines that are not fully compliant with the IEEE
10166 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10167 must be used for achieving IEEE confirming behavior (although at the cost
10168 of a significant performance penalty), so infinite and NaN values are
10169 properly generated.
10170
10171 @sp 1
10172 @cartouche
10173 @noindent
10174 @strong{127}. The result interval for division (or exponentiation by a
10175 negative exponent), when the floating point hardware implements division
10176 as multiplication by a reciprocal. See G.2.1(16).
10177 @end cartouche
10178 @noindent
10179 Not relevant, division is IEEE exact.
10180
10181 @sp 1
10182 @cartouche
10183 @noindent
10184 @strong{128}. The definition of close result set, which determines the
10185 accuracy of certain fixed point multiplications and divisions. See
10186 G.2.3(5).
10187 @end cartouche
10188 @noindent
10189 Operations in the close result set are performed using IEEE long format
10190 floating-point arithmetic. The input operands are converted to
10191 floating-point, the operation is done in floating-point, and the result
10192 is converted to the target type.
10193
10194 @sp 1
10195 @cartouche
10196 @noindent
10197 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10198 point multiplication or division for which the result shall be in the
10199 perfect result set. See G.2.3(22).
10200 @end cartouche
10201 @noindent
10202 The result is only defined to be in the perfect result set if the result
10203 can be computed by a single scaling operation involving a scale factor
10204 representable in 64-bits.
10205
10206 @sp 1
10207 @cartouche
10208 @noindent
10209 @strong{130}. The result of a fixed point arithmetic operation in
10210 overflow situations, when the @code{Machine_Overflows} attribute of the
10211 result type is @code{False}. See G.2.3(27).
10212 @end cartouche
10213 @noindent
10214 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10215 types.
10216
10217 @sp 1
10218 @cartouche
10219 @noindent
10220 @strong{131}. The result of an elementary function reference in
10221 overflow situations, when the @code{Machine_Overflows} attribute of the
10222 result type is @code{False}. See G.2.4(4).
10223 @end cartouche
10224 @noindent
10225 IEEE infinite and Nan values are produced as appropriate.
10226
10227 @sp 1
10228 @cartouche
10229 @noindent
10230 @strong{132}. The value of the angle threshold, within which certain
10231 elementary functions, complex arithmetic operations, and complex
10232 elementary functions yield results conforming to a maximum relative
10233 error bound. See G.2.4(10).
10234 @end cartouche
10235 @noindent
10236 Information on this subject is not yet available.
10237
10238 @sp 1
10239 @cartouche
10240 @noindent
10241 @strong{133}. The accuracy of certain elementary functions for
10242 parameters beyond the angle threshold. See G.2.4(10).
10243 @end cartouche
10244 @noindent
10245 Information on this subject is not yet available.
10246
10247 @sp 1
10248 @cartouche
10249 @noindent
10250 @strong{134}. The result of a complex arithmetic operation or complex
10251 elementary function reference in overflow situations, when the
10252 @code{Machine_Overflows} attribute of the corresponding real type is
10253 @code{False}. See G.2.6(5).
10254 @end cartouche
10255 @noindent
10256 IEEE infinite and Nan values are produced as appropriate.
10257
10258 @sp 1
10259 @cartouche
10260 @noindent
10261 @strong{135}. The accuracy of certain complex arithmetic operations and
10262 certain complex elementary functions for parameters (or components
10263 thereof) beyond the angle threshold. See G.2.6(8).
10264 @end cartouche
10265 @noindent
10266 Information on those subjects is not yet available.
10267
10268 @sp 1
10269 @cartouche
10270 @noindent
10271 @strong{136}. Information regarding bounded errors and erroneous
10272 execution. See H.2(1).
10273 @end cartouche
10274 @noindent
10275 Information on this subject is not yet available.
10276
10277 @sp 1
10278 @cartouche
10279 @noindent
10280 @strong{137}. Implementation-defined aspects of pragma
10281 @code{Inspection_Point}. See H.3.2(8).
10282 @end cartouche
10283 @noindent
10284 Pragma @code{Inspection_Point} ensures that the variable is live and can
10285 be examined by the debugger at the inspection point.
10286
10287 @sp 1
10288 @cartouche
10289 @noindent
10290 @strong{138}. Implementation-defined aspects of pragma
10291 @code{Restrictions}. See H.4(25).
10292 @end cartouche
10293 @noindent
10294 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10295 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10296 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10297
10298 @sp 1
10299 @cartouche
10300 @noindent
10301 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10302 H.4(27).
10303 @end cartouche
10304 @noindent
10305 There are no restrictions on pragma @code{Restrictions}.
10306
10307 @node Intrinsic Subprograms
10308 @chapter Intrinsic Subprograms
10309 @cindex Intrinsic Subprograms
10310
10311 @menu
10312 * Intrinsic Operators::
10313 * Enclosing_Entity::
10314 * Exception_Information::
10315 * Exception_Message::
10316 * Exception_Name::
10317 * File::
10318 * Line::
10319 * Rotate_Left::
10320 * Rotate_Right::
10321 * Shift_Left::
10322 * Shift_Right::
10323 * Shift_Right_Arithmetic::
10324 * Source_Location::
10325 @end menu
10326
10327 @noindent
10328 GNAT allows a user application program to write the declaration:
10329
10330 @smallexample @c ada
10331 pragma Import (Intrinsic, name);
10332 @end smallexample
10333
10334 @noindent
10335 providing that the name corresponds to one of the implemented intrinsic
10336 subprograms in GNAT, and that the parameter profile of the referenced
10337 subprogram meets the requirements. This chapter describes the set of
10338 implemented intrinsic subprograms, and the requirements on parameter profiles.
10339 Note that no body is supplied; as with other uses of pragma Import, the
10340 body is supplied elsewhere (in this case by the compiler itself). Note
10341 that any use of this feature is potentially non-portable, since the
10342 Ada standard does not require Ada compilers to implement this feature.
10343
10344 @node Intrinsic Operators
10345 @section Intrinsic Operators
10346 @cindex Intrinsic operator
10347
10348 @noindent
10349 All the predefined numeric operators in package Standard
10350 in @code{pragma Import (Intrinsic,..)}
10351 declarations. In the binary operator case, the operands must have the same
10352 size. The operand or operands must also be appropriate for
10353 the operator. For example, for addition, the operands must
10354 both be floating-point or both be fixed-point, and the
10355 right operand for @code{"**"} must have a root type of
10356 @code{Standard.Integer'Base}.
10357 You can use an intrinsic operator declaration as in the following example:
10358
10359 @smallexample @c ada
10360 type Int1 is new Integer;
10361 type Int2 is new Integer;
10362
10363 function "+" (X1 : Int1; X2 : Int2) return Int1;
10364 function "+" (X1 : Int1; X2 : Int2) return Int2;
10365 pragma Import (Intrinsic, "+");
10366 @end smallexample
10367
10368 @noindent
10369 This declaration would permit ``mixed mode'' arithmetic on items
10370 of the differing types @code{Int1} and @code{Int2}.
10371 It is also possible to specify such operators for private types, if the
10372 full views are appropriate arithmetic types.
10373
10374 @node Enclosing_Entity
10375 @section Enclosing_Entity
10376 @cindex Enclosing_Entity
10377 @noindent
10378 This intrinsic subprogram is used in the implementation of the
10379 library routine @code{GNAT.Source_Info}. The only useful use of the
10380 intrinsic import in this case is the one in this unit, so an
10381 application program should simply call the function
10382 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10383 the current subprogram, package, task, entry, or protected subprogram.
10384
10385 @node Exception_Information
10386 @section Exception_Information
10387 @cindex Exception_Information'
10388 @noindent
10389 This intrinsic subprogram is used in the implementation of the
10390 library routine @code{GNAT.Current_Exception}. The only useful
10391 use of the intrinsic import in this case is the one in this unit,
10392 so an application program should simply call the function
10393 @code{GNAT.Current_Exception.Exception_Information} to obtain
10394 the exception information associated with the current exception.
10395
10396 @node Exception_Message
10397 @section Exception_Message
10398 @cindex Exception_Message
10399 @noindent
10400 This intrinsic subprogram is used in the implementation of the
10401 library routine @code{GNAT.Current_Exception}. The only useful
10402 use of the intrinsic import in this case is the one in this unit,
10403 so an application program should simply call the function
10404 @code{GNAT.Current_Exception.Exception_Message} to obtain
10405 the message associated with the current exception.
10406
10407 @node Exception_Name
10408 @section Exception_Name
10409 @cindex Exception_Name
10410 @noindent
10411 This intrinsic subprogram is used in the implementation of the
10412 library routine @code{GNAT.Current_Exception}. The only useful
10413 use of the intrinsic import in this case is the one in this unit,
10414 so an application program should simply call the function
10415 @code{GNAT.Current_Exception.Exception_Name} to obtain
10416 the name of the current exception.
10417
10418 @node File
10419 @section File
10420 @cindex File
10421 @noindent
10422 This intrinsic subprogram is used in the implementation of the
10423 library routine @code{GNAT.Source_Info}. The only useful use of the
10424 intrinsic import in this case is the one in this unit, so an
10425 application program should simply call the function
10426 @code{GNAT.Source_Info.File} to obtain the name of the current
10427 file.
10428
10429 @node Line
10430 @section Line
10431 @cindex Line
10432 @noindent
10433 This intrinsic subprogram is used in the implementation of the
10434 library routine @code{GNAT.Source_Info}. The only useful use of the
10435 intrinsic import in this case is the one in this unit, so an
10436 application program should simply call the function
10437 @code{GNAT.Source_Info.Line} to obtain the number of the current
10438 source line.
10439
10440 @node Rotate_Left
10441 @section Rotate_Left
10442 @cindex Rotate_Left
10443 @noindent
10444 In standard Ada, the @code{Rotate_Left} function is available only
10445 for the predefined modular types in package @code{Interfaces}. However, in
10446 GNAT it is possible to define a Rotate_Left function for a user
10447 defined modular type or any signed integer type as in this example:
10448
10449 @smallexample @c ada
10450 function Shift_Left
10451 (Value : My_Modular_Type;
10452 Amount : Natural)
10453 return My_Modular_Type;
10454 @end smallexample
10455
10456 @noindent
10457 The requirements are that the profile be exactly as in the example
10458 above. The only modifications allowed are in the formal parameter
10459 names, and in the type of @code{Value} and the return type, which
10460 must be the same, and must be either a signed integer type, or
10461 a modular integer type with a binary modulus, and the size must
10462 be 8. 16, 32 or 64 bits.
10463
10464 @node Rotate_Right
10465 @section Rotate_Right
10466 @cindex Rotate_Right
10467 @noindent
10468 A @code{Rotate_Right} function can be defined for any user defined
10469 binary modular integer type, or signed integer type, as described
10470 above for @code{Rotate_Left}.
10471
10472 @node Shift_Left
10473 @section Shift_Left
10474 @cindex Shift_Left
10475 @noindent
10476 A @code{Shift_Left} function can be defined for any user defined
10477 binary modular integer type, or signed integer type, as described
10478 above for @code{Rotate_Left}.
10479
10480 @node Shift_Right
10481 @section Shift_Right
10482 @cindex Shift_Right
10483 @noindent
10484 A @code{Shift_Right} function can be defined for any user defined
10485 binary modular integer type, or signed integer type, as described
10486 above for @code{Rotate_Left}.
10487
10488 @node Shift_Right_Arithmetic
10489 @section Shift_Right_Arithmetic
10490 @cindex Shift_Right_Arithmetic
10491 @noindent
10492 A @code{Shift_Right_Arithmetic} function can be defined for any user
10493 defined binary modular integer type, or signed integer type, as described
10494 above for @code{Rotate_Left}.
10495
10496 @node Source_Location
10497 @section Source_Location
10498 @cindex Source_Location
10499 @noindent
10500 This intrinsic subprogram is used in the implementation of the
10501 library routine @code{GNAT.Source_Info}. The only useful use of the
10502 intrinsic import in this case is the one in this unit, so an
10503 application program should simply call the function
10504 @code{GNAT.Source_Info.Source_Location} to obtain the current
10505 source file location.
10506
10507 @node Representation Clauses and Pragmas
10508 @chapter Representation Clauses and Pragmas
10509 @cindex Representation Clauses
10510
10511 @menu
10512 * Alignment Clauses::
10513 * Size Clauses::
10514 * Storage_Size Clauses::
10515 * Size of Variant Record Objects::
10516 * Biased Representation ::
10517 * Value_Size and Object_Size Clauses::
10518 * Component_Size Clauses::
10519 * Bit_Order Clauses::
10520 * Effect of Bit_Order on Byte Ordering::
10521 * Pragma Pack for Arrays::
10522 * Pragma Pack for Records::
10523 * Record Representation Clauses::
10524 * Enumeration Clauses::
10525 * Address Clauses::
10526 * Effect of Convention on Representation::
10527 * Determining the Representations chosen by GNAT::
10528 @end menu
10529
10530 @noindent
10531 @cindex Representation Clause
10532 @cindex Representation Pragma
10533 @cindex Pragma, representation
10534 This section describes the representation clauses accepted by GNAT, and
10535 their effect on the representation of corresponding data objects.
10536
10537 GNAT fully implements Annex C (Systems Programming). This means that all
10538 the implementation advice sections in chapter 13 are fully implemented.
10539 However, these sections only require a minimal level of support for
10540 representation clauses. GNAT provides much more extensive capabilities,
10541 and this section describes the additional capabilities provided.
10542
10543 @node Alignment Clauses
10544 @section Alignment Clauses
10545 @cindex Alignment Clause
10546
10547 @noindent
10548 GNAT requires that all alignment clauses specify a power of 2, and all
10549 default alignments are always a power of 2. The default alignment
10550 values are as follows:
10551
10552 @itemize @bullet
10553 @item @emph{Primitive Types}.
10554 For primitive types, the alignment is the minimum of the actual size of
10555 objects of the type divided by @code{Storage_Unit},
10556 and the maximum alignment supported by the target.
10557 (This maximum alignment is given by the GNAT-specific attribute
10558 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10559 @cindex @code{Maximum_Alignment} attribute
10560 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10561 default alignment will be 8 on any target that supports alignments
10562 this large, but on some targets, the maximum alignment may be smaller
10563 than 8, in which case objects of type @code{Long_Float} will be maximally
10564 aligned.
10565
10566 @item @emph{Arrays}.
10567 For arrays, the alignment is equal to the alignment of the component type
10568 for the normal case where no packing or component size is given. If the
10569 array is packed, and the packing is effective (see separate section on
10570 packed arrays), then the alignment will be one for long packed arrays,
10571 or arrays whose length is not known at compile time. For short packed
10572 arrays, which are handled internally as modular types, the alignment
10573 will be as described for primitive types, e.g.@: a packed array of length
10574 31 bits will have an object size of four bytes, and an alignment of 4.
10575
10576 @item @emph{Records}.
10577 For the normal non-packed case, the alignment of a record is equal to
10578 the maximum alignment of any of its components. For tagged records, this
10579 includes the implicit access type used for the tag. If a pragma @code{Pack}
10580 is used and all components are packable (see separate section on pragma
10581 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10582 record makes it profitable to increase it.
10583
10584 A special case is when:
10585 @itemize @bullet
10586 @item
10587 the size of the record is given explicitly, or a
10588 full record representation clause is given, and
10589 @item
10590 the size of the record is 2, 4, or 8 bytes.
10591 @end itemize
10592 @noindent
10593 In this case, an alignment is chosen to match the
10594 size of the record. For example, if we have:
10595
10596 @smallexample @c ada
10597 type Small is record
10598 A, B : Character;
10599 end record;
10600 for Small'Size use 16;
10601 @end smallexample
10602
10603 @noindent
10604 then the default alignment of the record type @code{Small} is 2, not 1. This
10605 leads to more efficient code when the record is treated as a unit, and also
10606 allows the type to specified as @code{Atomic} on architectures requiring
10607 strict alignment.
10608
10609 @end itemize
10610
10611 @noindent
10612 An alignment clause may specify a larger alignment than the default value
10613 up to some maximum value dependent on the target (obtainable by using the
10614 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10615 a smaller alignment than the default value for enumeration, integer and
10616 fixed point types, as well as for record types, for example
10617
10618 @smallexample @c ada
10619 type V is record
10620 A : Integer;
10621 end record;
10622
10623 for V'alignment use 1;
10624 @end smallexample
10625
10626 @noindent
10627 @cindex Alignment, default
10628 The default alignment for the type @code{V} is 4, as a result of the
10629 Integer field in the record, but it is permissible, as shown, to
10630 override the default alignment of the record with a smaller value.
10631
10632 @node Size Clauses
10633 @section Size Clauses
10634 @cindex Size Clause
10635
10636 @noindent
10637 The default size for a type @code{T} is obtainable through the
10638 language-defined attribute @code{T'Size} and also through the
10639 equivalent GNAT-defined attribute @code{T'Value_Size}.
10640 For objects of type @code{T}, GNAT will generally increase the type size
10641 so that the object size (obtainable through the GNAT-defined attribute
10642 @code{T'Object_Size})
10643 is a multiple of @code{T'Alignment * Storage_Unit}.
10644 For example
10645
10646 @smallexample @c ada
10647 type Smallint is range 1 .. 6;
10648
10649 type Rec is record
10650 Y1 : integer;
10651 Y2 : boolean;
10652 end record;
10653 @end smallexample
10654
10655 @noindent
10656 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10657 as specified by the RM rules,
10658 but objects of this type will have a size of 8
10659 (@code{Smallint'Object_Size} = 8),
10660 since objects by default occupy an integral number
10661 of storage units. On some targets, notably older
10662 versions of the Digital Alpha, the size of stand
10663 alone objects of this type may be 32, reflecting
10664 the inability of the hardware to do byte load/stores.
10665
10666 Similarly, the size of type @code{Rec} is 40 bits
10667 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10668 the alignment is 4, so objects of this type will have
10669 their size increased to 64 bits so that it is a multiple
10670 of the alignment (in bits). This decision is
10671 in accordance with the specific Implementation Advice in RM 13.3(43):
10672
10673 @quotation
10674 A @code{Size} clause should be supported for an object if the specified
10675 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10676 to a size in storage elements that is a multiple of the object's
10677 @code{Alignment} (if the @code{Alignment} is nonzero).
10678 @end quotation
10679
10680 @noindent
10681 An explicit size clause may be used to override the default size by
10682 increasing it. For example, if we have:
10683
10684 @smallexample @c ada
10685 type My_Boolean is new Boolean;
10686 for My_Boolean'Size use 32;
10687 @end smallexample
10688
10689 @noindent
10690 then values of this type will always be 32 bits long. In the case of
10691 discrete types, the size can be increased up to 64 bits, with the effect
10692 that the entire specified field is used to hold the value, sign- or
10693 zero-extended as appropriate. If more than 64 bits is specified, then
10694 padding space is allocated after the value, and a warning is issued that
10695 there are unused bits.
10696
10697 Similarly the size of records and arrays may be increased, and the effect
10698 is to add padding bits after the value. This also causes a warning message
10699 to be generated.
10700
10701 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
10702 Size in bits, this corresponds to an object of size 256 megabytes (minus
10703 one). This limitation is true on all targets. The reason for this
10704 limitation is that it improves the quality of the code in many cases
10705 if it is known that a Size value can be accommodated in an object of
10706 type Integer.
10707
10708 @node Storage_Size Clauses
10709 @section Storage_Size Clauses
10710 @cindex Storage_Size Clause
10711
10712 @noindent
10713 For tasks, the @code{Storage_Size} clause specifies the amount of space
10714 to be allocated for the task stack. This cannot be extended, and if the
10715 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10716 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
10717 or a @code{Storage_Size} pragma in the task definition to set the
10718 appropriate required size. A useful technique is to include in every
10719 task definition a pragma of the form:
10720
10721 @smallexample @c ada
10722 pragma Storage_Size (Default_Stack_Size);
10723 @end smallexample
10724
10725 @noindent
10726 Then @code{Default_Stack_Size} can be defined in a global package, and
10727 modified as required. Any tasks requiring stack sizes different from the
10728 default can have an appropriate alternative reference in the pragma.
10729
10730 You can also use the @option{-d} binder switch to modify the default stack
10731 size.
10732
10733 For access types, the @code{Storage_Size} clause specifies the maximum
10734 space available for allocation of objects of the type. If this space is
10735 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10736 In the case where the access type is declared local to a subprogram, the
10737 use of a @code{Storage_Size} clause triggers automatic use of a special
10738 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10739 space for the pool is automatically reclaimed on exit from the scope in
10740 which the type is declared.
10741
10742 A special case recognized by the compiler is the specification of a
10743 @code{Storage_Size} of zero for an access type. This means that no
10744 items can be allocated from the pool, and this is recognized at compile
10745 time, and all the overhead normally associated with maintaining a fixed
10746 size storage pool is eliminated. Consider the following example:
10747
10748 @smallexample @c ada
10749 procedure p is
10750 type R is array (Natural) of Character;
10751 type P is access all R;
10752 for P'Storage_Size use 0;
10753 -- Above access type intended only for interfacing purposes
10754
10755 y : P;
10756
10757 procedure g (m : P);
10758 pragma Import (C, g);
10759
10760 -- @dots{}
10761
10762 begin
10763 -- @dots{}
10764 y := new R;
10765 end;
10766 @end smallexample
10767
10768 @noindent
10769 As indicated in this example, these dummy storage pools are often useful in
10770 connection with interfacing where no object will ever be allocated. If you
10771 compile the above example, you get the warning:
10772
10773 @smallexample
10774 p.adb:16:09: warning: allocation from empty storage pool
10775 p.adb:16:09: warning: Storage_Error will be raised at run time
10776 @end smallexample
10777
10778 @noindent
10779 Of course in practice, there will not be any explicit allocators in the
10780 case of such an access declaration.
10781
10782 @node Size of Variant Record Objects
10783 @section Size of Variant Record Objects
10784 @cindex Size, variant record objects
10785 @cindex Variant record objects, size
10786
10787 @noindent
10788 In the case of variant record objects, there is a question whether Size gives
10789 information about a particular variant, or the maximum size required
10790 for any variant. Consider the following program
10791
10792 @smallexample @c ada
10793 with Text_IO; use Text_IO;
10794 procedure q is
10795 type R1 (A : Boolean := False) is record
10796 case A is
10797 when True => X : Character;
10798 when False => null;
10799 end case;
10800 end record;
10801
10802 V1 : R1 (False);
10803 V2 : R1;
10804
10805 begin
10806 Put_Line (Integer'Image (V1'Size));
10807 Put_Line (Integer'Image (V2'Size));
10808 end q;
10809 @end smallexample
10810
10811 @noindent
10812 Here we are dealing with a variant record, where the True variant
10813 requires 16 bits, and the False variant requires 8 bits.
10814 In the above example, both V1 and V2 contain the False variant,
10815 which is only 8 bits long. However, the result of running the
10816 program is:
10817
10818 @smallexample
10819 8
10820 16
10821 @end smallexample
10822
10823 @noindent
10824 The reason for the difference here is that the discriminant value of
10825 V1 is fixed, and will always be False. It is not possible to assign
10826 a True variant value to V1, therefore 8 bits is sufficient. On the
10827 other hand, in the case of V2, the initial discriminant value is
10828 False (from the default), but it is possible to assign a True
10829 variant value to V2, therefore 16 bits must be allocated for V2
10830 in the general case, even fewer bits may be needed at any particular
10831 point during the program execution.
10832
10833 As can be seen from the output of this program, the @code{'Size}
10834 attribute applied to such an object in GNAT gives the actual allocated
10835 size of the variable, which is the largest size of any of the variants.
10836 The Ada Reference Manual is not completely clear on what choice should
10837 be made here, but the GNAT behavior seems most consistent with the
10838 language in the RM@.
10839
10840 In some cases, it may be desirable to obtain the size of the current
10841 variant, rather than the size of the largest variant. This can be
10842 achieved in GNAT by making use of the fact that in the case of a
10843 subprogram parameter, GNAT does indeed return the size of the current
10844 variant (because a subprogram has no way of knowing how much space
10845 is actually allocated for the actual).
10846
10847 Consider the following modified version of the above program:
10848
10849 @smallexample @c ada
10850 with Text_IO; use Text_IO;
10851 procedure q is
10852 type R1 (A : Boolean := False) is record
10853 case A is
10854 when True => X : Character;
10855 when False => null;
10856 end case;
10857 end record;
10858
10859 V2 : R1;
10860
10861 function Size (V : R1) return Integer is
10862 begin
10863 return V'Size;
10864 end Size;
10865
10866 begin
10867 Put_Line (Integer'Image (V2'Size));
10868 Put_Line (Integer'IMage (Size (V2)));
10869 V2 := (True, 'x');
10870 Put_Line (Integer'Image (V2'Size));
10871 Put_Line (Integer'IMage (Size (V2)));
10872 end q;
10873 @end smallexample
10874
10875 @noindent
10876 The output from this program is
10877
10878 @smallexample
10879 16
10880 8
10881 16
10882 16
10883 @end smallexample
10884
10885 @noindent
10886 Here we see that while the @code{'Size} attribute always returns
10887 the maximum size, regardless of the current variant value, the
10888 @code{Size} function does indeed return the size of the current
10889 variant value.
10890
10891 @node Biased Representation
10892 @section Biased Representation
10893 @cindex Size for biased representation
10894 @cindex Biased representation
10895
10896 @noindent
10897 In the case of scalars with a range starting at other than zero, it is
10898 possible in some cases to specify a size smaller than the default minimum
10899 value, and in such cases, GNAT uses an unsigned biased representation,
10900 in which zero is used to represent the lower bound, and successive values
10901 represent successive values of the type.
10902
10903 For example, suppose we have the declaration:
10904
10905 @smallexample @c ada
10906 type Small is range -7 .. -4;
10907 for Small'Size use 2;
10908 @end smallexample
10909
10910 @noindent
10911 Although the default size of type @code{Small} is 4, the @code{Size}
10912 clause is accepted by GNAT and results in the following representation
10913 scheme:
10914
10915 @smallexample
10916 -7 is represented as 2#00#
10917 -6 is represented as 2#01#
10918 -5 is represented as 2#10#
10919 -4 is represented as 2#11#
10920 @end smallexample
10921
10922 @noindent
10923 Biased representation is only used if the specified @code{Size} clause
10924 cannot be accepted in any other manner. These reduced sizes that force
10925 biased representation can be used for all discrete types except for
10926 enumeration types for which a representation clause is given.
10927
10928 @node Value_Size and Object_Size Clauses
10929 @section Value_Size and Object_Size Clauses
10930 @findex Value_Size
10931 @findex Object_Size
10932 @cindex Size, of objects
10933
10934 @noindent
10935 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10936 number of bits required to hold values of type @code{T}.
10937 Although this interpretation was allowed in Ada 83, it was not required,
10938 and this requirement in practice can cause some significant difficulties.
10939 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10940 However, in Ada 95 and Ada 2005,
10941 @code{Natural'Size} is
10942 typically 31. This means that code may change in behavior when moving
10943 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
10944
10945 @smallexample @c ada
10946 type Rec is record;
10947 A : Natural;
10948 B : Natural;
10949 end record;
10950
10951 for Rec use record
10952 at 0 range 0 .. Natural'Size - 1;
10953 at 0 range Natural'Size .. 2 * Natural'Size - 1;
10954 end record;
10955 @end smallexample
10956
10957 @noindent
10958 In the above code, since the typical size of @code{Natural} objects
10959 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10960 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10961 there are cases where the fact that the object size can exceed the
10962 size of the type causes surprises.
10963
10964 To help get around this problem GNAT provides two implementation
10965 defined attributes, @code{Value_Size} and @code{Object_Size}. When
10966 applied to a type, these attributes yield the size of the type
10967 (corresponding to the RM defined size attribute), and the size of
10968 objects of the type respectively.
10969
10970 The @code{Object_Size} is used for determining the default size of
10971 objects and components. This size value can be referred to using the
10972 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
10973 the basis of the determination of the size. The backend is free to
10974 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10975 character might be stored in 32 bits on a machine with no efficient
10976 byte access instructions such as the Alpha.
10977
10978 The default rules for the value of @code{Object_Size} for
10979 discrete types are as follows:
10980
10981 @itemize @bullet
10982 @item
10983 The @code{Object_Size} for base subtypes reflect the natural hardware
10984 size in bits (run the compiler with @option{-gnatS} to find those values
10985 for numeric types). Enumeration types and fixed-point base subtypes have
10986 8, 16, 32 or 64 bits for this size, depending on the range of values
10987 to be stored.
10988
10989 @item
10990 The @code{Object_Size} of a subtype is the same as the
10991 @code{Object_Size} of
10992 the type from which it is obtained.
10993
10994 @item
10995 The @code{Object_Size} of a derived base type is copied from the parent
10996 base type, and the @code{Object_Size} of a derived first subtype is copied
10997 from the parent first subtype.
10998 @end itemize
10999
11000 @noindent
11001 The @code{Value_Size} attribute
11002 is the (minimum) number of bits required to store a value
11003 of the type.
11004 This value is used to determine how tightly to pack
11005 records or arrays with components of this type, and also affects
11006 the semantics of unchecked conversion (unchecked conversions where
11007 the @code{Value_Size} values differ generate a warning, and are potentially
11008 target dependent).
11009
11010 The default rules for the value of @code{Value_Size} are as follows:
11011
11012 @itemize @bullet
11013 @item
11014 The @code{Value_Size} for a base subtype is the minimum number of bits
11015 required to store all values of the type (including the sign bit
11016 only if negative values are possible).
11017
11018 @item
11019 If a subtype statically matches the first subtype of a given type, then it has
11020 by default the same @code{Value_Size} as the first subtype. This is a
11021 consequence of RM 13.1(14) (``if two subtypes statically match,
11022 then their subtype-specific aspects are the same''.)
11023
11024 @item
11025 All other subtypes have a @code{Value_Size} corresponding to the minimum
11026 number of bits required to store all values of the subtype. For
11027 dynamic bounds, it is assumed that the value can range down or up
11028 to the corresponding bound of the ancestor
11029 @end itemize
11030
11031 @noindent
11032 The RM defined attribute @code{Size} corresponds to the
11033 @code{Value_Size} attribute.
11034
11035 The @code{Size} attribute may be defined for a first-named subtype. This sets
11036 the @code{Value_Size} of
11037 the first-named subtype to the given value, and the
11038 @code{Object_Size} of this first-named subtype to the given value padded up
11039 to an appropriate boundary. It is a consequence of the default rules
11040 above that this @code{Object_Size} will apply to all further subtypes. On the
11041 other hand, @code{Value_Size} is affected only for the first subtype, any
11042 dynamic subtypes obtained from it directly, and any statically matching
11043 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11044
11045 @code{Value_Size} and
11046 @code{Object_Size} may be explicitly set for any subtype using
11047 an attribute definition clause. Note that the use of these attributes
11048 can cause the RM 13.1(14) rule to be violated. If two access types
11049 reference aliased objects whose subtypes have differing @code{Object_Size}
11050 values as a result of explicit attribute definition clauses, then it
11051 is erroneous to convert from one access subtype to the other.
11052
11053 At the implementation level, Esize stores the Object_Size and the
11054 RM_Size field stores the @code{Value_Size} (and hence the value of the
11055 @code{Size} attribute,
11056 which, as noted above, is equivalent to @code{Value_Size}).
11057
11058 To get a feel for the difference, consider the following examples (note
11059 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11060
11061 @smallexample
11062 Object_Size Value_Size
11063
11064 type x1 is range 0 .. 5; 8 3
11065
11066 type x2 is range 0 .. 5;
11067 for x2'size use 12; 16 12
11068
11069 subtype x3 is x2 range 0 .. 3; 16 2
11070
11071 subtype x4 is x2'base range 0 .. 10; 8 4
11072
11073 subtype x5 is x2 range 0 .. dynamic; 16 3*
11074
11075 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11076
11077 @end smallexample
11078
11079 @noindent
11080 Note: the entries marked ``3*'' are not actually specified by the Ada
11081 Reference Manual, but it seems in the spirit of the RM rules to allocate
11082 the minimum number of bits (here 3, given the range for @code{x2})
11083 known to be large enough to hold the given range of values.
11084
11085 So far, so good, but GNAT has to obey the RM rules, so the question is
11086 under what conditions must the RM @code{Size} be used.
11087 The following is a list
11088 of the occasions on which the RM @code{Size} must be used:
11089
11090 @itemize @bullet
11091 @item
11092 Component size for packed arrays or records
11093
11094 @item
11095 Value of the attribute @code{Size} for a type
11096
11097 @item
11098 Warning about sizes not matching for unchecked conversion
11099 @end itemize
11100
11101 @noindent
11102 For record types, the @code{Object_Size} is always a multiple of the
11103 alignment of the type (this is true for all types). In some cases the
11104 @code{Value_Size} can be smaller. Consider:
11105
11106 @smallexample
11107 type R is record
11108 X : Integer;
11109 Y : Character;
11110 end record;
11111 @end smallexample
11112
11113 @noindent
11114 On a typical 32-bit architecture, the X component will be four bytes, and
11115 require four-byte alignment, and the Y component will be one byte. In this
11116 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11117 required to store a value of this type, and for example, it is permissible
11118 to have a component of type R in an outer array whose component size is
11119 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11120 since it must be rounded up so that this value is a multiple of the
11121 alignment (4 bytes = 32 bits).
11122
11123 @noindent
11124 For all other types, the @code{Object_Size}
11125 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11126 Only @code{Size} may be specified for such types.
11127
11128 @node Component_Size Clauses
11129 @section Component_Size Clauses
11130 @cindex Component_Size Clause
11131
11132 @noindent
11133 Normally, the value specified in a component size clause must be consistent
11134 with the subtype of the array component with regard to size and alignment.
11135 In other words, the value specified must be at least equal to the size
11136 of this subtype, and must be a multiple of the alignment value.
11137
11138 In addition, component size clauses are allowed which cause the array
11139 to be packed, by specifying a smaller value. A first case is for
11140 component size values in the range 1 through 63. The value specified
11141 must not be smaller than the Size of the subtype. GNAT will accurately
11142 honor all packing requests in this range. For example, if we have:
11143
11144 @smallexample @c ada
11145 type r is array (1 .. 8) of Natural;
11146 for r'Component_Size use 31;
11147 @end smallexample
11148
11149 @noindent
11150 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11151 Of course access to the components of such an array is considerably
11152 less efficient than if the natural component size of 32 is used.
11153 A second case is when the subtype of the component is a record type
11154 padded because of its default alignment. For example, if we have:
11155
11156 @smallexample @c ada
11157 type r is record
11158 i : Integer;
11159 j : Integer;
11160 b : Boolean;
11161 end record;
11162
11163 type a is array (1 .. 8) of r;
11164 for a'Component_Size use 72;
11165 @end smallexample
11166
11167 @noindent
11168 then the resulting array has a length of 72 bytes, instead of 96 bytes
11169 if the alignment of the record (4) was obeyed.
11170
11171 Note that there is no point in giving both a component size clause
11172 and a pragma Pack for the same array type. if such duplicate
11173 clauses are given, the pragma Pack will be ignored.
11174
11175 @node Bit_Order Clauses
11176 @section Bit_Order Clauses
11177 @cindex Bit_Order Clause
11178 @cindex bit ordering
11179 @cindex ordering, of bits
11180
11181 @noindent
11182 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11183 attribute. The specification may either correspond to the default bit
11184 order for the target, in which case the specification has no effect and
11185 places no additional restrictions, or it may be for the non-standard
11186 setting (that is the opposite of the default).
11187
11188 In the case where the non-standard value is specified, the effect is
11189 to renumber bits within each byte, but the ordering of bytes is not
11190 affected. There are certain
11191 restrictions placed on component clauses as follows:
11192
11193 @itemize @bullet
11194
11195 @item Components fitting within a single storage unit.
11196 @noindent
11197 These are unrestricted, and the effect is merely to renumber bits. For
11198 example if we are on a little-endian machine with @code{Low_Order_First}
11199 being the default, then the following two declarations have exactly
11200 the same effect:
11201
11202 @smallexample @c ada
11203 type R1 is record
11204 A : Boolean;
11205 B : Integer range 1 .. 120;
11206 end record;
11207
11208 for R1 use record
11209 A at 0 range 0 .. 0;
11210 B at 0 range 1 .. 7;
11211 end record;
11212
11213 type R2 is record
11214 A : Boolean;
11215 B : Integer range 1 .. 120;
11216 end record;
11217
11218 for R2'Bit_Order use High_Order_First;
11219
11220 for R2 use record
11221 A at 0 range 7 .. 7;
11222 B at 0 range 0 .. 6;
11223 end record;
11224 @end smallexample
11225
11226 @noindent
11227 The useful application here is to write the second declaration with the
11228 @code{Bit_Order} attribute definition clause, and know that it will be treated
11229 the same, regardless of whether the target is little-endian or big-endian.
11230
11231 @item Components occupying an integral number of bytes.
11232 @noindent
11233 These are components that exactly fit in two or more bytes. Such component
11234 declarations are allowed, but have no effect, since it is important to realize
11235 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11236 In particular, the following attempt at getting an endian-independent integer
11237 does not work:
11238
11239 @smallexample @c ada
11240 type R2 is record
11241 A : Integer;
11242 end record;
11243
11244 for R2'Bit_Order use High_Order_First;
11245
11246 for R2 use record
11247 A at 0 range 0 .. 31;
11248 end record;
11249 @end smallexample
11250
11251 @noindent
11252 This declaration will result in a little-endian integer on a
11253 little-endian machine, and a big-endian integer on a big-endian machine.
11254 If byte flipping is required for interoperability between big- and
11255 little-endian machines, this must be explicitly programmed. This capability
11256 is not provided by @code{Bit_Order}.
11257
11258 @item Components that are positioned across byte boundaries
11259 @noindent
11260 but do not occupy an integral number of bytes. Given that bytes are not
11261 reordered, such fields would occupy a non-contiguous sequence of bits
11262 in memory, requiring non-trivial code to reassemble. They are for this
11263 reason not permitted, and any component clause specifying such a layout
11264 will be flagged as illegal by GNAT@.
11265
11266 @end itemize
11267
11268 @noindent
11269 Since the misconception that Bit_Order automatically deals with all
11270 endian-related incompatibilities is a common one, the specification of
11271 a component field that is an integral number of bytes will always
11272 generate a warning. This warning may be suppressed using @code{pragma
11273 Warnings (Off)} if desired. The following section contains additional
11274 details regarding the issue of byte ordering.
11275
11276 @node Effect of Bit_Order on Byte Ordering
11277 @section Effect of Bit_Order on Byte Ordering
11278 @cindex byte ordering
11279 @cindex ordering, of bytes
11280
11281 @noindent
11282 In this section we will review the effect of the @code{Bit_Order} attribute
11283 definition clause on byte ordering. Briefly, it has no effect at all, but
11284 a detailed example will be helpful. Before giving this
11285 example, let us review the precise
11286 definition of the effect of defining @code{Bit_Order}. The effect of a
11287 non-standard bit order is described in section 15.5.3 of the Ada
11288 Reference Manual:
11289
11290 @quotation
11291 2 A bit ordering is a method of interpreting the meaning of
11292 the storage place attributes.
11293 @end quotation
11294
11295 @noindent
11296 To understand the precise definition of storage place attributes in
11297 this context, we visit section 13.5.1 of the manual:
11298
11299 @quotation
11300 13 A record_representation_clause (without the mod_clause)
11301 specifies the layout. The storage place attributes (see 13.5.2)
11302 are taken from the values of the position, first_bit, and last_bit
11303 expressions after normalizing those values so that first_bit is
11304 less than Storage_Unit.
11305 @end quotation
11306
11307 @noindent
11308 The critical point here is that storage places are taken from
11309 the values after normalization, not before. So the @code{Bit_Order}
11310 interpretation applies to normalized values. The interpretation
11311 is described in the later part of the 15.5.3 paragraph:
11312
11313 @quotation
11314 2 A bit ordering is a method of interpreting the meaning of
11315 the storage place attributes. High_Order_First (known in the
11316 vernacular as ``big endian'') means that the first bit of a
11317 storage element (bit 0) is the most significant bit (interpreting
11318 the sequence of bits that represent a component as an unsigned
11319 integer value). Low_Order_First (known in the vernacular as
11320 ``little endian'') means the opposite: the first bit is the
11321 least significant.
11322 @end quotation
11323
11324 @noindent
11325 Note that the numbering is with respect to the bits of a storage
11326 unit. In other words, the specification affects only the numbering
11327 of bits within a single storage unit.
11328
11329 We can make the effect clearer by giving an example.
11330
11331 Suppose that we have an external device which presents two bytes, the first
11332 byte presented, which is the first (low addressed byte) of the two byte
11333 record is called Master, and the second byte is called Slave.
11334
11335 The left most (most significant bit is called Control for each byte, and
11336 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11337 (least significant) bit.
11338
11339 On a big-endian machine, we can write the following representation clause
11340
11341 @smallexample @c ada
11342 type Data is record
11343 Master_Control : Bit;
11344 Master_V1 : Bit;
11345 Master_V2 : Bit;
11346 Master_V3 : Bit;
11347 Master_V4 : Bit;
11348 Master_V5 : Bit;
11349 Master_V6 : Bit;
11350 Master_V7 : Bit;
11351 Slave_Control : Bit;
11352 Slave_V1 : Bit;
11353 Slave_V2 : Bit;
11354 Slave_V3 : Bit;
11355 Slave_V4 : Bit;
11356 Slave_V5 : Bit;
11357 Slave_V6 : Bit;
11358 Slave_V7 : Bit;
11359 end record;
11360
11361 for Data use record
11362 Master_Control at 0 range 0 .. 0;
11363 Master_V1 at 0 range 1 .. 1;
11364 Master_V2 at 0 range 2 .. 2;
11365 Master_V3 at 0 range 3 .. 3;
11366 Master_V4 at 0 range 4 .. 4;
11367 Master_V5 at 0 range 5 .. 5;
11368 Master_V6 at 0 range 6 .. 6;
11369 Master_V7 at 0 range 7 .. 7;
11370 Slave_Control at 1 range 0 .. 0;
11371 Slave_V1 at 1 range 1 .. 1;
11372 Slave_V2 at 1 range 2 .. 2;
11373 Slave_V3 at 1 range 3 .. 3;
11374 Slave_V4 at 1 range 4 .. 4;
11375 Slave_V5 at 1 range 5 .. 5;
11376 Slave_V6 at 1 range 6 .. 6;
11377 Slave_V7 at 1 range 7 .. 7;
11378 end record;
11379 @end smallexample
11380
11381 @noindent
11382 Now if we move this to a little endian machine, then the bit ordering within
11383 the byte is backwards, so we have to rewrite the record rep clause as:
11384
11385 @smallexample @c ada
11386 for Data use record
11387 Master_Control at 0 range 7 .. 7;
11388 Master_V1 at 0 range 6 .. 6;
11389 Master_V2 at 0 range 5 .. 5;
11390 Master_V3 at 0 range 4 .. 4;
11391 Master_V4 at 0 range 3 .. 3;
11392 Master_V5 at 0 range 2 .. 2;
11393 Master_V6 at 0 range 1 .. 1;
11394 Master_V7 at 0 range 0 .. 0;
11395 Slave_Control at 1 range 7 .. 7;
11396 Slave_V1 at 1 range 6 .. 6;
11397 Slave_V2 at 1 range 5 .. 5;
11398 Slave_V3 at 1 range 4 .. 4;
11399 Slave_V4 at 1 range 3 .. 3;
11400 Slave_V5 at 1 range 2 .. 2;
11401 Slave_V6 at 1 range 1 .. 1;
11402 Slave_V7 at 1 range 0 .. 0;
11403 end record;
11404 @end smallexample
11405
11406 @noindent
11407 It is a nuisance to have to rewrite the clause, especially if
11408 the code has to be maintained on both machines. However,
11409 this is a case that we can handle with the
11410 @code{Bit_Order} attribute if it is implemented.
11411 Note that the implementation is not required on byte addressed
11412 machines, but it is indeed implemented in GNAT.
11413 This means that we can simply use the
11414 first record clause, together with the declaration
11415
11416 @smallexample @c ada
11417 for Data'Bit_Order use High_Order_First;
11418 @end smallexample
11419
11420 @noindent
11421 and the effect is what is desired, namely the layout is exactly the same,
11422 independent of whether the code is compiled on a big-endian or little-endian
11423 machine.
11424
11425 The important point to understand is that byte ordering is not affected.
11426 A @code{Bit_Order} attribute definition never affects which byte a field
11427 ends up in, only where it ends up in that byte.
11428 To make this clear, let us rewrite the record rep clause of the previous
11429 example as:
11430
11431 @smallexample @c ada
11432 for Data'Bit_Order use High_Order_First;
11433 for Data use record
11434 Master_Control at 0 range 0 .. 0;
11435 Master_V1 at 0 range 1 .. 1;
11436 Master_V2 at 0 range 2 .. 2;
11437 Master_V3 at 0 range 3 .. 3;
11438 Master_V4 at 0 range 4 .. 4;
11439 Master_V5 at 0 range 5 .. 5;
11440 Master_V6 at 0 range 6 .. 6;
11441 Master_V7 at 0 range 7 .. 7;
11442 Slave_Control at 0 range 8 .. 8;
11443 Slave_V1 at 0 range 9 .. 9;
11444 Slave_V2 at 0 range 10 .. 10;
11445 Slave_V3 at 0 range 11 .. 11;
11446 Slave_V4 at 0 range 12 .. 12;
11447 Slave_V5 at 0 range 13 .. 13;
11448 Slave_V6 at 0 range 14 .. 14;
11449 Slave_V7 at 0 range 15 .. 15;
11450 end record;
11451 @end smallexample
11452
11453 @noindent
11454 This is exactly equivalent to saying (a repeat of the first example):
11455
11456 @smallexample @c ada
11457 for Data'Bit_Order use High_Order_First;
11458 for Data use record
11459 Master_Control at 0 range 0 .. 0;
11460 Master_V1 at 0 range 1 .. 1;
11461 Master_V2 at 0 range 2 .. 2;
11462 Master_V3 at 0 range 3 .. 3;
11463 Master_V4 at 0 range 4 .. 4;
11464 Master_V5 at 0 range 5 .. 5;
11465 Master_V6 at 0 range 6 .. 6;
11466 Master_V7 at 0 range 7 .. 7;
11467 Slave_Control at 1 range 0 .. 0;
11468 Slave_V1 at 1 range 1 .. 1;
11469 Slave_V2 at 1 range 2 .. 2;
11470 Slave_V3 at 1 range 3 .. 3;
11471 Slave_V4 at 1 range 4 .. 4;
11472 Slave_V5 at 1 range 5 .. 5;
11473 Slave_V6 at 1 range 6 .. 6;
11474 Slave_V7 at 1 range 7 .. 7;
11475 end record;
11476 @end smallexample
11477
11478 @noindent
11479 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11480 field. The storage place attributes are obtained by normalizing the
11481 values given so that the @code{First_Bit} value is less than 8. After
11482 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11483 we specified in the other case.
11484
11485 Now one might expect that the @code{Bit_Order} attribute might affect
11486 bit numbering within the entire record component (two bytes in this
11487 case, thus affecting which byte fields end up in), but that is not
11488 the way this feature is defined, it only affects numbering of bits,
11489 not which byte they end up in.
11490
11491 Consequently it never makes sense to specify a starting bit number
11492 greater than 7 (for a byte addressable field) if an attribute
11493 definition for @code{Bit_Order} has been given, and indeed it
11494 may be actively confusing to specify such a value, so the compiler
11495 generates a warning for such usage.
11496
11497 If you do need to control byte ordering then appropriate conditional
11498 values must be used. If in our example, the slave byte came first on
11499 some machines we might write:
11500
11501 @smallexample @c ada
11502 Master_Byte_First constant Boolean := @dots{};
11503
11504 Master_Byte : constant Natural :=
11505 1 - Boolean'Pos (Master_Byte_First);
11506 Slave_Byte : constant Natural :=
11507 Boolean'Pos (Master_Byte_First);
11508
11509 for Data'Bit_Order use High_Order_First;
11510 for Data use record
11511 Master_Control at Master_Byte range 0 .. 0;
11512 Master_V1 at Master_Byte range 1 .. 1;
11513 Master_V2 at Master_Byte range 2 .. 2;
11514 Master_V3 at Master_Byte range 3 .. 3;
11515 Master_V4 at Master_Byte range 4 .. 4;
11516 Master_V5 at Master_Byte range 5 .. 5;
11517 Master_V6 at Master_Byte range 6 .. 6;
11518 Master_V7 at Master_Byte range 7 .. 7;
11519 Slave_Control at Slave_Byte range 0 .. 0;
11520 Slave_V1 at Slave_Byte range 1 .. 1;
11521 Slave_V2 at Slave_Byte range 2 .. 2;
11522 Slave_V3 at Slave_Byte range 3 .. 3;
11523 Slave_V4 at Slave_Byte range 4 .. 4;
11524 Slave_V5 at Slave_Byte range 5 .. 5;
11525 Slave_V6 at Slave_Byte range 6 .. 6;
11526 Slave_V7 at Slave_Byte range 7 .. 7;
11527 end record;
11528 @end smallexample
11529
11530 @noindent
11531 Now to switch between machines, all that is necessary is
11532 to set the boolean constant @code{Master_Byte_First} in
11533 an appropriate manner.
11534
11535 @node Pragma Pack for Arrays
11536 @section Pragma Pack for Arrays
11537 @cindex Pragma Pack (for arrays)
11538
11539 @noindent
11540 Pragma @code{Pack} applied to an array has no effect unless the component type
11541 is packable. For a component type to be packable, it must be one of the
11542 following cases:
11543
11544 @itemize @bullet
11545 @item
11546 Any scalar type
11547 @item
11548 Any type whose size is specified with a size clause
11549 @item
11550 Any packed array type with a static size
11551 @item
11552 Any record type padded because of its default alignment
11553 @end itemize
11554
11555 @noindent
11556 For all these cases, if the component subtype size is in the range
11557 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11558 component size were specified giving the component subtype size.
11559 For example if we have:
11560
11561 @smallexample @c ada
11562 type r is range 0 .. 17;
11563
11564 type ar is array (1 .. 8) of r;
11565 pragma Pack (ar);
11566 @end smallexample
11567
11568 @noindent
11569 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11570 and the size of the array @code{ar} will be exactly 40 bits.
11571
11572 Note that in some cases this rather fierce approach to packing can produce
11573 unexpected effects. For example, in Ada 95 and Ada 2005,
11574 subtype @code{Natural} typically has a size of 31, meaning that if you
11575 pack an array of @code{Natural}, you get 31-bit
11576 close packing, which saves a few bits, but results in far less efficient
11577 access. Since many other Ada compilers will ignore such a packing request,
11578 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11579 might not be what is intended. You can easily remove this warning by
11580 using an explicit @code{Component_Size} setting instead, which never generates
11581 a warning, since the intention of the programmer is clear in this case.
11582
11583 GNAT treats packed arrays in one of two ways. If the size of the array is
11584 known at compile time and is less than 64 bits, then internally the array
11585 is represented as a single modular type, of exactly the appropriate number
11586 of bits. If the length is greater than 63 bits, or is not known at compile
11587 time, then the packed array is represented as an array of bytes, and the
11588 length is always a multiple of 8 bits.
11589
11590 Note that to represent a packed array as a modular type, the alignment must
11591 be suitable for the modular type involved. For example, on typical machines
11592 a 32-bit packed array will be represented by a 32-bit modular integer with
11593 an alignment of four bytes. If you explicitly override the default alignment
11594 with an alignment clause that is too small, the modular representation
11595 cannot be used. For example, consider the following set of declarations:
11596
11597 @smallexample @c ada
11598 type R is range 1 .. 3;
11599 type S is array (1 .. 31) of R;
11600 for S'Component_Size use 2;
11601 for S'Size use 62;
11602 for S'Alignment use 1;
11603 @end smallexample
11604
11605 @noindent
11606 If the alignment clause were not present, then a 62-bit modular
11607 representation would be chosen (typically with an alignment of 4 or 8
11608 bytes depending on the target). But the default alignment is overridden
11609 with the explicit alignment clause. This means that the modular
11610 representation cannot be used, and instead the array of bytes
11611 representation must be used, meaning that the length must be a multiple
11612 of 8. Thus the above set of declarations will result in a diagnostic
11613 rejecting the size clause and noting that the minimum size allowed is 64.
11614
11615 @cindex Pragma Pack (for type Natural)
11616 @cindex Pragma Pack warning
11617
11618 One special case that is worth noting occurs when the base type of the
11619 component size is 8/16/32 and the subtype is one bit less. Notably this
11620 occurs with subtype @code{Natural}. Consider:
11621
11622 @smallexample @c ada
11623 type Arr is array (1 .. 32) of Natural;
11624 pragma Pack (Arr);
11625 @end smallexample
11626
11627 @noindent
11628 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11629 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11630 Ada 83 compilers did not attempt 31 bit packing.
11631
11632 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11633 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11634 substantial unintended performance penalty when porting legacy Ada 83 code.
11635 To help prevent this, GNAT generates a warning in such cases. If you really
11636 want 31 bit packing in a case like this, you can set the component size
11637 explicitly:
11638
11639 @smallexample @c ada
11640 type Arr is array (1 .. 32) of Natural;
11641 for Arr'Component_Size use 31;
11642 @end smallexample
11643
11644 @noindent
11645 Here 31-bit packing is achieved as required, and no warning is generated,
11646 since in this case the programmer intention is clear.
11647
11648 @node Pragma Pack for Records
11649 @section Pragma Pack for Records
11650 @cindex Pragma Pack (for records)
11651
11652 @noindent
11653 Pragma @code{Pack} applied to a record will pack the components to reduce
11654 wasted space from alignment gaps and by reducing the amount of space
11655 taken by components. We distinguish between @emph{packable} components and
11656 @emph{non-packable} components.
11657 Components of the following types are considered packable:
11658 @itemize @bullet
11659 @item
11660 All primitive types are packable.
11661
11662 @item
11663 Small packed arrays, whose size does not exceed 64 bits, and where the
11664 size is statically known at compile time, are represented internally
11665 as modular integers, and so they are also packable.
11666
11667 @end itemize
11668
11669 @noindent
11670 All packable components occupy the exact number of bits corresponding to
11671 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11672 can start on an arbitrary bit boundary.
11673
11674 All other types are non-packable, they occupy an integral number of
11675 storage units, and
11676 are placed at a boundary corresponding to their alignment requirements.
11677
11678 For example, consider the record
11679
11680 @smallexample @c ada
11681 type Rb1 is array (1 .. 13) of Boolean;
11682 pragma Pack (rb1);
11683
11684 type Rb2 is array (1 .. 65) of Boolean;
11685 pragma Pack (rb2);
11686
11687 type x2 is record
11688 l1 : Boolean;
11689 l2 : Duration;
11690 l3 : Float;
11691 l4 : Boolean;
11692 l5 : Rb1;
11693 l6 : Rb2;
11694 end record;
11695 pragma Pack (x2);
11696 @end smallexample
11697
11698 @noindent
11699 The representation for the record x2 is as follows:
11700
11701 @smallexample @c ada
11702 for x2'Size use 224;
11703 for x2 use record
11704 l1 at 0 range 0 .. 0;
11705 l2 at 0 range 1 .. 64;
11706 l3 at 12 range 0 .. 31;
11707 l4 at 16 range 0 .. 0;
11708 l5 at 16 range 1 .. 13;
11709 l6 at 18 range 0 .. 71;
11710 end record;
11711 @end smallexample
11712
11713 @noindent
11714 Studying this example, we see that the packable fields @code{l1}
11715 and @code{l2} are
11716 of length equal to their sizes, and placed at specific bit boundaries (and
11717 not byte boundaries) to
11718 eliminate padding. But @code{l3} is of a non-packable float type, so
11719 it is on the next appropriate alignment boundary.
11720
11721 The next two fields are fully packable, so @code{l4} and @code{l5} are
11722 minimally packed with no gaps. However, type @code{Rb2} is a packed
11723 array that is longer than 64 bits, so it is itself non-packable. Thus
11724 the @code{l6} field is aligned to the next byte boundary, and takes an
11725 integral number of bytes, i.e.@: 72 bits.
11726
11727 @node Record Representation Clauses
11728 @section Record Representation Clauses
11729 @cindex Record Representation Clause
11730
11731 @noindent
11732 Record representation clauses may be given for all record types, including
11733 types obtained by record extension. Component clauses are allowed for any
11734 static component. The restrictions on component clauses depend on the type
11735 of the component.
11736
11737 @cindex Component Clause
11738 For all components of an elementary type, the only restriction on component
11739 clauses is that the size must be at least the 'Size value of the type
11740 (actually the Value_Size). There are no restrictions due to alignment,
11741 and such components may freely cross storage boundaries.
11742
11743 Packed arrays with a size up to and including 64 bits are represented
11744 internally using a modular type with the appropriate number of bits, and
11745 thus the same lack of restriction applies. For example, if you declare:
11746
11747 @smallexample @c ada
11748 type R is array (1 .. 49) of Boolean;
11749 pragma Pack (R);
11750 for R'Size use 49;
11751 @end smallexample
11752
11753 @noindent
11754 then a component clause for a component of type R may start on any
11755 specified bit boundary, and may specify a value of 49 bits or greater.
11756
11757 For packed bit arrays that are longer than 64 bits, there are two
11758 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11759 including the important case of single bits or boolean values, then
11760 there are no limitations on placement of such components, and they
11761 may start and end at arbitrary bit boundaries.
11762
11763 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11764 an array of this type longer than 64 bits must always be placed on
11765 on a storage unit (byte) boundary and occupy an integral number
11766 of storage units (bytes). Any component clause that does not
11767 meet this requirement will be rejected.
11768
11769 Any aliased component, or component of an aliased type, must
11770 have its normal alignment and size. A component clause that
11771 does not meet this requirement will be rejected.
11772
11773 The tag field of a tagged type always occupies an address sized field at
11774 the start of the record. No component clause may attempt to overlay this
11775 tag. When a tagged type appears as a component, the tag field must have
11776 proper alignment
11777
11778 In the case of a record extension T1, of a type T, no component clause applied
11779 to the type T1 can specify a storage location that would overlap the first
11780 T'Size bytes of the record.
11781
11782 For all other component types, including non-bit-packed arrays,
11783 the component can be placed at an arbitrary bit boundary,
11784 so for example, the following is permitted:
11785
11786 @smallexample @c ada
11787 type R is array (1 .. 10) of Boolean;
11788 for R'Size use 80;
11789
11790 type Q is record
11791 G, H : Boolean;
11792 L, M : R;
11793 end record;
11794
11795 for Q use record
11796 G at 0 range 0 .. 0;
11797 H at 0 range 1 .. 1;
11798 L at 0 range 2 .. 81;
11799 R at 0 range 82 .. 161;
11800 end record;
11801 @end smallexample
11802
11803 @noindent
11804 Note: the above rules apply to recent releases of GNAT 5.
11805 In GNAT 3, there are more severe restrictions on larger components.
11806 For non-primitive types, including packed arrays with a size greater than
11807 64 bits, component clauses must respect the alignment requirement of the
11808 type, in particular, always starting on a byte boundary, and the length
11809 must be a multiple of the storage unit.
11810
11811 @node Enumeration Clauses
11812 @section Enumeration Clauses
11813
11814 The only restriction on enumeration clauses is that the range of values
11815 must be representable. For the signed case, if one or more of the
11816 representation values are negative, all values must be in the range:
11817
11818 @smallexample @c ada
11819 System.Min_Int .. System.Max_Int
11820 @end smallexample
11821
11822 @noindent
11823 For the unsigned case, where all values are nonnegative, the values must
11824 be in the range:
11825
11826 @smallexample @c ada
11827 0 .. System.Max_Binary_Modulus;
11828 @end smallexample
11829
11830 @noindent
11831 A @emph{confirming} representation clause is one in which the values range
11832 from 0 in sequence, i.e.@: a clause that confirms the default representation
11833 for an enumeration type.
11834 Such a confirming representation
11835 is permitted by these rules, and is specially recognized by the compiler so
11836 that no extra overhead results from the use of such a clause.
11837
11838 If an array has an index type which is an enumeration type to which an
11839 enumeration clause has been applied, then the array is stored in a compact
11840 manner. Consider the declarations:
11841
11842 @smallexample @c ada
11843 type r is (A, B, C);
11844 for r use (A => 1, B => 5, C => 10);
11845 type t is array (r) of Character;
11846 @end smallexample
11847
11848 @noindent
11849 The array type t corresponds to a vector with exactly three elements and
11850 has a default size equal to @code{3*Character'Size}. This ensures efficient
11851 use of space, but means that accesses to elements of the array will incur
11852 the overhead of converting representation values to the corresponding
11853 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11854
11855 @node Address Clauses
11856 @section Address Clauses
11857 @cindex Address Clause
11858
11859 The reference manual allows a general restriction on representation clauses,
11860 as found in RM 13.1(22):
11861
11862 @quotation
11863 An implementation need not support representation
11864 items containing nonstatic expressions, except that
11865 an implementation should support a representation item
11866 for a given entity if each nonstatic expression in the
11867 representation item is a name that statically denotes
11868 a constant declared before the entity.
11869 @end quotation
11870
11871 @noindent
11872 In practice this is applicable only to address clauses, since this is the
11873 only case in which a non-static expression is permitted by the syntax. As
11874 the AARM notes in sections 13.1 (22.a-22.h):
11875
11876 @display
11877 22.a Reason: This is to avoid the following sort of thing:
11878
11879 22.b X : Integer := F(@dots{});
11880 Y : Address := G(@dots{});
11881 for X'Address use Y;
11882
11883 22.c In the above, we have to evaluate the
11884 initialization expression for X before we
11885 know where to put the result. This seems
11886 like an unreasonable implementation burden.
11887
11888 22.d The above code should instead be written
11889 like this:
11890
11891 22.e Y : constant Address := G(@dots{});
11892 X : Integer := F(@dots{});
11893 for X'Address use Y;
11894
11895 22.f This allows the expression ``Y'' to be safely
11896 evaluated before X is created.
11897
11898 22.g The constant could be a formal parameter of mode in.
11899
11900 22.h An implementation can support other nonstatic
11901 expressions if it wants to. Expressions of type
11902 Address are hardly ever static, but their value
11903 might be known at compile time anyway in many
11904 cases.
11905 @end display
11906
11907 @noindent
11908 GNAT does indeed permit many additional cases of non-static expressions. In
11909 particular, if the type involved is elementary there are no restrictions
11910 (since in this case, holding a temporary copy of the initialization value,
11911 if one is present, is inexpensive). In addition, if there is no implicit or
11912 explicit initialization, then there are no restrictions. GNAT will reject
11913 only the case where all three of these conditions hold:
11914
11915 @itemize @bullet
11916
11917 @item
11918 The type of the item is non-elementary (e.g.@: a record or array).
11919
11920 @item
11921 There is explicit or implicit initialization required for the object.
11922 Note that access values are always implicitly initialized, and also
11923 in GNAT, certain bit-packed arrays (those having a dynamic length or
11924 a length greater than 64) will also be implicitly initialized to zero.
11925
11926 @item
11927 The address value is non-static. Here GNAT is more permissive than the
11928 RM, and allows the address value to be the address of a previously declared
11929 stand-alone variable, as long as it does not itself have an address clause.
11930
11931 @smallexample @c ada
11932 Anchor : Some_Initialized_Type;
11933 Overlay : Some_Initialized_Type;
11934 for Overlay'Address use Anchor'Address;
11935 @end smallexample
11936
11937 @noindent
11938 However, the prefix of the address clause cannot be an array component, or
11939 a component of a discriminated record.
11940
11941 @end itemize
11942
11943 @noindent
11944 As noted above in section 22.h, address values are typically non-static. In
11945 particular the To_Address function, even if applied to a literal value, is
11946 a non-static function call. To avoid this minor annoyance, GNAT provides
11947 the implementation defined attribute 'To_Address. The following two
11948 expressions have identical values:
11949
11950 @findex Attribute
11951 @findex To_Address
11952 @smallexample @c ada
11953 To_Address (16#1234_0000#)
11954 System'To_Address (16#1234_0000#);
11955 @end smallexample
11956
11957 @noindent
11958 except that the second form is considered to be a static expression, and
11959 thus when used as an address clause value is always permitted.
11960
11961 @noindent
11962 Additionally, GNAT treats as static an address clause that is an
11963 unchecked_conversion of a static integer value. This simplifies the porting
11964 of legacy code, and provides a portable equivalent to the GNAT attribute
11965 @code{To_Address}.
11966
11967 Another issue with address clauses is the interaction with alignment
11968 requirements. When an address clause is given for an object, the address
11969 value must be consistent with the alignment of the object (which is usually
11970 the same as the alignment of the type of the object). If an address clause
11971 is given that specifies an inappropriately aligned address value, then the
11972 program execution is erroneous.
11973
11974 Since this source of erroneous behavior can have unfortunate effects, GNAT
11975 checks (at compile time if possible, generating a warning, or at execution
11976 time with a run-time check) that the alignment is appropriate. If the
11977 run-time check fails, then @code{Program_Error} is raised. This run-time
11978 check is suppressed if range checks are suppressed, or if the special GNAT
11979 check Alignment_Check is suppressed, or if
11980 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11981
11982 Finally, GNAT does not permit overlaying of objects of controlled types or
11983 composite types containing a controlled component. In most cases, the compiler
11984 can detect an attempt at such overlays and will generate a warning at compile
11985 time and a Program_Error exception at run time.
11986
11987 @findex Export
11988 An address clause cannot be given for an exported object. More
11989 understandably the real restriction is that objects with an address
11990 clause cannot be exported. This is because such variables are not
11991 defined by the Ada program, so there is no external object to export.
11992
11993 @findex Import
11994 It is permissible to give an address clause and a pragma Import for the
11995 same object. In this case, the variable is not really defined by the
11996 Ada program, so there is no external symbol to be linked. The link name
11997 and the external name are ignored in this case. The reason that we allow this
11998 combination is that it provides a useful idiom to avoid unwanted
11999 initializations on objects with address clauses.
12000
12001 When an address clause is given for an object that has implicit or
12002 explicit initialization, then by default initialization takes place. This
12003 means that the effect of the object declaration is to overwrite the
12004 memory at the specified address. This is almost always not what the
12005 programmer wants, so GNAT will output a warning:
12006
12007 @smallexample
12008 with System;
12009 package G is
12010 type R is record
12011 M : Integer := 0;
12012 end record;
12013
12014 Ext : R;
12015 for Ext'Address use System'To_Address (16#1234_1234#);
12016 |
12017 >>> warning: implicit initialization of "Ext" may
12018 modify overlaid storage
12019 >>> warning: use pragma Import for "Ext" to suppress
12020 initialization (RM B(24))
12021
12022 end G;
12023 @end smallexample
12024
12025 @noindent
12026 As indicated by the warning message, the solution is to use a (dummy) pragma
12027 Import to suppress this initialization. The pragma tell the compiler that the
12028 object is declared and initialized elsewhere. The following package compiles
12029 without warnings (and the initialization is suppressed):
12030
12031 @smallexample @c ada
12032 with System;
12033 package G is
12034 type R is record
12035 M : Integer := 0;
12036 end record;
12037
12038 Ext : R;
12039 for Ext'Address use System'To_Address (16#1234_1234#);
12040 pragma Import (Ada, Ext);
12041 end G;
12042 @end smallexample
12043
12044 @noindent
12045 A final issue with address clauses involves their use for overlaying
12046 variables, as in the following example:
12047 @cindex Overlaying of objects
12048
12049 @smallexample @c ada
12050 A : Integer;
12051 B : Integer;
12052 for B'Address use A'Address;
12053 @end smallexample
12054
12055 @noindent
12056 or alternatively, using the form recommended by the RM:
12057
12058 @smallexample @c ada
12059 A : Integer;
12060 Addr : constant Address := A'Address;
12061 B : Integer;
12062 for B'Address use Addr;
12063 @end smallexample
12064
12065 @noindent
12066 In both of these cases, @code{A}
12067 and @code{B} become aliased to one another via the
12068 address clause. This use of address clauses to overlay
12069 variables, achieving an effect similar to unchecked
12070 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12071 the effect is implementation defined. Furthermore, the
12072 Ada RM specifically recommends that in a situation
12073 like this, @code{B} should be subject to the following
12074 implementation advice (RM 13.3(19)):
12075
12076 @quotation
12077 19 If the Address of an object is specified, or it is imported
12078 or exported, then the implementation should not perform
12079 optimizations based on assumptions of no aliases.
12080 @end quotation
12081
12082 @noindent
12083 GNAT follows this recommendation, and goes further by also applying
12084 this recommendation to the overlaid variable (@code{A}
12085 in the above example) in this case. This means that the overlay
12086 works "as expected", in that a modification to one of the variables
12087 will affect the value of the other.
12088
12089 @node Effect of Convention on Representation
12090 @section Effect of Convention on Representation
12091 @cindex Convention, effect on representation
12092
12093 @noindent
12094 Normally the specification of a foreign language convention for a type or
12095 an object has no effect on the chosen representation. In particular, the
12096 representation chosen for data in GNAT generally meets the standard system
12097 conventions, and for example records are laid out in a manner that is
12098 consistent with C@. This means that specifying convention C (for example)
12099 has no effect.
12100
12101 There are four exceptions to this general rule:
12102
12103 @itemize @bullet
12104
12105 @item Convention Fortran and array subtypes
12106 If pragma Convention Fortran is specified for an array subtype, then in
12107 accordance with the implementation advice in section 3.6.2(11) of the
12108 Ada Reference Manual, the array will be stored in a Fortran-compatible
12109 column-major manner, instead of the normal default row-major order.
12110
12111 @item Convention C and enumeration types
12112 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12113 to accommodate all values of the type. For example, for the enumeration
12114 type declared by:
12115
12116 @smallexample @c ada
12117 type Color is (Red, Green, Blue);
12118 @end smallexample
12119
12120 @noindent
12121 8 bits is sufficient to store all values of the type, so by default, objects
12122 of type @code{Color} will be represented using 8 bits. However, normal C
12123 convention is to use 32 bits for all enum values in C, since enum values
12124 are essentially of type int. If pragma @code{Convention C} is specified for an
12125 Ada enumeration type, then the size is modified as necessary (usually to
12126 32 bits) to be consistent with the C convention for enum values.
12127
12128 Note that this treatment applies only to types. If Convention C is given for
12129 an enumeration object, where the enumeration type is not Convention C, then
12130 Object_Size bits are allocated. For example, for a normal enumeration type,
12131 with less than 256 elements, only 8 bits will be allocated for the object.
12132 Since this may be a surprise in terms of what C expects, GNAT will issue a
12133 warning in this situation. The warning can be suppressed by giving an explicit
12134 size clause specifying the desired size.
12135
12136 @item Convention C/Fortran and Boolean types
12137 In C, the usual convention for boolean values, that is values used for
12138 conditions, is that zero represents false, and nonzero values represent
12139 true. In Ada, the normal convention is that two specific values, typically
12140 0/1, are used to represent false/true respectively.
12141
12142 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12143 value represents true).
12144
12145 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12146 C or Fortran convention for a derived Boolean, as in the following example:
12147
12148 @smallexample @c ada
12149 type C_Switch is new Boolean;
12150 pragma Convention (C, C_Switch);
12151 @end smallexample
12152
12153 @noindent
12154 then the GNAT generated code will treat any nonzero value as true. For truth
12155 values generated by GNAT, the conventional value 1 will be used for True, but
12156 when one of these values is read, any nonzero value is treated as True.
12157
12158 @item Access types on OpenVMS
12159 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12160 arrays) are 64-bits long. An exception to this rule is for the case of
12161 C-convention access types where there is no explicit size clause present (or
12162 inherited for derived types). In this case, GNAT chooses to make these
12163 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12164 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12165
12166 @end itemize
12167
12168 @node Determining the Representations chosen by GNAT
12169 @section Determining the Representations chosen by GNAT
12170 @cindex Representation, determination of
12171 @cindex @option{-gnatR} switch
12172
12173 @noindent
12174 Although the descriptions in this section are intended to be complete, it is
12175 often easier to simply experiment to see what GNAT accepts and what the
12176 effect is on the layout of types and objects.
12177
12178 As required by the Ada RM, if a representation clause is not accepted, then
12179 it must be rejected as illegal by the compiler. However, when a
12180 representation clause or pragma is accepted, there can still be questions
12181 of what the compiler actually does. For example, if a partial record
12182 representation clause specifies the location of some components and not
12183 others, then where are the non-specified components placed? Or if pragma
12184 @code{Pack} is used on a record, then exactly where are the resulting
12185 fields placed? The section on pragma @code{Pack} in this chapter can be
12186 used to answer the second question, but it is often easier to just see
12187 what the compiler does.
12188
12189 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12190 with this option, then the compiler will output information on the actual
12191 representations chosen, in a format similar to source representation
12192 clauses. For example, if we compile the package:
12193
12194 @smallexample @c ada
12195 package q is
12196 type r (x : boolean) is tagged record
12197 case x is
12198 when True => S : String (1 .. 100);
12199 when False => null;
12200 end case;
12201 end record;
12202
12203 type r2 is new r (false) with record
12204 y2 : integer;
12205 end record;
12206
12207 for r2 use record
12208 y2 at 16 range 0 .. 31;
12209 end record;
12210
12211 type x is record
12212 y : character;
12213 end record;
12214
12215 type x1 is array (1 .. 10) of x;
12216 for x1'component_size use 11;
12217
12218 type ia is access integer;
12219
12220 type Rb1 is array (1 .. 13) of Boolean;
12221 pragma Pack (rb1);
12222
12223 type Rb2 is array (1 .. 65) of Boolean;
12224 pragma Pack (rb2);
12225
12226 type x2 is record
12227 l1 : Boolean;
12228 l2 : Duration;
12229 l3 : Float;
12230 l4 : Boolean;
12231 l5 : Rb1;
12232 l6 : Rb2;
12233 end record;
12234 pragma Pack (x2);
12235 end q;
12236 @end smallexample
12237
12238 @noindent
12239 using the switch @option{-gnatR} we obtain the following output:
12240
12241 @smallexample
12242 Representation information for unit q
12243 -------------------------------------
12244
12245 for r'Size use ??;
12246 for r'Alignment use 4;
12247 for r use record
12248 x at 4 range 0 .. 7;
12249 _tag at 0 range 0 .. 31;
12250 s at 5 range 0 .. 799;
12251 end record;
12252
12253 for r2'Size use 160;
12254 for r2'Alignment use 4;
12255 for r2 use record
12256 x at 4 range 0 .. 7;
12257 _tag at 0 range 0 .. 31;
12258 _parent at 0 range 0 .. 63;
12259 y2 at 16 range 0 .. 31;
12260 end record;
12261
12262 for x'Size use 8;
12263 for x'Alignment use 1;
12264 for x use record
12265 y at 0 range 0 .. 7;
12266 end record;
12267
12268 for x1'Size use 112;
12269 for x1'Alignment use 1;
12270 for x1'Component_Size use 11;
12271
12272 for rb1'Size use 13;
12273 for rb1'Alignment use 2;
12274 for rb1'Component_Size use 1;
12275
12276 for rb2'Size use 72;
12277 for rb2'Alignment use 1;
12278 for rb2'Component_Size use 1;
12279
12280 for x2'Size use 224;
12281 for x2'Alignment use 4;
12282 for x2 use record
12283 l1 at 0 range 0 .. 0;
12284 l2 at 0 range 1 .. 64;
12285 l3 at 12 range 0 .. 31;
12286 l4 at 16 range 0 .. 0;
12287 l5 at 16 range 1 .. 13;
12288 l6 at 18 range 0 .. 71;
12289 end record;
12290 @end smallexample
12291
12292 @noindent
12293 The Size values are actually the Object_Size, i.e.@: the default size that
12294 will be allocated for objects of the type.
12295 The ?? size for type r indicates that we have a variant record, and the
12296 actual size of objects will depend on the discriminant value.
12297
12298 The Alignment values show the actual alignment chosen by the compiler
12299 for each record or array type.
12300
12301 The record representation clause for type r shows where all fields
12302 are placed, including the compiler generated tag field (whose location
12303 cannot be controlled by the programmer).
12304
12305 The record representation clause for the type extension r2 shows all the
12306 fields present, including the parent field, which is a copy of the fields
12307 of the parent type of r2, i.e.@: r1.
12308
12309 The component size and size clauses for types rb1 and rb2 show
12310 the exact effect of pragma @code{Pack} on these arrays, and the record
12311 representation clause for type x2 shows how pragma @code{Pack} affects
12312 this record type.
12313
12314 In some cases, it may be useful to cut and paste the representation clauses
12315 generated by the compiler into the original source to fix and guarantee
12316 the actual representation to be used.
12317
12318 @node Standard Library Routines
12319 @chapter Standard Library Routines
12320
12321 @noindent
12322 The Ada Reference Manual contains in Annex A a full description of an
12323 extensive set of standard library routines that can be used in any Ada
12324 program, and which must be provided by all Ada compilers. They are
12325 analogous to the standard C library used by C programs.
12326
12327 GNAT implements all of the facilities described in annex A, and for most
12328 purposes the description in the Ada Reference Manual, or appropriate Ada
12329 text book, will be sufficient for making use of these facilities.
12330
12331 In the case of the input-output facilities,
12332 @xref{The Implementation of Standard I/O},
12333 gives details on exactly how GNAT interfaces to the
12334 file system. For the remaining packages, the Ada Reference Manual
12335 should be sufficient. The following is a list of the packages included,
12336 together with a brief description of the functionality that is provided.
12337
12338 For completeness, references are included to other predefined library
12339 routines defined in other sections of the Ada Reference Manual (these are
12340 cross-indexed from Annex A).
12341
12342 @table @code
12343 @item Ada (A.2)
12344 This is a parent package for all the standard library packages. It is
12345 usually included implicitly in your program, and itself contains no
12346 useful data or routines.
12347
12348 @item Ada.Calendar (9.6)
12349 @code{Calendar} provides time of day access, and routines for
12350 manipulating times and durations.
12351
12352 @item Ada.Characters (A.3.1)
12353 This is a dummy parent package that contains no useful entities
12354
12355 @item Ada.Characters.Handling (A.3.2)
12356 This package provides some basic character handling capabilities,
12357 including classification functions for classes of characters (e.g.@: test
12358 for letters, or digits).
12359
12360 @item Ada.Characters.Latin_1 (A.3.3)
12361 This package includes a complete set of definitions of the characters
12362 that appear in type CHARACTER@. It is useful for writing programs that
12363 will run in international environments. For example, if you want an
12364 upper case E with an acute accent in a string, it is often better to use
12365 the definition of @code{UC_E_Acute} in this package. Then your program
12366 will print in an understandable manner even if your environment does not
12367 support these extended characters.
12368
12369 @item Ada.Command_Line (A.15)
12370 This package provides access to the command line parameters and the name
12371 of the current program (analogous to the use of @code{argc} and @code{argv}
12372 in C), and also allows the exit status for the program to be set in a
12373 system-independent manner.
12374
12375 @item Ada.Decimal (F.2)
12376 This package provides constants describing the range of decimal numbers
12377 implemented, and also a decimal divide routine (analogous to the COBOL
12378 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12379
12380 @item Ada.Direct_IO (A.8.4)
12381 This package provides input-output using a model of a set of records of
12382 fixed-length, containing an arbitrary definite Ada type, indexed by an
12383 integer record number.
12384
12385 @item Ada.Dynamic_Priorities (D.5)
12386 This package allows the priorities of a task to be adjusted dynamically
12387 as the task is running.
12388
12389 @item Ada.Exceptions (11.4.1)
12390 This package provides additional information on exceptions, and also
12391 contains facilities for treating exceptions as data objects, and raising
12392 exceptions with associated messages.
12393
12394 @item Ada.Finalization (7.6)
12395 This package contains the declarations and subprograms to support the
12396 use of controlled types, providing for automatic initialization and
12397 finalization (analogous to the constructors and destructors of C++)
12398
12399 @item Ada.Interrupts (C.3.2)
12400 This package provides facilities for interfacing to interrupts, which
12401 includes the set of signals or conditions that can be raised and
12402 recognized as interrupts.
12403
12404 @item Ada.Interrupts.Names (C.3.2)
12405 This package provides the set of interrupt names (actually signal
12406 or condition names) that can be handled by GNAT@.
12407
12408 @item Ada.IO_Exceptions (A.13)
12409 This package defines the set of exceptions that can be raised by use of
12410 the standard IO packages.
12411
12412 @item Ada.Numerics
12413 This package contains some standard constants and exceptions used
12414 throughout the numerics packages. Note that the constants pi and e are
12415 defined here, and it is better to use these definitions than rolling
12416 your own.
12417
12418 @item Ada.Numerics.Complex_Elementary_Functions
12419 Provides the implementation of standard elementary functions (such as
12420 log and trigonometric functions) operating on complex numbers using the
12421 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12422 created by the package @code{Numerics.Complex_Types}.
12423
12424 @item Ada.Numerics.Complex_Types
12425 This is a predefined instantiation of
12426 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12427 build the type @code{Complex} and @code{Imaginary}.
12428
12429 @item Ada.Numerics.Discrete_Random
12430 This generic package provides a random number generator suitable for generating
12431 uniformly distributed values of a specified discrete subtype.
12432
12433 @item Ada.Numerics.Float_Random
12434 This package provides a random number generator suitable for generating
12435 uniformly distributed floating point values in the unit interval.
12436
12437 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12438 This is a generic version of the package that provides the
12439 implementation of standard elementary functions (such as log and
12440 trigonometric functions) for an arbitrary complex type.
12441
12442 The following predefined instantiations of this package are provided:
12443
12444 @table @code
12445 @item Short_Float
12446 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12447 @item Float
12448 @code{Ada.Numerics.Complex_Elementary_Functions}
12449 @item Long_Float
12450 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12451 @end table
12452
12453 @item Ada.Numerics.Generic_Complex_Types
12454 This is a generic package that allows the creation of complex types,
12455 with associated complex arithmetic operations.
12456
12457 The following predefined instantiations of this package exist
12458 @table @code
12459 @item Short_Float
12460 @code{Ada.Numerics.Short_Complex_Complex_Types}
12461 @item Float
12462 @code{Ada.Numerics.Complex_Complex_Types}
12463 @item Long_Float
12464 @code{Ada.Numerics.Long_Complex_Complex_Types}
12465 @end table
12466
12467 @item Ada.Numerics.Generic_Elementary_Functions
12468 This is a generic package that provides the implementation of standard
12469 elementary functions (such as log an trigonometric functions) for an
12470 arbitrary float type.
12471
12472 The following predefined instantiations of this package exist
12473
12474 @table @code
12475 @item Short_Float
12476 @code{Ada.Numerics.Short_Elementary_Functions}
12477 @item Float
12478 @code{Ada.Numerics.Elementary_Functions}
12479 @item Long_Float
12480 @code{Ada.Numerics.Long_Elementary_Functions}
12481 @end table
12482
12483 @item Ada.Real_Time (D.8)
12484 This package provides facilities similar to those of @code{Calendar}, but
12485 operating with a finer clock suitable for real time control. Note that
12486 annex D requires that there be no backward clock jumps, and GNAT generally
12487 guarantees this behavior, but of course if the external clock on which
12488 the GNAT runtime depends is deliberately reset by some external event,
12489 then such a backward jump may occur.
12490
12491 @item Ada.Sequential_IO (A.8.1)
12492 This package provides input-output facilities for sequential files,
12493 which can contain a sequence of values of a single type, which can be
12494 any Ada type, including indefinite (unconstrained) types.
12495
12496 @item Ada.Storage_IO (A.9)
12497 This package provides a facility for mapping arbitrary Ada types to and
12498 from a storage buffer. It is primarily intended for the creation of new
12499 IO packages.
12500
12501 @item Ada.Streams (13.13.1)
12502 This is a generic package that provides the basic support for the
12503 concept of streams as used by the stream attributes (@code{Input},
12504 @code{Output}, @code{Read} and @code{Write}).
12505
12506 @item Ada.Streams.Stream_IO (A.12.1)
12507 This package is a specialization of the type @code{Streams} defined in
12508 package @code{Streams} together with a set of operations providing
12509 Stream_IO capability. The Stream_IO model permits both random and
12510 sequential access to a file which can contain an arbitrary set of values
12511 of one or more Ada types.
12512
12513 @item Ada.Strings (A.4.1)
12514 This package provides some basic constants used by the string handling
12515 packages.
12516
12517 @item Ada.Strings.Bounded (A.4.4)
12518 This package provides facilities for handling variable length
12519 strings. The bounded model requires a maximum length. It is thus
12520 somewhat more limited than the unbounded model, but avoids the use of
12521 dynamic allocation or finalization.
12522
12523 @item Ada.Strings.Fixed (A.4.3)
12524 This package provides facilities for handling fixed length strings.
12525
12526 @item Ada.Strings.Maps (A.4.2)
12527 This package provides facilities for handling character mappings and
12528 arbitrarily defined subsets of characters. For instance it is useful in
12529 defining specialized translation tables.
12530
12531 @item Ada.Strings.Maps.Constants (A.4.6)
12532 This package provides a standard set of predefined mappings and
12533 predefined character sets. For example, the standard upper to lower case
12534 conversion table is found in this package. Note that upper to lower case
12535 conversion is non-trivial if you want to take the entire set of
12536 characters, including extended characters like E with an acute accent,
12537 into account. You should use the mappings in this package (rather than
12538 adding 32 yourself) to do case mappings.
12539
12540 @item Ada.Strings.Unbounded (A.4.5)
12541 This package provides facilities for handling variable length
12542 strings. The unbounded model allows arbitrary length strings, but
12543 requires the use of dynamic allocation and finalization.
12544
12545 @item Ada.Strings.Wide_Bounded (A.4.7)
12546 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12547 @itemx Ada.Strings.Wide_Maps (A.4.7)
12548 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12549 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12550 These packages provide analogous capabilities to the corresponding
12551 packages without @samp{Wide_} in the name, but operate with the types
12552 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12553 and @code{Character}.
12554
12555 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12556 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12557 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12558 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12559 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12560 These packages provide analogous capabilities to the corresponding
12561 packages without @samp{Wide_} in the name, but operate with the types
12562 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12563 of @code{String} and @code{Character}.
12564
12565 @item Ada.Synchronous_Task_Control (D.10)
12566 This package provides some standard facilities for controlling task
12567 communication in a synchronous manner.
12568
12569 @item Ada.Tags
12570 This package contains definitions for manipulation of the tags of tagged
12571 values.
12572
12573 @item Ada.Task_Attributes
12574 This package provides the capability of associating arbitrary
12575 task-specific data with separate tasks.
12576
12577 @item Ada.Text_IO
12578 This package provides basic text input-output capabilities for
12579 character, string and numeric data. The subpackages of this
12580 package are listed next.
12581
12582 @item Ada.Text_IO.Decimal_IO
12583 Provides input-output facilities for decimal fixed-point types
12584
12585 @item Ada.Text_IO.Enumeration_IO
12586 Provides input-output facilities for enumeration types.
12587
12588 @item Ada.Text_IO.Fixed_IO
12589 Provides input-output facilities for ordinary fixed-point types.
12590
12591 @item Ada.Text_IO.Float_IO
12592 Provides input-output facilities for float types. The following
12593 predefined instantiations of this generic package are available:
12594
12595 @table @code
12596 @item Short_Float
12597 @code{Short_Float_Text_IO}
12598 @item Float
12599 @code{Float_Text_IO}
12600 @item Long_Float
12601 @code{Long_Float_Text_IO}
12602 @end table
12603
12604 @item Ada.Text_IO.Integer_IO
12605 Provides input-output facilities for integer types. The following
12606 predefined instantiations of this generic package are available:
12607
12608 @table @code
12609 @item Short_Short_Integer
12610 @code{Ada.Short_Short_Integer_Text_IO}
12611 @item Short_Integer
12612 @code{Ada.Short_Integer_Text_IO}
12613 @item Integer
12614 @code{Ada.Integer_Text_IO}
12615 @item Long_Integer
12616 @code{Ada.Long_Integer_Text_IO}
12617 @item Long_Long_Integer
12618 @code{Ada.Long_Long_Integer_Text_IO}
12619 @end table
12620
12621 @item Ada.Text_IO.Modular_IO
12622 Provides input-output facilities for modular (unsigned) types
12623
12624 @item Ada.Text_IO.Complex_IO (G.1.3)
12625 This package provides basic text input-output capabilities for complex
12626 data.
12627
12628 @item Ada.Text_IO.Editing (F.3.3)
12629 This package contains routines for edited output, analogous to the use
12630 of pictures in COBOL@. The picture formats used by this package are a
12631 close copy of the facility in COBOL@.
12632
12633 @item Ada.Text_IO.Text_Streams (A.12.2)
12634 This package provides a facility that allows Text_IO files to be treated
12635 as streams, so that the stream attributes can be used for writing
12636 arbitrary data, including binary data, to Text_IO files.
12637
12638 @item Ada.Unchecked_Conversion (13.9)
12639 This generic package allows arbitrary conversion from one type to
12640 another of the same size, providing for breaking the type safety in
12641 special circumstances.
12642
12643 If the types have the same Size (more accurately the same Value_Size),
12644 then the effect is simply to transfer the bits from the source to the
12645 target type without any modification. This usage is well defined, and
12646 for simple types whose representation is typically the same across
12647 all implementations, gives a portable method of performing such
12648 conversions.
12649
12650 If the types do not have the same size, then the result is implementation
12651 defined, and thus may be non-portable. The following describes how GNAT
12652 handles such unchecked conversion cases.
12653
12654 If the types are of different sizes, and are both discrete types, then
12655 the effect is of a normal type conversion without any constraint checking.
12656 In particular if the result type has a larger size, the result will be
12657 zero or sign extended. If the result type has a smaller size, the result
12658 will be truncated by ignoring high order bits.
12659
12660 If the types are of different sizes, and are not both discrete types,
12661 then the conversion works as though pointers were created to the source
12662 and target, and the pointer value is converted. The effect is that bits
12663 are copied from successive low order storage units and bits of the source
12664 up to the length of the target type.
12665
12666 A warning is issued if the lengths differ, since the effect in this
12667 case is implementation dependent, and the above behavior may not match
12668 that of some other compiler.
12669
12670 A pointer to one type may be converted to a pointer to another type using
12671 unchecked conversion. The only case in which the effect is undefined is
12672 when one or both pointers are pointers to unconstrained array types. In
12673 this case, the bounds information may get incorrectly transferred, and in
12674 particular, GNAT uses double size pointers for such types, and it is
12675 meaningless to convert between such pointer types. GNAT will issue a
12676 warning if the alignment of the target designated type is more strict
12677 than the alignment of the source designated type (since the result may
12678 be unaligned in this case).
12679
12680 A pointer other than a pointer to an unconstrained array type may be
12681 converted to and from System.Address. Such usage is common in Ada 83
12682 programs, but note that Ada.Address_To_Access_Conversions is the
12683 preferred method of performing such conversions in Ada 95 and Ada 2005.
12684 Neither
12685 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12686 used in conjunction with pointers to unconstrained objects, since
12687 the bounds information cannot be handled correctly in this case.
12688
12689 @item Ada.Unchecked_Deallocation (13.11.2)
12690 This generic package allows explicit freeing of storage previously
12691 allocated by use of an allocator.
12692
12693 @item Ada.Wide_Text_IO (A.11)
12694 This package is similar to @code{Ada.Text_IO}, except that the external
12695 file supports wide character representations, and the internal types are
12696 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12697 and @code{String}. It contains generic subpackages listed next.
12698
12699 @item Ada.Wide_Text_IO.Decimal_IO
12700 Provides input-output facilities for decimal fixed-point types
12701
12702 @item Ada.Wide_Text_IO.Enumeration_IO
12703 Provides input-output facilities for enumeration types.
12704
12705 @item Ada.Wide_Text_IO.Fixed_IO
12706 Provides input-output facilities for ordinary fixed-point types.
12707
12708 @item Ada.Wide_Text_IO.Float_IO
12709 Provides input-output facilities for float types. The following
12710 predefined instantiations of this generic package are available:
12711
12712 @table @code
12713 @item Short_Float
12714 @code{Short_Float_Wide_Text_IO}
12715 @item Float
12716 @code{Float_Wide_Text_IO}
12717 @item Long_Float
12718 @code{Long_Float_Wide_Text_IO}
12719 @end table
12720
12721 @item Ada.Wide_Text_IO.Integer_IO
12722 Provides input-output facilities for integer types. The following
12723 predefined instantiations of this generic package are available:
12724
12725 @table @code
12726 @item Short_Short_Integer
12727 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12728 @item Short_Integer
12729 @code{Ada.Short_Integer_Wide_Text_IO}
12730 @item Integer
12731 @code{Ada.Integer_Wide_Text_IO}
12732 @item Long_Integer
12733 @code{Ada.Long_Integer_Wide_Text_IO}
12734 @item Long_Long_Integer
12735 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12736 @end table
12737
12738 @item Ada.Wide_Text_IO.Modular_IO
12739 Provides input-output facilities for modular (unsigned) types
12740
12741 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12742 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12743 external file supports wide character representations.
12744
12745 @item Ada.Wide_Text_IO.Editing (F.3.4)
12746 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12747 types are @code{Wide_Character} and @code{Wide_String} instead of
12748 @code{Character} and @code{String}.
12749
12750 @item Ada.Wide_Text_IO.Streams (A.12.3)
12751 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12752 types are @code{Wide_Character} and @code{Wide_String} instead of
12753 @code{Character} and @code{String}.
12754
12755 @item Ada.Wide_Wide_Text_IO (A.11)
12756 This package is similar to @code{Ada.Text_IO}, except that the external
12757 file supports wide character representations, and the internal types are
12758 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12759 and @code{String}. It contains generic subpackages listed next.
12760
12761 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12762 Provides input-output facilities for decimal fixed-point types
12763
12764 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12765 Provides input-output facilities for enumeration types.
12766
12767 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12768 Provides input-output facilities for ordinary fixed-point types.
12769
12770 @item Ada.Wide_Wide_Text_IO.Float_IO
12771 Provides input-output facilities for float types. The following
12772 predefined instantiations of this generic package are available:
12773
12774 @table @code
12775 @item Short_Float
12776 @code{Short_Float_Wide_Wide_Text_IO}
12777 @item Float
12778 @code{Float_Wide_Wide_Text_IO}
12779 @item Long_Float
12780 @code{Long_Float_Wide_Wide_Text_IO}
12781 @end table
12782
12783 @item Ada.Wide_Wide_Text_IO.Integer_IO
12784 Provides input-output facilities for integer types. The following
12785 predefined instantiations of this generic package are available:
12786
12787 @table @code
12788 @item Short_Short_Integer
12789 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12790 @item Short_Integer
12791 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12792 @item Integer
12793 @code{Ada.Integer_Wide_Wide_Text_IO}
12794 @item Long_Integer
12795 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12796 @item Long_Long_Integer
12797 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12798 @end table
12799
12800 @item Ada.Wide_Wide_Text_IO.Modular_IO
12801 Provides input-output facilities for modular (unsigned) types
12802
12803 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12804 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12805 external file supports wide character representations.
12806
12807 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12808 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12809 types are @code{Wide_Character} and @code{Wide_String} instead of
12810 @code{Character} and @code{String}.
12811
12812 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12813 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12814 types are @code{Wide_Character} and @code{Wide_String} instead of
12815 @code{Character} and @code{String}.
12816 @end table
12817
12818 @node The Implementation of Standard I/O
12819 @chapter The Implementation of Standard I/O
12820
12821 @noindent
12822 GNAT implements all the required input-output facilities described in
12823 A.6 through A.14. These sections of the Ada Reference Manual describe the
12824 required behavior of these packages from the Ada point of view, and if
12825 you are writing a portable Ada program that does not need to know the
12826 exact manner in which Ada maps to the outside world when it comes to
12827 reading or writing external files, then you do not need to read this
12828 chapter. As long as your files are all regular files (not pipes or
12829 devices), and as long as you write and read the files only from Ada, the
12830 description in the Ada Reference Manual is sufficient.
12831
12832 However, if you want to do input-output to pipes or other devices, such
12833 as the keyboard or screen, or if the files you are dealing with are
12834 either generated by some other language, or to be read by some other
12835 language, then you need to know more about the details of how the GNAT
12836 implementation of these input-output facilities behaves.
12837
12838 In this chapter we give a detailed description of exactly how GNAT
12839 interfaces to the file system. As always, the sources of the system are
12840 available to you for answering questions at an even more detailed level,
12841 but for most purposes the information in this chapter will suffice.
12842
12843 Another reason that you may need to know more about how input-output is
12844 implemented arises when you have a program written in mixed languages
12845 where, for example, files are shared between the C and Ada sections of
12846 the same program. GNAT provides some additional facilities, in the form
12847 of additional child library packages, that facilitate this sharing, and
12848 these additional facilities are also described in this chapter.
12849
12850 @menu
12851 * Standard I/O Packages::
12852 * FORM Strings::
12853 * Direct_IO::
12854 * Sequential_IO::
12855 * Text_IO::
12856 * Wide_Text_IO::
12857 * Wide_Wide_Text_IO::
12858 * Stream_IO::
12859 * Text Translation::
12860 * Shared Files::
12861 * Filenames encoding::
12862 * Open Modes::
12863 * Operations on C Streams::
12864 * Interfacing to C Streams::
12865 @end menu
12866
12867 @node Standard I/O Packages
12868 @section Standard I/O Packages
12869
12870 @noindent
12871 The Standard I/O packages described in Annex A for
12872
12873 @itemize @bullet
12874 @item
12875 Ada.Text_IO
12876 @item
12877 Ada.Text_IO.Complex_IO
12878 @item
12879 Ada.Text_IO.Text_Streams
12880 @item
12881 Ada.Wide_Text_IO
12882 @item
12883 Ada.Wide_Text_IO.Complex_IO
12884 @item
12885 Ada.Wide_Text_IO.Text_Streams
12886 @item
12887 Ada.Wide_Wide_Text_IO
12888 @item
12889 Ada.Wide_Wide_Text_IO.Complex_IO
12890 @item
12891 Ada.Wide_Wide_Text_IO.Text_Streams
12892 @item
12893 Ada.Stream_IO
12894 @item
12895 Ada.Sequential_IO
12896 @item
12897 Ada.Direct_IO
12898 @end itemize
12899
12900 @noindent
12901 are implemented using the C
12902 library streams facility; where
12903
12904 @itemize @bullet
12905 @item
12906 All files are opened using @code{fopen}.
12907 @item
12908 All input/output operations use @code{fread}/@code{fwrite}.
12909 @end itemize
12910
12911 @noindent
12912 There is no internal buffering of any kind at the Ada library level. The only
12913 buffering is that provided at the system level in the implementation of the
12914 library routines that support streams. This facilitates shared use of these
12915 streams by mixed language programs. Note though that system level buffering is
12916 explicitly enabled at elaboration of the standard I/O packages and that can
12917 have an impact on mixed language programs, in particular those using I/O before
12918 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12919 the Ada elaboration routine before performing any I/O or when impractical,
12920 flush the common I/O streams and in particular Standard_Output before
12921 elaborating the Ada code.
12922
12923 @node FORM Strings
12924 @section FORM Strings
12925
12926 @noindent
12927 The format of a FORM string in GNAT is:
12928
12929 @smallexample
12930 "keyword=value,keyword=value,@dots{},keyword=value"
12931 @end smallexample
12932
12933 @noindent
12934 where letters may be in upper or lower case, and there are no spaces
12935 between values. The order of the entries is not important. Currently
12936 the following keywords defined.
12937
12938 @smallexample
12939 TEXT_TRANSLATION=[YES|NO]
12940 SHARED=[YES|NO]
12941 WCEM=[n|h|u|s|e|8|b]
12942 ENCODING=[UTF8|8BITS]
12943 @end smallexample
12944
12945 @noindent
12946 The use of these parameters is described later in this section.
12947
12948 @node Direct_IO
12949 @section Direct_IO
12950
12951 @noindent
12952 Direct_IO can only be instantiated for definite types. This is a
12953 restriction of the Ada language, which means that the records are fixed
12954 length (the length being determined by @code{@var{type}'Size}, rounded
12955 up to the next storage unit boundary if necessary).
12956
12957 The records of a Direct_IO file are simply written to the file in index
12958 sequence, with the first record starting at offset zero, and subsequent
12959 records following. There is no control information of any kind. For
12960 example, if 32-bit integers are being written, each record takes
12961 4-bytes, so the record at index @var{K} starts at offset
12962 (@var{K}@minus{}1)*4.
12963
12964 There is no limit on the size of Direct_IO files, they are expanded as
12965 necessary to accommodate whatever records are written to the file.
12966
12967 @node Sequential_IO
12968 @section Sequential_IO
12969
12970 @noindent
12971 Sequential_IO may be instantiated with either a definite (constrained)
12972 or indefinite (unconstrained) type.
12973
12974 For the definite type case, the elements written to the file are simply
12975 the memory images of the data values with no control information of any
12976 kind. The resulting file should be read using the same type, no validity
12977 checking is performed on input.
12978
12979 For the indefinite type case, the elements written consist of two
12980 parts. First is the size of the data item, written as the memory image
12981 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12982 the data value. The resulting file can only be read using the same
12983 (unconstrained) type. Normal assignment checks are performed on these
12984 read operations, and if these checks fail, @code{Data_Error} is
12985 raised. In particular, in the array case, the lengths must match, and in
12986 the variant record case, if the variable for a particular read operation
12987 is constrained, the discriminants must match.
12988
12989 Note that it is not possible to use Sequential_IO to write variable
12990 length array items, and then read the data back into different length
12991 arrays. For example, the following will raise @code{Data_Error}:
12992
12993 @smallexample @c ada
12994 package IO is new Sequential_IO (String);
12995 F : IO.File_Type;
12996 S : String (1..4);
12997 @dots{}
12998 IO.Create (F)
12999 IO.Write (F, "hello!")
13000 IO.Reset (F, Mode=>In_File);
13001 IO.Read (F, S);
13002 Put_Line (S);
13003
13004 @end smallexample
13005
13006 @noindent
13007 On some Ada implementations, this will print @code{hell}, but the program is
13008 clearly incorrect, since there is only one element in the file, and that
13009 element is the string @code{hello!}.
13010
13011 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13012 using Stream_IO, and this is the preferred mechanism. In particular, the
13013 above program fragment rewritten to use Stream_IO will work correctly.
13014
13015 @node Text_IO
13016 @section Text_IO
13017
13018 @noindent
13019 Text_IO files consist of a stream of characters containing the following
13020 special control characters:
13021
13022 @smallexample
13023 LF (line feed, 16#0A#) Line Mark
13024 FF (form feed, 16#0C#) Page Mark
13025 @end smallexample
13026
13027 @noindent
13028 A canonical Text_IO file is defined as one in which the following
13029 conditions are met:
13030
13031 @itemize @bullet
13032 @item
13033 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13034 of the line.
13035
13036 @item
13037 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13038 end of a page and consequently can appear only immediately following a
13039 @code{LF} (line mark) character.
13040
13041 @item
13042 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13043 (line mark, page mark). In the former case, the page mark is implicitly
13044 assumed to be present.
13045 @end itemize
13046
13047 @noindent
13048 A file written using Text_IO will be in canonical form provided that no
13049 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13050 or @code{Put_Line}. There will be no @code{FF} character at the end of
13051 the file unless an explicit @code{New_Page} operation was performed
13052 before closing the file.
13053
13054 A canonical Text_IO file that is a regular file (i.e., not a device or a
13055 pipe) can be read using any of the routines in Text_IO@. The
13056 semantics in this case will be exactly as defined in the Ada Reference
13057 Manual, and all the routines in Text_IO are fully implemented.
13058
13059 A text file that does not meet the requirements for a canonical Text_IO
13060 file has one of the following:
13061
13062 @itemize @bullet
13063 @item
13064 The file contains @code{FF} characters not immediately following a
13065 @code{LF} character.
13066
13067 @item
13068 The file contains @code{LF} or @code{FF} characters written by
13069 @code{Put} or @code{Put_Line}, which are not logically considered to be
13070 line marks or page marks.
13071
13072 @item
13073 The file ends in a character other than @code{LF} or @code{FF},
13074 i.e.@: there is no explicit line mark or page mark at the end of the file.
13075 @end itemize
13076
13077 @noindent
13078 Text_IO can be used to read such non-standard text files but subprograms
13079 to do with line or page numbers do not have defined meanings. In
13080 particular, a @code{FF} character that does not follow a @code{LF}
13081 character may or may not be treated as a page mark from the point of
13082 view of page and line numbering. Every @code{LF} character is considered
13083 to end a line, and there is an implied @code{LF} character at the end of
13084 the file.
13085
13086 @menu
13087 * Text_IO Stream Pointer Positioning::
13088 * Text_IO Reading and Writing Non-Regular Files::
13089 * Get_Immediate::
13090 * Treating Text_IO Files as Streams::
13091 * Text_IO Extensions::
13092 * Text_IO Facilities for Unbounded Strings::
13093 @end menu
13094
13095 @node Text_IO Stream Pointer Positioning
13096 @subsection Stream Pointer Positioning
13097
13098 @noindent
13099 @code{Ada.Text_IO} has a definition of current position for a file that
13100 is being read. No internal buffering occurs in Text_IO, and usually the
13101 physical position in the stream used to implement the file corresponds
13102 to this logical position defined by Text_IO@. There are two exceptions:
13103
13104 @itemize @bullet
13105 @item
13106 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13107 is positioned past the @code{LF} (line mark) that precedes the page
13108 mark. Text_IO maintains an internal flag so that subsequent read
13109 operations properly handle the logical position which is unchanged by
13110 the @code{End_Of_Page} call.
13111
13112 @item
13113 After a call to @code{End_Of_File} that returns @code{True}, if the
13114 Text_IO file was positioned before the line mark at the end of file
13115 before the call, then the logical position is unchanged, but the stream
13116 is physically positioned right at the end of file (past the line mark,
13117 and past a possible page mark following the line mark. Again Text_IO
13118 maintains internal flags so that subsequent read operations properly
13119 handle the logical position.
13120 @end itemize
13121
13122 @noindent
13123 These discrepancies have no effect on the observable behavior of
13124 Text_IO, but if a single Ada stream is shared between a C program and
13125 Ada program, or shared (using @samp{shared=yes} in the form string)
13126 between two Ada files, then the difference may be observable in some
13127 situations.
13128
13129 @node Text_IO Reading and Writing Non-Regular Files
13130 @subsection Reading and Writing Non-Regular Files
13131
13132 @noindent
13133 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13134 can be used for reading and writing. Writing is not affected and the
13135 sequence of characters output is identical to the normal file case, but
13136 for reading, the behavior of Text_IO is modified to avoid undesirable
13137 look-ahead as follows:
13138
13139 An input file that is not a regular file is considered to have no page
13140 marks. Any @code{Ascii.FF} characters (the character normally used for a
13141 page mark) appearing in the file are considered to be data
13142 characters. In particular:
13143
13144 @itemize @bullet
13145 @item
13146 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13147 following a line mark. If a page mark appears, it will be treated as a
13148 data character.
13149
13150 @item
13151 This avoids the need to wait for an extra character to be typed or
13152 entered from the pipe to complete one of these operations.
13153
13154 @item
13155 @code{End_Of_Page} always returns @code{False}
13156
13157 @item
13158 @code{End_Of_File} will return @code{False} if there is a page mark at
13159 the end of the file.
13160 @end itemize
13161
13162 @noindent
13163 Output to non-regular files is the same as for regular files. Page marks
13164 may be written to non-regular files using @code{New_Page}, but as noted
13165 above they will not be treated as page marks on input if the output is
13166 piped to another Ada program.
13167
13168 Another important discrepancy when reading non-regular files is that the end
13169 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13170 pressing the @key{EOT} key,
13171 then end of file
13172 is signaled once (i.e.@: the test @code{End_Of_File}
13173 will yield @code{True}, or a read will
13174 raise @code{End_Error}), but then reading can resume
13175 to read data past that end of
13176 file indication, until another end of file indication is entered.
13177
13178 @node Get_Immediate
13179 @subsection Get_Immediate
13180 @cindex Get_Immediate
13181
13182 @noindent
13183 Get_Immediate returns the next character (including control characters)
13184 from the input file. In particular, Get_Immediate will return LF or FF
13185 characters used as line marks or page marks. Such operations leave the
13186 file positioned past the control character, and it is thus not treated
13187 as having its normal function. This means that page, line and column
13188 counts after this kind of Get_Immediate call are set as though the mark
13189 did not occur. In the case where a Get_Immediate leaves the file
13190 positioned between the line mark and page mark (which is not normally
13191 possible), it is undefined whether the FF character will be treated as a
13192 page mark.
13193
13194 @node Treating Text_IO Files as Streams
13195 @subsection Treating Text_IO Files as Streams
13196 @cindex Stream files
13197
13198 @noindent
13199 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13200 as a stream. Data written to a Text_IO file in this stream mode is
13201 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13202 16#0C# (@code{FF}), the resulting file may have non-standard
13203 format. Similarly if read operations are used to read from a Text_IO
13204 file treated as a stream, then @code{LF} and @code{FF} characters may be
13205 skipped and the effect is similar to that described above for
13206 @code{Get_Immediate}.
13207
13208 @node Text_IO Extensions
13209 @subsection Text_IO Extensions
13210 @cindex Text_IO extensions
13211
13212 @noindent
13213 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13214 to the standard @code{Text_IO} package:
13215
13216 @itemize @bullet
13217 @item function File_Exists (Name : String) return Boolean;
13218 Determines if a file of the given name exists.
13219
13220 @item function Get_Line return String;
13221 Reads a string from the standard input file. The value returned is exactly
13222 the length of the line that was read.
13223
13224 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13225 Similar, except that the parameter File specifies the file from which
13226 the string is to be read.
13227
13228 @end itemize
13229
13230 @node Text_IO Facilities for Unbounded Strings
13231 @subsection Text_IO Facilities for Unbounded Strings
13232 @cindex Text_IO for unbounded strings
13233 @cindex Unbounded_String, Text_IO operations
13234
13235 @noindent
13236 The package @code{Ada.Strings.Unbounded.Text_IO}
13237 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13238 subprograms useful for Text_IO operations on unbounded strings:
13239
13240 @itemize @bullet
13241
13242 @item function Get_Line (File : File_Type) return Unbounded_String;
13243 Reads a line from the specified file
13244 and returns the result as an unbounded string.
13245
13246 @item procedure Put (File : File_Type; U : Unbounded_String);
13247 Writes the value of the given unbounded string to the specified file
13248 Similar to the effect of
13249 @code{Put (To_String (U))} except that an extra copy is avoided.
13250
13251 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13252 Writes the value of the given unbounded string to the specified file,
13253 followed by a @code{New_Line}.
13254 Similar to the effect of @code{Put_Line (To_String (U))} except
13255 that an extra copy is avoided.
13256 @end itemize
13257
13258 @noindent
13259 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13260 and is optional. If the parameter is omitted, then the standard input or
13261 output file is referenced as appropriate.
13262
13263 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13264 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13265 @code{Wide_Text_IO} functionality for unbounded wide strings.
13266
13267 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13268 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13269 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13270
13271 @node Wide_Text_IO
13272 @section Wide_Text_IO
13273
13274 @noindent
13275 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13276 both input and output files may contain special sequences that represent
13277 wide character values. The encoding scheme for a given file may be
13278 specified using a FORM parameter:
13279
13280 @smallexample
13281 WCEM=@var{x}
13282 @end smallexample
13283
13284 @noindent
13285 as part of the FORM string (WCEM = wide character encoding method),
13286 where @var{x} is one of the following characters
13287
13288 @table @samp
13289 @item h
13290 Hex ESC encoding
13291 @item u
13292 Upper half encoding
13293 @item s
13294 Shift-JIS encoding
13295 @item e
13296 EUC Encoding
13297 @item 8
13298 UTF-8 encoding
13299 @item b
13300 Brackets encoding
13301 @end table
13302
13303 @noindent
13304 The encoding methods match those that
13305 can be used in a source
13306 program, but there is no requirement that the encoding method used for
13307 the source program be the same as the encoding method used for files,
13308 and different files may use different encoding methods.
13309
13310 The default encoding method for the standard files, and for opened files
13311 for which no WCEM parameter is given in the FORM string matches the
13312 wide character encoding specified for the main program (the default
13313 being brackets encoding if no coding method was specified with -gnatW).
13314
13315 @table @asis
13316 @item Hex Coding
13317 In this encoding, a wide character is represented by a five character
13318 sequence:
13319
13320 @smallexample
13321 ESC a b c d
13322 @end smallexample
13323
13324 @noindent
13325 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13326 characters (using upper case letters) of the wide character code. For
13327 example, ESC A345 is used to represent the wide character with code
13328 16#A345#. This scheme is compatible with use of the full
13329 @code{Wide_Character} set.
13330
13331 @item Upper Half Coding
13332 The wide character with encoding 16#abcd#, where the upper bit is on
13333 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13334 16#cd#. The second byte may never be a format control character, but is
13335 not required to be in the upper half. This method can be also used for
13336 shift-JIS or EUC where the internal coding matches the external coding.
13337
13338 @item Shift JIS Coding
13339 A wide character is represented by a two character sequence 16#ab# and
13340 16#cd#, with the restrictions described for upper half encoding as
13341 described above. The internal character code is the corresponding JIS
13342 character according to the standard algorithm for Shift-JIS
13343 conversion. Only characters defined in the JIS code set table can be
13344 used with this encoding method.
13345
13346 @item EUC Coding
13347 A wide character is represented by a two character sequence 16#ab# and
13348 16#cd#, with both characters being in the upper half. The internal
13349 character code is the corresponding JIS character according to the EUC
13350 encoding algorithm. Only characters defined in the JIS code set table
13351 can be used with this encoding method.
13352
13353 @item UTF-8 Coding
13354 A wide character is represented using
13355 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13356 10646-1/Am.2. Depending on the character value, the representation
13357 is a one, two, or three byte sequence:
13358
13359 @smallexample
13360 16#0000#-16#007f#: 2#0xxxxxxx#
13361 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13362 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13363 @end smallexample
13364
13365 @noindent
13366 where the @var{xxx} bits correspond to the left-padded bits of the
13367 16-bit character value. Note that all lower half ASCII characters
13368 are represented as ASCII bytes and all upper half characters and
13369 other wide characters are represented as sequences of upper-half
13370 (The full UTF-8 scheme allows for encoding 31-bit characters as
13371 6-byte sequences, but in this implementation, all UTF-8 sequences
13372 of four or more bytes length will raise a Constraint_Error, as
13373 will all invalid UTF-8 sequences.)
13374
13375 @item Brackets Coding
13376 In this encoding, a wide character is represented by the following eight
13377 character sequence:
13378
13379 @smallexample
13380 [ " a b c d " ]
13381 @end smallexample
13382
13383 @noindent
13384 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13385 characters (using uppercase letters) of the wide character code. For
13386 example, @code{["A345"]} is used to represent the wide character with code
13387 @code{16#A345#}.
13388 This scheme is compatible with use of the full Wide_Character set.
13389 On input, brackets coding can also be used for upper half characters,
13390 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13391 is only used for wide characters with a code greater than @code{16#FF#}.
13392
13393 Note that brackets coding is not normally used in the context of
13394 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13395 a portable way of encoding source files. In the context of Wide_Text_IO
13396 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13397 any instance of the left bracket character other than to encode wide
13398 character values using the brackets encoding method. In practice it is
13399 expected that some standard wide character encoding method such
13400 as UTF-8 will be used for text input output.
13401
13402 If brackets notation is used, then any occurrence of a left bracket
13403 in the input file which is not the start of a valid wide character
13404 sequence will cause Constraint_Error to be raised. It is possible to
13405 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13406 input will interpret this as a left bracket.
13407
13408 However, when a left bracket is output, it will be output as a left bracket
13409 and not as ["5B"]. We make this decision because for normal use of
13410 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13411 brackets. For example, if we write:
13412
13413 @smallexample
13414 Put_Line ("Start of output [first run]");
13415 @end smallexample
13416
13417 @noindent
13418 we really do not want to have the left bracket in this message clobbered so
13419 that the output reads:
13420
13421 @smallexample
13422 Start of output ["5B"]first run]
13423 @end smallexample
13424
13425 @noindent
13426 In practice brackets encoding is reasonably useful for normal Put_Line use
13427 since we won't get confused between left brackets and wide character
13428 sequences in the output. But for input, or when files are written out
13429 and read back in, it really makes better sense to use one of the standard
13430 encoding methods such as UTF-8.
13431
13432 @end table
13433
13434 @noindent
13435 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13436 not all wide character
13437 values can be represented. An attempt to output a character that cannot
13438 be represented using the encoding scheme for the file causes
13439 Constraint_Error to be raised. An invalid wide character sequence on
13440 input also causes Constraint_Error to be raised.
13441
13442 @menu
13443 * Wide_Text_IO Stream Pointer Positioning::
13444 * Wide_Text_IO Reading and Writing Non-Regular Files::
13445 @end menu
13446
13447 @node Wide_Text_IO Stream Pointer Positioning
13448 @subsection Stream Pointer Positioning
13449
13450 @noindent
13451 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13452 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13453 case:
13454
13455 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13456 normal lower ASCII set (i.e.@: a character in the range:
13457
13458 @smallexample @c ada
13459 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13460 @end smallexample
13461
13462 @noindent
13463 then although the logical position of the file pointer is unchanged by
13464 the @code{Look_Ahead} call, the stream is physically positioned past the
13465 wide character sequence. Again this is to avoid the need for buffering
13466 or backup, and all @code{Wide_Text_IO} routines check the internal
13467 indication that this situation has occurred so that this is not visible
13468 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
13469 can be observed if the wide text file shares a stream with another file.
13470
13471 @node Wide_Text_IO Reading and Writing Non-Regular Files
13472 @subsection Reading and Writing Non-Regular Files
13473
13474 @noindent
13475 As in the case of Text_IO, when a non-regular file is read, it is
13476 assumed that the file contains no page marks (any form characters are
13477 treated as data characters), and @code{End_Of_Page} always returns
13478 @code{False}. Similarly, the end of file indication is not sticky, so
13479 it is possible to read beyond an end of file.
13480
13481 @node Wide_Wide_Text_IO
13482 @section Wide_Wide_Text_IO
13483
13484 @noindent
13485 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13486 both input and output files may contain special sequences that represent
13487 wide wide character values. The encoding scheme for a given file may be
13488 specified using a FORM parameter:
13489
13490 @smallexample
13491 WCEM=@var{x}
13492 @end smallexample
13493
13494 @noindent
13495 as part of the FORM string (WCEM = wide character encoding method),
13496 where @var{x} is one of the following characters
13497
13498 @table @samp
13499 @item h
13500 Hex ESC encoding
13501 @item u
13502 Upper half encoding
13503 @item s
13504 Shift-JIS encoding
13505 @item e
13506 EUC Encoding
13507 @item 8
13508 UTF-8 encoding
13509 @item b
13510 Brackets encoding
13511 @end table
13512
13513 @noindent
13514 The encoding methods match those that
13515 can be used in a source
13516 program, but there is no requirement that the encoding method used for
13517 the source program be the same as the encoding method used for files,
13518 and different files may use different encoding methods.
13519
13520 The default encoding method for the standard files, and for opened files
13521 for which no WCEM parameter is given in the FORM string matches the
13522 wide character encoding specified for the main program (the default
13523 being brackets encoding if no coding method was specified with -gnatW).
13524
13525 @table @asis
13526
13527 @item UTF-8 Coding
13528 A wide character is represented using
13529 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13530 10646-1/Am.2. Depending on the character value, the representation
13531 is a one, two, three, or four byte sequence:
13532
13533 @smallexample
13534 16#000000#-16#00007f#: 2#0xxxxxxx#
13535 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13536 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13537 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13538 @end smallexample
13539
13540 @noindent
13541 where the @var{xxx} bits correspond to the left-padded bits of the
13542 21-bit character value. Note that all lower half ASCII characters
13543 are represented as ASCII bytes and all upper half characters and
13544 other wide characters are represented as sequences of upper-half
13545 characters.
13546
13547 @item Brackets Coding
13548 In this encoding, a wide wide character is represented by the following eight
13549 character sequence if is in wide character range
13550
13551 @smallexample
13552 [ " a b c d " ]
13553 @end smallexample
13554
13555 and by the following ten character sequence if not
13556
13557 @smallexample
13558 [ " a b c d e f " ]
13559 @end smallexample
13560
13561 @noindent
13562 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13563 are the four or six hexadecimal
13564 characters (using uppercase letters) of the wide wide character code. For
13565 example, @code{["01A345"]} is used to represent the wide wide character
13566 with code @code{16#01A345#}.
13567
13568 This scheme is compatible with use of the full Wide_Wide_Character set.
13569 On input, brackets coding can also be used for upper half characters,
13570 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
13571 is only used for wide characters with a code greater than @code{16#FF#}.
13572
13573 @end table
13574
13575 @noindent
13576 If is also possible to use the other Wide_Character encoding methods,
13577 such as Shift-JIS, but the other schemes cannot support the full range
13578 of wide wide characters.
13579 An attempt to output a character that cannot
13580 be represented using the encoding scheme for the file causes
13581 Constraint_Error to be raised. An invalid wide character sequence on
13582 input also causes Constraint_Error to be raised.
13583
13584 @menu
13585 * Wide_Wide_Text_IO Stream Pointer Positioning::
13586 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13587 @end menu
13588
13589 @node Wide_Wide_Text_IO Stream Pointer Positioning
13590 @subsection Stream Pointer Positioning
13591
13592 @noindent
13593 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13594 of stream pointer positioning (@pxref{Text_IO}). There is one additional
13595 case:
13596
13597 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13598 normal lower ASCII set (i.e.@: a character in the range:
13599
13600 @smallexample @c ada
13601 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13602 @end smallexample
13603
13604 @noindent
13605 then although the logical position of the file pointer is unchanged by
13606 the @code{Look_Ahead} call, the stream is physically positioned past the
13607 wide character sequence. Again this is to avoid the need for buffering
13608 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13609 indication that this situation has occurred so that this is not visible
13610 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
13611 can be observed if the wide text file shares a stream with another file.
13612
13613 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13614 @subsection Reading and Writing Non-Regular Files
13615
13616 @noindent
13617 As in the case of Text_IO, when a non-regular file is read, it is
13618 assumed that the file contains no page marks (any form characters are
13619 treated as data characters), and @code{End_Of_Page} always returns
13620 @code{False}. Similarly, the end of file indication is not sticky, so
13621 it is possible to read beyond an end of file.
13622
13623 @node Stream_IO
13624 @section Stream_IO
13625
13626 @noindent
13627 A stream file is a sequence of bytes, where individual elements are
13628 written to the file as described in the Ada Reference Manual. The type
13629 @code{Stream_Element} is simply a byte. There are two ways to read or
13630 write a stream file.
13631
13632 @itemize @bullet
13633 @item
13634 The operations @code{Read} and @code{Write} directly read or write a
13635 sequence of stream elements with no control information.
13636
13637 @item
13638 The stream attributes applied to a stream file transfer data in the
13639 manner described for stream attributes.
13640 @end itemize
13641
13642 @node Text Translation
13643 @section Text Translation
13644
13645 @noindent
13646 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13647 passed to Text_IO.Create and Text_IO.Open:
13648 @samp{Text_Translation=@var{Yes}} is the default, which means to
13649 translate LF to/from CR/LF on Windows systems.
13650 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13651 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13652 may be used to create Unix-style files on
13653 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13654 systems.
13655
13656 @node Shared Files
13657 @section Shared Files
13658
13659 @noindent
13660 Section A.14 of the Ada Reference Manual allows implementations to
13661 provide a wide variety of behavior if an attempt is made to access the
13662 same external file with two or more internal files.
13663
13664 To provide a full range of functionality, while at the same time
13665 minimizing the problems of portability caused by this implementation
13666 dependence, GNAT handles file sharing as follows:
13667
13668 @itemize @bullet
13669 @item
13670 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13671 to open two or more files with the same full name is considered an error
13672 and is not supported. The exception @code{Use_Error} will be
13673 raised. Note that a file that is not explicitly closed by the program
13674 remains open until the program terminates.
13675
13676 @item
13677 If the form parameter @samp{shared=no} appears in the form string, the
13678 file can be opened or created with its own separate stream identifier,
13679 regardless of whether other files sharing the same external file are
13680 opened. The exact effect depends on how the C stream routines handle
13681 multiple accesses to the same external files using separate streams.
13682
13683 @item
13684 If the form parameter @samp{shared=yes} appears in the form string for
13685 each of two or more files opened using the same full name, the same
13686 stream is shared between these files, and the semantics are as described
13687 in Ada Reference Manual, Section A.14.
13688 @end itemize
13689
13690 @noindent
13691 When a program that opens multiple files with the same name is ported
13692 from another Ada compiler to GNAT, the effect will be that
13693 @code{Use_Error} is raised.
13694
13695 The documentation of the original compiler and the documentation of the
13696 program should then be examined to determine if file sharing was
13697 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13698 and @code{Create} calls as required.
13699
13700 When a program is ported from GNAT to some other Ada compiler, no
13701 special attention is required unless the @samp{shared=@var{xxx}} form
13702 parameter is used in the program. In this case, you must examine the
13703 documentation of the new compiler to see if it supports the required
13704 file sharing semantics, and form strings modified appropriately. Of
13705 course it may be the case that the program cannot be ported if the
13706 target compiler does not support the required functionality. The best
13707 approach in writing portable code is to avoid file sharing (and hence
13708 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13709 completely.
13710
13711 One common use of file sharing in Ada 83 is the use of instantiations of
13712 Sequential_IO on the same file with different types, to achieve
13713 heterogeneous input-output. Although this approach will work in GNAT if
13714 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13715 for this purpose (using the stream attributes)
13716
13717 @node Filenames encoding
13718 @section Filenames encoding
13719
13720 @noindent
13721 An encoding form parameter can be used to specify the filename
13722 encoding @samp{encoding=@var{xxx}}.
13723
13724 @itemize @bullet
13725 @item
13726 If the form parameter @samp{encoding=utf8} appears in the form string, the
13727 filename must be encoded in UTF-8.
13728
13729 @item
13730 If the form parameter @samp{encoding=8bits} appears in the form
13731 string, the filename must be a standard 8bits string.
13732 @end itemize
13733
13734 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13735 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13736 variable. And if not set @samp{utf8} is assumed.
13737
13738 @table @samp
13739 @item CP_ACP
13740 The current system Windows ANSI code page.
13741 @item CP_UTF8
13742 UTF-8 encoding
13743 @end table
13744
13745 This encoding form parameter is only supported on the Windows
13746 platform. On the other Operating Systems the run-time is supporting
13747 UTF-8 natively.
13748
13749 @node Open Modes
13750 @section Open Modes
13751
13752 @noindent
13753 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13754 using the mode shown in the following table:
13755
13756 @sp 2
13757 @center @code{Open} and @code{Create} Call Modes
13758 @smallexample
13759 @b{OPEN } @b{CREATE}
13760 Append_File "r+" "w+"
13761 In_File "r" "w+"
13762 Out_File (Direct_IO) "r+" "w"
13763 Out_File (all other cases) "w" "w"
13764 Inout_File "r+" "w+"
13765 @end smallexample
13766
13767 @noindent
13768 If text file translation is required, then either @samp{b} or @samp{t}
13769 is added to the mode, depending on the setting of Text. Text file
13770 translation refers to the mapping of CR/LF sequences in an external file
13771 to LF characters internally. This mapping only occurs in DOS and
13772 DOS-like systems, and is not relevant to other systems.
13773
13774 A special case occurs with Stream_IO@. As shown in the above table, the
13775 file is initially opened in @samp{r} or @samp{w} mode for the
13776 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
13777 subsequently requires switching from reading to writing or vice-versa,
13778 then the file is reopened in @samp{r+} mode to permit the required operation.
13779
13780 @node Operations on C Streams
13781 @section Operations on C Streams
13782 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13783 access to the C library functions for operations on C streams:
13784
13785 @smallexample @c adanocomment
13786 package Interfaces.C_Streams is
13787 -- Note: the reason we do not use the types that are in
13788 -- Interfaces.C is that we want to avoid dragging in the
13789 -- code in this unit if possible.
13790 subtype chars is System.Address;
13791 -- Pointer to null-terminated array of characters
13792 subtype FILEs is System.Address;
13793 -- Corresponds to the C type FILE*
13794 subtype voids is System.Address;
13795 -- Corresponds to the C type void*
13796 subtype int is Integer;
13797 subtype long is Long_Integer;
13798 -- Note: the above types are subtypes deliberately, and it
13799 -- is part of this spec that the above correspondences are
13800 -- guaranteed. This means that it is legitimate to, for
13801 -- example, use Integer instead of int. We provide these
13802 -- synonyms for clarity, but in some cases it may be
13803 -- convenient to use the underlying types (for example to
13804 -- avoid an unnecessary dependency of a spec on the spec
13805 -- of this unit).
13806 type size_t is mod 2 ** Standard'Address_Size;
13807 NULL_Stream : constant FILEs;
13808 -- Value returned (NULL in C) to indicate an
13809 -- fdopen/fopen/tmpfile error
13810 ----------------------------------
13811 -- Constants Defined in stdio.h --
13812 ----------------------------------
13813 EOF : constant int;
13814 -- Used by a number of routines to indicate error or
13815 -- end of file
13816 IOFBF : constant int;
13817 IOLBF : constant int;
13818 IONBF : constant int;
13819 -- Used to indicate buffering mode for setvbuf call
13820 SEEK_CUR : constant int;
13821 SEEK_END : constant int;
13822 SEEK_SET : constant int;
13823 -- Used to indicate origin for fseek call
13824 function stdin return FILEs;
13825 function stdout return FILEs;
13826 function stderr return FILEs;
13827 -- Streams associated with standard files
13828 --------------------------
13829 -- Standard C functions --
13830 --------------------------
13831 -- The functions selected below are ones that are
13832 -- available in UNIX (but not necessarily in ANSI C).
13833 -- These are very thin interfaces
13834 -- which copy exactly the C headers. For more
13835 -- documentation on these functions, see the Microsoft C
13836 -- "Run-Time Library Reference" (Microsoft Press, 1990,
13837 -- ISBN 1-55615-225-6), which includes useful information
13838 -- on system compatibility.
13839 procedure clearerr (stream : FILEs);
13840 function fclose (stream : FILEs) return int;
13841 function fdopen (handle : int; mode : chars) return FILEs;
13842 function feof (stream : FILEs) return int;
13843 function ferror (stream : FILEs) return int;
13844 function fflush (stream : FILEs) return int;
13845 function fgetc (stream : FILEs) return int;
13846 function fgets (strng : chars; n : int; stream : FILEs)
13847 return chars;
13848 function fileno (stream : FILEs) return int;
13849 function fopen (filename : chars; Mode : chars)
13850 return FILEs;
13851 -- Note: to maintain target independence, use
13852 -- text_translation_required, a boolean variable defined in
13853 -- a-sysdep.c to deal with the target dependent text
13854 -- translation requirement. If this variable is set,
13855 -- then b/t should be appended to the standard mode
13856 -- argument to set the text translation mode off or on
13857 -- as required.
13858 function fputc (C : int; stream : FILEs) return int;
13859 function fputs (Strng : chars; Stream : FILEs) return int;
13860 function fread
13861 (buffer : voids;
13862 size : size_t;
13863 count : size_t;
13864 stream : FILEs)
13865 return size_t;
13866 function freopen
13867 (filename : chars;
13868 mode : chars;
13869 stream : FILEs)
13870 return FILEs;
13871 function fseek
13872 (stream : FILEs;
13873 offset : long;
13874 origin : int)
13875 return int;
13876 function ftell (stream : FILEs) return long;
13877 function fwrite
13878 (buffer : voids;
13879 size : size_t;
13880 count : size_t;
13881 stream : FILEs)
13882 return size_t;
13883 function isatty (handle : int) return int;
13884 procedure mktemp (template : chars);
13885 -- The return value (which is just a pointer to template)
13886 -- is discarded
13887 procedure rewind (stream : FILEs);
13888 function rmtmp return int;
13889 function setvbuf
13890 (stream : FILEs;
13891 buffer : chars;
13892 mode : int;
13893 size : size_t)
13894 return int;
13895
13896 function tmpfile return FILEs;
13897 function ungetc (c : int; stream : FILEs) return int;
13898 function unlink (filename : chars) return int;
13899 ---------------------
13900 -- Extra functions --
13901 ---------------------
13902 -- These functions supply slightly thicker bindings than
13903 -- those above. They are derived from functions in the
13904 -- C Run-Time Library, but may do a bit more work than
13905 -- just directly calling one of the Library functions.
13906 function is_regular_file (handle : int) return int;
13907 -- Tests if given handle is for a regular file (result 1)
13908 -- or for a non-regular file (pipe or device, result 0).
13909 ---------------------------------
13910 -- Control of Text/Binary Mode --
13911 ---------------------------------
13912 -- If text_translation_required is true, then the following
13913 -- functions may be used to dynamically switch a file from
13914 -- binary to text mode or vice versa. These functions have
13915 -- no effect if text_translation_required is false (i.e.@: in
13916 -- normal UNIX mode). Use fileno to get a stream handle.
13917 procedure set_binary_mode (handle : int);
13918 procedure set_text_mode (handle : int);
13919 ----------------------------
13920 -- Full Path Name support --
13921 ----------------------------
13922 procedure full_name (nam : chars; buffer : chars);
13923 -- Given a NUL terminated string representing a file
13924 -- name, returns in buffer a NUL terminated string
13925 -- representing the full path name for the file name.
13926 -- On systems where it is relevant the drive is also
13927 -- part of the full path name. It is the responsibility
13928 -- of the caller to pass an actual parameter for buffer
13929 -- that is big enough for any full path name. Use
13930 -- max_path_len given below as the size of buffer.
13931 max_path_len : integer;
13932 -- Maximum length of an allowable full path name on the
13933 -- system, including a terminating NUL character.
13934 end Interfaces.C_Streams;
13935 @end smallexample
13936
13937 @node Interfacing to C Streams
13938 @section Interfacing to C Streams
13939
13940 @noindent
13941 The packages in this section permit interfacing Ada files to C Stream
13942 operations.
13943
13944 @smallexample @c ada
13945 with Interfaces.C_Streams;
13946 package Ada.Sequential_IO.C_Streams is
13947 function C_Stream (F : File_Type)
13948 return Interfaces.C_Streams.FILEs;
13949 procedure Open
13950 (File : in out File_Type;
13951 Mode : in File_Mode;
13952 C_Stream : in Interfaces.C_Streams.FILEs;
13953 Form : in String := "");
13954 end Ada.Sequential_IO.C_Streams;
13955
13956 with Interfaces.C_Streams;
13957 package Ada.Direct_IO.C_Streams is
13958 function C_Stream (F : File_Type)
13959 return Interfaces.C_Streams.FILEs;
13960 procedure Open
13961 (File : in out File_Type;
13962 Mode : in File_Mode;
13963 C_Stream : in Interfaces.C_Streams.FILEs;
13964 Form : in String := "");
13965 end Ada.Direct_IO.C_Streams;
13966
13967 with Interfaces.C_Streams;
13968 package Ada.Text_IO.C_Streams is
13969 function C_Stream (F : File_Type)
13970 return Interfaces.C_Streams.FILEs;
13971 procedure Open
13972 (File : in out File_Type;
13973 Mode : in File_Mode;
13974 C_Stream : in Interfaces.C_Streams.FILEs;
13975 Form : in String := "");
13976 end Ada.Text_IO.C_Streams;
13977
13978 with Interfaces.C_Streams;
13979 package Ada.Wide_Text_IO.C_Streams is
13980 function C_Stream (F : File_Type)
13981 return Interfaces.C_Streams.FILEs;
13982 procedure Open
13983 (File : in out File_Type;
13984 Mode : in File_Mode;
13985 C_Stream : in Interfaces.C_Streams.FILEs;
13986 Form : in String := "");
13987 end Ada.Wide_Text_IO.C_Streams;
13988
13989 with Interfaces.C_Streams;
13990 package Ada.Wide_Wide_Text_IO.C_Streams is
13991 function C_Stream (F : File_Type)
13992 return Interfaces.C_Streams.FILEs;
13993 procedure Open
13994 (File : in out File_Type;
13995 Mode : in File_Mode;
13996 C_Stream : in Interfaces.C_Streams.FILEs;
13997 Form : in String := "");
13998 end Ada.Wide_Wide_Text_IO.C_Streams;
13999
14000 with Interfaces.C_Streams;
14001 package Ada.Stream_IO.C_Streams is
14002 function C_Stream (F : File_Type)
14003 return Interfaces.C_Streams.FILEs;
14004 procedure Open
14005 (File : in out File_Type;
14006 Mode : in File_Mode;
14007 C_Stream : in Interfaces.C_Streams.FILEs;
14008 Form : in String := "");
14009 end Ada.Stream_IO.C_Streams;
14010 @end smallexample
14011
14012 @noindent
14013 In each of these six packages, the @code{C_Stream} function obtains the
14014 @code{FILE} pointer from a currently opened Ada file. It is then
14015 possible to use the @code{Interfaces.C_Streams} package to operate on
14016 this stream, or the stream can be passed to a C program which can
14017 operate on it directly. Of course the program is responsible for
14018 ensuring that only appropriate sequences of operations are executed.
14019
14020 One particular use of relevance to an Ada program is that the
14021 @code{setvbuf} function can be used to control the buffering of the
14022 stream used by an Ada file. In the absence of such a call the standard
14023 default buffering is used.
14024
14025 The @code{Open} procedures in these packages open a file giving an
14026 existing C Stream instead of a file name. Typically this stream is
14027 imported from a C program, allowing an Ada file to operate on an
14028 existing C file.
14029
14030 @node The GNAT Library
14031 @chapter The GNAT Library
14032
14033 @noindent
14034 The GNAT library contains a number of general and special purpose packages.
14035 It represents functionality that the GNAT developers have found useful, and
14036 which is made available to GNAT users. The packages described here are fully
14037 supported, and upwards compatibility will be maintained in future releases,
14038 so you can use these facilities with the confidence that the same functionality
14039 will be available in future releases.
14040
14041 The chapter here simply gives a brief summary of the facilities available.
14042 The full documentation is found in the spec file for the package. The full
14043 sources of these library packages, including both spec and body, are provided
14044 with all GNAT releases. For example, to find out the full specifications of
14045 the SPITBOL pattern matching capability, including a full tutorial and
14046 extensive examples, look in the @file{g-spipat.ads} file in the library.
14047
14048 For each entry here, the package name (as it would appear in a @code{with}
14049 clause) is given, followed by the name of the corresponding spec file in
14050 parentheses. The packages are children in four hierarchies, @code{Ada},
14051 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14052 GNAT-specific hierarchy.
14053
14054 Note that an application program should only use packages in one of these
14055 four hierarchies if the package is defined in the Ada Reference Manual,
14056 or is listed in this section of the GNAT Programmers Reference Manual.
14057 All other units should be considered internal implementation units and
14058 should not be directly @code{with}'ed by application code. The use of
14059 a @code{with} statement that references one of these internal implementation
14060 units makes an application potentially dependent on changes in versions
14061 of GNAT, and will generate a warning message.
14062
14063 @menu
14064 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14065 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14066 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14067 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14068 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14069 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14070 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14071 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14072 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14073 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14074 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14075 * Ada.Command_Line.Environment (a-colien.ads)::
14076 * Ada.Command_Line.Remove (a-colire.ads)::
14077 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14078 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14079 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14080 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14081 * Ada.Exceptions.Traceback (a-exctra.ads)::
14082 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14083 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14084 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14085 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14086 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14087 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14088 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14089 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14090 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14091 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14092 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14093 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14094 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14095 * GNAT.Altivec (g-altive.ads)::
14096 * GNAT.Altivec.Conversions (g-altcon.ads)::
14097 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14098 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14099 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14100 * GNAT.Array_Split (g-arrspl.ads)::
14101 * GNAT.AWK (g-awk.ads)::
14102 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14103 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14104 * GNAT.Bubble_Sort (g-bubsor.ads)::
14105 * GNAT.Bubble_Sort_A (g-busora.ads)::
14106 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14107 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14108 * GNAT.Byte_Swapping (g-bytswa.ads)::
14109 * GNAT.Calendar (g-calend.ads)::
14110 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14111 * GNAT.Case_Util (g-casuti.ads)::
14112 * GNAT.CGI (g-cgi.ads)::
14113 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14114 * GNAT.CGI.Debug (g-cgideb.ads)::
14115 * GNAT.Command_Line (g-comlin.ads)::
14116 * GNAT.Compiler_Version (g-comver.ads)::
14117 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14118 * GNAT.CRC32 (g-crc32.ads)::
14119 * GNAT.Current_Exception (g-curexc.ads)::
14120 * GNAT.Debug_Pools (g-debpoo.ads)::
14121 * GNAT.Debug_Utilities (g-debuti.ads)::
14122 * GNAT.Decode_String (g-decstr.ads)::
14123 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14124 * GNAT.Directory_Operations (g-dirope.ads)::
14125 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14126 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14127 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14128 * GNAT.Encode_String (g-encstr.ads)::
14129 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14130 * GNAT.Exception_Actions (g-excact.ads)::
14131 * GNAT.Exception_Traces (g-exctra.ads)::
14132 * GNAT.Exceptions (g-except.ads)::
14133 * GNAT.Expect (g-expect.ads)::
14134 * GNAT.Float_Control (g-flocon.ads)::
14135 * GNAT.Heap_Sort (g-heasor.ads)::
14136 * GNAT.Heap_Sort_A (g-hesora.ads)::
14137 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14138 * GNAT.HTable (g-htable.ads)::
14139 * GNAT.IO (g-io.ads)::
14140 * GNAT.IO_Aux (g-io_aux.ads)::
14141 * GNAT.Lock_Files (g-locfil.ads)::
14142 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14143 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14144 * GNAT.MD5 (g-md5.ads)::
14145 * GNAT.Memory_Dump (g-memdum.ads)::
14146 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14147 * GNAT.OS_Lib (g-os_lib.ads)::
14148 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14149 * GNAT.Random_Numbers (g-rannum.ads)::
14150 * GNAT.Regexp (g-regexp.ads)::
14151 * GNAT.Registry (g-regist.ads)::
14152 * GNAT.Regpat (g-regpat.ads)::
14153 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14154 * GNAT.Semaphores (g-semaph.ads)::
14155 * GNAT.Serial_Communications (g-sercom.ads)::
14156 * GNAT.SHA1 (g-sha1.ads)::
14157 * GNAT.SHA224 (g-sha224.ads)::
14158 * GNAT.SHA256 (g-sha256.ads)::
14159 * GNAT.SHA384 (g-sha384.ads)::
14160 * GNAT.SHA512 (g-sha512.ads)::
14161 * GNAT.Signals (g-signal.ads)::
14162 * GNAT.Sockets (g-socket.ads)::
14163 * GNAT.Source_Info (g-souinf.ads)::
14164 * GNAT.Spelling_Checker (g-speche.ads)::
14165 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14166 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14167 * GNAT.Spitbol (g-spitbo.ads)::
14168 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14169 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14170 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14171 * GNAT.SSE (g-sse.ads)::
14172 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14173 * GNAT.Strings (g-string.ads)::
14174 * GNAT.String_Split (g-strspl.ads)::
14175 * GNAT.Table (g-table.ads)::
14176 * GNAT.Task_Lock (g-tasloc.ads)::
14177 * GNAT.Threads (g-thread.ads)::
14178 * GNAT.Time_Stamp (g-timsta.ads)::
14179 * GNAT.Traceback (g-traceb.ads)::
14180 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14181 * GNAT.UTF_32 (g-utf_32.ads)::
14182 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14183 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14184 * GNAT.Wide_String_Split (g-wistsp.ads)::
14185 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14186 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14187 * Interfaces.C.Extensions (i-cexten.ads)::
14188 * Interfaces.C.Streams (i-cstrea.ads)::
14189 * Interfaces.CPP (i-cpp.ads)::
14190 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14191 * Interfaces.VxWorks (i-vxwork.ads)::
14192 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14193 * System.Address_Image (s-addima.ads)::
14194 * System.Assertions (s-assert.ads)::
14195 * System.Memory (s-memory.ads)::
14196 * System.Partition_Interface (s-parint.ads)::
14197 * System.Pool_Global (s-pooglo.ads)::
14198 * System.Pool_Local (s-pooloc.ads)::
14199 * System.Restrictions (s-restri.ads)::
14200 * System.Rident (s-rident.ads)::
14201 * System.Strings.Stream_Ops (s-ststop.ads)::
14202 * System.Task_Info (s-tasinf.ads)::
14203 * System.Wch_Cnv (s-wchcnv.ads)::
14204 * System.Wch_Con (s-wchcon.ads)::
14205 @end menu
14206
14207 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14208 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14209 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14210 @cindex Latin_9 constants for Character
14211
14212 @noindent
14213 This child of @code{Ada.Characters}
14214 provides a set of definitions corresponding to those in the
14215 RM-defined package @code{Ada.Characters.Latin_1} but with the
14216 few modifications required for @code{Latin-9}
14217 The provision of such a package
14218 is specifically authorized by the Ada Reference Manual
14219 (RM A.3.3(27)).
14220
14221 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14222 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14223 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14224 @cindex Latin_1 constants for Wide_Character
14225
14226 @noindent
14227 This child of @code{Ada.Characters}
14228 provides a set of definitions corresponding to those in the
14229 RM-defined package @code{Ada.Characters.Latin_1} but with the
14230 types of the constants being @code{Wide_Character}
14231 instead of @code{Character}. The provision of such a package
14232 is specifically authorized by the Ada Reference Manual
14233 (RM A.3.3(27)).
14234
14235 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14236 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14237 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14238 @cindex Latin_9 constants for Wide_Character
14239
14240 @noindent
14241 This child of @code{Ada.Characters}
14242 provides a set of definitions corresponding to those in the
14243 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14244 types of the constants being @code{Wide_Character}
14245 instead of @code{Character}. The provision of such a package
14246 is specifically authorized by the Ada Reference Manual
14247 (RM A.3.3(27)).
14248
14249 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14250 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14251 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14252 @cindex Latin_1 constants for Wide_Wide_Character
14253
14254 @noindent
14255 This child of @code{Ada.Characters}
14256 provides a set of definitions corresponding to those in the
14257 RM-defined package @code{Ada.Characters.Latin_1} but with the
14258 types of the constants being @code{Wide_Wide_Character}
14259 instead of @code{Character}. The provision of such a package
14260 is specifically authorized by the Ada Reference Manual
14261 (RM A.3.3(27)).
14262
14263 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14264 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14265 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14266 @cindex Latin_9 constants for Wide_Wide_Character
14267
14268 @noindent
14269 This child of @code{Ada.Characters}
14270 provides a set of definitions corresponding to those in the
14271 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14272 types of the constants being @code{Wide_Wide_Character}
14273 instead of @code{Character}. The provision of such a package
14274 is specifically authorized by the Ada Reference Manual
14275 (RM A.3.3(27)).
14276
14277 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14278 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14279 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14280 @cindex Formal container for doubly linked lists
14281
14282 @noindent
14283 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14284 container for doubly linked lists, meant to facilitate formal verification of
14285 code using such containers.
14286
14287 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14288 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14289 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14290 @cindex Formal container for hashed maps
14291
14292 @noindent
14293 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14294 container for hashed maps, meant to facilitate formal verification of
14295 code using such containers.
14296
14297 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14298 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14299 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14300 @cindex Formal container for hashed sets
14301
14302 @noindent
14303 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14304 container for hashed sets, meant to facilitate formal verification of
14305 code using such containers.
14306
14307 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14308 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14309 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14310 @cindex Formal container for ordered maps
14311
14312 @noindent
14313 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14314 container for ordered maps, meant to facilitate formal verification of
14315 code using such containers.
14316
14317 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14318 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14319 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14320 @cindex Formal container for ordered sets
14321
14322 @noindent
14323 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14324 container for ordered sets, meant to facilitate formal verification of
14325 code using such containers.
14326
14327 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14328 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14329 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14330 @cindex Formal container for vectors
14331
14332 @noindent
14333 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14334 container for vectors, meant to facilitate formal verification of
14335 code using such containers.
14336
14337 @node Ada.Command_Line.Environment (a-colien.ads)
14338 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14339 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14340 @cindex Environment entries
14341
14342 @noindent
14343 This child of @code{Ada.Command_Line}
14344 provides a mechanism for obtaining environment values on systems
14345 where this concept makes sense.
14346
14347 @node Ada.Command_Line.Remove (a-colire.ads)
14348 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14349 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14350 @cindex Removing command line arguments
14351 @cindex Command line, argument removal
14352
14353 @noindent
14354 This child of @code{Ada.Command_Line}
14355 provides a mechanism for logically removing
14356 arguments from the argument list. Once removed, an argument is not visible
14357 to further calls on the subprograms in @code{Ada.Command_Line} will not
14358 see the removed argument.
14359
14360 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14361 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14362 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14363 @cindex Response file for command line
14364 @cindex Command line, response file
14365 @cindex Command line, handling long command lines
14366
14367 @noindent
14368 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14369 getting command line arguments from a text file, called a "response file".
14370 Using a response file allow passing a set of arguments to an executable longer
14371 than the maximum allowed by the system on the command line.
14372
14373 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14374 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14375 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14376 @cindex C Streams, Interfacing with Direct_IO
14377
14378 @noindent
14379 This package provides subprograms that allow interfacing between
14380 C streams and @code{Direct_IO}. The stream identifier can be
14381 extracted from a file opened on the Ada side, and an Ada file
14382 can be constructed from a stream opened on the C side.
14383
14384 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14385 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14386 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14387 @cindex Null_Occurrence, testing for
14388
14389 @noindent
14390 This child subprogram provides a way of testing for the null
14391 exception occurrence (@code{Null_Occurrence}) without raising
14392 an exception.
14393
14394 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14395 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14396 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14397 @cindex Null_Occurrence, testing for
14398
14399 @noindent
14400 This child subprogram is used for handling otherwise unhandled
14401 exceptions (hence the name last chance), and perform clean ups before
14402 terminating the program. Note that this subprogram never returns.
14403
14404 @node Ada.Exceptions.Traceback (a-exctra.ads)
14405 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14406 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14407 @cindex Traceback for Exception Occurrence
14408
14409 @noindent
14410 This child package provides the subprogram (@code{Tracebacks}) to
14411 give a traceback array of addresses based on an exception
14412 occurrence.
14413
14414 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14415 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14416 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14417 @cindex C Streams, Interfacing with Sequential_IO
14418
14419 @noindent
14420 This package provides subprograms that allow interfacing between
14421 C streams and @code{Sequential_IO}. The stream identifier can be
14422 extracted from a file opened on the Ada side, and an Ada file
14423 can be constructed from a stream opened on the C side.
14424
14425 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14426 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14427 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14428 @cindex C Streams, Interfacing with Stream_IO
14429
14430 @noindent
14431 This package provides subprograms that allow interfacing between
14432 C streams and @code{Stream_IO}. The stream identifier can be
14433 extracted from a file opened on the Ada side, and an Ada file
14434 can be constructed from a stream opened on the C side.
14435
14436 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14437 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14438 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14439 @cindex @code{Unbounded_String}, IO support
14440 @cindex @code{Text_IO}, extensions for unbounded strings
14441
14442 @noindent
14443 This package provides subprograms for Text_IO for unbounded
14444 strings, avoiding the necessity for an intermediate operation
14445 with ordinary strings.
14446
14447 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14448 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14449 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14450 @cindex @code{Unbounded_Wide_String}, IO support
14451 @cindex @code{Text_IO}, extensions for unbounded wide strings
14452
14453 @noindent
14454 This package provides subprograms for Text_IO for unbounded
14455 wide strings, avoiding the necessity for an intermediate operation
14456 with ordinary wide strings.
14457
14458 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14459 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14460 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14461 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14462 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14463
14464 @noindent
14465 This package provides subprograms for Text_IO for unbounded
14466 wide wide strings, avoiding the necessity for an intermediate operation
14467 with ordinary wide wide strings.
14468
14469 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14470 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14471 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14472 @cindex C Streams, Interfacing with @code{Text_IO}
14473
14474 @noindent
14475 This package provides subprograms that allow interfacing between
14476 C streams and @code{Text_IO}. The stream identifier can be
14477 extracted from a file opened on the Ada side, and an Ada file
14478 can be constructed from a stream opened on the C side.
14479
14480 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14481 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14482 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14483 @cindex @code{Text_IO} resetting standard files
14484
14485 @noindent
14486 This procedure is used to reset the status of the standard files used
14487 by Ada.Text_IO. This is useful in a situation (such as a restart in an
14488 embedded application) where the status of the files may change during
14489 execution (for example a standard input file may be redefined to be
14490 interactive).
14491
14492 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14493 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14494 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14495 @cindex Unicode categorization, Wide_Character
14496
14497 @noindent
14498 This package provides subprograms that allow categorization of
14499 Wide_Character values according to Unicode categories.
14500
14501 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14502 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14503 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14504 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14505
14506 @noindent
14507 This package provides subprograms that allow interfacing between
14508 C streams and @code{Wide_Text_IO}. The stream identifier can be
14509 extracted from a file opened on the Ada side, and an Ada file
14510 can be constructed from a stream opened on the C side.
14511
14512 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14513 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14514 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14515 @cindex @code{Wide_Text_IO} resetting standard files
14516
14517 @noindent
14518 This procedure is used to reset the status of the standard files used
14519 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
14520 embedded application) where the status of the files may change during
14521 execution (for example a standard input file may be redefined to be
14522 interactive).
14523
14524 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14525 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14526 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14527 @cindex Unicode categorization, Wide_Wide_Character
14528
14529 @noindent
14530 This package provides subprograms that allow categorization of
14531 Wide_Wide_Character values according to Unicode categories.
14532
14533 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14534 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14535 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14536 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14537
14538 @noindent
14539 This package provides subprograms that allow interfacing between
14540 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
14541 extracted from a file opened on the Ada side, and an Ada file
14542 can be constructed from a stream opened on the C side.
14543
14544 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14545 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14546 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14547 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14548
14549 @noindent
14550 This procedure is used to reset the status of the standard files used
14551 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14552 restart in an embedded application) where the status of the files may
14553 change during execution (for example a standard input file may be
14554 redefined to be interactive).
14555
14556 @node GNAT.Altivec (g-altive.ads)
14557 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14558 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14559 @cindex AltiVec
14560
14561 @noindent
14562 This is the root package of the GNAT AltiVec binding. It provides
14563 definitions of constants and types common to all the versions of the
14564 binding.
14565
14566 @node GNAT.Altivec.Conversions (g-altcon.ads)
14567 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14568 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14569 @cindex AltiVec
14570
14571 @noindent
14572 This package provides the Vector/View conversion routines.
14573
14574 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14575 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14576 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14577 @cindex AltiVec
14578
14579 @noindent
14580 This package exposes the Ada interface to the AltiVec operations on
14581 vector objects. A soft emulation is included by default in the GNAT
14582 library. The hard binding is provided as a separate package. This unit
14583 is common to both bindings.
14584
14585 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14586 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14587 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14588 @cindex AltiVec
14589
14590 @noindent
14591 This package exposes the various vector types part of the Ada binding
14592 to AltiVec facilities.
14593
14594 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14595 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14596 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14597 @cindex AltiVec
14598
14599 @noindent
14600 This package provides public 'View' data types from/to which private
14601 vector representations can be converted via
14602 GNAT.Altivec.Conversions. This allows convenient access to individual
14603 vector elements and provides a simple way to initialize vector
14604 objects.
14605
14606 @node GNAT.Array_Split (g-arrspl.ads)
14607 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14608 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14609 @cindex Array splitter
14610
14611 @noindent
14612 Useful array-manipulation routines: given a set of separators, split
14613 an array wherever the separators appear, and provide direct access
14614 to the resulting slices.
14615
14616 @node GNAT.AWK (g-awk.ads)
14617 @section @code{GNAT.AWK} (@file{g-awk.ads})
14618 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14619 @cindex Parsing
14620 @cindex AWK
14621
14622 @noindent
14623 Provides AWK-like parsing functions, with an easy interface for parsing one
14624 or more files containing formatted data. The file is viewed as a database
14625 where each record is a line and a field is a data element in this line.
14626
14627 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14628 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14629 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14630 @cindex Parsing
14631 @cindex Bounded Buffers
14632
14633 @noindent
14634 Provides a concurrent generic bounded buffer abstraction. Instances are
14635 useful directly or as parts of the implementations of other abstractions,
14636 such as mailboxes.
14637
14638 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14639 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14640 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14641 @cindex Parsing
14642 @cindex Mailboxes
14643
14644 @noindent
14645 Provides a thread-safe asynchronous intertask mailbox communication facility.
14646
14647 @node GNAT.Bubble_Sort (g-bubsor.ads)
14648 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14649 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14650 @cindex Sorting
14651 @cindex Bubble sort
14652
14653 @noindent
14654 Provides a general implementation of bubble sort usable for sorting arbitrary
14655 data items. Exchange and comparison procedures are provided by passing
14656 access-to-procedure values.
14657
14658 @node GNAT.Bubble_Sort_A (g-busora.ads)
14659 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14660 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14661 @cindex Sorting
14662 @cindex Bubble sort
14663
14664 @noindent
14665 Provides a general implementation of bubble sort usable for sorting arbitrary
14666 data items. Move and comparison procedures are provided by passing
14667 access-to-procedure values. This is an older version, retained for
14668 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14669
14670 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14671 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14672 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14673 @cindex Sorting
14674 @cindex Bubble sort
14675
14676 @noindent
14677 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14678 are provided as generic parameters, this improves efficiency, especially
14679 if the procedures can be inlined, at the expense of duplicating code for
14680 multiple instantiations.
14681
14682 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14683 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14684 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14685 @cindex UTF-8 representation
14686 @cindex Wide characte representations
14687
14688 @noindent
14689 Provides a routine which given a string, reads the start of the string to
14690 see whether it is one of the standard byte order marks (BOM's) which signal
14691 the encoding of the string. The routine includes detection of special XML
14692 sequences for various UCS input formats.
14693
14694 @node GNAT.Byte_Swapping (g-bytswa.ads)
14695 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14696 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14697 @cindex Byte swapping
14698 @cindex Endian
14699
14700 @noindent
14701 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14702 Machine-specific implementations are available in some cases.
14703
14704 @node GNAT.Calendar (g-calend.ads)
14705 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14706 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14707 @cindex @code{Calendar}
14708
14709 @noindent
14710 Extends the facilities provided by @code{Ada.Calendar} to include handling
14711 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14712 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14713 C @code{timeval} format.
14714
14715 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14716 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14717 @cindex @code{Calendar}
14718 @cindex Time
14719 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14720
14721 @node GNAT.CRC32 (g-crc32.ads)
14722 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14723 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14724 @cindex CRC32
14725 @cindex Cyclic Redundancy Check
14726
14727 @noindent
14728 This package implements the CRC-32 algorithm. For a full description
14729 of this algorithm see
14730 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14731 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14732 Aug.@: 1988. Sarwate, D.V@.
14733
14734 @node GNAT.Case_Util (g-casuti.ads)
14735 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14736 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14737 @cindex Casing utilities
14738 @cindex Character handling (@code{GNAT.Case_Util})
14739
14740 @noindent
14741 A set of simple routines for handling upper and lower casing of strings
14742 without the overhead of the full casing tables
14743 in @code{Ada.Characters.Handling}.
14744
14745 @node GNAT.CGI (g-cgi.ads)
14746 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14747 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14748 @cindex CGI (Common Gateway Interface)
14749
14750 @noindent
14751 This is a package for interfacing a GNAT program with a Web server via the
14752 Common Gateway Interface (CGI)@. Basically this package parses the CGI
14753 parameters, which are a set of key/value pairs sent by the Web server. It
14754 builds a table whose index is the key and provides some services to deal
14755 with this table.
14756
14757 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14758 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14759 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14760 @cindex CGI (Common Gateway Interface) cookie support
14761 @cindex Cookie support in CGI
14762
14763 @noindent
14764 This is a package to interface a GNAT program with a Web server via the
14765 Common Gateway Interface (CGI). It exports services to deal with Web
14766 cookies (piece of information kept in the Web client software).
14767
14768 @node GNAT.CGI.Debug (g-cgideb.ads)
14769 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14770 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14771 @cindex CGI (Common Gateway Interface) debugging
14772
14773 @noindent
14774 This is a package to help debugging CGI (Common Gateway Interface)
14775 programs written in Ada.
14776
14777 @node GNAT.Command_Line (g-comlin.ads)
14778 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14779 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14780 @cindex Command line
14781
14782 @noindent
14783 Provides a high level interface to @code{Ada.Command_Line} facilities,
14784 including the ability to scan for named switches with optional parameters
14785 and expand file names using wild card notations.
14786
14787 @node GNAT.Compiler_Version (g-comver.ads)
14788 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14789 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14790 @cindex Compiler Version
14791 @cindex Version, of compiler
14792
14793 @noindent
14794 Provides a routine for obtaining the version of the compiler used to
14795 compile the program. More accurately this is the version of the binder
14796 used to bind the program (this will normally be the same as the version
14797 of the compiler if a consistent tool set is used to compile all units
14798 of a partition).
14799
14800 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14801 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14802 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14803 @cindex Interrupt
14804
14805 @noindent
14806 Provides a simple interface to handle Ctrl-C keyboard events.
14807
14808 @node GNAT.Current_Exception (g-curexc.ads)
14809 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14810 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14811 @cindex Current exception
14812 @cindex Exception retrieval
14813
14814 @noindent
14815 Provides access to information on the current exception that has been raised
14816 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14817 specification syntax.
14818 This is particularly useful in simulating typical facilities for
14819 obtaining information about exceptions provided by Ada 83 compilers.
14820
14821 @node GNAT.Debug_Pools (g-debpoo.ads)
14822 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14823 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14824 @cindex Debugging
14825 @cindex Debug pools
14826 @cindex Memory corruption debugging
14827
14828 @noindent
14829 Provide a debugging storage pools that helps tracking memory corruption
14830 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14831 @value{EDITION} User's Guide}.
14832
14833 @node GNAT.Debug_Utilities (g-debuti.ads)
14834 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14835 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14836 @cindex Debugging
14837
14838 @noindent
14839 Provides a few useful utilities for debugging purposes, including conversion
14840 to and from string images of address values. Supports both C and Ada formats
14841 for hexadecimal literals.
14842
14843 @node GNAT.Decode_String (g-decstr.ads)
14844 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14845 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14846 @cindex Decoding strings
14847 @cindex String decoding
14848 @cindex Wide character encoding
14849 @cindex UTF-8
14850 @cindex Unicode
14851
14852 @noindent
14853 A generic package providing routines for decoding wide character and wide wide
14854 character strings encoded as sequences of 8-bit characters using a specified
14855 encoding method. Includes validation routines, and also routines for stepping
14856 to next or previous encoded character in an encoded string.
14857 Useful in conjunction with Unicode character coding. Note there is a
14858 preinstantiation for UTF-8. See next entry.
14859
14860 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14861 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14862 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14863 @cindex Decoding strings
14864 @cindex Decoding UTF-8 strings
14865 @cindex UTF-8 string decoding
14866 @cindex Wide character decoding
14867 @cindex UTF-8
14868 @cindex Unicode
14869
14870 @noindent
14871 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14872
14873 @node GNAT.Directory_Operations (g-dirope.ads)
14874 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14875 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14876 @cindex Directory operations
14877
14878 @noindent
14879 Provides a set of routines for manipulating directories, including changing
14880 the current directory, making new directories, and scanning the files in a
14881 directory.
14882
14883 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14884 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14885 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14886 @cindex Directory operations iteration
14887
14888 @noindent
14889 A child unit of GNAT.Directory_Operations providing additional operations
14890 for iterating through directories.
14891
14892 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14893 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14894 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14895 @cindex Hash tables
14896
14897 @noindent
14898 A generic implementation of hash tables that can be used to hash arbitrary
14899 data. Provided in two forms, a simple form with built in hash functions,
14900 and a more complex form in which the hash function is supplied.
14901
14902 @noindent
14903 This package provides a facility similar to that of @code{GNAT.HTable},
14904 except that this package declares a type that can be used to define
14905 dynamic instances of the hash table, while an instantiation of
14906 @code{GNAT.HTable} creates a single instance of the hash table.
14907
14908 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14909 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14910 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14911 @cindex Table implementation
14912 @cindex Arrays, extendable
14913
14914 @noindent
14915 A generic package providing a single dimension array abstraction where the
14916 length of the array can be dynamically modified.
14917
14918 @noindent
14919 This package provides a facility similar to that of @code{GNAT.Table},
14920 except that this package declares a type that can be used to define
14921 dynamic instances of the table, while an instantiation of
14922 @code{GNAT.Table} creates a single instance of the table type.
14923
14924 @node GNAT.Encode_String (g-encstr.ads)
14925 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14926 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14927 @cindex Encoding strings
14928 @cindex String encoding
14929 @cindex Wide character encoding
14930 @cindex UTF-8
14931 @cindex Unicode
14932
14933 @noindent
14934 A generic package providing routines for encoding wide character and wide
14935 wide character strings as sequences of 8-bit characters using a specified
14936 encoding method. Useful in conjunction with Unicode character coding.
14937 Note there is a preinstantiation for UTF-8. See next entry.
14938
14939 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14940 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14941 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14942 @cindex Encoding strings
14943 @cindex Encoding UTF-8 strings
14944 @cindex UTF-8 string encoding
14945 @cindex Wide character encoding
14946 @cindex UTF-8
14947 @cindex Unicode
14948
14949 @noindent
14950 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14951
14952 @node GNAT.Exception_Actions (g-excact.ads)
14953 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14954 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14955 @cindex Exception actions
14956
14957 @noindent
14958 Provides callbacks when an exception is raised. Callbacks can be registered
14959 for specific exceptions, or when any exception is raised. This
14960 can be used for instance to force a core dump to ease debugging.
14961
14962 @node GNAT.Exception_Traces (g-exctra.ads)
14963 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14964 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14965 @cindex Exception traces
14966 @cindex Debugging
14967
14968 @noindent
14969 Provides an interface allowing to control automatic output upon exception
14970 occurrences.
14971
14972 @node GNAT.Exceptions (g-except.ads)
14973 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14974 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14975 @cindex Exceptions, Pure
14976 @cindex Pure packages, exceptions
14977
14978 @noindent
14979 Normally it is not possible to raise an exception with
14980 a message from a subprogram in a pure package, since the
14981 necessary types and subprograms are in @code{Ada.Exceptions}
14982 which is not a pure unit. @code{GNAT.Exceptions} provides a
14983 facility for getting around this limitation for a few
14984 predefined exceptions, and for example allow raising
14985 @code{Constraint_Error} with a message from a pure subprogram.
14986
14987 @node GNAT.Expect (g-expect.ads)
14988 @section @code{GNAT.Expect} (@file{g-expect.ads})
14989 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14990
14991 @noindent
14992 Provides a set of subprograms similar to what is available
14993 with the standard Tcl Expect tool.
14994 It allows you to easily spawn and communicate with an external process.
14995 You can send commands or inputs to the process, and compare the output
14996 with some expected regular expression. Currently @code{GNAT.Expect}
14997 is implemented on all native GNAT ports except for OpenVMS@.
14998 It is not implemented for cross ports, and in particular is not
14999 implemented for VxWorks or LynxOS@.
15000
15001 @node GNAT.Float_Control (g-flocon.ads)
15002 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15003 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15004 @cindex Floating-Point Processor
15005
15006 @noindent
15007 Provides an interface for resetting the floating-point processor into the
15008 mode required for correct semantic operation in Ada. Some third party
15009 library calls may cause this mode to be modified, and the Reset procedure
15010 in this package can be used to reestablish the required mode.
15011
15012 @node GNAT.Heap_Sort (g-heasor.ads)
15013 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15014 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15015 @cindex Sorting
15016
15017 @noindent
15018 Provides a general implementation of heap sort usable for sorting arbitrary
15019 data items. Exchange and comparison procedures are provided by passing
15020 access-to-procedure values. The algorithm used is a modified heap sort
15021 that performs approximately N*log(N) comparisons in the worst case.
15022
15023 @node GNAT.Heap_Sort_A (g-hesora.ads)
15024 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15025 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15026 @cindex Sorting
15027
15028 @noindent
15029 Provides a general implementation of heap sort usable for sorting arbitrary
15030 data items. Move and comparison procedures are provided by passing
15031 access-to-procedure values. The algorithm used is a modified heap sort
15032 that performs approximately N*log(N) comparisons in the worst case.
15033 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15034 interface, but may be slightly more efficient.
15035
15036 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15037 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15038 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15039 @cindex Sorting
15040
15041 @noindent
15042 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15043 are provided as generic parameters, this improves efficiency, especially
15044 if the procedures can be inlined, at the expense of duplicating code for
15045 multiple instantiations.
15046
15047 @node GNAT.HTable (g-htable.ads)
15048 @section @code{GNAT.HTable} (@file{g-htable.ads})
15049 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15050 @cindex Hash tables
15051
15052 @noindent
15053 A generic implementation of hash tables that can be used to hash arbitrary
15054 data. Provides two approaches, one a simple static approach, and the other
15055 allowing arbitrary dynamic hash tables.
15056
15057 @node GNAT.IO (g-io.ads)
15058 @section @code{GNAT.IO} (@file{g-io.ads})
15059 @cindex @code{GNAT.IO} (@file{g-io.ads})
15060 @cindex Simple I/O
15061 @cindex Input/Output facilities
15062
15063 @noindent
15064 A simple preelaborable input-output package that provides a subset of
15065 simple Text_IO functions for reading characters and strings from
15066 Standard_Input, and writing characters, strings and integers to either
15067 Standard_Output or Standard_Error.
15068
15069 @node GNAT.IO_Aux (g-io_aux.ads)
15070 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15071 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15072 @cindex Text_IO
15073 @cindex Input/Output facilities
15074
15075 Provides some auxiliary functions for use with Text_IO, including a test
15076 for whether a file exists, and functions for reading a line of text.
15077
15078 @node GNAT.Lock_Files (g-locfil.ads)
15079 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15080 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15081 @cindex File locking
15082 @cindex Locking using files
15083
15084 @noindent
15085 Provides a general interface for using files as locks. Can be used for
15086 providing program level synchronization.
15087
15088 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15089 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15090 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15091 @cindex Random number generation
15092
15093 @noindent
15094 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15095 a modified version of the Blum-Blum-Shub generator.
15096
15097 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15098 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15099 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15100 @cindex Random number generation
15101
15102 @noindent
15103 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15104 a modified version of the Blum-Blum-Shub generator.
15105
15106 @node GNAT.MD5 (g-md5.ads)
15107 @section @code{GNAT.MD5} (@file{g-md5.ads})
15108 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15109 @cindex Message Digest MD5
15110
15111 @noindent
15112 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15113
15114 @node GNAT.Memory_Dump (g-memdum.ads)
15115 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15116 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15117 @cindex Dump Memory
15118
15119 @noindent
15120 Provides a convenient routine for dumping raw memory to either the
15121 standard output or standard error files. Uses GNAT.IO for actual
15122 output.
15123
15124 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15125 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15126 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15127 @cindex Exception, obtaining most recent
15128
15129 @noindent
15130 Provides access to the most recently raised exception. Can be used for
15131 various logging purposes, including duplicating functionality of some
15132 Ada 83 implementation dependent extensions.
15133
15134 @node GNAT.OS_Lib (g-os_lib.ads)
15135 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15136 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15137 @cindex Operating System interface
15138 @cindex Spawn capability
15139
15140 @noindent
15141 Provides a range of target independent operating system interface functions,
15142 including time/date management, file operations, subprocess management,
15143 including a portable spawn procedure, and access to environment variables
15144 and error return codes.
15145
15146 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15147 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15148 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15149 @cindex Hash functions
15150
15151 @noindent
15152 Provides a generator of static minimal perfect hash functions. No
15153 collisions occur and each item can be retrieved from the table in one
15154 probe (perfect property). The hash table size corresponds to the exact
15155 size of the key set and no larger (minimal property). The key set has to
15156 be know in advance (static property). The hash functions are also order
15157 preserving. If w2 is inserted after w1 in the generator, their
15158 hashcode are in the same order. These hashing functions are very
15159 convenient for use with realtime applications.
15160
15161 @node GNAT.Random_Numbers (g-rannum.ads)
15162 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15163 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15164 @cindex Random number generation
15165
15166 @noindent
15167 Provides random number capabilities which extend those available in the
15168 standard Ada library and are more convenient to use.
15169
15170 @node GNAT.Regexp (g-regexp.ads)
15171 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15172 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15173 @cindex Regular expressions
15174 @cindex Pattern matching
15175
15176 @noindent
15177 A simple implementation of regular expressions, using a subset of regular
15178 expression syntax copied from familiar Unix style utilities. This is the
15179 simples of the three pattern matching packages provided, and is particularly
15180 suitable for ``file globbing'' applications.
15181
15182 @node GNAT.Registry (g-regist.ads)
15183 @section @code{GNAT.Registry} (@file{g-regist.ads})
15184 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15185 @cindex Windows Registry
15186
15187 @noindent
15188 This is a high level binding to the Windows registry. It is possible to
15189 do simple things like reading a key value, creating a new key. For full
15190 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15191 package provided with the Win32Ada binding
15192
15193 @node GNAT.Regpat (g-regpat.ads)
15194 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15195 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15196 @cindex Regular expressions
15197 @cindex Pattern matching
15198
15199 @noindent
15200 A complete implementation of Unix-style regular expression matching, copied
15201 from the original V7 style regular expression library written in C by
15202 Henry Spencer (and binary compatible with this C library).
15203
15204 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15205 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15206 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15207 @cindex Secondary Stack Info
15208
15209 @noindent
15210 Provide the capability to query the high water mark of the current task's
15211 secondary stack.
15212
15213 @node GNAT.Semaphores (g-semaph.ads)
15214 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15215 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15216 @cindex Semaphores
15217
15218 @noindent
15219 Provides classic counting and binary semaphores using protected types.
15220
15221 @node GNAT.Serial_Communications (g-sercom.ads)
15222 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15223 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15224 @cindex Serial_Communications
15225
15226 @noindent
15227 Provides a simple interface to send and receive data over a serial
15228 port. This is only supported on GNU/Linux and Windows.
15229
15230 @node GNAT.SHA1 (g-sha1.ads)
15231 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15232 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15233 @cindex Secure Hash Algorithm SHA-1
15234
15235 @noindent
15236 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15237 and RFC 3174.
15238
15239 @node GNAT.SHA224 (g-sha224.ads)
15240 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15241 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15242 @cindex Secure Hash Algorithm SHA-224
15243
15244 @noindent
15245 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15246
15247 @node GNAT.SHA256 (g-sha256.ads)
15248 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15249 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15250 @cindex Secure Hash Algorithm SHA-256
15251
15252 @noindent
15253 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15254
15255 @node GNAT.SHA384 (g-sha384.ads)
15256 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15257 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15258 @cindex Secure Hash Algorithm SHA-384
15259
15260 @noindent
15261 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15262
15263 @node GNAT.SHA512 (g-sha512.ads)
15264 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15265 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15266 @cindex Secure Hash Algorithm SHA-512
15267
15268 @noindent
15269 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15270
15271 @node GNAT.Signals (g-signal.ads)
15272 @section @code{GNAT.Signals} (@file{g-signal.ads})
15273 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15274 @cindex Signals
15275
15276 @noindent
15277 Provides the ability to manipulate the blocked status of signals on supported
15278 targets.
15279
15280 @node GNAT.Sockets (g-socket.ads)
15281 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15282 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15283 @cindex Sockets
15284
15285 @noindent
15286 A high level and portable interface to develop sockets based applications.
15287 This package is based on the sockets thin binding found in
15288 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15289 on all native GNAT ports except for OpenVMS@. It is not implemented
15290 for the LynxOS@ cross port.
15291
15292 @node GNAT.Source_Info (g-souinf.ads)
15293 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15294 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15295 @cindex Source Information
15296
15297 @noindent
15298 Provides subprograms that give access to source code information known at
15299 compile time, such as the current file name and line number.
15300
15301 @node GNAT.Spelling_Checker (g-speche.ads)
15302 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15303 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15304 @cindex Spell checking
15305
15306 @noindent
15307 Provides a function for determining whether one string is a plausible
15308 near misspelling of another string.
15309
15310 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15311 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15312 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15313 @cindex Spell checking
15314
15315 @noindent
15316 Provides a generic function that can be instantiated with a string type for
15317 determining whether one string is a plausible near misspelling of another
15318 string.
15319
15320 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15321 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15322 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15323 @cindex SPITBOL pattern matching
15324 @cindex Pattern matching
15325
15326 @noindent
15327 A complete implementation of SNOBOL4 style pattern matching. This is the
15328 most elaborate of the pattern matching packages provided. It fully duplicates
15329 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15330 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15331
15332 @node GNAT.Spitbol (g-spitbo.ads)
15333 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15334 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15335 @cindex SPITBOL interface
15336
15337 @noindent
15338 The top level package of the collection of SPITBOL-style functionality, this
15339 package provides basic SNOBOL4 string manipulation functions, such as
15340 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15341 useful for constructing arbitrary mappings from strings in the style of
15342 the SNOBOL4 TABLE function.
15343
15344 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15345 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15346 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15347 @cindex Sets of strings
15348 @cindex SPITBOL Tables
15349
15350 @noindent
15351 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15352 for type @code{Standard.Boolean}, giving an implementation of sets of
15353 string values.
15354
15355 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15356 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15357 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15358 @cindex Integer maps
15359 @cindex Maps
15360 @cindex SPITBOL Tables
15361
15362 @noindent
15363 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15364 for type @code{Standard.Integer}, giving an implementation of maps
15365 from string to integer values.
15366
15367 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15368 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15369 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15370 @cindex String maps
15371 @cindex Maps
15372 @cindex SPITBOL Tables
15373
15374 @noindent
15375 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15376 a variable length string type, giving an implementation of general
15377 maps from strings to strings.
15378
15379 @node GNAT.SSE (g-sse.ads)
15380 @section @code{GNAT.SSE} (@file{g-sse.ads})
15381 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15382
15383 @noindent
15384 Root of a set of units aimed at offering Ada bindings to a subset of
15385 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15386 targets. It exposes vector component types together with a general
15387 introduction to the binding contents and use.
15388
15389 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15390 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15391 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15392
15393 @noindent
15394 SSE vector types for use with SSE related intrinsics.
15395
15396 @node GNAT.Strings (g-string.ads)
15397 @section @code{GNAT.Strings} (@file{g-string.ads})
15398 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15399
15400 @noindent
15401 Common String access types and related subprograms. Basically it
15402 defines a string access and an array of string access types.
15403
15404 @node GNAT.String_Split (g-strspl.ads)
15405 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15406 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15407 @cindex String splitter
15408
15409 @noindent
15410 Useful string manipulation routines: given a set of separators, split
15411 a string wherever the separators appear, and provide direct access
15412 to the resulting slices. This package is instantiated from
15413 @code{GNAT.Array_Split}.
15414
15415 @node GNAT.Table (g-table.ads)
15416 @section @code{GNAT.Table} (@file{g-table.ads})
15417 @cindex @code{GNAT.Table} (@file{g-table.ads})
15418 @cindex Table implementation
15419 @cindex Arrays, extendable
15420
15421 @noindent
15422 A generic package providing a single dimension array abstraction where the
15423 length of the array can be dynamically modified.
15424
15425 @noindent
15426 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15427 except that this package declares a single instance of the table type,
15428 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15429 used to define dynamic instances of the table.
15430
15431 @node GNAT.Task_Lock (g-tasloc.ads)
15432 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15433 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15434 @cindex Task synchronization
15435 @cindex Task locking
15436 @cindex Locking
15437
15438 @noindent
15439 A very simple facility for locking and unlocking sections of code using a
15440 single global task lock. Appropriate for use in situations where contention
15441 between tasks is very rarely expected.
15442
15443 @node GNAT.Time_Stamp (g-timsta.ads)
15444 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15445 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15446 @cindex Time stamp
15447 @cindex Current time
15448
15449 @noindent
15450 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15451 represents the current date and time in ISO 8601 format. This is a very simple
15452 routine with minimal code and there are no dependencies on any other unit.
15453
15454 @node GNAT.Threads (g-thread.ads)
15455 @section @code{GNAT.Threads} (@file{g-thread.ads})
15456 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15457 @cindex Foreign threads
15458 @cindex Threads, foreign
15459
15460 @noindent
15461 Provides facilities for dealing with foreign threads which need to be known
15462 by the GNAT run-time system. Consult the documentation of this package for
15463 further details if your program has threads that are created by a non-Ada
15464 environment which then accesses Ada code.
15465
15466 @node GNAT.Traceback (g-traceb.ads)
15467 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15468 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15469 @cindex Trace back facilities
15470
15471 @noindent
15472 Provides a facility for obtaining non-symbolic traceback information, useful
15473 in various debugging situations.
15474
15475 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15476 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15477 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15478 @cindex Trace back facilities
15479
15480 @node GNAT.UTF_32 (g-utf_32.ads)
15481 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15482 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15483 @cindex Wide character codes
15484
15485 @noindent
15486 This is a package intended to be used in conjunction with the
15487 @code{Wide_Character} type in Ada 95 and the
15488 @code{Wide_Wide_Character} type in Ada 2005 (available
15489 in @code{GNAT} in Ada 2005 mode). This package contains
15490 Unicode categorization routines, as well as lexical
15491 categorization routines corresponding to the Ada 2005
15492 lexical rules for identifiers and strings, and also a
15493 lower case to upper case fold routine corresponding to
15494 the Ada 2005 rules for identifier equivalence.
15495
15496 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15497 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15498 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15499 @cindex Spell checking
15500
15501 @noindent
15502 Provides a function for determining whether one wide wide string is a plausible
15503 near misspelling of another wide wide string, where the strings are represented
15504 using the UTF_32_String type defined in System.Wch_Cnv.
15505
15506 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15507 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15508 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15509 @cindex Spell checking
15510
15511 @noindent
15512 Provides a function for determining whether one wide string is a plausible
15513 near misspelling of another wide string.
15514
15515 @node GNAT.Wide_String_Split (g-wistsp.ads)
15516 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15517 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15518 @cindex Wide_String splitter
15519
15520 @noindent
15521 Useful wide string manipulation routines: given a set of separators, split
15522 a wide string wherever the separators appear, and provide direct access
15523 to the resulting slices. This package is instantiated from
15524 @code{GNAT.Array_Split}.
15525
15526 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15527 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15528 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15529 @cindex Spell checking
15530
15531 @noindent
15532 Provides a function for determining whether one wide wide string is a plausible
15533 near misspelling of another wide wide string.
15534
15535 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15536 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15537 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15538 @cindex Wide_Wide_String splitter
15539
15540 @noindent
15541 Useful wide wide string manipulation routines: given a set of separators, split
15542 a wide wide string wherever the separators appear, and provide direct access
15543 to the resulting slices. This package is instantiated from
15544 @code{GNAT.Array_Split}.
15545
15546 @node Interfaces.C.Extensions (i-cexten.ads)
15547 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15548 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15549
15550 @noindent
15551 This package contains additional C-related definitions, intended
15552 for use with either manually or automatically generated bindings
15553 to C libraries.
15554
15555 @node Interfaces.C.Streams (i-cstrea.ads)
15556 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15557 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15558 @cindex C streams, interfacing
15559
15560 @noindent
15561 This package is a binding for the most commonly used operations
15562 on C streams.
15563
15564 @node Interfaces.CPP (i-cpp.ads)
15565 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15566 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15567 @cindex C++ interfacing
15568 @cindex Interfacing, to C++
15569
15570 @noindent
15571 This package provides facilities for use in interfacing to C++. It
15572 is primarily intended to be used in connection with automated tools
15573 for the generation of C++ interfaces.
15574
15575 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15576 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15577 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15578 @cindex IBM Packed Format
15579 @cindex Packed Decimal
15580
15581 @noindent
15582 This package provides a set of routines for conversions to and
15583 from a packed decimal format compatible with that used on IBM
15584 mainframes.
15585
15586 @node Interfaces.VxWorks (i-vxwork.ads)
15587 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15588 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15589 @cindex Interfacing to VxWorks
15590 @cindex VxWorks, interfacing
15591
15592 @noindent
15593 This package provides a limited binding to the VxWorks API.
15594 In particular, it interfaces with the
15595 VxWorks hardware interrupt facilities.
15596
15597 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15598 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15599 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15600 @cindex Interfacing to VxWorks' I/O
15601 @cindex VxWorks, I/O interfacing
15602 @cindex VxWorks, Get_Immediate
15603 @cindex Get_Immediate, VxWorks
15604
15605 @noindent
15606 This package provides a binding to the ioctl (IO/Control)
15607 function of VxWorks, defining a set of option values and
15608 function codes. A particular use of this package is
15609 to enable the use of Get_Immediate under VxWorks.
15610
15611 @node System.Address_Image (s-addima.ads)
15612 @section @code{System.Address_Image} (@file{s-addima.ads})
15613 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15614 @cindex Address image
15615 @cindex Image, of an address
15616
15617 @noindent
15618 This function provides a useful debugging
15619 function that gives an (implementation dependent)
15620 string which identifies an address.
15621
15622 @node System.Assertions (s-assert.ads)
15623 @section @code{System.Assertions} (@file{s-assert.ads})
15624 @cindex @code{System.Assertions} (@file{s-assert.ads})
15625 @cindex Assertions
15626 @cindex Assert_Failure, exception
15627
15628 @noindent
15629 This package provides the declaration of the exception raised
15630 by an run-time assertion failure, as well as the routine that
15631 is used internally to raise this assertion.
15632
15633 @node System.Memory (s-memory.ads)
15634 @section @code{System.Memory} (@file{s-memory.ads})
15635 @cindex @code{System.Memory} (@file{s-memory.ads})
15636 @cindex Memory allocation
15637
15638 @noindent
15639 This package provides the interface to the low level routines used
15640 by the generated code for allocation and freeing storage for the
15641 default storage pool (analogous to the C routines malloc and free.
15642 It also provides a reallocation interface analogous to the C routine
15643 realloc. The body of this unit may be modified to provide alternative
15644 allocation mechanisms for the default pool, and in addition, direct
15645 calls to this unit may be made for low level allocation uses (for
15646 example see the body of @code{GNAT.Tables}).
15647
15648 @node System.Partition_Interface (s-parint.ads)
15649 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15650 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15651 @cindex Partition interfacing functions
15652
15653 @noindent
15654 This package provides facilities for partition interfacing. It
15655 is used primarily in a distribution context when using Annex E
15656 with @code{GLADE}.
15657
15658 @node System.Pool_Global (s-pooglo.ads)
15659 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15660 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15661 @cindex Storage pool, global
15662 @cindex Global storage pool
15663
15664 @noindent
15665 This package provides a storage pool that is equivalent to the default
15666 storage pool used for access types for which no pool is specifically
15667 declared. It uses malloc/free to allocate/free and does not attempt to
15668 do any automatic reclamation.
15669
15670 @node System.Pool_Local (s-pooloc.ads)
15671 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15672 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15673 @cindex Storage pool, local
15674 @cindex Local storage pool
15675
15676 @noindent
15677 This package provides a storage pool that is intended for use with locally
15678 defined access types. It uses malloc/free for allocate/free, and maintains
15679 a list of allocated blocks, so that all storage allocated for the pool can
15680 be freed automatically when the pool is finalized.
15681
15682 @node System.Restrictions (s-restri.ads)
15683 @section @code{System.Restrictions} (@file{s-restri.ads})
15684 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15685 @cindex Run-time restrictions access
15686
15687 @noindent
15688 This package provides facilities for accessing at run time
15689 the status of restrictions specified at compile time for
15690 the partition. Information is available both with regard
15691 to actual restrictions specified, and with regard to
15692 compiler determined information on which restrictions
15693 are violated by one or more packages in the partition.
15694
15695 @node System.Rident (s-rident.ads)
15696 @section @code{System.Rident} (@file{s-rident.ads})
15697 @cindex @code{System.Rident} (@file{s-rident.ads})
15698 @cindex Restrictions definitions
15699
15700 @noindent
15701 This package provides definitions of the restrictions
15702 identifiers supported by GNAT, and also the format of
15703 the restrictions provided in package System.Restrictions.
15704 It is not normally necessary to @code{with} this generic package
15705 since the necessary instantiation is included in
15706 package System.Restrictions.
15707
15708 @node System.Strings.Stream_Ops (s-ststop.ads)
15709 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15710 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15711 @cindex Stream operations
15712 @cindex String stream operations
15713
15714 @noindent
15715 This package provides a set of stream subprograms for standard string types.
15716 It is intended primarily to support implicit use of such subprograms when
15717 stream attributes are applied to string types, but the subprograms in this
15718 package can be used directly by application programs.
15719
15720 @node System.Task_Info (s-tasinf.ads)
15721 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15722 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15723 @cindex Task_Info pragma
15724
15725 @noindent
15726 This package provides target dependent functionality that is used
15727 to support the @code{Task_Info} pragma
15728
15729 @node System.Wch_Cnv (s-wchcnv.ads)
15730 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15731 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15732 @cindex Wide Character, Representation
15733 @cindex Wide String, Conversion
15734 @cindex Representation of wide characters
15735
15736 @noindent
15737 This package provides routines for converting between
15738 wide and wide wide characters and a representation as a value of type
15739 @code{Standard.String}, using a specified wide character
15740 encoding method. It uses definitions in
15741 package @code{System.Wch_Con}.
15742
15743 @node System.Wch_Con (s-wchcon.ads)
15744 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15745 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15746
15747 @noindent
15748 This package provides definitions and descriptions of
15749 the various methods used for encoding wide characters
15750 in ordinary strings. These definitions are used by
15751 the package @code{System.Wch_Cnv}.
15752
15753 @node Interfacing to Other Languages
15754 @chapter Interfacing to Other Languages
15755 @noindent
15756 The facilities in annex B of the Ada Reference Manual are fully
15757 implemented in GNAT, and in addition, a full interface to C++ is
15758 provided.
15759
15760 @menu
15761 * Interfacing to C::
15762 * Interfacing to C++::
15763 * Interfacing to COBOL::
15764 * Interfacing to Fortran::
15765 * Interfacing to non-GNAT Ada code::
15766 @end menu
15767
15768 @node Interfacing to C
15769 @section Interfacing to C
15770
15771 @noindent
15772 Interfacing to C with GNAT can use one of two approaches:
15773
15774 @itemize @bullet
15775 @item
15776 The types in the package @code{Interfaces.C} may be used.
15777 @item
15778 Standard Ada types may be used directly. This may be less portable to
15779 other compilers, but will work on all GNAT compilers, which guarantee
15780 correspondence between the C and Ada types.
15781 @end itemize
15782
15783 @noindent
15784 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15785 effect, since this is the default. The following table shows the
15786 correspondence between Ada scalar types and the corresponding C types.
15787
15788 @table @code
15789 @item Integer
15790 @code{int}
15791 @item Short_Integer
15792 @code{short}
15793 @item Short_Short_Integer
15794 @code{signed char}
15795 @item Long_Integer
15796 @code{long}
15797 @item Long_Long_Integer
15798 @code{long long}
15799 @item Short_Float
15800 @code{float}
15801 @item Float
15802 @code{float}
15803 @item Long_Float
15804 @code{double}
15805 @item Long_Long_Float
15806 This is the longest floating-point type supported by the hardware.
15807 @end table
15808
15809 @noindent
15810 Additionally, there are the following general correspondences between Ada
15811 and C types:
15812 @itemize @bullet
15813 @item
15814 Ada enumeration types map to C enumeration types directly if pragma
15815 @code{Convention C} is specified, which causes them to have int
15816 length. Without pragma @code{Convention C}, Ada enumeration types map to
15817 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15818 @code{int}, respectively) depending on the number of values passed.
15819 This is the only case in which pragma @code{Convention C} affects the
15820 representation of an Ada type.
15821
15822 @item
15823 Ada access types map to C pointers, except for the case of pointers to
15824 unconstrained types in Ada, which have no direct C equivalent.
15825
15826 @item
15827 Ada arrays map directly to C arrays.
15828
15829 @item
15830 Ada records map directly to C structures.
15831
15832 @item
15833 Packed Ada records map to C structures where all members are bit fields
15834 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15835 @end itemize
15836
15837 @node Interfacing to C++
15838 @section Interfacing to C++
15839
15840 @noindent
15841 The interface to C++ makes use of the following pragmas, which are
15842 primarily intended to be constructed automatically using a binding generator
15843 tool, although it is possible to construct them by hand. No suitable binding
15844 generator tool is supplied with GNAT though.
15845
15846 Using these pragmas it is possible to achieve complete
15847 inter-operability between Ada tagged types and C++ class definitions.
15848 See @ref{Implementation Defined Pragmas}, for more details.
15849
15850 @table @code
15851 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15852 The argument denotes an entity in the current declarative region that is
15853 declared as a tagged or untagged record type. It indicates that the type
15854 corresponds to an externally declared C++ class type, and is to be laid
15855 out the same way that C++ would lay out the type.
15856
15857 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15858 for backward compatibility but its functionality is available
15859 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15860
15861 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15862 This pragma identifies an imported function (imported in the usual way
15863 with pragma @code{Import}) as corresponding to a C++ constructor.
15864 @end table
15865
15866 @node Interfacing to COBOL
15867 @section Interfacing to COBOL
15868
15869 @noindent
15870 Interfacing to COBOL is achieved as described in section B.4 of
15871 the Ada Reference Manual.
15872
15873 @node Interfacing to Fortran
15874 @section Interfacing to Fortran
15875
15876 @noindent
15877 Interfacing to Fortran is achieved as described in section B.5 of the
15878 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
15879 multi-dimensional array causes the array to be stored in column-major
15880 order as required for convenient interface to Fortran.
15881
15882 @node Interfacing to non-GNAT Ada code
15883 @section Interfacing to non-GNAT Ada code
15884
15885 It is possible to specify the convention @code{Ada} in a pragma
15886 @code{Import} or pragma @code{Export}. However this refers to
15887 the calling conventions used by GNAT, which may or may not be
15888 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15889 compiler to allow interoperation.
15890
15891 If arguments types are kept simple, and if the foreign compiler generally
15892 follows system calling conventions, then it may be possible to integrate
15893 files compiled by other Ada compilers, provided that the elaboration
15894 issues are adequately addressed (for example by eliminating the
15895 need for any load time elaboration).
15896
15897 In particular, GNAT running on VMS is designed to
15898 be highly compatible with the DEC Ada 83 compiler, so this is one
15899 case in which it is possible to import foreign units of this type,
15900 provided that the data items passed are restricted to simple scalar
15901 values or simple record types without variants, or simple array
15902 types with fixed bounds.
15903
15904 @node Specialized Needs Annexes
15905 @chapter Specialized Needs Annexes
15906
15907 @noindent
15908 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15909 required in all implementations. However, as described in this chapter,
15910 GNAT implements all of these annexes:
15911
15912 @table @asis
15913 @item Systems Programming (Annex C)
15914 The Systems Programming Annex is fully implemented.
15915
15916 @item Real-Time Systems (Annex D)
15917 The Real-Time Systems Annex is fully implemented.
15918
15919 @item Distributed Systems (Annex E)
15920 Stub generation is fully implemented in the GNAT compiler. In addition,
15921 a complete compatible PCS is available as part of the GLADE system,
15922 a separate product. When the two
15923 products are used in conjunction, this annex is fully implemented.
15924
15925 @item Information Systems (Annex F)
15926 The Information Systems annex is fully implemented.
15927
15928 @item Numerics (Annex G)
15929 The Numerics Annex is fully implemented.
15930
15931 @item Safety and Security / High-Integrity Systems (Annex H)
15932 The Safety and Security Annex (termed the High-Integrity Systems Annex
15933 in Ada 2005) is fully implemented.
15934 @end table
15935
15936 @node Implementation of Specific Ada Features
15937 @chapter Implementation of Specific Ada Features
15938
15939 @noindent
15940 This chapter describes the GNAT implementation of several Ada language
15941 facilities.
15942
15943 @menu
15944 * Machine Code Insertions::
15945 * GNAT Implementation of Tasking::
15946 * GNAT Implementation of Shared Passive Packages::
15947 * Code Generation for Array Aggregates::
15948 * The Size of Discriminated Records with Default Discriminants::
15949 * Strict Conformance to the Ada Reference Manual::
15950 @end menu
15951
15952 @node Machine Code Insertions
15953 @section Machine Code Insertions
15954 @cindex Machine Code insertions
15955
15956 @noindent
15957 Package @code{Machine_Code} provides machine code support as described
15958 in the Ada Reference Manual in two separate forms:
15959 @itemize @bullet
15960 @item
15961 Machine code statements, consisting of qualified expressions that
15962 fit the requirements of RM section 13.8.
15963 @item
15964 An intrinsic callable procedure, providing an alternative mechanism of
15965 including machine instructions in a subprogram.
15966 @end itemize
15967
15968 @noindent
15969 The two features are similar, and both are closely related to the mechanism
15970 provided by the asm instruction in the GNU C compiler. Full understanding
15971 and use of the facilities in this package requires understanding the asm
15972 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15973 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15974
15975 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15976 semantic restrictions and effects as described below. Both are provided so
15977 that the procedure call can be used as a statement, and the function call
15978 can be used to form a code_statement.
15979
15980 The first example given in the GCC documentation is the C @code{asm}
15981 instruction:
15982 @smallexample
15983 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15984 @end smallexample
15985
15986 @noindent
15987 The equivalent can be written for GNAT as:
15988
15989 @smallexample @c ada
15990 Asm ("fsinx %1 %0",
15991 My_Float'Asm_Output ("=f", result),
15992 My_Float'Asm_Input ("f", angle));
15993 @end smallexample
15994
15995 @noindent
15996 The first argument to @code{Asm} is the assembler template, and is
15997 identical to what is used in GNU C@. This string must be a static
15998 expression. The second argument is the output operand list. It is
15999 either a single @code{Asm_Output} attribute reference, or a list of such
16000 references enclosed in parentheses (technically an array aggregate of
16001 such references).
16002
16003 The @code{Asm_Output} attribute denotes a function that takes two
16004 parameters. The first is a string, the second is the name of a variable
16005 of the type designated by the attribute prefix. The first (string)
16006 argument is required to be a static expression and designates the
16007 constraint for the parameter (e.g.@: what kind of register is
16008 required). The second argument is the variable to be updated with the
16009 result. The possible values for constraint are the same as those used in
16010 the RTL, and are dependent on the configuration file used to build the
16011 GCC back end. If there are no output operands, then this argument may
16012 either be omitted, or explicitly given as @code{No_Output_Operands}.
16013
16014 The second argument of @code{@var{my_float}'Asm_Output} functions as
16015 though it were an @code{out} parameter, which is a little curious, but
16016 all names have the form of expressions, so there is no syntactic
16017 irregularity, even though normally functions would not be permitted
16018 @code{out} parameters. The third argument is the list of input
16019 operands. It is either a single @code{Asm_Input} attribute reference, or
16020 a list of such references enclosed in parentheses (technically an array
16021 aggregate of such references).
16022
16023 The @code{Asm_Input} attribute denotes a function that takes two
16024 parameters. The first is a string, the second is an expression of the
16025 type designated by the prefix. The first (string) argument is required
16026 to be a static expression, and is the constraint for the parameter,
16027 (e.g.@: what kind of register is required). The second argument is the
16028 value to be used as the input argument. The possible values for the
16029 constant are the same as those used in the RTL, and are dependent on
16030 the configuration file used to built the GCC back end.
16031
16032 If there are no input operands, this argument may either be omitted, or
16033 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16034 present in the above example, is a list of register names, called the
16035 @dfn{clobber} argument. This argument, if given, must be a static string
16036 expression, and is a space or comma separated list of names of registers
16037 that must be considered destroyed as a result of the @code{Asm} call. If
16038 this argument is the null string (the default value), then the code
16039 generator assumes that no additional registers are destroyed.
16040
16041 The fifth argument, not present in the above example, called the
16042 @dfn{volatile} argument, is by default @code{False}. It can be set to
16043 the literal value @code{True} to indicate to the code generator that all
16044 optimizations with respect to the instruction specified should be
16045 suppressed, and that in particular, for an instruction that has outputs,
16046 the instruction will still be generated, even if none of the outputs are
16047 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16048 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16049 Generally it is strongly advisable to use Volatile for any ASM statement
16050 that is missing either input or output operands, or when two or more ASM
16051 statements appear in sequence, to avoid unwanted optimizations. A warning
16052 is generated if this advice is not followed.
16053
16054 The @code{Asm} subprograms may be used in two ways. First the procedure
16055 forms can be used anywhere a procedure call would be valid, and
16056 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16057 be used to intersperse machine instructions with other Ada statements.
16058 Second, the function forms, which return a dummy value of the limited
16059 private type @code{Asm_Insn}, can be used in code statements, and indeed
16060 this is the only context where such calls are allowed. Code statements
16061 appear as aggregates of the form:
16062
16063 @smallexample @c ada
16064 Asm_Insn'(Asm (@dots{}));
16065 Asm_Insn'(Asm_Volatile (@dots{}));
16066 @end smallexample
16067
16068 @noindent
16069 In accordance with RM rules, such code statements are allowed only
16070 within subprograms whose entire body consists of such statements. It is
16071 not permissible to intermix such statements with other Ada statements.
16072
16073 Typically the form using intrinsic procedure calls is more convenient
16074 and more flexible. The code statement form is provided to meet the RM
16075 suggestion that such a facility should be made available. The following
16076 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16077 is used, the arguments may be given in arbitrary order, following the
16078 normal rules for use of positional and named arguments)
16079
16080 @smallexample
16081 ASM_CALL ::= Asm (
16082 [Template =>] static_string_EXPRESSION
16083 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16084 [,[Inputs =>] INPUT_OPERAND_LIST ]
16085 [,[Clobber =>] static_string_EXPRESSION ]
16086 [,[Volatile =>] static_boolean_EXPRESSION] )
16087
16088 OUTPUT_OPERAND_LIST ::=
16089 [PREFIX.]No_Output_Operands
16090 | OUTPUT_OPERAND_ATTRIBUTE
16091 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16092
16093 OUTPUT_OPERAND_ATTRIBUTE ::=
16094 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16095
16096 INPUT_OPERAND_LIST ::=
16097 [PREFIX.]No_Input_Operands
16098 | INPUT_OPERAND_ATTRIBUTE
16099 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16100
16101 INPUT_OPERAND_ATTRIBUTE ::=
16102 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16103 @end smallexample
16104
16105 @noindent
16106 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16107 are declared in the package @code{Machine_Code} and must be referenced
16108 according to normal visibility rules. In particular if there is no
16109 @code{use} clause for this package, then appropriate package name
16110 qualification is required.
16111
16112 @node GNAT Implementation of Tasking
16113 @section GNAT Implementation of Tasking
16114
16115 @noindent
16116 This chapter outlines the basic GNAT approach to tasking (in particular,
16117 a multi-layered library for portability) and discusses issues related
16118 to compliance with the Real-Time Systems Annex.
16119
16120 @menu
16121 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16122 * Ensuring Compliance with the Real-Time Annex::
16123 @end menu
16124
16125 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16126 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16127
16128 @noindent
16129 GNAT's run-time support comprises two layers:
16130
16131 @itemize @bullet
16132 @item GNARL (GNAT Run-time Layer)
16133 @item GNULL (GNAT Low-level Library)
16134 @end itemize
16135
16136 @noindent
16137 In GNAT, Ada's tasking services rely on a platform and OS independent
16138 layer known as GNARL@. This code is responsible for implementing the
16139 correct semantics of Ada's task creation, rendezvous, protected
16140 operations etc.
16141
16142 GNARL decomposes Ada's tasking semantics into simpler lower level
16143 operations such as create a thread, set the priority of a thread,
16144 yield, create a lock, lock/unlock, etc. The spec for these low-level
16145 operations constitutes GNULLI, the GNULL Interface. This interface is
16146 directly inspired from the POSIX real-time API@.
16147
16148 If the underlying executive or OS implements the POSIX standard
16149 faithfully, the GNULL Interface maps as is to the services offered by
16150 the underlying kernel. Otherwise, some target dependent glue code maps
16151 the services offered by the underlying kernel to the semantics expected
16152 by GNARL@.
16153
16154 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16155 key point is that each Ada task is mapped on a thread in the underlying
16156 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16157
16158 In addition Ada task priorities map onto the underlying thread priorities.
16159 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16160
16161 @itemize @bullet
16162 @item
16163 The underlying scheduler is used to schedule the Ada tasks. This
16164 makes Ada tasks as efficient as kernel threads from a scheduling
16165 standpoint.
16166
16167 @item
16168 Interaction with code written in C containing threads is eased
16169 since at the lowest level Ada tasks and C threads map onto the same
16170 underlying kernel concept.
16171
16172 @item
16173 When an Ada task is blocked during I/O the remaining Ada tasks are
16174 able to proceed.
16175
16176 @item
16177 On multiprocessor systems Ada tasks can execute in parallel.
16178 @end itemize
16179
16180 @noindent
16181 Some threads libraries offer a mechanism to fork a new process, with the
16182 child process duplicating the threads from the parent.
16183 GNAT does not
16184 support this functionality when the parent contains more than one task.
16185 @cindex Forking a new process
16186
16187 @node Ensuring Compliance with the Real-Time Annex
16188 @subsection Ensuring Compliance with the Real-Time Annex
16189 @cindex Real-Time Systems Annex compliance
16190
16191 @noindent
16192 Although mapping Ada tasks onto
16193 the underlying threads has significant advantages, it does create some
16194 complications when it comes to respecting the scheduling semantics
16195 specified in the real-time annex (Annex D).
16196
16197 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16198 scheduling policy states:
16199
16200 @quotation
16201 @emph{When the active priority of a ready task that is not running
16202 changes, or the setting of its base priority takes effect, the
16203 task is removed from the ready queue for its old active priority
16204 and is added at the tail of the ready queue for its new active
16205 priority, except in the case where the active priority is lowered
16206 due to the loss of inherited priority, in which case the task is
16207 added at the head of the ready queue for its new active priority.}
16208 @end quotation
16209
16210 @noindent
16211 While most kernels do put tasks at the end of the priority queue when
16212 a task changes its priority, (which respects the main
16213 FIFO_Within_Priorities requirement), almost none keep a thread at the
16214 beginning of its priority queue when its priority drops from the loss
16215 of inherited priority.
16216
16217 As a result most vendors have provided incomplete Annex D implementations.
16218
16219 The GNAT run-time, has a nice cooperative solution to this problem
16220 which ensures that accurate FIFO_Within_Priorities semantics are
16221 respected.
16222
16223 The principle is as follows. When an Ada task T is about to start
16224 running, it checks whether some other Ada task R with the same
16225 priority as T has been suspended due to the loss of priority
16226 inheritance. If this is the case, T yields and is placed at the end of
16227 its priority queue. When R arrives at the front of the queue it
16228 executes.
16229
16230 Note that this simple scheme preserves the relative order of the tasks
16231 that were ready to execute in the priority queue where R has been
16232 placed at the end.
16233
16234 @node GNAT Implementation of Shared Passive Packages
16235 @section GNAT Implementation of Shared Passive Packages
16236 @cindex Shared passive packages
16237
16238 @noindent
16239 GNAT fully implements the pragma @code{Shared_Passive} for
16240 @cindex pragma @code{Shared_Passive}
16241 the purpose of designating shared passive packages.
16242 This allows the use of passive partitions in the
16243 context described in the Ada Reference Manual; i.e., for communication
16244 between separate partitions of a distributed application using the
16245 features in Annex E.
16246 @cindex Annex E
16247 @cindex Distribution Systems Annex
16248
16249 However, the implementation approach used by GNAT provides for more
16250 extensive usage as follows:
16251
16252 @table @emph
16253 @item Communication between separate programs
16254
16255 This allows separate programs to access the data in passive
16256 partitions, using protected objects for synchronization where
16257 needed. The only requirement is that the two programs have a
16258 common shared file system. It is even possible for programs
16259 running on different machines with different architectures
16260 (e.g.@: different endianness) to communicate via the data in
16261 a passive partition.
16262
16263 @item Persistence between program runs
16264
16265 The data in a passive package can persist from one run of a
16266 program to another, so that a later program sees the final
16267 values stored by a previous run of the same program.
16268
16269 @end table
16270
16271 @noindent
16272 The implementation approach used is to store the data in files. A
16273 separate stream file is created for each object in the package, and
16274 an access to an object causes the corresponding file to be read or
16275 written.
16276
16277 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16278 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16279 set to the directory to be used for these files.
16280 The files in this directory
16281 have names that correspond to their fully qualified names. For
16282 example, if we have the package
16283
16284 @smallexample @c ada
16285 package X is
16286 pragma Shared_Passive (X);
16287 Y : Integer;
16288 Z : Float;
16289 end X;
16290 @end smallexample
16291
16292 @noindent
16293 and the environment variable is set to @code{/stemp/}, then the files created
16294 will have the names:
16295
16296 @smallexample
16297 /stemp/x.y
16298 /stemp/x.z
16299 @end smallexample
16300
16301 @noindent
16302 These files are created when a value is initially written to the object, and
16303 the files are retained until manually deleted. This provides the persistence
16304 semantics. If no file exists, it means that no partition has assigned a value
16305 to the variable; in this case the initial value declared in the package
16306 will be used. This model ensures that there are no issues in synchronizing
16307 the elaboration process, since elaboration of passive packages elaborates the
16308 initial values, but does not create the files.
16309
16310 The files are written using normal @code{Stream_IO} access.
16311 If you want to be able
16312 to communicate between programs or partitions running on different
16313 architectures, then you should use the XDR versions of the stream attribute
16314 routines, since these are architecture independent.
16315
16316 If active synchronization is required for access to the variables in the
16317 shared passive package, then as described in the Ada Reference Manual, the
16318 package may contain protected objects used for this purpose. In this case
16319 a lock file (whose name is @file{___lock} (three underscores)
16320 is created in the shared memory directory.
16321 @cindex @file{___lock} file (for shared passive packages)
16322 This is used to provide the required locking
16323 semantics for proper protected object synchronization.
16324
16325 As of January 2003, GNAT supports shared passive packages on all platforms
16326 except for OpenVMS.
16327
16328 @node Code Generation for Array Aggregates
16329 @section Code Generation for Array Aggregates
16330
16331 @menu
16332 * Static constant aggregates with static bounds::
16333 * Constant aggregates with unconstrained nominal types::
16334 * Aggregates with static bounds::
16335 * Aggregates with non-static bounds::
16336 * Aggregates in assignment statements::
16337 @end menu
16338
16339 @noindent
16340 Aggregates have a rich syntax and allow the user to specify the values of
16341 complex data structures by means of a single construct. As a result, the
16342 code generated for aggregates can be quite complex and involve loops, case
16343 statements and multiple assignments. In the simplest cases, however, the
16344 compiler will recognize aggregates whose components and constraints are
16345 fully static, and in those cases the compiler will generate little or no
16346 executable code. The following is an outline of the code that GNAT generates
16347 for various aggregate constructs. For further details, you will find it
16348 useful to examine the output produced by the -gnatG flag to see the expanded
16349 source that is input to the code generator. You may also want to examine
16350 the assembly code generated at various levels of optimization.
16351
16352 The code generated for aggregates depends on the context, the component values,
16353 and the type. In the context of an object declaration the code generated is
16354 generally simpler than in the case of an assignment. As a general rule, static
16355 component values and static subtypes also lead to simpler code.
16356
16357 @node Static constant aggregates with static bounds
16358 @subsection Static constant aggregates with static bounds
16359
16360 @noindent
16361 For the declarations:
16362 @smallexample @c ada
16363 type One_Dim is array (1..10) of integer;
16364 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16365 @end smallexample
16366
16367 @noindent
16368 GNAT generates no executable code: the constant ar0 is placed in static memory.
16369 The same is true for constant aggregates with named associations:
16370
16371 @smallexample @c ada
16372 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16373 Cr3 : constant One_Dim := (others => 7777);
16374 @end smallexample
16375
16376 @noindent
16377 The same is true for multidimensional constant arrays such as:
16378
16379 @smallexample @c ada
16380 type two_dim is array (1..3, 1..3) of integer;
16381 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16382 @end smallexample
16383
16384 @noindent
16385 The same is true for arrays of one-dimensional arrays: the following are
16386 static:
16387
16388 @smallexample @c ada
16389 type ar1b is array (1..3) of boolean;
16390 type ar_ar is array (1..3) of ar1b;
16391 None : constant ar1b := (others => false); -- fully static
16392 None2 : constant ar_ar := (1..3 => None); -- fully static
16393 @end smallexample
16394
16395 @noindent
16396 However, for multidimensional aggregates with named associations, GNAT will
16397 generate assignments and loops, even if all associations are static. The
16398 following two declarations generate a loop for the first dimension, and
16399 individual component assignments for the second dimension:
16400
16401 @smallexample @c ada
16402 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16403 Zero2: constant two_dim := (others => (others => 0));
16404 @end smallexample
16405
16406 @node Constant aggregates with unconstrained nominal types
16407 @subsection Constant aggregates with unconstrained nominal types
16408
16409 @noindent
16410 In such cases the aggregate itself establishes the subtype, so that
16411 associations with @code{others} cannot be used. GNAT determines the
16412 bounds for the actual subtype of the aggregate, and allocates the
16413 aggregate statically as well. No code is generated for the following:
16414
16415 @smallexample @c ada
16416 type One_Unc is array (natural range <>) of integer;
16417 Cr_Unc : constant One_Unc := (12,24,36);
16418 @end smallexample
16419
16420 @node Aggregates with static bounds
16421 @subsection Aggregates with static bounds
16422
16423 @noindent
16424 In all previous examples the aggregate was the initial (and immutable) value
16425 of a constant. If the aggregate initializes a variable, then code is generated
16426 for it as a combination of individual assignments and loops over the target
16427 object. The declarations
16428
16429 @smallexample @c ada
16430 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16431 Cr_Var2 : One_Dim := (others > -1);
16432 @end smallexample
16433
16434 @noindent
16435 generate the equivalent of
16436
16437 @smallexample @c ada
16438 Cr_Var1 (1) := 2;
16439 Cr_Var1 (2) := 3;
16440 Cr_Var1 (3) := 5;
16441 Cr_Var1 (4) := 11;
16442
16443 for I in Cr_Var2'range loop
16444 Cr_Var2 (I) := -1;
16445 end loop;
16446 @end smallexample
16447
16448 @node Aggregates with non-static bounds
16449 @subsection Aggregates with non-static bounds
16450
16451 @noindent
16452 If the bounds of the aggregate are not statically compatible with the bounds
16453 of the nominal subtype of the target, then constraint checks have to be
16454 generated on the bounds. For a multidimensional array, constraint checks may
16455 have to be applied to sub-arrays individually, if they do not have statically
16456 compatible subtypes.
16457
16458 @node Aggregates in assignment statements
16459 @subsection Aggregates in assignment statements
16460
16461 @noindent
16462 In general, aggregate assignment requires the construction of a temporary,
16463 and a copy from the temporary to the target of the assignment. This is because
16464 it is not always possible to convert the assignment into a series of individual
16465 component assignments. For example, consider the simple case:
16466
16467 @smallexample @c ada
16468 A := (A(2), A(1));
16469 @end smallexample
16470
16471 @noindent
16472 This cannot be converted into:
16473
16474 @smallexample @c ada
16475 A(1) := A(2);
16476 A(2) := A(1);
16477 @end smallexample
16478
16479 @noindent
16480 So the aggregate has to be built first in a separate location, and then
16481 copied into the target. GNAT recognizes simple cases where this intermediate
16482 step is not required, and the assignments can be performed in place, directly
16483 into the target. The following sufficient criteria are applied:
16484
16485 @itemize @bullet
16486 @item
16487 The bounds of the aggregate are static, and the associations are static.
16488 @item
16489 The components of the aggregate are static constants, names of
16490 simple variables that are not renamings, or expressions not involving
16491 indexed components whose operands obey these rules.
16492 @end itemize
16493
16494 @noindent
16495 If any of these conditions are violated, the aggregate will be built in
16496 a temporary (created either by the front-end or the code generator) and then
16497 that temporary will be copied onto the target.
16498
16499 @node The Size of Discriminated Records with Default Discriminants
16500 @section The Size of Discriminated Records with Default Discriminants
16501
16502 @noindent
16503 If a discriminated type @code{T} has discriminants with default values, it is
16504 possible to declare an object of this type without providing an explicit
16505 constraint:
16506
16507 @smallexample @c ada
16508 @group
16509 type Size is range 1..100;
16510
16511 type Rec (D : Size := 15) is record
16512 Name : String (1..D);
16513 end T;
16514
16515 Word : Rec;
16516 @end group
16517 @end smallexample
16518
16519 @noindent
16520 Such an object is said to be @emph{unconstrained}.
16521 The discriminant of the object
16522 can be modified by a full assignment to the object, as long as it preserves the
16523 relation between the value of the discriminant, and the value of the components
16524 that depend on it:
16525
16526 @smallexample @c ada
16527 @group
16528 Word := (3, "yes");
16529
16530 Word := (5, "maybe");
16531
16532 Word := (5, "no"); -- raises Constraint_Error
16533 @end group
16534 @end smallexample
16535
16536 @noindent
16537 In order to support this behavior efficiently, an unconstrained object is
16538 given the maximum size that any value of the type requires. In the case
16539 above, @code{Word} has storage for the discriminant and for
16540 a @code{String} of length 100.
16541 It is important to note that unconstrained objects do not require dynamic
16542 allocation. It would be an improper implementation to place on the heap those
16543 components whose size depends on discriminants. (This improper implementation
16544 was used by some Ada83 compilers, where the @code{Name} component above
16545 would have
16546 been stored as a pointer to a dynamic string). Following the principle that
16547 dynamic storage management should never be introduced implicitly,
16548 an Ada compiler should reserve the full size for an unconstrained declared
16549 object, and place it on the stack.
16550
16551 This maximum size approach
16552 has been a source of surprise to some users, who expect the default
16553 values of the discriminants to determine the size reserved for an
16554 unconstrained object: ``If the default is 15, why should the object occupy
16555 a larger size?''
16556 The answer, of course, is that the discriminant may be later modified,
16557 and its full range of values must be taken into account. This is why the
16558 declaration:
16559
16560 @smallexample
16561 @group
16562 type Rec (D : Positive := 15) is record
16563 Name : String (1..D);
16564 end record;
16565
16566 Too_Large : Rec;
16567 @end group
16568 @end smallexample
16569
16570 @noindent
16571 is flagged by the compiler with a warning:
16572 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16573 because the required size includes @code{Positive'Last}
16574 bytes. As the first example indicates, the proper approach is to declare an
16575 index type of ``reasonable'' range so that unconstrained objects are not too
16576 large.
16577
16578 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16579 created in the heap by means of an allocator, then it is @emph{not}
16580 unconstrained:
16581 it is constrained by the default values of the discriminants, and those values
16582 cannot be modified by full assignment. This is because in the presence of
16583 aliasing all views of the object (which may be manipulated by different tasks,
16584 say) must be consistent, so it is imperative that the object, once created,
16585 remain invariant.
16586
16587 @node Strict Conformance to the Ada Reference Manual
16588 @section Strict Conformance to the Ada Reference Manual
16589
16590 @noindent
16591 The dynamic semantics defined by the Ada Reference Manual impose a set of
16592 run-time checks to be generated. By default, the GNAT compiler will insert many
16593 run-time checks into the compiled code, including most of those required by the
16594 Ada Reference Manual. However, there are three checks that are not enabled
16595 in the default mode for efficiency reasons: arithmetic overflow checking for
16596 integer operations (including division by zero), checks for access before
16597 elaboration on subprogram calls, and stack overflow checking (most operating
16598 systems do not perform this check by default).
16599
16600 Strict conformance to the Ada Reference Manual can be achieved by adding
16601 three compiler options for overflow checking for integer operations
16602 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16603 calls and generic instantiations (@option{-gnatE}), and stack overflow
16604 checking (@option{-fstack-check}).
16605
16606 Note that the result of a floating point arithmetic operation in overflow and
16607 invalid situations, when the @code{Machine_Overflows} attribute of the result
16608 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16609 case for machines compliant with the IEEE floating-point standard, but on
16610 machines that are not fully compliant with this standard, such as Alpha, the
16611 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16612 behavior (although at the cost of a significant performance penalty), so
16613 infinite and NaN values are properly generated.
16614
16615
16616 @node Implementation of Ada 2012 Features
16617 @chapter Implementation of Ada 2012 Features
16618 @cindex Ada 2012 implementation status
16619
16620 This chapter contains a complete list of Ada 2012 features that have been
16621 implemented as of GNAT version 6.4. Generally, these features are only
16622 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16623 @cindex @option{-gnat12} option
16624 or if the configuration pragma @code{Ada_2012} is used.
16625 @cindex pragma @code{Ada_2012}
16626 @cindex configuration pragma @code{Ada_2012}
16627 @cindex @code{Ada_2012} configuration pragma
16628 However, new pragmas, attributes, and restrictions are
16629 unconditionally available, since the Ada 95 standard allows the addition of
16630 new pragmas, attributes, and restrictions (there are exceptions, which are
16631 documented in the individual descriptions), and also certain packages
16632 were made available in earlier versions of Ada.
16633
16634 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16635 This date shows the implementation date of the feature. Any wavefront
16636 subsequent to this date will contain the indicated feature, as will any
16637 subsequent releases. A date of 0000-00-00 means that GNAT has always
16638 implemented the feature, or implemented it as soon as it appeared as a
16639 binding interpretation.
16640
16641 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16642 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16643 The features are ordered based on the relevant sections of the Ada
16644 Reference Manual (``RM''). When a given AI relates to multiple points
16645 in the RM, the earliest is used.
16646
16647 A complete description of the AIs may be found in
16648 @url{www.ada-auth.org/ai05-summary.html}.
16649
16650 @itemize @bullet
16651
16652 @item
16653 @emph{AI-0176 Quantified expressions (2010-09-29)}
16654 @cindex AI-0176 (Ada 2012 feature)
16655
16656 @noindent
16657 Both universally and existentially quantified expressions are implemented.
16658 They use the new syntax for iterators proposed in AI05-139-2, as well as
16659 the standard Ada loop syntax.
16660
16661 @noindent
16662 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
16663
16664 @item
16665 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16666 @cindex AI-0079 (Ada 2012 feature)
16667
16668 @noindent
16669 Wide characters in the unicode category @i{other_format} are now allowed in
16670 source programs between tokens, but not within a token such as an identifier.
16671
16672 @noindent
16673 RM References: 2.01 (4/2) 2.02 (7)
16674
16675 @item
16676 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16677 @cindex AI-0091 (Ada 2012 feature)
16678
16679 @noindent
16680 Wide characters in the unicode category @i{other_format} are not permitted
16681 within an identifier, since this can be a security problem. The error
16682 message for this case has been improved to be more specific, but GNAT has
16683 never allowed such characters to appear in identifiers.
16684
16685 @noindent
16686 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)
16687
16688 @item
16689 @emph{AI-0100 Placement of pragmas (2010-07-01)}
16690 @cindex AI-0100 (Ada 2012 feature)
16691
16692 @noindent
16693 This AI is an earlier version of AI-163. It simplifies the rules
16694 for legal placement of pragmas. In the case of lists that allow pragmas, if
16695 the list may have no elements, then the list may consist solely of pragmas.
16696
16697 @noindent
16698 RM References: 2.08 (7)
16699
16700 @item
16701 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16702 @cindex AI-0163 (Ada 2012 feature)
16703
16704 @noindent
16705 A statement sequence may be composed entirely of pragmas. It is no longer
16706 necessary to add a dummy @code{null} statement to make the sequence legal.
16707
16708 @noindent
16709 RM References: 2.08 (7) 2.08 (16)
16710
16711
16712 @item
16713 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16714 @cindex AI-0080 (Ada 2012 feature)
16715
16716 @noindent
16717 This is an editorial change only, described as non-testable in the AI.
16718
16719 @noindent
16720 RM References: 3.01 (7)
16721
16722
16723 @item
16724 @emph{AI-0183 Aspect specifications (2010-08-16)}
16725 @cindex AI-0183 (Ada 2012 feature)
16726
16727 @noindent
16728 Aspect specifications have been fully implemented except for pre and post-
16729 conditions, and type invariants, which have their own separate AI's. All
16730 forms of declarations listed in the AI are supported. The following is a
16731 list of the aspects supported (with GNAT implementation aspects marked)
16732
16733 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16734 @item @code{Ada_2005} @tab -- GNAT
16735 @item @code{Ada_2012} @tab -- GNAT
16736 @item @code{Address} @tab
16737 @item @code{Alignment} @tab
16738 @item @code{Atomic} @tab
16739 @item @code{Atomic_Components} @tab
16740 @item @code{Bit_Order} @tab
16741 @item @code{Component_Size} @tab
16742 @item @code{Discard_Names} @tab
16743 @item @code{External_Tag} @tab
16744 @item @code{Favor_Top_Level} @tab -- GNAT
16745 @item @code{Inline} @tab
16746 @item @code{Inline_Always} @tab -- GNAT
16747 @item @code{Invariant} @tab
16748 @item @code{Machine_Radix} @tab
16749 @item @code{No_Return} @tab
16750 @item @code{Object_Size} @tab -- GNAT
16751 @item @code{Pack} @tab
16752 @item @code{Persistent_BSS} @tab -- GNAT
16753 @item @code{Post} @tab
16754 @item @code{Pre} @tab
16755 @item @code{Predicate} @tab
16756 @item @code{Preelaborable_Initialization} @tab
16757 @item @code{Pure_Function} @tab -- GNAT
16758 @item @code{Shared} @tab -- GNAT
16759 @item @code{Size} @tab
16760 @item @code{Storage_Pool} @tab
16761 @item @code{Storage_Size} @tab
16762 @item @code{Stream_Size} @tab
16763 @item @code{Suppress} @tab
16764 @item @code{Suppress_Debug_Info} @tab -- GNAT
16765 @item @code{Test_Case} @tab -- GNAT
16766 @item @code{Unchecked_Union} @tab
16767 @item @code{Universal_Aliasing} @tab -- GNAT
16768 @item @code{Unmodified} @tab -- GNAT
16769 @item @code{Unreferenced} @tab -- GNAT
16770 @item @code{Unreferenced_Objects} @tab -- GNAT
16771 @item @code{Unsuppress} @tab
16772 @item @code{Value_Size} @tab -- GNAT
16773 @item @code{Volatile} @tab
16774 @item @code{Volatile_Components}
16775 @item @code{Warnings} @tab -- GNAT
16776 @end multitable
16777
16778 @noindent
16779 Note that for aspects with an expression, e.g. @code{Size}, the expression is
16780 treated like a default expression (visibility is analyzed at the point of
16781 occurrence of the aspect, but evaluation of the expression occurs at the
16782 freeze point of the entity involved.
16783
16784 @noindent
16785 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
16786 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
16787 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
16788 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
16789 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
16790 13.03.01 (0)
16791
16792
16793 @item
16794 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16795 @cindex AI-0128 (Ada 2012 feature)
16796
16797 @noindent
16798 If an equality operator ("=") is declared for a type, then the implicitly
16799 declared inequality operator ("/=") is a primitive operation of the type.
16800 This is the only reasonable interpretation, and is the one always implemented
16801 by GNAT, but the RM was not entirely clear in making this point.
16802
16803 @noindent
16804 RM References: 3.02.03 (6) 6.06 (6)
16805
16806 @item
16807 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16808 @cindex AI-0003 (Ada 2012 feature)
16809
16810 @noindent
16811 In Ada 2012, a qualified expression is considered to be syntactically a name,
16812 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16813 useful in disambiguating some cases of overloading.
16814
16815 @noindent
16816 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
16817 5.04 (7)
16818
16819 @item
16820 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16821 @cindex AI-0120 (Ada 2012 feature)
16822
16823 @noindent
16824 This is an RM editorial change only. The section that lists objects that are
16825 constant failed to include the current instance of a protected object
16826 within a protected function. This has always been treated as a constant
16827 in GNAT.
16828
16829 @noindent
16830 RM References: 3.03 (21)
16831
16832 @item
16833 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16834 @cindex AI-0008 (Ada 2012 feature)
16835
16836 @noindent
16837 The wording in the RM implied that if you have a general access to a
16838 constrained object, it could be used to modify the discriminants. This was
16839 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16840 has always done so in this situation.
16841
16842 @noindent
16843 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
16844
16845
16846 @item
16847 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16848 @cindex AI-0093 (Ada 2012 feature)
16849
16850 @noindent
16851 This is an editorial change only, to make more widespread use of the Ada 2012
16852 ``immutably limited''.
16853
16854 @noindent
16855 RM References: 3.03 (23.4/3)
16856
16857
16858
16859 @item
16860 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16861 @cindex AI-0096 (Ada 2012 feature)
16862
16863 @noindent
16864 In general it is illegal for a type derived from a formal limited type to be
16865 nonlimited. This AI makes an exception to this rule: derivation is legal
16866 if it appears in the private part of the generic, and the formal type is not
16867 tagged. If the type is tagged, the legality check must be applied to the
16868 private part of the package.
16869
16870 @noindent
16871 RM References: 3.04 (5.1/2) 6.02 (7)
16872
16873
16874 @item
16875 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16876 @cindex AI-0181 (Ada 2012 feature)
16877
16878 @noindent
16879 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16880 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16881 @code{Image} and @code{Value} attributes for the character types. Strictly
16882 speaking this is an inconsistency with Ada 95, but in practice the use of
16883 these attributes is so obscure that it will not cause problems.
16884
16885 @noindent
16886 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
16887
16888
16889 @item
16890 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16891 @cindex AI-0182 (Ada 2012 feature)
16892
16893 @noindent
16894 This AI allows @code{Character'Value} to accept the string @code{'?'} where
16895 @code{?} is any character including non-graphic control characters. GNAT has
16896 always accepted such strings. It also allows strings such as
16897 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16898 permission and raises @code{Constraint_Error}, as is certainly still
16899 permitted.
16900
16901 @noindent
16902 RM References: 3.05 (56/2)
16903
16904
16905 @item
16906 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16907 @cindex AI-0214 (Ada 2012 feature)
16908
16909 @noindent
16910 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16911 to have default expressions by allowing them when the type is limited. It
16912 is often useful to define a default value for a discriminant even though
16913 it can't be changed by assignment.
16914
16915 @noindent
16916 RM References: 3.07 (9.1/2) 3.07.02 (3)
16917
16918
16919 @item
16920 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16921 @cindex AI-0102 (Ada 2012 feature)
16922
16923 @noindent
16924 It is illegal to assign an anonymous access constant to an anonymous access
16925 variable. The RM did not have a clear rule to prevent this, but GNAT has
16926 always generated an error for this usage.
16927
16928 @noindent
16929 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
16930
16931
16932 @item
16933 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16934 @cindex AI-0158 (Ada 2012 feature)
16935
16936 @noindent
16937 This AI extends the syntax of membership tests to simplify complex conditions
16938 that can be expressed as membership in a subset of values of any type. It
16939 introduces syntax for a list of expressions that may be used in loop contexts
16940 as well.
16941
16942 @noindent
16943 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
16944
16945
16946 @item
16947 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16948 @cindex AI-0173 (Ada 2012 feature)
16949
16950 @noindent
16951 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
16952 with the tag of an abstract type, and @code{False} otherwise.
16953
16954 @noindent
16955 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
16956
16957
16958
16959 @item
16960 @emph{AI-0076 function with controlling result (0000-00-00)}
16961 @cindex AI-0076 (Ada 2012 feature)
16962
16963 @noindent
16964 This is an editorial change only. The RM defines calls with controlling
16965 results, but uses the term ``function with controlling result'' without an
16966 explicit definition.
16967
16968 @noindent
16969 RM References: 3.09.02 (2/2)
16970
16971
16972 @item
16973 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
16974 @cindex AI-0126 (Ada 2012 feature)
16975
16976 @noindent
16977 This AI clarifies dispatching rules, and simply confirms that dispatching
16978 executes the operation of the parent type when there is no explicitly or
16979 implicitly declared operation for the descendant type. This has always been
16980 the case in all versions of GNAT.
16981
16982 @noindent
16983 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
16984
16985
16986 @item
16987 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
16988 @cindex AI-0097 (Ada 2012 feature)
16989
16990 @noindent
16991 The RM as written implied that in some cases it was possible to create an
16992 object of an abstract type, by having an abstract extension inherit a non-
16993 abstract constructor from its parent type. This mistake has been corrected
16994 in GNAT and in the RM, and this construct is now illegal.
16995
16996 @noindent
16997 RM References: 3.09.03 (4/2)
16998
16999
17000 @item
17001 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17002 @cindex AI-0203 (Ada 2012 feature)
17003
17004 @noindent
17005 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17006 permitted such usage.
17007
17008 @noindent
17009 RM References: 3.09.03 (8/3)
17010
17011
17012 @item
17013 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17014 @cindex AI-0198 (Ada 2012 feature)
17015
17016 @noindent
17017 This AI resolves a conflict between two rules involving inherited abstract
17018 operations and predefined operators. If a derived numeric type inherits
17019 an abstract operator, it overrides the predefined one. This interpretation
17020 was always the one implemented in GNAT.
17021
17022 @noindent
17023 RM References: 3.09.03 (4/3)
17024
17025 @item
17026 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17027 @cindex AI-0073 (Ada 2012 feature)
17028
17029 @noindent
17030 This AI covers a number of issues regarding returning abstract types. In
17031 particular generic functions cannot have abstract result types or access
17032 result types designated an abstract type. There are some other cases which
17033 are detailed in the AI. Note that this binding interpretation has not been
17034 retrofitted to operate before Ada 2012 mode, since it caused a significant
17035 number of regressions.
17036
17037 @noindent
17038 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17039
17040
17041 @item
17042 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17043 @cindex AI-0070 (Ada 2012 feature)
17044
17045 @noindent
17046 This is an editorial change only, there are no testable consequences short of
17047 checking for the absence of generated code for an interface declaration.
17048
17049 @noindent
17050 RM References: 3.09.04 (18/2)
17051
17052
17053 @item
17054 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17055 @cindex AI-0208 (Ada 2012 feature)
17056
17057 @noindent
17058 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17059 was incorrect and implied that some programs intended to be legal were now
17060 illegal. GNAT had never considered such programs illegal, so it has always
17061 implemented the intent of this AI.
17062
17063 @noindent
17064 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17065
17066
17067 @item
17068 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17069 @cindex AI-0162 (Ada 2012 feature)
17070
17071 @noindent
17072 Incomplete types are made more useful by allowing them to be completed by
17073 private types and private extensions.
17074
17075 @noindent
17076 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17077
17078
17079
17080 @item
17081 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17082 @cindex AI-0098 (Ada 2012 feature)
17083
17084 @noindent
17085 An unintentional omission in the RM implied some inconsistent restrictions on
17086 the use of anonymous access to subprogram values. These restrictions were not
17087 intentional, and have never been enforced by GNAT.
17088
17089 @noindent
17090 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17091
17092
17093 @item
17094 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17095 @cindex AI-0199 (Ada 2012 feature)
17096
17097 @noindent
17098 A choice list in a record aggregate can include several components of
17099 (distinct) anonymous access types as long as they have matching designated
17100 subtypes.
17101
17102 @noindent
17103 RM References: 4.03.01 (16)
17104
17105
17106 @item
17107 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17108 @cindex AI-0220 (Ada 2012 feature)
17109
17110 @noindent
17111 This AI addresses a wording problem in the RM that appears to permit some
17112 complex cases of aggregates with non-static discriminants. GNAT has always
17113 implemented the intended semantics.
17114
17115 @noindent
17116 RM References: 4.03.01 (17)
17117
17118 @item
17119 @emph{AI-0147 Conditional expressions (2009-03-29)}
17120 @cindex AI-0147 (Ada 2012 feature)
17121
17122 @noindent
17123 Conditional expressions are permitted. The form of such an expression is:
17124
17125 @smallexample
17126 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17127 @end smallexample
17128
17129 The parentheses can be omitted in contexts where parentheses are present
17130 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17131 clause is omitted, @b{else True} is assumed;
17132 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17133 @emph{(A implies B)} in standard logic.
17134
17135 @noindent
17136 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17137 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17138
17139
17140 @item
17141 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17142 @cindex AI-0037 (Ada 2012 feature)
17143
17144 @noindent
17145 This AI confirms that an association of the form @code{Indx => <>} in an
17146 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17147 is out of range. The RM specified a range check on other associations, but
17148 not when the value of the association was defaulted. GNAT has always inserted
17149 a constraint check on the index value.
17150
17151 @noindent
17152 RM References: 4.03.03 (29)
17153
17154
17155 @item
17156 @emph{AI-0123 Composability of equality (2010-04-13)}
17157 @cindex AI-0123 (Ada 2012 feature)
17158
17159 @noindent
17160 Equality of untagged record composes, so that the predefined equality for a
17161 composite type that includes a component of some untagged record type
17162 @code{R} uses the equality operation of @code{R} (which may be user-defined
17163 or predefined). This makes the behavior of untagged records identical to that
17164 of tagged types in this respect.
17165
17166 This change is an incompatibility with previous versions of Ada, but it
17167 corrects a non-uniformity that was often a source of confusion. Analysis of
17168 a large number of industrial programs indicates that in those rare cases
17169 where a composite type had an untagged record component with a user-defined
17170 equality, either there was no use of the composite equality, or else the code
17171 expected the same composability as for tagged types, and thus had a bug that
17172 would be fixed by this change.
17173
17174 @noindent
17175 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17176 8.05.04 (8)
17177
17178
17179 @item
17180 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17181 @cindex AI-0088 (Ada 2012 feature)
17182
17183 @noindent
17184 This AI clarifies the equivalence rule given for the dynamic semantics of
17185 exponentiation: the value of the operation can be obtained by repeated
17186 multiplication, but the operation can be implemented otherwise (for example
17187 using the familiar divide-by-two-and-square algorithm, even if this is less
17188 accurate), and does not imply repeated reads of a volatile base.
17189
17190 @noindent
17191 RM References: 4.05.06 (11)
17192
17193 @item
17194 @emph{AI-0188 Case expressions (2010-01-09)}
17195 @cindex AI-0188 (Ada 2012 feature)
17196
17197 @noindent
17198 Case expressions are permitted. This allows use of constructs such as:
17199 @smallexample
17200 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17201 @end smallexample
17202
17203 @noindent
17204 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17205
17206 @item
17207 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17208 @cindex AI-0104 (Ada 2012 feature)
17209
17210 @noindent
17211 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17212 @code{Constraint_Error} because the default value of the allocated object is
17213 @b{null}. This useless construct is illegal in Ada 2012.
17214
17215 @noindent
17216 RM References: 4.08 (2)
17217
17218 @item
17219 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17220 @cindex AI-0157 (Ada 2012 feature)
17221
17222 @noindent
17223 Allocation and Deallocation from an empty storage pool (i.e. allocation or
17224 deallocation of a pointer for which a static storage size clause of zero
17225 has been given) is now illegal and is detected as such. GNAT
17226 previously gave a warning but not an error.
17227
17228 @noindent
17229 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
17230
17231 @item
17232 @emph{AI-0179 Statement not required after label (2010-04-10)}
17233 @cindex AI-0179 (Ada 2012 feature)
17234
17235 @noindent
17236 It is not necessary to have a statement following a label, so a label
17237 can appear at the end of a statement sequence without the need for putting a
17238 null statement afterwards, but it is not allowable to have only labels and
17239 no real statements in a statement sequence.
17240
17241 @noindent
17242 RM References: 5.01 (2)
17243
17244
17245 @item
17246 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17247 @cindex AI-139-2 (Ada 2012 feature)
17248
17249 @noindent
17250 The new syntax for iterating over arrays and containers is now implemented.
17251 Iteration over containers is for now limited to read-only iterators. Only
17252 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
17253
17254 @noindent
17255 RM References: 5.05
17256
17257 @item
17258 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17259 @cindex AI-0134 (Ada 2012 feature)
17260
17261 @noindent
17262 For full conformance, the profiles of anonymous-access-to-subprogram
17263 parameters must match. GNAT has always enforced this rule.
17264
17265 @noindent
17266 RM References: 6.03.01 (18)
17267
17268 @item
17269 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17270 @cindex AI-0207 (Ada 2012 feature)
17271
17272 @noindent
17273 This AI confirms that access_to_constant indication must match for mode
17274 conformance. This was implemented in GNAT when the qualifier was originally
17275 introduced in Ada 2005.
17276
17277 @noindent
17278 RM References: 6.03.01 (16/2)
17279
17280
17281 @item
17282 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17283 @cindex AI-0046 (Ada 2012 feature)
17284
17285 @noindent
17286 For full conformance, in the case of access parameters, the null exclusion
17287 must match (either both or neither must have @code{@b{not null}}).
17288
17289 @noindent
17290 RM References: 6.03.02 (18)
17291
17292
17293 @item
17294 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17295 @cindex AI-0118 (Ada 2012 feature)
17296
17297 @noindent
17298 This AI clarifies the rules for named associations in subprogram calls and
17299 generic instantiations. The rules have been in place since Ada 83.
17300
17301 @noindent
17302 RM References: 6.04.01 (2) 12.03 (9)
17303
17304
17305 @item
17306 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17307 @cindex AI-0196 (Ada 2012 feature)
17308
17309 @noindent
17310 Null exclusion checks are not made for @code{@b{out}} parameters when
17311 evaluating the actual parameters. GNAT has never generated these checks.
17312
17313 @noindent
17314 RM References: 6.04.01 (13)
17315
17316 @item
17317 @emph{AI-0015 Constant return objects (0000-00-00)}
17318 @cindex AI-0015 (Ada 2012 feature)
17319
17320 @noindent
17321 The return object declared in an @i{extended_return_statement} may be
17322 declared constant. This was always intended, and GNAT has always allowed it.
17323
17324 @noindent
17325 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17326 6.05 (5.7/2)
17327
17328
17329 @item
17330 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17331 @cindex AI-0032 (Ada 2012 feature)
17332
17333 @noindent
17334 If a function returns a class-wide type, the object of an extended return
17335 statement can be declared with a specific type that is covered by the class-
17336 wide type. This has been implemented in GNAT since the introduction of
17337 extended returns. Note AI-0103 complements this AI by imposing matching
17338 rules for constrained return types.
17339
17340 @noindent
17341 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17342 6.05 (8/2)
17343
17344 @item
17345 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17346 @cindex AI-0103 (Ada 2012 feature)
17347
17348 @noindent
17349 If the return subtype of a function is an elementary type or a constrained
17350 type, the subtype indication in an extended return statement must match
17351 statically this return subtype.
17352
17353 @noindent
17354 RM References: 6.05 (5.2/2)
17355
17356
17357 @item
17358 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17359 @cindex AI-0058 (Ada 2012 feature)
17360
17361 @noindent
17362 The RM had some incorrect wording implying wrong treatment of abnormal
17363 completion in an extended return. GNAT has always implemented the intended
17364 correct semantics as described by this AI.
17365
17366 @noindent
17367 RM References: 6.05 (22/2)
17368
17369
17370 @item
17371 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
17372 @cindex AI-0050 (Ada 2012 feature)
17373
17374 @noindent
17375 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
17376 not take advantage of these incorrect permissions in any case.
17377
17378 @noindent
17379 RM References: 6.05 (24/2)
17380
17381
17382 @item
17383 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17384 @cindex AI-0125 (Ada 2012 feature)
17385
17386 @noindent
17387 In Ada 2012, the declaration of a primitive operation of a type extension
17388 or private extension can also override an inherited primitive that is not
17389 visible at the point of this declaration.
17390
17391 @noindent
17392 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
17393
17394 @item
17395 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17396 @cindex AI-0062 (Ada 2012 feature)
17397
17398 @noindent
17399 A full constant may have a null exclusion even if its associated deferred
17400 constant does not. GNAT has always allowed this.
17401
17402 @noindent
17403 RM References: 7.04 (6/2) 7.04 (7.1/2)
17404
17405
17406 @item
17407 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17408 @cindex AI-0178 (Ada 2012 feature)
17409
17410 @noindent
17411 This AI clarifies the role of incomplete views and plugs an omission in the
17412 RM. GNAT always correctly restricted the use of incomplete views and types.
17413
17414 @noindent
17415 RM References: 7.05 (3/2) 7.05 (6/2)
17416
17417 @item
17418 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17419 @cindex AI-0087 (Ada 2012 feature)
17420
17421 @noindent
17422 The actual for a formal nonlimited derived type cannot be limited. In
17423 particular, a formal derived type that extends a limited interface but which
17424 is not explicitly limited cannot be instantiated with a limited type.
17425
17426 @noindent
17427 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
17428
17429 @item
17430 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17431 @cindex AI-0099 (Ada 2012 feature)
17432
17433 @noindent
17434 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17435 and therefore depends on the run-time characteristics of an object (i.e. its
17436 tag) and not on its nominal type. As the AI indicates: ``we do not expect
17437 this to affect any implementation''.
17438
17439 @noindent
17440 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
17441
17442
17443
17444 @item
17445 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17446 @cindex AI-0064 (Ada 2012 feature)
17447
17448 @noindent
17449 This is an editorial change only. The intended behavior is already checked
17450 by an existing ACATS test, which GNAT has always executed correctly.
17451
17452 @noindent
17453 RM References: 7.06.01 (17.1/1)
17454
17455 @item
17456 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17457 @cindex AI-0026 (Ada 2012 feature)
17458
17459 @noindent
17460 Record representation clauses concerning Unchecked_Union types cannot mention
17461 the discriminant of the type. The type of a component declared in the variant
17462 part of an Unchecked_Union cannot be controlled, have controlled components,
17463 nor have protected or task parts. If an Unchecked_Union type is declared
17464 within the body of a generic unit or its descendants, then the type of a
17465 component declared in the variant part cannot be a formal private type or a
17466 formal private extension declared within the same generic unit.
17467
17468 @noindent
17469 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
17470
17471
17472 @item
17473 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17474 @cindex AI-0205 (Ada 2012 feature)
17475
17476 @noindent
17477 This AI corrects a simple omission in the RM. Return objects have always
17478 been visible within an extended return statement.
17479
17480 @noindent
17481 RM References: 8.03 (17)
17482
17483
17484 @item
17485 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17486 @cindex AI-0042 (Ada 2012 feature)
17487
17488 @noindent
17489 This AI fixes a wording gap in the RM. An operation of a synchronized
17490 interface can be implemented by a protected or task entry, but the abstract
17491 operation is not being overridden in the usual sense, and it must be stated
17492 separately that this implementation is legal. This has always been the case
17493 in GNAT.
17494
17495 @noindent
17496 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
17497
17498 @item
17499 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17500 @cindex AI-0030 (Ada 2012 feature)
17501
17502 @noindent
17503 Requeue is permitted to a protected, synchronized or task interface primitive
17504 providing it is known that the overriding operation is an entry. Otherwise
17505 the requeue statement has the same effect as a procedure call. Use of pragma
17506 @code{Implemented} provides a way to impose a static requirement on the
17507 overriding operation by adhering to one of the implementation kinds: entry,
17508 protected procedure or any of the above.
17509
17510 @noindent
17511 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
17512 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
17513
17514
17515 @item
17516 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17517 @cindex AI-0201 (Ada 2012 feature)
17518
17519 @noindent
17520 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17521 attribute, then individual components may not be addressable by independent
17522 tasks. However, if the representation clause has no effect (is confirming),
17523 then independence is not compromised. Furthermore, in GNAT, specification of
17524 other appropriately addressable component sizes (e.g. 16 for 8-bit
17525 characters) also preserves independence. GNAT now gives very clear warnings
17526 both for the declaration of such a type, and for any assignment to its components.
17527
17528 @noindent
17529 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
17530
17531 @item
17532 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17533 @cindex AI-0009 (Ada 2012 feature)
17534
17535 @noindent
17536 This AI introduces the new pragmas @code{Independent} and
17537 @code{Independent_Components},
17538 which control guaranteeing independence of access to objects and components.
17539 The AI also requires independence not unaffected by confirming rep clauses.
17540
17541 @noindent
17542 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
17543 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
17544
17545
17546 @item
17547 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17548 @cindex AI-0072 (Ada 2012 feature)
17549
17550 @noindent
17551 This AI clarifies that task signalling for reading @code{'Terminated} only
17552 occurs if the result is True. GNAT semantics has always been consistent with
17553 this notion of task signalling.
17554
17555 @noindent
17556 RM References: 9.10 (6.1/1)
17557
17558 @item
17559 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17560 @cindex AI-0108 (Ada 2012 feature)
17561
17562 @noindent
17563 This AI confirms that an incomplete type from a limited view does not have
17564 discriminants. This has always been the case in GNAT.
17565
17566 @noindent
17567 RM References: 10.01.01 (12.3/2)
17568
17569 @item
17570 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17571 @cindex AI-0129 (Ada 2012 feature)
17572
17573 @noindent
17574 This AI clarifies the description of limited views: a limited view of a
17575 package includes only one view of a type that has an incomplete declaration
17576 and a full declaration (there is no possible ambiguity in a client package).
17577 This AI also fixes an omission: a nested package in the private part has no
17578 limited view. GNAT always implemented this correctly.
17579
17580 @noindent
17581 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
17582
17583
17584
17585 @item
17586 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17587 @cindex AI-0077 (Ada 2012 feature)
17588
17589 @noindent
17590 This AI clarifies that a declaration does not include a context clause,
17591 and confirms that it is illegal to have a context in which both a limited
17592 and a nonlimited view of a package are accessible. Such double visibility
17593 was always rejected by GNAT.
17594
17595 @noindent
17596 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
17597
17598 @item
17599 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17600 @cindex AI-0122 (Ada 2012 feature)
17601
17602 @noindent
17603 This AI clarifies the visibility of private children of generic units within
17604 instantiations of a parent. GNAT has always handled this correctly.
17605
17606 @noindent
17607 RM References: 10.01.02 (12/2)
17608
17609
17610
17611 @item
17612 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17613 @cindex AI-0040 (Ada 2012 feature)
17614
17615 @noindent
17616 This AI confirms that a limited with clause in a child unit cannot name
17617 an ancestor of the unit. This has always been checked in GNAT.
17618
17619 @noindent
17620 RM References: 10.01.02 (20/2)
17621
17622 @item
17623 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17624 @cindex AI-0132 (Ada 2012 feature)
17625
17626 @noindent
17627 This AI fills a gap in the description of library unit pragmas. The pragma
17628 clearly must apply to a library unit, even if it does not carry the name
17629 of the enclosing unit. GNAT has always enforced the required check.
17630
17631 @noindent
17632 RM References: 10.01.05 (7)
17633
17634
17635 @item
17636 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17637 @cindex AI-0034 (Ada 2012 feature)
17638
17639 @noindent
17640 The RM makes certain limited with clauses illegal because of categorization
17641 considerations, when the corresponding normal with would be legal. This is
17642 not intended, and GNAT has always implemented the recommended behavior.
17643
17644 @noindent
17645 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
17646
17647
17648 @item
17649 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17650 @cindex AI-0035 (Ada 2012 feature)
17651
17652 @noindent
17653 This AI remedies some inconsistencies in the legality rules for Pure units.
17654 Derived access types are legal in a pure unit (on the assumption that the
17655 rule for a zero storage pool size has been enforced on the ancestor type).
17656 The rules are enforced in generic instances and in subunits. GNAT has always
17657 implemented the recommended behavior.
17658
17659 @noindent
17660 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)
17661
17662
17663 @item
17664 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17665 @cindex AI-0219 (Ada 2012 feature)
17666
17667 @noindent
17668 This AI refines the rules for the cases with limited parameters which do not
17669 allow the implementations to omit ``redundant''. GNAT now properly conforms
17670 to the requirements of this binding interpretation.
17671
17672 @noindent
17673 RM References: 10.02.01 (18/2)
17674
17675 @item
17676 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17677 @cindex AI-0043 (Ada 2012 feature)
17678
17679 @noindent
17680 This AI covers various omissions in the RM regarding the raising of
17681 exceptions. GNAT has always implemented the intended semantics.
17682
17683 @noindent
17684 RM References: 11.04.01 (10.1/2) 11 (2)
17685
17686
17687 @item
17688 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17689 @cindex AI-0200 (Ada 2012 feature)
17690
17691 @noindent
17692 This AI plugs a gap in the RM which appeared to allow some obviously intended
17693 illegal instantiations. GNAT has never allowed these instantiations.
17694
17695 @noindent
17696 RM References: 12.07 (16)
17697
17698
17699 @item
17700 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17701 @cindex AI-0112 (Ada 2012 feature)
17702
17703 @noindent
17704 This AI concerns giving names to various representation aspects, but the
17705 practical effect is simply to make the use of duplicate
17706 @code{Atomic}[@code{_Components}],
17707 @code{Volatile}[@code{_Components}] and
17708 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17709 now performs this required check.
17710
17711 @noindent
17712 RM References: 13.01 (8)
17713
17714 @item
17715 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17716 @cindex AI-0106 (Ada 2012 feature)
17717
17718 @noindent
17719 The RM appeared to allow representation pragmas on generic formal parameters,
17720 but this was not intended, and GNAT has never permitted this usage.
17721
17722 @noindent
17723 RM References: 13.01 (9.1/1)
17724
17725
17726 @item
17727 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17728 @cindex AI-0012 (Ada 2012 feature)
17729
17730 @noindent
17731 It is now illegal to give an inappropriate component size or a pragma
17732 @code{Pack} that attempts to change the component size in the case of atomic
17733 or aliased components. Previously GNAT ignored such an attempt with a
17734 warning.
17735
17736 @noindent
17737 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
17738
17739
17740 @item
17741 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17742 @cindex AI-0039 (Ada 2012 feature)
17743
17744 @noindent
17745 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17746 for stream attributes, but these were never useful and are now illegal. GNAT
17747 has always regarded such expressions as illegal.
17748
17749 @noindent
17750 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
17751
17752
17753 @item
17754 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17755 @cindex AI-0095 (Ada 2012 feature)
17756
17757 @noindent
17758 The prefix of @code{'Address} cannot statically denote a subprogram with
17759 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17760 @code{Program_Error} if the prefix denotes a subprogram with convention
17761 @code{Intrinsic}.
17762
17763 @noindent
17764 RM References: 13.03 (11/1)
17765
17766
17767 @item
17768 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17769 @cindex AI-0116 (Ada 2012 feature)
17770
17771 @noindent
17772 This AI requires that the alignment of a class-wide object be no greater
17773 than the alignment of any type in the class. GNAT has always followed this
17774 recommendation.
17775
17776 @noindent
17777 RM References: 13.03 (29) 13.11 (16)
17778
17779
17780 @item
17781 @emph{AI-0146 Type invariants (2009-09-21)}
17782 @cindex AI-0146 (Ada 2012 feature)
17783
17784 @noindent
17785 Type invariants may be specified for private types using the aspect notation.
17786 Aspect @code{Invariant} may be specified for any private type,
17787 @code{Invariant'Class} can
17788 only be specified for tagged types, and is inherited by any descendent of the
17789 tagged types. The invariant is a boolean expression that is tested for being
17790 true in the following situations: conversions to the private type, object
17791 declarations for the private type that are default initialized, and
17792 [@b{in}] @b{out}
17793 parameters and returned result on return from any primitive operation for
17794 the type that is visible to a client.
17795
17796 @noindent
17797 RM References: 13.03.03 (00)
17798
17799 @item
17800 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17801 @cindex AI-0078 (Ada 2012 feature)
17802
17803 @noindent
17804 In Ada 2012, compilers are required to support unchecked conversion where the
17805 target alignment is a multiple of the source alignment. GNAT always supported
17806 this case (and indeed all cases of differing alignments, doing copies where
17807 required if the alignment was reduced).
17808
17809 @noindent
17810 RM References: 13.09 (7)
17811
17812
17813 @item
17814 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17815 @cindex AI-0195 (Ada 2012 feature)
17816
17817 @noindent
17818 The handling of invalid values is now designated to be implementation
17819 defined. This is a documentation change only, requiring Annex M in the GNAT
17820 Reference Manual to document this handling.
17821 In GNAT, checks for invalid values are made
17822 only when necessary to avoid erroneous behavior. Operations like assignments
17823 which cannot cause erroneous behavior ignore the possibility of invalid
17824 values and do not do a check. The date given above applies only to the
17825 documentation change, this behavior has always been implemented by GNAT.
17826
17827 @noindent
17828 RM References: 13.09.01 (10)
17829
17830 @item
17831 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17832 @cindex AI-0193 (Ada 2012 feature)
17833
17834 @noindent
17835 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17836 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17837 of size.
17838
17839 @noindent
17840 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
17841 13.11.01 (2) 13.11.01 (3)
17842
17843
17844 @item
17845 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17846 @cindex AI-0177 (Ada 2012 feature)
17847
17848 @noindent
17849 The new Ada 2012 notion of parameterized expressions is implemented. The form
17850 is:
17851 @smallexample
17852 @i{function specification} @b{is} (@i{expression})
17853 @end smallexample
17854
17855 @noindent
17856 This is exactly equivalent to the
17857 corresponding function body that returns the expression, but it can appear
17858 in a package spec. Note that the expression must be parenthesized.
17859
17860 @noindent
17861 RM References: 13.11.01 (3/2)
17862
17863 @item
17864 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17865 @cindex AI-0033 (Ada 2012 feature)
17866
17867 @noindent
17868 Neither of these two pragmas may appear within a generic template, because
17869 the generic might be instantiated at other than the library level.
17870
17871 @noindent
17872 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
17873
17874
17875 @item
17876 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17877 @cindex AI-0161 (Ada 2012 feature)
17878
17879 @noindent
17880 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17881 of the default stream attributes for elementary types. If this restriction is
17882 in force, then it is necessary to provide explicit subprograms for any
17883 stream attributes used.
17884
17885 @noindent
17886 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
17887
17888 @item
17889 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17890 @cindex AI-0194 (Ada 2012 feature)
17891
17892 @noindent
17893 The @code{Stream_Size} attribute returns the default number of bits in the
17894 stream representation of the given type.
17895 This value is not affected by the presence
17896 of stream subprogram attributes for the type. GNAT has always implemented
17897 this interpretation.
17898
17899 @noindent
17900 RM References: 13.13.02 (1.2/2)
17901
17902 @item
17903 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17904 @cindex AI-0109 (Ada 2012 feature)
17905
17906 @noindent
17907 This AI is an editorial change only. It removes the need for a tag check
17908 that can never fail.
17909
17910 @noindent
17911 RM References: 13.13.02 (34/2)
17912
17913 @item
17914 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17915 @cindex AI-0007 (Ada 2012 feature)
17916
17917 @noindent
17918 The RM as written appeared to limit the possibilities of declaring read
17919 attribute procedures for private scalar types. This limitation was not
17920 intended, and has never been enforced by GNAT.
17921
17922 @noindent
17923 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
17924
17925
17926 @item
17927 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17928 @cindex AI-0065 (Ada 2012 feature)
17929
17930 @noindent
17931 This AI clarifies the fact that all remote access types support external
17932 streaming. This fixes an obvious oversight in the definition of the
17933 language, and GNAT always implemented the intended correct rules.
17934
17935 @noindent
17936 RM References: 13.13.02 (52/2)
17937
17938 @item
17939 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17940 @cindex AI-0019 (Ada 2012 feature)
17941
17942 @noindent
17943 The RM suggests that primitive subprograms of a specific tagged type are
17944 frozen when the tagged type is frozen. This would be an incompatible change
17945 and is not intended. GNAT has never attempted this kind of freezing and its
17946 behavior is consistent with the recommendation of this AI.
17947
17948 @noindent
17949 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)
17950
17951 @item
17952 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
17953 @cindex AI-0017 (Ada 2012 feature)
17954
17955 @noindent
17956 So-called ``Taft-amendment types'' (i.e., types that are completed in package
17957 bodies) are not frozen by the occurrence of bodies in the
17958 enclosing declarative part. GNAT always implemented this properly.
17959
17960 @noindent
17961 RM References: 13.14 (3/1)
17962
17963
17964 @item
17965 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
17966 @cindex AI-0060 (Ada 2012 feature)
17967
17968 @noindent
17969 This AI extends the definition of remote access types to include access
17970 to limited, synchronized, protected or task class-wide interface types.
17971 GNAT already implemented this extension.
17972
17973 @noindent
17974 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
17975
17976 @item
17977 @emph{AI-0114 Classification of letters (0000-00-00)}
17978 @cindex AI-0114 (Ada 2012 feature)
17979
17980 @noindent
17981 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
17982 181 (@code{MICRO SIGN}), and
17983 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
17984 lower case letters by Unicode.
17985 However, they are not allowed in identifiers, and they
17986 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
17987 This behavior is consistent with that defined in Ada 95.
17988
17989 @noindent
17990 RM References: A.03.02 (59) A.04.06 (7)
17991
17992
17993 @item
17994 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
17995 @cindex AI-0185 (Ada 2012 feature)
17996
17997 @noindent
17998 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
17999 classification functions for @code{Wide_Character} and
18000 @code{Wide_Wide_Character}, as well as providing
18001 case folding routines for @code{Wide_[Wide_]Character} and
18002 @code{Wide_[Wide_]String}.
18003
18004 @noindent
18005 RM References: A.03.05 (0) A.03.06 (0)
18006
18007
18008 @item
18009 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18010 @cindex AI-0031 (Ada 2012 feature)
18011
18012 @noindent
18013 A new version of @code{Find_Token} is added to all relevant string packages,
18014 with an extra parameter @code{From}. Instead of starting at the first
18015 character of the string, the search for a matching Token starts at the
18016 character indexed by the value of @code{From}.
18017 These procedures are available in all versions of Ada
18018 but if used in versions earlier than Ada 2012 they will generate a warning
18019 that an Ada 2012 subprogram is being used.
18020
18021 @noindent
18022 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18023 A.04.05 (46)
18024
18025
18026 @item
18027 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18028 @cindex AI-0056 (Ada 2012 feature)
18029
18030 @noindent
18031 The wording in the Ada 2005 RM implied an incompatible handling of the
18032 @code{Index} functions, resulting in raising an exception instead of
18033 returning zero in some situations.
18034 This was not intended and has been corrected.
18035 GNAT always returned zero, and is thus consistent with this AI.
18036
18037 @noindent
18038 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18039
18040
18041 @item
18042 @emph{AI-0137 String encoding package (2010-03-25)}
18043 @cindex AI-0137 (Ada 2012 feature)
18044
18045 @noindent
18046 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18047 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18048 and @code{Wide_Wide_Strings} have been
18049 implemented. These packages (whose documentation can be found in the spec
18050 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18051 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18052 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18053 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18054 UTF-16), as well as conversions between the different UTF encodings. With
18055 the exception of @code{Wide_Wide_Strings}, these packages are available in
18056 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18057 The @code{Wide_Wide_Strings package}
18058 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18059 mode since it uses @code{Wide_Wide_Character}).
18060
18061 @noindent
18062 RM References: A.04.11
18063
18064 @item
18065 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18066 @cindex AI-0038 (Ada 2012 feature)
18067
18068 @noindent
18069 These are minor errors in the description on three points. The intent on
18070 all these points has always been clear, and GNAT has always implemented the
18071 correct intended semantics.
18072
18073 @noindent
18074 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)
18075
18076 @item
18077 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18078 @cindex AI-0044 (Ada 2012 feature)
18079
18080 @noindent
18081 This AI places restrictions on allowed instantiations of generic containers.
18082 These restrictions are not checked by the compiler, so there is nothing to
18083 change in the implementation. This affects only the RM documentation.
18084
18085 @noindent
18086 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)
18087
18088 @item
18089 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18090 @cindex AI-0127 (Ada 2012 feature)
18091
18092 @noindent
18093 This package provides an interface for identifying the current locale.
18094
18095 @noindent
18096 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18097 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18098
18099
18100
18101 @item
18102 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18103 @cindex AI-0002 (Ada 2012 feature)
18104
18105 @noindent
18106 The compiler is not required to support exporting an Ada subprogram with
18107 convention C if there are parameters or a return type of an unconstrained
18108 array type (such as @code{String}). GNAT allows such declarations but
18109 generates warnings. It is possible, but complicated, to write the
18110 corresponding C code and certainly such code would be specific to GNAT and
18111 non-portable.
18112
18113 @noindent
18114 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18115
18116
18117 @item
18118 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18119 @cindex AI05-0216 (Ada 2012 feature)
18120
18121 @noindent
18122 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18123 forbid tasks declared locally within subprograms, or functions returning task
18124 objects, and that is the implementation that GNAT has always provided.
18125 However the language in the RM was not sufficiently clear on this point.
18126 Thus this is a documentation change in the RM only.
18127
18128 @noindent
18129 RM References: D.07 (3/3)
18130
18131 @item
18132 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18133 @cindex AI-0211 (Ada 2012 feature)
18134
18135 @noindent
18136 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18137 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18138
18139 @noindent
18140 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18141
18142 @item
18143 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18144 @cindex AI-0190 (Ada 2012 feature)
18145
18146 @noindent
18147 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18148 used to control storage pools globally.
18149 In particular, you can force every access
18150 type that is used for allocation (@b{new}) to have an explicit storage pool,
18151 or you can declare a pool globally to be used for all access types that lack
18152 an explicit one.
18153
18154 @noindent
18155 RM References: D.07 (8)
18156
18157 @item
18158 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18159 @cindex AI-0189 (Ada 2012 feature)
18160
18161 @noindent
18162 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18163 which says that no dynamic allocation will occur once elaboration is
18164 completed.
18165 In general this requires a run-time check, which is not required, and which
18166 GNAT does not attempt. But the static cases of allocators in a task body or
18167 in the body of the main program are detected and flagged at compile or bind
18168 time.
18169
18170 @noindent
18171 RM References: D.07 (19.1/2) H.04 (23.3/2)
18172
18173 @item
18174 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18175 @cindex AI-0171 (Ada 2012 feature)
18176
18177 @noindent
18178 A new package @code{System.Multiprocessors} is added, together with the
18179 definition of pragma @code{CPU} for controlling task affinity. A new no
18180 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18181 is added to the Ravenscar profile.
18182
18183 @noindent
18184 RM References: D.13.01 (4/2) D.16
18185
18186
18187 @item
18188 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18189 @cindex AI-0210 (Ada 2012 feature)
18190
18191 @noindent
18192 This is a documentation only issue regarding wording of metric requirements,
18193 that does not affect the implementation of the compiler.
18194
18195 @noindent
18196 RM References: D.15 (24/2)
18197
18198
18199 @item
18200 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18201 @cindex AI-0206 (Ada 2012 feature)
18202
18203 @noindent
18204 Remote types packages are now allowed to depend on preelaborated packages.
18205 This was formerly considered illegal.
18206
18207 @noindent
18208 RM References: E.02.02 (6)
18209
18210
18211
18212 @item
18213 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18214 @cindex AI-0152 (Ada 2012 feature)
18215
18216 @noindent
18217 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18218 where the type of the returned value is an anonymous access type.
18219
18220 @noindent
18221 RM References: H.04 (8/1)
18222 @end itemize
18223
18224
18225 @node Obsolescent Features
18226 @chapter Obsolescent Features
18227
18228 @noindent
18229 This chapter describes features that are provided by GNAT, but are
18230 considered obsolescent since there are preferred ways of achieving
18231 the same effect. These features are provided solely for historical
18232 compatibility purposes.
18233
18234 @menu
18235 * pragma No_Run_Time::
18236 * pragma Ravenscar::
18237 * pragma Restricted_Run_Time::
18238 @end menu
18239
18240 @node pragma No_Run_Time
18241 @section pragma No_Run_Time
18242
18243 The pragma @code{No_Run_Time} is used to achieve an affect similar
18244 to the use of the "Zero Foot Print" configurable run time, but without
18245 requiring a specially configured run time. The result of using this
18246 pragma, which must be used for all units in a partition, is to restrict
18247 the use of any language features requiring run-time support code. The
18248 preferred usage is to use an appropriately configured run-time that
18249 includes just those features that are to be made accessible.
18250
18251 @node pragma Ravenscar
18252 @section pragma Ravenscar
18253
18254 The pragma @code{Ravenscar} has exactly the same effect as pragma
18255 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18256 is part of the new Ada 2005 standard.
18257
18258 @node pragma Restricted_Run_Time
18259 @section pragma Restricted_Run_Time
18260
18261 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18262 pragma @code{Profile (Restricted)}. The latter usage is
18263 preferred since the Ada 2005 pragma @code{Profile} is intended for
18264 this kind of implementation dependent addition.
18265
18266 @include fdl.texi
18267 @c GNU Free Documentation License
18268
18269 @node Index,,GNU Free Documentation License, Top
18270 @unnumbered Index
18271
18272 @printindex cp
18273
18274 @contents
18275
18276 @bye