[multiple changes]
[gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c o
7 @c GNAT DOCUMENTATION o
8 @c o
9 @c G N A T _ RM o
10 @c o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
12 @c o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Defined Restrictions::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
81 * The GNAT Library::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Implementation of Ada 2012 Features::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
88 * Index::
89
90 --- The Detailed Node Listing ---
91
92 About This Guide
93
94 * What This Reference Manual Contains::
95 * Related Information::
96
97 Implementation Defined Pragmas
98
99 * Pragma Abort_Defer::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Ada_12::
105 * Pragma Ada_2012::
106 * Pragma Annotate::
107 * Pragma Assert::
108 * Pragma Assertion_Policy::
109 * Pragma Assume_No_Invalid_Values::
110 * Pragma Ast_Entry::
111 * Pragma C_Pass_By_Copy::
112 * Pragma Check::
113 * Pragma Check_Name::
114 * Pragma Check_Policy::
115 * Pragma Comment::
116 * Pragma Common_Object::
117 * Pragma Compile_Time_Error::
118 * Pragma Compile_Time_Warning::
119 * Pragma Compiler_Unit::
120 * Pragma Complete_Representation::
121 * Pragma Complex_Representation::
122 * Pragma Component_Alignment::
123 * Pragma Convention_Identifier::
124 * Pragma CPP_Class::
125 * Pragma CPP_Constructor::
126 * Pragma CPP_Virtual::
127 * Pragma CPP_Vtable::
128 * Pragma Debug::
129 * Pragma Debug_Policy::
130 * Pragma Detect_Blocking::
131 * Pragma Elaboration_Checks::
132 * Pragma Eliminate::
133 * Pragma Export_Exception::
134 * Pragma Export_Function::
135 * Pragma Export_Object::
136 * Pragma Export_Procedure::
137 * Pragma Export_Value::
138 * Pragma Export_Valued_Procedure::
139 * Pragma Extend_System::
140 * Pragma Extensions_Allowed::
141 * Pragma External::
142 * Pragma External_Name_Casing::
143 * Pragma Fast_Math::
144 * Pragma Favor_Top_Level::
145 * Pragma Finalize_Storage_Only::
146 * Pragma Float_Representation::
147 * Pragma Ident::
148 * Pragma Implemented::
149 * Pragma Implicit_Packing::
150 * Pragma Import_Exception::
151 * Pragma Import_Function::
152 * Pragma Import_Object::
153 * Pragma Import_Procedure::
154 * Pragma Import_Valued_Procedure::
155 * Pragma Initialize_Scalars::
156 * Pragma Inline_Always::
157 * Pragma Inline_Generic::
158 * Pragma Interface::
159 * Pragma Interface_Name::
160 * Pragma Interrupt_Handler::
161 * Pragma Interrupt_State::
162 * Pragma Invariant::
163 * Pragma Keep_Names::
164 * Pragma License::
165 * Pragma Link_With::
166 * Pragma Linker_Alias::
167 * Pragma Linker_Constructor::
168 * Pragma Linker_Destructor::
169 * Pragma Linker_Section::
170 * Pragma Long_Float::
171 * Pragma Machine_Attribute::
172 * Pragma Main::
173 * Pragma Main_Storage::
174 * Pragma No_Body::
175 * Pragma No_Return::
176 * Pragma No_Strict_Aliasing ::
177 * Pragma Normalize_Scalars::
178 * Pragma Obsolescent::
179 * Pragma Optimize_Alignment::
180 * Pragma Ordered::
181 * Pragma Passive::
182 * Pragma Persistent_BSS::
183 * Pragma Polling::
184 * Pragma Postcondition::
185 * Pragma Precondition::
186 * Pragma Profile (Ravenscar)::
187 * Pragma Profile (Restricted)::
188 * Pragma Psect_Object::
189 * Pragma Pure_Function::
190 * Pragma Remote_Access_Type::
191 * Pragma Restriction_Warnings::
192 * Pragma Shared::
193 * Pragma Short_Circuit_And_Or::
194 * Pragma Short_Descriptors::
195 * Pragma Simple_Storage_Pool_Type::
196 * Pragma Source_File_Name::
197 * Pragma Source_File_Name_Project::
198 * Pragma Source_Reference::
199 * Pragma Static_Elaboration_Desired::
200 * Pragma Stream_Convert::
201 * Pragma Style_Checks::
202 * Pragma Subtitle::
203 * Pragma Suppress::
204 * Pragma Suppress_All::
205 * Pragma Suppress_Exception_Locations::
206 * Pragma Suppress_Initialization::
207 * Pragma Task_Info::
208 * Pragma Task_Name::
209 * Pragma Task_Storage::
210 * Pragma Test_Case::
211 * Pragma Thread_Local_Storage::
212 * Pragma Time_Slice::
213 * Pragma Title::
214 * Pragma Unchecked_Union::
215 * Pragma Unimplemented_Unit::
216 * Pragma Universal_Aliasing ::
217 * Pragma Universal_Data::
218 * Pragma Unmodified::
219 * Pragma Unreferenced::
220 * Pragma Unreferenced_Objects::
221 * Pragma Unreserve_All_Interrupts::
222 * Pragma Unsuppress::
223 * Pragma Use_VADS_Size::
224 * Pragma Validity_Checks::
225 * Pragma Volatile::
226 * Pragma Warnings::
227 * Pragma Weak_External::
228 * Pragma Wide_Character_Encoding::
229
230 Implementation Defined Attributes
231
232 * Abort_Signal::
233 * Address_Size::
234 * Asm_Input::
235 * Asm_Output::
236 * AST_Entry::
237 * Bit::
238 * Bit_Position::
239 * Compiler_Version::
240 * Code_Address::
241 * Default_Bit_Order::
242 * Descriptor_Size::
243 * Elaborated::
244 * Elab_Body::
245 * Elab_Spec::
246 * Elab_Subp_Body::
247 * Emax::
248 * Enabled::
249 * Enum_Rep::
250 * Enum_Val::
251 * Epsilon::
252 * Fixed_Value::
253 * Has_Access_Values::
254 * Has_Discriminants::
255 * Img::
256 * Integer_Value::
257 * Invalid_Value::
258 * Large::
259 * Machine_Size::
260 * Mantissa::
261 * Max_Interrupt_Priority::
262 * Max_Priority::
263 * Maximum_Alignment::
264 * Mechanism_Code::
265 * Null_Parameter::
266 * Object_Size::
267 * Old::
268 * Passed_By_Reference::
269 * Pool_Address::
270 * Range_Length::
271 * Result::
272 * Safe_Emax::
273 * Safe_Large::
274 * Simple_Storage_Pool::
275 * Small::
276 * Storage_Unit::
277 * Stub_Type::
278 * System_Allocator_Alignment::
279 * Target_Name::
280 * Tick::
281 * To_Address::
282 * Type_Class::
283 * UET_Address::
284 * Unconstrained_Array::
285 * Universal_Literal_String::
286 * Unrestricted_Access::
287 * VADS_Size::
288 * Value_Size::
289 * Wchar_T_Size::
290 * Word_Size::
291
292 Implementation Defined Restrictions
293
294 * Partition-Wide Restrictions::
295 * Program Unit Level Restrictions::
296
297 Partition-Wide Restrictions
298
299 * Immediate_Reclamation::
300 * Max_Asynchronous_Select_Nesting::
301 * Max_Entry_Queue_Length::
302 * Max_Protected_Entries::
303 * Max_Select_Alternatives::
304 * Max_Storage_At_Blocking::
305 * Max_Task_Entries::
306 * Max_Tasks::
307 * No_Abort_Statements::
308 * No_Access_Parameter_Allocators::
309 * No_Access_Subprograms::
310 * No_Allocators::
311 * No_Anonymous_Allocators::
312 * No_Calendar::
313 * No_Coextensions::
314 * No_Default_Initialization::
315 * No_Delay::
316 * No_Dependence::
317 * No_Direct_Boolean_Operators::
318 * No_Dispatch::
319 * No_Dispatching_Calls::
320 * No_Dynamic_Attachment::
321 * No_Dynamic_Priorities::
322 * No_Entry_Calls_In_Elaboration_Code::
323 * No_Enumeration_Maps::
324 * No_Exception_Handlers::
325 * No_Exception_Propagation::
326 * No_Exception_Registration::
327 * No_Exceptions::
328 * No_Finalization::
329 * No_Fixed_Point::
330 * No_Floating_Point::
331 * No_Implicit_Conditionals::
332 * No_Implicit_Dynamic_Code::
333 * No_Implicit_Heap_Allocations::
334 * No_Implicit_Loops::
335 * No_Initialize_Scalars::
336 * No_IO::
337 * No_Local_Allocators::
338 * No_Local_Protected_Objects::
339 * No_Local_Timing_Events::
340 * No_Nested_Finalization::
341 * No_Protected_Type_Allocators::
342 * No_Protected_Types::
343 * No_Recursion::
344 * No_Reentrancy::
345 * No_Relative_Delay::
346 * No_Requeue_Statements::
347 * No_Secondary_Stack::
348 * No_Select_Statements::
349 * No_Specific_Termination_Handlers::
350 * No_Specification_of_Aspect::
351 * No_Standard_Allocators_After_Elaboration::
352 * No_Standard_Storage_Pools::
353 * No_Stream_Optimizations::
354 * No_Streams::
355 * No_Task_Allocators::
356 * No_Task_Attributes_Package::
357 * No_Task_Hierarchy::
358 * No_Task_Termination::
359 * No_Tasking::
360 * No_Terminate_Alternatives::
361 * No_Unchecked_Access::
362 * Simple_Barriers::
363 * Static_Priorities::
364 * Static_Storage_Size::
365
366 Program Unit Level Restrictions
367
368 * No_Elaboration_Code::
369 * No_Entry_Queue::
370 * No_Implementation_Aspect_Specifications::
371 * No_Implementation_Attributes::
372 * No_Implementation_Identifiers::
373 * No_Implementation_Pragmas::
374 * No_Implementation_Restrictions::
375 * No_Implementation_Units::
376 * No_Implicit_Aliasing::
377 * No_Obsolescent_Features::
378 * No_Wide_Characters::
379 * SPARK::
380
381 The Implementation of Standard I/O
382
383 * Standard I/O Packages::
384 * FORM Strings::
385 * Direct_IO::
386 * Sequential_IO::
387 * Text_IO::
388 * Wide_Text_IO::
389 * Wide_Wide_Text_IO::
390 * Stream_IO::
391 * Text Translation::
392 * Shared Files::
393 * Filenames encoding::
394 * Open Modes::
395 * Operations on C Streams::
396 * Interfacing to C Streams::
397
398 The GNAT Library
399
400 * Ada.Characters.Latin_9 (a-chlat9.ads)::
401 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
402 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
403 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
404 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
405 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
406 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
407 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
408 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
409 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
410 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
411 * Ada.Command_Line.Environment (a-colien.ads)::
412 * Ada.Command_Line.Remove (a-colire.ads)::
413 * Ada.Command_Line.Response_File (a-clrefi.ads)::
414 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
415 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
416 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
417 * Ada.Exceptions.Traceback (a-exctra.ads)::
418 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
419 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
420 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
421 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
422 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
423 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
424 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
425 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
426 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
427 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
428 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
429 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
430 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
431 * GNAT.Altivec (g-altive.ads)::
432 * GNAT.Altivec.Conversions (g-altcon.ads)::
433 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
434 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
435 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
436 * GNAT.Array_Split (g-arrspl.ads)::
437 * GNAT.AWK (g-awk.ads)::
438 * GNAT.Bounded_Buffers (g-boubuf.ads)::
439 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
440 * GNAT.Bubble_Sort (g-bubsor.ads)::
441 * GNAT.Bubble_Sort_A (g-busora.ads)::
442 * GNAT.Bubble_Sort_G (g-busorg.ads)::
443 * GNAT.Byte_Order_Mark (g-byorma.ads)::
444 * GNAT.Byte_Swapping (g-bytswa.ads)::
445 * GNAT.Calendar (g-calend.ads)::
446 * GNAT.Calendar.Time_IO (g-catiio.ads)::
447 * GNAT.Case_Util (g-casuti.ads)::
448 * GNAT.CGI (g-cgi.ads)::
449 * GNAT.CGI.Cookie (g-cgicoo.ads)::
450 * GNAT.CGI.Debug (g-cgideb.ads)::
451 * GNAT.Command_Line (g-comlin.ads)::
452 * GNAT.Compiler_Version (g-comver.ads)::
453 * GNAT.Ctrl_C (g-ctrl_c.ads)::
454 * GNAT.CRC32 (g-crc32.ads)::
455 * GNAT.Current_Exception (g-curexc.ads)::
456 * GNAT.Debug_Pools (g-debpoo.ads)::
457 * GNAT.Debug_Utilities (g-debuti.ads)::
458 * GNAT.Decode_String (g-decstr.ads)::
459 * GNAT.Decode_UTF8_String (g-deutst.ads)::
460 * GNAT.Directory_Operations (g-dirope.ads)::
461 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
462 * GNAT.Dynamic_HTables (g-dynhta.ads)::
463 * GNAT.Dynamic_Tables (g-dyntab.ads)::
464 * GNAT.Encode_String (g-encstr.ads)::
465 * GNAT.Encode_UTF8_String (g-enutst.ads)::
466 * GNAT.Exception_Actions (g-excact.ads)::
467 * GNAT.Exception_Traces (g-exctra.ads)::
468 * GNAT.Exceptions (g-except.ads)::
469 * GNAT.Expect (g-expect.ads)::
470 * GNAT.Expect.TTY (g-exptty.ads)::
471 * GNAT.Float_Control (g-flocon.ads)::
472 * GNAT.Heap_Sort (g-heasor.ads)::
473 * GNAT.Heap_Sort_A (g-hesora.ads)::
474 * GNAT.Heap_Sort_G (g-hesorg.ads)::
475 * GNAT.HTable (g-htable.ads)::
476 * GNAT.IO (g-io.ads)::
477 * GNAT.IO_Aux (g-io_aux.ads)::
478 * GNAT.Lock_Files (g-locfil.ads)::
479 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
480 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
481 * GNAT.MD5 (g-md5.ads)::
482 * GNAT.Memory_Dump (g-memdum.ads)::
483 * GNAT.Most_Recent_Exception (g-moreex.ads)::
484 * GNAT.OS_Lib (g-os_lib.ads)::
485 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
486 * GNAT.Random_Numbers (g-rannum.ads)::
487 * GNAT.Regexp (g-regexp.ads)::
488 * GNAT.Registry (g-regist.ads)::
489 * GNAT.Regpat (g-regpat.ads)::
490 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
491 * GNAT.Semaphores (g-semaph.ads)::
492 * GNAT.Serial_Communications (g-sercom.ads)::
493 * GNAT.SHA1 (g-sha1.ads)::
494 * GNAT.SHA224 (g-sha224.ads)::
495 * GNAT.SHA256 (g-sha256.ads)::
496 * GNAT.SHA384 (g-sha384.ads)::
497 * GNAT.SHA512 (g-sha512.ads)::
498 * GNAT.Signals (g-signal.ads)::
499 * GNAT.Sockets (g-socket.ads)::
500 * GNAT.Source_Info (g-souinf.ads)::
501 * GNAT.Spelling_Checker (g-speche.ads)::
502 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
503 * GNAT.Spitbol.Patterns (g-spipat.ads)::
504 * GNAT.Spitbol (g-spitbo.ads)::
505 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
506 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
507 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
508 * GNAT.SSE (g-sse.ads)::
509 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
510 * GNAT.Strings (g-string.ads)::
511 * GNAT.String_Split (g-strspl.ads)::
512 * GNAT.Table (g-table.ads)::
513 * GNAT.Task_Lock (g-tasloc.ads)::
514 * GNAT.Threads (g-thread.ads)::
515 * GNAT.Time_Stamp (g-timsta.ads)::
516 * GNAT.Traceback (g-traceb.ads)::
517 * GNAT.Traceback.Symbolic (g-trasym.ads)::
518 * GNAT.UTF_32 (g-utf_32.ads)::
519 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
520 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
521 * GNAT.Wide_String_Split (g-wistsp.ads)::
522 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
523 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
524 * Interfaces.C.Extensions (i-cexten.ads)::
525 * Interfaces.C.Streams (i-cstrea.ads)::
526 * Interfaces.CPP (i-cpp.ads)::
527 * Interfaces.Packed_Decimal (i-pacdec.ads)::
528 * Interfaces.VxWorks (i-vxwork.ads)::
529 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
530 * System.Address_Image (s-addima.ads)::
531 * System.Assertions (s-assert.ads)::
532 * System.Memory (s-memory.ads)::
533 * System.Partition_Interface (s-parint.ads)::
534 * System.Pool_Global (s-pooglo.ads)::
535 * System.Pool_Local (s-pooloc.ads)::
536 * System.Restrictions (s-restri.ads)::
537 * System.Rident (s-rident.ads)::
538 * System.Strings.Stream_Ops (s-ststop.ads)::
539 * System.Task_Info (s-tasinf.ads)::
540 * System.Wch_Cnv (s-wchcnv.ads)::
541 * System.Wch_Con (s-wchcon.ads)::
542
543 Text_IO
544
545 * Text_IO Stream Pointer Positioning::
546 * Text_IO Reading and Writing Non-Regular Files::
547 * Get_Immediate::
548 * Treating Text_IO Files as Streams::
549 * Text_IO Extensions::
550 * Text_IO Facilities for Unbounded Strings::
551
552 Wide_Text_IO
553
554 * Wide_Text_IO Stream Pointer Positioning::
555 * Wide_Text_IO Reading and Writing Non-Regular Files::
556
557 Wide_Wide_Text_IO
558
559 * Wide_Wide_Text_IO Stream Pointer Positioning::
560 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
561
562 Interfacing to Other Languages
563
564 * Interfacing to C::
565 * Interfacing to C++::
566 * Interfacing to COBOL::
567 * Interfacing to Fortran::
568 * Interfacing to non-GNAT Ada code::
569
570 Specialized Needs Annexes
571
572 Implementation of Specific Ada Features
573 * Machine Code Insertions::
574 * GNAT Implementation of Tasking::
575 * GNAT Implementation of Shared Passive Packages::
576 * Code Generation for Array Aggregates::
577 * The Size of Discriminated Records with Default Discriminants::
578 * Strict Conformance to the Ada Reference Manual::
579
580 Implementation of Ada 2012 Features
581
582 Obsolescent Features
583
584 GNU Free Documentation License
585
586 Index
587 @end menu
588
589 @end ifnottex
590
591 @node About This Guide
592 @unnumbered About This Guide
593
594 @noindent
595 This manual contains useful information in writing programs using the
596 @value{EDITION} compiler. It includes information on implementation dependent
597 characteristics of @value{EDITION}, including all the information required by
598 Annex M of the Ada language standard.
599
600 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
601 Ada 83 compatibility mode.
602 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
603 but you can override with a compiler switch
604 to explicitly specify the language version.
605 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
606 @value{EDITION} User's Guide}, for details on these switches.)
607 Throughout this manual, references to ``Ada'' without a year suffix
608 apply to both the Ada 95 and Ada 2005 versions of the language.
609
610 Ada is designed to be highly portable.
611 In general, a program will have the same effect even when compiled by
612 different compilers on different platforms.
613 However, since Ada is designed to be used in a
614 wide variety of applications, it also contains a number of system
615 dependent features to be used in interfacing to the external world.
616 @cindex Implementation-dependent features
617 @cindex Portability
618
619 Note: Any program that makes use of implementation-dependent features
620 may be non-portable. You should follow good programming practice and
621 isolate and clearly document any sections of your program that make use
622 of these features in a non-portable manner.
623
624 @ifset PROEDITION
625 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
626 ``GNAT'' in the remainder of this document.
627 @end ifset
628
629 @menu
630 * What This Reference Manual Contains::
631 * Conventions::
632 * Related Information::
633 @end menu
634
635 @node What This Reference Manual Contains
636 @unnumberedsec What This Reference Manual Contains
637
638 @noindent
639 This reference manual contains the following chapters:
640
641 @itemize @bullet
642 @item
643 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
644 pragmas, which can be used to extend and enhance the functionality of the
645 compiler.
646
647 @item
648 @ref{Implementation Defined Attributes}, lists GNAT
649 implementation-dependent attributes, which can be used to extend and
650 enhance the functionality of the compiler.
651
652 @item
653 @ref{Implementation Defined Restrictions}, lists GNAT
654 implementation-dependent restrictions, which can be used to extend and
655 enhance the functionality of the compiler.
656
657 @item
658 @ref{Implementation Advice}, provides information on generally
659 desirable behavior which are not requirements that all compilers must
660 follow since it cannot be provided on all systems, or which may be
661 undesirable on some systems.
662
663 @item
664 @ref{Implementation Defined Characteristics}, provides a guide to
665 minimizing implementation dependent features.
666
667 @item
668 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
669 implemented by GNAT, and how they can be imported into user
670 application programs.
671
672 @item
673 @ref{Representation Clauses and Pragmas}, describes in detail the
674 way that GNAT represents data, and in particular the exact set
675 of representation clauses and pragmas that is accepted.
676
677 @item
678 @ref{Standard Library Routines}, provides a listing of packages and a
679 brief description of the functionality that is provided by Ada's
680 extensive set of standard library routines as implemented by GNAT@.
681
682 @item
683 @ref{The Implementation of Standard I/O}, details how the GNAT
684 implementation of the input-output facilities.
685
686 @item
687 @ref{The GNAT Library}, is a catalog of packages that complement
688 the Ada predefined library.
689
690 @item
691 @ref{Interfacing to Other Languages}, describes how programs
692 written in Ada using GNAT can be interfaced to other programming
693 languages.
694
695 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
696 of the specialized needs annexes.
697
698 @item
699 @ref{Implementation of Specific Ada Features}, discusses issues related
700 to GNAT's implementation of machine code insertions, tasking, and several
701 other features.
702
703 @item
704 @ref{Implementation of Ada 2012 Features}, describes the status of the
705 GNAT implementation of the Ada 2012 language standard.
706
707 @item
708 @ref{Obsolescent Features} documents implementation dependent features,
709 including pragmas and attributes, which are considered obsolescent, since
710 there are other preferred ways of achieving the same results. These
711 obsolescent forms are retained for backwards compatibility.
712
713 @end itemize
714
715 @cindex Ada 95 Language Reference Manual
716 @cindex Ada 2005 Language Reference Manual
717 @noindent
718 This reference manual assumes a basic familiarity with the Ada 95 language, as
719 described in the International Standard ANSI/ISO/IEC-8652:1995,
720 January 1995.
721 It does not require knowledge of the new features introduced by Ada 2005,
722 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
723 and Amendment 1).
724 Both reference manuals are included in the GNAT documentation
725 package.
726
727 @node Conventions
728 @unnumberedsec Conventions
729 @cindex Conventions, typographical
730 @cindex Typographical conventions
731
732 @noindent
733 Following are examples of the typographical and graphic conventions used
734 in this guide:
735
736 @itemize @bullet
737 @item
738 @code{Functions}, @code{utility program names}, @code{standard names},
739 and @code{classes}.
740
741 @item
742 @code{Option flags}
743
744 @item
745 @file{File names}, @samp{button names}, and @samp{field names}.
746
747 @item
748 @code{Variables}, @env{environment variables}, and @var{metasyntactic
749 variables}.
750
751 @item
752 @emph{Emphasis}.
753
754 @item
755 [optional information or parameters]
756
757 @item
758 Examples are described by text
759 @smallexample
760 and then shown this way.
761 @end smallexample
762 @end itemize
763
764 @noindent
765 Commands that are entered by the user are preceded in this manual by the
766 characters @samp{$ } (dollar sign followed by space). If your system uses this
767 sequence as a prompt, then the commands will appear exactly as you see them
768 in the manual. If your system uses some other prompt, then the command will
769 appear with the @samp{$} replaced by whatever prompt character you are using.
770
771 @node Related Information
772 @unnumberedsec Related Information
773 @noindent
774 See the following documents for further information on GNAT:
775
776 @itemize @bullet
777 @item
778 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
779 @value{EDITION} User's Guide}, which provides information on how to use the
780 GNAT compiler system.
781
782 @item
783 @cite{Ada 95 Reference Manual}, which contains all reference
784 material for the Ada 95 programming language.
785
786 @item
787 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
788 of the Ada 95 standard. The annotations describe
789 detailed aspects of the design decision, and in particular contain useful
790 sections on Ada 83 compatibility.
791
792 @item
793 @cite{Ada 2005 Reference Manual}, which contains all reference
794 material for the Ada 2005 programming language.
795
796 @item
797 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
798 of the Ada 2005 standard. The annotations describe
799 detailed aspects of the design decision, and in particular contain useful
800 sections on Ada 83 and Ada 95 compatibility.
801
802 @item
803 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
804 which contains specific information on compatibility between GNAT and
805 DEC Ada 83 systems.
806
807 @item
808 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
809 describes in detail the pragmas and attributes provided by the DEC Ada 83
810 compiler system.
811
812 @end itemize
813
814 @node Implementation Defined Pragmas
815 @chapter Implementation Defined Pragmas
816
817 @noindent
818 Ada defines a set of pragmas that can be used to supply additional
819 information to the compiler. These language defined pragmas are
820 implemented in GNAT and work as described in the Ada Reference Manual.
821
822 In addition, Ada allows implementations to define additional pragmas
823 whose meaning is defined by the implementation. GNAT provides a number
824 of these implementation-defined pragmas, which can be used to extend
825 and enhance the functionality of the compiler. This section of the GNAT
826 Reference Manual describes these additional pragmas.
827
828 Note that any program using these pragmas might not be portable to other
829 compilers (although GNAT implements this set of pragmas on all
830 platforms). Therefore if portability to other compilers is an important
831 consideration, the use of these pragmas should be minimized.
832
833 @menu
834 * Pragma Abort_Defer::
835 * Pragma Ada_83::
836 * Pragma Ada_95::
837 * Pragma Ada_05::
838 * Pragma Ada_2005::
839 * Pragma Ada_12::
840 * Pragma Ada_2012::
841 * Pragma Annotate::
842 * Pragma Assert::
843 * Pragma Assertion_Policy::
844 * Pragma Assume_No_Invalid_Values::
845 * Pragma Ast_Entry::
846 * Pragma C_Pass_By_Copy::
847 * Pragma Check::
848 * Pragma Check_Name::
849 * Pragma Check_Policy::
850 * Pragma Comment::
851 * Pragma Common_Object::
852 * Pragma Compile_Time_Error::
853 * Pragma Compile_Time_Warning::
854 * Pragma Compiler_Unit::
855 * Pragma Complete_Representation::
856 * Pragma Complex_Representation::
857 * Pragma Component_Alignment::
858 * Pragma Convention_Identifier::
859 * Pragma CPP_Class::
860 * Pragma CPP_Constructor::
861 * Pragma CPP_Virtual::
862 * Pragma CPP_Vtable::
863 * Pragma Debug::
864 * Pragma Debug_Policy::
865 * Pragma Detect_Blocking::
866 * Pragma Elaboration_Checks::
867 * Pragma Eliminate::
868 * Pragma Export_Exception::
869 * Pragma Export_Function::
870 * Pragma Export_Object::
871 * Pragma Export_Procedure::
872 * Pragma Export_Value::
873 * Pragma Export_Valued_Procedure::
874 * Pragma Extend_System::
875 * Pragma Extensions_Allowed::
876 * Pragma External::
877 * Pragma External_Name_Casing::
878 * Pragma Fast_Math::
879 * Pragma Favor_Top_Level::
880 * Pragma Finalize_Storage_Only::
881 * Pragma Float_Representation::
882 * Pragma Ident::
883 * Pragma Implemented::
884 * Pragma Implicit_Packing::
885 * Pragma Import_Exception::
886 * Pragma Import_Function::
887 * Pragma Import_Object::
888 * Pragma Import_Procedure::
889 * Pragma Import_Valued_Procedure::
890 * Pragma Initialize_Scalars::
891 * Pragma Inline_Always::
892 * Pragma Inline_Generic::
893 * Pragma Interface::
894 * Pragma Interface_Name::
895 * Pragma Interrupt_Handler::
896 * Pragma Interrupt_State::
897 * Pragma Invariant::
898 * Pragma Keep_Names::
899 * Pragma License::
900 * Pragma Link_With::
901 * Pragma Linker_Alias::
902 * Pragma Linker_Constructor::
903 * Pragma Linker_Destructor::
904 * Pragma Linker_Section::
905 * Pragma Long_Float::
906 * Pragma Machine_Attribute::
907 * Pragma Main::
908 * Pragma Main_Storage::
909 * Pragma No_Body::
910 * Pragma No_Return::
911 * Pragma No_Strict_Aliasing::
912 * Pragma Normalize_Scalars::
913 * Pragma Obsolescent::
914 * Pragma Optimize_Alignment::
915 * Pragma Ordered::
916 * Pragma Passive::
917 * Pragma Persistent_BSS::
918 * Pragma Polling::
919 * Pragma Postcondition::
920 * Pragma Precondition::
921 * Pragma Profile (Ravenscar)::
922 * Pragma Profile (Restricted)::
923 * Pragma Psect_Object::
924 * Pragma Pure_Function::
925 * Pragma Remote_Access_Type::
926 * Pragma Restriction_Warnings::
927 * Pragma Shared::
928 * Pragma Short_Circuit_And_Or::
929 * Pragma Short_Descriptors::
930 * Pragma Simple_Storage_Pool_Type::
931 * Pragma Source_File_Name::
932 * Pragma Source_File_Name_Project::
933 * Pragma Source_Reference::
934 * Pragma Static_Elaboration_Desired::
935 * Pragma Stream_Convert::
936 * Pragma Style_Checks::
937 * Pragma Subtitle::
938 * Pragma Suppress::
939 * Pragma Suppress_All::
940 * Pragma Suppress_Exception_Locations::
941 * Pragma Suppress_Initialization::
942 * Pragma Task_Info::
943 * Pragma Task_Name::
944 * Pragma Task_Storage::
945 * Pragma Test_Case::
946 * Pragma Thread_Local_Storage::
947 * Pragma Time_Slice::
948 * Pragma Title::
949 * Pragma Unchecked_Union::
950 * Pragma Unimplemented_Unit::
951 * Pragma Universal_Aliasing ::
952 * Pragma Universal_Data::
953 * Pragma Unmodified::
954 * Pragma Unreferenced::
955 * Pragma Unreferenced_Objects::
956 * Pragma Unreserve_All_Interrupts::
957 * Pragma Unsuppress::
958 * Pragma Use_VADS_Size::
959 * Pragma Validity_Checks::
960 * Pragma Volatile::
961 * Pragma Warnings::
962 * Pragma Weak_External::
963 * Pragma Wide_Character_Encoding::
964 @end menu
965
966 @node Pragma Abort_Defer
967 @unnumberedsec Pragma Abort_Defer
968 @findex Abort_Defer
969 @cindex Deferring aborts
970 @noindent
971 Syntax:
972 @smallexample
973 pragma Abort_Defer;
974 @end smallexample
975
976 @noindent
977 This pragma must appear at the start of the statement sequence of a
978 handled sequence of statements (right after the @code{begin}). It has
979 the effect of deferring aborts for the sequence of statements (but not
980 for the declarations or handlers, if any, associated with this statement
981 sequence).
982
983 @node Pragma Ada_83
984 @unnumberedsec Pragma Ada_83
985 @findex Ada_83
986 @noindent
987 Syntax:
988 @smallexample @c ada
989 pragma Ada_83;
990 @end smallexample
991
992 @noindent
993 A configuration pragma that establishes Ada 83 mode for the unit to
994 which it applies, regardless of the mode set by the command line
995 switches. In Ada 83 mode, GNAT attempts to be as compatible with
996 the syntax and semantics of Ada 83, as defined in the original Ada
997 83 Reference Manual as possible. In particular, the keywords added by Ada 95
998 and Ada 2005 are not recognized, optional package bodies are allowed,
999 and generics may name types with unknown discriminants without using
1000 the @code{(<>)} notation. In addition, some but not all of the additional
1001 restrictions of Ada 83 are enforced.
1002
1003 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1004 Ada 83 code to be compiled and adapted to GNAT with less effort.
1005 Secondly, it aids in keeping code backwards compatible with Ada 83.
1006 However, there is no guarantee that code that is processed correctly
1007 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1008 83 compiler, since GNAT does not enforce all the additional checks
1009 required by Ada 83.
1010
1011 @node Pragma Ada_95
1012 @unnumberedsec Pragma Ada_95
1013 @findex Ada_95
1014 @noindent
1015 Syntax:
1016 @smallexample @c ada
1017 pragma Ada_95;
1018 @end smallexample
1019
1020 @noindent
1021 A configuration pragma that establishes Ada 95 mode for the unit to which
1022 it applies, regardless of the mode set by the command line switches.
1023 This mode is set automatically for the @code{Ada} and @code{System}
1024 packages and their children, so you need not specify it in these
1025 contexts. This pragma is useful when writing a reusable component that
1026 itself uses Ada 95 features, but which is intended to be usable from
1027 either Ada 83 or Ada 95 programs.
1028
1029 @node Pragma Ada_05
1030 @unnumberedsec Pragma Ada_05
1031 @findex Ada_05
1032 @noindent
1033 Syntax:
1034 @smallexample @c ada
1035 pragma Ada_05;
1036 @end smallexample
1037
1038 @noindent
1039 A configuration pragma that establishes Ada 2005 mode for the unit to which
1040 it applies, regardless of the mode set by the command line switches.
1041 This pragma is useful when writing a reusable component that
1042 itself uses Ada 2005 features, but which is intended to be usable from
1043 either Ada 83 or Ada 95 programs.
1044
1045 @node Pragma Ada_2005
1046 @unnumberedsec Pragma Ada_2005
1047 @findex Ada_2005
1048 @noindent
1049 Syntax:
1050 @smallexample @c ada
1051 pragma Ada_2005;
1052 @end smallexample
1053
1054 @noindent
1055 This configuration pragma is a synonym for pragma Ada_05 and has the
1056 same syntax and effect.
1057
1058 @node Pragma Ada_12
1059 @unnumberedsec Pragma Ada_12
1060 @findex Ada_12
1061 @noindent
1062 Syntax:
1063 @smallexample @c ada
1064 pragma Ada_12;
1065 @end smallexample
1066
1067 @noindent
1068 A configuration pragma that establishes Ada 2012 mode for the unit to which
1069 it applies, regardless of the mode set by the command line switches.
1070 This mode is set automatically for the @code{Ada} and @code{System}
1071 packages and their children, so you need not specify it in these
1072 contexts. This pragma is useful when writing a reusable component that
1073 itself uses Ada 2012 features, but which is intended to be usable from
1074 Ada 83, Ada 95, or Ada 2005 programs.
1075
1076 @node Pragma Ada_2012
1077 @unnumberedsec Pragma Ada_2012
1078 @findex Ada_2005
1079 @noindent
1080 Syntax:
1081 @smallexample @c ada
1082 pragma Ada_2012;
1083 @end smallexample
1084
1085 @noindent
1086 This configuration pragma is a synonym for pragma Ada_12 and has the
1087 same syntax and effect.
1088
1089 @node Pragma Annotate
1090 @unnumberedsec Pragma Annotate
1091 @findex Annotate
1092 @noindent
1093 Syntax:
1094 @smallexample @c ada
1095 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1096
1097 ARG ::= NAME | EXPRESSION
1098 @end smallexample
1099
1100 @noindent
1101 This pragma is used to annotate programs. @var{identifier} identifies
1102 the type of annotation. GNAT verifies that it is an identifier, but does
1103 not otherwise analyze it. The second optional identifier is also left
1104 unanalyzed, and by convention is used to control the action of the tool to
1105 which the annotation is addressed. The remaining @var{arg} arguments
1106 can be either string literals or more generally expressions.
1107 String literals are assumed to be either of type
1108 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1109 depending on the character literals they contain.
1110 All other kinds of arguments are analyzed as expressions, and must be
1111 unambiguous.
1112
1113 The analyzed pragma is retained in the tree, but not otherwise processed
1114 by any part of the GNAT compiler, except to generate corresponding note
1115 lines in the generated ALI file. For the format of these note lines, see
1116 the compiler source file lib-writ.ads. This pragma is intended for use by
1117 external tools, including ASIS@. The use of pragma Annotate does not
1118 affect the compilation process in any way. This pragma may be used as
1119 a configuration pragma.
1120
1121 @node Pragma Assert
1122 @unnumberedsec Pragma Assert
1123 @findex Assert
1124 @noindent
1125 Syntax:
1126 @smallexample @c ada
1127 pragma Assert (
1128 boolean_EXPRESSION
1129 [, string_EXPRESSION]);
1130 @end smallexample
1131
1132 @noindent
1133 The effect of this pragma depends on whether the corresponding command
1134 line switch is set to activate assertions. The pragma expands into code
1135 equivalent to the following:
1136
1137 @smallexample @c ada
1138 if assertions-enabled then
1139 if not boolean_EXPRESSION then
1140 System.Assertions.Raise_Assert_Failure
1141 (string_EXPRESSION);
1142 end if;
1143 end if;
1144 @end smallexample
1145
1146 @noindent
1147 The string argument, if given, is the message that will be associated
1148 with the exception occurrence if the exception is raised. If no second
1149 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1150 where @var{file} is the name of the source file containing the assert,
1151 and @var{nnn} is the line number of the assert. A pragma is not a
1152 statement, so if a statement sequence contains nothing but a pragma
1153 assert, then a null statement is required in addition, as in:
1154
1155 @smallexample @c ada
1156 @dots{}
1157 if J > 3 then
1158 pragma Assert (K > 3, "Bad value for K");
1159 null;
1160 end if;
1161 @end smallexample
1162
1163 @noindent
1164 Note that, as with the @code{if} statement to which it is equivalent, the
1165 type of the expression is either @code{Standard.Boolean}, or any type derived
1166 from this standard type.
1167
1168 If assertions are disabled (switch @option{-gnata} not used), then there
1169 is no run-time effect (and in particular, any side effects from the
1170 expression will not occur at run time). (The expression is still
1171 analyzed at compile time, and may cause types to be frozen if they are
1172 mentioned here for the first time).
1173
1174 If assertions are enabled, then the given expression is tested, and if
1175 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1176 which results in the raising of @code{Assert_Failure} with the given message.
1177
1178 You should generally avoid side effects in the expression arguments of
1179 this pragma, because these side effects will turn on and off with the
1180 setting of the assertions mode, resulting in assertions that have an
1181 effect on the program. However, the expressions are analyzed for
1182 semantic correctness whether or not assertions are enabled, so turning
1183 assertions on and off cannot affect the legality of a program.
1184
1185 Note that the implementation defined policy @code{DISABLE}, given in a
1186 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1187
1188 Note: this is a standard language-defined pragma in versions
1189 of Ada from 2005 on. In GNAT, it is implemented in all versions
1190 of Ada, and the DISABLE policy is an implementation-defined
1191 addition.
1192
1193
1194 @node Pragma Assertion_Policy
1195 @unnumberedsec Pragma Assertion_Policy
1196 @findex Debug_Policy
1197 @noindent
1198 Syntax:
1199
1200 @smallexample @c ada
1201 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1202 @end smallexample
1203
1204 @noindent
1205 If the argument is @code{CHECK}, then assertions are enabled.
1206 If the argument is @code{IGNORE}, then assertions are ignored.
1207 This pragma overrides the effect of the @option{-gnata} switch on the
1208 command line.
1209
1210 Assertions are of three kinds:
1211
1212 @itemize @bullet
1213 @item
1214 Pragma @code{Assert}.
1215 @item
1216 In Ada 2012, all assertions defined in the RM as aspects: preconditions,
1217 postconditions, type invariants and (sub)type predicates.
1218 @item
1219 Corresponding pragmas for type invariants and (sub)type predicates.
1220 @end itemize
1221
1222 The implementation defined policy @code{DISABLE} is like
1223 @code{IGNORE} except that it completely disables semantic
1224 checking of the argument to @code{pragma Assert}. This may
1225 be useful when the pragma argument references subprograms
1226 in a with'ed package which is replaced by a dummy package
1227 for the final build.
1228
1229 Note: this is a standard language-defined pragma in versions
1230 of Ada from 2005 on. In GNAT, it is implemented in all versions
1231 of Ada, and the DISABLE policy is an implementation-defined
1232 addition.
1233
1234 @node Pragma Assume_No_Invalid_Values
1235 @unnumberedsec Pragma Assume_No_Invalid_Values
1236 @findex Assume_No_Invalid_Values
1237 @cindex Invalid representations
1238 @cindex Invalid values
1239 @noindent
1240 Syntax:
1241 @smallexample @c ada
1242 pragma Assume_No_Invalid_Values (On | Off);
1243 @end smallexample
1244
1245 @noindent
1246 This is a configuration pragma that controls the assumptions made by the
1247 compiler about the occurrence of invalid representations (invalid values)
1248 in the code.
1249
1250 The default behavior (corresponding to an Off argument for this pragma), is
1251 to assume that values may in general be invalid unless the compiler can
1252 prove they are valid. Consider the following example:
1253
1254 @smallexample @c ada
1255 V1 : Integer range 1 .. 10;
1256 V2 : Integer range 11 .. 20;
1257 ...
1258 for J in V2 .. V1 loop
1259 ...
1260 end loop;
1261 @end smallexample
1262
1263 @noindent
1264 if V1 and V2 have valid values, then the loop is known at compile
1265 time not to execute since the lower bound must be greater than the
1266 upper bound. However in default mode, no such assumption is made,
1267 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1268 is given, the compiler will assume that any occurrence of a variable
1269 other than in an explicit @code{'Valid} test always has a valid
1270 value, and the loop above will be optimized away.
1271
1272 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1273 you know your code is free of uninitialized variables and other
1274 possible sources of invalid representations, and may result in
1275 more efficient code. A program that accesses an invalid representation
1276 with this pragma in effect is erroneous, so no guarantees can be made
1277 about its behavior.
1278
1279 It is peculiar though permissible to use this pragma in conjunction
1280 with validity checking (-gnatVa). In such cases, accessing invalid
1281 values will generally give an exception, though formally the program
1282 is erroneous so there are no guarantees that this will always be the
1283 case, and it is recommended that these two options not be used together.
1284
1285 @node Pragma Ast_Entry
1286 @unnumberedsec Pragma Ast_Entry
1287 @cindex OpenVMS
1288 @findex Ast_Entry
1289 @noindent
1290 Syntax:
1291 @smallexample @c ada
1292 pragma AST_Entry (entry_IDENTIFIER);
1293 @end smallexample
1294
1295 @noindent
1296 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1297 argument is the simple name of a single entry; at most one @code{AST_Entry}
1298 pragma is allowed for any given entry. This pragma must be used in
1299 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1300 the entry declaration and in the same task type specification or single task
1301 as the entry to which it applies. This pragma specifies that the given entry
1302 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1303 resulting from an OpenVMS system service call. The pragma does not affect
1304 normal use of the entry. For further details on this pragma, see the
1305 DEC Ada Language Reference Manual, section 9.12a.
1306
1307 @node Pragma C_Pass_By_Copy
1308 @unnumberedsec Pragma C_Pass_By_Copy
1309 @cindex Passing by copy
1310 @findex C_Pass_By_Copy
1311 @noindent
1312 Syntax:
1313 @smallexample @c ada
1314 pragma C_Pass_By_Copy
1315 ([Max_Size =>] static_integer_EXPRESSION);
1316 @end smallexample
1317
1318 @noindent
1319 Normally the default mechanism for passing C convention records to C
1320 convention subprograms is to pass them by reference, as suggested by RM
1321 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1322 this default, by requiring that record formal parameters be passed by
1323 copy if all of the following conditions are met:
1324
1325 @itemize @bullet
1326 @item
1327 The size of the record type does not exceed the value specified for
1328 @code{Max_Size}.
1329 @item
1330 The record type has @code{Convention C}.
1331 @item
1332 The formal parameter has this record type, and the subprogram has a
1333 foreign (non-Ada) convention.
1334 @end itemize
1335
1336 @noindent
1337 If these conditions are met the argument is passed by copy, i.e.@: in a
1338 manner consistent with what C expects if the corresponding formal in the
1339 C prototype is a struct (rather than a pointer to a struct).
1340
1341 You can also pass records by copy by specifying the convention
1342 @code{C_Pass_By_Copy} for the record type, or by using the extended
1343 @code{Import} and @code{Export} pragmas, which allow specification of
1344 passing mechanisms on a parameter by parameter basis.
1345
1346 @node Pragma Check
1347 @unnumberedsec Pragma Check
1348 @cindex Assertions
1349 @cindex Named assertions
1350 @findex Check
1351 @noindent
1352 Syntax:
1353 @smallexample @c ada
1354 pragma Check (
1355 [Name =>] Identifier,
1356 [Check =>] Boolean_EXPRESSION
1357 [, [Message =>] string_EXPRESSION] );
1358 @end smallexample
1359
1360 @noindent
1361 This pragma is similar to the predefined pragma @code{Assert} except that an
1362 extra identifier argument is present. In conjunction with pragma
1363 @code{Check_Policy}, this can be used to define groups of assertions that can
1364 be independently controlled. The identifier @code{Assertion} is special, it
1365 refers to the normal set of pragma @code{Assert} statements. The identifiers
1366 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1367 names, so these three names would normally not be used directly in a pragma
1368 @code{Check}.
1369
1370 Checks introduced by this pragma are normally deactivated by default. They can
1371 be activated either by the command line option @option{-gnata}, which turns on
1372 all checks, or individually controlled using pragma @code{Check_Policy}.
1373
1374 @node Pragma Check_Name
1375 @unnumberedsec Pragma Check_Name
1376 @cindex Defining check names
1377 @cindex Check names, defining
1378 @findex Check_Name
1379 @noindent
1380 Syntax:
1381 @smallexample @c ada
1382 pragma Check_Name (check_name_IDENTIFIER);
1383 @end smallexample
1384
1385 @noindent
1386 This is a configuration pragma that defines a new implementation
1387 defined check name (unless IDENTIFIER matches one of the predefined
1388 check names, in which case the pragma has no effect). Check names
1389 are global to a partition, so if two or more configuration pragmas
1390 are present in a partition mentioning the same name, only one new
1391 check name is introduced.
1392
1393 An implementation defined check name introduced with this pragma may
1394 be used in only three contexts: @code{pragma Suppress},
1395 @code{pragma Unsuppress},
1396 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1397 any of these three cases, the check name must be visible. A check
1398 name is visible if it is in the configuration pragmas applying to
1399 the current unit, or if it appears at the start of any unit that
1400 is part of the dependency set of the current unit (e.g., units that
1401 are mentioned in @code{with} clauses).
1402
1403 @node Pragma Check_Policy
1404 @unnumberedsec Pragma Check_Policy
1405 @cindex Controlling assertions
1406 @cindex Assertions, control
1407 @cindex Check pragma control
1408 @cindex Named assertions
1409 @findex Check
1410 @noindent
1411 Syntax:
1412 @smallexample @c ada
1413 pragma Check_Policy
1414 ([Name =>] Identifier,
1415 [Policy =>] POLICY_IDENTIFIER);
1416
1417 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1418 @end smallexample
1419
1420 @noindent
1421 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1422 except that it controls sets of named assertions introduced using the
1423 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1424 @code{Assertion_Policy}) can be used within a declarative part, in which case
1425 it controls the status to the end of the corresponding construct (in a manner
1426 identical to pragma @code{Suppress)}.
1427
1428 The identifier given as the first argument corresponds to a name used in
1429 associated @code{Check} pragmas. For example, if the pragma:
1430
1431 @smallexample @c ada
1432 pragma Check_Policy (Critical_Error, OFF);
1433 @end smallexample
1434
1435 @noindent
1436 is given, then subsequent @code{Check} pragmas whose first argument is also
1437 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1438 controls the behavior of normal assertions (thus a pragma
1439 @code{Check_Policy} with this identifier is similar to the normal
1440 @code{Assertion_Policy} pragma except that it can appear within a
1441 declarative part).
1442
1443 The special identifiers @code{Precondition} and @code{Postcondition} control
1444 the status of preconditions and postconditions given as pragmas.
1445 If a @code{Precondition} pragma
1446 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1447 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1448 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1449 are recognized. Note that preconditions and postconditions given as aspects
1450 are controlled differently, either by the @code{Assertion_Policy} pragma or
1451 by the @code{Check_Policy} pragma with identifier @code{Assertion}.
1452
1453 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1454 to turn on corresponding checks. The default for a set of checks for which no
1455 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1456 @option{-gnata} is given, which turns on all checks by default.
1457
1458 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1459 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1460 compatibility with the standard @code{Assertion_Policy} pragma.
1461
1462 The implementation defined policy @code{DISABLE} is like
1463 @code{OFF} except that it completely disables semantic
1464 checking of the argument to the corresponding class of
1465 pragmas. This may be useful when the pragma arguments reference
1466 subprograms in a with'ed package which is replaced by a dummy package
1467 for the final build.
1468
1469 @node Pragma Comment
1470 @unnumberedsec Pragma Comment
1471 @findex Comment
1472 @noindent
1473 Syntax:
1474
1475 @smallexample @c ada
1476 pragma Comment (static_string_EXPRESSION);
1477 @end smallexample
1478
1479 @noindent
1480 This is almost identical in effect to pragma @code{Ident}. It allows the
1481 placement of a comment into the object file and hence into the
1482 executable file if the operating system permits such usage. The
1483 difference is that @code{Comment}, unlike @code{Ident}, has
1484 no limitations on placement of the pragma (it can be placed
1485 anywhere in the main source unit), and if more than one pragma
1486 is used, all comments are retained.
1487
1488 @node Pragma Common_Object
1489 @unnumberedsec Pragma Common_Object
1490 @findex Common_Object
1491 @noindent
1492 Syntax:
1493
1494 @smallexample @c ada
1495 pragma Common_Object (
1496 [Internal =>] LOCAL_NAME
1497 [, [External =>] EXTERNAL_SYMBOL]
1498 [, [Size =>] EXTERNAL_SYMBOL] );
1499
1500 EXTERNAL_SYMBOL ::=
1501 IDENTIFIER
1502 | static_string_EXPRESSION
1503 @end smallexample
1504
1505 @noindent
1506 This pragma enables the shared use of variables stored in overlaid
1507 linker areas corresponding to the use of @code{COMMON}
1508 in Fortran. The single
1509 object @var{LOCAL_NAME} is assigned to the area designated by
1510 the @var{External} argument.
1511 You may define a record to correspond to a series
1512 of fields. The @var{Size} argument
1513 is syntax checked in GNAT, but otherwise ignored.
1514
1515 @code{Common_Object} is not supported on all platforms. If no
1516 support is available, then the code generator will issue a message
1517 indicating that the necessary attribute for implementation of this
1518 pragma is not available.
1519
1520 @node Pragma Compile_Time_Error
1521 @unnumberedsec Pragma Compile_Time_Error
1522 @findex Compile_Time_Error
1523 @noindent
1524 Syntax:
1525
1526 @smallexample @c ada
1527 pragma Compile_Time_Error
1528 (boolean_EXPRESSION, static_string_EXPRESSION);
1529 @end smallexample
1530
1531 @noindent
1532 This pragma can be used to generate additional compile time
1533 error messages. It
1534 is particularly useful in generics, where errors can be issued for
1535 specific problematic instantiations. The first parameter is a boolean
1536 expression. The pragma is effective only if the value of this expression
1537 is known at compile time, and has the value True. The set of expressions
1538 whose values are known at compile time includes all static boolean
1539 expressions, and also other values which the compiler can determine
1540 at compile time (e.g., the size of a record type set by an explicit
1541 size representation clause, or the value of a variable which was
1542 initialized to a constant and is known not to have been modified).
1543 If these conditions are met, an error message is generated using
1544 the value given as the second argument. This string value may contain
1545 embedded ASCII.LF characters to break the message into multiple lines.
1546
1547 @node Pragma Compile_Time_Warning
1548 @unnumberedsec Pragma Compile_Time_Warning
1549 @findex Compile_Time_Warning
1550 @noindent
1551 Syntax:
1552
1553 @smallexample @c ada
1554 pragma Compile_Time_Warning
1555 (boolean_EXPRESSION, static_string_EXPRESSION);
1556 @end smallexample
1557
1558 @noindent
1559 Same as pragma Compile_Time_Error, except a warning is issued instead
1560 of an error message. Note that if this pragma is used in a package that
1561 is with'ed by a client, the client will get the warning even though it
1562 is issued by a with'ed package (normally warnings in with'ed units are
1563 suppressed, but this is a special exception to that rule).
1564
1565 One typical use is within a generic where compile time known characteristics
1566 of formal parameters are tested, and warnings given appropriately. Another use
1567 with a first parameter of True is to warn a client about use of a package,
1568 for example that it is not fully implemented.
1569
1570 @node Pragma Compiler_Unit
1571 @unnumberedsec Pragma Compiler_Unit
1572 @findex Compiler_Unit
1573 @noindent
1574 Syntax:
1575
1576 @smallexample @c ada
1577 pragma Compiler_Unit;
1578 @end smallexample
1579
1580 @noindent
1581 This pragma is intended only for internal use in the GNAT run-time library.
1582 It indicates that the unit is used as part of the compiler build. The effect
1583 is to disallow constructs (raise with message, conditional expressions etc)
1584 that would cause trouble when bootstrapping using an older version of GNAT.
1585 For the exact list of restrictions, see the compiler sources and references
1586 to Is_Compiler_Unit.
1587
1588 @node Pragma Complete_Representation
1589 @unnumberedsec Pragma Complete_Representation
1590 @findex Complete_Representation
1591 @noindent
1592 Syntax:
1593
1594 @smallexample @c ada
1595 pragma Complete_Representation;
1596 @end smallexample
1597
1598 @noindent
1599 This pragma must appear immediately within a record representation
1600 clause. Typical placements are before the first component clause
1601 or after the last component clause. The effect is to give an error
1602 message if any component is missing a component clause. This pragma
1603 may be used to ensure that a record representation clause is
1604 complete, and that this invariant is maintained if fields are
1605 added to the record in the future.
1606
1607 @node Pragma Complex_Representation
1608 @unnumberedsec Pragma Complex_Representation
1609 @findex Complex_Representation
1610 @noindent
1611 Syntax:
1612
1613 @smallexample @c ada
1614 pragma Complex_Representation
1615 ([Entity =>] LOCAL_NAME);
1616 @end smallexample
1617
1618 @noindent
1619 The @var{Entity} argument must be the name of a record type which has
1620 two fields of the same floating-point type. The effect of this pragma is
1621 to force gcc to use the special internal complex representation form for
1622 this record, which may be more efficient. Note that this may result in
1623 the code for this type not conforming to standard ABI (application
1624 binary interface) requirements for the handling of record types. For
1625 example, in some environments, there is a requirement for passing
1626 records by pointer, and the use of this pragma may result in passing
1627 this type in floating-point registers.
1628
1629 @node Pragma Component_Alignment
1630 @unnumberedsec Pragma Component_Alignment
1631 @cindex Alignments of components
1632 @findex Component_Alignment
1633 @noindent
1634 Syntax:
1635
1636 @smallexample @c ada
1637 pragma Component_Alignment (
1638 [Form =>] ALIGNMENT_CHOICE
1639 [, [Name =>] type_LOCAL_NAME]);
1640
1641 ALIGNMENT_CHOICE ::=
1642 Component_Size
1643 | Component_Size_4
1644 | Storage_Unit
1645 | Default
1646 @end smallexample
1647
1648 @noindent
1649 Specifies the alignment of components in array or record types.
1650 The meaning of the @var{Form} argument is as follows:
1651
1652 @table @code
1653 @findex Component_Size
1654 @item Component_Size
1655 Aligns scalar components and subcomponents of the array or record type
1656 on boundaries appropriate to their inherent size (naturally
1657 aligned). For example, 1-byte components are aligned on byte boundaries,
1658 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1659 integer components are aligned on 4-byte boundaries and so on. These
1660 alignment rules correspond to the normal rules for C compilers on all
1661 machines except the VAX@.
1662
1663 @findex Component_Size_4
1664 @item Component_Size_4
1665 Naturally aligns components with a size of four or fewer
1666 bytes. Components that are larger than 4 bytes are placed on the next
1667 4-byte boundary.
1668
1669 @findex Storage_Unit
1670 @item Storage_Unit
1671 Specifies that array or record components are byte aligned, i.e.@:
1672 aligned on boundaries determined by the value of the constant
1673 @code{System.Storage_Unit}.
1674
1675 @cindex OpenVMS
1676 @item Default
1677 Specifies that array or record components are aligned on default
1678 boundaries, appropriate to the underlying hardware or operating system or
1679 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1680 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1681 the @code{Default} choice is the same as @code{Component_Size} (natural
1682 alignment).
1683 @end table
1684
1685 @noindent
1686 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1687 refer to a local record or array type, and the specified alignment
1688 choice applies to the specified type. The use of
1689 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1690 @code{Component_Alignment} pragma to be ignored. The use of
1691 @code{Component_Alignment} together with a record representation clause
1692 is only effective for fields not specified by the representation clause.
1693
1694 If the @code{Name} parameter is absent, the pragma can be used as either
1695 a configuration pragma, in which case it applies to one or more units in
1696 accordance with the normal rules for configuration pragmas, or it can be
1697 used within a declarative part, in which case it applies to types that
1698 are declared within this declarative part, or within any nested scope
1699 within this declarative part. In either case it specifies the alignment
1700 to be applied to any record or array type which has otherwise standard
1701 representation.
1702
1703 If the alignment for a record or array type is not specified (using
1704 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1705 clause), the GNAT uses the default alignment as described previously.
1706
1707 @node Pragma Convention_Identifier
1708 @unnumberedsec Pragma Convention_Identifier
1709 @findex Convention_Identifier
1710 @cindex Conventions, synonyms
1711 @noindent
1712 Syntax:
1713
1714 @smallexample @c ada
1715 pragma Convention_Identifier (
1716 [Name =>] IDENTIFIER,
1717 [Convention =>] convention_IDENTIFIER);
1718 @end smallexample
1719
1720 @noindent
1721 This pragma provides a mechanism for supplying synonyms for existing
1722 convention identifiers. The @code{Name} identifier can subsequently
1723 be used as a synonym for the given convention in other pragmas (including
1724 for example pragma @code{Import} or another @code{Convention_Identifier}
1725 pragma). As an example of the use of this, suppose you had legacy code
1726 which used Fortran77 as the identifier for Fortran. Then the pragma:
1727
1728 @smallexample @c ada
1729 pragma Convention_Identifier (Fortran77, Fortran);
1730 @end smallexample
1731
1732 @noindent
1733 would allow the use of the convention identifier @code{Fortran77} in
1734 subsequent code, avoiding the need to modify the sources. As another
1735 example, you could use this to parameterize convention requirements
1736 according to systems. Suppose you needed to use @code{Stdcall} on
1737 windows systems, and @code{C} on some other system, then you could
1738 define a convention identifier @code{Library} and use a single
1739 @code{Convention_Identifier} pragma to specify which convention
1740 would be used system-wide.
1741
1742 @node Pragma CPP_Class
1743 @unnumberedsec Pragma CPP_Class
1744 @findex CPP_Class
1745 @cindex Interfacing with C++
1746 @noindent
1747 Syntax:
1748
1749 @smallexample @c ada
1750 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1751 @end smallexample
1752
1753 @noindent
1754 The argument denotes an entity in the current declarative region that is
1755 declared as a record type. It indicates that the type corresponds to an
1756 externally declared C++ class type, and is to be laid out the same way
1757 that C++ would lay out the type. If the C++ class has virtual primitives
1758 then the record must be declared as a tagged record type.
1759
1760 Types for which @code{CPP_Class} is specified do not have assignment or
1761 equality operators defined (such operations can be imported or declared
1762 as subprograms as required). Initialization is allowed only by constructor
1763 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1764 limited if not explicitly declared as limited or derived from a limited
1765 type, and an error is issued in that case.
1766
1767 Pragma @code{CPP_Class} is intended primarily for automatic generation
1768 using an automatic binding generator tool.
1769 See @ref{Interfacing to C++} for related information.
1770
1771 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1772 for backward compatibility but its functionality is available
1773 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1774
1775 @node Pragma CPP_Constructor
1776 @unnumberedsec Pragma CPP_Constructor
1777 @cindex Interfacing with C++
1778 @findex CPP_Constructor
1779 @noindent
1780 Syntax:
1781
1782 @smallexample @c ada
1783 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1784 [, [External_Name =>] static_string_EXPRESSION ]
1785 [, [Link_Name =>] static_string_EXPRESSION ]);
1786 @end smallexample
1787
1788 @noindent
1789 This pragma identifies an imported function (imported in the usual way
1790 with pragma @code{Import}) as corresponding to a C++ constructor. If
1791 @code{External_Name} and @code{Link_Name} are not specified then the
1792 @code{Entity} argument is a name that must have been previously mentioned
1793 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1794 must be of one of the following forms:
1795
1796 @itemize @bullet
1797 @item
1798 @code{function @var{Fname} return @var{T}}
1799
1800 @itemize @bullet
1801 @item
1802 @code{function @var{Fname} return @var{T}'Class}
1803
1804 @item
1805 @code{function @var{Fname} (@dots{}) return @var{T}}
1806 @end itemize
1807
1808 @item
1809 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1810 @end itemize
1811
1812 @noindent
1813 where @var{T} is a limited record type imported from C++ with pragma
1814 @code{Import} and @code{Convention} = @code{CPP}.
1815
1816 The first two forms import the default constructor, used when an object
1817 of type @var{T} is created on the Ada side with no explicit constructor.
1818 The latter two forms cover all the non-default constructors of the type.
1819 See the GNAT users guide for details.
1820
1821 If no constructors are imported, it is impossible to create any objects
1822 on the Ada side and the type is implicitly declared abstract.
1823
1824 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1825 using an automatic binding generator tool.
1826 See @ref{Interfacing to C++} for more related information.
1827
1828 Note: The use of functions returning class-wide types for constructors is
1829 currently obsolete. They are supported for backward compatibility. The
1830 use of functions returning the type T leave the Ada sources more clear
1831 because the imported C++ constructors always return an object of type T;
1832 that is, they never return an object whose type is a descendant of type T.
1833
1834 @node Pragma CPP_Virtual
1835 @unnumberedsec Pragma CPP_Virtual
1836 @cindex Interfacing to C++
1837 @findex CPP_Virtual
1838 @noindent
1839 This pragma is now obsolete has has no effect because GNAT generates
1840 the same object layout than the G++ compiler.
1841
1842 See @ref{Interfacing to C++} for related information.
1843
1844 @node Pragma CPP_Vtable
1845 @unnumberedsec Pragma CPP_Vtable
1846 @cindex Interfacing with C++
1847 @findex CPP_Vtable
1848 @noindent
1849 This pragma is now obsolete has has no effect because GNAT generates
1850 the same object layout than the G++ compiler.
1851
1852 See @ref{Interfacing to C++} for related information.
1853
1854 @node Pragma Debug
1855 @unnumberedsec Pragma Debug
1856 @findex Debug
1857 @noindent
1858 Syntax:
1859
1860 @smallexample @c ada
1861 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1862
1863 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1864 PROCEDURE_NAME
1865 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1866 @end smallexample
1867
1868 @noindent
1869 The procedure call argument has the syntactic form of an expression, meeting
1870 the syntactic requirements for pragmas.
1871
1872 If debug pragmas are not enabled or if the condition is present and evaluates
1873 to False, this pragma has no effect. If debug pragmas are enabled, the
1874 semantics of the pragma is exactly equivalent to the procedure call statement
1875 corresponding to the argument with a terminating semicolon. Pragmas are
1876 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1877 intersperse calls to debug procedures in the middle of declarations. Debug
1878 pragmas can be enabled either by use of the command line switch @option{-gnata}
1879 or by use of the configuration pragma @code{Debug_Policy}.
1880
1881 @node Pragma Debug_Policy
1882 @unnumberedsec Pragma Debug_Policy
1883 @findex Debug_Policy
1884 @noindent
1885 Syntax:
1886
1887 @smallexample @c ada
1888 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1889 @end smallexample
1890
1891 @noindent
1892 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1893 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1894 This pragma overrides the effect of the @option{-gnata} switch on the
1895 command line.
1896
1897 The implementation defined policy @code{DISABLE} is like
1898 @code{IGNORE} except that it completely disables semantic
1899 checking of the argument to @code{pragma Debug}. This may
1900 be useful when the pragma argument references subprograms
1901 in a with'ed package which is replaced by a dummy package
1902 for the final build.
1903
1904 @node Pragma Detect_Blocking
1905 @unnumberedsec Pragma Detect_Blocking
1906 @findex Detect_Blocking
1907 @noindent
1908 Syntax:
1909
1910 @smallexample @c ada
1911 pragma Detect_Blocking;
1912 @end smallexample
1913
1914 @noindent
1915 This is a configuration pragma that forces the detection of potentially
1916 blocking operations within a protected operation, and to raise Program_Error
1917 if that happens.
1918
1919 @node Pragma Elaboration_Checks
1920 @unnumberedsec Pragma Elaboration_Checks
1921 @cindex Elaboration control
1922 @findex Elaboration_Checks
1923 @noindent
1924 Syntax:
1925
1926 @smallexample @c ada
1927 pragma Elaboration_Checks (Dynamic | Static);
1928 @end smallexample
1929
1930 @noindent
1931 This is a configuration pragma that provides control over the
1932 elaboration model used by the compilation affected by the
1933 pragma. If the parameter is @code{Dynamic},
1934 then the dynamic elaboration
1935 model described in the Ada Reference Manual is used, as though
1936 the @option{-gnatE} switch had been specified on the command
1937 line. If the parameter is @code{Static}, then the default GNAT static
1938 model is used. This configuration pragma overrides the setting
1939 of the command line. For full details on the elaboration models
1940 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1941 gnat_ugn, @value{EDITION} User's Guide}.
1942
1943 @node Pragma Eliminate
1944 @unnumberedsec Pragma Eliminate
1945 @cindex Elimination of unused subprograms
1946 @findex Eliminate
1947 @noindent
1948 Syntax:
1949
1950 @smallexample @c ada
1951 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
1952 [Source_Location =>] STRING_LITERAL);
1953 @end smallexample
1954
1955 @noindent
1956 The string literal given for the source location is a string which
1957 specifies the line number of the occurrence of the entity, using
1958 the syntax for SOURCE_TRACE given below:
1959
1960 @smallexample @c ada
1961 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1962
1963 LBRACKET ::= [
1964 RBRACKET ::= ]
1965
1966 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1967
1968 LINE_NUMBER ::= DIGIT @{DIGIT@}
1969 @end smallexample
1970
1971 @noindent
1972 Spaces around the colon in a @code{Source_Reference} are optional.
1973
1974 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1975 explicit subprogram declaration, where the @code{entity} name in this
1976 designator appears on the source line specified by the source location.
1977
1978 The source trace that is given as the @code{Source_Location} shall obey the
1979 following rules. The @code{FILE_NAME} is the short name (with no directory
1980 information) of an Ada source file, given using exactly the required syntax
1981 for the underlying file system (e.g. case is important if the underlying
1982 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1983 number of the occurrence of the @code{entity}
1984 as a decimal literal without an exponent or point. If an @code{entity} is not
1985 declared in a generic instantiation (this includes generic subprogram
1986 instances), the source trace includes only one source reference. If an entity
1987 is declared inside a generic instantiation, its source trace (when parsing
1988 from left to right) starts with the source location of the declaration of the
1989 entity in the generic unit and ends with the source location of the
1990 instantiation (it is given in square brackets). This approach is recursively
1991 used in case of nested instantiations: the rightmost (nested most deeply in
1992 square brackets) element of the source trace is the location of the outermost
1993 instantiation, the next to left element is the location of the next (first
1994 nested) instantiation in the code of the corresponding generic unit, and so
1995 on, and the leftmost element (that is out of any square brackets) is the
1996 location of the declaration of the entity to eliminate in a generic unit.
1997
1998 Note that the @code{Source_Location} argument specifies which of a set of
1999 similarly named entities is being eliminated, dealing both with overloading,
2000 and also appearence of the same entity name in different scopes.
2001
2002 This pragma indicates that the given entity is not used in the program to be
2003 compiled and built. The effect of the pragma is to allow the compiler to
2004 eliminate the code or data associated with the named entity. Any reference to
2005 an eliminated entity causes a compile-time or link-time error.
2006
2007 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2008 in a system-independent manner, with unused entities eliminated, without
2009 needing to modify the source text. Normally the required set of
2010 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2011
2012 Any source file change that removes, splits, or
2013 adds lines may make the set of Eliminate pragmas invalid because their
2014 @code{Source_Location} argument values may get out of date.
2015
2016 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2017 operation. In this case all the subprograms to which the given operation can
2018 dispatch are considered to be unused (are never called as a result of a direct
2019 or a dispatching call).
2020
2021 @node Pragma Export_Exception
2022 @unnumberedsec Pragma Export_Exception
2023 @cindex OpenVMS
2024 @findex Export_Exception
2025 @noindent
2026 Syntax:
2027
2028 @smallexample @c ada
2029 pragma Export_Exception (
2030 [Internal =>] LOCAL_NAME
2031 [, [External =>] EXTERNAL_SYMBOL]
2032 [, [Form =>] Ada | VMS]
2033 [, [Code =>] static_integer_EXPRESSION]);
2034
2035 EXTERNAL_SYMBOL ::=
2036 IDENTIFIER
2037 | static_string_EXPRESSION
2038 @end smallexample
2039
2040 @noindent
2041 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2042 causes the specified exception to be propagated outside of the Ada program,
2043 so that it can be handled by programs written in other OpenVMS languages.
2044 This pragma establishes an external name for an Ada exception and makes the
2045 name available to the OpenVMS Linker as a global symbol. For further details
2046 on this pragma, see the
2047 DEC Ada Language Reference Manual, section 13.9a3.2.
2048
2049 @node Pragma Export_Function
2050 @unnumberedsec Pragma Export_Function
2051 @cindex Argument passing mechanisms
2052 @findex Export_Function
2053
2054 @noindent
2055 Syntax:
2056
2057 @smallexample @c ada
2058 pragma Export_Function (
2059 [Internal =>] LOCAL_NAME
2060 [, [External =>] EXTERNAL_SYMBOL]
2061 [, [Parameter_Types =>] PARAMETER_TYPES]
2062 [, [Result_Type =>] result_SUBTYPE_MARK]
2063 [, [Mechanism =>] MECHANISM]
2064 [, [Result_Mechanism =>] MECHANISM_NAME]);
2065
2066 EXTERNAL_SYMBOL ::=
2067 IDENTIFIER
2068 | static_string_EXPRESSION
2069 | ""
2070
2071 PARAMETER_TYPES ::=
2072 null
2073 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2074
2075 TYPE_DESIGNATOR ::=
2076 subtype_NAME
2077 | subtype_Name ' Access
2078
2079 MECHANISM ::=
2080 MECHANISM_NAME
2081 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2082
2083 MECHANISM_ASSOCIATION ::=
2084 [formal_parameter_NAME =>] MECHANISM_NAME
2085
2086 MECHANISM_NAME ::=
2087 Value
2088 | Reference
2089 | Descriptor [([Class =>] CLASS_NAME)]
2090 | Short_Descriptor [([Class =>] CLASS_NAME)]
2091
2092 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2093 @end smallexample
2094
2095 @noindent
2096 Use this pragma to make a function externally callable and optionally
2097 provide information on mechanisms to be used for passing parameter and
2098 result values. We recommend, for the purposes of improving portability,
2099 this pragma always be used in conjunction with a separate pragma
2100 @code{Export}, which must precede the pragma @code{Export_Function}.
2101 GNAT does not require a separate pragma @code{Export}, but if none is
2102 present, @code{Convention Ada} is assumed, which is usually
2103 not what is wanted, so it is usually appropriate to use this
2104 pragma in conjunction with a @code{Export} or @code{Convention}
2105 pragma that specifies the desired foreign convention.
2106 Pragma @code{Export_Function}
2107 (and @code{Export}, if present) must appear in the same declarative
2108 region as the function to which they apply.
2109
2110 @var{internal_name} must uniquely designate the function to which the
2111 pragma applies. If more than one function name exists of this name in
2112 the declarative part you must use the @code{Parameter_Types} and
2113 @code{Result_Type} parameters is mandatory to achieve the required
2114 unique designation. @var{subtype_mark}s in these parameters must
2115 exactly match the subtypes in the corresponding function specification,
2116 using positional notation to match parameters with subtype marks.
2117 The form with an @code{'Access} attribute can be used to match an
2118 anonymous access parameter.
2119
2120 @cindex OpenVMS
2121 @cindex Passing by descriptor
2122 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2123 The default behavior for Export_Function is to accept either 64bit or
2124 32bit descriptors unless short_descriptor is specified, then only 32bit
2125 descriptors are accepted.
2126
2127 @cindex Suppressing external name
2128 Special treatment is given if the EXTERNAL is an explicit null
2129 string or a static string expressions that evaluates to the null
2130 string. In this case, no external name is generated. This form
2131 still allows the specification of parameter mechanisms.
2132
2133 @node Pragma Export_Object
2134 @unnumberedsec Pragma Export_Object
2135 @findex Export_Object
2136 @noindent
2137 Syntax:
2138
2139 @smallexample @c ada
2140 pragma Export_Object
2141 [Internal =>] LOCAL_NAME
2142 [, [External =>] EXTERNAL_SYMBOL]
2143 [, [Size =>] EXTERNAL_SYMBOL]
2144
2145 EXTERNAL_SYMBOL ::=
2146 IDENTIFIER
2147 | static_string_EXPRESSION
2148 @end smallexample
2149
2150 @noindent
2151 This pragma designates an object as exported, and apart from the
2152 extended rules for external symbols, is identical in effect to the use of
2153 the normal @code{Export} pragma applied to an object. You may use a
2154 separate Export pragma (and you probably should from the point of view
2155 of portability), but it is not required. @var{Size} is syntax checked,
2156 but otherwise ignored by GNAT@.
2157
2158 @node Pragma Export_Procedure
2159 @unnumberedsec Pragma Export_Procedure
2160 @findex Export_Procedure
2161 @noindent
2162 Syntax:
2163
2164 @smallexample @c ada
2165 pragma Export_Procedure (
2166 [Internal =>] LOCAL_NAME
2167 [, [External =>] EXTERNAL_SYMBOL]
2168 [, [Parameter_Types =>] PARAMETER_TYPES]
2169 [, [Mechanism =>] MECHANISM]);
2170
2171 EXTERNAL_SYMBOL ::=
2172 IDENTIFIER
2173 | static_string_EXPRESSION
2174 | ""
2175
2176 PARAMETER_TYPES ::=
2177 null
2178 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2179
2180 TYPE_DESIGNATOR ::=
2181 subtype_NAME
2182 | subtype_Name ' Access
2183
2184 MECHANISM ::=
2185 MECHANISM_NAME
2186 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2187
2188 MECHANISM_ASSOCIATION ::=
2189 [formal_parameter_NAME =>] MECHANISM_NAME
2190
2191 MECHANISM_NAME ::=
2192 Value
2193 | Reference
2194 | Descriptor [([Class =>] CLASS_NAME)]
2195 | Short_Descriptor [([Class =>] CLASS_NAME)]
2196
2197 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2198 @end smallexample
2199
2200 @noindent
2201 This pragma is identical to @code{Export_Function} except that it
2202 applies to a procedure rather than a function and the parameters
2203 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2204 GNAT does not require a separate pragma @code{Export}, but if none is
2205 present, @code{Convention Ada} is assumed, which is usually
2206 not what is wanted, so it is usually appropriate to use this
2207 pragma in conjunction with a @code{Export} or @code{Convention}
2208 pragma that specifies the desired foreign convention.
2209
2210 @cindex OpenVMS
2211 @cindex Passing by descriptor
2212 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2213 The default behavior for Export_Procedure is to accept either 64bit or
2214 32bit descriptors unless short_descriptor is specified, then only 32bit
2215 descriptors are accepted.
2216
2217 @cindex Suppressing external name
2218 Special treatment is given if the EXTERNAL is an explicit null
2219 string or a static string expressions that evaluates to the null
2220 string. In this case, no external name is generated. This form
2221 still allows the specification of parameter mechanisms.
2222
2223 @node Pragma Export_Value
2224 @unnumberedsec Pragma Export_Value
2225 @findex Export_Value
2226 @noindent
2227 Syntax:
2228
2229 @smallexample @c ada
2230 pragma Export_Value (
2231 [Value =>] static_integer_EXPRESSION,
2232 [Link_Name =>] static_string_EXPRESSION);
2233 @end smallexample
2234
2235 @noindent
2236 This pragma serves to export a static integer value for external use.
2237 The first argument specifies the value to be exported. The Link_Name
2238 argument specifies the symbolic name to be associated with the integer
2239 value. This pragma is useful for defining a named static value in Ada
2240 that can be referenced in assembly language units to be linked with
2241 the application. This pragma is currently supported only for the
2242 AAMP target and is ignored for other targets.
2243
2244 @node Pragma Export_Valued_Procedure
2245 @unnumberedsec Pragma Export_Valued_Procedure
2246 @findex Export_Valued_Procedure
2247 @noindent
2248 Syntax:
2249
2250 @smallexample @c ada
2251 pragma Export_Valued_Procedure (
2252 [Internal =>] LOCAL_NAME
2253 [, [External =>] EXTERNAL_SYMBOL]
2254 [, [Parameter_Types =>] PARAMETER_TYPES]
2255 [, [Mechanism =>] MECHANISM]);
2256
2257 EXTERNAL_SYMBOL ::=
2258 IDENTIFIER
2259 | static_string_EXPRESSION
2260 | ""
2261
2262 PARAMETER_TYPES ::=
2263 null
2264 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2265
2266 TYPE_DESIGNATOR ::=
2267 subtype_NAME
2268 | subtype_Name ' Access
2269
2270 MECHANISM ::=
2271 MECHANISM_NAME
2272 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2273
2274 MECHANISM_ASSOCIATION ::=
2275 [formal_parameter_NAME =>] MECHANISM_NAME
2276
2277 MECHANISM_NAME ::=
2278 Value
2279 | Reference
2280 | Descriptor [([Class =>] CLASS_NAME)]
2281 | Short_Descriptor [([Class =>] CLASS_NAME)]
2282
2283 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2284 @end smallexample
2285
2286 @noindent
2287 This pragma is identical to @code{Export_Procedure} except that the
2288 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2289 mode @code{OUT}, and externally the subprogram is treated as a function
2290 with this parameter as the result of the function. GNAT provides for
2291 this capability to allow the use of @code{OUT} and @code{IN OUT}
2292 parameters in interfacing to external functions (which are not permitted
2293 in Ada functions).
2294 GNAT does not require a separate pragma @code{Export}, but if none is
2295 present, @code{Convention Ada} is assumed, which is almost certainly
2296 not what is wanted since the whole point of this pragma is to interface
2297 with foreign language functions, so it is usually appropriate to use this
2298 pragma in conjunction with a @code{Export} or @code{Convention}
2299 pragma that specifies the desired foreign convention.
2300
2301 @cindex OpenVMS
2302 @cindex Passing by descriptor
2303 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2304 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2305 32bit descriptors unless short_descriptor is specified, then only 32bit
2306 descriptors are accepted.
2307
2308 @cindex Suppressing external name
2309 Special treatment is given if the EXTERNAL is an explicit null
2310 string or a static string expressions that evaluates to the null
2311 string. In this case, no external name is generated. This form
2312 still allows the specification of parameter mechanisms.
2313
2314 @node Pragma Extend_System
2315 @unnumberedsec Pragma Extend_System
2316 @cindex @code{system}, extending
2317 @cindex Dec Ada 83
2318 @findex Extend_System
2319 @noindent
2320 Syntax:
2321
2322 @smallexample @c ada
2323 pragma Extend_System ([Name =>] IDENTIFIER);
2324 @end smallexample
2325
2326 @noindent
2327 This pragma is used to provide backwards compatibility with other
2328 implementations that extend the facilities of package @code{System}. In
2329 GNAT, @code{System} contains only the definitions that are present in
2330 the Ada RM@. However, other implementations, notably the DEC Ada 83
2331 implementation, provide many extensions to package @code{System}.
2332
2333 For each such implementation accommodated by this pragma, GNAT provides a
2334 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2335 implementation, which provides the required additional definitions. You
2336 can use this package in two ways. You can @code{with} it in the normal
2337 way and access entities either by selection or using a @code{use}
2338 clause. In this case no special processing is required.
2339
2340 However, if existing code contains references such as
2341 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2342 definitions provided in package @code{System}, you may use this pragma
2343 to extend visibility in @code{System} in a non-standard way that
2344 provides greater compatibility with the existing code. Pragma
2345 @code{Extend_System} is a configuration pragma whose single argument is
2346 the name of the package containing the extended definition
2347 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2348 control of this pragma will be processed using special visibility
2349 processing that looks in package @code{System.Aux_@var{xxx}} where
2350 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2351 package @code{System}, but not found in package @code{System}.
2352
2353 You can use this pragma either to access a predefined @code{System}
2354 extension supplied with the compiler, for example @code{Aux_DEC} or
2355 you can construct your own extension unit following the above
2356 definition. Note that such a package is a child of @code{System}
2357 and thus is considered part of the implementation. To compile
2358 it you will have to use the appropriate switch for compiling
2359 system units.
2360 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2361 for details.
2362
2363 @node Pragma Extensions_Allowed
2364 @unnumberedsec Pragma Extensions_Allowed
2365 @cindex Ada Extensions
2366 @cindex GNAT Extensions
2367 @findex Extensions_Allowed
2368 @noindent
2369 Syntax:
2370
2371 @smallexample @c ada
2372 pragma Extensions_Allowed (On | Off);
2373 @end smallexample
2374
2375 @noindent
2376 This configuration pragma enables or disables the implementation
2377 extension mode (the use of Off as a parameter cancels the effect
2378 of the @option{-gnatX} command switch).
2379
2380 In extension mode, the latest version of the Ada language is
2381 implemented (currently Ada 2012), and in addition a small number
2382 of GNAT specific extensions are recognized as follows:
2383
2384 @table @asis
2385 @item Constrained attribute for generic objects
2386 The @code{Constrained} attribute is permitted for objects of
2387 generic types. The result indicates if the corresponding actual
2388 is constrained.
2389
2390 @end table
2391
2392 @node Pragma External
2393 @unnumberedsec Pragma External
2394 @findex External
2395 @noindent
2396 Syntax:
2397
2398 @smallexample @c ada
2399 pragma External (
2400 [ Convention =>] convention_IDENTIFIER,
2401 [ Entity =>] LOCAL_NAME
2402 [, [External_Name =>] static_string_EXPRESSION ]
2403 [, [Link_Name =>] static_string_EXPRESSION ]);
2404 @end smallexample
2405
2406 @noindent
2407 This pragma is identical in syntax and semantics to pragma
2408 @code{Export} as defined in the Ada Reference Manual. It is
2409 provided for compatibility with some Ada 83 compilers that
2410 used this pragma for exactly the same purposes as pragma
2411 @code{Export} before the latter was standardized.
2412
2413 @node Pragma External_Name_Casing
2414 @unnumberedsec Pragma External_Name_Casing
2415 @cindex Dec Ada 83 casing compatibility
2416 @cindex External Names, casing
2417 @cindex Casing of External names
2418 @findex External_Name_Casing
2419 @noindent
2420 Syntax:
2421
2422 @smallexample @c ada
2423 pragma External_Name_Casing (
2424 Uppercase | Lowercase
2425 [, Uppercase | Lowercase | As_Is]);
2426 @end smallexample
2427
2428 @noindent
2429 This pragma provides control over the casing of external names associated
2430 with Import and Export pragmas. There are two cases to consider:
2431
2432 @table @asis
2433 @item Implicit external names
2434 Implicit external names are derived from identifiers. The most common case
2435 arises when a standard Ada Import or Export pragma is used with only two
2436 arguments, as in:
2437
2438 @smallexample @c ada
2439 pragma Import (C, C_Routine);
2440 @end smallexample
2441
2442 @noindent
2443 Since Ada is a case-insensitive language, the spelling of the identifier in
2444 the Ada source program does not provide any information on the desired
2445 casing of the external name, and so a convention is needed. In GNAT the
2446 default treatment is that such names are converted to all lower case
2447 letters. This corresponds to the normal C style in many environments.
2448 The first argument of pragma @code{External_Name_Casing} can be used to
2449 control this treatment. If @code{Uppercase} is specified, then the name
2450 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2451 then the normal default of all lower case letters will be used.
2452
2453 This same implicit treatment is also used in the case of extended DEC Ada 83
2454 compatible Import and Export pragmas where an external name is explicitly
2455 specified using an identifier rather than a string.
2456
2457 @item Explicit external names
2458 Explicit external names are given as string literals. The most common case
2459 arises when a standard Ada Import or Export pragma is used with three
2460 arguments, as in:
2461
2462 @smallexample @c ada
2463 pragma Import (C, C_Routine, "C_routine");
2464 @end smallexample
2465
2466 @noindent
2467 In this case, the string literal normally provides the exact casing required
2468 for the external name. The second argument of pragma
2469 @code{External_Name_Casing} may be used to modify this behavior.
2470 If @code{Uppercase} is specified, then the name
2471 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2472 then the name will be forced to all lowercase letters. A specification of
2473 @code{As_Is} provides the normal default behavior in which the casing is
2474 taken from the string provided.
2475 @end table
2476
2477 @noindent
2478 This pragma may appear anywhere that a pragma is valid. In particular, it
2479 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2480 case it applies to all subsequent compilations, or it can be used as a program
2481 unit pragma, in which case it only applies to the current unit, or it can
2482 be used more locally to control individual Import/Export pragmas.
2483
2484 It is primarily intended for use with OpenVMS systems, where many
2485 compilers convert all symbols to upper case by default. For interfacing to
2486 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2487 the pragma:
2488
2489 @smallexample @c ada
2490 pragma External_Name_Casing (Uppercase, Uppercase);
2491 @end smallexample
2492
2493 @noindent
2494 to enforce the upper casing of all external symbols.
2495
2496 @node Pragma Fast_Math
2497 @unnumberedsec Pragma Fast_Math
2498 @findex Fast_Math
2499 @noindent
2500 Syntax:
2501
2502 @smallexample @c ada
2503 pragma Fast_Math;
2504 @end smallexample
2505
2506 @noindent
2507 This is a configuration pragma which activates a mode in which speed is
2508 considered more important for floating-point operations than absolutely
2509 accurate adherence to the requirements of the standard. Currently the
2510 following operations are affected:
2511
2512 @table @asis
2513 @item Complex Multiplication
2514 The normal simple formula for complex multiplication can result in intermediate
2515 overflows for numbers near the end of the range. The Ada standard requires that
2516 this situation be detected and corrected by scaling, but in Fast_Math mode such
2517 cases will simply result in overflow. Note that to take advantage of this you
2518 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2519 under control of the pragma, rather than use the preinstantiated versions.
2520 @end table
2521
2522 @node Pragma Favor_Top_Level
2523 @unnumberedsec Pragma Favor_Top_Level
2524 @findex Favor_Top_Level
2525 @noindent
2526 Syntax:
2527
2528 @smallexample @c ada
2529 pragma Favor_Top_Level (type_NAME);
2530 @end smallexample
2531
2532 @noindent
2533 The named type must be an access-to-subprogram type. This pragma is an
2534 efficiency hint to the compiler, regarding the use of 'Access or
2535 'Unrestricted_Access on nested (non-library-level) subprograms. The
2536 pragma means that nested subprograms are not used with this type, or
2537 are rare, so that the generated code should be efficient in the
2538 top-level case. When this pragma is used, dynamically generated
2539 trampolines may be used on some targets for nested subprograms.
2540 See also the No_Implicit_Dynamic_Code restriction.
2541
2542 @node Pragma Finalize_Storage_Only
2543 @unnumberedsec Pragma Finalize_Storage_Only
2544 @findex Finalize_Storage_Only
2545 @noindent
2546 Syntax:
2547
2548 @smallexample @c ada
2549 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2550 @end smallexample
2551
2552 @noindent
2553 This pragma allows the compiler not to emit a Finalize call for objects
2554 defined at the library level. This is mostly useful for types where
2555 finalization is only used to deal with storage reclamation since in most
2556 environments it is not necessary to reclaim memory just before terminating
2557 execution, hence the name.
2558
2559 @node Pragma Float_Representation
2560 @unnumberedsec Pragma Float_Representation
2561 @cindex OpenVMS
2562 @findex Float_Representation
2563 @noindent
2564 Syntax:
2565
2566 @smallexample @c ada
2567 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2568
2569 FLOAT_REP ::= VAX_Float | IEEE_Float
2570 @end smallexample
2571
2572 @noindent
2573 In the one argument form, this pragma is a configuration pragma which
2574 allows control over the internal representation chosen for the predefined
2575 floating point types declared in the packages @code{Standard} and
2576 @code{System}. On all systems other than OpenVMS, the argument must
2577 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2578 argument may be @code{VAX_Float} to specify the use of the VAX float
2579 format for the floating-point types in Standard. This requires that
2580 the standard runtime libraries be recompiled.
2581
2582 The two argument form specifies the representation to be used for
2583 the specified floating-point type. On all systems other than OpenVMS,
2584 the argument must
2585 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2586 argument may be @code{VAX_Float} to specify the use of the VAX float
2587 format, as follows:
2588
2589 @itemize @bullet
2590 @item
2591 For digits values up to 6, F float format will be used.
2592 @item
2593 For digits values from 7 to 9, D float format will be used.
2594 @item
2595 For digits values from 10 to 15, G float format will be used.
2596 @item
2597 Digits values above 15 are not allowed.
2598 @end itemize
2599
2600 @node Pragma Ident
2601 @unnumberedsec Pragma Ident
2602 @findex Ident
2603 @noindent
2604 Syntax:
2605
2606 @smallexample @c ada
2607 pragma Ident (static_string_EXPRESSION);
2608 @end smallexample
2609
2610 @noindent
2611 This pragma provides a string identification in the generated object file,
2612 if the system supports the concept of this kind of identification string.
2613 This pragma is allowed only in the outermost declarative part or
2614 declarative items of a compilation unit. If more than one @code{Ident}
2615 pragma is given, only the last one processed is effective.
2616 @cindex OpenVMS
2617 On OpenVMS systems, the effect of the pragma is identical to the effect of
2618 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2619 maximum allowed length is 31 characters, so if it is important to
2620 maintain compatibility with this compiler, you should obey this length
2621 limit.
2622
2623 @node Pragma Implemented
2624 @unnumberedsec Pragma Implemented
2625 @findex Implemented
2626 @noindent
2627 Syntax:
2628
2629 @smallexample @c ada
2630 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2631
2632 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2633 @end smallexample
2634
2635 @noindent
2636 This is an Ada 2012 representation pragma which applies to protected, task
2637 and synchronized interface primitives. The use of pragma Implemented provides
2638 a way to impose a static requirement on the overriding operation by adhering
2639 to one of the three implementation kids: entry, protected procedure or any of
2640 the above.
2641
2642 @smallexample @c ada
2643 type Synch_Iface is synchronized interface;
2644 procedure Prim_Op (Obj : in out Iface) is abstract;
2645 pragma Implemented (Prim_Op, By_Protected_Procedure);
2646
2647 protected type Prot_1 is new Synch_Iface with
2648 procedure Prim_Op; -- Legal
2649 end Prot_1;
2650
2651 protected type Prot_2 is new Synch_Iface with
2652 entry Prim_Op; -- Illegal
2653 end Prot_2;
2654
2655 task type Task_Typ is new Synch_Iface with
2656 entry Prim_Op; -- Illegal
2657 end Task_Typ;
2658 @end smallexample
2659
2660 @noindent
2661 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2662 Implemented determines the runtime behavior of the requeue. Implementation kind
2663 By_Entry guarantees that the action of requeueing will proceed from an entry to
2664 another entry. Implementation kind By_Protected_Procedure transforms the
2665 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2666 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2667 the target's overriding subprogram kind.
2668
2669 @node Pragma Implicit_Packing
2670 @unnumberedsec Pragma Implicit_Packing
2671 @findex Implicit_Packing
2672 @noindent
2673 Syntax:
2674
2675 @smallexample @c ada
2676 pragma Implicit_Packing;
2677 @end smallexample
2678
2679 @noindent
2680 This is a configuration pragma that requests implicit packing for packed
2681 arrays for which a size clause is given but no explicit pragma Pack or
2682 specification of Component_Size is present. It also applies to records
2683 where no record representation clause is present. Consider this example:
2684
2685 @smallexample @c ada
2686 type R is array (0 .. 7) of Boolean;
2687 for R'Size use 8;
2688 @end smallexample
2689
2690 @noindent
2691 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2692 does not change the layout of a composite object. So the Size clause in the
2693 above example is normally rejected, since the default layout of the array uses
2694 8-bit components, and thus the array requires a minimum of 64 bits.
2695
2696 If this declaration is compiled in a region of code covered by an occurrence
2697 of the configuration pragma Implicit_Packing, then the Size clause in this
2698 and similar examples will cause implicit packing and thus be accepted. For
2699 this implicit packing to occur, the type in question must be an array of small
2700 components whose size is known at compile time, and the Size clause must
2701 specify the exact size that corresponds to the length of the array multiplied
2702 by the size in bits of the component type.
2703 @cindex Array packing
2704
2705 Similarly, the following example shows the use in the record case
2706
2707 @smallexample @c ada
2708 type r is record
2709 a, b, c, d, e, f, g, h : boolean;
2710 chr : character;
2711 end record;
2712 for r'size use 16;
2713 @end smallexample
2714
2715 @noindent
2716 Without a pragma Pack, each Boolean field requires 8 bits, so the
2717 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2718 sufficient. The use of pragma Implicit_Packing allows this record
2719 declaration to compile without an explicit pragma Pack.
2720 @node Pragma Import_Exception
2721 @unnumberedsec Pragma Import_Exception
2722 @cindex OpenVMS
2723 @findex Import_Exception
2724 @noindent
2725 Syntax:
2726
2727 @smallexample @c ada
2728 pragma Import_Exception (
2729 [Internal =>] LOCAL_NAME
2730 [, [External =>] EXTERNAL_SYMBOL]
2731 [, [Form =>] Ada | VMS]
2732 [, [Code =>] static_integer_EXPRESSION]);
2733
2734 EXTERNAL_SYMBOL ::=
2735 IDENTIFIER
2736 | static_string_EXPRESSION
2737 @end smallexample
2738
2739 @noindent
2740 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2741 It allows OpenVMS conditions (for example, from OpenVMS system services or
2742 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2743 The pragma specifies that the exception associated with an exception
2744 declaration in an Ada program be defined externally (in non-Ada code).
2745 For further details on this pragma, see the
2746 DEC Ada Language Reference Manual, section 13.9a.3.1.
2747
2748 @node Pragma Import_Function
2749 @unnumberedsec Pragma Import_Function
2750 @findex Import_Function
2751 @noindent
2752 Syntax:
2753
2754 @smallexample @c ada
2755 pragma Import_Function (
2756 [Internal =>] LOCAL_NAME,
2757 [, [External =>] EXTERNAL_SYMBOL]
2758 [, [Parameter_Types =>] PARAMETER_TYPES]
2759 [, [Result_Type =>] SUBTYPE_MARK]
2760 [, [Mechanism =>] MECHANISM]
2761 [, [Result_Mechanism =>] MECHANISM_NAME]
2762 [, [First_Optional_Parameter =>] IDENTIFIER]);
2763
2764 EXTERNAL_SYMBOL ::=
2765 IDENTIFIER
2766 | static_string_EXPRESSION
2767
2768 PARAMETER_TYPES ::=
2769 null
2770 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2771
2772 TYPE_DESIGNATOR ::=
2773 subtype_NAME
2774 | subtype_Name ' Access
2775
2776 MECHANISM ::=
2777 MECHANISM_NAME
2778 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2779
2780 MECHANISM_ASSOCIATION ::=
2781 [formal_parameter_NAME =>] MECHANISM_NAME
2782
2783 MECHANISM_NAME ::=
2784 Value
2785 | Reference
2786 | Descriptor [([Class =>] CLASS_NAME)]
2787 | Short_Descriptor [([Class =>] CLASS_NAME)]
2788
2789 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2790 @end smallexample
2791
2792 @noindent
2793 This pragma is used in conjunction with a pragma @code{Import} to
2794 specify additional information for an imported function. The pragma
2795 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2796 @code{Import_Function} pragma and both must appear in the same
2797 declarative part as the function specification.
2798
2799 The @var{Internal} argument must uniquely designate
2800 the function to which the
2801 pragma applies. If more than one function name exists of this name in
2802 the declarative part you must use the @code{Parameter_Types} and
2803 @var{Result_Type} parameters to achieve the required unique
2804 designation. Subtype marks in these parameters must exactly match the
2805 subtypes in the corresponding function specification, using positional
2806 notation to match parameters with subtype marks.
2807 The form with an @code{'Access} attribute can be used to match an
2808 anonymous access parameter.
2809
2810 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2811 parameters to specify passing mechanisms for the
2812 parameters and result. If you specify a single mechanism name, it
2813 applies to all parameters. Otherwise you may specify a mechanism on a
2814 parameter by parameter basis using either positional or named
2815 notation. If the mechanism is not specified, the default mechanism
2816 is used.
2817
2818 @cindex OpenVMS
2819 @cindex Passing by descriptor
2820 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2821 The default behavior for Import_Function is to pass a 64bit descriptor
2822 unless short_descriptor is specified, then a 32bit descriptor is passed.
2823
2824 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2825 It specifies that the designated parameter and all following parameters
2826 are optional, meaning that they are not passed at the generated code
2827 level (this is distinct from the notion of optional parameters in Ada
2828 where the parameters are passed anyway with the designated optional
2829 parameters). All optional parameters must be of mode @code{IN} and have
2830 default parameter values that are either known at compile time
2831 expressions, or uses of the @code{'Null_Parameter} attribute.
2832
2833 @node Pragma Import_Object
2834 @unnumberedsec Pragma Import_Object
2835 @findex Import_Object
2836 @noindent
2837 Syntax:
2838
2839 @smallexample @c ada
2840 pragma Import_Object
2841 [Internal =>] LOCAL_NAME
2842 [, [External =>] EXTERNAL_SYMBOL]
2843 [, [Size =>] EXTERNAL_SYMBOL]);
2844
2845 EXTERNAL_SYMBOL ::=
2846 IDENTIFIER
2847 | static_string_EXPRESSION
2848 @end smallexample
2849
2850 @noindent
2851 This pragma designates an object as imported, and apart from the
2852 extended rules for external symbols, is identical in effect to the use of
2853 the normal @code{Import} pragma applied to an object. Unlike the
2854 subprogram case, you need not use a separate @code{Import} pragma,
2855 although you may do so (and probably should do so from a portability
2856 point of view). @var{size} is syntax checked, but otherwise ignored by
2857 GNAT@.
2858
2859 @node Pragma Import_Procedure
2860 @unnumberedsec Pragma Import_Procedure
2861 @findex Import_Procedure
2862 @noindent
2863 Syntax:
2864
2865 @smallexample @c ada
2866 pragma Import_Procedure (
2867 [Internal =>] LOCAL_NAME
2868 [, [External =>] EXTERNAL_SYMBOL]
2869 [, [Parameter_Types =>] PARAMETER_TYPES]
2870 [, [Mechanism =>] MECHANISM]
2871 [, [First_Optional_Parameter =>] IDENTIFIER]);
2872
2873 EXTERNAL_SYMBOL ::=
2874 IDENTIFIER
2875 | static_string_EXPRESSION
2876
2877 PARAMETER_TYPES ::=
2878 null
2879 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2880
2881 TYPE_DESIGNATOR ::=
2882 subtype_NAME
2883 | subtype_Name ' Access
2884
2885 MECHANISM ::=
2886 MECHANISM_NAME
2887 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2888
2889 MECHANISM_ASSOCIATION ::=
2890 [formal_parameter_NAME =>] MECHANISM_NAME
2891
2892 MECHANISM_NAME ::=
2893 Value
2894 | Reference
2895 | Descriptor [([Class =>] CLASS_NAME)]
2896 | Short_Descriptor [([Class =>] CLASS_NAME)]
2897
2898 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2899 @end smallexample
2900
2901 @noindent
2902 This pragma is identical to @code{Import_Function} except that it
2903 applies to a procedure rather than a function and the parameters
2904 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2905
2906 @node Pragma Import_Valued_Procedure
2907 @unnumberedsec Pragma Import_Valued_Procedure
2908 @findex Import_Valued_Procedure
2909 @noindent
2910 Syntax:
2911
2912 @smallexample @c ada
2913 pragma Import_Valued_Procedure (
2914 [Internal =>] LOCAL_NAME
2915 [, [External =>] EXTERNAL_SYMBOL]
2916 [, [Parameter_Types =>] PARAMETER_TYPES]
2917 [, [Mechanism =>] MECHANISM]
2918 [, [First_Optional_Parameter =>] IDENTIFIER]);
2919
2920 EXTERNAL_SYMBOL ::=
2921 IDENTIFIER
2922 | static_string_EXPRESSION
2923
2924 PARAMETER_TYPES ::=
2925 null
2926 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2927
2928 TYPE_DESIGNATOR ::=
2929 subtype_NAME
2930 | subtype_Name ' Access
2931
2932 MECHANISM ::=
2933 MECHANISM_NAME
2934 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2935
2936 MECHANISM_ASSOCIATION ::=
2937 [formal_parameter_NAME =>] MECHANISM_NAME
2938
2939 MECHANISM_NAME ::=
2940 Value
2941 | Reference
2942 | Descriptor [([Class =>] CLASS_NAME)]
2943 | Short_Descriptor [([Class =>] CLASS_NAME)]
2944
2945 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2946 @end smallexample
2947
2948 @noindent
2949 This pragma is identical to @code{Import_Procedure} except that the
2950 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2951 mode @code{OUT}, and externally the subprogram is treated as a function
2952 with this parameter as the result of the function. The purpose of this
2953 capability is to allow the use of @code{OUT} and @code{IN OUT}
2954 parameters in interfacing to external functions (which are not permitted
2955 in Ada functions). You may optionally use the @code{Mechanism}
2956 parameters to specify passing mechanisms for the parameters.
2957 If you specify a single mechanism name, it applies to all parameters.
2958 Otherwise you may specify a mechanism on a parameter by parameter
2959 basis using either positional or named notation. If the mechanism is not
2960 specified, the default mechanism is used.
2961
2962 Note that it is important to use this pragma in conjunction with a separate
2963 pragma Import that specifies the desired convention, since otherwise the
2964 default convention is Ada, which is almost certainly not what is required.
2965
2966 @node Pragma Initialize_Scalars
2967 @unnumberedsec Pragma Initialize_Scalars
2968 @findex Initialize_Scalars
2969 @cindex debugging with Initialize_Scalars
2970 @noindent
2971 Syntax:
2972
2973 @smallexample @c ada
2974 pragma Initialize_Scalars;
2975 @end smallexample
2976
2977 @noindent
2978 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2979 two important differences. First, there is no requirement for the pragma
2980 to be used uniformly in all units of a partition, in particular, it is fine
2981 to use this just for some or all of the application units of a partition,
2982 without needing to recompile the run-time library.
2983
2984 In the case where some units are compiled with the pragma, and some without,
2985 then a declaration of a variable where the type is defined in package
2986 Standard or is locally declared will always be subject to initialization,
2987 as will any declaration of a scalar variable. For composite variables,
2988 whether the variable is initialized may also depend on whether the package
2989 in which the type of the variable is declared is compiled with the pragma.
2990
2991 The other important difference is that you can control the value used
2992 for initializing scalar objects. At bind time, you can select several
2993 options for initialization. You can
2994 initialize with invalid values (similar to Normalize_Scalars, though for
2995 Initialize_Scalars it is not always possible to determine the invalid
2996 values in complex cases like signed component fields with non-standard
2997 sizes). You can also initialize with high or
2998 low values, or with a specified bit pattern. See the users guide for binder
2999 options for specifying these cases.
3000
3001 This means that you can compile a program, and then without having to
3002 recompile the program, you can run it with different values being used
3003 for initializing otherwise uninitialized values, to test if your program
3004 behavior depends on the choice. Of course the behavior should not change,
3005 and if it does, then most likely you have an erroneous reference to an
3006 uninitialized value.
3007
3008 It is even possible to change the value at execution time eliminating even
3009 the need to rebind with a different switch using an environment variable.
3010 See the GNAT users guide for details.
3011
3012 Note that pragma @code{Initialize_Scalars} is particularly useful in
3013 conjunction with the enhanced validity checking that is now provided
3014 in GNAT, which checks for invalid values under more conditions.
3015 Using this feature (see description of the @option{-gnatV} flag in the
3016 users guide) in conjunction with pragma @code{Initialize_Scalars}
3017 provides a powerful new tool to assist in the detection of problems
3018 caused by uninitialized variables.
3019
3020 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3021 effect on the generated code. This may cause your code to be
3022 substantially larger. It may also cause an increase in the amount
3023 of stack required, so it is probably a good idea to turn on stack
3024 checking (see description of stack checking in the GNAT users guide)
3025 when using this pragma.
3026
3027 @node Pragma Inline_Always
3028 @unnumberedsec Pragma Inline_Always
3029 @findex Inline_Always
3030 @noindent
3031 Syntax:
3032
3033 @smallexample @c ada
3034 pragma Inline_Always (NAME [, NAME]);
3035 @end smallexample
3036
3037 @noindent
3038 Similar to pragma @code{Inline} except that inlining is not subject to
3039 the use of option @option{-gnatn} and the inlining happens regardless of
3040 whether this option is used.
3041
3042 @node Pragma Inline_Generic
3043 @unnumberedsec Pragma Inline_Generic
3044 @findex Inline_Generic
3045 @noindent
3046 Syntax:
3047
3048 @smallexample @c ada
3049 pragma Inline_Generic (generic_package_NAME);
3050 @end smallexample
3051
3052 @noindent
3053 This is implemented for compatibility with DEC Ada 83 and is recognized,
3054 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3055 by default when using GNAT@.
3056
3057 @node Pragma Interface
3058 @unnumberedsec Pragma Interface
3059 @findex Interface
3060 @noindent
3061 Syntax:
3062
3063 @smallexample @c ada
3064 pragma Interface (
3065 [Convention =>] convention_identifier,
3066 [Entity =>] local_NAME
3067 [, [External_Name =>] static_string_expression]
3068 [, [Link_Name =>] static_string_expression]);
3069 @end smallexample
3070
3071 @noindent
3072 This pragma is identical in syntax and semantics to
3073 the standard Ada pragma @code{Import}. It is provided for compatibility
3074 with Ada 83. The definition is upwards compatible both with pragma
3075 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3076 with some extended implementations of this pragma in certain Ada 83
3077 implementations. The only difference between pragma @code{Interface}
3078 and pragma @code{Import} is that there is special circuitry to allow
3079 both pragmas to appear for the same subprogram entity (normally it
3080 is illegal to have multiple @code{Import} pragmas. This is useful in
3081 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3082 Ada 83 compilers.
3083
3084 @node Pragma Interface_Name
3085 @unnumberedsec Pragma Interface_Name
3086 @findex Interface_Name
3087 @noindent
3088 Syntax:
3089
3090 @smallexample @c ada
3091 pragma Interface_Name (
3092 [Entity =>] LOCAL_NAME
3093 [, [External_Name =>] static_string_EXPRESSION]
3094 [, [Link_Name =>] static_string_EXPRESSION]);
3095 @end smallexample
3096
3097 @noindent
3098 This pragma provides an alternative way of specifying the interface name
3099 for an interfaced subprogram, and is provided for compatibility with Ada
3100 83 compilers that use the pragma for this purpose. You must provide at
3101 least one of @var{External_Name} or @var{Link_Name}.
3102
3103 @node Pragma Interrupt_Handler
3104 @unnumberedsec Pragma Interrupt_Handler
3105 @findex Interrupt_Handler
3106 @noindent
3107 Syntax:
3108
3109 @smallexample @c ada
3110 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3111 @end smallexample
3112
3113 @noindent
3114 This program unit pragma is supported for parameterless protected procedures
3115 as described in Annex C of the Ada Reference Manual. On the AAMP target
3116 the pragma can also be specified for nonprotected parameterless procedures
3117 that are declared at the library level (which includes procedures
3118 declared at the top level of a library package). In the case of AAMP,
3119 when this pragma is applied to a nonprotected procedure, the instruction
3120 @code{IERET} is generated for returns from the procedure, enabling
3121 maskable interrupts, in place of the normal return instruction.
3122
3123 @node Pragma Interrupt_State
3124 @unnumberedsec Pragma Interrupt_State
3125 @findex Interrupt_State
3126 @noindent
3127 Syntax:
3128
3129 @smallexample @c ada
3130 pragma Interrupt_State
3131 ([Name =>] value,
3132 [State =>] SYSTEM | RUNTIME | USER);
3133 @end smallexample
3134
3135 @noindent
3136 Normally certain interrupts are reserved to the implementation. Any attempt
3137 to attach an interrupt causes Program_Error to be raised, as described in
3138 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3139 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3140 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3141 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3142 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3143 Ada exceptions, or used to implement run-time functions such as the
3144 @code{abort} statement and stack overflow checking.
3145
3146 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3147 such uses of interrupts. It subsumes the functionality of pragma
3148 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3149 available on Windows or VMS. On all other platforms than VxWorks,
3150 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3151 and may be used to mark interrupts required by the board support package
3152 as reserved.
3153
3154 Interrupts can be in one of three states:
3155 @itemize @bullet
3156 @item System
3157
3158 The interrupt is reserved (no Ada handler can be installed), and the
3159 Ada run-time may not install a handler. As a result you are guaranteed
3160 standard system default action if this interrupt is raised.
3161
3162 @item Runtime
3163
3164 The interrupt is reserved (no Ada handler can be installed). The run time
3165 is allowed to install a handler for internal control purposes, but is
3166 not required to do so.
3167
3168 @item User
3169
3170 The interrupt is unreserved. The user may install a handler to provide
3171 some other action.
3172 @end itemize
3173
3174 @noindent
3175 These states are the allowed values of the @code{State} parameter of the
3176 pragma. The @code{Name} parameter is a value of the type
3177 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3178 @code{Ada.Interrupts.Names}.
3179
3180 This is a configuration pragma, and the binder will check that there
3181 are no inconsistencies between different units in a partition in how a
3182 given interrupt is specified. It may appear anywhere a pragma is legal.
3183
3184 The effect is to move the interrupt to the specified state.
3185
3186 By declaring interrupts to be SYSTEM, you guarantee the standard system
3187 action, such as a core dump.
3188
3189 By declaring interrupts to be USER, you guarantee that you can install
3190 a handler.
3191
3192 Note that certain signals on many operating systems cannot be caught and
3193 handled by applications. In such cases, the pragma is ignored. See the
3194 operating system documentation, or the value of the array @code{Reserved}
3195 declared in the spec of package @code{System.OS_Interface}.
3196
3197 Overriding the default state of signals used by the Ada runtime may interfere
3198 with an application's runtime behavior in the cases of the synchronous signals,
3199 and in the case of the signal used to implement the @code{abort} statement.
3200
3201 @node Pragma Invariant
3202 @unnumberedsec Pragma Invariant
3203 @findex Invariant
3204 @noindent
3205 Syntax:
3206
3207 @smallexample @c ada
3208 pragma Invariant
3209 ([Entity =>] private_type_LOCAL_NAME,
3210 [Check =>] EXPRESSION
3211 [,[Message =>] String_Expression]);
3212 @end smallexample
3213
3214 @noindent
3215 This pragma provides exactly the same capabilities as the Invariant aspect
3216 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3217 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3218 of the aspect syntax, which is not available exception in 2012 mode, it is
3219 not possible to use the Invariant aspect in earlier versions of Ada. However
3220 the Invariant pragma may be used in any version of Ada.
3221
3222 The pragma must appear within the visible part of the package specification,
3223 after the type to which its Entity argument appears. As with the Invariant
3224 aspect, the Check expression is not analyzed until the end of the visible
3225 part of the package, so it may contain forward references. The Message
3226 argument, if present, provides the exception message used if the invariant
3227 is violated. If no Message parameter is provided, a default message that
3228 identifies the line on which the pragma appears is used.
3229
3230 It is permissible to have multiple Invariants for the same type entity, in
3231 which case they are and'ed together. It is permissible to use this pragma
3232 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3233 invariant pragma for the same entity.
3234
3235 For further details on the use of this pragma, see the Ada 2012 documentation
3236 of the Invariant aspect.
3237
3238 @node Pragma Keep_Names
3239 @unnumberedsec Pragma Keep_Names
3240 @findex Keep_Names
3241 @noindent
3242 Syntax:
3243
3244 @smallexample @c ada
3245 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3246 @end smallexample
3247
3248 @noindent
3249 The @var{LOCAL_NAME} argument
3250 must refer to an enumeration first subtype
3251 in the current declarative part. The effect is to retain the enumeration
3252 literal names for use by @code{Image} and @code{Value} even if a global
3253 @code{Discard_Names} pragma applies. This is useful when you want to
3254 generally suppress enumeration literal names and for example you therefore
3255 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3256 want to retain the names for specific enumeration types.
3257
3258 @node Pragma License
3259 @unnumberedsec Pragma License
3260 @findex License
3261 @cindex License checking
3262 @noindent
3263 Syntax:
3264
3265 @smallexample @c ada
3266 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3267 @end smallexample
3268
3269 @noindent
3270 This pragma is provided to allow automated checking for appropriate license
3271 conditions with respect to the standard and modified GPL@. A pragma
3272 @code{License}, which is a configuration pragma that typically appears at
3273 the start of a source file or in a separate @file{gnat.adc} file, specifies
3274 the licensing conditions of a unit as follows:
3275
3276 @itemize @bullet
3277 @item Unrestricted
3278 This is used for a unit that can be freely used with no license restrictions.
3279 Examples of such units are public domain units, and units from the Ada
3280 Reference Manual.
3281
3282 @item GPL
3283 This is used for a unit that is licensed under the unmodified GPL, and which
3284 therefore cannot be @code{with}'ed by a restricted unit.
3285
3286 @item Modified_GPL
3287 This is used for a unit licensed under the GNAT modified GPL that includes
3288 a special exception paragraph that specifically permits the inclusion of
3289 the unit in programs without requiring the entire program to be released
3290 under the GPL@.
3291
3292 @item Restricted
3293 This is used for a unit that is restricted in that it is not permitted to
3294 depend on units that are licensed under the GPL@. Typical examples are
3295 proprietary code that is to be released under more restrictive license
3296 conditions. Note that restricted units are permitted to @code{with} units
3297 which are licensed under the modified GPL (this is the whole point of the
3298 modified GPL).
3299
3300 @end itemize
3301
3302 @noindent
3303 Normally a unit with no @code{License} pragma is considered to have an
3304 unknown license, and no checking is done. However, standard GNAT headers
3305 are recognized, and license information is derived from them as follows.
3306
3307 @itemize @bullet
3308
3309 A GNAT license header starts with a line containing 78 hyphens. The following
3310 comment text is searched for the appearance of any of the following strings.
3311
3312 If the string ``GNU General Public License'' is found, then the unit is assumed
3313 to have GPL license, unless the string ``As a special exception'' follows, in
3314 which case the license is assumed to be modified GPL@.
3315
3316 If one of the strings
3317 ``This specification is adapted from the Ada Semantic Interface'' or
3318 ``This specification is derived from the Ada Reference Manual'' is found
3319 then the unit is assumed to be unrestricted.
3320 @end itemize
3321
3322 @noindent
3323 These default actions means that a program with a restricted license pragma
3324 will automatically get warnings if a GPL unit is inappropriately
3325 @code{with}'ed. For example, the program:
3326
3327 @smallexample @c ada
3328 with Sem_Ch3;
3329 with GNAT.Sockets;
3330 procedure Secret_Stuff is
3331 @dots{}
3332 end Secret_Stuff
3333 @end smallexample
3334
3335 @noindent
3336 if compiled with pragma @code{License} (@code{Restricted}) in a
3337 @file{gnat.adc} file will generate the warning:
3338
3339 @smallexample
3340 1. with Sem_Ch3;
3341 |
3342 >>> license of withed unit "Sem_Ch3" is incompatible
3343
3344 2. with GNAT.Sockets;
3345 3. procedure Secret_Stuff is
3346 @end smallexample
3347
3348 @noindent
3349 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3350 compiler and is licensed under the
3351 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3352 run time, and is therefore licensed under the modified GPL@.
3353
3354 @node Pragma Link_With
3355 @unnumberedsec Pragma Link_With
3356 @findex Link_With
3357 @noindent
3358 Syntax:
3359
3360 @smallexample @c ada
3361 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3362 @end smallexample
3363
3364 @noindent
3365 This pragma is provided for compatibility with certain Ada 83 compilers.
3366 It has exactly the same effect as pragma @code{Linker_Options} except
3367 that spaces occurring within one of the string expressions are treated
3368 as separators. For example, in the following case:
3369
3370 @smallexample @c ada
3371 pragma Link_With ("-labc -ldef");
3372 @end smallexample
3373
3374 @noindent
3375 results in passing the strings @code{-labc} and @code{-ldef} as two
3376 separate arguments to the linker. In addition pragma Link_With allows
3377 multiple arguments, with the same effect as successive pragmas.
3378
3379 @node Pragma Linker_Alias
3380 @unnumberedsec Pragma Linker_Alias
3381 @findex Linker_Alias
3382 @noindent
3383 Syntax:
3384
3385 @smallexample @c ada
3386 pragma Linker_Alias (
3387 [Entity =>] LOCAL_NAME,
3388 [Target =>] static_string_EXPRESSION);
3389 @end smallexample
3390
3391 @noindent
3392 @var{LOCAL_NAME} must refer to an object that is declared at the library
3393 level. This pragma establishes the given entity as a linker alias for the
3394 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3395 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3396 @var{static_string_EXPRESSION} in the object file, that is to say no space
3397 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3398 to the same address as @var{static_string_EXPRESSION} by the linker.
3399
3400 The actual linker name for the target must be used (e.g.@: the fully
3401 encoded name with qualification in Ada, or the mangled name in C++),
3402 or it must be declared using the C convention with @code{pragma Import}
3403 or @code{pragma Export}.
3404
3405 Not all target machines support this pragma. On some of them it is accepted
3406 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3407
3408 @smallexample @c ada
3409 -- Example of the use of pragma Linker_Alias
3410
3411 package p is
3412 i : Integer := 1;
3413 pragma Export (C, i);
3414
3415 new_name_for_i : Integer;
3416 pragma Linker_Alias (new_name_for_i, "i");
3417 end p;
3418 @end smallexample
3419
3420 @node Pragma Linker_Constructor
3421 @unnumberedsec Pragma Linker_Constructor
3422 @findex Linker_Constructor
3423 @noindent
3424 Syntax:
3425
3426 @smallexample @c ada
3427 pragma Linker_Constructor (procedure_LOCAL_NAME);
3428 @end smallexample
3429
3430 @noindent
3431 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3432 is declared at the library level. A procedure to which this pragma is
3433 applied will be treated as an initialization routine by the linker.
3434 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3435 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3436 of the executable is called (or immediately after the shared library is
3437 loaded if the procedure is linked in a shared library), in particular
3438 before the Ada run-time environment is set up.
3439
3440 Because of these specific contexts, the set of operations such a procedure
3441 can perform is very limited and the type of objects it can manipulate is
3442 essentially restricted to the elementary types. In particular, it must only
3443 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3444
3445 This pragma is used by GNAT to implement auto-initialization of shared Stand
3446 Alone Libraries, which provides a related capability without the restrictions
3447 listed above. Where possible, the use of Stand Alone Libraries is preferable
3448 to the use of this pragma.
3449
3450 @node Pragma Linker_Destructor
3451 @unnumberedsec Pragma Linker_Destructor
3452 @findex Linker_Destructor
3453 @noindent
3454 Syntax:
3455
3456 @smallexample @c ada
3457 pragma Linker_Destructor (procedure_LOCAL_NAME);
3458 @end smallexample
3459
3460 @noindent
3461 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3462 is declared at the library level. A procedure to which this pragma is
3463 applied will be treated as a finalization routine by the linker.
3464 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3465 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3466 of the executable has exited (or immediately before the shared library
3467 is unloaded if the procedure is linked in a shared library), in particular
3468 after the Ada run-time environment is shut down.
3469
3470 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3471 because of these specific contexts.
3472
3473 @node Pragma Linker_Section
3474 @unnumberedsec Pragma Linker_Section
3475 @findex Linker_Section
3476 @noindent
3477 Syntax:
3478
3479 @smallexample @c ada
3480 pragma Linker_Section (
3481 [Entity =>] LOCAL_NAME,
3482 [Section =>] static_string_EXPRESSION);
3483 @end smallexample
3484
3485 @noindent
3486 @var{LOCAL_NAME} must refer to an object that is declared at the library
3487 level. This pragma specifies the name of the linker section for the given
3488 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3489 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3490 section of the executable (assuming the linker doesn't rename the section).
3491
3492 The compiler normally places library-level objects in standard sections
3493 depending on their type: procedures and functions generally go in the
3494 @code{.text} section, initialized variables in the @code{.data} section
3495 and uninitialized variables in the @code{.bss} section.
3496
3497 Other, special sections may exist on given target machines to map special
3498 hardware, for example I/O ports or flash memory. This pragma is a means to
3499 defer the final layout of the executable to the linker, thus fully working
3500 at the symbolic level with the compiler.
3501
3502 Some file formats do not support arbitrary sections so not all target
3503 machines support this pragma. The use of this pragma may cause a program
3504 execution to be erroneous if it is used to place an entity into an
3505 inappropriate section (e.g.@: a modified variable into the @code{.text}
3506 section). See also @code{pragma Persistent_BSS}.
3507
3508 @smallexample @c ada
3509 -- Example of the use of pragma Linker_Section
3510
3511 package IO_Card is
3512 Port_A : Integer;
3513 pragma Volatile (Port_A);
3514 pragma Linker_Section (Port_A, ".bss.port_a");
3515
3516 Port_B : Integer;
3517 pragma Volatile (Port_B);
3518 pragma Linker_Section (Port_B, ".bss.port_b");
3519 end IO_Card;
3520 @end smallexample
3521
3522 @node Pragma Long_Float
3523 @unnumberedsec Pragma Long_Float
3524 @cindex OpenVMS
3525 @findex Long_Float
3526 @noindent
3527 Syntax:
3528
3529 @smallexample @c ada
3530 pragma Long_Float (FLOAT_FORMAT);
3531
3532 FLOAT_FORMAT ::= D_Float | G_Float
3533 @end smallexample
3534
3535 @noindent
3536 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3537 It allows control over the internal representation chosen for the predefined
3538 type @code{Long_Float} and for floating point type representations with
3539 @code{digits} specified in the range 7 through 15.
3540 For further details on this pragma, see the
3541 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3542 this pragma, the standard runtime libraries must be recompiled.
3543
3544 @node Pragma Machine_Attribute
3545 @unnumberedsec Pragma Machine_Attribute
3546 @findex Machine_Attribute
3547 @noindent
3548 Syntax:
3549
3550 @smallexample @c ada
3551 pragma Machine_Attribute (
3552 [Entity =>] LOCAL_NAME,
3553 [Attribute_Name =>] static_string_EXPRESSION
3554 [, [Info =>] static_EXPRESSION] );
3555 @end smallexample
3556
3557 @noindent
3558 Machine-dependent attributes can be specified for types and/or
3559 declarations. This pragma is semantically equivalent to
3560 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3561 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3562 in GNU C, where @code{@var{attribute_name}} is recognized by the
3563 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3564 specific macro. A string literal for the optional parameter @var{info}
3565 is transformed into an identifier, which may make this pragma unusable
3566 for some attributes. @xref{Target Attributes,, Defining target-specific
3567 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3568 Internals}, further information.
3569
3570 @node Pragma Main
3571 @unnumberedsec Pragma Main
3572 @cindex OpenVMS
3573 @findex Main
3574 @noindent
3575 Syntax:
3576
3577 @smallexample @c ada
3578 pragma Main
3579 (MAIN_OPTION [, MAIN_OPTION]);
3580
3581 MAIN_OPTION ::=
3582 [Stack_Size =>] static_integer_EXPRESSION
3583 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3584 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3585 @end smallexample
3586
3587 @noindent
3588 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3589 no effect in GNAT, other than being syntax checked.
3590
3591 @node Pragma Main_Storage
3592 @unnumberedsec Pragma Main_Storage
3593 @cindex OpenVMS
3594 @findex Main_Storage
3595 @noindent
3596 Syntax:
3597
3598 @smallexample @c ada
3599 pragma Main_Storage
3600 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3601
3602 MAIN_STORAGE_OPTION ::=
3603 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3604 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
3605 @end smallexample
3606
3607 @noindent
3608 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3609 no effect in GNAT, other than being syntax checked. Note that the pragma
3610 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3611
3612 @node Pragma No_Body
3613 @unnumberedsec Pragma No_Body
3614 @findex No_Body
3615 @noindent
3616 Syntax:
3617
3618 @smallexample @c ada
3619 pragma No_Body;
3620 @end smallexample
3621
3622 @noindent
3623 There are a number of cases in which a package spec does not require a body,
3624 and in fact a body is not permitted. GNAT will not permit the spec to be
3625 compiled if there is a body around. The pragma No_Body allows you to provide
3626 a body file, even in a case where no body is allowed. The body file must
3627 contain only comments and a single No_Body pragma. This is recognized by
3628 the compiler as indicating that no body is logically present.
3629
3630 This is particularly useful during maintenance when a package is modified in
3631 such a way that a body needed before is no longer needed. The provision of a
3632 dummy body with a No_Body pragma ensures that there is no interference from
3633 earlier versions of the package body.
3634
3635 @node Pragma No_Return
3636 @unnumberedsec Pragma No_Return
3637 @findex No_Return
3638 @noindent
3639 Syntax:
3640
3641 @smallexample @c ada
3642 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3643 @end smallexample
3644
3645 @noindent
3646 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3647 declarations in the current declarative part. A procedure to which this
3648 pragma is applied may not contain any explicit @code{return} statements.
3649 In addition, if the procedure contains any implicit returns from falling
3650 off the end of a statement sequence, then execution of that implicit
3651 return will cause Program_Error to be raised.
3652
3653 One use of this pragma is to identify procedures whose only purpose is to raise
3654 an exception. Another use of this pragma is to suppress incorrect warnings
3655 about missing returns in functions, where the last statement of a function
3656 statement sequence is a call to such a procedure.
3657
3658 Note that in Ada 2005 mode, this pragma is part of the language, and is
3659 identical in effect to the pragma as implemented in Ada 95 mode.
3660
3661 @node Pragma No_Strict_Aliasing
3662 @unnumberedsec Pragma No_Strict_Aliasing
3663 @findex No_Strict_Aliasing
3664 @noindent
3665 Syntax:
3666
3667 @smallexample @c ada
3668 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3669 @end smallexample
3670
3671 @noindent
3672 @var{type_LOCAL_NAME} must refer to an access type
3673 declaration in the current declarative part. The effect is to inhibit
3674 strict aliasing optimization for the given type. The form with no
3675 arguments is a configuration pragma which applies to all access types
3676 declared in units to which the pragma applies. For a detailed
3677 description of the strict aliasing optimization, and the situations
3678 in which it must be suppressed, see @ref{Optimization and Strict
3679 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3680
3681 This pragma currently has no effects on access to unconstrained array types.
3682
3683 @node Pragma Normalize_Scalars
3684 @unnumberedsec Pragma Normalize_Scalars
3685 @findex Normalize_Scalars
3686 @noindent
3687 Syntax:
3688
3689 @smallexample @c ada
3690 pragma Normalize_Scalars;
3691 @end smallexample
3692
3693 @noindent
3694 This is a language defined pragma which is fully implemented in GNAT@. The
3695 effect is to cause all scalar objects that are not otherwise initialized
3696 to be initialized. The initial values are implementation dependent and
3697 are as follows:
3698
3699 @table @code
3700 @item Standard.Character
3701 @noindent
3702 Objects whose root type is Standard.Character are initialized to
3703 Character'Last unless the subtype range excludes NUL (in which case
3704 NUL is used). This choice will always generate an invalid value if
3705 one exists.
3706
3707 @item Standard.Wide_Character
3708 @noindent
3709 Objects whose root type is Standard.Wide_Character are initialized to
3710 Wide_Character'Last unless the subtype range excludes NUL (in which case
3711 NUL is used). This choice will always generate an invalid value if
3712 one exists.
3713
3714 @item Standard.Wide_Wide_Character
3715 @noindent
3716 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3717 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3718 which case NUL is used). This choice will always generate an invalid value if
3719 one exists.
3720
3721 @item Integer types
3722 @noindent
3723 Objects of an integer type are treated differently depending on whether
3724 negative values are present in the subtype. If no negative values are
3725 present, then all one bits is used as the initial value except in the
3726 special case where zero is excluded from the subtype, in which case
3727 all zero bits are used. This choice will always generate an invalid
3728 value if one exists.
3729
3730 For subtypes with negative values present, the largest negative number
3731 is used, except in the unusual case where this largest negative number
3732 is in the subtype, and the largest positive number is not, in which case
3733 the largest positive value is used. This choice will always generate
3734 an invalid value if one exists.
3735
3736 @item Floating-Point Types
3737 Objects of all floating-point types are initialized to all 1-bits. For
3738 standard IEEE format, this corresponds to a NaN (not a number) which is
3739 indeed an invalid value.
3740
3741 @item Fixed-Point Types
3742 Objects of all fixed-point types are treated as described above for integers,
3743 with the rules applying to the underlying integer value used to represent
3744 the fixed-point value.
3745
3746 @item Modular types
3747 Objects of a modular type are initialized to all one bits, except in
3748 the special case where zero is excluded from the subtype, in which
3749 case all zero bits are used. This choice will always generate an
3750 invalid value if one exists.
3751
3752 @item Enumeration types
3753 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3754 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3755 whose Pos value is zero, in which case a code of zero is used. This choice
3756 will always generate an invalid value if one exists.
3757
3758 @end table
3759
3760 @node Pragma Obsolescent
3761 @unnumberedsec Pragma Obsolescent
3762 @findex Obsolescent
3763 @noindent
3764 Syntax:
3765
3766 @smallexample @c ada
3767 pragma Obsolescent;
3768
3769 pragma Obsolescent (
3770 [Message =>] static_string_EXPRESSION
3771 [,[Version =>] Ada_05]]);
3772
3773 pragma Obsolescent (
3774 [Entity =>] NAME
3775 [,[Message =>] static_string_EXPRESSION
3776 [,[Version =>] Ada_05]] );
3777 @end smallexample
3778
3779 @noindent
3780 This pragma can occur immediately following a declaration of an entity,
3781 including the case of a record component. If no Entity argument is present,
3782 then this declaration is the one to which the pragma applies. If an Entity
3783 parameter is present, it must either match the name of the entity in this
3784 declaration, or alternatively, the pragma can immediately follow an enumeration
3785 type declaration, where the Entity argument names one of the enumeration
3786 literals.
3787
3788 This pragma is used to indicate that the named entity
3789 is considered obsolescent and should not be used. Typically this is
3790 used when an API must be modified by eventually removing or modifying
3791 existing subprograms or other entities. The pragma can be used at an
3792 intermediate stage when the entity is still present, but will be
3793 removed later.
3794
3795 The effect of this pragma is to output a warning message on a reference to
3796 an entity thus marked that the subprogram is obsolescent if the appropriate
3797 warning option in the compiler is activated. If the Message parameter is
3798 present, then a second warning message is given containing this text. In
3799 addition, a reference to the entity is considered to be a violation of pragma
3800 Restrictions (No_Obsolescent_Features).
3801
3802 This pragma can also be used as a program unit pragma for a package,
3803 in which case the entity name is the name of the package, and the
3804 pragma indicates that the entire package is considered
3805 obsolescent. In this case a client @code{with}'ing such a package
3806 violates the restriction, and the @code{with} statement is
3807 flagged with warnings if the warning option is set.
3808
3809 If the Version parameter is present (which must be exactly
3810 the identifier Ada_05, no other argument is allowed), then the
3811 indication of obsolescence applies only when compiling in Ada 2005
3812 mode. This is primarily intended for dealing with the situations
3813 in the predefined library where subprograms or packages
3814 have become defined as obsolescent in Ada 2005
3815 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3816
3817 The following examples show typical uses of this pragma:
3818
3819 @smallexample @c ada
3820 package p is
3821 pragma Obsolescent (p, Message => "use pp instead of p");
3822 end p;
3823
3824 package q is
3825 procedure q2;
3826 pragma Obsolescent ("use q2new instead");
3827
3828 type R is new integer;
3829 pragma Obsolescent
3830 (Entity => R,
3831 Message => "use RR in Ada 2005",
3832 Version => Ada_05);
3833
3834 type M is record
3835 F1 : Integer;
3836 F2 : Integer;
3837 pragma Obsolescent;
3838 F3 : Integer;
3839 end record;
3840
3841 type E is (a, bc, 'd', quack);
3842 pragma Obsolescent (Entity => bc)
3843 pragma Obsolescent (Entity => 'd')
3844
3845 function "+"
3846 (a, b : character) return character;
3847 pragma Obsolescent (Entity => "+");
3848 end;
3849 @end smallexample
3850
3851 @noindent
3852 Note that, as for all pragmas, if you use a pragma argument identifier,
3853 then all subsequent parameters must also use a pragma argument identifier.
3854 So if you specify "Entity =>" for the Entity argument, and a Message
3855 argument is present, it must be preceded by "Message =>".
3856
3857 @node Pragma Optimize_Alignment
3858 @unnumberedsec Pragma Optimize_Alignment
3859 @findex Optimize_Alignment
3860 @cindex Alignment, default settings
3861 @noindent
3862 Syntax:
3863
3864 @smallexample @c ada
3865 pragma Optimize_Alignment (TIME | SPACE | OFF);
3866 @end smallexample
3867
3868 @noindent
3869 This is a configuration pragma which affects the choice of default alignments
3870 for types where no alignment is explicitly specified. There is a time/space
3871 trade-off in the selection of these values. Large alignments result in more
3872 efficient code, at the expense of larger data space, since sizes have to be
3873 increased to match these alignments. Smaller alignments save space, but the
3874 access code is slower. The normal choice of default alignments (which is what
3875 you get if you do not use this pragma, or if you use an argument of OFF),
3876 tries to balance these two requirements.
3877
3878 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3879 First any packed record is given an alignment of 1. Second, if a size is given
3880 for the type, then the alignment is chosen to avoid increasing this size. For
3881 example, consider:
3882
3883 @smallexample @c ada
3884 type R is record
3885 X : Integer;
3886 Y : Character;
3887 end record;
3888
3889 for R'Size use 5*8;
3890 @end smallexample
3891
3892 @noindent
3893 In the default mode, this type gets an alignment of 4, so that access to the
3894 Integer field X are efficient. But this means that objects of the type end up
3895 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3896 allowed to be bigger than the size of the type, but it can waste space if for
3897 example fields of type R appear in an enclosing record. If the above type is
3898 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3899
3900 Specifying TIME causes larger default alignments to be chosen in the case of
3901 small types with sizes that are not a power of 2. For example, consider:
3902
3903 @smallexample @c ada
3904 type R is record
3905 A : Character;
3906 B : Character;
3907 C : Boolean;
3908 end record;
3909
3910 pragma Pack (R);
3911 for R'Size use 17;
3912 @end smallexample
3913
3914 @noindent
3915 The default alignment for this record is normally 1, but if this type is
3916 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3917 to 4, which wastes space for objects of the type, since they are now 4 bytes
3918 long, but results in more efficient access when the whole record is referenced.
3919
3920 As noted above, this is a configuration pragma, and there is a requirement
3921 that all units in a partition be compiled with a consistent setting of the
3922 optimization setting. This would normally be achieved by use of a configuration
3923 pragma file containing the appropriate setting. The exception to this rule is
3924 that units with an explicit configuration pragma in the same file as the source
3925 unit are excluded from the consistency check, as are all predefined units. The
3926 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3927 pragma appears at the start of the file.
3928
3929 @node Pragma Ordered
3930 @unnumberedsec Pragma Ordered
3931 @findex Ordered
3932 @findex pragma @code{Ordered}
3933 @noindent
3934 Syntax:
3935
3936 @smallexample @c ada
3937 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3938 @end smallexample
3939
3940 @noindent
3941 Most enumeration types are from a conceptual point of view unordered.
3942 For example, consider:
3943
3944 @smallexample @c ada
3945 type Color is (Red, Blue, Green, Yellow);
3946 @end smallexample
3947
3948 @noindent
3949 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3950 but really these relations make no sense; the enumeration type merely
3951 specifies a set of possible colors, and the order is unimportant.
3952
3953 For unordered enumeration types, it is generally a good idea if
3954 clients avoid comparisons (other than equality or inequality) and
3955 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3956 other than the unit where the type is declared, its body, and its subunits.)
3957 For example, if code buried in some client says:
3958
3959 @smallexample @c ada
3960 if Current_Color < Yellow then ...
3961 if Current_Color in Blue .. Green then ...
3962 @end smallexample
3963
3964 @noindent
3965 then the client code is relying on the order, which is undesirable.
3966 It makes the code hard to read and creates maintenance difficulties if
3967 entries have to be added to the enumeration type. Instead,
3968 the code in the client should list the possibilities, or an
3969 appropriate subtype should be declared in the unit that declares
3970 the original enumeration type. E.g., the following subtype could
3971 be declared along with the type @code{Color}:
3972
3973 @smallexample @c ada
3974 subtype RBG is Color range Red .. Green;
3975 @end smallexample
3976
3977 @noindent
3978 and then the client could write:
3979
3980 @smallexample @c ada
3981 if Current_Color in RBG then ...
3982 if Current_Color = Blue or Current_Color = Green then ...
3983 @end smallexample
3984
3985 @noindent
3986 However, some enumeration types are legitimately ordered from a conceptual
3987 point of view. For example, if you declare:
3988
3989 @smallexample @c ada
3990 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3991 @end smallexample
3992
3993 @noindent
3994 then the ordering imposed by the language is reasonable, and
3995 clients can depend on it, writing for example:
3996
3997 @smallexample @c ada
3998 if D in Mon .. Fri then ...
3999 if D < Wed then ...
4000 @end smallexample
4001
4002 @noindent
4003 The pragma @option{Ordered} is provided to mark enumeration types that
4004 are conceptually ordered, alerting the reader that clients may depend
4005 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4006 rather than one to mark them as unordered, since in our experience,
4007 the great majority of enumeration types are conceptually unordered.
4008
4009 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4010 and @code{Wide_Wide_Character}
4011 are considered to be ordered types, so each is declared with a
4012 pragma @code{Ordered} in package @code{Standard}.
4013
4014 Normally pragma @code{Ordered} serves only as documentation and a guide for
4015 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4016 requests warnings for inappropriate uses (comparisons and explicit
4017 subranges) for unordered types. If this switch is used, then any
4018 enumeration type not marked with pragma @code{Ordered} will be considered
4019 as unordered, and will generate warnings for inappropriate uses.
4020
4021 For additional information please refer to the description of the
4022 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4023
4024 @node Pragma Passive
4025 @unnumberedsec Pragma Passive
4026 @findex Passive
4027 @noindent
4028 Syntax:
4029
4030 @smallexample @c ada
4031 pragma Passive [(Semaphore | No)];
4032 @end smallexample
4033
4034 @noindent
4035 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4036 compatibility with DEC Ada 83 implementations, where it is used within a
4037 task definition to request that a task be made passive. If the argument
4038 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4039 treats the pragma as an assertion that the containing task is passive
4040 and that optimization of context switch with this task is permitted and
4041 desired. If the argument @code{No} is present, the task must not be
4042 optimized. GNAT does not attempt to optimize any tasks in this manner
4043 (since protected objects are available in place of passive tasks).
4044
4045 @node Pragma Persistent_BSS
4046 @unnumberedsec Pragma Persistent_BSS
4047 @findex Persistent_BSS
4048 @noindent
4049 Syntax:
4050
4051 @smallexample @c ada
4052 pragma Persistent_BSS [(LOCAL_NAME)]
4053 @end smallexample
4054
4055 @noindent
4056 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4057 section. On some targets the linker and loader provide for special
4058 treatment of this section, allowing a program to be reloaded without
4059 affecting the contents of this data (hence the name persistent).
4060
4061 There are two forms of usage. If an argument is given, it must be the
4062 local name of a library level object, with no explicit initialization
4063 and whose type is potentially persistent. If no argument is given, then
4064 the pragma is a configuration pragma, and applies to all library level
4065 objects with no explicit initialization of potentially persistent types.
4066
4067 A potentially persistent type is a scalar type, or a non-tagged,
4068 non-discriminated record, all of whose components have no explicit
4069 initialization and are themselves of a potentially persistent type,
4070 or an array, all of whose constraints are static, and whose component
4071 type is potentially persistent.
4072
4073 If this pragma is used on a target where this feature is not supported,
4074 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4075
4076 @node Pragma Polling
4077 @unnumberedsec Pragma Polling
4078 @findex Polling
4079 @noindent
4080 Syntax:
4081
4082 @smallexample @c ada
4083 pragma Polling (ON | OFF);
4084 @end smallexample
4085
4086 @noindent
4087 This pragma controls the generation of polling code. This is normally off.
4088 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4089 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4090 runtime library, and can be found in file @file{a-excpol.adb}.
4091
4092 Pragma @code{Polling} can appear as a configuration pragma (for example it
4093 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4094 can be used in the statement or declaration sequence to control polling
4095 more locally.
4096
4097 A call to the polling routine is generated at the start of every loop and
4098 at the start of every subprogram call. This guarantees that the @code{Poll}
4099 routine is called frequently, and places an upper bound (determined by
4100 the complexity of the code) on the period between two @code{Poll} calls.
4101
4102 The primary purpose of the polling interface is to enable asynchronous
4103 aborts on targets that cannot otherwise support it (for example Windows
4104 NT), but it may be used for any other purpose requiring periodic polling.
4105 The standard version is null, and can be replaced by a user program. This
4106 will require re-compilation of the @code{Ada.Exceptions} package that can
4107 be found in files @file{a-except.ads} and @file{a-except.adb}.
4108
4109 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4110 distribution) is used to enable the asynchronous abort capability on
4111 targets that do not normally support the capability. The version of
4112 @code{Poll} in this file makes a call to the appropriate runtime routine
4113 to test for an abort condition.
4114
4115 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4116 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4117 details.
4118
4119 @node Pragma Postcondition
4120 @unnumberedsec Pragma Postcondition
4121 @cindex Postconditions
4122 @cindex Checks, postconditions
4123 @findex Postconditions
4124 @noindent
4125 Syntax:
4126
4127 @smallexample @c ada
4128 pragma Postcondition (
4129 [Check =>] Boolean_Expression
4130 [,[Message =>] String_Expression]);
4131 @end smallexample
4132
4133 @noindent
4134 The @code{Postcondition} pragma allows specification of automatic
4135 postcondition checks for subprograms. These checks are similar to
4136 assertions, but are automatically inserted just prior to the return
4137 statements of the subprogram with which they are associated (including
4138 implicit returns at the end of procedure bodies and associated
4139 exception handlers).
4140
4141 In addition, the boolean expression which is the condition which
4142 must be true may contain references to function'Result in the case
4143 of a function to refer to the returned value.
4144
4145 @code{Postcondition} pragmas may appear either immediately following the
4146 (separate) declaration of a subprogram, or at the start of the
4147 declarations of a subprogram body. Only other pragmas may intervene
4148 (that is appear between the subprogram declaration and its
4149 postconditions, or appear before the postcondition in the
4150 declaration sequence in a subprogram body). In the case of a
4151 postcondition appearing after a subprogram declaration, the
4152 formal arguments of the subprogram are visible, and can be
4153 referenced in the postcondition expressions.
4154
4155 The postconditions are collected and automatically tested just
4156 before any return (implicit or explicit) in the subprogram body.
4157 A postcondition is only recognized if postconditions are active
4158 at the time the pragma is encountered. The compiler switch @option{gnata}
4159 turns on all postconditions by default, and pragma @code{Check_Policy}
4160 with an identifier of @code{Postcondition} can also be used to
4161 control whether postconditions are active.
4162
4163 The general approach is that postconditions are placed in the spec
4164 if they represent functional aspects which make sense to the client.
4165 For example we might have:
4166
4167 @smallexample @c ada
4168 function Direction return Integer;
4169 pragma Postcondition
4170 (Direction'Result = +1
4171 or else
4172 Direction'Result = -1);
4173 @end smallexample
4174
4175 @noindent
4176 which serves to document that the result must be +1 or -1, and
4177 will test that this is the case at run time if postcondition
4178 checking is active.
4179
4180 Postconditions within the subprogram body can be used to
4181 check that some internal aspect of the implementation,
4182 not visible to the client, is operating as expected.
4183 For instance if a square root routine keeps an internal
4184 counter of the number of times it is called, then we
4185 might have the following postcondition:
4186
4187 @smallexample @c ada
4188 Sqrt_Calls : Natural := 0;
4189
4190 function Sqrt (Arg : Float) return Float is
4191 pragma Postcondition
4192 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4193 ...
4194 end Sqrt
4195 @end smallexample
4196
4197 @noindent
4198 As this example, shows, the use of the @code{Old} attribute
4199 is often useful in postconditions to refer to the state on
4200 entry to the subprogram.
4201
4202 Note that postconditions are only checked on normal returns
4203 from the subprogram. If an abnormal return results from
4204 raising an exception, then the postconditions are not checked.
4205
4206 If a postcondition fails, then the exception
4207 @code{System.Assertions.Assert_Failure} is raised. If
4208 a message argument was supplied, then the given string
4209 will be used as the exception message. If no message
4210 argument was supplied, then the default message has
4211 the form "Postcondition failed at file:line". The
4212 exception is raised in the context of the subprogram
4213 body, so it is possible to catch postcondition failures
4214 within the subprogram body itself.
4215
4216 Within a package spec, normal visibility rules
4217 in Ada would prevent forward references within a
4218 postcondition pragma to functions defined later in
4219 the same package. This would introduce undesirable
4220 ordering constraints. To avoid this problem, all
4221 postcondition pragmas are analyzed at the end of
4222 the package spec, allowing forward references.
4223
4224 The following example shows that this even allows
4225 mutually recursive postconditions as in:
4226
4227 @smallexample @c ada
4228 package Parity_Functions is
4229 function Odd (X : Natural) return Boolean;
4230 pragma Postcondition
4231 (Odd'Result =
4232 (x = 1
4233 or else
4234 (x /= 0 and then Even (X - 1))));
4235
4236 function Even (X : Natural) return Boolean;
4237 pragma Postcondition
4238 (Even'Result =
4239 (x = 0
4240 or else
4241 (x /= 1 and then Odd (X - 1))));
4242
4243 end Parity_Functions;
4244 @end smallexample
4245
4246 @noindent
4247 There are no restrictions on the complexity or form of
4248 conditions used within @code{Postcondition} pragmas.
4249 The following example shows that it is even possible
4250 to verify performance behavior.
4251
4252 @smallexample @c ada
4253 package Sort is
4254
4255 Performance : constant Float;
4256 -- Performance constant set by implementation
4257 -- to match target architecture behavior.
4258
4259 procedure Treesort (Arg : String);
4260 -- Sorts characters of argument using N*logN sort
4261 pragma Postcondition
4262 (Float (Clock - Clock'Old) <=
4263 Float (Arg'Length) *
4264 log (Float (Arg'Length)) *
4265 Performance);
4266 end Sort;
4267 @end smallexample
4268
4269 @noindent
4270 Note: postcondition pragmas associated with subprograms that are
4271 marked as Inline_Always, or those marked as Inline with front-end
4272 inlining (-gnatN option set) are accepted and legality-checked
4273 by the compiler, but are ignored at run-time even if postcondition
4274 checking is enabled.
4275
4276 @node Pragma Precondition
4277 @unnumberedsec Pragma Precondition
4278 @cindex Preconditions
4279 @cindex Checks, preconditions
4280 @findex Preconditions
4281 @noindent
4282 Syntax:
4283
4284 @smallexample @c ada
4285 pragma Precondition (
4286 [Check =>] Boolean_Expression
4287 [,[Message =>] String_Expression]);
4288 @end smallexample
4289
4290 @noindent
4291 The @code{Precondition} pragma is similar to @code{Postcondition}
4292 except that the corresponding checks take place immediately upon
4293 entry to the subprogram, and if a precondition fails, the exception
4294 is raised in the context of the caller, and the attribute 'Result
4295 cannot be used within the precondition expression.
4296
4297 Otherwise, the placement and visibility rules are identical to those
4298 described for postconditions. The following is an example of use
4299 within a package spec:
4300
4301 @smallexample @c ada
4302 package Math_Functions is
4303 ...
4304 function Sqrt (Arg : Float) return Float;
4305 pragma Precondition (Arg >= 0.0)
4306 ...
4307 end Math_Functions;
4308 @end smallexample
4309
4310 @noindent
4311 @code{Precondition} pragmas may appear either immediately following the
4312 (separate) declaration of a subprogram, or at the start of the
4313 declarations of a subprogram body. Only other pragmas may intervene
4314 (that is appear between the subprogram declaration and its
4315 postconditions, or appear before the postcondition in the
4316 declaration sequence in a subprogram body).
4317
4318 Note: postcondition pragmas associated with subprograms that are
4319 marked as Inline_Always, or those marked as Inline with front-end
4320 inlining (-gnatN option set) are accepted and legality-checked
4321 by the compiler, but are ignored at run-time even if postcondition
4322 checking is enabled.
4323
4324 @node Pragma Profile (Ravenscar)
4325 @unnumberedsec Pragma Profile (Ravenscar)
4326 @findex Ravenscar
4327 @noindent
4328 Syntax:
4329
4330 @smallexample @c ada
4331 pragma Profile (Ravenscar);
4332 @end smallexample
4333
4334 @noindent
4335 A configuration pragma that establishes the following set of configuration
4336 pragmas:
4337
4338 @table @code
4339 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4340 [RM D.2.2] Tasks are dispatched following a preemptive
4341 priority-ordered scheduling policy.
4342
4343 @item Locking_Policy (Ceiling_Locking)
4344 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4345 the ceiling priority of the corresponding protected object.
4346 @c
4347 @c @item Detect_Blocking
4348 @c This pragma forces the detection of potentially blocking operations within a
4349 @c protected operation, and to raise Program_Error if that happens.
4350 @end table
4351 @noindent
4352
4353 plus the following set of restrictions:
4354
4355 @table @code
4356 @item Max_Entry_Queue_Length => 1
4357 No task can be queued on a protected entry.
4358 @item Max_Protected_Entries => 1
4359 @item Max_Task_Entries => 0
4360 No rendezvous statements are allowed.
4361 @item No_Abort_Statements
4362 @item No_Dynamic_Attachment
4363 @item No_Dynamic_Priorities
4364 @item No_Implicit_Heap_Allocations
4365 @item No_Local_Protected_Objects
4366 @item No_Local_Timing_Events
4367 @item No_Protected_Type_Allocators
4368 @item No_Relative_Delay
4369 @item No_Requeue_Statements
4370 @item No_Select_Statements
4371 @item No_Specific_Termination_Handlers
4372 @item No_Task_Allocators
4373 @item No_Task_Hierarchy
4374 @item No_Task_Termination
4375 @item Simple_Barriers
4376 @end table
4377 @noindent
4378
4379 The Ravenscar profile also includes the following restrictions that specify
4380 that there are no semantic dependences on the corresponding predefined
4381 packages:
4382
4383 @table @code
4384 @item No_Dependence => Ada.Asynchronous_Task_Control
4385 @item No_Dependence => Ada.Calendar
4386 @item No_Dependence => Ada.Execution_Time.Group_Budget
4387 @item No_Dependence => Ada.Execution_Time.Timers
4388 @item No_Dependence => Ada.Task_Attributes
4389 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4390 @end table
4391
4392 @noindent
4393
4394 This set of configuration pragmas and restrictions correspond to the
4395 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4396 published by the @cite{International Real-Time Ada Workshop}, 1997,
4397 and whose most recent description is available at
4398 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4399
4400 The original definition of the profile was revised at subsequent IRTAW
4401 meetings. It has been included in the ISO
4402 @cite{Guide for the Use of the Ada Programming Language in High
4403 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4404 the next revision of the standard. The formal definition given by
4405 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4406 AI-305) available at
4407 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4408 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4409
4410 The above set is a superset of the restrictions provided by pragma
4411 @code{Profile (Restricted)}, it includes six additional restrictions
4412 (@code{Simple_Barriers}, @code{No_Select_Statements},
4413 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4414 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4415 that pragma @code{Profile (Ravenscar)}, like the pragma
4416 @code{Profile (Restricted)},
4417 automatically causes the use of a simplified,
4418 more efficient version of the tasking run-time system.
4419
4420 @node Pragma Profile (Restricted)
4421 @unnumberedsec Pragma Profile (Restricted)
4422 @findex Restricted Run Time
4423 @noindent
4424 Syntax:
4425
4426 @smallexample @c ada
4427 pragma Profile (Restricted);
4428 @end smallexample
4429
4430 @noindent
4431 A configuration pragma that establishes the following set of restrictions:
4432
4433 @itemize @bullet
4434 @item No_Abort_Statements
4435 @item No_Entry_Queue
4436 @item No_Task_Hierarchy
4437 @item No_Task_Allocators
4438 @item No_Dynamic_Priorities
4439 @item No_Terminate_Alternatives
4440 @item No_Dynamic_Attachment
4441 @item No_Protected_Type_Allocators
4442 @item No_Local_Protected_Objects
4443 @item No_Requeue_Statements
4444 @item No_Task_Attributes_Package
4445 @item Max_Asynchronous_Select_Nesting = 0
4446 @item Max_Task_Entries = 0
4447 @item Max_Protected_Entries = 1
4448 @item Max_Select_Alternatives = 0
4449 @end itemize
4450
4451 @noindent
4452 This set of restrictions causes the automatic selection of a simplified
4453 version of the run time that provides improved performance for the
4454 limited set of tasking functionality permitted by this set of restrictions.
4455
4456 @node Pragma Psect_Object
4457 @unnumberedsec Pragma Psect_Object
4458 @findex Psect_Object
4459 @noindent
4460 Syntax:
4461
4462 @smallexample @c ada
4463 pragma Psect_Object (
4464 [Internal =>] LOCAL_NAME,
4465 [, [External =>] EXTERNAL_SYMBOL]
4466 [, [Size =>] EXTERNAL_SYMBOL]);
4467
4468 EXTERNAL_SYMBOL ::=
4469 IDENTIFIER
4470 | static_string_EXPRESSION
4471 @end smallexample
4472
4473 @noindent
4474 This pragma is identical in effect to pragma @code{Common_Object}.
4475
4476 @node Pragma Pure_Function
4477 @unnumberedsec Pragma Pure_Function
4478 @findex Pure_Function
4479 @noindent
4480 Syntax:
4481
4482 @smallexample @c ada
4483 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4484 @end smallexample
4485
4486 @noindent
4487 This pragma appears in the same declarative part as a function
4488 declaration (or a set of function declarations if more than one
4489 overloaded declaration exists, in which case the pragma applies
4490 to all entities). It specifies that the function @code{Entity} is
4491 to be considered pure for the purposes of code generation. This means
4492 that the compiler can assume that there are no side effects, and
4493 in particular that two calls with identical arguments produce the
4494 same result. It also means that the function can be used in an
4495 address clause.
4496
4497 Note that, quite deliberately, there are no static checks to try
4498 to ensure that this promise is met, so @code{Pure_Function} can be used
4499 with functions that are conceptually pure, even if they do modify
4500 global variables. For example, a square root function that is
4501 instrumented to count the number of times it is called is still
4502 conceptually pure, and can still be optimized, even though it
4503 modifies a global variable (the count). Memo functions are another
4504 example (where a table of previous calls is kept and consulted to
4505 avoid re-computation).
4506
4507 Note also that the normal rules excluding optimization of subprograms
4508 in pure units (when parameter types are descended from System.Address,
4509 or when the full view of a parameter type is limited), do not apply
4510 for the Pure_Function case. If you explicitly specify Pure_Function,
4511 the compiler may optimize away calls with identical arguments, and
4512 if that results in unexpected behavior, the proper action is not to
4513 use the pragma for subprograms that are not (conceptually) pure.
4514
4515 @findex Pure
4516 Note: Most functions in a @code{Pure} package are automatically pure, and
4517 there is no need to use pragma @code{Pure_Function} for such functions. One
4518 exception is any function that has at least one formal of type
4519 @code{System.Address} or a type derived from it. Such functions are not
4520 considered pure by default, since the compiler assumes that the
4521 @code{Address} parameter may be functioning as a pointer and that the
4522 referenced data may change even if the address value does not.
4523 Similarly, imported functions are not considered to be pure by default,
4524 since there is no way of checking that they are in fact pure. The use
4525 of pragma @code{Pure_Function} for such a function will override these default
4526 assumption, and cause the compiler to treat a designated subprogram as pure
4527 in these cases.
4528
4529 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4530 applies to the underlying renamed function. This can be used to
4531 disambiguate cases of overloading where some but not all functions
4532 in a set of overloaded functions are to be designated as pure.
4533
4534 If pragma @code{Pure_Function} is applied to a library level function, the
4535 function is also considered pure from an optimization point of view, but the
4536 unit is not a Pure unit in the categorization sense. So for example, a function
4537 thus marked is free to @code{with} non-pure units.
4538
4539 @node Pragma Remote_Access_Type
4540 @unnumberedsec Pragma Remote_Access_Type
4541 @findex Remote_Access_Type
4542 @noindent
4543 Syntax:
4544
4545 @smallexample @c ada
4546 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
4547 @end smallexample
4548
4549 @noindent
4550 This pragma appears in the formal part of a generic declaration.
4551 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
4552 the use of a remote access to class-wide type as actual for a formal
4553 access type.
4554
4555 When this pragma applies to a formal access type @code{Entity}, that
4556 type is treated as a remote access to class-wide type in the generic.
4557 It must be a formal general access type, and its designated type must
4558 be the class-wide type of a formal tagged limited private type from the
4559 same generic declaration.
4560
4561 In the generic unit, the formal type is subject to all restrictions
4562 pertaining to remote access to class-wide types. At instantiation, the
4563 actual type must be a remote access to class-wide type.
4564
4565 @node Pragma Restriction_Warnings
4566 @unnumberedsec Pragma Restriction_Warnings
4567 @findex Restriction_Warnings
4568 @noindent
4569 Syntax:
4570
4571 @smallexample @c ada
4572 pragma Restriction_Warnings
4573 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4574 @end smallexample
4575
4576 @noindent
4577 This pragma allows a series of restriction identifiers to be
4578 specified (the list of allowed identifiers is the same as for
4579 pragma @code{Restrictions}). For each of these identifiers
4580 the compiler checks for violations of the restriction, but
4581 generates a warning message rather than an error message
4582 if the restriction is violated.
4583
4584 @node Pragma Shared
4585 @unnumberedsec Pragma Shared
4586 @findex Shared
4587
4588 @noindent
4589 This pragma is provided for compatibility with Ada 83. The syntax and
4590 semantics are identical to pragma Atomic.
4591
4592 @node Pragma Short_Circuit_And_Or
4593 @unnumberedsec Pragma Short_Circuit_And_Or
4594 @findex Short_Circuit_And_Or
4595
4596 @noindent
4597 This configuration pragma causes any occurrence of the AND operator applied to
4598 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4599 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4600 may be useful in the context of certification protocols requiring the use of
4601 short-circuited logical operators. If this configuration pragma occurs locally
4602 within the file being compiled, it applies only to the file being compiled.
4603 There is no requirement that all units in a partition use this option.
4604
4605 @node Pragma Short_Descriptors
4606 @unnumberedsec Pragma Short_Descriptors
4607 @findex Short_Descriptors
4608 @noindent
4609 Syntax:
4610
4611 @smallexample @c ada
4612 pragma Short_Descriptors
4613 @end smallexample
4614
4615 @noindent
4616 In VMS versions of the compiler, this configuration pragma causes all
4617 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4618 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4619 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4620 versions.
4621
4622 @node Pragma Simple_Storage_Pool_Type
4623 @unnumberedsec Pragma Simple_Storage_Pool_Type
4624 @findex Simple_Storage_Pool_Type
4625 @cindex Storage pool, simple
4626 @cindex Simple storage pool
4627 @noindent
4628 Syntax:
4629
4630 @smallexample @c ada
4631 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
4632 @end smallexample
4633
4634 @noindent
4635 A type can be established as a ``simple storage pool type'' by applying
4636 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
4637 A type named in the pragma must be a library-level immutably limited record
4638 type or limited tagged type declared immediately within a package declaration.
4639 The type can also be a limited private type whose full type is allowed as
4640 a simple storage pool type.
4641
4642 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
4643 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
4644 are subtype conformant with the following subprogram declarations:
4645
4646 @smallexample @c ada
4647 procedure Allocate
4648 (Pool : in out SSP;
4649 Storage_Address : out System.Address;
4650 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4651 Alignment : System.Storage_Elements.Storage_Count);
4652
4653 procedure Deallocate
4654 (Pool : in out SSP;
4655 Storage_Address : System.Address;
4656 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
4657 Alignment : System.Storage_Elements.Storage_Count);
4658
4659 function Storage_Size (Pool : SSP)
4660 return System.Storage_Elements.Storage_Count;
4661 @end smallexample
4662
4663 @noindent
4664 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
4665 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
4666 applying an unchecked deallocation has no effect other than to set its actual
4667 parameter to null. If @code{Storage_Size} is not declared, then the
4668 @code{Storage_Size} attribute applied to an access type associated with
4669 a pool object of type SSP returns zero. Additional operations can be declared
4670 for a simple storage pool type (such as for supporting a mark/release
4671 storage-management discipline).
4672
4673 An object of a simple storage pool type can be associated with an access
4674 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
4675
4676 @smallexample @c ada
4677
4678 My_Pool : My_Simple_Storage_Pool_Type;
4679
4680 type Acc is access My_Data_Type;
4681
4682 for Acc'Simple_Storage_Pool use My_Pool;
4683
4684 @end smallexample
4685
4686 @noindent
4687 See attribute @code{Simple_Storage_Pool} for further details.
4688
4689 @node Pragma Source_File_Name
4690 @unnumberedsec Pragma Source_File_Name
4691 @findex Source_File_Name
4692 @noindent
4693 Syntax:
4694
4695 @smallexample @c ada
4696 pragma Source_File_Name (
4697 [Unit_Name =>] unit_NAME,
4698 Spec_File_Name => STRING_LITERAL,
4699 [Index => INTEGER_LITERAL]);
4700
4701 pragma Source_File_Name (
4702 [Unit_Name =>] unit_NAME,
4703 Body_File_Name => STRING_LITERAL,
4704 [Index => INTEGER_LITERAL]);
4705 @end smallexample
4706
4707 @noindent
4708 Use this to override the normal naming convention. It is a configuration
4709 pragma, and so has the usual applicability of configuration pragmas
4710 (i.e.@: it applies to either an entire partition, or to all units in a
4711 compilation, or to a single unit, depending on how it is used.
4712 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
4713 the second argument is required, and indicates whether this is the file
4714 name for the spec or for the body.
4715
4716 The optional Index argument should be used when a file contains multiple
4717 units, and when you do not want to use @code{gnatchop} to separate then
4718 into multiple files (which is the recommended procedure to limit the
4719 number of recompilations that are needed when some sources change).
4720 For instance, if the source file @file{source.ada} contains
4721
4722 @smallexample @c ada
4723 package B is
4724 ...
4725 end B;
4726
4727 with B;
4728 procedure A is
4729 begin
4730 ..
4731 end A;
4732 @end smallexample
4733
4734 you could use the following configuration pragmas:
4735
4736 @smallexample @c ada
4737 pragma Source_File_Name
4738 (B, Spec_File_Name => "source.ada", Index => 1);
4739 pragma Source_File_Name
4740 (A, Body_File_Name => "source.ada", Index => 2);
4741 @end smallexample
4742
4743 Note that the @code{gnatname} utility can also be used to generate those
4744 configuration pragmas.
4745
4746 Another form of the @code{Source_File_Name} pragma allows
4747 the specification of patterns defining alternative file naming schemes
4748 to apply to all files.
4749
4750 @smallexample @c ada
4751 pragma Source_File_Name
4752 ( [Spec_File_Name =>] STRING_LITERAL
4753 [,[Casing =>] CASING_SPEC]
4754 [,[Dot_Replacement =>] STRING_LITERAL]);
4755
4756 pragma Source_File_Name
4757 ( [Body_File_Name =>] STRING_LITERAL
4758 [,[Casing =>] CASING_SPEC]
4759 [,[Dot_Replacement =>] STRING_LITERAL]);
4760
4761 pragma Source_File_Name
4762 ( [Subunit_File_Name =>] STRING_LITERAL
4763 [,[Casing =>] CASING_SPEC]
4764 [,[Dot_Replacement =>] STRING_LITERAL]);
4765
4766 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4767 @end smallexample
4768
4769 @noindent
4770 The first argument is a pattern that contains a single asterisk indicating
4771 the point at which the unit name is to be inserted in the pattern string
4772 to form the file name. The second argument is optional. If present it
4773 specifies the casing of the unit name in the resulting file name string.
4774 The default is lower case. Finally the third argument allows for systematic
4775 replacement of any dots in the unit name by the specified string literal.
4776
4777 Note that Source_File_Name pragmas should not be used if you are using
4778 project files. The reason for this rule is that the project manager is not
4779 aware of these pragmas, and so other tools that use the projet file would not
4780 be aware of the intended naming conventions. If you are using project files,
4781 file naming is controlled by Source_File_Name_Project pragmas, which are
4782 usually supplied automatically by the project manager. A pragma
4783 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4784
4785 For more details on the use of the @code{Source_File_Name} pragma,
4786 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4787 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4788 User's Guide}.
4789
4790 @node Pragma Source_File_Name_Project
4791 @unnumberedsec Pragma Source_File_Name_Project
4792 @findex Source_File_Name_Project
4793 @noindent
4794
4795 This pragma has the same syntax and semantics as pragma Source_File_Name.
4796 It is only allowed as a stand alone configuration pragma.
4797 It cannot appear after a @ref{Pragma Source_File_Name}, and
4798 most importantly, once pragma Source_File_Name_Project appears,
4799 no further Source_File_Name pragmas are allowed.
4800
4801 The intention is that Source_File_Name_Project pragmas are always
4802 generated by the Project Manager in a manner consistent with the naming
4803 specified in a project file, and when naming is controlled in this manner,
4804 it is not permissible to attempt to modify this naming scheme using
4805 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4806 known to the project manager).
4807
4808 @node Pragma Source_Reference
4809 @unnumberedsec Pragma Source_Reference
4810 @findex Source_Reference
4811 @noindent
4812 Syntax:
4813
4814 @smallexample @c ada
4815 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4816 @end smallexample
4817
4818 @noindent
4819 This pragma must appear as the first line of a source file.
4820 @var{integer_literal} is the logical line number of the line following
4821 the pragma line (for use in error messages and debugging
4822 information). @var{string_literal} is a static string constant that
4823 specifies the file name to be used in error messages and debugging
4824 information. This is most notably used for the output of @code{gnatchop}
4825 with the @option{-r} switch, to make sure that the original unchopped
4826 source file is the one referred to.
4827
4828 The second argument must be a string literal, it cannot be a static
4829 string expression other than a string literal. This is because its value
4830 is needed for error messages issued by all phases of the compiler.
4831
4832 @node Pragma Static_Elaboration_Desired
4833 @unnumberedsec Pragma Static_Elaboration_Desired
4834 @findex Static_Elaboration_Desired
4835 @noindent
4836 Syntax:
4837
4838 @smallexample @c ada
4839 pragma Static_Elaboration_Desired;
4840 @end smallexample
4841
4842 @noindent
4843 This pragma is used to indicate that the compiler should attempt to initialize
4844 statically the objects declared in the library unit to which the pragma applies,
4845 when these objects are initialized (explicitly or implicitly) by an aggregate.
4846 In the absence of this pragma, aggregates in object declarations are expanded
4847 into assignments and loops, even when the aggregate components are static
4848 constants. When the aggregate is present the compiler builds a static expression
4849 that requires no run-time code, so that the initialized object can be placed in
4850 read-only data space. If the components are not static, or the aggregate has
4851 more that 100 components, the compiler emits a warning that the pragma cannot
4852 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4853 construction of larger aggregates with static components that include an others
4854 choice.)
4855
4856 @node Pragma Stream_Convert
4857 @unnumberedsec Pragma Stream_Convert
4858 @findex Stream_Convert
4859 @noindent
4860 Syntax:
4861
4862 @smallexample @c ada
4863 pragma Stream_Convert (
4864 [Entity =>] type_LOCAL_NAME,
4865 [Read =>] function_NAME,
4866 [Write =>] function_NAME);
4867 @end smallexample
4868
4869 @noindent
4870 This pragma provides an efficient way of providing stream functions for
4871 types defined in packages. Not only is it simpler to use than declaring
4872 the necessary functions with attribute representation clauses, but more
4873 significantly, it allows the declaration to made in such a way that the
4874 stream packages are not loaded unless they are needed. The use of
4875 the Stream_Convert pragma adds no overhead at all, unless the stream
4876 attributes are actually used on the designated type.
4877
4878 The first argument specifies the type for which stream functions are
4879 provided. The second parameter provides a function used to read values
4880 of this type. It must name a function whose argument type may be any
4881 subtype, and whose returned type must be the type given as the first
4882 argument to the pragma.
4883
4884 The meaning of the @var{Read}
4885 parameter is that if a stream attribute directly
4886 or indirectly specifies reading of the type given as the first parameter,
4887 then a value of the type given as the argument to the Read function is
4888 read from the stream, and then the Read function is used to convert this
4889 to the required target type.
4890
4891 Similarly the @var{Write} parameter specifies how to treat write attributes
4892 that directly or indirectly apply to the type given as the first parameter.
4893 It must have an input parameter of the type specified by the first parameter,
4894 and the return type must be the same as the input type of the Read function.
4895 The effect is to first call the Write function to convert to the given stream
4896 type, and then write the result type to the stream.
4897
4898 The Read and Write functions must not be overloaded subprograms. If necessary
4899 renamings can be supplied to meet this requirement.
4900 The usage of this attribute is best illustrated by a simple example, taken
4901 from the GNAT implementation of package Ada.Strings.Unbounded:
4902
4903 @smallexample @c ada
4904 function To_Unbounded (S : String)
4905 return Unbounded_String
4906 renames To_Unbounded_String;
4907
4908 pragma Stream_Convert
4909 (Unbounded_String, To_Unbounded, To_String);
4910 @end smallexample
4911
4912 @noindent
4913 The specifications of the referenced functions, as given in the Ada
4914 Reference Manual are:
4915
4916 @smallexample @c ada
4917 function To_Unbounded_String (Source : String)
4918 return Unbounded_String;
4919
4920 function To_String (Source : Unbounded_String)
4921 return String;
4922 @end smallexample
4923
4924 @noindent
4925 The effect is that if the value of an unbounded string is written to a stream,
4926 then the representation of the item in the stream is in the same format that
4927 would be used for @code{Standard.String'Output}, and this same representation
4928 is expected when a value of this type is read from the stream. Note that the
4929 value written always includes the bounds, even for Unbounded_String'Write,
4930 since Unbounded_String is not an array type.
4931
4932 @node Pragma Style_Checks
4933 @unnumberedsec Pragma Style_Checks
4934 @findex Style_Checks
4935 @noindent
4936 Syntax:
4937
4938 @smallexample @c ada
4939 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4940 On | Off [, LOCAL_NAME]);
4941 @end smallexample
4942
4943 @noindent
4944 This pragma is used in conjunction with compiler switches to control the
4945 built in style checking provided by GNAT@. The compiler switches, if set,
4946 provide an initial setting for the switches, and this pragma may be used
4947 to modify these settings, or the settings may be provided entirely by
4948 the use of the pragma. This pragma can be used anywhere that a pragma
4949 is legal, including use as a configuration pragma (including use in
4950 the @file{gnat.adc} file).
4951
4952 The form with a string literal specifies which style options are to be
4953 activated. These are additive, so they apply in addition to any previously
4954 set style check options. The codes for the options are the same as those
4955 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4956 For example the following two methods can be used to enable
4957 layout checking:
4958
4959 @itemize @bullet
4960 @item
4961 @smallexample @c ada
4962 pragma Style_Checks ("l");
4963 @end smallexample
4964
4965 @item
4966 @smallexample
4967 gcc -c -gnatyl @dots{}
4968 @end smallexample
4969 @end itemize
4970
4971 @noindent
4972 The form ALL_CHECKS activates all standard checks (its use is equivalent
4973 to the use of the @code{gnaty} switch with no options. @xref{Top,
4974 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4975 @value{EDITION} User's Guide}, for details.)
4976
4977 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4978 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4979 options (i.e. equivalent to -gnatyg).
4980
4981 The forms with @code{Off} and @code{On}
4982 can be used to temporarily disable style checks
4983 as shown in the following example:
4984
4985 @smallexample @c ada
4986 @iftex
4987 @leftskip=0cm
4988 @end iftex
4989 pragma Style_Checks ("k"); -- requires keywords in lower case
4990 pragma Style_Checks (Off); -- turn off style checks
4991 NULL; -- this will not generate an error message
4992 pragma Style_Checks (On); -- turn style checks back on
4993 NULL; -- this will generate an error message
4994 @end smallexample
4995
4996 @noindent
4997 Finally the two argument form is allowed only if the first argument is
4998 @code{On} or @code{Off}. The effect is to turn of semantic style checks
4999 for the specified entity, as shown in the following example:
5000
5001 @smallexample @c ada
5002 @iftex
5003 @leftskip=0cm
5004 @end iftex
5005 pragma Style_Checks ("r"); -- require consistency of identifier casing
5006 Arg : Integer;
5007 Rf1 : Integer := ARG; -- incorrect, wrong case
5008 pragma Style_Checks (Off, Arg);
5009 Rf2 : Integer := ARG; -- OK, no error
5010 @end smallexample
5011
5012 @node Pragma Subtitle
5013 @unnumberedsec Pragma Subtitle
5014 @findex Subtitle
5015 @noindent
5016 Syntax:
5017
5018 @smallexample @c ada
5019 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5020 @end smallexample
5021
5022 @noindent
5023 This pragma is recognized for compatibility with other Ada compilers
5024 but is ignored by GNAT@.
5025
5026 @node Pragma Suppress
5027 @unnumberedsec Pragma Suppress
5028 @findex Suppress
5029 @noindent
5030 Syntax:
5031
5032 @smallexample @c ada
5033 pragma Suppress (Identifier [, [On =>] Name]);
5034 @end smallexample
5035
5036 @noindent
5037 This is a standard pragma, and supports all the check names required in
5038 the RM. It is included here because GNAT recognizes one additional check
5039 name: @code{Alignment_Check} which can be used to suppress alignment checks
5040 on addresses used in address clauses. Such checks can also be suppressed
5041 by suppressing range checks, but the specific use of @code{Alignment_Check}
5042 allows suppression of alignment checks without suppressing other range checks.
5043
5044 Note that pragma Suppress gives the compiler permission to omit
5045 checks, but does not require the compiler to omit checks. The compiler
5046 will generate checks if they are essentially free, even when they are
5047 suppressed. In particular, if the compiler can prove that a certain
5048 check will necessarily fail, it will generate code to do an
5049 unconditional ``raise'', even if checks are suppressed. The compiler
5050 warns in this case.
5051
5052 Of course, run-time checks are omitted whenever the compiler can prove
5053 that they will not fail, whether or not checks are suppressed.
5054
5055 @node Pragma Suppress_All
5056 @unnumberedsec Pragma Suppress_All
5057 @findex Suppress_All
5058 @noindent
5059 Syntax:
5060
5061 @smallexample @c ada
5062 pragma Suppress_All;
5063 @end smallexample
5064
5065 @noindent
5066 This pragma can appear anywhere within a unit.
5067 The effect is to apply @code{Suppress (All_Checks)} to the unit
5068 in which it appears. This pragma is implemented for compatibility with DEC
5069 Ada 83 usage where it appears at the end of a unit, and for compatibility
5070 with Rational Ada, where it appears as a program unit pragma.
5071 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5072 as a normal configuration pragma is the preferred usage in GNAT@.
5073
5074 @node Pragma Suppress_Exception_Locations
5075 @unnumberedsec Pragma Suppress_Exception_Locations
5076 @findex Suppress_Exception_Locations
5077 @noindent
5078 Syntax:
5079
5080 @smallexample @c ada
5081 pragma Suppress_Exception_Locations;
5082 @end smallexample
5083
5084 @noindent
5085 In normal mode, a raise statement for an exception by default generates
5086 an exception message giving the file name and line number for the location
5087 of the raise. This is useful for debugging and logging purposes, but this
5088 entails extra space for the strings for the messages. The configuration
5089 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5090 generation of these strings, with the result that space is saved, but the
5091 exception message for such raises is null. This configuration pragma may
5092 appear in a global configuration pragma file, or in a specific unit as
5093 usual. It is not required that this pragma be used consistently within
5094 a partition, so it is fine to have some units within a partition compiled
5095 with this pragma and others compiled in normal mode without it.
5096
5097 @node Pragma Suppress_Initialization
5098 @unnumberedsec Pragma Suppress_Initialization
5099 @findex Suppress_Initialization
5100 @cindex Suppressing initialization
5101 @cindex Initialization, suppression of
5102 @noindent
5103 Syntax:
5104
5105 @smallexample @c ada
5106 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5107 @end smallexample
5108
5109 @noindent
5110 Here subtype_Name is the name introduced by a type declaration
5111 or subtype declaration.
5112 This pragma suppresses any implicit or explicit initialization
5113 for all variables of the given type or subtype,
5114 including initialization resulting from the use of pragmas
5115 Normalize_Scalars or Initialize_Scalars.
5116
5117 This is considered a representation item, so it cannot be given after
5118 the type is frozen. It applies to all subsequent object declarations,
5119 and also any allocator that creates objects of the type.
5120
5121 If the pragma is given for the first subtype, then it is considered
5122 to apply to the base type and all its subtypes. If the pragma is given
5123 for other than a first subtype, then it applies only to the given subtype.
5124 The pragma may not be given after the type is frozen.
5125
5126 @node Pragma Task_Info
5127 @unnumberedsec Pragma Task_Info
5128 @findex Task_Info
5129 @noindent
5130 Syntax
5131
5132 @smallexample @c ada
5133 pragma Task_Info (EXPRESSION);
5134 @end smallexample
5135
5136 @noindent
5137 This pragma appears within a task definition (like pragma
5138 @code{Priority}) and applies to the task in which it appears. The
5139 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5140 The @code{Task_Info} pragma provides system dependent control over
5141 aspects of tasking implementation, for example, the ability to map
5142 tasks to specific processors. For details on the facilities available
5143 for the version of GNAT that you are using, see the documentation
5144 in the spec of package System.Task_Info in the runtime
5145 library.
5146
5147 @node Pragma Task_Name
5148 @unnumberedsec Pragma Task_Name
5149 @findex Task_Name
5150 @noindent
5151 Syntax
5152
5153 @smallexample @c ada
5154 pragma Task_Name (string_EXPRESSION);
5155 @end smallexample
5156
5157 @noindent
5158 This pragma appears within a task definition (like pragma
5159 @code{Priority}) and applies to the task in which it appears. The
5160 argument must be of type String, and provides a name to be used for
5161 the task instance when the task is created. Note that this expression
5162 is not required to be static, and in particular, it can contain
5163 references to task discriminants. This facility can be used to
5164 provide different names for different tasks as they are created,
5165 as illustrated in the example below.
5166
5167 The task name is recorded internally in the run-time structures
5168 and is accessible to tools like the debugger. In addition the
5169 routine @code{Ada.Task_Identification.Image} will return this
5170 string, with a unique task address appended.
5171
5172 @smallexample @c ada
5173 -- Example of the use of pragma Task_Name
5174
5175 with Ada.Task_Identification;
5176 use Ada.Task_Identification;
5177 with Text_IO; use Text_IO;
5178 procedure t3 is
5179
5180 type Astring is access String;
5181
5182 task type Task_Typ (Name : access String) is
5183 pragma Task_Name (Name.all);
5184 end Task_Typ;
5185
5186 task body Task_Typ is
5187 Nam : constant String := Image (Current_Task);
5188 begin
5189 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5190 end Task_Typ;
5191
5192 type Ptr_Task is access Task_Typ;
5193 Task_Var : Ptr_Task;
5194
5195 begin
5196 Task_Var :=
5197 new Task_Typ (new String'("This is task 1"));
5198 Task_Var :=
5199 new Task_Typ (new String'("This is task 2"));
5200 end;
5201 @end smallexample
5202
5203 @node Pragma Task_Storage
5204 @unnumberedsec Pragma Task_Storage
5205 @findex Task_Storage
5206 Syntax:
5207
5208 @smallexample @c ada
5209 pragma Task_Storage (
5210 [Task_Type =>] LOCAL_NAME,
5211 [Top_Guard =>] static_integer_EXPRESSION);
5212 @end smallexample
5213
5214 @noindent
5215 This pragma specifies the length of the guard area for tasks. The guard
5216 area is an additional storage area allocated to a task. A value of zero
5217 means that either no guard area is created or a minimal guard area is
5218 created, depending on the target. This pragma can appear anywhere a
5219 @code{Storage_Size} attribute definition clause is allowed for a task
5220 type.
5221
5222 @node Pragma Test_Case
5223 @unnumberedsec Pragma Test_Case
5224 @cindex Test cases
5225 @findex Test_Case
5226 @noindent
5227 Syntax:
5228
5229 @smallexample @c ada
5230 pragma Test_Case (
5231 [Name =>] static_string_Expression
5232 ,[Mode =>] (Nominal | Robustness)
5233 [, Requires => Boolean_Expression]
5234 [, Ensures => Boolean_Expression]);
5235 @end smallexample
5236
5237 @noindent
5238 The @code{Test_Case} pragma allows defining fine-grain specifications
5239 for use by testing and verification tools. The compiler checks its
5240 validity but the presence of pragma @code{Test_Case} does not lead to
5241 any modification of the code generated by the compiler.
5242
5243 @code{Test_Case} pragmas may only appear immediately following the
5244 (separate) declaration of a subprogram in a package declaration, inside
5245 a package spec unit. Only other pragmas may intervene (that is appear
5246 between the subprogram declaration and a test case).
5247
5248 The compiler checks that boolean expressions given in @code{Requires} and
5249 @code{Ensures} are valid, where the rules for @code{Requires} are the
5250 same as the rule for an expression in @code{Precondition} and the rules
5251 for @code{Ensures} are the same as the rule for an expression in
5252 @code{Postcondition}. In particular, attributes @code{'Old} and
5253 @code{'Result} can only be used within the @code{Ensures}
5254 expression. The following is an example of use within a package spec:
5255
5256 @smallexample @c ada
5257 package Math_Functions is
5258 ...
5259 function Sqrt (Arg : Float) return Float;
5260 pragma Test_Case (Name => "Test 1",
5261 Mode => Nominal,
5262 Requires => Arg < 100,
5263 Ensures => Sqrt'Result < 10);
5264 ...
5265 end Math_Functions;
5266 @end smallexample
5267
5268 @noindent
5269 The meaning of a test case is that, if the associated subprogram is
5270 executed in a context where @code{Requires} holds, then @code{Ensures}
5271 should hold when the subprogram returns. Mode @code{Nominal} indicates
5272 that the input context should satisfy the precondition of the
5273 subprogram, and the output context should then satisfy its
5274 postcondition. More @code{Robustness} indicates that the pre- and
5275 postcondition of the subprogram should be ignored for this test case.
5276
5277 @node Pragma Thread_Local_Storage
5278 @unnumberedsec Pragma Thread_Local_Storage
5279 @findex Thread_Local_Storage
5280 @cindex Task specific storage
5281 @cindex TLS (Thread Local Storage)
5282 Syntax:
5283
5284 @smallexample @c ada
5285 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5286 @end smallexample
5287
5288 @noindent
5289 This pragma specifies that the specified entity, which must be
5290 a variable declared in a library level package, is to be marked as
5291 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5292 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5293 (and hence each Ada task) to see a distinct copy of the variable.
5294
5295 The variable may not have default initialization, and if there is
5296 an explicit initialization, it must be either @code{null} for an
5297 access variable, or a static expression for a scalar variable.
5298 This provides a low level mechanism similar to that provided by
5299 the @code{Ada.Task_Attributes} package, but much more efficient
5300 and is also useful in writing interface code that will interact
5301 with foreign threads.
5302
5303 If this pragma is used on a system where @code{TLS} is not supported,
5304 then an error message will be generated and the program will be rejected.
5305
5306 @node Pragma Time_Slice
5307 @unnumberedsec Pragma Time_Slice
5308 @findex Time_Slice
5309 @noindent
5310 Syntax:
5311
5312 @smallexample @c ada
5313 pragma Time_Slice (static_duration_EXPRESSION);
5314 @end smallexample
5315
5316 @noindent
5317 For implementations of GNAT on operating systems where it is possible
5318 to supply a time slice value, this pragma may be used for this purpose.
5319 It is ignored if it is used in a system that does not allow this control,
5320 or if it appears in other than the main program unit.
5321 @cindex OpenVMS
5322 Note that the effect of this pragma is identical to the effect of the
5323 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5324
5325 @node Pragma Title
5326 @unnumberedsec Pragma Title
5327 @findex Title
5328 @noindent
5329 Syntax:
5330
5331 @smallexample @c ada
5332 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5333
5334 TITLING_OPTION ::=
5335 [Title =>] STRING_LITERAL,
5336 | [Subtitle =>] STRING_LITERAL
5337 @end smallexample
5338
5339 @noindent
5340 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5341 pragma used in DEC Ada 83 implementations to provide a title and/or
5342 subtitle for the program listing. The program listing generated by GNAT
5343 does not have titles or subtitles.
5344
5345 Unlike other pragmas, the full flexibility of named notation is allowed
5346 for this pragma, i.e.@: the parameters may be given in any order if named
5347 notation is used, and named and positional notation can be mixed
5348 following the normal rules for procedure calls in Ada.
5349
5350 @node Pragma Unchecked_Union
5351 @unnumberedsec Pragma Unchecked_Union
5352 @cindex Unions in C
5353 @findex Unchecked_Union
5354 @noindent
5355 Syntax:
5356
5357 @smallexample @c ada
5358 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5359 @end smallexample
5360
5361 @noindent
5362 This pragma is used to specify a representation of a record type that is
5363 equivalent to a C union. It was introduced as a GNAT implementation defined
5364 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5365 pragma, making it language defined, and GNAT fully implements this extended
5366 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5367 details, consult the Ada 2005 Reference Manual, section B.3.3.
5368
5369 @node Pragma Unimplemented_Unit
5370 @unnumberedsec Pragma Unimplemented_Unit
5371 @findex Unimplemented_Unit
5372 @noindent
5373 Syntax:
5374
5375 @smallexample @c ada
5376 pragma Unimplemented_Unit;
5377 @end smallexample
5378
5379 @noindent
5380 If this pragma occurs in a unit that is processed by the compiler, GNAT
5381 aborts with the message @samp{@var{xxx} not implemented}, where
5382 @var{xxx} is the name of the current compilation unit. This pragma is
5383 intended to allow the compiler to handle unimplemented library units in
5384 a clean manner.
5385
5386 The abort only happens if code is being generated. Thus you can use
5387 specs of unimplemented packages in syntax or semantic checking mode.
5388
5389 @node Pragma Universal_Aliasing
5390 @unnumberedsec Pragma Universal_Aliasing
5391 @findex Universal_Aliasing
5392 @noindent
5393 Syntax:
5394
5395 @smallexample @c ada
5396 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5397 @end smallexample
5398
5399 @noindent
5400 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5401 declarative part. The effect is to inhibit strict type-based aliasing
5402 optimization for the given type. In other words, the effect is as though
5403 access types designating this type were subject to pragma No_Strict_Aliasing.
5404 For a detailed description of the strict aliasing optimization, and the
5405 situations in which it must be suppressed, @xref{Optimization and Strict
5406 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5407
5408 @node Pragma Universal_Data
5409 @unnumberedsec Pragma Universal_Data
5410 @findex Universal_Data
5411 @noindent
5412 Syntax:
5413
5414 @smallexample @c ada
5415 pragma Universal_Data [(library_unit_Name)];
5416 @end smallexample
5417
5418 @noindent
5419 This pragma is supported only for the AAMP target and is ignored for
5420 other targets. The pragma specifies that all library-level objects
5421 (Counter 0 data) associated with the library unit are to be accessed
5422 and updated using universal addressing (24-bit addresses for AAMP5)
5423 rather than the default of 16-bit Data Environment (DENV) addressing.
5424 Use of this pragma will generally result in less efficient code for
5425 references to global data associated with the library unit, but
5426 allows such data to be located anywhere in memory. This pragma is
5427 a library unit pragma, but can also be used as a configuration pragma
5428 (including use in the @file{gnat.adc} file). The functionality
5429 of this pragma is also available by applying the -univ switch on the
5430 compilations of units where universal addressing of the data is desired.
5431
5432 @node Pragma Unmodified
5433 @unnumberedsec Pragma Unmodified
5434 @findex Unmodified
5435 @cindex Warnings, unmodified
5436 @noindent
5437 Syntax:
5438
5439 @smallexample @c ada
5440 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5441 @end smallexample
5442
5443 @noindent
5444 This pragma signals that the assignable entities (variables,
5445 @code{out} parameters, @code{in out} parameters) whose names are listed are
5446 deliberately not assigned in the current source unit. This
5447 suppresses warnings about the
5448 entities being referenced but not assigned, and in addition a warning will be
5449 generated if one of these entities is in fact assigned in the
5450 same unit as the pragma (or in the corresponding body, or one
5451 of its subunits).
5452
5453 This is particularly useful for clearly signaling that a particular
5454 parameter is not modified, even though the spec suggests that it might
5455 be.
5456
5457 @node Pragma Unreferenced
5458 @unnumberedsec Pragma Unreferenced
5459 @findex Unreferenced
5460 @cindex Warnings, unreferenced
5461 @noindent
5462 Syntax:
5463
5464 @smallexample @c ada
5465 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5466 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5467 @end smallexample
5468
5469 @noindent
5470 This pragma signals that the entities whose names are listed are
5471 deliberately not referenced in the current source unit. This
5472 suppresses warnings about the
5473 entities being unreferenced, and in addition a warning will be
5474 generated if one of these entities is in fact subsequently referenced in the
5475 same unit as the pragma (or in the corresponding body, or one
5476 of its subunits).
5477
5478 This is particularly useful for clearly signaling that a particular
5479 parameter is not referenced in some particular subprogram implementation
5480 and that this is deliberate. It can also be useful in the case of
5481 objects declared only for their initialization or finalization side
5482 effects.
5483
5484 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5485 current scope, then the entity most recently declared is the one to which
5486 the pragma applies. Note that in the case of accept formals, the pragma
5487 Unreferenced may appear immediately after the keyword @code{do} which
5488 allows the indication of whether or not accept formals are referenced
5489 or not to be given individually for each accept statement.
5490
5491 The left hand side of an assignment does not count as a reference for the
5492 purpose of this pragma. Thus it is fine to assign to an entity for which
5493 pragma Unreferenced is given.
5494
5495 Note that if a warning is desired for all calls to a given subprogram,
5496 regardless of whether they occur in the same unit as the subprogram
5497 declaration, then this pragma should not be used (calls from another
5498 unit would not be flagged); pragma Obsolescent can be used instead
5499 for this purpose, see @xref{Pragma Obsolescent}.
5500
5501 The second form of pragma @code{Unreferenced} is used within a context
5502 clause. In this case the arguments must be unit names of units previously
5503 mentioned in @code{with} clauses (similar to the usage of pragma
5504 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5505 units and unreferenced entities within these units.
5506
5507 @node Pragma Unreferenced_Objects
5508 @unnumberedsec Pragma Unreferenced_Objects
5509 @findex Unreferenced_Objects
5510 @cindex Warnings, unreferenced
5511 @noindent
5512 Syntax:
5513
5514 @smallexample @c ada
5515 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5516 @end smallexample
5517
5518 @noindent
5519 This pragma signals that for the types or subtypes whose names are
5520 listed, objects which are declared with one of these types or subtypes may
5521 not be referenced, and if no references appear, no warnings are given.
5522
5523 This is particularly useful for objects which are declared solely for their
5524 initialization and finalization effect. Such variables are sometimes referred
5525 to as RAII variables (Resource Acquisition Is Initialization). Using this
5526 pragma on the relevant type (most typically a limited controlled type), the
5527 compiler will automatically suppress unwanted warnings about these variables
5528 not being referenced.
5529
5530 @node Pragma Unreserve_All_Interrupts
5531 @unnumberedsec Pragma Unreserve_All_Interrupts
5532 @findex Unreserve_All_Interrupts
5533 @noindent
5534 Syntax:
5535
5536 @smallexample @c ada
5537 pragma Unreserve_All_Interrupts;
5538 @end smallexample
5539
5540 @noindent
5541 Normally certain interrupts are reserved to the implementation. Any attempt
5542 to attach an interrupt causes Program_Error to be raised, as described in
5543 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
5544 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
5545 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5546 interrupt execution.
5547
5548 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5549 a program, then all such interrupts are unreserved. This allows the
5550 program to handle these interrupts, but disables their standard
5551 functions. For example, if this pragma is used, then pressing
5552 @kbd{Ctrl-C} will not automatically interrupt execution. However,
5553 a program can then handle the @code{SIGINT} interrupt as it chooses.
5554
5555 For a full list of the interrupts handled in a specific implementation,
5556 see the source code for the spec of @code{Ada.Interrupts.Names} in
5557 file @file{a-intnam.ads}. This is a target dependent file that contains the
5558 list of interrupts recognized for a given target. The documentation in
5559 this file also specifies what interrupts are affected by the use of
5560 the @code{Unreserve_All_Interrupts} pragma.
5561
5562 For a more general facility for controlling what interrupts can be
5563 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5564 of the @code{Unreserve_All_Interrupts} pragma.
5565
5566 @node Pragma Unsuppress
5567 @unnumberedsec Pragma Unsuppress
5568 @findex Unsuppress
5569 @noindent
5570 Syntax:
5571
5572 @smallexample @c ada
5573 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5574 @end smallexample
5575
5576 @noindent
5577 This pragma undoes the effect of a previous pragma @code{Suppress}. If
5578 there is no corresponding pragma @code{Suppress} in effect, it has no
5579 effect. The range of the effect is the same as for pragma
5580 @code{Suppress}. The meaning of the arguments is identical to that used
5581 in pragma @code{Suppress}.
5582
5583 One important application is to ensure that checks are on in cases where
5584 code depends on the checks for its correct functioning, so that the code
5585 will compile correctly even if the compiler switches are set to suppress
5586 checks.
5587
5588 @node Pragma Use_VADS_Size
5589 @unnumberedsec Pragma Use_VADS_Size
5590 @cindex @code{Size}, VADS compatibility
5591 @findex Use_VADS_Size
5592 @noindent
5593 Syntax:
5594
5595 @smallexample @c ada
5596 pragma Use_VADS_Size;
5597 @end smallexample
5598
5599 @noindent
5600 This is a configuration pragma. In a unit to which it applies, any use
5601 of the 'Size attribute is automatically interpreted as a use of the
5602 'VADS_Size attribute. Note that this may result in incorrect semantic
5603 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
5604 the handling of existing code which depends on the interpretation of Size
5605 as implemented in the VADS compiler. See description of the VADS_Size
5606 attribute for further details.
5607
5608 @node Pragma Validity_Checks
5609 @unnumberedsec Pragma Validity_Checks
5610 @findex Validity_Checks
5611 @noindent
5612 Syntax:
5613
5614 @smallexample @c ada
5615 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5616 @end smallexample
5617
5618 @noindent
5619 This pragma is used in conjunction with compiler switches to control the
5620 built-in validity checking provided by GNAT@. The compiler switches, if set
5621 provide an initial setting for the switches, and this pragma may be used
5622 to modify these settings, or the settings may be provided entirely by
5623 the use of the pragma. This pragma can be used anywhere that a pragma
5624 is legal, including use as a configuration pragma (including use in
5625 the @file{gnat.adc} file).
5626
5627 The form with a string literal specifies which validity options are to be
5628 activated. The validity checks are first set to include only the default
5629 reference manual settings, and then a string of letters in the string
5630 specifies the exact set of options required. The form of this string
5631 is exactly as described for the @option{-gnatVx} compiler switch (see the
5632 GNAT users guide for details). For example the following two methods
5633 can be used to enable validity checking for mode @code{in} and
5634 @code{in out} subprogram parameters:
5635
5636 @itemize @bullet
5637 @item
5638 @smallexample @c ada
5639 pragma Validity_Checks ("im");
5640 @end smallexample
5641
5642 @item
5643 @smallexample
5644 gcc -c -gnatVim @dots{}
5645 @end smallexample
5646 @end itemize
5647
5648 @noindent
5649 The form ALL_CHECKS activates all standard checks (its use is equivalent
5650 to the use of the @code{gnatva} switch.
5651
5652 The forms with @code{Off} and @code{On}
5653 can be used to temporarily disable validity checks
5654 as shown in the following example:
5655
5656 @smallexample @c ada
5657 @iftex
5658 @leftskip=0cm
5659 @end iftex
5660 pragma Validity_Checks ("c"); -- validity checks for copies
5661 pragma Validity_Checks (Off); -- turn off validity checks
5662 A := B; -- B will not be validity checked
5663 pragma Validity_Checks (On); -- turn validity checks back on
5664 A := C; -- C will be validity checked
5665 @end smallexample
5666
5667 @node Pragma Volatile
5668 @unnumberedsec Pragma Volatile
5669 @findex Volatile
5670 @noindent
5671 Syntax:
5672
5673 @smallexample @c ada
5674 pragma Volatile (LOCAL_NAME);
5675 @end smallexample
5676
5677 @noindent
5678 This pragma is defined by the Ada Reference Manual, and the GNAT
5679 implementation is fully conformant with this definition. The reason it
5680 is mentioned in this section is that a pragma of the same name was supplied
5681 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
5682 implementation of pragma Volatile is upwards compatible with the
5683 implementation in DEC Ada 83.
5684
5685 @node Pragma Warnings
5686 @unnumberedsec Pragma Warnings
5687 @findex Warnings
5688 @noindent
5689 Syntax:
5690
5691 @smallexample @c ada
5692 pragma Warnings (On | Off);
5693 pragma Warnings (On | Off, LOCAL_NAME);
5694 pragma Warnings (static_string_EXPRESSION);
5695 pragma Warnings (On | Off, static_string_EXPRESSION);
5696 @end smallexample
5697
5698 @noindent
5699 Normally warnings are enabled, with the output being controlled by
5700 the command line switch. Warnings (@code{Off}) turns off generation of
5701 warnings until a Warnings (@code{On}) is encountered or the end of the
5702 current unit. If generation of warnings is turned off using this
5703 pragma, then no warning messages are output, regardless of the
5704 setting of the command line switches.
5705
5706 The form with a single argument may be used as a configuration pragma.
5707
5708 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5709 the specified entity. This suppression is effective from the point where
5710 it occurs till the end of the extended scope of the variable (similar to
5711 the scope of @code{Suppress}).
5712
5713 The form with a single static_string_EXPRESSION argument provides more precise
5714 control over which warnings are active. The string is a list of letters
5715 specifying which warnings are to be activated and which deactivated. The
5716 code for these letters is the same as the string used in the command
5717 line switch controlling warnings. For a brief summary, use the gnatmake
5718 command with no arguments, which will generate usage information containing
5719 the list of warnings switches supported. For
5720 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5721 User's Guide}.
5722
5723 @noindent
5724 The specified warnings will be in effect until the end of the program
5725 or another pragma Warnings is encountered. The effect of the pragma is
5726 cumulative. Initially the set of warnings is the standard default set
5727 as possibly modified by compiler switches. Then each pragma Warning
5728 modifies this set of warnings as specified. This form of the pragma may
5729 also be used as a configuration pragma.
5730
5731 The fourth form, with an @code{On|Off} parameter and a string, is used to
5732 control individual messages, based on their text. The string argument
5733 is a pattern that is used to match against the text of individual
5734 warning messages (not including the initial "warning: " tag).
5735
5736 The pattern may contain asterisks, which match zero or more characters in
5737 the message. For example, you can use
5738 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5739 message @code{warning: 960 bits of "a" unused}. No other regular
5740 expression notations are permitted. All characters other than asterisk in
5741 these three specific cases are treated as literal characters in the match.
5742
5743 There are two ways to use the pragma in this form. The OFF form can be used as a
5744 configuration pragma. The effect is to suppress all warnings (if any)
5745 that match the pattern string throughout the compilation.
5746
5747 The second usage is to suppress a warning locally, and in this case, two
5748 pragmas must appear in sequence:
5749
5750 @smallexample @c ada
5751 pragma Warnings (Off, Pattern);
5752 @dots{} code where given warning is to be suppressed
5753 pragma Warnings (On, Pattern);
5754 @end smallexample
5755
5756 @noindent
5757 In this usage, the pattern string must match in the Off and On pragmas,
5758 and at least one matching warning must be suppressed.
5759
5760 Note: to write a string that will match any warning, use the string
5761 @code{"***"}. It will not work to use a single asterisk or two asterisks
5762 since this looks like an operator name. This form with three asterisks
5763 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5764 matching @code{pragma Warnings (On, "***")} will be required. This can be
5765 helpful in avoiding forgetting to turn warnings back on.
5766
5767 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5768 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5769 be useful in checking whether obsolete pragmas in existing programs are hiding
5770 real problems.
5771
5772 Note: pragma Warnings does not affect the processing of style messages. See
5773 separate entry for pragma Style_Checks for control of style messages.
5774
5775 @node Pragma Weak_External
5776 @unnumberedsec Pragma Weak_External
5777 @findex Weak_External
5778 @noindent
5779 Syntax:
5780
5781 @smallexample @c ada
5782 pragma Weak_External ([Entity =>] LOCAL_NAME);
5783 @end smallexample
5784
5785 @noindent
5786 @var{LOCAL_NAME} must refer to an object that is declared at the library
5787 level. This pragma specifies that the given entity should be marked as a
5788 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5789 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5790 of a regular symbol, that is to say a symbol that does not have to be
5791 resolved by the linker if used in conjunction with a pragma Import.
5792
5793 When a weak symbol is not resolved by the linker, its address is set to
5794 zero. This is useful in writing interfaces to external modules that may
5795 or may not be linked in the final executable, for example depending on
5796 configuration settings.
5797
5798 If a program references at run time an entity to which this pragma has been
5799 applied, and the corresponding symbol was not resolved at link time, then
5800 the execution of the program is erroneous. It is not erroneous to take the
5801 Address of such an entity, for example to guard potential references,
5802 as shown in the example below.
5803
5804 Some file formats do not support weak symbols so not all target machines
5805 support this pragma.
5806
5807 @smallexample @c ada
5808 -- Example of the use of pragma Weak_External
5809
5810 package External_Module is
5811 key : Integer;
5812 pragma Import (C, key);
5813 pragma Weak_External (key);
5814 function Present return boolean;
5815 end External_Module;
5816
5817 with System; use System;
5818 package body External_Module is
5819 function Present return boolean is
5820 begin
5821 return key'Address /= System.Null_Address;
5822 end Present;
5823 end External_Module;
5824 @end smallexample
5825
5826 @node Pragma Wide_Character_Encoding
5827 @unnumberedsec Pragma Wide_Character_Encoding
5828 @findex Wide_Character_Encoding
5829 @noindent
5830 Syntax:
5831
5832 @smallexample @c ada
5833 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5834 @end smallexample
5835
5836 @noindent
5837 This pragma specifies the wide character encoding to be used in program
5838 source text appearing subsequently. It is a configuration pragma, but may
5839 also be used at any point that a pragma is allowed, and it is permissible
5840 to have more than one such pragma in a file, allowing multiple encodings
5841 to appear within the same file.
5842
5843 The argument can be an identifier or a character literal. In the identifier
5844 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5845 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5846 case it is correspondingly one of the characters @samp{h}, @samp{u},
5847 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5848
5849 Note that when the pragma is used within a file, it affects only the
5850 encoding within that file, and does not affect withed units, specs,
5851 or subunits.
5852
5853 @node Implementation Defined Attributes
5854 @chapter Implementation Defined Attributes
5855 Ada defines (throughout the Ada reference manual,
5856 summarized in Annex K),
5857 a set of attributes that provide useful additional functionality in all
5858 areas of the language. These language defined attributes are implemented
5859 in GNAT and work as described in the Ada Reference Manual.
5860
5861 In addition, Ada allows implementations to define additional
5862 attributes whose meaning is defined by the implementation. GNAT provides
5863 a number of these implementation-dependent attributes which can be used
5864 to extend and enhance the functionality of the compiler. This section of
5865 the GNAT reference manual describes these additional attributes.
5866
5867 Note that any program using these attributes may not be portable to
5868 other compilers (although GNAT implements this set of attributes on all
5869 platforms). Therefore if portability to other compilers is an important
5870 consideration, you should minimize the use of these attributes.
5871
5872 @menu
5873 * Abort_Signal::
5874 * Address_Size::
5875 * Asm_Input::
5876 * Asm_Output::
5877 * AST_Entry::
5878 * Bit::
5879 * Bit_Position::
5880 * Compiler_Version::
5881 * Code_Address::
5882 * Default_Bit_Order::
5883 * Descriptor_Size::
5884 * Elaborated::
5885 * Elab_Body::
5886 * Elab_Spec::
5887 * Elab_Subp_Body::
5888 * Emax::
5889 * Enabled::
5890 * Enum_Rep::
5891 * Enum_Val::
5892 * Epsilon::
5893 * Fixed_Value::
5894 * Has_Access_Values::
5895 * Has_Discriminants::
5896 * Img::
5897 * Integer_Value::
5898 * Invalid_Value::
5899 * Large::
5900 * Machine_Size::
5901 * Mantissa::
5902 * Max_Interrupt_Priority::
5903 * Max_Priority::
5904 * Maximum_Alignment::
5905 * Mechanism_Code::
5906 * Null_Parameter::
5907 * Object_Size::
5908 * Old::
5909 * Passed_By_Reference::
5910 * Pool_Address::
5911 * Range_Length::
5912 * Ref::
5913 * Result::
5914 * Safe_Emax::
5915 * Safe_Large::
5916 * Simple_Storage_Pool::
5917 * Small::
5918 * Storage_Unit::
5919 * Stub_Type::
5920 * System_Allocator_Alignment::
5921 * Target_Name::
5922 * Tick::
5923 * To_Address::
5924 * Type_Class::
5925 * UET_Address::
5926 * Unconstrained_Array::
5927 * Universal_Literal_String::
5928 * Unrestricted_Access::
5929 * VADS_Size::
5930 * Value_Size::
5931 * Wchar_T_Size::
5932 * Word_Size::
5933 @end menu
5934
5935 @node Abort_Signal
5936 @unnumberedsec Abort_Signal
5937 @findex Abort_Signal
5938 @noindent
5939 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5940 prefix) provides the entity for the special exception used to signal
5941 task abort or asynchronous transfer of control. Normally this attribute
5942 should only be used in the tasking runtime (it is highly peculiar, and
5943 completely outside the normal semantics of Ada, for a user program to
5944 intercept the abort exception).
5945
5946 @node Address_Size
5947 @unnumberedsec Address_Size
5948 @cindex Size of @code{Address}
5949 @findex Address_Size
5950 @noindent
5951 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5952 prefix) is a static constant giving the number of bits in an
5953 @code{Address}. It is the same value as System.Address'Size,
5954 but has the advantage of being static, while a direct
5955 reference to System.Address'Size is non-static because Address
5956 is a private type.
5957
5958 @node Asm_Input
5959 @unnumberedsec Asm_Input
5960 @findex Asm_Input
5961 @noindent
5962 The @code{Asm_Input} attribute denotes a function that takes two
5963 parameters. The first is a string, the second is an expression of the
5964 type designated by the prefix. The first (string) argument is required
5965 to be a static expression, and is the constraint for the parameter,
5966 (e.g.@: what kind of register is required). The second argument is the
5967 value to be used as the input argument. The possible values for the
5968 constant are the same as those used in the RTL, and are dependent on
5969 the configuration file used to built the GCC back end.
5970 @ref{Machine Code Insertions}
5971
5972 @node Asm_Output
5973 @unnumberedsec Asm_Output
5974 @findex Asm_Output
5975 @noindent
5976 The @code{Asm_Output} attribute denotes a function that takes two
5977 parameters. The first is a string, the second is the name of a variable
5978 of the type designated by the attribute prefix. The first (string)
5979 argument is required to be a static expression and designates the
5980 constraint for the parameter (e.g.@: what kind of register is
5981 required). The second argument is the variable to be updated with the
5982 result. The possible values for constraint are the same as those used in
5983 the RTL, and are dependent on the configuration file used to build the
5984 GCC back end. If there are no output operands, then this argument may
5985 either be omitted, or explicitly given as @code{No_Output_Operands}.
5986 @ref{Machine Code Insertions}
5987
5988 @node AST_Entry
5989 @unnumberedsec AST_Entry
5990 @cindex OpenVMS
5991 @findex AST_Entry
5992 @noindent
5993 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
5994 the name of an entry, it yields a value of the predefined type AST_Handler
5995 (declared in the predefined package System, as extended by the use of
5996 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
5997 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
5998 Language Reference Manual}, section 9.12a.
5999
6000 @node Bit
6001 @unnumberedsec Bit
6002 @findex Bit
6003 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6004 offset within the storage unit (byte) that contains the first bit of
6005 storage allocated for the object. The value of this attribute is of the
6006 type @code{Universal_Integer}, and is always a non-negative number not
6007 exceeding the value of @code{System.Storage_Unit}.
6008
6009 For an object that is a variable or a constant allocated in a register,
6010 the value is zero. (The use of this attribute does not force the
6011 allocation of a variable to memory).
6012
6013 For an object that is a formal parameter, this attribute applies
6014 to either the matching actual parameter or to a copy of the
6015 matching actual parameter.
6016
6017 For an access object the value is zero. Note that
6018 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6019 designated object. Similarly for a record component
6020 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6021 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6022 are subject to index checks.
6023
6024 This attribute is designed to be compatible with the DEC Ada 83 definition
6025 and implementation of the @code{Bit} attribute.
6026
6027 @node Bit_Position
6028 @unnumberedsec Bit_Position
6029 @findex Bit_Position
6030 @noindent
6031 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6032 of the fields of the record type, yields the bit
6033 offset within the record contains the first bit of
6034 storage allocated for the object. The value of this attribute is of the
6035 type @code{Universal_Integer}. The value depends only on the field
6036 @var{C} and is independent of the alignment of
6037 the containing record @var{R}.
6038
6039 @node Compiler_Version
6040 @unnumberedsec Compiler_Version
6041 @findex Compiler_Version
6042 @noindent
6043 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6044 prefix) yields a static string identifying the version of the compiler
6045 being used to compile the unit containing the attribute reference. A
6046 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6047
6048 @node Code_Address
6049 @unnumberedsec Code_Address
6050 @findex Code_Address
6051 @cindex Subprogram address
6052 @cindex Address of subprogram code
6053 @noindent
6054 The @code{'Address}
6055 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6056 intended effect seems to be to provide
6057 an address value which can be used to call the subprogram by means of
6058 an address clause as in the following example:
6059
6060 @smallexample @c ada
6061 procedure K is @dots{}
6062
6063 procedure L;
6064 for L'Address use K'Address;
6065 pragma Import (Ada, L);
6066 @end smallexample
6067
6068 @noindent
6069 A call to @code{L} is then expected to result in a call to @code{K}@.
6070 In Ada 83, where there were no access-to-subprogram values, this was
6071 a common work-around for getting the effect of an indirect call.
6072 GNAT implements the above use of @code{Address} and the technique
6073 illustrated by the example code works correctly.
6074
6075 However, for some purposes, it is useful to have the address of the start
6076 of the generated code for the subprogram. On some architectures, this is
6077 not necessarily the same as the @code{Address} value described above.
6078 For example, the @code{Address} value may reference a subprogram
6079 descriptor rather than the subprogram itself.
6080
6081 The @code{'Code_Address} attribute, which can only be applied to
6082 subprogram entities, always returns the address of the start of the
6083 generated code of the specified subprogram, which may or may not be
6084 the same value as is returned by the corresponding @code{'Address}
6085 attribute.
6086
6087 @node Default_Bit_Order
6088 @unnumberedsec Default_Bit_Order
6089 @cindex Big endian
6090 @cindex Little endian
6091 @findex Default_Bit_Order
6092 @noindent
6093 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6094 permissible prefix), provides the value @code{System.Default_Bit_Order}
6095 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6096 @code{Low_Order_First}). This is used to construct the definition of
6097 @code{Default_Bit_Order} in package @code{System}.
6098
6099 @node Descriptor_Size
6100 @unnumberedsec Descriptor_Size
6101 @cindex Descriptor
6102 @cindex Dope vector
6103 @findex Descriptor_Size
6104 @noindent
6105 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6106 descriptor allocated for a type. The result is non-zero only for unconstrained
6107 array types and the returned value is of type universal integer. In GNAT, an
6108 array descriptor contains bounds information and is located immediately before
6109 the first element of the array.
6110
6111 @smallexample @c ada
6112 type Unconstr_Array is array (Positive range <>) of Boolean;
6113 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6114 @end smallexample
6115
6116 @noindent
6117 The attribute takes into account any additional padding due to type alignment.
6118 In the example above, the descriptor contains two values of type
6119 @code{Positive} representing the low and high bound. Since @code{Positive} has
6120 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6121 Positive'Size + 2} or 64 bits.
6122
6123 @node Elaborated
6124 @unnumberedsec Elaborated
6125 @findex Elaborated
6126 @noindent
6127 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6128 value is a Boolean which indicates whether or not the given unit has been
6129 elaborated. This attribute is primarily intended for internal use by the
6130 generated code for dynamic elaboration checking, but it can also be used
6131 in user programs. The value will always be True once elaboration of all
6132 units has been completed. An exception is for units which need no
6133 elaboration, the value is always False for such units.
6134
6135 @node Elab_Body
6136 @unnumberedsec Elab_Body
6137 @findex Elab_Body
6138 @noindent
6139 This attribute can only be applied to a program unit name. It returns
6140 the entity for the corresponding elaboration procedure for elaborating
6141 the body of the referenced unit. This is used in the main generated
6142 elaboration procedure by the binder and is not normally used in any
6143 other context. However, there may be specialized situations in which it
6144 is useful to be able to call this elaboration procedure from Ada code,
6145 e.g.@: if it is necessary to do selective re-elaboration to fix some
6146 error.
6147
6148 @node Elab_Spec
6149 @unnumberedsec Elab_Spec
6150 @findex Elab_Spec
6151 @noindent
6152 This attribute can only be applied to a program unit name. It returns
6153 the entity for the corresponding elaboration procedure for elaborating
6154 the spec of the referenced unit. This is used in the main
6155 generated elaboration procedure by the binder and is not normally used
6156 in any other context. However, there may be specialized situations in
6157 which it is useful to be able to call this elaboration procedure from
6158 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6159 some error.
6160
6161 @node Elab_Subp_Body
6162 @unnumberedsec Elab_Subp_Body
6163 @findex Elab_Subp_Body
6164 @noindent
6165 This attribute can only be applied to a library level subprogram
6166 name and is only allowed in CodePeer mode. It returns the entity
6167 for the corresponding elaboration procedure for elaborating the body
6168 of the referenced subprogram unit. This is used in the main generated
6169 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6170 otherwise.
6171
6172 @node Emax
6173 @unnumberedsec Emax
6174 @cindex Ada 83 attributes
6175 @findex Emax
6176 @noindent
6177 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6178 the Ada 83 reference manual for an exact description of the semantics of
6179 this attribute.
6180
6181 @node Enabled
6182 @unnumberedsec Enabled
6183 @findex Enabled
6184 @noindent
6185 The @code{Enabled} attribute allows an application program to check at compile
6186 time to see if the designated check is currently enabled. The prefix is a
6187 simple identifier, referencing any predefined check name (other than
6188 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6189 no argument is given for the attribute, the check is for the general state
6190 of the check, if an argument is given, then it is an entity name, and the
6191 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6192 given naming the entity (if not, then the argument is ignored).
6193
6194 Note that instantiations inherit the check status at the point of the
6195 instantiation, so a useful idiom is to have a library package that
6196 introduces a check name with @code{pragma Check_Name}, and then contains
6197 generic packages or subprograms which use the @code{Enabled} attribute
6198 to see if the check is enabled. A user of this package can then issue
6199 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6200 the package or subprogram, controlling whether the check will be present.
6201
6202 @node Enum_Rep
6203 @unnumberedsec Enum_Rep
6204 @cindex Representation of enums
6205 @findex Enum_Rep
6206 @noindent
6207 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6208 function with the following spec:
6209
6210 @smallexample @c ada
6211 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6212 return @i{Universal_Integer};
6213 @end smallexample
6214
6215 @noindent
6216 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6217 enumeration type or to a non-overloaded enumeration
6218 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6219 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6220 enumeration literal or object.
6221
6222 The function returns the representation value for the given enumeration
6223 value. This will be equal to value of the @code{Pos} attribute in the
6224 absence of an enumeration representation clause. This is a static
6225 attribute (i.e.@: the result is static if the argument is static).
6226
6227 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6228 in which case it simply returns the integer value. The reason for this
6229 is to allow it to be used for @code{(<>)} discrete formal arguments in
6230 a generic unit that can be instantiated with either enumeration types
6231 or integer types. Note that if @code{Enum_Rep} is used on a modular
6232 type whose upper bound exceeds the upper bound of the largest signed
6233 integer type, and the argument is a variable, so that the universal
6234 integer calculation is done at run time, then the call to @code{Enum_Rep}
6235 may raise @code{Constraint_Error}.
6236
6237 @node Enum_Val
6238 @unnumberedsec Enum_Val
6239 @cindex Representation of enums
6240 @findex Enum_Val
6241 @noindent
6242 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6243 function with the following spec:
6244
6245 @smallexample @c ada
6246 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6247 return @var{S}'Base};
6248 @end smallexample
6249
6250 @noindent
6251 The function returns the enumeration value whose representation matches the
6252 argument, or raises Constraint_Error if no enumeration literal of the type
6253 has the matching value.
6254 This will be equal to value of the @code{Val} attribute in the
6255 absence of an enumeration representation clause. This is a static
6256 attribute (i.e.@: the result is static if the argument is static).
6257
6258 @node Epsilon
6259 @unnumberedsec Epsilon
6260 @cindex Ada 83 attributes
6261 @findex Epsilon
6262 @noindent
6263 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6264 the Ada 83 reference manual for an exact description of the semantics of
6265 this attribute.
6266
6267 @node Fixed_Value
6268 @unnumberedsec Fixed_Value
6269 @findex Fixed_Value
6270 @noindent
6271 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6272 function with the following specification:
6273
6274 @smallexample @c ada
6275 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6276 return @var{S};
6277 @end smallexample
6278
6279 @noindent
6280 The value returned is the fixed-point value @var{V} such that
6281
6282 @smallexample @c ada
6283 @var{V} = Arg * @var{S}'Small
6284 @end smallexample
6285
6286 @noindent
6287 The effect is thus similar to first converting the argument to the
6288 integer type used to represent @var{S}, and then doing an unchecked
6289 conversion to the fixed-point type. The difference is
6290 that there are full range checks, to ensure that the result is in range.
6291 This attribute is primarily intended for use in implementation of the
6292 input-output functions for fixed-point values.
6293
6294 @node Has_Access_Values
6295 @unnumberedsec Has_Access_Values
6296 @cindex Access values, testing for
6297 @findex Has_Access_Values
6298 @noindent
6299 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6300 is a Boolean value which is True if the is an access type, or is a composite
6301 type with a component (at any nesting depth) that is an access type, and is
6302 False otherwise.
6303 The intended use of this attribute is in conjunction with generic
6304 definitions. If the attribute is applied to a generic private type, it
6305 indicates whether or not the corresponding actual type has access values.
6306
6307 @node Has_Discriminants
6308 @unnumberedsec Has_Discriminants
6309 @cindex Discriminants, testing for
6310 @findex Has_Discriminants
6311 @noindent
6312 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6313 is a Boolean value which is True if the type has discriminants, and False
6314 otherwise. The intended use of this attribute is in conjunction with generic
6315 definitions. If the attribute is applied to a generic private type, it
6316 indicates whether or not the corresponding actual type has discriminants.
6317
6318 @node Img
6319 @unnumberedsec Img
6320 @findex Img
6321 @noindent
6322 The @code{Img} attribute differs from @code{Image} in that it may be
6323 applied to objects as well as types, in which case it gives the
6324 @code{Image} for the subtype of the object. This is convenient for
6325 debugging:
6326
6327 @smallexample @c ada
6328 Put_Line ("X = " & X'Img);
6329 @end smallexample
6330
6331 @noindent
6332 has the same meaning as the more verbose:
6333
6334 @smallexample @c ada
6335 Put_Line ("X = " & @var{T}'Image (X));
6336 @end smallexample
6337
6338 @noindent
6339 where @var{T} is the (sub)type of the object @code{X}.
6340
6341 @node Integer_Value
6342 @unnumberedsec Integer_Value
6343 @findex Integer_Value
6344 @noindent
6345 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6346 function with the following spec:
6347
6348 @smallexample @c ada
6349 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6350 return @var{S};
6351 @end smallexample
6352
6353 @noindent
6354 The value returned is the integer value @var{V}, such that
6355
6356 @smallexample @c ada
6357 Arg = @var{V} * @var{T}'Small
6358 @end smallexample
6359
6360 @noindent
6361 where @var{T} is the type of @code{Arg}.
6362 The effect is thus similar to first doing an unchecked conversion from
6363 the fixed-point type to its corresponding implementation type, and then
6364 converting the result to the target integer type. The difference is
6365 that there are full range checks, to ensure that the result is in range.
6366 This attribute is primarily intended for use in implementation of the
6367 standard input-output functions for fixed-point values.
6368
6369 @node Invalid_Value
6370 @unnumberedsec Invalid_Value
6371 @findex Invalid_Value
6372 @noindent
6373 For every scalar type S, S'Invalid_Value returns an undefined value of the
6374 type. If possible this value is an invalid representation for the type. The
6375 value returned is identical to the value used to initialize an otherwise
6376 uninitialized value of the type if pragma Initialize_Scalars is used,
6377 including the ability to modify the value with the binder -Sxx flag and
6378 relevant environment variables at run time.
6379
6380 @node Large
6381 @unnumberedsec Large
6382 @cindex Ada 83 attributes
6383 @findex Large
6384 @noindent
6385 The @code{Large} attribute is provided for compatibility with Ada 83. See
6386 the Ada 83 reference manual for an exact description of the semantics of
6387 this attribute.
6388
6389 @node Machine_Size
6390 @unnumberedsec Machine_Size
6391 @findex Machine_Size
6392 @noindent
6393 This attribute is identical to the @code{Object_Size} attribute. It is
6394 provided for compatibility with the DEC Ada 83 attribute of this name.
6395
6396 @node Mantissa
6397 @unnumberedsec Mantissa
6398 @cindex Ada 83 attributes
6399 @findex Mantissa
6400 @noindent
6401 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
6402 the Ada 83 reference manual for an exact description of the semantics of
6403 this attribute.
6404
6405 @node Max_Interrupt_Priority
6406 @unnumberedsec Max_Interrupt_Priority
6407 @cindex Interrupt priority, maximum
6408 @findex Max_Interrupt_Priority
6409 @noindent
6410 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6411 permissible prefix), provides the same value as
6412 @code{System.Max_Interrupt_Priority}.
6413
6414 @node Max_Priority
6415 @unnumberedsec Max_Priority
6416 @cindex Priority, maximum
6417 @findex Max_Priority
6418 @noindent
6419 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6420 prefix) provides the same value as @code{System.Max_Priority}.
6421
6422 @node Maximum_Alignment
6423 @unnumberedsec Maximum_Alignment
6424 @cindex Alignment, maximum
6425 @findex Maximum_Alignment
6426 @noindent
6427 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6428 permissible prefix) provides the maximum useful alignment value for the
6429 target. This is a static value that can be used to specify the alignment
6430 for an object, guaranteeing that it is properly aligned in all
6431 cases.
6432
6433 @node Mechanism_Code
6434 @unnumberedsec Mechanism_Code
6435 @cindex Return values, passing mechanism
6436 @cindex Parameters, passing mechanism
6437 @findex Mechanism_Code
6438 @noindent
6439 @code{@var{function}'Mechanism_Code} yields an integer code for the
6440 mechanism used for the result of function, and
6441 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6442 used for formal parameter number @var{n} (a static integer value with 1
6443 meaning the first parameter) of @var{subprogram}. The code returned is:
6444
6445 @table @asis
6446 @item 1
6447 by copy (value)
6448 @item 2
6449 by reference
6450 @item 3
6451 by descriptor (default descriptor class)
6452 @item 4
6453 by descriptor (UBS: unaligned bit string)
6454 @item 5
6455 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6456 @item 6
6457 by descriptor (UBA: unaligned bit array)
6458 @item 7
6459 by descriptor (S: string, also scalar access type parameter)
6460 @item 8
6461 by descriptor (SB: string with arbitrary bounds)
6462 @item 9
6463 by descriptor (A: contiguous array)
6464 @item 10
6465 by descriptor (NCA: non-contiguous array)
6466 @end table
6467
6468 @noindent
6469 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6470 @cindex OpenVMS
6471
6472 @node Null_Parameter
6473 @unnumberedsec Null_Parameter
6474 @cindex Zero address, passing
6475 @findex Null_Parameter
6476 @noindent
6477 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6478 type or subtype @var{T} allocated at machine address zero. The attribute
6479 is allowed only as the default expression of a formal parameter, or as
6480 an actual expression of a subprogram call. In either case, the
6481 subprogram must be imported.
6482
6483 The identity of the object is represented by the address zero in the
6484 argument list, independent of the passing mechanism (explicit or
6485 default).
6486
6487 This capability is needed to specify that a zero address should be
6488 passed for a record or other composite object passed by reference.
6489 There is no way of indicating this without the @code{Null_Parameter}
6490 attribute.
6491
6492 @node Object_Size
6493 @unnumberedsec Object_Size
6494 @cindex Size, used for objects
6495 @findex Object_Size
6496 @noindent
6497 The size of an object is not necessarily the same as the size of the type
6498 of an object. This is because by default object sizes are increased to be
6499 a multiple of the alignment of the object. For example,
6500 @code{Natural'Size} is
6501 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6502 Similarly, a record containing an integer and a character:
6503
6504 @smallexample @c ada
6505 type Rec is record
6506 I : Integer;
6507 C : Character;
6508 end record;
6509 @end smallexample
6510
6511 @noindent
6512 will have a size of 40 (that is @code{Rec'Size} will be 40). The
6513 alignment will be 4, because of the
6514 integer field, and so the default size of record objects for this type
6515 will be 64 (8 bytes).
6516
6517 @node Old
6518 @unnumberedsec Old
6519 @cindex Capturing Old values
6520 @cindex Postconditions
6521 @noindent
6522 The attribute Prefix'Old can be used within a
6523 subprogram body or within a precondition or
6524 postcondition pragma. The effect is to
6525 refer to the value of the prefix on entry. So for
6526 example if you have an argument of a record type X called Arg1,
6527 you can refer to Arg1.Field'Old which yields the value of
6528 Arg1.Field on entry. The implementation simply involves generating
6529 an object declaration which captures the value on entry.
6530 The prefix must denote an object of a nonlimited type (since limited types
6531 cannot be copied to capture their values) and it must not reference a local
6532 variable (since local variables do not exist at subprogram entry time). Note
6533 that the variable introduced by a quantified expression is a local variable.
6534 The following example shows the use of 'Old to implement
6535 a test of a postcondition:
6536
6537 @smallexample @c ada
6538 with Old_Pkg;
6539 procedure Old is
6540 begin
6541 Old_Pkg.Incr;
6542 end Old;
6543
6544 package Old_Pkg is
6545 procedure Incr;
6546 end Old_Pkg;
6547
6548 package body Old_Pkg is
6549 Count : Natural := 0;
6550
6551 procedure Incr is
6552 begin
6553 ... code manipulating the value of Count
6554
6555 pragma Assert (Count = Count'Old + 1);
6556 end Incr;
6557 end Old_Pkg;
6558 @end smallexample
6559
6560 @noindent
6561 Note that it is allowed to apply 'Old to a constant entity, but this will
6562 result in a warning, since the old and new values will always be the same.
6563
6564 @node Passed_By_Reference
6565 @unnumberedsec Passed_By_Reference
6566 @cindex Parameters, when passed by reference
6567 @findex Passed_By_Reference
6568 @noindent
6569 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6570 a value of type @code{Boolean} value that is @code{True} if the type is
6571 normally passed by reference and @code{False} if the type is normally
6572 passed by copy in calls. For scalar types, the result is always @code{False}
6573 and is static. For non-scalar types, the result is non-static.
6574
6575 @node Pool_Address
6576 @unnumberedsec Pool_Address
6577 @cindex Parameters, when passed by reference
6578 @findex Pool_Address
6579 @noindent
6580 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6581 of X within its storage pool. This is the same as
6582 @code{@var{X}'Address}, except that for an unconstrained array whose
6583 bounds are allocated just before the first component,
6584 @code{@var{X}'Pool_Address} returns the address of those bounds,
6585 whereas @code{@var{X}'Address} returns the address of the first
6586 component.
6587
6588 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6589 the object is allocated'', which could be a user-defined storage pool,
6590 the global heap, on the stack, or in a static memory area. For an
6591 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6592 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6593
6594 @node Range_Length
6595 @unnumberedsec Range_Length
6596 @findex Range_Length
6597 @noindent
6598 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6599 the number of values represented by the subtype (zero for a null
6600 range). The result is static for static subtypes. @code{Range_Length}
6601 applied to the index subtype of a one dimensional array always gives the
6602 same result as @code{Range} applied to the array itself.
6603
6604 @node Ref
6605 @unnumberedsec Ref
6606 @findex Ref
6607 @noindent
6608 The @code{System.Address'Ref}
6609 (@code{System.Address} is the only permissible prefix)
6610 denotes a function identical to
6611 @code{System.Storage_Elements.To_Address} except that
6612 it is a static attribute. See @ref{To_Address} for more details.
6613
6614 @node Result
6615 @unnumberedsec Result
6616 @findex Result
6617 @noindent
6618 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6619 for a function. The prefix must be the name of the corresponding function. This
6620 is used to refer to the result of the function in the postcondition expression.
6621 For a further discussion of the use of this attribute and examples of its use,
6622 see the description of pragma Postcondition.
6623
6624 @node Safe_Emax
6625 @unnumberedsec Safe_Emax
6626 @cindex Ada 83 attributes
6627 @findex Safe_Emax
6628 @noindent
6629 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
6630 the Ada 83 reference manual for an exact description of the semantics of
6631 this attribute.
6632
6633 @node Safe_Large
6634 @unnumberedsec Safe_Large
6635 @cindex Ada 83 attributes
6636 @findex Safe_Large
6637 @noindent
6638 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
6639 the Ada 83 reference manual for an exact description of the semantics of
6640 this attribute.
6641
6642 @node Simple_Storage_Pool
6643 @unnumberedsec Simple_Storage_Pool
6644 @cindex Storage pool, simple
6645 @cindex Simple storage pool
6646 @findex Simple_Storage_Pool
6647 @noindent
6648 For every nonformal, nonderived access-to-object type @var{Acc}, the
6649 representation attribute @code{Simple_Storage_Pool} may be specified
6650 via an attribute_definition_clause (or by specifying the equivalent aspect):
6651
6652 @smallexample @c ada
6653
6654 My_Pool : My_Simple_Storage_Pool_Type;
6655
6656 type Acc is access My_Data_Type;
6657
6658 for Acc'Simple_Storage_Pool use My_Pool;
6659
6660 @end smallexample
6661
6662 @noindent
6663 The name given in an attribute_definition_clause for the
6664 @code{Simple_Storage_Pool} attribute shall denote a variable of
6665 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
6666
6667 The use of this attribute is only allowed for a prefix denoting a type
6668 for which it has been specified. The type of the attribute is the type
6669 of the variable specified as the simple storage pool of the access type,
6670 and the attribute denotes that variable.
6671
6672 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
6673 for the same access type.
6674
6675 If the @code{Simple_Storage_Pool} attribute has been specified for an access
6676 type, then applying the @code{Storage_Pool} attribute to the type is flagged
6677 with a warning and its evaluation raises the exception @code{Program_Error}.
6678
6679 If the Simple_Storage_Pool attribute has been specified for an access
6680 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
6681 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
6682 which is intended to indicate the number of storage elements reserved for
6683 the simple storage pool. If the Storage_Size function has not been defined
6684 for the simple storage pool type, then this attribute returns zero.
6685
6686 If an access type @var{S} has a specified simple storage pool of type
6687 @var{SSP}, then the evaluation of an allocator for that access type calls
6688 the primitive @code{Allocate} procedure for type @var{SSP}, passing
6689 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
6690 semantics of such allocators is the same as those defined for allocators
6691 in section 13.11 of the Ada Reference Manual, with the term
6692 ``simple storage pool'' substituted for ``storage pool''.
6693
6694 If an access type @var{S} has a specified simple storage pool of type
6695 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
6696 for that access type invokes the primitive @code{Deallocate} procedure
6697 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
6698 parameter. The detailed semantics of such unchecked deallocations is the same
6699 as defined in section 13.11.2 of the Ada Reference Manual, except that the
6700 term ``simple storage pool'' is substituted for ``storage pool''.
6701
6702 @node Small
6703 @unnumberedsec Small
6704 @cindex Ada 83 attributes
6705 @findex Small
6706 @noindent
6707 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6708 fixed-point types.
6709 GNAT also allows this attribute to be applied to floating-point types
6710 for compatibility with Ada 83. See
6711 the Ada 83 reference manual for an exact description of the semantics of
6712 this attribute when applied to floating-point types.
6713
6714 @node Storage_Unit
6715 @unnumberedsec Storage_Unit
6716 @findex Storage_Unit
6717 @noindent
6718 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6719 prefix) provides the same value as @code{System.Storage_Unit}.
6720
6721 @node Stub_Type
6722 @unnumberedsec Stub_Type
6723 @findex Stub_Type
6724 @noindent
6725 The GNAT implementation of remote access-to-classwide types is
6726 organized as described in AARM section E.4 (20.t): a value of an RACW type
6727 (designating a remote object) is represented as a normal access
6728 value, pointing to a "stub" object which in turn contains the
6729 necessary information to contact the designated remote object. A
6730 call on any dispatching operation of such a stub object does the
6731 remote call, if necessary, using the information in the stub object
6732 to locate the target partition, etc.
6733
6734 For a prefix @code{T} that denotes a remote access-to-classwide type,
6735 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6736
6737 By construction, the layout of @code{T'Stub_Type} is identical to that of
6738 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6739 unit @code{System.Partition_Interface}. Use of this attribute will create
6740 an implicit dependency on this unit.
6741
6742 @node System_Allocator_Alignment
6743 @unnumberedsec System_Allocator_Alignment
6744 @cindex Alignment, allocator
6745 @findex System_Allocator_Alignment
6746 @noindent
6747 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6748 permissible prefix) provides the observable guaranted to be honored by
6749 the system allocator (malloc). This is a static value that can be used
6750 in user storage pools based on malloc either to reject allocation
6751 with alignment too large or to enable a realignment circuitry if the
6752 alignment request is larger than this value.
6753
6754 @node Target_Name
6755 @unnumberedsec Target_Name
6756 @findex Target_Name
6757 @noindent
6758 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6759 prefix) provides a static string value that identifies the target
6760 for the current compilation. For GCC implementations, this is the
6761 standard gcc target name without the terminating slash (for
6762 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6763
6764 @node Tick
6765 @unnumberedsec Tick
6766 @findex Tick
6767 @noindent
6768 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6769 provides the same value as @code{System.Tick},
6770
6771 @node To_Address
6772 @unnumberedsec To_Address
6773 @findex To_Address
6774 @noindent
6775 The @code{System'To_Address}
6776 (@code{System} is the only permissible prefix)
6777 denotes a function identical to
6778 @code{System.Storage_Elements.To_Address} except that
6779 it is a static attribute. This means that if its argument is
6780 a static expression, then the result of the attribute is a
6781 static expression. The result is that such an expression can be
6782 used in contexts (e.g.@: preelaborable packages) which require a
6783 static expression and where the function call could not be used
6784 (since the function call is always non-static, even if its
6785 argument is static).
6786
6787 @node Type_Class
6788 @unnumberedsec Type_Class
6789 @findex Type_Class
6790 @noindent
6791 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6792 the value of the type class for the full type of @var{type}. If
6793 @var{type} is a generic formal type, the value is the value for the
6794 corresponding actual subtype. The value of this attribute is of type
6795 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6796
6797 @smallexample @c ada
6798 type Type_Class is
6799 (Type_Class_Enumeration,
6800 Type_Class_Integer,
6801 Type_Class_Fixed_Point,
6802 Type_Class_Floating_Point,
6803 Type_Class_Array,
6804 Type_Class_Record,
6805 Type_Class_Access,
6806 Type_Class_Task,
6807 Type_Class_Address);
6808 @end smallexample
6809
6810 @noindent
6811 Protected types yield the value @code{Type_Class_Task}, which thus
6812 applies to all concurrent types. This attribute is designed to
6813 be compatible with the DEC Ada 83 attribute of the same name.
6814
6815 @node UET_Address
6816 @unnumberedsec UET_Address
6817 @findex UET_Address
6818 @noindent
6819 The @code{UET_Address} attribute can only be used for a prefix which
6820 denotes a library package. It yields the address of the unit exception
6821 table when zero cost exception handling is used. This attribute is
6822 intended only for use within the GNAT implementation. See the unit
6823 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6824 for details on how this attribute is used in the implementation.
6825
6826 @node Unconstrained_Array
6827 @unnumberedsec Unconstrained_Array
6828 @findex Unconstrained_Array
6829 @noindent
6830 The @code{Unconstrained_Array} attribute can be used with a prefix that
6831 denotes any type or subtype. It is a static attribute that yields
6832 @code{True} if the prefix designates an unconstrained array,
6833 and @code{False} otherwise. In a generic instance, the result is
6834 still static, and yields the result of applying this test to the
6835 generic actual.
6836
6837 @node Universal_Literal_String
6838 @unnumberedsec Universal_Literal_String
6839 @cindex Named numbers, representation of
6840 @findex Universal_Literal_String
6841 @noindent
6842 The prefix of @code{Universal_Literal_String} must be a named
6843 number. The static result is the string consisting of the characters of
6844 the number as defined in the original source. This allows the user
6845 program to access the actual text of named numbers without intermediate
6846 conversions and without the need to enclose the strings in quotes (which
6847 would preclude their use as numbers).
6848
6849 For example, the following program prints the first 50 digits of pi:
6850
6851 @smallexample @c ada
6852 with Text_IO; use Text_IO;
6853 with Ada.Numerics;
6854 procedure Pi is
6855 begin
6856 Put (Ada.Numerics.Pi'Universal_Literal_String);
6857 end;
6858 @end smallexample
6859
6860 @node Unrestricted_Access
6861 @unnumberedsec Unrestricted_Access
6862 @cindex @code{Access}, unrestricted
6863 @findex Unrestricted_Access
6864 @noindent
6865 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6866 except that all accessibility and aliased view checks are omitted. This
6867 is a user-beware attribute. It is similar to
6868 @code{Address}, for which it is a desirable replacement where the value
6869 desired is an access type. In other words, its effect is identical to
6870 first applying the @code{Address} attribute and then doing an unchecked
6871 conversion to a desired access type. In GNAT, but not necessarily in
6872 other implementations, the use of static chains for inner level
6873 subprograms means that @code{Unrestricted_Access} applied to a
6874 subprogram yields a value that can be called as long as the subprogram
6875 is in scope (normal Ada accessibility rules restrict this usage).
6876
6877 It is possible to use @code{Unrestricted_Access} for any type, but care
6878 must be exercised if it is used to create pointers to unconstrained
6879 objects. In this case, the resulting pointer has the same scope as the
6880 context of the attribute, and may not be returned to some enclosing
6881 scope. For instance, a function cannot use @code{Unrestricted_Access}
6882 to create a unconstrained pointer and then return that value to the
6883 caller.
6884
6885 @node VADS_Size
6886 @unnumberedsec VADS_Size
6887 @cindex @code{Size}, VADS compatibility
6888 @findex VADS_Size
6889 @noindent
6890 The @code{'VADS_Size} attribute is intended to make it easier to port
6891 legacy code which relies on the semantics of @code{'Size} as implemented
6892 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
6893 same semantic interpretation. In particular, @code{'VADS_Size} applied
6894 to a predefined or other primitive type with no Size clause yields the
6895 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6896 typical machines). In addition @code{'VADS_Size} applied to an object
6897 gives the result that would be obtained by applying the attribute to
6898 the corresponding type.
6899
6900 @node Value_Size
6901 @unnumberedsec Value_Size
6902 @cindex @code{Size}, setting for not-first subtype
6903 @findex Value_Size
6904 @code{@var{type}'Value_Size} is the number of bits required to represent
6905 a value of the given subtype. It is the same as @code{@var{type}'Size},
6906 but, unlike @code{Size}, may be set for non-first subtypes.
6907
6908 @node Wchar_T_Size
6909 @unnumberedsec Wchar_T_Size
6910 @findex Wchar_T_Size
6911 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6912 prefix) provides the size in bits of the C @code{wchar_t} type
6913 primarily for constructing the definition of this type in
6914 package @code{Interfaces.C}.
6915
6916 @node Word_Size
6917 @unnumberedsec Word_Size
6918 @findex Word_Size
6919 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6920 prefix) provides the value @code{System.Word_Size}.
6921
6922 @node Implementation Defined Restrictions
6923 @chapter Implementation Defined Restrictions
6924
6925 @noindent
6926 All RM defined Restriction identifiers are implemented:
6927
6928 @itemize @bullet
6929 @item language-defined restrictions (see 13.12.1)
6930 @item tasking restrictions (see D.7)
6931 @item high integrity restrictions (see H.4)
6932 @end itemize
6933
6934 @noindent
6935 GNAT implements additional restriction identifiers. All restrictions, whether
6936 language defined or GNAT-specific, are listed in the following.
6937
6938 @menu
6939 * Partition-Wide Restrictions::
6940 * Program Unit Level Restrictions::
6941 @end menu
6942
6943 @node Partition-Wide Restrictions
6944 @section Partition-Wide Restrictions
6945
6946 There are two separate lists of restriction identifiers. The first
6947 set requires consistency throughout a partition (in other words, if the
6948 restriction identifier is used for any compilation unit in the partition,
6949 then all compilation units in the partition must obey the restriction).
6950
6951 @menu
6952 * Immediate_Reclamation::
6953 * Max_Asynchronous_Select_Nesting::
6954 * Max_Entry_Queue_Length::
6955 * Max_Protected_Entries::
6956 * Max_Select_Alternatives::
6957 * Max_Storage_At_Blocking::
6958 * Max_Task_Entries::
6959 * Max_Tasks::
6960 * No_Abort_Statements::
6961 * No_Access_Parameter_Allocators::
6962 * No_Access_Subprograms::
6963 * No_Allocators::
6964 * No_Anonymous_Allocators::
6965 * No_Calendar::
6966 * No_Coextensions::
6967 * No_Default_Initialization::
6968 * No_Delay::
6969 * No_Dependence::
6970 * No_Direct_Boolean_Operators::
6971 * No_Dispatch::
6972 * No_Dispatching_Calls::
6973 * No_Dynamic_Attachment::
6974 * No_Dynamic_Priorities::
6975 * No_Entry_Calls_In_Elaboration_Code::
6976 * No_Enumeration_Maps::
6977 * No_Exception_Handlers::
6978 * No_Exception_Propagation::
6979 * No_Exception_Registration::
6980 * No_Exceptions::
6981 * No_Finalization::
6982 * No_Fixed_Point::
6983 * No_Floating_Point::
6984 * No_Implicit_Conditionals::
6985 * No_Implicit_Dynamic_Code::
6986 * No_Implicit_Heap_Allocations::
6987 * No_Implicit_Loops::
6988 * No_Initialize_Scalars::
6989 * No_IO::
6990 * No_Local_Allocators::
6991 * No_Local_Protected_Objects::
6992 * No_Local_Timing_Events::
6993 * No_Nested_Finalization::
6994 * No_Protected_Type_Allocators::
6995 * No_Protected_Types::
6996 * No_Recursion::
6997 * No_Reentrancy::
6998 * No_Relative_Delay::
6999 * No_Requeue_Statements::
7000 * No_Secondary_Stack::
7001 * No_Select_Statements::
7002 * No_Specific_Termination_Handlers::
7003 * No_Specification_of_Aspect::
7004 * No_Standard_Allocators_After_Elaboration::
7005 * No_Standard_Storage_Pools::
7006 * No_Stream_Optimizations::
7007 * No_Streams::
7008 * No_Task_Allocators::
7009 * No_Task_Attributes_Package::
7010 * No_Task_Hierarchy::
7011 * No_Task_Termination::
7012 * No_Tasking::
7013 * No_Terminate_Alternatives::
7014 * No_Unchecked_Access::
7015 * Simple_Barriers::
7016 * Static_Priorities::
7017 * Static_Storage_Size::
7018 @end menu
7019
7020 @node Immediate_Reclamation
7021 @unnumberedsubsec Immediate_Reclamation
7022 @findex Immediate_Reclamation
7023 [RM H.4] This restriction ensures that, except for storage occupied by
7024 objects created by allocators and not deallocated via unchecked
7025 deallocation, any storage reserved at run time for an object is
7026 immediately reclaimed when the object no longer exists.
7027
7028 @node Max_Asynchronous_Select_Nesting
7029 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7030 @findex Max_Asynchronous_Select_Nesting
7031 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7032 selects. Violations of this restriction with a value of zero are
7033 detected at compile time. Violations of this restriction with values
7034 other than zero cause Storage_Error to be raised.
7035
7036 @node Max_Entry_Queue_Length
7037 @unnumberedsubsec Max_Entry_Queue_Length
7038 @findex Max_Entry_Queue_Length
7039 [RM D.7] This restriction is a declaration that any protected entry compiled in
7040 the scope of the restriction has at most the specified number of
7041 tasks waiting on the entry at any one time, and so no queue is required.
7042 Note that this restriction is checked at run time. Violation of this
7043 restriction results in the raising of Program_Error exception at the point of
7044 the call.
7045
7046 @node Max_Protected_Entries
7047 @unnumberedsubsec Max_Protected_Entries
7048 @findex Max_Protected_Entries
7049 [RM D.7] Specifies the maximum number of entries per protected type. The
7050 bounds of every entry family of a protected unit shall be static, or shall be
7051 defined by a discriminant of a subtype whose corresponding bound is static.
7052
7053 @node Max_Select_Alternatives
7054 @unnumberedsubsec Max_Select_Alternatives
7055 @findex Max_Select_Alternatives
7056 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7057
7058 @node Max_Storage_At_Blocking
7059 @unnumberedsubsec Max_Storage_At_Blocking
7060 @findex Max_Storage_At_Blocking
7061 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7062 Storage_Size that can be retained by a blocked task. A violation of this
7063 restriction causes Storage_Error to be raised.
7064
7065 @node Max_Task_Entries
7066 @unnumberedsubsec Max_Task_Entries
7067 @findex Max_Task_Entries
7068 [RM D.7] Specifies the maximum number of entries
7069 per task. The bounds of every entry family
7070 of a task unit shall be static, or shall be
7071 defined by a discriminant of a subtype whose
7072 corresponding bound is static.
7073
7074 @node Max_Tasks
7075 @unnumberedsubsec Max_Tasks
7076 @findex Max_Tasks
7077 [RM D.7] Specifies the maximum number of task that may be created, not
7078 counting the creation of the environment task. Violations of this
7079 restriction with a value of zero are detected at compile
7080 time. Violations of this restriction with values other than zero cause
7081 Storage_Error to be raised.
7082
7083 @node No_Abort_Statements
7084 @unnumberedsubsec No_Abort_Statements
7085 @findex No_Abort_Statements
7086 [RM D.7] There are no abort_statements, and there are
7087 no calls to Task_Identification.Abort_Task.
7088
7089 @node No_Access_Parameter_Allocators
7090 @unnumberedsubsec No_Access_Parameter_Allocators
7091 @findex No_Access_Parameter_Allocators
7092 [RM H.4] This restriction ensures at compile time that there are no
7093 occurrences of an allocator as the actual parameter to an access
7094 parameter.
7095
7096 @node No_Access_Subprograms
7097 @unnumberedsubsec No_Access_Subprograms
7098 @findex No_Access_Subprograms
7099 [RM H.4] This restriction ensures at compile time that there are no
7100 declarations of access-to-subprogram types.
7101
7102 @node No_Allocators
7103 @unnumberedsubsec No_Allocators
7104 @findex No_Allocators
7105 [RM H.4] This restriction ensures at compile time that there are no
7106 occurrences of an allocator.
7107
7108 @node No_Anonymous_Allocators
7109 @unnumberedsubsec No_Anonymous_Allocators
7110 @findex No_Anonymous_Allocators
7111 [RM H.4] This restriction ensures at compile time that there are no
7112 occurrences of an allocator of anonymous access type.
7113
7114 @node No_Calendar
7115 @unnumberedsubsec No_Calendar
7116 @findex No_Calendar
7117 [GNAT] This restriction ensures at compile time that there is no implicit or
7118 explicit dependence on the package @code{Ada.Calendar}.
7119
7120 @node No_Coextensions
7121 @unnumberedsubsec No_Coextensions
7122 @findex No_Coextensions
7123 [RM H.4] This restriction ensures at compile time that there are no
7124 coextensions. See 3.10.2.
7125
7126 @node No_Default_Initialization
7127 @unnumberedsubsec No_Default_Initialization
7128 @findex No_Default_Initialization
7129
7130 [GNAT] This restriction prohibits any instance of default initialization
7131 of variables. The binder implements a consistency rule which prevents
7132 any unit compiled without the restriction from with'ing a unit with the
7133 restriction (this allows the generation of initialization procedures to
7134 be skipped, since you can be sure that no call is ever generated to an
7135 initialization procedure in a unit with the restriction active). If used
7136 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7137 is to prohibit all cases of variables declared without a specific
7138 initializer (including the case of OUT scalar parameters).
7139
7140 @node No_Delay
7141 @unnumberedsubsec No_Delay
7142 @findex No_Delay
7143 [RM H.4] This restriction ensures at compile time that there are no
7144 delay statements and no dependences on package Calendar.
7145
7146 @node No_Dependence
7147 @unnumberedsubsec No_Dependence
7148 @findex No_Dependence
7149 [RM 13.12.1] This restriction checks at compile time that there are no
7150 dependence on a library unit.
7151
7152 @node No_Direct_Boolean_Operators
7153 @unnumberedsubsec No_Direct_Boolean_Operators
7154 @findex No_Direct_Boolean_Operators
7155 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7156 operands of type Boolean (or any type derived
7157 from Boolean). This is intended for use in safety critical programs
7158 where the certification protocol requires the use of short-circuit
7159 (and then, or else) forms for all composite boolean operations.
7160
7161 @node No_Dispatch
7162 @unnumberedsubsec No_Dispatch
7163 @findex No_Dispatch
7164 [RM H.4] This restriction ensures at compile time that there are no
7165 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7166
7167 @node No_Dispatching_Calls
7168 @unnumberedsubsec No_Dispatching_Calls
7169 @findex No_Dispatching_Calls
7170 [GNAT] This restriction ensures at compile time that the code generated by the
7171 compiler involves no dispatching calls. The use of this restriction allows the
7172 safe use of record extensions, classwide membership tests and other classwide
7173 features not involving implicit dispatching. This restriction ensures that
7174 the code contains no indirect calls through a dispatching mechanism. Note that
7175 this includes internally-generated calls created by the compiler, for example
7176 in the implementation of class-wide objects assignments. The
7177 membership test is allowed in the presence of this restriction, because its
7178 implementation requires no dispatching.
7179 This restriction is comparable to the official Ada restriction
7180 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7181 all classwide constructs that do not imply dispatching.
7182 The following example indicates constructs that violate this restriction.
7183
7184 @smallexample
7185 package Pkg is
7186 type T is tagged record
7187 Data : Natural;
7188 end record;
7189 procedure P (X : T);
7190
7191 type DT is new T with record
7192 More_Data : Natural;
7193 end record;
7194 procedure Q (X : DT);
7195 end Pkg;
7196
7197 with Pkg; use Pkg;
7198 procedure Example is
7199 procedure Test (O : T'Class) is
7200 N : Natural := O'Size;-- Error: Dispatching call
7201 C : T'Class := O; -- Error: implicit Dispatching Call
7202 begin
7203 if O in DT'Class then -- OK : Membership test
7204 Q (DT (O)); -- OK : Type conversion plus direct call
7205 else
7206 P (O); -- Error: Dispatching call
7207 end if;
7208 end Test;
7209
7210 Obj : DT;
7211 begin
7212 P (Obj); -- OK : Direct call
7213 P (T (Obj)); -- OK : Type conversion plus direct call
7214 P (T'Class (Obj)); -- Error: Dispatching call
7215
7216 Test (Obj); -- OK : Type conversion
7217
7218 if Obj in T'Class then -- OK : Membership test
7219 null;
7220 end if;
7221 end Example;
7222 @end smallexample
7223
7224 @node No_Dynamic_Attachment
7225 @unnumberedsubsec No_Dynamic_Attachment
7226 @findex No_Dynamic_Attachment
7227 [RM D.7] This restriction ensures that there is no call to any of the
7228 operations defined in package Ada.Interrupts
7229 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7230 Detach_Handler, and Reference).
7231
7232 @node No_Dynamic_Priorities
7233 @unnumberedsubsec No_Dynamic_Priorities
7234 @findex No_Dynamic_Priorities
7235 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7236
7237 @node No_Entry_Calls_In_Elaboration_Code
7238 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7239 @findex No_Entry_Calls_In_Elaboration_Code
7240 [GNAT] This restriction ensures at compile time that no task or protected entry
7241 calls are made during elaboration code. As a result of the use of this
7242 restriction, the compiler can assume that no code past an accept statement
7243 in a task can be executed at elaboration time.
7244
7245 @node No_Enumeration_Maps
7246 @unnumberedsubsec No_Enumeration_Maps
7247 @findex No_Enumeration_Maps
7248 [GNAT] This restriction ensures at compile time that no operations requiring
7249 enumeration maps are used (that is Image and Value attributes applied
7250 to enumeration types).
7251
7252 @node No_Exception_Handlers
7253 @unnumberedsubsec No_Exception_Handlers
7254 @findex No_Exception_Handlers
7255 [GNAT] This restriction ensures at compile time that there are no explicit
7256 exception handlers. It also indicates that no exception propagation will
7257 be provided. In this mode, exceptions may be raised but will result in
7258 an immediate call to the last chance handler, a routine that the user
7259 must define with the following profile:
7260
7261 @smallexample @c ada
7262 procedure Last_Chance_Handler
7263 (Source_Location : System.Address; Line : Integer);
7264 pragma Export (C, Last_Chance_Handler,
7265 "__gnat_last_chance_handler");
7266 @end smallexample
7267
7268 The parameter is a C null-terminated string representing a message to be
7269 associated with the exception (typically the source location of the raise
7270 statement generated by the compiler). The Line parameter when nonzero
7271 represents the line number in the source program where the raise occurs.
7272
7273 @node No_Exception_Propagation
7274 @unnumberedsubsec No_Exception_Propagation
7275 @findex No_Exception_Propagation
7276 [GNAT] This restriction guarantees that exceptions are never propagated
7277 to an outer subprogram scope. The only case in which an exception may
7278 be raised is when the handler is statically in the same subprogram, so
7279 that the effect of a raise is essentially like a goto statement. Any
7280 other raise statement (implicit or explicit) will be considered
7281 unhandled. Exception handlers are allowed, but may not contain an
7282 exception occurrence identifier (exception choice). In addition, use of
7283 the package GNAT.Current_Exception is not permitted, and reraise
7284 statements (raise with no operand) are not permitted.
7285
7286 @node No_Exception_Registration
7287 @unnumberedsubsec No_Exception_Registration
7288 @findex No_Exception_Registration
7289 [GNAT] This restriction ensures at compile time that no stream operations for
7290 types Exception_Id or Exception_Occurrence are used. This also makes it
7291 impossible to pass exceptions to or from a partition with this restriction
7292 in a distributed environment. If this exception is active, then the generated
7293 code is simplified by omitting the otherwise-required global registration
7294 of exceptions when they are declared.
7295
7296 @node No_Exceptions
7297 @unnumberedsubsec No_Exceptions
7298 @findex No_Exceptions
7299 [RM H.4] This restriction ensures at compile time that there are no
7300 raise statements and no exception handlers.
7301
7302 @node No_Finalization
7303 @unnumberedsubsec No_Finalization
7304 @findex No_Finalization
7305 [GNAT] This restriction disables the language features described in
7306 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7307 performed by the compiler to support these features. The following types
7308 are no longer considered controlled when this restriction is in effect:
7309 @itemize @bullet
7310 @item
7311 @code{Ada.Finalization.Controlled}
7312 @item
7313 @code{Ada.Finalization.Limited_Controlled}
7314 @item
7315 Derivations from @code{Controlled} or @code{Limited_Controlled}
7316 @item
7317 Class-wide types
7318 @item
7319 Protected types
7320 @item
7321 Task types
7322 @item
7323 Array and record types with controlled components
7324 @end itemize
7325 The compiler no longer generates code to initialize, finalize or adjust an
7326 object or a nested component, either declared on the stack or on the heap. The
7327 deallocation of a controlled object no longer finalizes its contents.
7328
7329 @node No_Fixed_Point
7330 @unnumberedsubsec No_Fixed_Point
7331 @findex No_Fixed_Point
7332 [RM H.4] This restriction ensures at compile time that there are no
7333 occurrences of fixed point types and operations.
7334
7335 @node No_Floating_Point
7336 @unnumberedsubsec No_Floating_Point
7337 @findex No_Floating_Point
7338 [RM H.4] This restriction ensures at compile time that there are no
7339 occurrences of floating point types and operations.
7340
7341 @node No_Implicit_Conditionals
7342 @unnumberedsubsec No_Implicit_Conditionals
7343 @findex No_Implicit_Conditionals
7344 [GNAT] This restriction ensures that the generated code does not contain any
7345 implicit conditionals, either by modifying the generated code where possible,
7346 or by rejecting any construct that would otherwise generate an implicit
7347 conditional. Note that this check does not include run time constraint
7348 checks, which on some targets may generate implicit conditionals as
7349 well. To control the latter, constraint checks can be suppressed in the
7350 normal manner. Constructs generating implicit conditionals include comparisons
7351 of composite objects and the Max/Min attributes.
7352
7353 @node No_Implicit_Dynamic_Code
7354 @unnumberedsubsec No_Implicit_Dynamic_Code
7355 @findex No_Implicit_Dynamic_Code
7356 @cindex trampoline
7357 [GNAT] This restriction prevents the compiler from building ``trampolines''.
7358 This is a structure that is built on the stack and contains dynamic
7359 code to be executed at run time. On some targets, a trampoline is
7360 built for the following features: @code{Access},
7361 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7362 nested task bodies; primitive operations of nested tagged types.
7363 Trampolines do not work on machines that prevent execution of stack
7364 data. For example, on windows systems, enabling DEP (data execution
7365 protection) will cause trampolines to raise an exception.
7366 Trampolines are also quite slow at run time.
7367
7368 On many targets, trampolines have been largely eliminated. Look at the
7369 version of system.ads for your target --- if it has
7370 Always_Compatible_Rep equal to False, then trampolines are largely
7371 eliminated. In particular, a trampoline is built for the following
7372 features: @code{Address} of a nested subprogram;
7373 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
7374 but only if pragma Favor_Top_Level applies, or the access type has a
7375 foreign-language convention; primitive operations of nested tagged
7376 types.
7377
7378 @node No_Implicit_Heap_Allocations
7379 @unnumberedsubsec No_Implicit_Heap_Allocations
7380 @findex No_Implicit_Heap_Allocations
7381 [RM D.7] No constructs are allowed to cause implicit heap allocation.
7382
7383 @node No_Implicit_Loops
7384 @unnumberedsubsec No_Implicit_Loops
7385 @findex No_Implicit_Loops
7386 [GNAT] This restriction ensures that the generated code does not contain any
7387 implicit @code{for} loops, either by modifying
7388 the generated code where possible,
7389 or by rejecting any construct that would otherwise generate an implicit
7390 @code{for} loop. If this restriction is active, it is possible to build
7391 large array aggregates with all static components without generating an
7392 intermediate temporary, and without generating a loop to initialize individual
7393 components. Otherwise, a loop is created for arrays larger than about 5000
7394 scalar components.
7395
7396 @node No_Initialize_Scalars
7397 @unnumberedsubsec No_Initialize_Scalars
7398 @findex No_Initialize_Scalars
7399 [GNAT] This restriction ensures that no unit in the partition is compiled with
7400 pragma Initialize_Scalars. This allows the generation of more efficient
7401 code, and in particular eliminates dummy null initialization routines that
7402 are otherwise generated for some record and array types.
7403
7404 @node No_IO
7405 @unnumberedsubsec No_IO
7406 @findex No_IO
7407 [RM H.4] This restriction ensures at compile time that there are no
7408 dependences on any of the library units Sequential_IO, Direct_IO,
7409 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
7410
7411 @node No_Local_Allocators
7412 @unnumberedsubsec No_Local_Allocators
7413 @findex No_Local_Allocators
7414 [RM H.4] This restriction ensures at compile time that there are no
7415 occurrences of an allocator in subprograms, generic subprograms, tasks,
7416 and entry bodies.
7417
7418 @node No_Local_Protected_Objects
7419 @unnumberedsubsec No_Local_Protected_Objects
7420 @findex No_Local_Protected_Objects
7421 [RM D.7] This restriction ensures at compile time that protected objects are
7422 only declared at the library level.
7423
7424 @node No_Local_Timing_Events
7425 @unnumberedsubsec No_Local_Timing_Events
7426 @findex No_Local_Timing_Events
7427 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
7428 declared at the library level.
7429
7430 @node No_Nested_Finalization
7431 @unnumberedsubsec No_Nested_Finalization
7432 @findex No_Nested_Finalization
7433 [RM D.7] All objects requiring finalization are declared at the library level.
7434
7435 @node No_Protected_Type_Allocators
7436 @unnumberedsubsec No_Protected_Type_Allocators
7437 @findex No_Protected_Type_Allocators
7438 [RM D.7] This restriction ensures at compile time that there are no allocator
7439 expressions that attempt to allocate protected objects.
7440
7441 @node No_Protected_Types
7442 @unnumberedsubsec No_Protected_Types
7443 @findex No_Protected_Types
7444 [RM H.4] This restriction ensures at compile time that there are no
7445 declarations of protected types or protected objects.
7446
7447 @node No_Recursion
7448 @unnumberedsubsec No_Recursion
7449 @findex No_Recursion
7450 [RM H.4] A program execution is erroneous if a subprogram is invoked as
7451 part of its execution.
7452
7453 @node No_Reentrancy
7454 @unnumberedsubsec No_Reentrancy
7455 @findex No_Reentrancy
7456 [RM H.4] A program execution is erroneous if a subprogram is executed by
7457 two tasks at the same time.
7458
7459 @node No_Relative_Delay
7460 @unnumberedsubsec No_Relative_Delay
7461 @findex No_Relative_Delay
7462 [RM D.7] This restriction ensures at compile time that there are no delay
7463 relative statements and prevents expressions such as @code{delay 1.23;} from
7464 appearing in source code.
7465
7466 @node No_Requeue_Statements
7467 @unnumberedsubsec No_Requeue_Statements
7468 @findex No_Requeue_Statements
7469 [RM D.7] This restriction ensures at compile time that no requeue statements
7470 are permitted and prevents keyword @code{requeue} from being used in source
7471 code.
7472
7473 @node No_Secondary_Stack
7474 @unnumberedsubsec No_Secondary_Stack
7475 @findex No_Secondary_Stack
7476 [GNAT] This restriction ensures at compile time that the generated code
7477 does not contain any reference to the secondary stack. The secondary
7478 stack is used to implement functions returning unconstrained objects
7479 (arrays or records) on some targets.
7480
7481 @node No_Select_Statements
7482 @unnumberedsubsec No_Select_Statements
7483 @findex No_Select_Statements
7484 [RM D.7] This restriction ensures at compile time no select statements of any
7485 kind are permitted, that is the keyword @code{select} may not appear.
7486
7487 @node No_Specific_Termination_Handlers
7488 @unnumberedsubsec No_Specific_Termination_Handlers
7489 @findex No_Specific_Termination_Handlers
7490 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
7491 or to Ada.Task_Termination.Specific_Handler.
7492
7493 @node No_Specification_of_Aspect
7494 @unnumberedsubsec No_Specification_of_Aspect
7495 @findex No_Specification_of_Aspect
7496 [RM 13.12.1] This restriction checks at compile time that no aspect
7497 specification, attribute definition clause, or pragma is given for a
7498 given aspect.
7499
7500 @node No_Standard_Allocators_After_Elaboration
7501 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
7502 @findex No_Standard_Allocators_After_Elaboration
7503 [RM D.7] Specifies that an allocator using a standard storage pool
7504 should never be evaluated at run time after the elaboration of the
7505 library items of the partition has completed. Otherwise, Storage_Error
7506 is raised.
7507
7508 @node No_Standard_Storage_Pools
7509 @unnumberedsubsec No_Standard_Storage_Pools
7510 @findex No_Standard_Storage_Pools
7511 [GNAT] This restriction ensures at compile time that no access types
7512 use the standard default storage pool. Any access type declared must
7513 have an explicit Storage_Pool attribute defined specifying a
7514 user-defined storage pool.
7515
7516 @node No_Stream_Optimizations
7517 @unnumberedsubsec No_Stream_Optimizations
7518 @findex No_Stream_Optimizations
7519 [GNAT] This restriction affects the performance of stream operations on types
7520 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
7521 compiler uses block reads and writes when manipulating @code{String} objects
7522 due to their supperior performance. When this restriction is in effect, the
7523 compiler performs all IO operations on a per-character basis.
7524
7525 @node No_Streams
7526 @unnumberedsubsec No_Streams
7527 @findex No_Streams
7528 [GNAT] This restriction ensures at compile/bind time that there are no
7529 stream objects created and no use of stream attributes.
7530 This restriction does not forbid dependences on the package
7531 @code{Ada.Streams}. So it is permissible to with
7532 @code{Ada.Streams} (or another package that does so itself)
7533 as long as no actual stream objects are created and no
7534 stream attributes are used.
7535
7536 Note that the use of restriction allows optimization of tagged types,
7537 since they do not need to worry about dispatching stream operations.
7538 To take maximum advantage of this space-saving optimization, any
7539 unit declaring a tagged type should be compiled with the restriction,
7540 though this is not required.
7541
7542 @node No_Task_Allocators
7543 @unnumberedsubsec No_Task_Allocators
7544 @findex No_Task_Allocators
7545 [RM D.7] There are no allocators for task types
7546 or types containing task subcomponents.
7547
7548 @node No_Task_Attributes_Package
7549 @unnumberedsubsec No_Task_Attributes_Package
7550 @findex No_Task_Attributes_Package
7551 [GNAT] This restriction ensures at compile time that there are no implicit or
7552 explicit dependencies on the package @code{Ada.Task_Attributes}.
7553
7554 @node No_Task_Hierarchy
7555 @unnumberedsubsec No_Task_Hierarchy
7556 @findex No_Task_Hierarchy
7557 [RM D.7] All (non-environment) tasks depend
7558 directly on the environment task of the partition.
7559
7560 @node No_Task_Termination
7561 @unnumberedsubsec No_Task_Termination
7562 @findex No_Task_Termination
7563 [RM D.7] Tasks which terminate are erroneous.
7564
7565 @node No_Tasking
7566 @unnumberedsubsec No_Tasking
7567 @findex No_Tasking
7568 [GNAT] This restriction prevents the declaration of tasks or task types
7569 throughout the partition. It is similar in effect to the use of
7570 @code{Max_Tasks => 0} except that violations are caught at compile time
7571 and cause an error message to be output either by the compiler or
7572 binder.
7573
7574 @node No_Terminate_Alternatives
7575 @unnumberedsubsec No_Terminate_Alternatives
7576 @findex No_Terminate_Alternatives
7577 [RM D.7] There are no selective accepts with terminate alternatives.
7578
7579 @node No_Unchecked_Access
7580 @unnumberedsubsec No_Unchecked_Access
7581 @findex No_Unchecked_Access
7582 [RM H.4] This restriction ensures at compile time that there are no
7583 occurrences of the Unchecked_Access attribute.
7584
7585 @node Simple_Barriers
7586 @unnumberedsubsec Simple_Barriers
7587 @findex Simple_Barriers
7588 [RM D.7] This restriction ensures at compile time that barriers in entry
7589 declarations for protected types are restricted to either static boolean
7590 expressions or references to simple boolean variables defined in the private
7591 part of the protected type. No other form of entry barriers is permitted.
7592
7593 @node Static_Priorities
7594 @unnumberedsubsec Static_Priorities
7595 @findex Static_Priorities
7596 [GNAT] This restriction ensures at compile time that all priority expressions
7597 are static, and that there are no dependences on the package
7598 @code{Ada.Dynamic_Priorities}.
7599
7600 @node Static_Storage_Size
7601 @unnumberedsubsec Static_Storage_Size
7602 @findex Static_Storage_Size
7603 [GNAT] This restriction ensures at compile time that any expression appearing
7604 in a Storage_Size pragma or attribute definition clause is static.
7605
7606 @node Program Unit Level Restrictions
7607 @section Program Unit Level Restrictions
7608
7609 @noindent
7610 The second set of restriction identifiers
7611 does not require partition-wide consistency.
7612 The restriction may be enforced for a single
7613 compilation unit without any effect on any of the
7614 other compilation units in the partition.
7615
7616 @menu
7617 * No_Elaboration_Code::
7618 * No_Entry_Queue::
7619 * No_Implementation_Aspect_Specifications::
7620 * No_Implementation_Attributes::
7621 * No_Implementation_Identifiers::
7622 * No_Implementation_Pragmas::
7623 * No_Implementation_Restrictions::
7624 * No_Implementation_Units::
7625 * No_Implicit_Aliasing::
7626 * No_Obsolescent_Features::
7627 * No_Wide_Characters::
7628 * SPARK::
7629 @end menu
7630
7631 @node No_Elaboration_Code
7632 @unnumberedsubsec No_Elaboration_Code
7633 @findex No_Elaboration_Code
7634 [GNAT] This restriction ensures at compile time that no elaboration code is
7635 generated. Note that this is not the same condition as is enforced
7636 by pragma @code{Preelaborate}. There are cases in which pragma
7637 @code{Preelaborate} still permits code to be generated (e.g.@: code
7638 to initialize a large array to all zeroes), and there are cases of units
7639 which do not meet the requirements for pragma @code{Preelaborate},
7640 but for which no elaboration code is generated. Generally, it is
7641 the case that preelaborable units will meet the restrictions, with
7642 the exception of large aggregates initialized with an others_clause,
7643 and exception declarations (which generate calls to a run-time
7644 registry procedure). This restriction is enforced on
7645 a unit by unit basis, it need not be obeyed consistently
7646 throughout a partition.
7647
7648 In the case of aggregates with others, if the aggregate has a dynamic
7649 size, there is no way to eliminate the elaboration code (such dynamic
7650 bounds would be incompatible with @code{Preelaborate} in any case). If
7651 the bounds are static, then use of this restriction actually modifies
7652 the code choice of the compiler to avoid generating a loop, and instead
7653 generate the aggregate statically if possible, no matter how many times
7654 the data for the others clause must be repeatedly generated.
7655
7656 It is not possible to precisely document
7657 the constructs which are compatible with this restriction, since,
7658 unlike most other restrictions, this is not a restriction on the
7659 source code, but a restriction on the generated object code. For
7660 example, if the source contains a declaration:
7661
7662 @smallexample
7663 Val : constant Integer := X;
7664 @end smallexample
7665
7666 @noindent
7667 where X is not a static constant, it may be possible, depending
7668 on complex optimization circuitry, for the compiler to figure
7669 out the value of X at compile time, in which case this initialization
7670 can be done by the loader, and requires no initialization code. It
7671 is not possible to document the precise conditions under which the
7672 optimizer can figure this out.
7673
7674 Note that this the implementation of this restriction requires full
7675 code generation. If it is used in conjunction with "semantics only"
7676 checking, then some cases of violations may be missed.
7677
7678 @node No_Entry_Queue
7679 @unnumberedsubsec No_Entry_Queue
7680 @findex No_Entry_Queue
7681 [GNAT] This restriction is a declaration that any protected entry compiled in
7682 the scope of the restriction has at most one task waiting on the entry
7683 at any one time, and so no queue is required. This restriction is not
7684 checked at compile time. A program execution is erroneous if an attempt
7685 is made to queue a second task on such an entry.
7686
7687 @node No_Implementation_Aspect_Specifications
7688 @unnumberedsubsec No_Implementation_Aspect_Specifications
7689 @findex No_Implementation_Aspect_Specifications
7690 [RM 13.12.1] This restriction checks at compile time that no
7691 GNAT-defined aspects are present. With this restriction, the only
7692 aspects that can be used are those defined in the Ada Reference Manual.
7693
7694 @node No_Implementation_Attributes
7695 @unnumberedsubsec No_Implementation_Attributes
7696 @findex No_Implementation_Attributes
7697 [RM 13.12.1] This restriction checks at compile time that no
7698 GNAT-defined attributes are present. With this restriction, the only
7699 attributes that can be used are those defined in the Ada Reference
7700 Manual.
7701
7702 @node No_Implementation_Identifiers
7703 @unnumberedsubsec No_Implementation_Identifiers
7704 @findex No_Implementation_Identifiers
7705 [RM 13.12.1] This restriction checks at compile time that no
7706 implementation-defined identifiers occur within language-defined
7707 packages.
7708
7709 @node No_Implementation_Pragmas
7710 @unnumberedsubsec No_Implementation_Pragmas
7711 @findex No_Implementation_Pragmas
7712 [RM 13.12.1] This restriction checks at compile time that no
7713 GNAT-defined pragmas are present. With this restriction, the only
7714 pragmas that can be used are those defined in the Ada Reference Manual.
7715
7716 @node No_Implementation_Restrictions
7717 @unnumberedsubsec No_Implementation_Restrictions
7718 @findex No_Implementation_Restrictions
7719 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
7720 identifiers (other than @code{No_Implementation_Restrictions} itself)
7721 are present. With this restriction, the only other restriction identifiers
7722 that can be used are those defined in the Ada Reference Manual.
7723
7724 @node No_Implementation_Units
7725 @unnumberedsubsec No_Implementation_Units
7726 @findex No_Implementation_Units
7727 [RM 13.12.1] This restriction checks at compile time that there is no
7728 mention in the context clause of any implementation-defined descendants
7729 of packages Ada, Interfaces, or System.
7730
7731 @node No_Implicit_Aliasing
7732 @unnumberedsubsec No_Implicit_Aliasing
7733 @findex No_Implicit_Aliasing
7734 [GNAT] This restriction, which is not required to be partition-wide consistent,
7735 requires an explicit aliased keyword for an object to which 'Access,
7736 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
7737 the 'Unrestricted_Access attribute for objects. Note: the reason that
7738 Unrestricted_Access is forbidden is that it would require the prefix
7739 to be aliased, and in such cases, it can always be replaced by
7740 the standard attribute Unchecked_Access which is preferable.
7741
7742 @node No_Obsolescent_Features
7743 @unnumberedsubsec No_Obsolescent_Features
7744 @findex No_Obsolescent_Features
7745 [RM 13.12.1] This restriction checks at compile time that no obsolescent
7746 features are used, as defined in Annex J of the Ada Reference Manual.
7747
7748 @node No_Wide_Characters
7749 @unnumberedsubsec No_Wide_Characters
7750 @findex No_Wide_Characters
7751 [GNAT] This restriction ensures at compile time that no uses of the types
7752 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7753 wide types
7754 appear, and that no wide or wide wide string or character literals
7755 appear in the program (that is literals representing characters not in
7756 type @code{Character}.
7757
7758 @node SPARK
7759 @unnumberedsubsec SPARK
7760 @findex SPARK
7761 [GNAT] This restriction checks at compile time that some constructs
7762 forbidden in SPARK are not present. The SPARK version used as a
7763 reference is the same as the Ada mode for the unit, so a unit compiled
7764 in Ada 95 mode with SPARK restrictions will be checked for constructs
7765 forbidden in SPARK 95. Error messages related to SPARK restriction have
7766 the form:
7767
7768 @smallexample
7769 violation of restriction "SPARK" at <file>
7770 <error message>
7771 @end smallexample
7772
7773 This is not a replacement for the semantic checks performed by the
7774 SPARK Examiner tool, as the compiler only deals currently with code,
7775 not at all with SPARK annotations and does not guarantee catching all
7776 cases of constructs forbidden by SPARK.
7777
7778 Thus it may well be the case that code which
7779 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
7780 e.g. due to the different visibility rules of the Examiner based on
7781 SPARK @code{inherit} annotations.
7782
7783 This restriction can be useful in providing an initial filter for
7784 code developed using SPARK, or in examining legacy code to see how far
7785 it is from meeting SPARK restrictions.
7786
7787 @c ------------------------
7788 @node Implementation Advice
7789 @chapter Implementation Advice
7790 @noindent
7791 The main text of the Ada Reference Manual describes the required
7792 behavior of all Ada compilers, and the GNAT compiler conforms to
7793 these requirements.
7794
7795 In addition, there are sections throughout the Ada Reference Manual headed
7796 by the phrase ``Implementation advice''. These sections are not normative,
7797 i.e., they do not specify requirements that all compilers must
7798 follow. Rather they provide advice on generally desirable behavior. You
7799 may wonder why they are not requirements. The most typical answer is
7800 that they describe behavior that seems generally desirable, but cannot
7801 be provided on all systems, or which may be undesirable on some systems.
7802
7803 As far as practical, GNAT follows the implementation advice sections in
7804 the Ada Reference Manual. This chapter contains a table giving the
7805 reference manual section number, paragraph number and several keywords
7806 for each advice. Each entry consists of the text of the advice followed
7807 by the GNAT interpretation of this advice. Most often, this simply says
7808 ``followed'', which means that GNAT follows the advice. However, in a
7809 number of cases, GNAT deliberately deviates from this advice, in which
7810 case the text describes what GNAT does and why.
7811
7812 @cindex Error detection
7813 @unnumberedsec 1.1.3(20): Error Detection
7814 @sp 1
7815 @cartouche
7816 If an implementation detects the use of an unsupported Specialized Needs
7817 Annex feature at run time, it should raise @code{Program_Error} if
7818 feasible.
7819 @end cartouche
7820 Not relevant. All specialized needs annex features are either supported,
7821 or diagnosed at compile time.
7822
7823 @cindex Child Units
7824 @unnumberedsec 1.1.3(31): Child Units
7825 @sp 1
7826 @cartouche
7827 If an implementation wishes to provide implementation-defined
7828 extensions to the functionality of a language-defined library unit, it
7829 should normally do so by adding children to the library unit.
7830 @end cartouche
7831 Followed.
7832
7833 @cindex Bounded errors
7834 @unnumberedsec 1.1.5(12): Bounded Errors
7835 @sp 1
7836 @cartouche
7837 If an implementation detects a bounded error or erroneous
7838 execution, it should raise @code{Program_Error}.
7839 @end cartouche
7840 Followed in all cases in which the implementation detects a bounded
7841 error or erroneous execution. Not all such situations are detected at
7842 runtime.
7843
7844 @cindex Pragmas
7845 @unnumberedsec 2.8(16): Pragmas
7846 @sp 1
7847 @cartouche
7848 Normally, implementation-defined pragmas should have no semantic effect
7849 for error-free programs; that is, if the implementation-defined pragmas
7850 are removed from a working program, the program should still be legal,
7851 and should still have the same semantics.
7852 @end cartouche
7853 The following implementation defined pragmas are exceptions to this
7854 rule:
7855
7856 @table @code
7857 @item Abort_Defer
7858 Affects semantics
7859 @item Ada_83
7860 Affects legality
7861 @item Assert
7862 Affects semantics
7863 @item CPP_Class
7864 Affects semantics
7865 @item CPP_Constructor
7866 Affects semantics
7867 @item Debug
7868 Affects semantics
7869 @item Interface_Name
7870 Affects semantics
7871 @item Machine_Attribute
7872 Affects semantics
7873 @item Unimplemented_Unit
7874 Affects legality
7875 @item Unchecked_Union
7876 Affects semantics
7877 @end table
7878
7879 @noindent
7880 In each of the above cases, it is essential to the purpose of the pragma
7881 that this advice not be followed. For details see the separate section
7882 on implementation defined pragmas.
7883
7884 @unnumberedsec 2.8(17-19): Pragmas
7885 @sp 1
7886 @cartouche
7887 Normally, an implementation should not define pragmas that can
7888 make an illegal program legal, except as follows:
7889 @end cartouche
7890 @sp 1
7891 @cartouche
7892 A pragma used to complete a declaration, such as a pragma @code{Import};
7893 @end cartouche
7894 @sp 1
7895 @cartouche
7896 A pragma used to configure the environment by adding, removing, or
7897 replacing @code{library_items}.
7898 @end cartouche
7899 See response to paragraph 16 of this same section.
7900
7901 @cindex Character Sets
7902 @cindex Alternative Character Sets
7903 @unnumberedsec 3.5.2(5): Alternative Character Sets
7904 @sp 1
7905 @cartouche
7906 If an implementation supports a mode with alternative interpretations
7907 for @code{Character} and @code{Wide_Character}, the set of graphic
7908 characters of @code{Character} should nevertheless remain a proper
7909 subset of the set of graphic characters of @code{Wide_Character}. Any
7910 character set ``localizations'' should be reflected in the results of
7911 the subprograms defined in the language-defined package
7912 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
7913 an alternative interpretation of @code{Character}, the implementation should
7914 also support a corresponding change in what is a legal
7915 @code{identifier_letter}.
7916 @end cartouche
7917 Not all wide character modes follow this advice, in particular the JIS
7918 and IEC modes reflect standard usage in Japan, and in these encoding,
7919 the upper half of the Latin-1 set is not part of the wide-character
7920 subset, since the most significant bit is used for wide character
7921 encoding. However, this only applies to the external forms. Internally
7922 there is no such restriction.
7923
7924 @cindex Integer types
7925 @unnumberedsec 3.5.4(28): Integer Types
7926
7927 @sp 1
7928 @cartouche
7929 An implementation should support @code{Long_Integer} in addition to
7930 @code{Integer} if the target machine supports 32-bit (or longer)
7931 arithmetic. No other named integer subtypes are recommended for package
7932 @code{Standard}. Instead, appropriate named integer subtypes should be
7933 provided in the library package @code{Interfaces} (see B.2).
7934 @end cartouche
7935 @code{Long_Integer} is supported. Other standard integer types are supported
7936 so this advice is not fully followed. These types
7937 are supported for convenient interface to C, and so that all hardware
7938 types of the machine are easily available.
7939 @unnumberedsec 3.5.4(29): Integer Types
7940
7941 @sp 1
7942 @cartouche
7943 An implementation for a two's complement machine should support
7944 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
7945 implementation should support a non-binary modules up to @code{Integer'Last}.
7946 @end cartouche
7947 Followed.
7948
7949 @cindex Enumeration values
7950 @unnumberedsec 3.5.5(8): Enumeration Values
7951 @sp 1
7952 @cartouche
7953 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
7954 subtype, if the value of the operand does not correspond to the internal
7955 code for any enumeration literal of its type (perhaps due to an
7956 un-initialized variable), then the implementation should raise
7957 @code{Program_Error}. This is particularly important for enumeration
7958 types with noncontiguous internal codes specified by an
7959 enumeration_representation_clause.
7960 @end cartouche
7961 Followed.
7962
7963 @cindex Float types
7964 @unnumberedsec 3.5.7(17): Float Types
7965 @sp 1
7966 @cartouche
7967 An implementation should support @code{Long_Float} in addition to
7968 @code{Float} if the target machine supports 11 or more digits of
7969 precision. No other named floating point subtypes are recommended for
7970 package @code{Standard}. Instead, appropriate named floating point subtypes
7971 should be provided in the library package @code{Interfaces} (see B.2).
7972 @end cartouche
7973 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
7974 former provides improved compatibility with other implementations
7975 supporting this type. The latter corresponds to the highest precision
7976 floating-point type supported by the hardware. On most machines, this
7977 will be the same as @code{Long_Float}, but on some machines, it will
7978 correspond to the IEEE extended form. The notable case is all ia32
7979 (x86) implementations, where @code{Long_Long_Float} corresponds to
7980 the 80-bit extended precision format supported in hardware on this
7981 processor. Note that the 128-bit format on SPARC is not supported,
7982 since this is a software rather than a hardware format.
7983
7984 @cindex Multidimensional arrays
7985 @cindex Arrays, multidimensional
7986 @unnumberedsec 3.6.2(11): Multidimensional Arrays
7987 @sp 1
7988 @cartouche
7989 An implementation should normally represent multidimensional arrays in
7990 row-major order, consistent with the notation used for multidimensional
7991 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
7992 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
7993 column-major order should be used instead (see B.5, ``Interfacing with
7994 Fortran'').
7995 @end cartouche
7996 Followed.
7997
7998 @findex Duration'Small
7999 @unnumberedsec 9.6(30-31): Duration'Small
8000 @sp 1
8001 @cartouche
8002 Whenever possible in an implementation, the value of @code{Duration'Small}
8003 should be no greater than 100 microseconds.
8004 @end cartouche
8005 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8006
8007 @sp 1
8008 @cartouche
8009 The time base for @code{delay_relative_statements} should be monotonic;
8010 it need not be the same time base as used for @code{Calendar.Clock}.
8011 @end cartouche
8012 Followed.
8013
8014 @unnumberedsec 10.2.1(12): Consistent Representation
8015 @sp 1
8016 @cartouche
8017 In an implementation, a type declared in a pre-elaborated package should
8018 have the same representation in every elaboration of a given version of
8019 the package, whether the elaborations occur in distinct executions of
8020 the same program, or in executions of distinct programs or partitions
8021 that include the given version.
8022 @end cartouche
8023 Followed, except in the case of tagged types. Tagged types involve
8024 implicit pointers to a local copy of a dispatch table, and these pointers
8025 have representations which thus depend on a particular elaboration of the
8026 package. It is not easy to see how it would be possible to follow this
8027 advice without severely impacting efficiency of execution.
8028
8029 @cindex Exception information
8030 @unnumberedsec 11.4.1(19): Exception Information
8031 @sp 1
8032 @cartouche
8033 @code{Exception_Message} by default and @code{Exception_Information}
8034 should produce information useful for
8035 debugging. @code{Exception_Message} should be short, about one
8036 line. @code{Exception_Information} can be long. @code{Exception_Message}
8037 should not include the
8038 @code{Exception_Name}. @code{Exception_Information} should include both
8039 the @code{Exception_Name} and the @code{Exception_Message}.
8040 @end cartouche
8041 Followed. For each exception that doesn't have a specified
8042 @code{Exception_Message}, the compiler generates one containing the location
8043 of the raise statement. This location has the form ``file:line'', where
8044 file is the short file name (without path information) and line is the line
8045 number in the file. Note that in the case of the Zero Cost Exception
8046 mechanism, these messages become redundant with the Exception_Information that
8047 contains a full backtrace of the calling sequence, so they are disabled.
8048 To disable explicitly the generation of the source location message, use the
8049 Pragma @code{Discard_Names}.
8050
8051 @cindex Suppression of checks
8052 @cindex Checks, suppression of
8053 @unnumberedsec 11.5(28): Suppression of Checks
8054 @sp 1
8055 @cartouche
8056 The implementation should minimize the code executed for checks that
8057 have been suppressed.
8058 @end cartouche
8059 Followed.
8060
8061 @cindex Representation clauses
8062 @unnumberedsec 13.1 (21-24): Representation Clauses
8063 @sp 1
8064 @cartouche
8065 The recommended level of support for all representation items is
8066 qualified as follows:
8067 @end cartouche
8068 @sp 1
8069 @cartouche
8070 An implementation need not support representation items containing
8071 non-static expressions, except that an implementation should support a
8072 representation item for a given entity if each non-static expression in
8073 the representation item is a name that statically denotes a constant
8074 declared before the entity.
8075 @end cartouche
8076 Followed. In fact, GNAT goes beyond the recommended level of support
8077 by allowing nonstatic expressions in some representation clauses even
8078 without the need to declare constants initialized with the values of
8079 such expressions.
8080 For example:
8081
8082 @smallexample @c ada
8083 X : Integer;
8084 Y : Float;
8085 for Y'Address use X'Address;>>
8086 @end smallexample
8087
8088 @sp 1
8089 @cartouche
8090 An implementation need not support a specification for the @code{Size}
8091 for a given composite subtype, nor the size or storage place for an
8092 object (including a component) of a given composite subtype, unless the
8093 constraints on the subtype and its composite subcomponents (if any) are
8094 all static constraints.
8095 @end cartouche
8096 Followed. Size Clauses are not permitted on non-static components, as
8097 described above.
8098
8099 @sp 1
8100 @cartouche
8101 An aliased component, or a component whose type is by-reference, should
8102 always be allocated at an addressable location.
8103 @end cartouche
8104 Followed.
8105
8106 @cindex Packed types
8107 @unnumberedsec 13.2(6-8): Packed Types
8108 @sp 1
8109 @cartouche
8110 If a type is packed, then the implementation should try to minimize
8111 storage allocated to objects of the type, possibly at the expense of
8112 speed of accessing components, subject to reasonable complexity in
8113 addressing calculations.
8114 @end cartouche
8115 @sp 1
8116 @cartouche
8117 The recommended level of support pragma @code{Pack} is:
8118
8119 For a packed record type, the components should be packed as tightly as
8120 possible subject to the Sizes of the component subtypes, and subject to
8121 any @code{record_representation_clause} that applies to the type; the
8122 implementation may, but need not, reorder components or cross aligned
8123 word boundaries to improve the packing. A component whose @code{Size} is
8124 greater than the word size may be allocated an integral number of words.
8125 @end cartouche
8126 Followed. Tight packing of arrays is supported for all component sizes
8127 up to 64-bits. If the array component size is 1 (that is to say, if
8128 the component is a boolean type or an enumeration type with two values)
8129 then values of the type are implicitly initialized to zero. This
8130 happens both for objects of the packed type, and for objects that have a
8131 subcomponent of the packed type.
8132
8133 @sp 1
8134 @cartouche
8135 An implementation should support Address clauses for imported
8136 subprograms.
8137 @end cartouche
8138 Followed.
8139 @cindex @code{Address} clauses
8140 @unnumberedsec 13.3(14-19): Address Clauses
8141
8142 @sp 1
8143 @cartouche
8144 For an array @var{X}, @code{@var{X}'Address} should point at the first
8145 component of the array, and not at the array bounds.
8146 @end cartouche
8147 Followed.
8148
8149 @sp 1
8150 @cartouche
8151 The recommended level of support for the @code{Address} attribute is:
8152
8153 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8154 object that is aliased or of a by-reference type, or is an entity whose
8155 @code{Address} has been specified.
8156 @end cartouche
8157 Followed. A valid address will be produced even if none of those
8158 conditions have been met. If necessary, the object is forced into
8159 memory to ensure the address is valid.
8160
8161 @sp 1
8162 @cartouche
8163 An implementation should support @code{Address} clauses for imported
8164 subprograms.
8165 @end cartouche
8166 Followed.
8167
8168 @sp 1
8169 @cartouche
8170 Objects (including subcomponents) that are aliased or of a by-reference
8171 type should be allocated on storage element boundaries.
8172 @end cartouche
8173 Followed.
8174
8175 @sp 1
8176 @cartouche
8177 If the @code{Address} of an object is specified, or it is imported or exported,
8178 then the implementation should not perform optimizations based on
8179 assumptions of no aliases.
8180 @end cartouche
8181 Followed.
8182
8183 @cindex @code{Alignment} clauses
8184 @unnumberedsec 13.3(29-35): Alignment Clauses
8185 @sp 1
8186 @cartouche
8187 The recommended level of support for the @code{Alignment} attribute for
8188 subtypes is:
8189
8190 An implementation should support specified Alignments that are factors
8191 and multiples of the number of storage elements per word, subject to the
8192 following:
8193 @end cartouche
8194 Followed.
8195
8196 @sp 1
8197 @cartouche
8198 An implementation need not support specified @code{Alignment}s for
8199 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8200 loaded and stored by available machine instructions.
8201 @end cartouche
8202 Followed.
8203
8204 @sp 1
8205 @cartouche
8206 An implementation need not support specified @code{Alignment}s that are
8207 greater than the maximum @code{Alignment} the implementation ever returns by
8208 default.
8209 @end cartouche
8210 Followed.
8211
8212 @sp 1
8213 @cartouche
8214 The recommended level of support for the @code{Alignment} attribute for
8215 objects is:
8216
8217 Same as above, for subtypes, but in addition:
8218 @end cartouche
8219 Followed.
8220
8221 @sp 1
8222 @cartouche
8223 For stand-alone library-level objects of statically constrained
8224 subtypes, the implementation should support all @code{Alignment}s
8225 supported by the target linker. For example, page alignment is likely to
8226 be supported for such objects, but not for subtypes.
8227 @end cartouche
8228 Followed.
8229
8230 @cindex @code{Size} clauses
8231 @unnumberedsec 13.3(42-43): Size Clauses
8232 @sp 1
8233 @cartouche
8234 The recommended level of support for the @code{Size} attribute of
8235 objects is:
8236
8237 A @code{Size} clause should be supported for an object if the specified
8238 @code{Size} is at least as large as its subtype's @code{Size}, and
8239 corresponds to a size in storage elements that is a multiple of the
8240 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8241 @end cartouche
8242 Followed.
8243
8244 @unnumberedsec 13.3(50-56): Size Clauses
8245 @sp 1
8246 @cartouche
8247 If the @code{Size} of a subtype is specified, and allows for efficient
8248 independent addressability (see 9.10) on the target architecture, then
8249 the @code{Size} of the following objects of the subtype should equal the
8250 @code{Size} of the subtype:
8251
8252 Aliased objects (including components).
8253 @end cartouche
8254 Followed.
8255
8256 @sp 1
8257 @cartouche
8258 @code{Size} clause on a composite subtype should not affect the
8259 internal layout of components.
8260 @end cartouche
8261 Followed. But note that this can be overridden by use of the implementation
8262 pragma Implicit_Packing in the case of packed arrays.
8263
8264 @sp 1
8265 @cartouche
8266 The recommended level of support for the @code{Size} attribute of subtypes is:
8267 @end cartouche
8268 @sp 1
8269 @cartouche
8270 The @code{Size} (if not specified) of a static discrete or fixed point
8271 subtype should be the number of bits needed to represent each value
8272 belonging to the subtype using an unbiased representation, leaving space
8273 for a sign bit only if the subtype contains negative values. If such a
8274 subtype is a first subtype, then an implementation should support a
8275 specified @code{Size} for it that reflects this representation.
8276 @end cartouche
8277 Followed.
8278
8279 @sp 1
8280 @cartouche
8281 For a subtype implemented with levels of indirection, the @code{Size}
8282 should include the size of the pointers, but not the size of what they
8283 point at.
8284 @end cartouche
8285 Followed.
8286
8287 @cindex @code{Component_Size} clauses
8288 @unnumberedsec 13.3(71-73): Component Size Clauses
8289 @sp 1
8290 @cartouche
8291 The recommended level of support for the @code{Component_Size}
8292 attribute is:
8293 @end cartouche
8294 @sp 1
8295 @cartouche
8296 An implementation need not support specified @code{Component_Sizes} that are
8297 less than the @code{Size} of the component subtype.
8298 @end cartouche
8299 Followed.
8300
8301 @sp 1
8302 @cartouche
8303 An implementation should support specified @code{Component_Size}s that
8304 are factors and multiples of the word size. For such
8305 @code{Component_Size}s, the array should contain no gaps between
8306 components. For other @code{Component_Size}s (if supported), the array
8307 should contain no gaps between components when packing is also
8308 specified; the implementation should forbid this combination in cases
8309 where it cannot support a no-gaps representation.
8310 @end cartouche
8311 Followed.
8312
8313 @cindex Enumeration representation clauses
8314 @cindex Representation clauses, enumeration
8315 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8316 @sp 1
8317 @cartouche
8318 The recommended level of support for enumeration representation clauses
8319 is:
8320
8321 An implementation need not support enumeration representation clauses
8322 for boolean types, but should at minimum support the internal codes in
8323 the range @code{System.Min_Int.System.Max_Int}.
8324 @end cartouche
8325 Followed.
8326
8327 @cindex Record representation clauses
8328 @cindex Representation clauses, records
8329 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8330 @sp 1
8331 @cartouche
8332 The recommended level of support for
8333 @*@code{record_representation_clauses} is:
8334
8335 An implementation should support storage places that can be extracted
8336 with a load, mask, shift sequence of machine code, and set with a load,
8337 shift, mask, store sequence, given the available machine instructions
8338 and run-time model.
8339 @end cartouche
8340 Followed.
8341
8342 @sp 1
8343 @cartouche
8344 A storage place should be supported if its size is equal to the
8345 @code{Size} of the component subtype, and it starts and ends on a
8346 boundary that obeys the @code{Alignment} of the component subtype.
8347 @end cartouche
8348 Followed.
8349
8350 @sp 1
8351 @cartouche
8352 If the default bit ordering applies to the declaration of a given type,
8353 then for a component whose subtype's @code{Size} is less than the word
8354 size, any storage place that does not cross an aligned word boundary
8355 should be supported.
8356 @end cartouche
8357 Followed.
8358
8359 @sp 1
8360 @cartouche
8361 An implementation may reserve a storage place for the tag field of a
8362 tagged type, and disallow other components from overlapping that place.
8363 @end cartouche
8364 Followed. The storage place for the tag field is the beginning of the tagged
8365 record, and its size is Address'Size. GNAT will reject an explicit component
8366 clause for the tag field.
8367
8368 @sp 1
8369 @cartouche
8370 An implementation need not support a @code{component_clause} for a
8371 component of an extension part if the storage place is not after the
8372 storage places of all components of the parent type, whether or not
8373 those storage places had been specified.
8374 @end cartouche
8375 Followed. The above advice on record representation clauses is followed,
8376 and all mentioned features are implemented.
8377
8378 @cindex Storage place attributes
8379 @unnumberedsec 13.5.2(5): Storage Place Attributes
8380 @sp 1
8381 @cartouche
8382 If a component is represented using some form of pointer (such as an
8383 offset) to the actual data of the component, and this data is contiguous
8384 with the rest of the object, then the storage place attributes should
8385 reflect the place of the actual data, not the pointer. If a component is
8386 allocated discontinuously from the rest of the object, then a warning
8387 should be generated upon reference to one of its storage place
8388 attributes.
8389 @end cartouche
8390 Followed. There are no such components in GNAT@.
8391
8392 @cindex Bit ordering
8393 @unnumberedsec 13.5.3(7-8): Bit Ordering
8394 @sp 1
8395 @cartouche
8396 The recommended level of support for the non-default bit ordering is:
8397 @end cartouche
8398 @sp 1
8399 @cartouche
8400 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
8401 should support the non-default bit ordering in addition to the default
8402 bit ordering.
8403 @end cartouche
8404 Followed. Word size does not equal storage size in this implementation.
8405 Thus non-default bit ordering is not supported.
8406
8407 @cindex @code{Address}, as private type
8408 @unnumberedsec 13.7(37): Address as Private
8409 @sp 1
8410 @cartouche
8411 @code{Address} should be of a private type.
8412 @end cartouche
8413 Followed.
8414
8415 @cindex Operations, on @code{Address}
8416 @cindex @code{Address}, operations of
8417 @unnumberedsec 13.7.1(16): Address Operations
8418 @sp 1
8419 @cartouche
8420 Operations in @code{System} and its children should reflect the target
8421 environment semantics as closely as is reasonable. For example, on most
8422 machines, it makes sense for address arithmetic to ``wrap around''.
8423 Operations that do not make sense should raise @code{Program_Error}.
8424 @end cartouche
8425 Followed. Address arithmetic is modular arithmetic that wraps around. No
8426 operation raises @code{Program_Error}, since all operations make sense.
8427
8428 @cindex Unchecked conversion
8429 @unnumberedsec 13.9(14-17): Unchecked Conversion
8430 @sp 1
8431 @cartouche
8432 The @code{Size} of an array object should not include its bounds; hence,
8433 the bounds should not be part of the converted data.
8434 @end cartouche
8435 Followed.
8436
8437 @sp 1
8438 @cartouche
8439 The implementation should not generate unnecessary run-time checks to
8440 ensure that the representation of @var{S} is a representation of the
8441 target type. It should take advantage of the permission to return by
8442 reference when possible. Restrictions on unchecked conversions should be
8443 avoided unless required by the target environment.
8444 @end cartouche
8445 Followed. There are no restrictions on unchecked conversion. A warning is
8446 generated if the source and target types do not have the same size since
8447 the semantics in this case may be target dependent.
8448
8449 @sp 1
8450 @cartouche
8451 The recommended level of support for unchecked conversions is:
8452 @end cartouche
8453 @sp 1
8454 @cartouche
8455 Unchecked conversions should be supported and should be reversible in
8456 the cases where this clause defines the result. To enable meaningful use
8457 of unchecked conversion, a contiguous representation should be used for
8458 elementary subtypes, for statically constrained array subtypes whose
8459 component subtype is one of the subtypes described in this paragraph,
8460 and for record subtypes without discriminants whose component subtypes
8461 are described in this paragraph.
8462 @end cartouche
8463 Followed.
8464
8465 @cindex Heap usage, implicit
8466 @unnumberedsec 13.11(23-25): Implicit Heap Usage
8467 @sp 1
8468 @cartouche
8469 An implementation should document any cases in which it dynamically
8470 allocates heap storage for a purpose other than the evaluation of an
8471 allocator.
8472 @end cartouche
8473 Followed, the only other points at which heap storage is dynamically
8474 allocated are as follows:
8475
8476 @itemize @bullet
8477 @item
8478 At initial elaboration time, to allocate dynamically sized global
8479 objects.
8480
8481 @item
8482 To allocate space for a task when a task is created.
8483
8484 @item
8485 To extend the secondary stack dynamically when needed. The secondary
8486 stack is used for returning variable length results.
8487 @end itemize
8488
8489 @sp 1
8490 @cartouche
8491 A default (implementation-provided) storage pool for an
8492 access-to-constant type should not have overhead to support deallocation of
8493 individual objects.
8494 @end cartouche
8495 Followed.
8496
8497 @sp 1
8498 @cartouche
8499 A storage pool for an anonymous access type should be created at the
8500 point of an allocator for the type, and be reclaimed when the designated
8501 object becomes inaccessible.
8502 @end cartouche
8503 Followed.
8504
8505 @cindex Unchecked deallocation
8506 @unnumberedsec 13.11.2(17): Unchecked De-allocation
8507 @sp 1
8508 @cartouche
8509 For a standard storage pool, @code{Free} should actually reclaim the
8510 storage.
8511 @end cartouche
8512 Followed.
8513
8514 @cindex Stream oriented attributes
8515 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
8516 @sp 1
8517 @cartouche
8518 If a stream element is the same size as a storage element, then the
8519 normal in-memory representation should be used by @code{Read} and
8520 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
8521 should use the smallest number of stream elements needed to represent
8522 all values in the base range of the scalar type.
8523 @end cartouche
8524
8525 Followed. By default, GNAT uses the interpretation suggested by AI-195,
8526 which specifies using the size of the first subtype.
8527 However, such an implementation is based on direct binary
8528 representations and is therefore target- and endianness-dependent.
8529 To address this issue, GNAT also supplies an alternate implementation
8530 of the stream attributes @code{Read} and @code{Write},
8531 which uses the target-independent XDR standard representation
8532 for scalar types.
8533 @cindex XDR representation
8534 @cindex @code{Read} attribute
8535 @cindex @code{Write} attribute
8536 @cindex Stream oriented attributes
8537 The XDR implementation is provided as an alternative body of the
8538 @code{System.Stream_Attributes} package, in the file
8539 @file{s-stratt-xdr.adb} in the GNAT library.
8540 There is no @file{s-stratt-xdr.ads} file.
8541 In order to install the XDR implementation, do the following:
8542 @enumerate
8543 @item Replace the default implementation of the
8544 @code{System.Stream_Attributes} package with the XDR implementation.
8545 For example on a Unix platform issue the commands:
8546 @smallexample
8547 $ mv s-stratt.adb s-stratt-default.adb
8548 $ mv s-stratt-xdr.adb s-stratt.adb
8549 @end smallexample
8550
8551 @item
8552 Rebuild the GNAT run-time library as documented in
8553 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
8554 @end enumerate
8555
8556 @unnumberedsec A.1(52): Names of Predefined Numeric Types
8557 @sp 1
8558 @cartouche
8559 If an implementation provides additional named predefined integer types,
8560 then the names should end with @samp{Integer} as in
8561 @samp{Long_Integer}. If an implementation provides additional named
8562 predefined floating point types, then the names should end with
8563 @samp{Float} as in @samp{Long_Float}.
8564 @end cartouche
8565 Followed.
8566
8567 @findex Ada.Characters.Handling
8568 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
8569 @sp 1
8570 @cartouche
8571 If an implementation provides a localized definition of @code{Character}
8572 or @code{Wide_Character}, then the effects of the subprograms in
8573 @code{Characters.Handling} should reflect the localizations. See also
8574 3.5.2.
8575 @end cartouche
8576 Followed. GNAT provides no such localized definitions.
8577
8578 @cindex Bounded-length strings
8579 @unnumberedsec A.4.4(106): Bounded-Length String Handling
8580 @sp 1
8581 @cartouche
8582 Bounded string objects should not be implemented by implicit pointers
8583 and dynamic allocation.
8584 @end cartouche
8585 Followed. No implicit pointers or dynamic allocation are used.
8586
8587 @cindex Random number generation
8588 @unnumberedsec A.5.2(46-47): Random Number Generation
8589 @sp 1
8590 @cartouche
8591 Any storage associated with an object of type @code{Generator} should be
8592 reclaimed on exit from the scope of the object.
8593 @end cartouche
8594 Followed.
8595
8596 @sp 1
8597 @cartouche
8598 If the generator period is sufficiently long in relation to the number
8599 of distinct initiator values, then each possible value of
8600 @code{Initiator} passed to @code{Reset} should initiate a sequence of
8601 random numbers that does not, in a practical sense, overlap the sequence
8602 initiated by any other value. If this is not possible, then the mapping
8603 between initiator values and generator states should be a rapidly
8604 varying function of the initiator value.
8605 @end cartouche
8606 Followed. The generator period is sufficiently long for the first
8607 condition here to hold true.
8608
8609 @findex Get_Immediate
8610 @unnumberedsec A.10.7(23): @code{Get_Immediate}
8611 @sp 1
8612 @cartouche
8613 The @code{Get_Immediate} procedures should be implemented with
8614 unbuffered input. For a device such as a keyboard, input should be
8615 @dfn{available} if a key has already been typed, whereas for a disk
8616 file, input should always be available except at end of file. For a file
8617 associated with a keyboard-like device, any line-editing features of the
8618 underlying operating system should be disabled during the execution of
8619 @code{Get_Immediate}.
8620 @end cartouche
8621 Followed on all targets except VxWorks. For VxWorks, there is no way to
8622 provide this functionality that does not result in the input buffer being
8623 flushed before the @code{Get_Immediate} call. A special unit
8624 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
8625 this functionality.
8626
8627 @findex Export
8628 @unnumberedsec B.1(39-41): Pragma @code{Export}
8629 @sp 1
8630 @cartouche
8631 If an implementation supports pragma @code{Export} to a given language,
8632 then it should also allow the main subprogram to be written in that
8633 language. It should support some mechanism for invoking the elaboration
8634 of the Ada library units included in the system, and for invoking the
8635 finalization of the environment task. On typical systems, the
8636 recommended mechanism is to provide two subprograms whose link names are
8637 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
8638 elaboration code for library units. @code{adafinal} should contain the
8639 finalization code. These subprograms should have no effect the second
8640 and subsequent time they are called.
8641 @end cartouche
8642 Followed.
8643
8644 @sp 1
8645 @cartouche
8646 Automatic elaboration of pre-elaborated packages should be
8647 provided when pragma @code{Export} is supported.
8648 @end cartouche
8649 Followed when the main program is in Ada. If the main program is in a
8650 foreign language, then
8651 @code{adainit} must be called to elaborate pre-elaborated
8652 packages.
8653
8654 @sp 1
8655 @cartouche
8656 For each supported convention @var{L} other than @code{Intrinsic}, an
8657 implementation should support @code{Import} and @code{Export} pragmas
8658 for objects of @var{L}-compatible types and for subprograms, and pragma
8659 @code{Convention} for @var{L}-eligible types and for subprograms,
8660 presuming the other language has corresponding features. Pragma
8661 @code{Convention} need not be supported for scalar types.
8662 @end cartouche
8663 Followed.
8664
8665 @cindex Package @code{Interfaces}
8666 @findex Interfaces
8667 @unnumberedsec B.2(12-13): Package @code{Interfaces}
8668 @sp 1
8669 @cartouche
8670 For each implementation-defined convention identifier, there should be a
8671 child package of package Interfaces with the corresponding name. This
8672 package should contain any declarations that would be useful for
8673 interfacing to the language (implementation) represented by the
8674 convention. Any declarations useful for interfacing to any language on
8675 the given hardware architecture should be provided directly in
8676 @code{Interfaces}.
8677 @end cartouche
8678 Followed. An additional package not defined
8679 in the Ada Reference Manual is @code{Interfaces.CPP}, used
8680 for interfacing to C++.
8681
8682 @sp 1
8683 @cartouche
8684 An implementation supporting an interface to C, COBOL, or Fortran should
8685 provide the corresponding package or packages described in the following
8686 clauses.
8687 @end cartouche
8688 Followed. GNAT provides all the packages described in this section.
8689
8690 @cindex C, interfacing with
8691 @unnumberedsec B.3(63-71): Interfacing with C
8692 @sp 1
8693 @cartouche
8694 An implementation should support the following interface correspondences
8695 between Ada and C@.
8696 @end cartouche
8697 Followed.
8698
8699 @sp 1
8700 @cartouche
8701 An Ada procedure corresponds to a void-returning C function.
8702 @end cartouche
8703 Followed.
8704
8705 @sp 1
8706 @cartouche
8707 An Ada function corresponds to a non-void C function.
8708 @end cartouche
8709 Followed.
8710
8711 @sp 1
8712 @cartouche
8713 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
8714 function.
8715 @end cartouche
8716 Followed.
8717
8718 @sp 1
8719 @cartouche
8720 An Ada @code{in} parameter of an access-to-object type with designated
8721 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
8722 where @var{t} is the C type corresponding to the Ada type @var{T}.
8723 @end cartouche
8724 Followed.
8725
8726 @sp 1
8727 @cartouche
8728 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
8729 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
8730 argument to a C function, where @var{t} is the C type corresponding to
8731 the Ada type @var{T}. In the case of an elementary @code{out} or
8732 @code{in out} parameter, a pointer to a temporary copy is used to
8733 preserve by-copy semantics.
8734 @end cartouche
8735 Followed.
8736
8737 @sp 1
8738 @cartouche
8739 An Ada parameter of a record type @var{T}, of any mode, is passed as a
8740 @code{@var{t}*} argument to a C function, where @var{t} is the C
8741 structure corresponding to the Ada type @var{T}.
8742 @end cartouche
8743 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
8744 pragma, or Convention, or by explicitly specifying the mechanism for a given
8745 call using an extended import or export pragma.
8746
8747 @sp 1
8748 @cartouche
8749 An Ada parameter of an array type with component type @var{T}, of any
8750 mode, is passed as a @code{@var{t}*} argument to a C function, where
8751 @var{t} is the C type corresponding to the Ada type @var{T}.
8752 @end cartouche
8753 Followed.
8754
8755 @sp 1
8756 @cartouche
8757 An Ada parameter of an access-to-subprogram type is passed as a pointer
8758 to a C function whose prototype corresponds to the designated
8759 subprogram's specification.
8760 @end cartouche
8761 Followed.
8762
8763 @cindex COBOL, interfacing with
8764 @unnumberedsec B.4(95-98): Interfacing with COBOL
8765 @sp 1
8766 @cartouche
8767 An Ada implementation should support the following interface
8768 correspondences between Ada and COBOL@.
8769 @end cartouche
8770 Followed.
8771
8772 @sp 1
8773 @cartouche
8774 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
8775 the COBOL type corresponding to @var{T}.
8776 @end cartouche
8777 Followed.
8778
8779 @sp 1
8780 @cartouche
8781 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
8782 the corresponding COBOL type.
8783 @end cartouche
8784 Followed.
8785
8786 @sp 1
8787 @cartouche
8788 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
8789 COBOL type corresponding to the Ada parameter type; for scalars, a local
8790 copy is used if necessary to ensure by-copy semantics.
8791 @end cartouche
8792 Followed.
8793
8794 @cindex Fortran, interfacing with
8795 @unnumberedsec B.5(22-26): Interfacing with Fortran
8796 @sp 1
8797 @cartouche
8798 An Ada implementation should support the following interface
8799 correspondences between Ada and Fortran:
8800 @end cartouche
8801 Followed.
8802
8803 @sp 1
8804 @cartouche
8805 An Ada procedure corresponds to a Fortran subroutine.
8806 @end cartouche
8807 Followed.
8808
8809 @sp 1
8810 @cartouche
8811 An Ada function corresponds to a Fortran function.
8812 @end cartouche
8813 Followed.
8814
8815 @sp 1
8816 @cartouche
8817 An Ada parameter of an elementary, array, or record type @var{T} is
8818 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
8819 the Fortran type corresponding to the Ada type @var{T}, and where the
8820 INTENT attribute of the corresponding dummy argument matches the Ada
8821 formal parameter mode; the Fortran implementation's parameter passing
8822 conventions are used. For elementary types, a local copy is used if
8823 necessary to ensure by-copy semantics.
8824 @end cartouche
8825 Followed.
8826
8827 @sp 1
8828 @cartouche
8829 An Ada parameter of an access-to-subprogram type is passed as a
8830 reference to a Fortran procedure whose interface corresponds to the
8831 designated subprogram's specification.
8832 @end cartouche
8833 Followed.
8834
8835 @cindex Machine operations
8836 @unnumberedsec C.1(3-5): Access to Machine Operations
8837 @sp 1
8838 @cartouche
8839 The machine code or intrinsic support should allow access to all
8840 operations normally available to assembly language programmers for the
8841 target environment, including privileged instructions, if any.
8842 @end cartouche
8843 Followed.
8844
8845 @sp 1
8846 @cartouche
8847 The interfacing pragmas (see Annex B) should support interface to
8848 assembler; the default assembler should be associated with the
8849 convention identifier @code{Assembler}.
8850 @end cartouche
8851 Followed.
8852
8853 @sp 1
8854 @cartouche
8855 If an entity is exported to assembly language, then the implementation
8856 should allocate it at an addressable location, and should ensure that it
8857 is retained by the linking process, even if not otherwise referenced
8858 from the Ada code. The implementation should assume that any call to a
8859 machine code or assembler subprogram is allowed to read or update every
8860 object that is specified as exported.
8861 @end cartouche
8862 Followed.
8863
8864 @unnumberedsec C.1(10-16): Access to Machine Operations
8865 @sp 1
8866 @cartouche
8867 The implementation should ensure that little or no overhead is
8868 associated with calling intrinsic and machine-code subprograms.
8869 @end cartouche
8870 Followed for both intrinsics and machine-code subprograms.
8871
8872 @sp 1
8873 @cartouche
8874 It is recommended that intrinsic subprograms be provided for convenient
8875 access to any machine operations that provide special capabilities or
8876 efficiency and that are not otherwise available through the language
8877 constructs.
8878 @end cartouche
8879 Followed. A full set of machine operation intrinsic subprograms is provided.
8880
8881 @sp 1
8882 @cartouche
8883 Atomic read-modify-write operations---e.g.@:, test and set, compare and
8884 swap, decrement and test, enqueue/dequeue.
8885 @end cartouche
8886 Followed on any target supporting such operations.
8887
8888 @sp 1
8889 @cartouche
8890 Standard numeric functions---e.g.@:, sin, log.
8891 @end cartouche
8892 Followed on any target supporting such operations.
8893
8894 @sp 1
8895 @cartouche
8896 String manipulation operations---e.g.@:, translate and test.
8897 @end cartouche
8898 Followed on any target supporting such operations.
8899
8900 @sp 1
8901 @cartouche
8902 Vector operations---e.g.@:, compare vector against thresholds.
8903 @end cartouche
8904 Followed on any target supporting such operations.
8905
8906 @sp 1
8907 @cartouche
8908 Direct operations on I/O ports.
8909 @end cartouche
8910 Followed on any target supporting such operations.
8911
8912 @cindex Interrupt support
8913 @unnumberedsec C.3(28): Interrupt Support
8914 @sp 1
8915 @cartouche
8916 If the @code{Ceiling_Locking} policy is not in effect, the
8917 implementation should provide means for the application to specify which
8918 interrupts are to be blocked during protected actions, if the underlying
8919 system allows for a finer-grain control of interrupt blocking.
8920 @end cartouche
8921 Followed. The underlying system does not allow for finer-grain control
8922 of interrupt blocking.
8923
8924 @cindex Protected procedure handlers
8925 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
8926 @sp 1
8927 @cartouche
8928 Whenever possible, the implementation should allow interrupt handlers to
8929 be called directly by the hardware.
8930 @end cartouche
8931 @c SGI info:
8932 @ignore
8933 This is never possible under IRIX, so this is followed by default.
8934 @end ignore
8935 Followed on any target where the underlying operating system permits
8936 such direct calls.
8937
8938 @sp 1
8939 @cartouche
8940 Whenever practical, violations of any
8941 implementation-defined restrictions should be detected before run time.
8942 @end cartouche
8943 Followed. Compile time warnings are given when possible.
8944
8945 @cindex Package @code{Interrupts}
8946 @findex Interrupts
8947 @unnumberedsec C.3.2(25): Package @code{Interrupts}
8948
8949 @sp 1
8950 @cartouche
8951 If implementation-defined forms of interrupt handler procedures are
8952 supported, such as protected procedures with parameters, then for each
8953 such form of a handler, a type analogous to @code{Parameterless_Handler}
8954 should be specified in a child package of @code{Interrupts}, with the
8955 same operations as in the predefined package Interrupts.
8956 @end cartouche
8957 Followed.
8958
8959 @cindex Pre-elaboration requirements
8960 @unnumberedsec C.4(14): Pre-elaboration Requirements
8961 @sp 1
8962 @cartouche
8963 It is recommended that pre-elaborated packages be implemented in such a
8964 way that there should be little or no code executed at run time for the
8965 elaboration of entities not already covered by the Implementation
8966 Requirements.
8967 @end cartouche
8968 Followed. Executable code is generated in some cases, e.g.@: loops
8969 to initialize large arrays.
8970
8971 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
8972 @sp 1
8973 @cartouche
8974 If the pragma applies to an entity, then the implementation should
8975 reduce the amount of storage used for storing names associated with that
8976 entity.
8977 @end cartouche
8978 Followed.
8979
8980 @cindex Package @code{Task_Attributes}
8981 @findex Task_Attributes
8982 @unnumberedsec C.7.2(30): The Package Task_Attributes
8983 @sp 1
8984 @cartouche
8985 Some implementations are targeted to domains in which memory use at run
8986 time must be completely deterministic. For such implementations, it is
8987 recommended that the storage for task attributes will be pre-allocated
8988 statically and not from the heap. This can be accomplished by either
8989 placing restrictions on the number and the size of the task's
8990 attributes, or by using the pre-allocated storage for the first @var{N}
8991 attribute objects, and the heap for the others. In the latter case,
8992 @var{N} should be documented.
8993 @end cartouche
8994 Not followed. This implementation is not targeted to such a domain.
8995
8996 @cindex Locking Policies
8997 @unnumberedsec D.3(17): Locking Policies
8998
8999 @sp 1
9000 @cartouche
9001 The implementation should use names that end with @samp{_Locking} for
9002 locking policies defined by the implementation.
9003 @end cartouche
9004 Followed. Two implementation-defined locking policies are defined,
9005 whose names (@code{Inheritance_Locking} and
9006 @code{Concurrent_Readers_Locking}) follow this suggestion.
9007
9008 @cindex Entry queuing policies
9009 @unnumberedsec D.4(16): Entry Queuing Policies
9010 @sp 1
9011 @cartouche
9012 Names that end with @samp{_Queuing} should be used
9013 for all implementation-defined queuing policies.
9014 @end cartouche
9015 Followed. No such implementation-defined queuing policies exist.
9016
9017 @cindex Preemptive abort
9018 @unnumberedsec D.6(9-10): Preemptive Abort
9019 @sp 1
9020 @cartouche
9021 Even though the @code{abort_statement} is included in the list of
9022 potentially blocking operations (see 9.5.1), it is recommended that this
9023 statement be implemented in a way that never requires the task executing
9024 the @code{abort_statement} to block.
9025 @end cartouche
9026 Followed.
9027
9028 @sp 1
9029 @cartouche
9030 On a multi-processor, the delay associated with aborting a task on
9031 another processor should be bounded; the implementation should use
9032 periodic polling, if necessary, to achieve this.
9033 @end cartouche
9034 Followed.
9035
9036 @cindex Tasking restrictions
9037 @unnumberedsec D.7(21): Tasking Restrictions
9038 @sp 1
9039 @cartouche
9040 When feasible, the implementation should take advantage of the specified
9041 restrictions to produce a more efficient implementation.
9042 @end cartouche
9043 GNAT currently takes advantage of these restrictions by providing an optimized
9044 run time when the Ravenscar profile and the GNAT restricted run time set
9045 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9046 pragma @code{Profile (Restricted)} for more details.
9047
9048 @cindex Time, monotonic
9049 @unnumberedsec D.8(47-49): Monotonic Time
9050 @sp 1
9051 @cartouche
9052 When appropriate, implementations should provide configuration
9053 mechanisms to change the value of @code{Tick}.
9054 @end cartouche
9055 Such configuration mechanisms are not appropriate to this implementation
9056 and are thus not supported.
9057
9058 @sp 1
9059 @cartouche
9060 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9061 be implemented as transformations of the same time base.
9062 @end cartouche
9063 Followed.
9064
9065 @sp 1
9066 @cartouche
9067 It is recommended that the @dfn{best} time base which exists in
9068 the underlying system be available to the application through
9069 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9070 @end cartouche
9071 Followed.
9072
9073 @cindex Partition communication subsystem
9074 @cindex PCS
9075 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9076 @sp 1
9077 @cartouche
9078 Whenever possible, the PCS on the called partition should allow for
9079 multiple tasks to call the RPC-receiver with different messages and
9080 should allow them to block until the corresponding subprogram body
9081 returns.
9082 @end cartouche
9083 Followed by GLADE, a separately supplied PCS that can be used with
9084 GNAT.
9085
9086 @sp 1
9087 @cartouche
9088 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9089 should raise @code{Storage_Error} if it runs out of space trying to
9090 write the @code{Item} into the stream.
9091 @end cartouche
9092 Followed by GLADE, a separately supplied PCS that can be used with
9093 GNAT@.
9094
9095 @cindex COBOL support
9096 @unnumberedsec F(7): COBOL Support
9097 @sp 1
9098 @cartouche
9099 If COBOL (respectively, C) is widely supported in the target
9100 environment, implementations supporting the Information Systems Annex
9101 should provide the child package @code{Interfaces.COBOL} (respectively,
9102 @code{Interfaces.C}) specified in Annex B and should support a
9103 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9104 pragmas (see Annex B), thus allowing Ada programs to interface with
9105 programs written in that language.
9106 @end cartouche
9107 Followed.
9108
9109 @cindex Decimal radix support
9110 @unnumberedsec F.1(2): Decimal Radix Support
9111 @sp 1
9112 @cartouche
9113 Packed decimal should be used as the internal representation for objects
9114 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9115 @end cartouche
9116 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9117 representations.
9118
9119 @cindex Numerics
9120 @unnumberedsec G: Numerics
9121 @sp 2
9122 @cartouche
9123 If Fortran (respectively, C) is widely supported in the target
9124 environment, implementations supporting the Numerics Annex
9125 should provide the child package @code{Interfaces.Fortran} (respectively,
9126 @code{Interfaces.C}) specified in Annex B and should support a
9127 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9128 pragmas (see Annex B), thus allowing Ada programs to interface with
9129 programs written in that language.
9130 @end cartouche
9131 Followed.
9132
9133 @cindex Complex types
9134 @unnumberedsec G.1.1(56-58): Complex Types
9135 @sp 2
9136 @cartouche
9137 Because the usual mathematical meaning of multiplication of a complex
9138 operand and a real operand is that of the scaling of both components of
9139 the former by the latter, an implementation should not perform this
9140 operation by first promoting the real operand to complex type and then
9141 performing a full complex multiplication. In systems that, in the
9142 future, support an Ada binding to IEC 559:1989, the latter technique
9143 will not generate the required result when one of the components of the
9144 complex operand is infinite. (Explicit multiplication of the infinite
9145 component by the zero component obtained during promotion yields a NaN
9146 that propagates into the final result.) Analogous advice applies in the
9147 case of multiplication of a complex operand and a pure-imaginary
9148 operand, and in the case of division of a complex operand by a real or
9149 pure-imaginary operand.
9150 @end cartouche
9151 Not followed.
9152
9153 @sp 1
9154 @cartouche
9155 Similarly, because the usual mathematical meaning of addition of a
9156 complex operand and a real operand is that the imaginary operand remains
9157 unchanged, an implementation should not perform this operation by first
9158 promoting the real operand to complex type and then performing a full
9159 complex addition. In implementations in which the @code{Signed_Zeros}
9160 attribute of the component type is @code{True} (and which therefore
9161 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9162 predefined arithmetic operations), the latter technique will not
9163 generate the required result when the imaginary component of the complex
9164 operand is a negatively signed zero. (Explicit addition of the negative
9165 zero to the zero obtained during promotion yields a positive zero.)
9166 Analogous advice applies in the case of addition of a complex operand
9167 and a pure-imaginary operand, and in the case of subtraction of a
9168 complex operand and a real or pure-imaginary operand.
9169 @end cartouche
9170 Not followed.
9171
9172 @sp 1
9173 @cartouche
9174 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9175 attempt to provide a rational treatment of the signs of zero results and
9176 result components. As one example, the result of the @code{Argument}
9177 function should have the sign of the imaginary component of the
9178 parameter @code{X} when the point represented by that parameter lies on
9179 the positive real axis; as another, the sign of the imaginary component
9180 of the @code{Compose_From_Polar} function should be the same as
9181 (respectively, the opposite of) that of the @code{Argument} parameter when that
9182 parameter has a value of zero and the @code{Modulus} parameter has a
9183 nonnegative (respectively, negative) value.
9184 @end cartouche
9185 Followed.
9186
9187 @cindex Complex elementary functions
9188 @unnumberedsec G.1.2(49): Complex Elementary Functions
9189 @sp 1
9190 @cartouche
9191 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9192 @code{True} should attempt to provide a rational treatment of the signs
9193 of zero results and result components. For example, many of the complex
9194 elementary functions have components that are odd functions of one of
9195 the parameter components; in these cases, the result component should
9196 have the sign of the parameter component at the origin. Other complex
9197 elementary functions have zero components whose sign is opposite that of
9198 a parameter component at the origin, or is always positive or always
9199 negative.
9200 @end cartouche
9201 Followed.
9202
9203 @cindex Accuracy requirements
9204 @unnumberedsec G.2.4(19): Accuracy Requirements
9205 @sp 1
9206 @cartouche
9207 The versions of the forward trigonometric functions without a
9208 @code{Cycle} parameter should not be implemented by calling the
9209 corresponding version with a @code{Cycle} parameter of
9210 @code{2.0*Numerics.Pi}, since this will not provide the required
9211 accuracy in some portions of the domain. For the same reason, the
9212 version of @code{Log} without a @code{Base} parameter should not be
9213 implemented by calling the corresponding version with a @code{Base}
9214 parameter of @code{Numerics.e}.
9215 @end cartouche
9216 Followed.
9217
9218 @cindex Complex arithmetic accuracy
9219 @cindex Accuracy, complex arithmetic
9220 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9221
9222 @sp 1
9223 @cartouche
9224 The version of the @code{Compose_From_Polar} function without a
9225 @code{Cycle} parameter should not be implemented by calling the
9226 corresponding version with a @code{Cycle} parameter of
9227 @code{2.0*Numerics.Pi}, since this will not provide the required
9228 accuracy in some portions of the domain.
9229 @end cartouche
9230 Followed.
9231
9232 @c -----------------------------------------
9233 @node Implementation Defined Characteristics
9234 @chapter Implementation Defined Characteristics
9235
9236 @noindent
9237 In addition to the implementation dependent pragmas and attributes, and the
9238 implementation advice, there are a number of other Ada features that are
9239 potentially implementation dependent and are designated as
9240 implementation-defined. These are mentioned throughout the Ada Reference
9241 Manual, and are summarized in Annex M@.
9242
9243 A requirement for conforming Ada compilers is that they provide
9244 documentation describing how the implementation deals with each of these
9245 issues. In this chapter, you will find each point in Annex M listed
9246 followed by a description in italic font of how GNAT
9247 @c SGI info:
9248 @ignore
9249 in the ProDev Ada
9250 implementation on IRIX 5.3 operating system or greater
9251 @end ignore
9252 handles the implementation dependence.
9253
9254 You can use this chapter as a guide to minimizing implementation
9255 dependent features in your programs if portability to other compilers
9256 and other operating systems is an important consideration. The numbers
9257 in each section below correspond to the paragraph number in the Ada
9258 Reference Manual.
9259
9260 @sp 1
9261 @cartouche
9262 @noindent
9263 @strong{2}. Whether or not each recommendation given in Implementation
9264 Advice is followed. See 1.1.2(37).
9265 @end cartouche
9266 @noindent
9267 @xref{Implementation Advice}.
9268
9269 @sp 1
9270 @cartouche
9271 @noindent
9272 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9273 @end cartouche
9274 @noindent
9275 The complexity of programs that can be processed is limited only by the
9276 total amount of available virtual memory, and disk space for the
9277 generated object files.
9278
9279 @sp 1
9280 @cartouche
9281 @noindent
9282 @strong{4}. Variations from the standard that are impractical to avoid
9283 given the implementation's execution environment. See 1.1.3(6).
9284 @end cartouche
9285 @noindent
9286 There are no variations from the standard.
9287
9288 @sp 1
9289 @cartouche
9290 @noindent
9291 @strong{5}. Which @code{code_statement}s cause external
9292 interactions. See 1.1.3(10).
9293 @end cartouche
9294 @noindent
9295 Any @code{code_statement} can potentially cause external interactions.
9296
9297 @sp 1
9298 @cartouche
9299 @noindent
9300 @strong{6}. The coded representation for the text of an Ada
9301 program. See 2.1(4).
9302 @end cartouche
9303 @noindent
9304 See separate section on source representation.
9305
9306 @sp 1
9307 @cartouche
9308 @noindent
9309 @strong{7}. The control functions allowed in comments. See 2.1(14).
9310 @end cartouche
9311 @noindent
9312 See separate section on source representation.
9313
9314 @sp 1
9315 @cartouche
9316 @noindent
9317 @strong{8}. The representation for an end of line. See 2.2(2).
9318 @end cartouche
9319 @noindent
9320 See separate section on source representation.
9321
9322 @sp 1
9323 @cartouche
9324 @noindent
9325 @strong{9}. Maximum supported line length and lexical element
9326 length. See 2.2(15).
9327 @end cartouche
9328 @noindent
9329 The maximum line length is 255 characters and the maximum length of a
9330 lexical element is also 255 characters.
9331
9332 @sp 1
9333 @cartouche
9334 @noindent
9335 @strong{10}. Implementation defined pragmas. See 2.8(14).
9336 @end cartouche
9337 @noindent
9338
9339 @xref{Implementation Defined Pragmas}.
9340
9341 @sp 1
9342 @cartouche
9343 @noindent
9344 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
9345 @end cartouche
9346 @noindent
9347 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
9348 parameter, checks that the optimization flag is set, and aborts if it is
9349 not.
9350
9351 @sp 1
9352 @cartouche
9353 @noindent
9354 @strong{12}. The sequence of characters of the value returned by
9355 @code{@var{S}'Image} when some of the graphic characters of
9356 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
9357 3.5(37).
9358 @end cartouche
9359 @noindent
9360 The sequence of characters is as defined by the wide character encoding
9361 method used for the source. See section on source representation for
9362 further details.
9363
9364 @sp 1
9365 @cartouche
9366 @noindent
9367 @strong{13}. The predefined integer types declared in
9368 @code{Standard}. See 3.5.4(25).
9369 @end cartouche
9370 @noindent
9371 @table @code
9372 @item Short_Short_Integer
9373 8 bit signed
9374 @item Short_Integer
9375 (Short) 16 bit signed
9376 @item Integer
9377 32 bit signed
9378 @item Long_Integer
9379 64 bit signed (on most 64 bit targets, depending on the C definition of long).
9380 32 bit signed (all other targets)
9381 @item Long_Long_Integer
9382 64 bit signed
9383 @end table
9384
9385 @sp 1
9386 @cartouche
9387 @noindent
9388 @strong{14}. Any nonstandard integer types and the operators defined
9389 for them. See 3.5.4(26).
9390 @end cartouche
9391 @noindent
9392 There are no nonstandard integer types.
9393
9394 @sp 1
9395 @cartouche
9396 @noindent
9397 @strong{15}. Any nonstandard real types and the operators defined for
9398 them. See 3.5.6(8).
9399 @end cartouche
9400 @noindent
9401 There are no nonstandard real types.
9402
9403 @sp 1
9404 @cartouche
9405 @noindent
9406 @strong{16}. What combinations of requested decimal precision and range
9407 are supported for floating point types. See 3.5.7(7).
9408 @end cartouche
9409 @noindent
9410 The precision and range is as defined by the IEEE standard.
9411
9412 @sp 1
9413 @cartouche
9414 @noindent
9415 @strong{17}. The predefined floating point types declared in
9416 @code{Standard}. See 3.5.7(16).
9417 @end cartouche
9418 @noindent
9419 @table @code
9420 @item Short_Float
9421 32 bit IEEE short
9422 @item Float
9423 (Short) 32 bit IEEE short
9424 @item Long_Float
9425 64 bit IEEE long
9426 @item Long_Long_Float
9427 64 bit IEEE long (80 bit IEEE long on x86 processors)
9428 @end table
9429
9430 @sp 1
9431 @cartouche
9432 @noindent
9433 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
9434 @end cartouche
9435 @noindent
9436 @code{Fine_Delta} is 2**(@minus{}63)
9437
9438 @sp 1
9439 @cartouche
9440 @noindent
9441 @strong{19}. What combinations of small, range, and digits are
9442 supported for fixed point types. See 3.5.9(10).
9443 @end cartouche
9444 @noindent
9445 Any combinations are permitted that do not result in a small less than
9446 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
9447 If the mantissa is larger than 53 bits on machines where Long_Long_Float
9448 is 64 bits (true of all architectures except ia32), then the output from
9449 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
9450 is because floating-point conversions are used to convert fixed point.
9451
9452 @sp 1
9453 @cartouche
9454 @noindent
9455 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
9456 within an unnamed @code{block_statement}. See 3.9(10).
9457 @end cartouche
9458 @noindent
9459 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
9460 decimal integer are allocated.
9461
9462 @sp 1
9463 @cartouche
9464 @noindent
9465 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
9466 @end cartouche
9467 @noindent
9468 @xref{Implementation Defined Attributes}.
9469
9470 @sp 1
9471 @cartouche
9472 @noindent
9473 @strong{22}. Any implementation-defined time types. See 9.6(6).
9474 @end cartouche
9475 @noindent
9476 There are no implementation-defined time types.
9477
9478 @sp 1
9479 @cartouche
9480 @noindent
9481 @strong{23}. The time base associated with relative delays.
9482 @end cartouche
9483 @noindent
9484 See 9.6(20). The time base used is that provided by the C library
9485 function @code{gettimeofday}.
9486
9487 @sp 1
9488 @cartouche
9489 @noindent
9490 @strong{24}. The time base of the type @code{Calendar.Time}. See
9491 9.6(23).
9492 @end cartouche
9493 @noindent
9494 The time base used is that provided by the C library function
9495 @code{gettimeofday}.
9496
9497 @sp 1
9498 @cartouche
9499 @noindent
9500 @strong{25}. The time zone used for package @code{Calendar}
9501 operations. See 9.6(24).
9502 @end cartouche
9503 @noindent
9504 The time zone used by package @code{Calendar} is the current system time zone
9505 setting for local time, as accessed by the C library function
9506 @code{localtime}.
9507
9508 @sp 1
9509 @cartouche
9510 @noindent
9511 @strong{26}. Any limit on @code{delay_until_statements} of
9512 @code{select_statements}. See 9.6(29).
9513 @end cartouche
9514 @noindent
9515 There are no such limits.
9516
9517 @sp 1
9518 @cartouche
9519 @noindent
9520 @strong{27}. Whether or not two non-overlapping parts of a composite
9521 object are independently addressable, in the case where packing, record
9522 layout, or @code{Component_Size} is specified for the object. See
9523 9.10(1).
9524 @end cartouche
9525 @noindent
9526 Separate components are independently addressable if they do not share
9527 overlapping storage units.
9528
9529 @sp 1
9530 @cartouche
9531 @noindent
9532 @strong{28}. The representation for a compilation. See 10.1(2).
9533 @end cartouche
9534 @noindent
9535 A compilation is represented by a sequence of files presented to the
9536 compiler in a single invocation of the @command{gcc} command.
9537
9538 @sp 1
9539 @cartouche
9540 @noindent
9541 @strong{29}. Any restrictions on compilations that contain multiple
9542 compilation_units. See 10.1(4).
9543 @end cartouche
9544 @noindent
9545 No single file can contain more than one compilation unit, but any
9546 sequence of files can be presented to the compiler as a single
9547 compilation.
9548
9549 @sp 1
9550 @cartouche
9551 @noindent
9552 @strong{30}. The mechanisms for creating an environment and for adding
9553 and replacing compilation units. See 10.1.4(3).
9554 @end cartouche
9555 @noindent
9556 See separate section on compilation model.
9557
9558 @sp 1
9559 @cartouche
9560 @noindent
9561 @strong{31}. The manner of explicitly assigning library units to a
9562 partition. See 10.2(2).
9563 @end cartouche
9564 @noindent
9565 If a unit contains an Ada main program, then the Ada units for the partition
9566 are determined by recursive application of the rules in the Ada Reference
9567 Manual section 10.2(2-6). In other words, the Ada units will be those that
9568 are needed by the main program, and then this definition of need is applied
9569 recursively to those units, and the partition contains the transitive
9570 closure determined by this relationship. In short, all the necessary units
9571 are included, with no need to explicitly specify the list. If additional
9572 units are required, e.g.@: by foreign language units, then all units must be
9573 mentioned in the context clause of one of the needed Ada units.
9574
9575 If the partition contains no main program, or if the main program is in
9576 a language other than Ada, then GNAT
9577 provides the binder options @option{-z} and @option{-n} respectively, and in
9578 this case a list of units can be explicitly supplied to the binder for
9579 inclusion in the partition (all units needed by these units will also
9580 be included automatically). For full details on the use of these
9581 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
9582 @value{EDITION} User's Guide}.
9583
9584 @sp 1
9585 @cartouche
9586 @noindent
9587 @strong{32}. The implementation-defined means, if any, of specifying
9588 which compilation units are needed by a given compilation unit. See
9589 10.2(2).
9590 @end cartouche
9591 @noindent
9592 The units needed by a given compilation unit are as defined in
9593 the Ada Reference Manual section 10.2(2-6). There are no
9594 implementation-defined pragmas or other implementation-defined
9595 means for specifying needed units.
9596
9597 @sp 1
9598 @cartouche
9599 @noindent
9600 @strong{33}. The manner of designating the main subprogram of a
9601 partition. See 10.2(7).
9602 @end cartouche
9603 @noindent
9604 The main program is designated by providing the name of the
9605 corresponding @file{ALI} file as the input parameter to the binder.
9606
9607 @sp 1
9608 @cartouche
9609 @noindent
9610 @strong{34}. The order of elaboration of @code{library_items}. See
9611 10.2(18).
9612 @end cartouche
9613 @noindent
9614 The first constraint on ordering is that it meets the requirements of
9615 Chapter 10 of the Ada Reference Manual. This still leaves some
9616 implementation dependent choices, which are resolved by first
9617 elaborating bodies as early as possible (i.e., in preference to specs
9618 where there is a choice), and second by evaluating the immediate with
9619 clauses of a unit to determine the probably best choice, and
9620 third by elaborating in alphabetical order of unit names
9621 where a choice still remains.
9622
9623 @sp 1
9624 @cartouche
9625 @noindent
9626 @strong{35}. Parameter passing and function return for the main
9627 subprogram. See 10.2(21).
9628 @end cartouche
9629 @noindent
9630 The main program has no parameters. It may be a procedure, or a function
9631 returning an integer type. In the latter case, the returned integer
9632 value is the return code of the program (overriding any value that
9633 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
9634
9635 @sp 1
9636 @cartouche
9637 @noindent
9638 @strong{36}. The mechanisms for building and running partitions. See
9639 10.2(24).
9640 @end cartouche
9641 @noindent
9642 GNAT itself supports programs with only a single partition. The GNATDIST
9643 tool provided with the GLADE package (which also includes an implementation
9644 of the PCS) provides a completely flexible method for building and running
9645 programs consisting of multiple partitions. See the separate GLADE manual
9646 for details.
9647
9648 @sp 1
9649 @cartouche
9650 @noindent
9651 @strong{37}. The details of program execution, including program
9652 termination. See 10.2(25).
9653 @end cartouche
9654 @noindent
9655 See separate section on compilation model.
9656
9657 @sp 1
9658 @cartouche
9659 @noindent
9660 @strong{38}. The semantics of any non-active partitions supported by the
9661 implementation. See 10.2(28).
9662 @end cartouche
9663 @noindent
9664 Passive partitions are supported on targets where shared memory is
9665 provided by the operating system. See the GLADE reference manual for
9666 further details.
9667
9668 @sp 1
9669 @cartouche
9670 @noindent
9671 @strong{39}. The information returned by @code{Exception_Message}. See
9672 11.4.1(10).
9673 @end cartouche
9674 @noindent
9675 Exception message returns the null string unless a specific message has
9676 been passed by the program.
9677
9678 @sp 1
9679 @cartouche
9680 @noindent
9681 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
9682 declared within an unnamed @code{block_statement}. See 11.4.1(12).
9683 @end cartouche
9684 @noindent
9685 Blocks have implementation defined names of the form @code{B@var{nnn}}
9686 where @var{nnn} is an integer.
9687
9688 @sp 1
9689 @cartouche
9690 @noindent
9691 @strong{41}. The information returned by
9692 @code{Exception_Information}. See 11.4.1(13).
9693 @end cartouche
9694 @noindent
9695 @code{Exception_Information} returns a string in the following format:
9696
9697 @smallexample
9698 @emph{Exception_Name:} nnnnn
9699 @emph{Message:} mmmmm
9700 @emph{PID:} ppp
9701 @emph{Call stack traceback locations:}
9702 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
9703 @end smallexample
9704
9705 @noindent
9706 where
9707
9708 @itemize @bullet
9709 @item
9710 @code{nnnn} is the fully qualified name of the exception in all upper
9711 case letters. This line is always present.
9712
9713 @item
9714 @code{mmmm} is the message (this line present only if message is non-null)
9715
9716 @item
9717 @code{ppp} is the Process Id value as a decimal integer (this line is
9718 present only if the Process Id is nonzero). Currently we are
9719 not making use of this field.
9720
9721 @item
9722 The Call stack traceback locations line and the following values
9723 are present only if at least one traceback location was recorded.
9724 The values are given in C style format, with lower case letters
9725 for a-f, and only as many digits present as are necessary.
9726 @end itemize
9727
9728 @noindent
9729 The line terminator sequence at the end of each line, including
9730 the last line is a single @code{LF} character (@code{16#0A#}).
9731
9732 @sp 1
9733 @cartouche
9734 @noindent
9735 @strong{42}. Implementation-defined check names. See 11.5(27).
9736 @end cartouche
9737 @noindent
9738 The implementation defined check name Alignment_Check controls checking of
9739 address clause values for proper alignment (that is, the address supplied
9740 must be consistent with the alignment of the type).
9741
9742 In addition, a user program can add implementation-defined check names
9743 by means of the pragma Check_Name.
9744
9745 @sp 1
9746 @cartouche
9747 @noindent
9748 @strong{43}. The interpretation of each aspect of representation. See
9749 13.1(20).
9750 @end cartouche
9751 @noindent
9752 See separate section on data representations.
9753
9754 @sp 1
9755 @cartouche
9756 @noindent
9757 @strong{44}. Any restrictions placed upon representation items. See
9758 13.1(20).
9759 @end cartouche
9760 @noindent
9761 See separate section on data representations.
9762
9763 @sp 1
9764 @cartouche
9765 @noindent
9766 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
9767 13.3(48).
9768 @end cartouche
9769 @noindent
9770 Size for an indefinite subtype is the maximum possible size, except that
9771 for the case of a subprogram parameter, the size of the parameter object
9772 is the actual size.
9773
9774 @sp 1
9775 @cartouche
9776 @noindent
9777 @strong{46}. The default external representation for a type tag. See
9778 13.3(75).
9779 @end cartouche
9780 @noindent
9781 The default external representation for a type tag is the fully expanded
9782 name of the type in upper case letters.
9783
9784 @sp 1
9785 @cartouche
9786 @noindent
9787 @strong{47}. What determines whether a compilation unit is the same in
9788 two different partitions. See 13.3(76).
9789 @end cartouche
9790 @noindent
9791 A compilation unit is the same in two different partitions if and only
9792 if it derives from the same source file.
9793
9794 @sp 1
9795 @cartouche
9796 @noindent
9797 @strong{48}. Implementation-defined components. See 13.5.1(15).
9798 @end cartouche
9799 @noindent
9800 The only implementation defined component is the tag for a tagged type,
9801 which contains a pointer to the dispatching table.
9802
9803 @sp 1
9804 @cartouche
9805 @noindent
9806 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
9807 ordering. See 13.5.3(5).
9808 @end cartouche
9809 @noindent
9810 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
9811 implementation, so no non-default bit ordering is supported. The default
9812 bit ordering corresponds to the natural endianness of the target architecture.
9813
9814 @sp 1
9815 @cartouche
9816 @noindent
9817 @strong{50}. The contents of the visible part of package @code{System}
9818 and its language-defined children. See 13.7(2).
9819 @end cartouche
9820 @noindent
9821 See the definition of these packages in files @file{system.ads} and
9822 @file{s-stoele.ads}.
9823
9824 @sp 1
9825 @cartouche
9826 @noindent
9827 @strong{51}. The contents of the visible part of package
9828 @code{System.Machine_Code}, and the meaning of
9829 @code{code_statements}. See 13.8(7).
9830 @end cartouche
9831 @noindent
9832 See the definition and documentation in file @file{s-maccod.ads}.
9833
9834 @sp 1
9835 @cartouche
9836 @noindent
9837 @strong{52}. The effect of unchecked conversion. See 13.9(11).
9838 @end cartouche
9839 @noindent
9840 Unchecked conversion between types of the same size
9841 results in an uninterpreted transmission of the bits from one type
9842 to the other. If the types are of unequal sizes, then in the case of
9843 discrete types, a shorter source is first zero or sign extended as
9844 necessary, and a shorter target is simply truncated on the left.
9845 For all non-discrete types, the source is first copied if necessary
9846 to ensure that the alignment requirements of the target are met, then
9847 a pointer is constructed to the source value, and the result is obtained
9848 by dereferencing this pointer after converting it to be a pointer to the
9849 target type. Unchecked conversions where the target subtype is an
9850 unconstrained array are not permitted. If the target alignment is
9851 greater than the source alignment, then a copy of the result is
9852 made with appropriate alignment
9853
9854 @sp 1
9855 @cartouche
9856 @noindent
9857 @strong{53}. The semantics of operations on invalid representations.
9858 See 13.9.2(10-11).
9859 @end cartouche
9860 @noindent
9861 For assignments and other operations where the use of invalid values cannot
9862 result in erroneous behavior, the compiler ignores the possibility of invalid
9863 values. An exception is raised at the point where an invalid value would
9864 result in erroneous behavior. For example executing:
9865
9866 @smallexample @c ada
9867 procedure invalidvals is
9868 X : Integer := -1;
9869 Y : Natural range 1 .. 10;
9870 for Y'Address use X'Address;
9871 Z : Natural range 1 .. 10;
9872 A : array (Natural range 1 .. 10) of Integer;
9873 begin
9874 Z := Y; -- no exception
9875 A (Z) := 3; -- exception raised;
9876 end;
9877 @end smallexample
9878
9879 @noindent
9880 As indicated, an exception is raised on the array assignment, but not
9881 on the simple assignment of the invalid negative value from Y to Z.
9882
9883 @sp 1
9884 @cartouche
9885 @noindent
9886 @strong{53}. The manner of choosing a storage pool for an access type
9887 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
9888 @end cartouche
9889 @noindent
9890 There are 3 different standard pools used by the compiler when
9891 @code{Storage_Pool} is not specified depending whether the type is local
9892 to a subprogram or defined at the library level and whether
9893 @code{Storage_Size}is specified or not. See documentation in the runtime
9894 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
9895 @code{System.Pool_Local} in files @file{s-poosiz.ads},
9896 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
9897 default pools used.
9898
9899 @sp 1
9900 @cartouche
9901 @noindent
9902 @strong{54}. Whether or not the implementation provides user-accessible
9903 names for the standard pool type(s). See 13.11(17).
9904 @end cartouche
9905 @noindent
9906
9907 See documentation in the sources of the run time mentioned in paragraph
9908 @strong{53} . All these pools are accessible by means of @code{with}'ing
9909 these units.
9910
9911 @sp 1
9912 @cartouche
9913 @noindent
9914 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
9915 @end cartouche
9916 @noindent
9917 @code{Storage_Size} is measured in storage units, and refers to the
9918 total space available for an access type collection, or to the primary
9919 stack space for a task.
9920
9921 @sp 1
9922 @cartouche
9923 @noindent
9924 @strong{56}. Implementation-defined aspects of storage pools. See
9925 13.11(22).
9926 @end cartouche
9927 @noindent
9928 See documentation in the sources of the run time mentioned in paragraph
9929 @strong{53} for details on GNAT-defined aspects of storage pools.
9930
9931 @sp 1
9932 @cartouche
9933 @noindent
9934 @strong{57}. The set of restrictions allowed in a pragma
9935 @code{Restrictions}. See 13.12(7).
9936 @end cartouche
9937 @noindent
9938 @xref{Implementation Defined Restrictions}.
9939
9940 @sp 1
9941 @cartouche
9942 @noindent
9943 @strong{58}. The consequences of violating limitations on
9944 @code{Restrictions} pragmas. See 13.12(9).
9945 @end cartouche
9946 @noindent
9947 Restrictions that can be checked at compile time result in illegalities
9948 if violated. Currently there are no other consequences of violating
9949 restrictions.
9950
9951 @sp 1
9952 @cartouche
9953 @noindent
9954 @strong{59}. The representation used by the @code{Read} and
9955 @code{Write} attributes of elementary types in terms of stream
9956 elements. See 13.13.2(9).
9957 @end cartouche
9958 @noindent
9959 The representation is the in-memory representation of the base type of
9960 the type, using the number of bits corresponding to the
9961 @code{@var{type}'Size} value, and the natural ordering of the machine.
9962
9963 @sp 1
9964 @cartouche
9965 @noindent
9966 @strong{60}. The names and characteristics of the numeric subtypes
9967 declared in the visible part of package @code{Standard}. See A.1(3).
9968 @end cartouche
9969 @noindent
9970 See items describing the integer and floating-point types supported.
9971
9972 @sp 1
9973 @cartouche
9974 @noindent
9975 @strong{61}. The accuracy actually achieved by the elementary
9976 functions. See A.5.1(1).
9977 @end cartouche
9978 @noindent
9979 The elementary functions correspond to the functions available in the C
9980 library. Only fast math mode is implemented.
9981
9982 @sp 1
9983 @cartouche
9984 @noindent
9985 @strong{62}. The sign of a zero result from some of the operators or
9986 functions in @code{Numerics.Generic_Elementary_Functions}, when
9987 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
9988 @end cartouche
9989 @noindent
9990 The sign of zeroes follows the requirements of the IEEE 754 standard on
9991 floating-point.
9992
9993 @sp 1
9994 @cartouche
9995 @noindent
9996 @strong{63}. The value of
9997 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
9998 @end cartouche
9999 @noindent
10000 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10001
10002 @sp 1
10003 @cartouche
10004 @noindent
10005 @strong{64}. The value of
10006 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10007 @end cartouche
10008 @noindent
10009 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10010
10011 @sp 1
10012 @cartouche
10013 @noindent
10014 @strong{65}. The algorithms for random number generation. See
10015 A.5.2(32).
10016 @end cartouche
10017 @noindent
10018 The algorithm is the Mersenne Twister, as documented in the source file
10019 @file{s-rannum.adb}. This version of the algorithm has a period of
10020 2**19937-1.
10021
10022 @sp 1
10023 @cartouche
10024 @noindent
10025 @strong{66}. The string representation of a random number generator's
10026 state. See A.5.2(38).
10027 @end cartouche
10028 @noindent
10029 The value returned by the Image function is the concatenation of
10030 the fixed-width decimal representations of the 624 32-bit integers
10031 of the state vector.
10032
10033 @sp 1
10034 @cartouche
10035 @noindent
10036 @strong{67}. The minimum time interval between calls to the
10037 time-dependent Reset procedure that are guaranteed to initiate different
10038 random number sequences. See A.5.2(45).
10039 @end cartouche
10040 @noindent
10041 The minimum period between reset calls to guarantee distinct series of
10042 random numbers is one microsecond.
10043
10044 @sp 1
10045 @cartouche
10046 @noindent
10047 @strong{68}. The values of the @code{Model_Mantissa},
10048 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10049 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10050 Annex is not supported. See A.5.3(72).
10051 @end cartouche
10052 @noindent
10053 Run the compiler with @option{-gnatS} to produce a listing of package
10054 @code{Standard}, has the values of all numeric attributes.
10055
10056 @sp 1
10057 @cartouche
10058 @noindent
10059 @strong{69}. Any implementation-defined characteristics of the
10060 input-output packages. See A.7(14).
10061 @end cartouche
10062 @noindent
10063 There are no special implementation defined characteristics for these
10064 packages.
10065
10066 @sp 1
10067 @cartouche
10068 @noindent
10069 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10070 A.9(10).
10071 @end cartouche
10072 @noindent
10073 All type representations are contiguous, and the @code{Buffer_Size} is
10074 the value of @code{@var{type}'Size} rounded up to the next storage unit
10075 boundary.
10076
10077 @sp 1
10078 @cartouche
10079 @noindent
10080 @strong{71}. External files for standard input, standard output, and
10081 standard error See A.10(5).
10082 @end cartouche
10083 @noindent
10084 These files are mapped onto the files provided by the C streams
10085 libraries. See source file @file{i-cstrea.ads} for further details.
10086
10087 @sp 1
10088 @cartouche
10089 @noindent
10090 @strong{72}. The accuracy of the value produced by @code{Put}. See
10091 A.10.9(36).
10092 @end cartouche
10093 @noindent
10094 If more digits are requested in the output than are represented by the
10095 precision of the value, zeroes are output in the corresponding least
10096 significant digit positions.
10097
10098 @sp 1
10099 @cartouche
10100 @noindent
10101 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10102 @code{Command_Name}. See A.15(1).
10103 @end cartouche
10104 @noindent
10105 These are mapped onto the @code{argv} and @code{argc} parameters of the
10106 main program in the natural manner.
10107
10108 @sp 1
10109 @cartouche
10110 @noindent
10111 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10112 @code{Create_Directory}. See A.16(56).
10113 @end cartouche
10114 @noindent
10115 The @code{Form} parameter is not used.
10116
10117 @sp 1
10118 @cartouche
10119 @noindent
10120 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10121 @code{Create_Path}. See A.16(60).
10122 @end cartouche
10123 @noindent
10124 The @code{Form} parameter is not used.
10125
10126 @sp 1
10127 @cartouche
10128 @noindent
10129 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10130 @code{Copy_File}. See A.16(68).
10131 @end cartouche
10132 @noindent
10133 The @code{Form} parameter is case-insensitive.
10134
10135 Two fields are recognized in the @code{Form} parameter:
10136
10137 @table @code
10138
10139 @item preserve=<value>
10140
10141 @item mode=<value>
10142
10143 @end table
10144
10145 @noindent
10146 <value> starts immediately after the character '=' and ends with the
10147 character immediately preceding the next comma (',') or with the last
10148 character of the parameter.
10149
10150 The only possible values for preserve= are:
10151
10152 @table @code
10153
10154 @item no_attributes
10155 Do not try to preserve any file attributes. This is the default if no
10156 preserve= is found in Form.
10157
10158 @item all_attributes
10159 Try to preserve all file attributes (timestamps, access rights).
10160
10161 @item timestamps
10162 Preserve the timestamp of the copied file, but not the other file attributes.
10163
10164 @end table
10165
10166 @noindent
10167 The only possible values for mode= are:
10168
10169 @table @code
10170
10171 @item copy
10172 Only do the copy if the destination file does not already exist. If it already
10173 exists, Copy_File fails.
10174
10175 @item overwrite
10176 Copy the file in all cases. Overwrite an already existing destination file.
10177
10178 @item append
10179 Append the original file to the destination file. If the destination file does
10180 not exist, the destination file is a copy of the source file. When mode=append,
10181 the field preserve=, if it exists, is not taken into account.
10182
10183 @end table
10184
10185 @noindent
10186 If the Form parameter includes one or both of the fields and the value or
10187 values are incorrect, Copy_file fails with Use_Error.
10188
10189 Examples of correct Forms:
10190
10191 @smallexample
10192 Form => "preserve=no_attributes,mode=overwrite" (the default)
10193 Form => "mode=append"
10194 Form => "mode=copy, preserve=all_attributes"
10195 @end smallexample
10196
10197 @noindent
10198 Examples of incorrect Forms
10199
10200 @smallexample
10201 Form => "preserve=junk"
10202 Form => "mode=internal, preserve=timestamps"
10203 @end smallexample
10204
10205 @sp 1
10206 @cartouche
10207 @noindent
10208 @strong{77}. Implementation-defined convention names. See B.1(11).
10209 @end cartouche
10210 @noindent
10211 The following convention names are supported
10212
10213 @table @code
10214 @item Ada
10215 Ada
10216 @item Ada_Pass_By_Copy
10217 Allowed for any types except by-reference types such as limited
10218 records. Compatible with convention Ada, but causes any parameters
10219 with this convention to be passed by copy.
10220 @item Ada_Pass_By_Reference
10221 Allowed for any types except by-copy types such as scalars.
10222 Compatible with convention Ada, but causes any parameters
10223 with this convention to be passed by reference.
10224 @item Assembler
10225 Assembly language
10226 @item Asm
10227 Synonym for Assembler
10228 @item Assembly
10229 Synonym for Assembler
10230 @item C
10231 C
10232 @item C_Pass_By_Copy
10233 Allowed only for record types, like C, but also notes that record
10234 is to be passed by copy rather than reference.
10235 @item COBOL
10236 COBOL
10237 @item C_Plus_Plus (or CPP)
10238 C++
10239 @item Default
10240 Treated the same as C
10241 @item External
10242 Treated the same as C
10243 @item Fortran
10244 Fortran
10245 @item Intrinsic
10246 For support of pragma @code{Import} with convention Intrinsic, see
10247 separate section on Intrinsic Subprograms.
10248 @item Stdcall
10249 Stdcall (used for Windows implementations only). This convention correspond
10250 to the WINAPI (previously called Pascal convention) C/C++ convention under
10251 Windows. A routine with this convention cleans the stack before
10252 exit. This pragma cannot be applied to a dispatching call.
10253 @item DLL
10254 Synonym for Stdcall
10255 @item Win32
10256 Synonym for Stdcall
10257 @item Stubbed
10258 Stubbed is a special convention used to indicate that the body of the
10259 subprogram will be entirely ignored. Any call to the subprogram
10260 is converted into a raise of the @code{Program_Error} exception. If a
10261 pragma @code{Import} specifies convention @code{stubbed} then no body need
10262 be present at all. This convention is useful during development for the
10263 inclusion of subprograms whose body has not yet been written.
10264
10265 @end table
10266 @noindent
10267 In addition, all otherwise unrecognized convention names are also
10268 treated as being synonymous with convention C@. In all implementations
10269 except for VMS, use of such other names results in a warning. In VMS
10270 implementations, these names are accepted silently.
10271
10272 @sp 1
10273 @cartouche
10274 @noindent
10275 @strong{78}. The meaning of link names. See B.1(36).
10276 @end cartouche
10277 @noindent
10278 Link names are the actual names used by the linker.
10279
10280 @sp 1
10281 @cartouche
10282 @noindent
10283 @strong{79}. The manner of choosing link names when neither the link
10284 name nor the address of an imported or exported entity is specified. See
10285 B.1(36).
10286 @end cartouche
10287 @noindent
10288 The default linker name is that which would be assigned by the relevant
10289 external language, interpreting the Ada name as being in all lower case
10290 letters.
10291
10292 @sp 1
10293 @cartouche
10294 @noindent
10295 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10296 @end cartouche
10297 @noindent
10298 The string passed to @code{Linker_Options} is presented uninterpreted as
10299 an argument to the link command, unless it contains ASCII.NUL characters.
10300 NUL characters if they appear act as argument separators, so for example
10301
10302 @smallexample @c ada
10303 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10304 @end smallexample
10305
10306 @noindent
10307 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10308 linker. The order of linker options is preserved for a given unit. The final
10309 list of options passed to the linker is in reverse order of the elaboration
10310 order. For example, linker options for a body always appear before the options
10311 from the corresponding package spec.
10312
10313 @sp 1
10314 @cartouche
10315 @noindent
10316 @strong{81}. The contents of the visible part of package
10317 @code{Interfaces} and its language-defined descendants. See B.2(1).
10318 @end cartouche
10319 @noindent
10320 See files with prefix @file{i-} in the distributed library.
10321
10322 @sp 1
10323 @cartouche
10324 @noindent
10325 @strong{82}. Implementation-defined children of package
10326 @code{Interfaces}. The contents of the visible part of package
10327 @code{Interfaces}. See B.2(11).
10328 @end cartouche
10329 @noindent
10330 See files with prefix @file{i-} in the distributed library.
10331
10332 @sp 1
10333 @cartouche
10334 @noindent
10335 @strong{83}. The types @code{Floating}, @code{Long_Floating},
10336 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
10337 @code{COBOL_Character}; and the initialization of the variables
10338 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
10339 @code{Interfaces.COBOL}. See B.4(50).
10340 @end cartouche
10341 @noindent
10342 @table @code
10343 @item Floating
10344 Float
10345 @item Long_Floating
10346 (Floating) Long_Float
10347 @item Binary
10348 Integer
10349 @item Long_Binary
10350 Long_Long_Integer
10351 @item Decimal_Element
10352 Character
10353 @item COBOL_Character
10354 Character
10355 @end table
10356
10357 @noindent
10358 For initialization, see the file @file{i-cobol.ads} in the distributed library.
10359
10360 @sp 1
10361 @cartouche
10362 @noindent
10363 @strong{84}. Support for access to machine instructions. See C.1(1).
10364 @end cartouche
10365 @noindent
10366 See documentation in file @file{s-maccod.ads} in the distributed library.
10367
10368 @sp 1
10369 @cartouche
10370 @noindent
10371 @strong{85}. Implementation-defined aspects of access to machine
10372 operations. See C.1(9).
10373 @end cartouche
10374 @noindent
10375 See documentation in file @file{s-maccod.ads} in the distributed library.
10376
10377 @sp 1
10378 @cartouche
10379 @noindent
10380 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
10381 @end cartouche
10382 @noindent
10383 Interrupts are mapped to signals or conditions as appropriate. See
10384 definition of unit
10385 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
10386 on the interrupts supported on a particular target.
10387
10388 @sp 1
10389 @cartouche
10390 @noindent
10391 @strong{87}. Implementation-defined aspects of pre-elaboration. See
10392 C.4(13).
10393 @end cartouche
10394 @noindent
10395 GNAT does not permit a partition to be restarted without reloading,
10396 except under control of the debugger.
10397
10398 @sp 1
10399 @cartouche
10400 @noindent
10401 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
10402 @end cartouche
10403 @noindent
10404 Pragma @code{Discard_Names} causes names of enumeration literals to
10405 be suppressed. In the presence of this pragma, the Image attribute
10406 provides the image of the Pos of the literal, and Value accepts
10407 Pos values.
10408
10409 @sp 1
10410 @cartouche
10411 @noindent
10412 @strong{89}. The result of the @code{Task_Identification.Image}
10413 attribute. See C.7.1(7).
10414 @end cartouche
10415 @noindent
10416 The result of this attribute is a string that identifies
10417 the object or component that denotes a given task. If a variable @code{Var}
10418 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
10419 where the suffix
10420 is the hexadecimal representation of the virtual address of the corresponding
10421 task control block. If the variable is an array of tasks, the image of each
10422 task will have the form of an indexed component indicating the position of a
10423 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
10424 component of a record, the image of the task will have the form of a selected
10425 component. These rules are fully recursive, so that the image of a task that
10426 is a subcomponent of a composite object corresponds to the expression that
10427 designates this task.
10428 @noindent
10429 If a task is created by an allocator, its image depends on the context. If the
10430 allocator is part of an object declaration, the rules described above are used
10431 to construct its image, and this image is not affected by subsequent
10432 assignments. If the allocator appears within an expression, the image
10433 includes only the name of the task type.
10434 @noindent
10435 If the configuration pragma Discard_Names is present, or if the restriction
10436 No_Implicit_Heap_Allocation is in effect, the image reduces to
10437 the numeric suffix, that is to say the hexadecimal representation of the
10438 virtual address of the control block of the task.
10439 @sp 1
10440 @cartouche
10441 @noindent
10442 @strong{90}. The value of @code{Current_Task} when in a protected entry
10443 or interrupt handler. See C.7.1(17).
10444 @end cartouche
10445 @noindent
10446 Protected entries or interrupt handlers can be executed by any
10447 convenient thread, so the value of @code{Current_Task} is undefined.
10448
10449 @sp 1
10450 @cartouche
10451 @noindent
10452 @strong{91}. The effect of calling @code{Current_Task} from an entry
10453 body or interrupt handler. See C.7.1(19).
10454 @end cartouche
10455 @noindent
10456 The effect of calling @code{Current_Task} from an entry body or
10457 interrupt handler is to return the identification of the task currently
10458 executing the code.
10459
10460 @sp 1
10461 @cartouche
10462 @noindent
10463 @strong{92}. Implementation-defined aspects of
10464 @code{Task_Attributes}. See C.7.2(19).
10465 @end cartouche
10466 @noindent
10467 There are no implementation-defined aspects of @code{Task_Attributes}.
10468
10469 @sp 1
10470 @cartouche
10471 @noindent
10472 @strong{93}. Values of all @code{Metrics}. See D(2).
10473 @end cartouche
10474 @noindent
10475 The metrics information for GNAT depends on the performance of the
10476 underlying operating system. The sources of the run-time for tasking
10477 implementation, together with the output from @option{-gnatG} can be
10478 used to determine the exact sequence of operating systems calls made
10479 to implement various tasking constructs. Together with appropriate
10480 information on the performance of the underlying operating system,
10481 on the exact target in use, this information can be used to determine
10482 the required metrics.
10483
10484 @sp 1
10485 @cartouche
10486 @noindent
10487 @strong{94}. The declarations of @code{Any_Priority} and
10488 @code{Priority}. See D.1(11).
10489 @end cartouche
10490 @noindent
10491 See declarations in file @file{system.ads}.
10492
10493 @sp 1
10494 @cartouche
10495 @noindent
10496 @strong{95}. Implementation-defined execution resources. See D.1(15).
10497 @end cartouche
10498 @noindent
10499 There are no implementation-defined execution resources.
10500
10501 @sp 1
10502 @cartouche
10503 @noindent
10504 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
10505 access to a protected object keeps its processor busy. See D.2.1(3).
10506 @end cartouche
10507 @noindent
10508 On a multi-processor, a task that is waiting for access to a protected
10509 object does not keep its processor busy.
10510
10511 @sp 1
10512 @cartouche
10513 @noindent
10514 @strong{97}. The affect of implementation defined execution resources
10515 on task dispatching. See D.2.1(9).
10516 @end cartouche
10517 @noindent
10518 @c SGI info
10519 @ignore
10520 Tasks map to IRIX threads, and the dispatching policy is as defined by
10521 the IRIX implementation of threads.
10522 @end ignore
10523 Tasks map to threads in the threads package used by GNAT@. Where possible
10524 and appropriate, these threads correspond to native threads of the
10525 underlying operating system.
10526
10527 @sp 1
10528 @cartouche
10529 @noindent
10530 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
10531 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
10532 @end cartouche
10533 @noindent
10534 There are no implementation-defined policy-identifiers allowed in this
10535 pragma.
10536
10537 @sp 1
10538 @cartouche
10539 @noindent
10540 @strong{99}. Implementation-defined aspects of priority inversion. See
10541 D.2.2(16).
10542 @end cartouche
10543 @noindent
10544 Execution of a task cannot be preempted by the implementation processing
10545 of delay expirations for lower priority tasks.
10546
10547 @sp 1
10548 @cartouche
10549 @noindent
10550 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
10551 @end cartouche
10552 @noindent
10553 @c SGI info:
10554 @ignore
10555 Tasks map to IRIX threads, and the dispatching policy is as defined by
10556 the IRIX implementation of threads.
10557 @end ignore
10558 The policy is the same as that of the underlying threads implementation.
10559
10560 @sp 1
10561 @cartouche
10562 @noindent
10563 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
10564 in a pragma @code{Locking_Policy}. See D.3(4).
10565 @end cartouche
10566 @noindent
10567 The two implementation defined policies permitted in GNAT are
10568 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
10569 targets that support the @code{Inheritance_Locking} policy, locking is
10570 implemented by inheritance, i.e.@: the task owning the lock operates
10571 at a priority equal to the highest priority of any task currently
10572 requesting the lock. On targets that support the
10573 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
10574 read/write lock allowing multiple propected object functions to enter
10575 concurrently.
10576
10577 @sp 1
10578 @cartouche
10579 @noindent
10580 @strong{102}. Default ceiling priorities. See D.3(10).
10581 @end cartouche
10582 @noindent
10583 The ceiling priority of protected objects of the type
10584 @code{System.Interrupt_Priority'Last} as described in the Ada
10585 Reference Manual D.3(10),
10586
10587 @sp 1
10588 @cartouche
10589 @noindent
10590 @strong{103}. The ceiling of any protected object used internally by
10591 the implementation. See D.3(16).
10592 @end cartouche
10593 @noindent
10594 The ceiling priority of internal protected objects is
10595 @code{System.Priority'Last}.
10596
10597 @sp 1
10598 @cartouche
10599 @noindent
10600 @strong{104}. Implementation-defined queuing policies. See D.4(1).
10601 @end cartouche
10602 @noindent
10603 There are no implementation-defined queuing policies.
10604
10605 @sp 1
10606 @cartouche
10607 @noindent
10608 @strong{105}. On a multiprocessor, any conditions that cause the
10609 completion of an aborted construct to be delayed later than what is
10610 specified for a single processor. See D.6(3).
10611 @end cartouche
10612 @noindent
10613 The semantics for abort on a multi-processor is the same as on a single
10614 processor, there are no further delays.
10615
10616 @sp 1
10617 @cartouche
10618 @noindent
10619 @strong{106}. Any operations that implicitly require heap storage
10620 allocation. See D.7(8).
10621 @end cartouche
10622 @noindent
10623 The only operation that implicitly requires heap storage allocation is
10624 task creation.
10625
10626 @sp 1
10627 @cartouche
10628 @noindent
10629 @strong{107}. Implementation-defined aspects of pragma
10630 @code{Restrictions}. See D.7(20).
10631 @end cartouche
10632 @noindent
10633 There are no such implementation-defined aspects.
10634
10635 @sp 1
10636 @cartouche
10637 @noindent
10638 @strong{108}. Implementation-defined aspects of package
10639 @code{Real_Time}. See D.8(17).
10640 @end cartouche
10641 @noindent
10642 There are no implementation defined aspects of package @code{Real_Time}.
10643
10644 @sp 1
10645 @cartouche
10646 @noindent
10647 @strong{109}. Implementation-defined aspects of
10648 @code{delay_statements}. See D.9(8).
10649 @end cartouche
10650 @noindent
10651 Any difference greater than one microsecond will cause the task to be
10652 delayed (see D.9(7)).
10653
10654 @sp 1
10655 @cartouche
10656 @noindent
10657 @strong{110}. The upper bound on the duration of interrupt blocking
10658 caused by the implementation. See D.12(5).
10659 @end cartouche
10660 @noindent
10661 The upper bound is determined by the underlying operating system. In
10662 no cases is it more than 10 milliseconds.
10663
10664 @sp 1
10665 @cartouche
10666 @noindent
10667 @strong{111}. The means for creating and executing distributed
10668 programs. See E(5).
10669 @end cartouche
10670 @noindent
10671 The GLADE package provides a utility GNATDIST for creating and executing
10672 distributed programs. See the GLADE reference manual for further details.
10673
10674 @sp 1
10675 @cartouche
10676 @noindent
10677 @strong{112}. Any events that can result in a partition becoming
10678 inaccessible. See E.1(7).
10679 @end cartouche
10680 @noindent
10681 See the GLADE reference manual for full details on such events.
10682
10683 @sp 1
10684 @cartouche
10685 @noindent
10686 @strong{113}. The scheduling policies, treatment of priorities, and
10687 management of shared resources between partitions in certain cases. See
10688 E.1(11).
10689 @end cartouche
10690 @noindent
10691 See the GLADE reference manual for full details on these aspects of
10692 multi-partition execution.
10693
10694 @sp 1
10695 @cartouche
10696 @noindent
10697 @strong{114}. Events that cause the version of a compilation unit to
10698 change. See E.3(5).
10699 @end cartouche
10700 @noindent
10701 Editing the source file of a compilation unit, or the source files of
10702 any units on which it is dependent in a significant way cause the version
10703 to change. No other actions cause the version number to change. All changes
10704 are significant except those which affect only layout, capitalization or
10705 comments.
10706
10707 @sp 1
10708 @cartouche
10709 @noindent
10710 @strong{115}. Whether the execution of the remote subprogram is
10711 immediately aborted as a result of cancellation. See E.4(13).
10712 @end cartouche
10713 @noindent
10714 See the GLADE reference manual for details on the effect of abort in
10715 a distributed application.
10716
10717 @sp 1
10718 @cartouche
10719 @noindent
10720 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
10721 @end cartouche
10722 @noindent
10723 See the GLADE reference manual for a full description of all implementation
10724 defined aspects of the PCS@.
10725
10726 @sp 1
10727 @cartouche
10728 @noindent
10729 @strong{117}. Implementation-defined interfaces in the PCS@. See
10730 E.5(26).
10731 @end cartouche
10732 @noindent
10733 See the GLADE reference manual for a full description of all
10734 implementation defined interfaces.
10735
10736 @sp 1
10737 @cartouche
10738 @noindent
10739 @strong{118}. The values of named numbers in the package
10740 @code{Decimal}. See F.2(7).
10741 @end cartouche
10742 @noindent
10743 @table @code
10744 @item Max_Scale
10745 +18
10746 @item Min_Scale
10747 -18
10748 @item Min_Delta
10749 1.0E-18
10750 @item Max_Delta
10751 1.0E+18
10752 @item Max_Decimal_Digits
10753 18
10754 @end table
10755
10756 @sp 1
10757 @cartouche
10758 @noindent
10759 @strong{119}. The value of @code{Max_Picture_Length} in the package
10760 @code{Text_IO.Editing}. See F.3.3(16).
10761 @end cartouche
10762 @noindent
10763 64
10764
10765 @sp 1
10766 @cartouche
10767 @noindent
10768 @strong{120}. The value of @code{Max_Picture_Length} in the package
10769 @code{Wide_Text_IO.Editing}. See F.3.4(5).
10770 @end cartouche
10771 @noindent
10772 64
10773
10774 @sp 1
10775 @cartouche
10776 @noindent
10777 @strong{121}. The accuracy actually achieved by the complex elementary
10778 functions and by other complex arithmetic operations. See G.1(1).
10779 @end cartouche
10780 @noindent
10781 Standard library functions are used for the complex arithmetic
10782 operations. Only fast math mode is currently supported.
10783
10784 @sp 1
10785 @cartouche
10786 @noindent
10787 @strong{122}. The sign of a zero result (or a component thereof) from
10788 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10789 @code{Real'Signed_Zeros} is True. See G.1.1(53).
10790 @end cartouche
10791 @noindent
10792 The signs of zero values are as recommended by the relevant
10793 implementation advice.
10794
10795 @sp 1
10796 @cartouche
10797 @noindent
10798 @strong{123}. The sign of a zero result (or a component thereof) from
10799 any operator or function in
10800 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10801 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
10802 @end cartouche
10803 @noindent
10804 The signs of zero values are as recommended by the relevant
10805 implementation advice.
10806
10807 @sp 1
10808 @cartouche
10809 @noindent
10810 @strong{124}. Whether the strict mode or the relaxed mode is the
10811 default. See G.2(2).
10812 @end cartouche
10813 @noindent
10814 The strict mode is the default. There is no separate relaxed mode. GNAT
10815 provides a highly efficient implementation of strict mode.
10816
10817 @sp 1
10818 @cartouche
10819 @noindent
10820 @strong{125}. The result interval in certain cases of fixed-to-float
10821 conversion. See G.2.1(10).
10822 @end cartouche
10823 @noindent
10824 For cases where the result interval is implementation dependent, the
10825 accuracy is that provided by performing all operations in 64-bit IEEE
10826 floating-point format.
10827
10828 @sp 1
10829 @cartouche
10830 @noindent
10831 @strong{126}. The result of a floating point arithmetic operation in
10832 overflow situations, when the @code{Machine_Overflows} attribute of the
10833 result type is @code{False}. See G.2.1(13).
10834 @end cartouche
10835 @noindent
10836 Infinite and NaN values are produced as dictated by the IEEE
10837 floating-point standard.
10838
10839 Note that on machines that are not fully compliant with the IEEE
10840 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10841 must be used for achieving IEEE conforming behavior (although at the cost
10842 of a significant performance penalty), so infinite and NaN values are
10843 properly generated.
10844
10845 @sp 1
10846 @cartouche
10847 @noindent
10848 @strong{127}. The result interval for division (or exponentiation by a
10849 negative exponent), when the floating point hardware implements division
10850 as multiplication by a reciprocal. See G.2.1(16).
10851 @end cartouche
10852 @noindent
10853 Not relevant, division is IEEE exact.
10854
10855 @sp 1
10856 @cartouche
10857 @noindent
10858 @strong{128}. The definition of close result set, which determines the
10859 accuracy of certain fixed point multiplications and divisions. See
10860 G.2.3(5).
10861 @end cartouche
10862 @noindent
10863 Operations in the close result set are performed using IEEE long format
10864 floating-point arithmetic. The input operands are converted to
10865 floating-point, the operation is done in floating-point, and the result
10866 is converted to the target type.
10867
10868 @sp 1
10869 @cartouche
10870 @noindent
10871 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
10872 point multiplication or division for which the result shall be in the
10873 perfect result set. See G.2.3(22).
10874 @end cartouche
10875 @noindent
10876 The result is only defined to be in the perfect result set if the result
10877 can be computed by a single scaling operation involving a scale factor
10878 representable in 64-bits.
10879
10880 @sp 1
10881 @cartouche
10882 @noindent
10883 @strong{130}. The result of a fixed point arithmetic operation in
10884 overflow situations, when the @code{Machine_Overflows} attribute of the
10885 result type is @code{False}. See G.2.3(27).
10886 @end cartouche
10887 @noindent
10888 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10889 types.
10890
10891 @sp 1
10892 @cartouche
10893 @noindent
10894 @strong{131}. The result of an elementary function reference in
10895 overflow situations, when the @code{Machine_Overflows} attribute of the
10896 result type is @code{False}. See G.2.4(4).
10897 @end cartouche
10898 @noindent
10899 IEEE infinite and Nan values are produced as appropriate.
10900
10901 @sp 1
10902 @cartouche
10903 @noindent
10904 @strong{132}. The value of the angle threshold, within which certain
10905 elementary functions, complex arithmetic operations, and complex
10906 elementary functions yield results conforming to a maximum relative
10907 error bound. See G.2.4(10).
10908 @end cartouche
10909 @noindent
10910 Information on this subject is not yet available.
10911
10912 @sp 1
10913 @cartouche
10914 @noindent
10915 @strong{133}. The accuracy of certain elementary functions for
10916 parameters beyond the angle threshold. See G.2.4(10).
10917 @end cartouche
10918 @noindent
10919 Information on this subject is not yet available.
10920
10921 @sp 1
10922 @cartouche
10923 @noindent
10924 @strong{134}. The result of a complex arithmetic operation or complex
10925 elementary function reference in overflow situations, when the
10926 @code{Machine_Overflows} attribute of the corresponding real type is
10927 @code{False}. See G.2.6(5).
10928 @end cartouche
10929 @noindent
10930 IEEE infinite and Nan values are produced as appropriate.
10931
10932 @sp 1
10933 @cartouche
10934 @noindent
10935 @strong{135}. The accuracy of certain complex arithmetic operations and
10936 certain complex elementary functions for parameters (or components
10937 thereof) beyond the angle threshold. See G.2.6(8).
10938 @end cartouche
10939 @noindent
10940 Information on those subjects is not yet available.
10941
10942 @sp 1
10943 @cartouche
10944 @noindent
10945 @strong{136}. Information regarding bounded errors and erroneous
10946 execution. See H.2(1).
10947 @end cartouche
10948 @noindent
10949 Information on this subject is not yet available.
10950
10951 @sp 1
10952 @cartouche
10953 @noindent
10954 @strong{137}. Implementation-defined aspects of pragma
10955 @code{Inspection_Point}. See H.3.2(8).
10956 @end cartouche
10957 @noindent
10958 Pragma @code{Inspection_Point} ensures that the variable is live and can
10959 be examined by the debugger at the inspection point.
10960
10961 @sp 1
10962 @cartouche
10963 @noindent
10964 @strong{138}. Implementation-defined aspects of pragma
10965 @code{Restrictions}. See H.4(25).
10966 @end cartouche
10967 @noindent
10968 There are no implementation-defined aspects of pragma @code{Restrictions}. The
10969 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10970 generated code. Checks must suppressed by use of pragma @code{Suppress}.
10971
10972 @sp 1
10973 @cartouche
10974 @noindent
10975 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
10976 H.4(27).
10977 @end cartouche
10978 @noindent
10979 There are no restrictions on pragma @code{Restrictions}.
10980
10981 @node Intrinsic Subprograms
10982 @chapter Intrinsic Subprograms
10983 @cindex Intrinsic Subprograms
10984
10985 @menu
10986 * Intrinsic Operators::
10987 * Enclosing_Entity::
10988 * Exception_Information::
10989 * Exception_Message::
10990 * Exception_Name::
10991 * File::
10992 * Line::
10993 * Shifts and Rotates::
10994 * Source_Location::
10995 @end menu
10996
10997 @noindent
10998 GNAT allows a user application program to write the declaration:
10999
11000 @smallexample @c ada
11001 pragma Import (Intrinsic, name);
11002 @end smallexample
11003
11004 @noindent
11005 providing that the name corresponds to one of the implemented intrinsic
11006 subprograms in GNAT, and that the parameter profile of the referenced
11007 subprogram meets the requirements. This chapter describes the set of
11008 implemented intrinsic subprograms, and the requirements on parameter profiles.
11009 Note that no body is supplied; as with other uses of pragma Import, the
11010 body is supplied elsewhere (in this case by the compiler itself). Note
11011 that any use of this feature is potentially non-portable, since the
11012 Ada standard does not require Ada compilers to implement this feature.
11013
11014 @node Intrinsic Operators
11015 @section Intrinsic Operators
11016 @cindex Intrinsic operator
11017
11018 @noindent
11019 All the predefined numeric operators in package Standard
11020 in @code{pragma Import (Intrinsic,..)}
11021 declarations. In the binary operator case, the operands must have the same
11022 size. The operand or operands must also be appropriate for
11023 the operator. For example, for addition, the operands must
11024 both be floating-point or both be fixed-point, and the
11025 right operand for @code{"**"} must have a root type of
11026 @code{Standard.Integer'Base}.
11027 You can use an intrinsic operator declaration as in the following example:
11028
11029 @smallexample @c ada
11030 type Int1 is new Integer;
11031 type Int2 is new Integer;
11032
11033 function "+" (X1 : Int1; X2 : Int2) return Int1;
11034 function "+" (X1 : Int1; X2 : Int2) return Int2;
11035 pragma Import (Intrinsic, "+");
11036 @end smallexample
11037
11038 @noindent
11039 This declaration would permit ``mixed mode'' arithmetic on items
11040 of the differing types @code{Int1} and @code{Int2}.
11041 It is also possible to specify such operators for private types, if the
11042 full views are appropriate arithmetic types.
11043
11044 @node Enclosing_Entity
11045 @section Enclosing_Entity
11046 @cindex Enclosing_Entity
11047 @noindent
11048 This intrinsic subprogram is used in the implementation of the
11049 library routine @code{GNAT.Source_Info}. The only useful use of the
11050 intrinsic import in this case is the one in this unit, so an
11051 application program should simply call the function
11052 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11053 the current subprogram, package, task, entry, or protected subprogram.
11054
11055 @node Exception_Information
11056 @section Exception_Information
11057 @cindex Exception_Information'
11058 @noindent
11059 This intrinsic subprogram is used in the implementation of the
11060 library routine @code{GNAT.Current_Exception}. The only useful
11061 use of the intrinsic import in this case is the one in this unit,
11062 so an application program should simply call the function
11063 @code{GNAT.Current_Exception.Exception_Information} to obtain
11064 the exception information associated with the current exception.
11065
11066 @node Exception_Message
11067 @section Exception_Message
11068 @cindex Exception_Message
11069 @noindent
11070 This intrinsic subprogram is used in the implementation of the
11071 library routine @code{GNAT.Current_Exception}. The only useful
11072 use of the intrinsic import in this case is the one in this unit,
11073 so an application program should simply call the function
11074 @code{GNAT.Current_Exception.Exception_Message} to obtain
11075 the message associated with the current exception.
11076
11077 @node Exception_Name
11078 @section Exception_Name
11079 @cindex Exception_Name
11080 @noindent
11081 This intrinsic subprogram is used in the implementation of the
11082 library routine @code{GNAT.Current_Exception}. The only useful
11083 use of the intrinsic import in this case is the one in this unit,
11084 so an application program should simply call the function
11085 @code{GNAT.Current_Exception.Exception_Name} to obtain
11086 the name of the current exception.
11087
11088 @node File
11089 @section File
11090 @cindex File
11091 @noindent
11092 This intrinsic subprogram is used in the implementation of the
11093 library routine @code{GNAT.Source_Info}. The only useful use of the
11094 intrinsic import in this case is the one in this unit, so an
11095 application program should simply call the function
11096 @code{GNAT.Source_Info.File} to obtain the name of the current
11097 file.
11098
11099 @node Line
11100 @section Line
11101 @cindex Line
11102 @noindent
11103 This intrinsic subprogram is used in the implementation of the
11104 library routine @code{GNAT.Source_Info}. The only useful use of the
11105 intrinsic import in this case is the one in this unit, so an
11106 application program should simply call the function
11107 @code{GNAT.Source_Info.Line} to obtain the number of the current
11108 source line.
11109
11110 @node Shifts and Rotates
11111 @section Shifts and Rotates
11112 @cindex Shift_Left
11113 @cindex Shift_Right
11114 @cindex Shift_Right_Arithmetic
11115 @cindex Rotate_Left
11116 @cindex Rotate_Right
11117 @noindent
11118 In standard Ada, the shift and rotate functions are available only
11119 for the predefined modular types in package @code{Interfaces}. However, in
11120 GNAT it is possible to define these functions for any integer
11121 type (signed or modular), as in this example:
11122
11123 @smallexample @c ada
11124 function Shift_Left
11125 (Value : T;
11126 Amount : Natural)
11127 return T;
11128 @end smallexample
11129
11130 @noindent
11131 The function name must be one of
11132 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11133 Rotate_Right. T must be an integer type. T'Size must be
11134 8, 16, 32 or 64 bits; if T is modular, the modulus
11135 must be 2**8, 2**16, 2**32 or 2**64.
11136 The result type must be the same as the type of @code{Value}.
11137 The shift amount must be Natural.
11138 The formal parameter names can be anything.
11139
11140 @node Source_Location
11141 @section Source_Location
11142 @cindex Source_Location
11143 @noindent
11144 This intrinsic subprogram is used in the implementation of the
11145 library routine @code{GNAT.Source_Info}. The only useful use of the
11146 intrinsic import in this case is the one in this unit, so an
11147 application program should simply call the function
11148 @code{GNAT.Source_Info.Source_Location} to obtain the current
11149 source file location.
11150
11151 @node Representation Clauses and Pragmas
11152 @chapter Representation Clauses and Pragmas
11153 @cindex Representation Clauses
11154
11155 @menu
11156 * Alignment Clauses::
11157 * Size Clauses::
11158 * Storage_Size Clauses::
11159 * Size of Variant Record Objects::
11160 * Biased Representation ::
11161 * Value_Size and Object_Size Clauses::
11162 * Component_Size Clauses::
11163 * Bit_Order Clauses::
11164 * Effect of Bit_Order on Byte Ordering::
11165 * Pragma Pack for Arrays::
11166 * Pragma Pack for Records::
11167 * Record Representation Clauses::
11168 * Enumeration Clauses::
11169 * Address Clauses::
11170 * Effect of Convention on Representation::
11171 * Determining the Representations chosen by GNAT::
11172 @end menu
11173
11174 @noindent
11175 @cindex Representation Clause
11176 @cindex Representation Pragma
11177 @cindex Pragma, representation
11178 This section describes the representation clauses accepted by GNAT, and
11179 their effect on the representation of corresponding data objects.
11180
11181 GNAT fully implements Annex C (Systems Programming). This means that all
11182 the implementation advice sections in chapter 13 are fully implemented.
11183 However, these sections only require a minimal level of support for
11184 representation clauses. GNAT provides much more extensive capabilities,
11185 and this section describes the additional capabilities provided.
11186
11187 @node Alignment Clauses
11188 @section Alignment Clauses
11189 @cindex Alignment Clause
11190
11191 @noindent
11192 GNAT requires that all alignment clauses specify a power of 2, and all
11193 default alignments are always a power of 2. The default alignment
11194 values are as follows:
11195
11196 @itemize @bullet
11197 @item @emph{Primitive Types}.
11198 For primitive types, the alignment is the minimum of the actual size of
11199 objects of the type divided by @code{Storage_Unit},
11200 and the maximum alignment supported by the target.
11201 (This maximum alignment is given by the GNAT-specific attribute
11202 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11203 @cindex @code{Maximum_Alignment} attribute
11204 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11205 default alignment will be 8 on any target that supports alignments
11206 this large, but on some targets, the maximum alignment may be smaller
11207 than 8, in which case objects of type @code{Long_Float} will be maximally
11208 aligned.
11209
11210 @item @emph{Arrays}.
11211 For arrays, the alignment is equal to the alignment of the component type
11212 for the normal case where no packing or component size is given. If the
11213 array is packed, and the packing is effective (see separate section on
11214 packed arrays), then the alignment will be one for long packed arrays,
11215 or arrays whose length is not known at compile time. For short packed
11216 arrays, which are handled internally as modular types, the alignment
11217 will be as described for primitive types, e.g.@: a packed array of length
11218 31 bits will have an object size of four bytes, and an alignment of 4.
11219
11220 @item @emph{Records}.
11221 For the normal non-packed case, the alignment of a record is equal to
11222 the maximum alignment of any of its components. For tagged records, this
11223 includes the implicit access type used for the tag. If a pragma @code{Pack}
11224 is used and all components are packable (see separate section on pragma
11225 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11226 record makes it profitable to increase it.
11227
11228 A special case is when:
11229 @itemize @bullet
11230 @item
11231 the size of the record is given explicitly, or a
11232 full record representation clause is given, and
11233 @item
11234 the size of the record is 2, 4, or 8 bytes.
11235 @end itemize
11236 @noindent
11237 In this case, an alignment is chosen to match the
11238 size of the record. For example, if we have:
11239
11240 @smallexample @c ada
11241 type Small is record
11242 A, B : Character;
11243 end record;
11244 for Small'Size use 16;
11245 @end smallexample
11246
11247 @noindent
11248 then the default alignment of the record type @code{Small} is 2, not 1. This
11249 leads to more efficient code when the record is treated as a unit, and also
11250 allows the type to specified as @code{Atomic} on architectures requiring
11251 strict alignment.
11252
11253 @end itemize
11254
11255 @noindent
11256 An alignment clause may specify a larger alignment than the default value
11257 up to some maximum value dependent on the target (obtainable by using the
11258 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11259 a smaller alignment than the default value for enumeration, integer and
11260 fixed point types, as well as for record types, for example
11261
11262 @smallexample @c ada
11263 type V is record
11264 A : Integer;
11265 end record;
11266
11267 for V'alignment use 1;
11268 @end smallexample
11269
11270 @noindent
11271 @cindex Alignment, default
11272 The default alignment for the type @code{V} is 4, as a result of the
11273 Integer field in the record, but it is permissible, as shown, to
11274 override the default alignment of the record with a smaller value.
11275
11276 @node Size Clauses
11277 @section Size Clauses
11278 @cindex Size Clause
11279
11280 @noindent
11281 The default size for a type @code{T} is obtainable through the
11282 language-defined attribute @code{T'Size} and also through the
11283 equivalent GNAT-defined attribute @code{T'Value_Size}.
11284 For objects of type @code{T}, GNAT will generally increase the type size
11285 so that the object size (obtainable through the GNAT-defined attribute
11286 @code{T'Object_Size})
11287 is a multiple of @code{T'Alignment * Storage_Unit}.
11288 For example
11289
11290 @smallexample @c ada
11291 type Smallint is range 1 .. 6;
11292
11293 type Rec is record
11294 Y1 : integer;
11295 Y2 : boolean;
11296 end record;
11297 @end smallexample
11298
11299 @noindent
11300 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11301 as specified by the RM rules,
11302 but objects of this type will have a size of 8
11303 (@code{Smallint'Object_Size} = 8),
11304 since objects by default occupy an integral number
11305 of storage units. On some targets, notably older
11306 versions of the Digital Alpha, the size of stand
11307 alone objects of this type may be 32, reflecting
11308 the inability of the hardware to do byte load/stores.
11309
11310 Similarly, the size of type @code{Rec} is 40 bits
11311 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11312 the alignment is 4, so objects of this type will have
11313 their size increased to 64 bits so that it is a multiple
11314 of the alignment (in bits). This decision is
11315 in accordance with the specific Implementation Advice in RM 13.3(43):
11316
11317 @quotation
11318 A @code{Size} clause should be supported for an object if the specified
11319 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
11320 to a size in storage elements that is a multiple of the object's
11321 @code{Alignment} (if the @code{Alignment} is nonzero).
11322 @end quotation
11323
11324 @noindent
11325 An explicit size clause may be used to override the default size by
11326 increasing it. For example, if we have:
11327
11328 @smallexample @c ada
11329 type My_Boolean is new Boolean;
11330 for My_Boolean'Size use 32;
11331 @end smallexample
11332
11333 @noindent
11334 then values of this type will always be 32 bits long. In the case of
11335 discrete types, the size can be increased up to 64 bits, with the effect
11336 that the entire specified field is used to hold the value, sign- or
11337 zero-extended as appropriate. If more than 64 bits is specified, then
11338 padding space is allocated after the value, and a warning is issued that
11339 there are unused bits.
11340
11341 Similarly the size of records and arrays may be increased, and the effect
11342 is to add padding bits after the value. This also causes a warning message
11343 to be generated.
11344
11345 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
11346 Size in bits, this corresponds to an object of size 256 megabytes (minus
11347 one). This limitation is true on all targets. The reason for this
11348 limitation is that it improves the quality of the code in many cases
11349 if it is known that a Size value can be accommodated in an object of
11350 type Integer.
11351
11352 @node Storage_Size Clauses
11353 @section Storage_Size Clauses
11354 @cindex Storage_Size Clause
11355
11356 @noindent
11357 For tasks, the @code{Storage_Size} clause specifies the amount of space
11358 to be allocated for the task stack. This cannot be extended, and if the
11359 stack is exhausted, then @code{Storage_Error} will be raised (if stack
11360 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
11361 or a @code{Storage_Size} pragma in the task definition to set the
11362 appropriate required size. A useful technique is to include in every
11363 task definition a pragma of the form:
11364
11365 @smallexample @c ada
11366 pragma Storage_Size (Default_Stack_Size);
11367 @end smallexample
11368
11369 @noindent
11370 Then @code{Default_Stack_Size} can be defined in a global package, and
11371 modified as required. Any tasks requiring stack sizes different from the
11372 default can have an appropriate alternative reference in the pragma.
11373
11374 You can also use the @option{-d} binder switch to modify the default stack
11375 size.
11376
11377 For access types, the @code{Storage_Size} clause specifies the maximum
11378 space available for allocation of objects of the type. If this space is
11379 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
11380 In the case where the access type is declared local to a subprogram, the
11381 use of a @code{Storage_Size} clause triggers automatic use of a special
11382 predefined storage pool (@code{System.Pool_Size}) that ensures that all
11383 space for the pool is automatically reclaimed on exit from the scope in
11384 which the type is declared.
11385
11386 A special case recognized by the compiler is the specification of a
11387 @code{Storage_Size} of zero for an access type. This means that no
11388 items can be allocated from the pool, and this is recognized at compile
11389 time, and all the overhead normally associated with maintaining a fixed
11390 size storage pool is eliminated. Consider the following example:
11391
11392 @smallexample @c ada
11393 procedure p is
11394 type R is array (Natural) of Character;
11395 type P is access all R;
11396 for P'Storage_Size use 0;
11397 -- Above access type intended only for interfacing purposes
11398
11399 y : P;
11400
11401 procedure g (m : P);
11402 pragma Import (C, g);
11403
11404 -- @dots{}
11405
11406 begin
11407 -- @dots{}
11408 y := new R;
11409 end;
11410 @end smallexample
11411
11412 @noindent
11413 As indicated in this example, these dummy storage pools are often useful in
11414 connection with interfacing where no object will ever be allocated. If you
11415 compile the above example, you get the warning:
11416
11417 @smallexample
11418 p.adb:16:09: warning: allocation from empty storage pool
11419 p.adb:16:09: warning: Storage_Error will be raised at run time
11420 @end smallexample
11421
11422 @noindent
11423 Of course in practice, there will not be any explicit allocators in the
11424 case of such an access declaration.
11425
11426 @node Size of Variant Record Objects
11427 @section Size of Variant Record Objects
11428 @cindex Size, variant record objects
11429 @cindex Variant record objects, size
11430
11431 @noindent
11432 In the case of variant record objects, there is a question whether Size gives
11433 information about a particular variant, or the maximum size required
11434 for any variant. Consider the following program
11435
11436 @smallexample @c ada
11437 with Text_IO; use Text_IO;
11438 procedure q is
11439 type R1 (A : Boolean := False) is record
11440 case A is
11441 when True => X : Character;
11442 when False => null;
11443 end case;
11444 end record;
11445
11446 V1 : R1 (False);
11447 V2 : R1;
11448
11449 begin
11450 Put_Line (Integer'Image (V1'Size));
11451 Put_Line (Integer'Image (V2'Size));
11452 end q;
11453 @end smallexample
11454
11455 @noindent
11456 Here we are dealing with a variant record, where the True variant
11457 requires 16 bits, and the False variant requires 8 bits.
11458 In the above example, both V1 and V2 contain the False variant,
11459 which is only 8 bits long. However, the result of running the
11460 program is:
11461
11462 @smallexample
11463 8
11464 16
11465 @end smallexample
11466
11467 @noindent
11468 The reason for the difference here is that the discriminant value of
11469 V1 is fixed, and will always be False. It is not possible to assign
11470 a True variant value to V1, therefore 8 bits is sufficient. On the
11471 other hand, in the case of V2, the initial discriminant value is
11472 False (from the default), but it is possible to assign a True
11473 variant value to V2, therefore 16 bits must be allocated for V2
11474 in the general case, even fewer bits may be needed at any particular
11475 point during the program execution.
11476
11477 As can be seen from the output of this program, the @code{'Size}
11478 attribute applied to such an object in GNAT gives the actual allocated
11479 size of the variable, which is the largest size of any of the variants.
11480 The Ada Reference Manual is not completely clear on what choice should
11481 be made here, but the GNAT behavior seems most consistent with the
11482 language in the RM@.
11483
11484 In some cases, it may be desirable to obtain the size of the current
11485 variant, rather than the size of the largest variant. This can be
11486 achieved in GNAT by making use of the fact that in the case of a
11487 subprogram parameter, GNAT does indeed return the size of the current
11488 variant (because a subprogram has no way of knowing how much space
11489 is actually allocated for the actual).
11490
11491 Consider the following modified version of the above program:
11492
11493 @smallexample @c ada
11494 with Text_IO; use Text_IO;
11495 procedure q is
11496 type R1 (A : Boolean := False) is record
11497 case A is
11498 when True => X : Character;
11499 when False => null;
11500 end case;
11501 end record;
11502
11503 V2 : R1;
11504
11505 function Size (V : R1) return Integer is
11506 begin
11507 return V'Size;
11508 end Size;
11509
11510 begin
11511 Put_Line (Integer'Image (V2'Size));
11512 Put_Line (Integer'IMage (Size (V2)));
11513 V2 := (True, 'x');
11514 Put_Line (Integer'Image (V2'Size));
11515 Put_Line (Integer'IMage (Size (V2)));
11516 end q;
11517 @end smallexample
11518
11519 @noindent
11520 The output from this program is
11521
11522 @smallexample
11523 16
11524 8
11525 16
11526 16
11527 @end smallexample
11528
11529 @noindent
11530 Here we see that while the @code{'Size} attribute always returns
11531 the maximum size, regardless of the current variant value, the
11532 @code{Size} function does indeed return the size of the current
11533 variant value.
11534
11535 @node Biased Representation
11536 @section Biased Representation
11537 @cindex Size for biased representation
11538 @cindex Biased representation
11539
11540 @noindent
11541 In the case of scalars with a range starting at other than zero, it is
11542 possible in some cases to specify a size smaller than the default minimum
11543 value, and in such cases, GNAT uses an unsigned biased representation,
11544 in which zero is used to represent the lower bound, and successive values
11545 represent successive values of the type.
11546
11547 For example, suppose we have the declaration:
11548
11549 @smallexample @c ada
11550 type Small is range -7 .. -4;
11551 for Small'Size use 2;
11552 @end smallexample
11553
11554 @noindent
11555 Although the default size of type @code{Small} is 4, the @code{Size}
11556 clause is accepted by GNAT and results in the following representation
11557 scheme:
11558
11559 @smallexample
11560 -7 is represented as 2#00#
11561 -6 is represented as 2#01#
11562 -5 is represented as 2#10#
11563 -4 is represented as 2#11#
11564 @end smallexample
11565
11566 @noindent
11567 Biased representation is only used if the specified @code{Size} clause
11568 cannot be accepted in any other manner. These reduced sizes that force
11569 biased representation can be used for all discrete types except for
11570 enumeration types for which a representation clause is given.
11571
11572 @node Value_Size and Object_Size Clauses
11573 @section Value_Size and Object_Size Clauses
11574 @findex Value_Size
11575 @findex Object_Size
11576 @cindex Size, of objects
11577
11578 @noindent
11579 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
11580 number of bits required to hold values of type @code{T}.
11581 Although this interpretation was allowed in Ada 83, it was not required,
11582 and this requirement in practice can cause some significant difficulties.
11583 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
11584 However, in Ada 95 and Ada 2005,
11585 @code{Natural'Size} is
11586 typically 31. This means that code may change in behavior when moving
11587 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
11588
11589 @smallexample @c ada
11590 type Rec is record;
11591 A : Natural;
11592 B : Natural;
11593 end record;
11594
11595 for Rec use record
11596 at 0 range 0 .. Natural'Size - 1;
11597 at 0 range Natural'Size .. 2 * Natural'Size - 1;
11598 end record;
11599 @end smallexample
11600
11601 @noindent
11602 In the above code, since the typical size of @code{Natural} objects
11603 is 32 bits and @code{Natural'Size} is 31, the above code can cause
11604 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11605 there are cases where the fact that the object size can exceed the
11606 size of the type causes surprises.
11607
11608 To help get around this problem GNAT provides two implementation
11609 defined attributes, @code{Value_Size} and @code{Object_Size}. When
11610 applied to a type, these attributes yield the size of the type
11611 (corresponding to the RM defined size attribute), and the size of
11612 objects of the type respectively.
11613
11614 The @code{Object_Size} is used for determining the default size of
11615 objects and components. This size value can be referred to using the
11616 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
11617 the basis of the determination of the size. The backend is free to
11618 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11619 character might be stored in 32 bits on a machine with no efficient
11620 byte access instructions such as the Alpha.
11621
11622 The default rules for the value of @code{Object_Size} for
11623 discrete types are as follows:
11624
11625 @itemize @bullet
11626 @item
11627 The @code{Object_Size} for base subtypes reflect the natural hardware
11628 size in bits (run the compiler with @option{-gnatS} to find those values
11629 for numeric types). Enumeration types and fixed-point base subtypes have
11630 8, 16, 32 or 64 bits for this size, depending on the range of values
11631 to be stored.
11632
11633 @item
11634 The @code{Object_Size} of a subtype is the same as the
11635 @code{Object_Size} of
11636 the type from which it is obtained.
11637
11638 @item
11639 The @code{Object_Size} of a derived base type is copied from the parent
11640 base type, and the @code{Object_Size} of a derived first subtype is copied
11641 from the parent first subtype.
11642 @end itemize
11643
11644 @noindent
11645 The @code{Value_Size} attribute
11646 is the (minimum) number of bits required to store a value
11647 of the type.
11648 This value is used to determine how tightly to pack
11649 records or arrays with components of this type, and also affects
11650 the semantics of unchecked conversion (unchecked conversions where
11651 the @code{Value_Size} values differ generate a warning, and are potentially
11652 target dependent).
11653
11654 The default rules for the value of @code{Value_Size} are as follows:
11655
11656 @itemize @bullet
11657 @item
11658 The @code{Value_Size} for a base subtype is the minimum number of bits
11659 required to store all values of the type (including the sign bit
11660 only if negative values are possible).
11661
11662 @item
11663 If a subtype statically matches the first subtype of a given type, then it has
11664 by default the same @code{Value_Size} as the first subtype. This is a
11665 consequence of RM 13.1(14) (``if two subtypes statically match,
11666 then their subtype-specific aspects are the same''.)
11667
11668 @item
11669 All other subtypes have a @code{Value_Size} corresponding to the minimum
11670 number of bits required to store all values of the subtype. For
11671 dynamic bounds, it is assumed that the value can range down or up
11672 to the corresponding bound of the ancestor
11673 @end itemize
11674
11675 @noindent
11676 The RM defined attribute @code{Size} corresponds to the
11677 @code{Value_Size} attribute.
11678
11679 The @code{Size} attribute may be defined for a first-named subtype. This sets
11680 the @code{Value_Size} of
11681 the first-named subtype to the given value, and the
11682 @code{Object_Size} of this first-named subtype to the given value padded up
11683 to an appropriate boundary. It is a consequence of the default rules
11684 above that this @code{Object_Size} will apply to all further subtypes. On the
11685 other hand, @code{Value_Size} is affected only for the first subtype, any
11686 dynamic subtypes obtained from it directly, and any statically matching
11687 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
11688
11689 @code{Value_Size} and
11690 @code{Object_Size} may be explicitly set for any subtype using
11691 an attribute definition clause. Note that the use of these attributes
11692 can cause the RM 13.1(14) rule to be violated. If two access types
11693 reference aliased objects whose subtypes have differing @code{Object_Size}
11694 values as a result of explicit attribute definition clauses, then it
11695 is erroneous to convert from one access subtype to the other.
11696
11697 At the implementation level, Esize stores the Object_Size and the
11698 RM_Size field stores the @code{Value_Size} (and hence the value of the
11699 @code{Size} attribute,
11700 which, as noted above, is equivalent to @code{Value_Size}).
11701
11702 To get a feel for the difference, consider the following examples (note
11703 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11704
11705 @smallexample
11706 Object_Size Value_Size
11707
11708 type x1 is range 0 .. 5; 8 3
11709
11710 type x2 is range 0 .. 5;
11711 for x2'size use 12; 16 12
11712
11713 subtype x3 is x2 range 0 .. 3; 16 2
11714
11715 subtype x4 is x2'base range 0 .. 10; 8 4
11716
11717 subtype x5 is x2 range 0 .. dynamic; 16 3*
11718
11719 subtype x6 is x2'base range 0 .. dynamic; 8 3*
11720
11721 @end smallexample
11722
11723 @noindent
11724 Note: the entries marked ``3*'' are not actually specified by the Ada
11725 Reference Manual, but it seems in the spirit of the RM rules to allocate
11726 the minimum number of bits (here 3, given the range for @code{x2})
11727 known to be large enough to hold the given range of values.
11728
11729 So far, so good, but GNAT has to obey the RM rules, so the question is
11730 under what conditions must the RM @code{Size} be used.
11731 The following is a list
11732 of the occasions on which the RM @code{Size} must be used:
11733
11734 @itemize @bullet
11735 @item
11736 Component size for packed arrays or records
11737
11738 @item
11739 Value of the attribute @code{Size} for a type
11740
11741 @item
11742 Warning about sizes not matching for unchecked conversion
11743 @end itemize
11744
11745 @noindent
11746 For record types, the @code{Object_Size} is always a multiple of the
11747 alignment of the type (this is true for all types). In some cases the
11748 @code{Value_Size} can be smaller. Consider:
11749
11750 @smallexample
11751 type R is record
11752 X : Integer;
11753 Y : Character;
11754 end record;
11755 @end smallexample
11756
11757 @noindent
11758 On a typical 32-bit architecture, the X component will be four bytes, and
11759 require four-byte alignment, and the Y component will be one byte. In this
11760 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11761 required to store a value of this type, and for example, it is permissible
11762 to have a component of type R in an outer array whose component size is
11763 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11764 since it must be rounded up so that this value is a multiple of the
11765 alignment (4 bytes = 32 bits).
11766
11767 @noindent
11768 For all other types, the @code{Object_Size}
11769 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11770 Only @code{Size} may be specified for such types.
11771
11772 @node Component_Size Clauses
11773 @section Component_Size Clauses
11774 @cindex Component_Size Clause
11775
11776 @noindent
11777 Normally, the value specified in a component size clause must be consistent
11778 with the subtype of the array component with regard to size and alignment.
11779 In other words, the value specified must be at least equal to the size
11780 of this subtype, and must be a multiple of the alignment value.
11781
11782 In addition, component size clauses are allowed which cause the array
11783 to be packed, by specifying a smaller value. A first case is for
11784 component size values in the range 1 through 63. The value specified
11785 must not be smaller than the Size of the subtype. GNAT will accurately
11786 honor all packing requests in this range. For example, if we have:
11787
11788 @smallexample @c ada
11789 type r is array (1 .. 8) of Natural;
11790 for r'Component_Size use 31;
11791 @end smallexample
11792
11793 @noindent
11794 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11795 Of course access to the components of such an array is considerably
11796 less efficient than if the natural component size of 32 is used.
11797 A second case is when the subtype of the component is a record type
11798 padded because of its default alignment. For example, if we have:
11799
11800 @smallexample @c ada
11801 type r is record
11802 i : Integer;
11803 j : Integer;
11804 b : Boolean;
11805 end record;
11806
11807 type a is array (1 .. 8) of r;
11808 for a'Component_Size use 72;
11809 @end smallexample
11810
11811 @noindent
11812 then the resulting array has a length of 72 bytes, instead of 96 bytes
11813 if the alignment of the record (4) was obeyed.
11814
11815 Note that there is no point in giving both a component size clause
11816 and a pragma Pack for the same array type. if such duplicate
11817 clauses are given, the pragma Pack will be ignored.
11818
11819 @node Bit_Order Clauses
11820 @section Bit_Order Clauses
11821 @cindex Bit_Order Clause
11822 @cindex bit ordering
11823 @cindex ordering, of bits
11824
11825 @noindent
11826 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11827 attribute. The specification may either correspond to the default bit
11828 order for the target, in which case the specification has no effect and
11829 places no additional restrictions, or it may be for the non-standard
11830 setting (that is the opposite of the default).
11831
11832 In the case where the non-standard value is specified, the effect is
11833 to renumber bits within each byte, but the ordering of bytes is not
11834 affected. There are certain
11835 restrictions placed on component clauses as follows:
11836
11837 @itemize @bullet
11838
11839 @item Components fitting within a single storage unit.
11840 @noindent
11841 These are unrestricted, and the effect is merely to renumber bits. For
11842 example if we are on a little-endian machine with @code{Low_Order_First}
11843 being the default, then the following two declarations have exactly
11844 the same effect:
11845
11846 @smallexample @c ada
11847 type R1 is record
11848 A : Boolean;
11849 B : Integer range 1 .. 120;
11850 end record;
11851
11852 for R1 use record
11853 A at 0 range 0 .. 0;
11854 B at 0 range 1 .. 7;
11855 end record;
11856
11857 type R2 is record
11858 A : Boolean;
11859 B : Integer range 1 .. 120;
11860 end record;
11861
11862 for R2'Bit_Order use High_Order_First;
11863
11864 for R2 use record
11865 A at 0 range 7 .. 7;
11866 B at 0 range 0 .. 6;
11867 end record;
11868 @end smallexample
11869
11870 @noindent
11871 The useful application here is to write the second declaration with the
11872 @code{Bit_Order} attribute definition clause, and know that it will be treated
11873 the same, regardless of whether the target is little-endian or big-endian.
11874
11875 @item Components occupying an integral number of bytes.
11876 @noindent
11877 These are components that exactly fit in two or more bytes. Such component
11878 declarations are allowed, but have no effect, since it is important to realize
11879 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11880 In particular, the following attempt at getting an endian-independent integer
11881 does not work:
11882
11883 @smallexample @c ada
11884 type R2 is record
11885 A : Integer;
11886 end record;
11887
11888 for R2'Bit_Order use High_Order_First;
11889
11890 for R2 use record
11891 A at 0 range 0 .. 31;
11892 end record;
11893 @end smallexample
11894
11895 @noindent
11896 This declaration will result in a little-endian integer on a
11897 little-endian machine, and a big-endian integer on a big-endian machine.
11898 If byte flipping is required for interoperability between big- and
11899 little-endian machines, this must be explicitly programmed. This capability
11900 is not provided by @code{Bit_Order}.
11901
11902 @item Components that are positioned across byte boundaries
11903 @noindent
11904 but do not occupy an integral number of bytes. Given that bytes are not
11905 reordered, such fields would occupy a non-contiguous sequence of bits
11906 in memory, requiring non-trivial code to reassemble. They are for this
11907 reason not permitted, and any component clause specifying such a layout
11908 will be flagged as illegal by GNAT@.
11909
11910 @end itemize
11911
11912 @noindent
11913 Since the misconception that Bit_Order automatically deals with all
11914 endian-related incompatibilities is a common one, the specification of
11915 a component field that is an integral number of bytes will always
11916 generate a warning. This warning may be suppressed using @code{pragma
11917 Warnings (Off)} if desired. The following section contains additional
11918 details regarding the issue of byte ordering.
11919
11920 @node Effect of Bit_Order on Byte Ordering
11921 @section Effect of Bit_Order on Byte Ordering
11922 @cindex byte ordering
11923 @cindex ordering, of bytes
11924
11925 @noindent
11926 In this section we will review the effect of the @code{Bit_Order} attribute
11927 definition clause on byte ordering. Briefly, it has no effect at all, but
11928 a detailed example will be helpful. Before giving this
11929 example, let us review the precise
11930 definition of the effect of defining @code{Bit_Order}. The effect of a
11931 non-standard bit order is described in section 15.5.3 of the Ada
11932 Reference Manual:
11933
11934 @quotation
11935 2 A bit ordering is a method of interpreting the meaning of
11936 the storage place attributes.
11937 @end quotation
11938
11939 @noindent
11940 To understand the precise definition of storage place attributes in
11941 this context, we visit section 13.5.1 of the manual:
11942
11943 @quotation
11944 13 A record_representation_clause (without the mod_clause)
11945 specifies the layout. The storage place attributes (see 13.5.2)
11946 are taken from the values of the position, first_bit, and last_bit
11947 expressions after normalizing those values so that first_bit is
11948 less than Storage_Unit.
11949 @end quotation
11950
11951 @noindent
11952 The critical point here is that storage places are taken from
11953 the values after normalization, not before. So the @code{Bit_Order}
11954 interpretation applies to normalized values. The interpretation
11955 is described in the later part of the 15.5.3 paragraph:
11956
11957 @quotation
11958 2 A bit ordering is a method of interpreting the meaning of
11959 the storage place attributes. High_Order_First (known in the
11960 vernacular as ``big endian'') means that the first bit of a
11961 storage element (bit 0) is the most significant bit (interpreting
11962 the sequence of bits that represent a component as an unsigned
11963 integer value). Low_Order_First (known in the vernacular as
11964 ``little endian'') means the opposite: the first bit is the
11965 least significant.
11966 @end quotation
11967
11968 @noindent
11969 Note that the numbering is with respect to the bits of a storage
11970 unit. In other words, the specification affects only the numbering
11971 of bits within a single storage unit.
11972
11973 We can make the effect clearer by giving an example.
11974
11975 Suppose that we have an external device which presents two bytes, the first
11976 byte presented, which is the first (low addressed byte) of the two byte
11977 record is called Master, and the second byte is called Slave.
11978
11979 The left most (most significant bit is called Control for each byte, and
11980 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11981 (least significant) bit.
11982
11983 On a big-endian machine, we can write the following representation clause
11984
11985 @smallexample @c ada
11986 type Data is record
11987 Master_Control : Bit;
11988 Master_V1 : Bit;
11989 Master_V2 : Bit;
11990 Master_V3 : Bit;
11991 Master_V4 : Bit;
11992 Master_V5 : Bit;
11993 Master_V6 : Bit;
11994 Master_V7 : Bit;
11995 Slave_Control : Bit;
11996 Slave_V1 : Bit;
11997 Slave_V2 : Bit;
11998 Slave_V3 : Bit;
11999 Slave_V4 : Bit;
12000 Slave_V5 : Bit;
12001 Slave_V6 : Bit;
12002 Slave_V7 : Bit;
12003 end record;
12004
12005 for Data use record
12006 Master_Control at 0 range 0 .. 0;
12007 Master_V1 at 0 range 1 .. 1;
12008 Master_V2 at 0 range 2 .. 2;
12009 Master_V3 at 0 range 3 .. 3;
12010 Master_V4 at 0 range 4 .. 4;
12011 Master_V5 at 0 range 5 .. 5;
12012 Master_V6 at 0 range 6 .. 6;
12013 Master_V7 at 0 range 7 .. 7;
12014 Slave_Control at 1 range 0 .. 0;
12015 Slave_V1 at 1 range 1 .. 1;
12016 Slave_V2 at 1 range 2 .. 2;
12017 Slave_V3 at 1 range 3 .. 3;
12018 Slave_V4 at 1 range 4 .. 4;
12019 Slave_V5 at 1 range 5 .. 5;
12020 Slave_V6 at 1 range 6 .. 6;
12021 Slave_V7 at 1 range 7 .. 7;
12022 end record;
12023 @end smallexample
12024
12025 @noindent
12026 Now if we move this to a little endian machine, then the bit ordering within
12027 the byte is backwards, so we have to rewrite the record rep clause as:
12028
12029 @smallexample @c ada
12030 for Data use record
12031 Master_Control at 0 range 7 .. 7;
12032 Master_V1 at 0 range 6 .. 6;
12033 Master_V2 at 0 range 5 .. 5;
12034 Master_V3 at 0 range 4 .. 4;
12035 Master_V4 at 0 range 3 .. 3;
12036 Master_V5 at 0 range 2 .. 2;
12037 Master_V6 at 0 range 1 .. 1;
12038 Master_V7 at 0 range 0 .. 0;
12039 Slave_Control at 1 range 7 .. 7;
12040 Slave_V1 at 1 range 6 .. 6;
12041 Slave_V2 at 1 range 5 .. 5;
12042 Slave_V3 at 1 range 4 .. 4;
12043 Slave_V4 at 1 range 3 .. 3;
12044 Slave_V5 at 1 range 2 .. 2;
12045 Slave_V6 at 1 range 1 .. 1;
12046 Slave_V7 at 1 range 0 .. 0;
12047 end record;
12048 @end smallexample
12049
12050 @noindent
12051 It is a nuisance to have to rewrite the clause, especially if
12052 the code has to be maintained on both machines. However,
12053 this is a case that we can handle with the
12054 @code{Bit_Order} attribute if it is implemented.
12055 Note that the implementation is not required on byte addressed
12056 machines, but it is indeed implemented in GNAT.
12057 This means that we can simply use the
12058 first record clause, together with the declaration
12059
12060 @smallexample @c ada
12061 for Data'Bit_Order use High_Order_First;
12062 @end smallexample
12063
12064 @noindent
12065 and the effect is what is desired, namely the layout is exactly the same,
12066 independent of whether the code is compiled on a big-endian or little-endian
12067 machine.
12068
12069 The important point to understand is that byte ordering is not affected.
12070 A @code{Bit_Order} attribute definition never affects which byte a field
12071 ends up in, only where it ends up in that byte.
12072 To make this clear, let us rewrite the record rep clause of the previous
12073 example as:
12074
12075 @smallexample @c ada
12076 for Data'Bit_Order use High_Order_First;
12077 for Data use record
12078 Master_Control at 0 range 0 .. 0;
12079 Master_V1 at 0 range 1 .. 1;
12080 Master_V2 at 0 range 2 .. 2;
12081 Master_V3 at 0 range 3 .. 3;
12082 Master_V4 at 0 range 4 .. 4;
12083 Master_V5 at 0 range 5 .. 5;
12084 Master_V6 at 0 range 6 .. 6;
12085 Master_V7 at 0 range 7 .. 7;
12086 Slave_Control at 0 range 8 .. 8;
12087 Slave_V1 at 0 range 9 .. 9;
12088 Slave_V2 at 0 range 10 .. 10;
12089 Slave_V3 at 0 range 11 .. 11;
12090 Slave_V4 at 0 range 12 .. 12;
12091 Slave_V5 at 0 range 13 .. 13;
12092 Slave_V6 at 0 range 14 .. 14;
12093 Slave_V7 at 0 range 15 .. 15;
12094 end record;
12095 @end smallexample
12096
12097 @noindent
12098 This is exactly equivalent to saying (a repeat of the first example):
12099
12100 @smallexample @c ada
12101 for Data'Bit_Order use High_Order_First;
12102 for Data use record
12103 Master_Control at 0 range 0 .. 0;
12104 Master_V1 at 0 range 1 .. 1;
12105 Master_V2 at 0 range 2 .. 2;
12106 Master_V3 at 0 range 3 .. 3;
12107 Master_V4 at 0 range 4 .. 4;
12108 Master_V5 at 0 range 5 .. 5;
12109 Master_V6 at 0 range 6 .. 6;
12110 Master_V7 at 0 range 7 .. 7;
12111 Slave_Control at 1 range 0 .. 0;
12112 Slave_V1 at 1 range 1 .. 1;
12113 Slave_V2 at 1 range 2 .. 2;
12114 Slave_V3 at 1 range 3 .. 3;
12115 Slave_V4 at 1 range 4 .. 4;
12116 Slave_V5 at 1 range 5 .. 5;
12117 Slave_V6 at 1 range 6 .. 6;
12118 Slave_V7 at 1 range 7 .. 7;
12119 end record;
12120 @end smallexample
12121
12122 @noindent
12123 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12124 field. The storage place attributes are obtained by normalizing the
12125 values given so that the @code{First_Bit} value is less than 8. After
12126 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12127 we specified in the other case.
12128
12129 Now one might expect that the @code{Bit_Order} attribute might affect
12130 bit numbering within the entire record component (two bytes in this
12131 case, thus affecting which byte fields end up in), but that is not
12132 the way this feature is defined, it only affects numbering of bits,
12133 not which byte they end up in.
12134
12135 Consequently it never makes sense to specify a starting bit number
12136 greater than 7 (for a byte addressable field) if an attribute
12137 definition for @code{Bit_Order} has been given, and indeed it
12138 may be actively confusing to specify such a value, so the compiler
12139 generates a warning for such usage.
12140
12141 If you do need to control byte ordering then appropriate conditional
12142 values must be used. If in our example, the slave byte came first on
12143 some machines we might write:
12144
12145 @smallexample @c ada
12146 Master_Byte_First constant Boolean := @dots{};
12147
12148 Master_Byte : constant Natural :=
12149 1 - Boolean'Pos (Master_Byte_First);
12150 Slave_Byte : constant Natural :=
12151 Boolean'Pos (Master_Byte_First);
12152
12153 for Data'Bit_Order use High_Order_First;
12154 for Data use record
12155 Master_Control at Master_Byte range 0 .. 0;
12156 Master_V1 at Master_Byte range 1 .. 1;
12157 Master_V2 at Master_Byte range 2 .. 2;
12158 Master_V3 at Master_Byte range 3 .. 3;
12159 Master_V4 at Master_Byte range 4 .. 4;
12160 Master_V5 at Master_Byte range 5 .. 5;
12161 Master_V6 at Master_Byte range 6 .. 6;
12162 Master_V7 at Master_Byte range 7 .. 7;
12163 Slave_Control at Slave_Byte range 0 .. 0;
12164 Slave_V1 at Slave_Byte range 1 .. 1;
12165 Slave_V2 at Slave_Byte range 2 .. 2;
12166 Slave_V3 at Slave_Byte range 3 .. 3;
12167 Slave_V4 at Slave_Byte range 4 .. 4;
12168 Slave_V5 at Slave_Byte range 5 .. 5;
12169 Slave_V6 at Slave_Byte range 6 .. 6;
12170 Slave_V7 at Slave_Byte range 7 .. 7;
12171 end record;
12172 @end smallexample
12173
12174 @noindent
12175 Now to switch between machines, all that is necessary is
12176 to set the boolean constant @code{Master_Byte_First} in
12177 an appropriate manner.
12178
12179 @node Pragma Pack for Arrays
12180 @section Pragma Pack for Arrays
12181 @cindex Pragma Pack (for arrays)
12182
12183 @noindent
12184 Pragma @code{Pack} applied to an array has no effect unless the component type
12185 is packable. For a component type to be packable, it must be one of the
12186 following cases:
12187
12188 @itemize @bullet
12189 @item
12190 Any scalar type
12191 @item
12192 Any type whose size is specified with a size clause
12193 @item
12194 Any packed array type with a static size
12195 @item
12196 Any record type padded because of its default alignment
12197 @end itemize
12198
12199 @noindent
12200 For all these cases, if the component subtype size is in the range
12201 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12202 component size were specified giving the component subtype size.
12203 For example if we have:
12204
12205 @smallexample @c ada
12206 type r is range 0 .. 17;
12207
12208 type ar is array (1 .. 8) of r;
12209 pragma Pack (ar);
12210 @end smallexample
12211
12212 @noindent
12213 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12214 and the size of the array @code{ar} will be exactly 40 bits.
12215
12216 Note that in some cases this rather fierce approach to packing can produce
12217 unexpected effects. For example, in Ada 95 and Ada 2005,
12218 subtype @code{Natural} typically has a size of 31, meaning that if you
12219 pack an array of @code{Natural}, you get 31-bit
12220 close packing, which saves a few bits, but results in far less efficient
12221 access. Since many other Ada compilers will ignore such a packing request,
12222 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12223 might not be what is intended. You can easily remove this warning by
12224 using an explicit @code{Component_Size} setting instead, which never generates
12225 a warning, since the intention of the programmer is clear in this case.
12226
12227 GNAT treats packed arrays in one of two ways. If the size of the array is
12228 known at compile time and is less than 64 bits, then internally the array
12229 is represented as a single modular type, of exactly the appropriate number
12230 of bits. If the length is greater than 63 bits, or is not known at compile
12231 time, then the packed array is represented as an array of bytes, and the
12232 length is always a multiple of 8 bits.
12233
12234 Note that to represent a packed array as a modular type, the alignment must
12235 be suitable for the modular type involved. For example, on typical machines
12236 a 32-bit packed array will be represented by a 32-bit modular integer with
12237 an alignment of four bytes. If you explicitly override the default alignment
12238 with an alignment clause that is too small, the modular representation
12239 cannot be used. For example, consider the following set of declarations:
12240
12241 @smallexample @c ada
12242 type R is range 1 .. 3;
12243 type S is array (1 .. 31) of R;
12244 for S'Component_Size use 2;
12245 for S'Size use 62;
12246 for S'Alignment use 1;
12247 @end smallexample
12248
12249 @noindent
12250 If the alignment clause were not present, then a 62-bit modular
12251 representation would be chosen (typically with an alignment of 4 or 8
12252 bytes depending on the target). But the default alignment is overridden
12253 with the explicit alignment clause. This means that the modular
12254 representation cannot be used, and instead the array of bytes
12255 representation must be used, meaning that the length must be a multiple
12256 of 8. Thus the above set of declarations will result in a diagnostic
12257 rejecting the size clause and noting that the minimum size allowed is 64.
12258
12259 @cindex Pragma Pack (for type Natural)
12260 @cindex Pragma Pack warning
12261
12262 One special case that is worth noting occurs when the base type of the
12263 component size is 8/16/32 and the subtype is one bit less. Notably this
12264 occurs with subtype @code{Natural}. Consider:
12265
12266 @smallexample @c ada
12267 type Arr is array (1 .. 32) of Natural;
12268 pragma Pack (Arr);
12269 @end smallexample
12270
12271 @noindent
12272 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12273 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12274 Ada 83 compilers did not attempt 31 bit packing.
12275
12276 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12277 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12278 substantial unintended performance penalty when porting legacy Ada 83 code.
12279 To help prevent this, GNAT generates a warning in such cases. If you really
12280 want 31 bit packing in a case like this, you can set the component size
12281 explicitly:
12282
12283 @smallexample @c ada
12284 type Arr is array (1 .. 32) of Natural;
12285 for Arr'Component_Size use 31;
12286 @end smallexample
12287
12288 @noindent
12289 Here 31-bit packing is achieved as required, and no warning is generated,
12290 since in this case the programmer intention is clear.
12291
12292 @node Pragma Pack for Records
12293 @section Pragma Pack for Records
12294 @cindex Pragma Pack (for records)
12295
12296 @noindent
12297 Pragma @code{Pack} applied to a record will pack the components to reduce
12298 wasted space from alignment gaps and by reducing the amount of space
12299 taken by components. We distinguish between @emph{packable} components and
12300 @emph{non-packable} components.
12301 Components of the following types are considered packable:
12302 @itemize @bullet
12303 @item
12304 All primitive types are packable.
12305
12306 @item
12307 Small packed arrays, whose size does not exceed 64 bits, and where the
12308 size is statically known at compile time, are represented internally
12309 as modular integers, and so they are also packable.
12310
12311 @end itemize
12312
12313 @noindent
12314 All packable components occupy the exact number of bits corresponding to
12315 their @code{Size} value, and are packed with no padding bits, i.e.@: they
12316 can start on an arbitrary bit boundary.
12317
12318 All other types are non-packable, they occupy an integral number of
12319 storage units, and
12320 are placed at a boundary corresponding to their alignment requirements.
12321
12322 For example, consider the record
12323
12324 @smallexample @c ada
12325 type Rb1 is array (1 .. 13) of Boolean;
12326 pragma Pack (rb1);
12327
12328 type Rb2 is array (1 .. 65) of Boolean;
12329 pragma Pack (rb2);
12330
12331 type x2 is record
12332 l1 : Boolean;
12333 l2 : Duration;
12334 l3 : Float;
12335 l4 : Boolean;
12336 l5 : Rb1;
12337 l6 : Rb2;
12338 end record;
12339 pragma Pack (x2);
12340 @end smallexample
12341
12342 @noindent
12343 The representation for the record x2 is as follows:
12344
12345 @smallexample @c ada
12346 for x2'Size use 224;
12347 for x2 use record
12348 l1 at 0 range 0 .. 0;
12349 l2 at 0 range 1 .. 64;
12350 l3 at 12 range 0 .. 31;
12351 l4 at 16 range 0 .. 0;
12352 l5 at 16 range 1 .. 13;
12353 l6 at 18 range 0 .. 71;
12354 end record;
12355 @end smallexample
12356
12357 @noindent
12358 Studying this example, we see that the packable fields @code{l1}
12359 and @code{l2} are
12360 of length equal to their sizes, and placed at specific bit boundaries (and
12361 not byte boundaries) to
12362 eliminate padding. But @code{l3} is of a non-packable float type, so
12363 it is on the next appropriate alignment boundary.
12364
12365 The next two fields are fully packable, so @code{l4} and @code{l5} are
12366 minimally packed with no gaps. However, type @code{Rb2} is a packed
12367 array that is longer than 64 bits, so it is itself non-packable. Thus
12368 the @code{l6} field is aligned to the next byte boundary, and takes an
12369 integral number of bytes, i.e.@: 72 bits.
12370
12371 @node Record Representation Clauses
12372 @section Record Representation Clauses
12373 @cindex Record Representation Clause
12374
12375 @noindent
12376 Record representation clauses may be given for all record types, including
12377 types obtained by record extension. Component clauses are allowed for any
12378 static component. The restrictions on component clauses depend on the type
12379 of the component.
12380
12381 @cindex Component Clause
12382 For all components of an elementary type, the only restriction on component
12383 clauses is that the size must be at least the 'Size value of the type
12384 (actually the Value_Size). There are no restrictions due to alignment,
12385 and such components may freely cross storage boundaries.
12386
12387 Packed arrays with a size up to and including 64 bits are represented
12388 internally using a modular type with the appropriate number of bits, and
12389 thus the same lack of restriction applies. For example, if you declare:
12390
12391 @smallexample @c ada
12392 type R is array (1 .. 49) of Boolean;
12393 pragma Pack (R);
12394 for R'Size use 49;
12395 @end smallexample
12396
12397 @noindent
12398 then a component clause for a component of type R may start on any
12399 specified bit boundary, and may specify a value of 49 bits or greater.
12400
12401 For packed bit arrays that are longer than 64 bits, there are two
12402 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
12403 including the important case of single bits or boolean values, then
12404 there are no limitations on placement of such components, and they
12405 may start and end at arbitrary bit boundaries.
12406
12407 If the component size is not a power of 2 (e.g.@: 3 or 5), then
12408 an array of this type longer than 64 bits must always be placed on
12409 on a storage unit (byte) boundary and occupy an integral number
12410 of storage units (bytes). Any component clause that does not
12411 meet this requirement will be rejected.
12412
12413 Any aliased component, or component of an aliased type, must
12414 have its normal alignment and size. A component clause that
12415 does not meet this requirement will be rejected.
12416
12417 The tag field of a tagged type always occupies an address sized field at
12418 the start of the record. No component clause may attempt to overlay this
12419 tag. When a tagged type appears as a component, the tag field must have
12420 proper alignment
12421
12422 In the case of a record extension T1, of a type T, no component clause applied
12423 to the type T1 can specify a storage location that would overlap the first
12424 T'Size bytes of the record.
12425
12426 For all other component types, including non-bit-packed arrays,
12427 the component can be placed at an arbitrary bit boundary,
12428 so for example, the following is permitted:
12429
12430 @smallexample @c ada
12431 type R is array (1 .. 10) of Boolean;
12432 for R'Size use 80;
12433
12434 type Q is record
12435 G, H : Boolean;
12436 L, M : R;
12437 end record;
12438
12439 for Q use record
12440 G at 0 range 0 .. 0;
12441 H at 0 range 1 .. 1;
12442 L at 0 range 2 .. 81;
12443 R at 0 range 82 .. 161;
12444 end record;
12445 @end smallexample
12446
12447 @noindent
12448 Note: the above rules apply to recent releases of GNAT 5.
12449 In GNAT 3, there are more severe restrictions on larger components.
12450 For non-primitive types, including packed arrays with a size greater than
12451 64 bits, component clauses must respect the alignment requirement of the
12452 type, in particular, always starting on a byte boundary, and the length
12453 must be a multiple of the storage unit.
12454
12455 @node Enumeration Clauses
12456 @section Enumeration Clauses
12457
12458 The only restriction on enumeration clauses is that the range of values
12459 must be representable. For the signed case, if one or more of the
12460 representation values are negative, all values must be in the range:
12461
12462 @smallexample @c ada
12463 System.Min_Int .. System.Max_Int
12464 @end smallexample
12465
12466 @noindent
12467 For the unsigned case, where all values are nonnegative, the values must
12468 be in the range:
12469
12470 @smallexample @c ada
12471 0 .. System.Max_Binary_Modulus;
12472 @end smallexample
12473
12474 @noindent
12475 A @emph{confirming} representation clause is one in which the values range
12476 from 0 in sequence, i.e.@: a clause that confirms the default representation
12477 for an enumeration type.
12478 Such a confirming representation
12479 is permitted by these rules, and is specially recognized by the compiler so
12480 that no extra overhead results from the use of such a clause.
12481
12482 If an array has an index type which is an enumeration type to which an
12483 enumeration clause has been applied, then the array is stored in a compact
12484 manner. Consider the declarations:
12485
12486 @smallexample @c ada
12487 type r is (A, B, C);
12488 for r use (A => 1, B => 5, C => 10);
12489 type t is array (r) of Character;
12490 @end smallexample
12491
12492 @noindent
12493 The array type t corresponds to a vector with exactly three elements and
12494 has a default size equal to @code{3*Character'Size}. This ensures efficient
12495 use of space, but means that accesses to elements of the array will incur
12496 the overhead of converting representation values to the corresponding
12497 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
12498
12499 @node Address Clauses
12500 @section Address Clauses
12501 @cindex Address Clause
12502
12503 The reference manual allows a general restriction on representation clauses,
12504 as found in RM 13.1(22):
12505
12506 @quotation
12507 An implementation need not support representation
12508 items containing nonstatic expressions, except that
12509 an implementation should support a representation item
12510 for a given entity if each nonstatic expression in the
12511 representation item is a name that statically denotes
12512 a constant declared before the entity.
12513 @end quotation
12514
12515 @noindent
12516 In practice this is applicable only to address clauses, since this is the
12517 only case in which a non-static expression is permitted by the syntax. As
12518 the AARM notes in sections 13.1 (22.a-22.h):
12519
12520 @display
12521 22.a Reason: This is to avoid the following sort of thing:
12522
12523 22.b X : Integer := F(@dots{});
12524 Y : Address := G(@dots{});
12525 for X'Address use Y;
12526
12527 22.c In the above, we have to evaluate the
12528 initialization expression for X before we
12529 know where to put the result. This seems
12530 like an unreasonable implementation burden.
12531
12532 22.d The above code should instead be written
12533 like this:
12534
12535 22.e Y : constant Address := G(@dots{});
12536 X : Integer := F(@dots{});
12537 for X'Address use Y;
12538
12539 22.f This allows the expression ``Y'' to be safely
12540 evaluated before X is created.
12541
12542 22.g The constant could be a formal parameter of mode in.
12543
12544 22.h An implementation can support other nonstatic
12545 expressions if it wants to. Expressions of type
12546 Address are hardly ever static, but their value
12547 might be known at compile time anyway in many
12548 cases.
12549 @end display
12550
12551 @noindent
12552 GNAT does indeed permit many additional cases of non-static expressions. In
12553 particular, if the type involved is elementary there are no restrictions
12554 (since in this case, holding a temporary copy of the initialization value,
12555 if one is present, is inexpensive). In addition, if there is no implicit or
12556 explicit initialization, then there are no restrictions. GNAT will reject
12557 only the case where all three of these conditions hold:
12558
12559 @itemize @bullet
12560
12561 @item
12562 The type of the item is non-elementary (e.g.@: a record or array).
12563
12564 @item
12565 There is explicit or implicit initialization required for the object.
12566 Note that access values are always implicitly initialized.
12567
12568 @item
12569 The address value is non-static. Here GNAT is more permissive than the
12570 RM, and allows the address value to be the address of a previously declared
12571 stand-alone variable, as long as it does not itself have an address clause.
12572
12573 @smallexample @c ada
12574 Anchor : Some_Initialized_Type;
12575 Overlay : Some_Initialized_Type;
12576 for Overlay'Address use Anchor'Address;
12577 @end smallexample
12578
12579 @noindent
12580 However, the prefix of the address clause cannot be an array component, or
12581 a component of a discriminated record.
12582
12583 @end itemize
12584
12585 @noindent
12586 As noted above in section 22.h, address values are typically non-static. In
12587 particular the To_Address function, even if applied to a literal value, is
12588 a non-static function call. To avoid this minor annoyance, GNAT provides
12589 the implementation defined attribute 'To_Address. The following two
12590 expressions have identical values:
12591
12592 @findex Attribute
12593 @findex To_Address
12594 @smallexample @c ada
12595 To_Address (16#1234_0000#)
12596 System'To_Address (16#1234_0000#);
12597 @end smallexample
12598
12599 @noindent
12600 except that the second form is considered to be a static expression, and
12601 thus when used as an address clause value is always permitted.
12602
12603 @noindent
12604 Additionally, GNAT treats as static an address clause that is an
12605 unchecked_conversion of a static integer value. This simplifies the porting
12606 of legacy code, and provides a portable equivalent to the GNAT attribute
12607 @code{To_Address}.
12608
12609 Another issue with address clauses is the interaction with alignment
12610 requirements. When an address clause is given for an object, the address
12611 value must be consistent with the alignment of the object (which is usually
12612 the same as the alignment of the type of the object). If an address clause
12613 is given that specifies an inappropriately aligned address value, then the
12614 program execution is erroneous.
12615
12616 Since this source of erroneous behavior can have unfortunate effects, GNAT
12617 checks (at compile time if possible, generating a warning, or at execution
12618 time with a run-time check) that the alignment is appropriate. If the
12619 run-time check fails, then @code{Program_Error} is raised. This run-time
12620 check is suppressed if range checks are suppressed, or if the special GNAT
12621 check Alignment_Check is suppressed, or if
12622 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12623
12624 Finally, GNAT does not permit overlaying of objects of controlled types or
12625 composite types containing a controlled component. In most cases, the compiler
12626 can detect an attempt at such overlays and will generate a warning at compile
12627 time and a Program_Error exception at run time.
12628
12629 @findex Export
12630 An address clause cannot be given for an exported object. More
12631 understandably the real restriction is that objects with an address
12632 clause cannot be exported. This is because such variables are not
12633 defined by the Ada program, so there is no external object to export.
12634
12635 @findex Import
12636 It is permissible to give an address clause and a pragma Import for the
12637 same object. In this case, the variable is not really defined by the
12638 Ada program, so there is no external symbol to be linked. The link name
12639 and the external name are ignored in this case. The reason that we allow this
12640 combination is that it provides a useful idiom to avoid unwanted
12641 initializations on objects with address clauses.
12642
12643 When an address clause is given for an object that has implicit or
12644 explicit initialization, then by default initialization takes place. This
12645 means that the effect of the object declaration is to overwrite the
12646 memory at the specified address. This is almost always not what the
12647 programmer wants, so GNAT will output a warning:
12648
12649 @smallexample
12650 with System;
12651 package G is
12652 type R is record
12653 M : Integer := 0;
12654 end record;
12655
12656 Ext : R;
12657 for Ext'Address use System'To_Address (16#1234_1234#);
12658 |
12659 >>> warning: implicit initialization of "Ext" may
12660 modify overlaid storage
12661 >>> warning: use pragma Import for "Ext" to suppress
12662 initialization (RM B(24))
12663
12664 end G;
12665 @end smallexample
12666
12667 @noindent
12668 As indicated by the warning message, the solution is to use a (dummy) pragma
12669 Import to suppress this initialization. The pragma tell the compiler that the
12670 object is declared and initialized elsewhere. The following package compiles
12671 without warnings (and the initialization is suppressed):
12672
12673 @smallexample @c ada
12674 with System;
12675 package G is
12676 type R is record
12677 M : Integer := 0;
12678 end record;
12679
12680 Ext : R;
12681 for Ext'Address use System'To_Address (16#1234_1234#);
12682 pragma Import (Ada, Ext);
12683 end G;
12684 @end smallexample
12685
12686 @noindent
12687 A final issue with address clauses involves their use for overlaying
12688 variables, as in the following example:
12689 @cindex Overlaying of objects
12690
12691 @smallexample @c ada
12692 A : Integer;
12693 B : Integer;
12694 for B'Address use A'Address;
12695 @end smallexample
12696
12697 @noindent
12698 or alternatively, using the form recommended by the RM:
12699
12700 @smallexample @c ada
12701 A : Integer;
12702 Addr : constant Address := A'Address;
12703 B : Integer;
12704 for B'Address use Addr;
12705 @end smallexample
12706
12707 @noindent
12708 In both of these cases, @code{A}
12709 and @code{B} become aliased to one another via the
12710 address clause. This use of address clauses to overlay
12711 variables, achieving an effect similar to unchecked
12712 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12713 the effect is implementation defined. Furthermore, the
12714 Ada RM specifically recommends that in a situation
12715 like this, @code{B} should be subject to the following
12716 implementation advice (RM 13.3(19)):
12717
12718 @quotation
12719 19 If the Address of an object is specified, or it is imported
12720 or exported, then the implementation should not perform
12721 optimizations based on assumptions of no aliases.
12722 @end quotation
12723
12724 @noindent
12725 GNAT follows this recommendation, and goes further by also applying
12726 this recommendation to the overlaid variable (@code{A}
12727 in the above example) in this case. This means that the overlay
12728 works "as expected", in that a modification to one of the variables
12729 will affect the value of the other.
12730
12731 @node Effect of Convention on Representation
12732 @section Effect of Convention on Representation
12733 @cindex Convention, effect on representation
12734
12735 @noindent
12736 Normally the specification of a foreign language convention for a type or
12737 an object has no effect on the chosen representation. In particular, the
12738 representation chosen for data in GNAT generally meets the standard system
12739 conventions, and for example records are laid out in a manner that is
12740 consistent with C@. This means that specifying convention C (for example)
12741 has no effect.
12742
12743 There are four exceptions to this general rule:
12744
12745 @itemize @bullet
12746
12747 @item Convention Fortran and array subtypes
12748 If pragma Convention Fortran is specified for an array subtype, then in
12749 accordance with the implementation advice in section 3.6.2(11) of the
12750 Ada Reference Manual, the array will be stored in a Fortran-compatible
12751 column-major manner, instead of the normal default row-major order.
12752
12753 @item Convention C and enumeration types
12754 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12755 to accommodate all values of the type. For example, for the enumeration
12756 type declared by:
12757
12758 @smallexample @c ada
12759 type Color is (Red, Green, Blue);
12760 @end smallexample
12761
12762 @noindent
12763 8 bits is sufficient to store all values of the type, so by default, objects
12764 of type @code{Color} will be represented using 8 bits. However, normal C
12765 convention is to use 32 bits for all enum values in C, since enum values
12766 are essentially of type int. If pragma @code{Convention C} is specified for an
12767 Ada enumeration type, then the size is modified as necessary (usually to
12768 32 bits) to be consistent with the C convention for enum values.
12769
12770 Note that this treatment applies only to types. If Convention C is given for
12771 an enumeration object, where the enumeration type is not Convention C, then
12772 Object_Size bits are allocated. For example, for a normal enumeration type,
12773 with less than 256 elements, only 8 bits will be allocated for the object.
12774 Since this may be a surprise in terms of what C expects, GNAT will issue a
12775 warning in this situation. The warning can be suppressed by giving an explicit
12776 size clause specifying the desired size.
12777
12778 @item Convention C/Fortran and Boolean types
12779 In C, the usual convention for boolean values, that is values used for
12780 conditions, is that zero represents false, and nonzero values represent
12781 true. In Ada, the normal convention is that two specific values, typically
12782 0/1, are used to represent false/true respectively.
12783
12784 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12785 value represents true).
12786
12787 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12788 C or Fortran convention for a derived Boolean, as in the following example:
12789
12790 @smallexample @c ada
12791 type C_Switch is new Boolean;
12792 pragma Convention (C, C_Switch);
12793 @end smallexample
12794
12795 @noindent
12796 then the GNAT generated code will treat any nonzero value as true. For truth
12797 values generated by GNAT, the conventional value 1 will be used for True, but
12798 when one of these values is read, any nonzero value is treated as True.
12799
12800 @item Access types on OpenVMS
12801 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12802 arrays) are 64-bits long. An exception to this rule is for the case of
12803 C-convention access types where there is no explicit size clause present (or
12804 inherited for derived types). In this case, GNAT chooses to make these
12805 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12806 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12807
12808 @end itemize
12809
12810 @node Determining the Representations chosen by GNAT
12811 @section Determining the Representations chosen by GNAT
12812 @cindex Representation, determination of
12813 @cindex @option{-gnatR} switch
12814
12815 @noindent
12816 Although the descriptions in this section are intended to be complete, it is
12817 often easier to simply experiment to see what GNAT accepts and what the
12818 effect is on the layout of types and objects.
12819
12820 As required by the Ada RM, if a representation clause is not accepted, then
12821 it must be rejected as illegal by the compiler. However, when a
12822 representation clause or pragma is accepted, there can still be questions
12823 of what the compiler actually does. For example, if a partial record
12824 representation clause specifies the location of some components and not
12825 others, then where are the non-specified components placed? Or if pragma
12826 @code{Pack} is used on a record, then exactly where are the resulting
12827 fields placed? The section on pragma @code{Pack} in this chapter can be
12828 used to answer the second question, but it is often easier to just see
12829 what the compiler does.
12830
12831 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
12832 with this option, then the compiler will output information on the actual
12833 representations chosen, in a format similar to source representation
12834 clauses. For example, if we compile the package:
12835
12836 @smallexample @c ada
12837 package q is
12838 type r (x : boolean) is tagged record
12839 case x is
12840 when True => S : String (1 .. 100);
12841 when False => null;
12842 end case;
12843 end record;
12844
12845 type r2 is new r (false) with record
12846 y2 : integer;
12847 end record;
12848
12849 for r2 use record
12850 y2 at 16 range 0 .. 31;
12851 end record;
12852
12853 type x is record
12854 y : character;
12855 end record;
12856
12857 type x1 is array (1 .. 10) of x;
12858 for x1'component_size use 11;
12859
12860 type ia is access integer;
12861
12862 type Rb1 is array (1 .. 13) of Boolean;
12863 pragma Pack (rb1);
12864
12865 type Rb2 is array (1 .. 65) of Boolean;
12866 pragma Pack (rb2);
12867
12868 type x2 is record
12869 l1 : Boolean;
12870 l2 : Duration;
12871 l3 : Float;
12872 l4 : Boolean;
12873 l5 : Rb1;
12874 l6 : Rb2;
12875 end record;
12876 pragma Pack (x2);
12877 end q;
12878 @end smallexample
12879
12880 @noindent
12881 using the switch @option{-gnatR} we obtain the following output:
12882
12883 @smallexample
12884 Representation information for unit q
12885 -------------------------------------
12886
12887 for r'Size use ??;
12888 for r'Alignment use 4;
12889 for r use record
12890 x at 4 range 0 .. 7;
12891 _tag at 0 range 0 .. 31;
12892 s at 5 range 0 .. 799;
12893 end record;
12894
12895 for r2'Size use 160;
12896 for r2'Alignment use 4;
12897 for r2 use record
12898 x at 4 range 0 .. 7;
12899 _tag at 0 range 0 .. 31;
12900 _parent at 0 range 0 .. 63;
12901 y2 at 16 range 0 .. 31;
12902 end record;
12903
12904 for x'Size use 8;
12905 for x'Alignment use 1;
12906 for x use record
12907 y at 0 range 0 .. 7;
12908 end record;
12909
12910 for x1'Size use 112;
12911 for x1'Alignment use 1;
12912 for x1'Component_Size use 11;
12913
12914 for rb1'Size use 13;
12915 for rb1'Alignment use 2;
12916 for rb1'Component_Size use 1;
12917
12918 for rb2'Size use 72;
12919 for rb2'Alignment use 1;
12920 for rb2'Component_Size use 1;
12921
12922 for x2'Size use 224;
12923 for x2'Alignment use 4;
12924 for x2 use record
12925 l1 at 0 range 0 .. 0;
12926 l2 at 0 range 1 .. 64;
12927 l3 at 12 range 0 .. 31;
12928 l4 at 16 range 0 .. 0;
12929 l5 at 16 range 1 .. 13;
12930 l6 at 18 range 0 .. 71;
12931 end record;
12932 @end smallexample
12933
12934 @noindent
12935 The Size values are actually the Object_Size, i.e.@: the default size that
12936 will be allocated for objects of the type.
12937 The ?? size for type r indicates that we have a variant record, and the
12938 actual size of objects will depend on the discriminant value.
12939
12940 The Alignment values show the actual alignment chosen by the compiler
12941 for each record or array type.
12942
12943 The record representation clause for type r shows where all fields
12944 are placed, including the compiler generated tag field (whose location
12945 cannot be controlled by the programmer).
12946
12947 The record representation clause for the type extension r2 shows all the
12948 fields present, including the parent field, which is a copy of the fields
12949 of the parent type of r2, i.e.@: r1.
12950
12951 The component size and size clauses for types rb1 and rb2 show
12952 the exact effect of pragma @code{Pack} on these arrays, and the record
12953 representation clause for type x2 shows how pragma @code{Pack} affects
12954 this record type.
12955
12956 In some cases, it may be useful to cut and paste the representation clauses
12957 generated by the compiler into the original source to fix and guarantee
12958 the actual representation to be used.
12959
12960 @node Standard Library Routines
12961 @chapter Standard Library Routines
12962
12963 @noindent
12964 The Ada Reference Manual contains in Annex A a full description of an
12965 extensive set of standard library routines that can be used in any Ada
12966 program, and which must be provided by all Ada compilers. They are
12967 analogous to the standard C library used by C programs.
12968
12969 GNAT implements all of the facilities described in annex A, and for most
12970 purposes the description in the Ada Reference Manual, or appropriate Ada
12971 text book, will be sufficient for making use of these facilities.
12972
12973 In the case of the input-output facilities,
12974 @xref{The Implementation of Standard I/O},
12975 gives details on exactly how GNAT interfaces to the
12976 file system. For the remaining packages, the Ada Reference Manual
12977 should be sufficient. The following is a list of the packages included,
12978 together with a brief description of the functionality that is provided.
12979
12980 For completeness, references are included to other predefined library
12981 routines defined in other sections of the Ada Reference Manual (these are
12982 cross-indexed from Annex A).
12983
12984 @table @code
12985 @item Ada (A.2)
12986 This is a parent package for all the standard library packages. It is
12987 usually included implicitly in your program, and itself contains no
12988 useful data or routines.
12989
12990 @item Ada.Calendar (9.6)
12991 @code{Calendar} provides time of day access, and routines for
12992 manipulating times and durations.
12993
12994 @item Ada.Characters (A.3.1)
12995 This is a dummy parent package that contains no useful entities
12996
12997 @item Ada.Characters.Handling (A.3.2)
12998 This package provides some basic character handling capabilities,
12999 including classification functions for classes of characters (e.g.@: test
13000 for letters, or digits).
13001
13002 @item Ada.Characters.Latin_1 (A.3.3)
13003 This package includes a complete set of definitions of the characters
13004 that appear in type CHARACTER@. It is useful for writing programs that
13005 will run in international environments. For example, if you want an
13006 upper case E with an acute accent in a string, it is often better to use
13007 the definition of @code{UC_E_Acute} in this package. Then your program
13008 will print in an understandable manner even if your environment does not
13009 support these extended characters.
13010
13011 @item Ada.Command_Line (A.15)
13012 This package provides access to the command line parameters and the name
13013 of the current program (analogous to the use of @code{argc} and @code{argv}
13014 in C), and also allows the exit status for the program to be set in a
13015 system-independent manner.
13016
13017 @item Ada.Decimal (F.2)
13018 This package provides constants describing the range of decimal numbers
13019 implemented, and also a decimal divide routine (analogous to the COBOL
13020 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13021
13022 @item Ada.Direct_IO (A.8.4)
13023 This package provides input-output using a model of a set of records of
13024 fixed-length, containing an arbitrary definite Ada type, indexed by an
13025 integer record number.
13026
13027 @item Ada.Dynamic_Priorities (D.5)
13028 This package allows the priorities of a task to be adjusted dynamically
13029 as the task is running.
13030
13031 @item Ada.Exceptions (11.4.1)
13032 This package provides additional information on exceptions, and also
13033 contains facilities for treating exceptions as data objects, and raising
13034 exceptions with associated messages.
13035
13036 @item Ada.Finalization (7.6)
13037 This package contains the declarations and subprograms to support the
13038 use of controlled types, providing for automatic initialization and
13039 finalization (analogous to the constructors and destructors of C++)
13040
13041 @item Ada.Interrupts (C.3.2)
13042 This package provides facilities for interfacing to interrupts, which
13043 includes the set of signals or conditions that can be raised and
13044 recognized as interrupts.
13045
13046 @item Ada.Interrupts.Names (C.3.2)
13047 This package provides the set of interrupt names (actually signal
13048 or condition names) that can be handled by GNAT@.
13049
13050 @item Ada.IO_Exceptions (A.13)
13051 This package defines the set of exceptions that can be raised by use of
13052 the standard IO packages.
13053
13054 @item Ada.Numerics
13055 This package contains some standard constants and exceptions used
13056 throughout the numerics packages. Note that the constants pi and e are
13057 defined here, and it is better to use these definitions than rolling
13058 your own.
13059
13060 @item Ada.Numerics.Complex_Elementary_Functions
13061 Provides the implementation of standard elementary functions (such as
13062 log and trigonometric functions) operating on complex numbers using the
13063 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13064 created by the package @code{Numerics.Complex_Types}.
13065
13066 @item Ada.Numerics.Complex_Types
13067 This is a predefined instantiation of
13068 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13069 build the type @code{Complex} and @code{Imaginary}.
13070
13071 @item Ada.Numerics.Discrete_Random
13072 This generic package provides a random number generator suitable for generating
13073 uniformly distributed values of a specified discrete subtype.
13074
13075 @item Ada.Numerics.Float_Random
13076 This package provides a random number generator suitable for generating
13077 uniformly distributed floating point values in the unit interval.
13078
13079 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13080 This is a generic version of the package that provides the
13081 implementation of standard elementary functions (such as log and
13082 trigonometric functions) for an arbitrary complex type.
13083
13084 The following predefined instantiations of this package are provided:
13085
13086 @table @code
13087 @item Short_Float
13088 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13089 @item Float
13090 @code{Ada.Numerics.Complex_Elementary_Functions}
13091 @item Long_Float
13092 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13093 @end table
13094
13095 @item Ada.Numerics.Generic_Complex_Types
13096 This is a generic package that allows the creation of complex types,
13097 with associated complex arithmetic operations.
13098
13099 The following predefined instantiations of this package exist
13100 @table @code
13101 @item Short_Float
13102 @code{Ada.Numerics.Short_Complex_Complex_Types}
13103 @item Float
13104 @code{Ada.Numerics.Complex_Complex_Types}
13105 @item Long_Float
13106 @code{Ada.Numerics.Long_Complex_Complex_Types}
13107 @end table
13108
13109 @item Ada.Numerics.Generic_Elementary_Functions
13110 This is a generic package that provides the implementation of standard
13111 elementary functions (such as log an trigonometric functions) for an
13112 arbitrary float type.
13113
13114 The following predefined instantiations of this package exist
13115
13116 @table @code
13117 @item Short_Float
13118 @code{Ada.Numerics.Short_Elementary_Functions}
13119 @item Float
13120 @code{Ada.Numerics.Elementary_Functions}
13121 @item Long_Float
13122 @code{Ada.Numerics.Long_Elementary_Functions}
13123 @end table
13124
13125 @item Ada.Real_Time (D.8)
13126 This package provides facilities similar to those of @code{Calendar}, but
13127 operating with a finer clock suitable for real time control. Note that
13128 annex D requires that there be no backward clock jumps, and GNAT generally
13129 guarantees this behavior, but of course if the external clock on which
13130 the GNAT runtime depends is deliberately reset by some external event,
13131 then such a backward jump may occur.
13132
13133 @item Ada.Sequential_IO (A.8.1)
13134 This package provides input-output facilities for sequential files,
13135 which can contain a sequence of values of a single type, which can be
13136 any Ada type, including indefinite (unconstrained) types.
13137
13138 @item Ada.Storage_IO (A.9)
13139 This package provides a facility for mapping arbitrary Ada types to and
13140 from a storage buffer. It is primarily intended for the creation of new
13141 IO packages.
13142
13143 @item Ada.Streams (13.13.1)
13144 This is a generic package that provides the basic support for the
13145 concept of streams as used by the stream attributes (@code{Input},
13146 @code{Output}, @code{Read} and @code{Write}).
13147
13148 @item Ada.Streams.Stream_IO (A.12.1)
13149 This package is a specialization of the type @code{Streams} defined in
13150 package @code{Streams} together with a set of operations providing
13151 Stream_IO capability. The Stream_IO model permits both random and
13152 sequential access to a file which can contain an arbitrary set of values
13153 of one or more Ada types.
13154
13155 @item Ada.Strings (A.4.1)
13156 This package provides some basic constants used by the string handling
13157 packages.
13158
13159 @item Ada.Strings.Bounded (A.4.4)
13160 This package provides facilities for handling variable length
13161 strings. The bounded model requires a maximum length. It is thus
13162 somewhat more limited than the unbounded model, but avoids the use of
13163 dynamic allocation or finalization.
13164
13165 @item Ada.Strings.Fixed (A.4.3)
13166 This package provides facilities for handling fixed length strings.
13167
13168 @item Ada.Strings.Maps (A.4.2)
13169 This package provides facilities for handling character mappings and
13170 arbitrarily defined subsets of characters. For instance it is useful in
13171 defining specialized translation tables.
13172
13173 @item Ada.Strings.Maps.Constants (A.4.6)
13174 This package provides a standard set of predefined mappings and
13175 predefined character sets. For example, the standard upper to lower case
13176 conversion table is found in this package. Note that upper to lower case
13177 conversion is non-trivial if you want to take the entire set of
13178 characters, including extended characters like E with an acute accent,
13179 into account. You should use the mappings in this package (rather than
13180 adding 32 yourself) to do case mappings.
13181
13182 @item Ada.Strings.Unbounded (A.4.5)
13183 This package provides facilities for handling variable length
13184 strings. The unbounded model allows arbitrary length strings, but
13185 requires the use of dynamic allocation and finalization.
13186
13187 @item Ada.Strings.Wide_Bounded (A.4.7)
13188 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13189 @itemx Ada.Strings.Wide_Maps (A.4.7)
13190 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13191 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13192 These packages provide analogous capabilities to the corresponding
13193 packages without @samp{Wide_} in the name, but operate with the types
13194 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13195 and @code{Character}.
13196
13197 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13198 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13199 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13200 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13201 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13202 These packages provide analogous capabilities to the corresponding
13203 packages without @samp{Wide_} in the name, but operate with the types
13204 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13205 of @code{String} and @code{Character}.
13206
13207 @item Ada.Synchronous_Task_Control (D.10)
13208 This package provides some standard facilities for controlling task
13209 communication in a synchronous manner.
13210
13211 @item Ada.Tags
13212 This package contains definitions for manipulation of the tags of tagged
13213 values.
13214
13215 @item Ada.Task_Attributes
13216 This package provides the capability of associating arbitrary
13217 task-specific data with separate tasks.
13218
13219 @item Ada.Text_IO
13220 This package provides basic text input-output capabilities for
13221 character, string and numeric data. The subpackages of this
13222 package are listed next.
13223
13224 @item Ada.Text_IO.Decimal_IO
13225 Provides input-output facilities for decimal fixed-point types
13226
13227 @item Ada.Text_IO.Enumeration_IO
13228 Provides input-output facilities for enumeration types.
13229
13230 @item Ada.Text_IO.Fixed_IO
13231 Provides input-output facilities for ordinary fixed-point types.
13232
13233 @item Ada.Text_IO.Float_IO
13234 Provides input-output facilities for float types. The following
13235 predefined instantiations of this generic package are available:
13236
13237 @table @code
13238 @item Short_Float
13239 @code{Short_Float_Text_IO}
13240 @item Float
13241 @code{Float_Text_IO}
13242 @item Long_Float
13243 @code{Long_Float_Text_IO}
13244 @end table
13245
13246 @item Ada.Text_IO.Integer_IO
13247 Provides input-output facilities for integer types. The following
13248 predefined instantiations of this generic package are available:
13249
13250 @table @code
13251 @item Short_Short_Integer
13252 @code{Ada.Short_Short_Integer_Text_IO}
13253 @item Short_Integer
13254 @code{Ada.Short_Integer_Text_IO}
13255 @item Integer
13256 @code{Ada.Integer_Text_IO}
13257 @item Long_Integer
13258 @code{Ada.Long_Integer_Text_IO}
13259 @item Long_Long_Integer
13260 @code{Ada.Long_Long_Integer_Text_IO}
13261 @end table
13262
13263 @item Ada.Text_IO.Modular_IO
13264 Provides input-output facilities for modular (unsigned) types
13265
13266 @item Ada.Text_IO.Complex_IO (G.1.3)
13267 This package provides basic text input-output capabilities for complex
13268 data.
13269
13270 @item Ada.Text_IO.Editing (F.3.3)
13271 This package contains routines for edited output, analogous to the use
13272 of pictures in COBOL@. The picture formats used by this package are a
13273 close copy of the facility in COBOL@.
13274
13275 @item Ada.Text_IO.Text_Streams (A.12.2)
13276 This package provides a facility that allows Text_IO files to be treated
13277 as streams, so that the stream attributes can be used for writing
13278 arbitrary data, including binary data, to Text_IO files.
13279
13280 @item Ada.Unchecked_Conversion (13.9)
13281 This generic package allows arbitrary conversion from one type to
13282 another of the same size, providing for breaking the type safety in
13283 special circumstances.
13284
13285 If the types have the same Size (more accurately the same Value_Size),
13286 then the effect is simply to transfer the bits from the source to the
13287 target type without any modification. This usage is well defined, and
13288 for simple types whose representation is typically the same across
13289 all implementations, gives a portable method of performing such
13290 conversions.
13291
13292 If the types do not have the same size, then the result is implementation
13293 defined, and thus may be non-portable. The following describes how GNAT
13294 handles such unchecked conversion cases.
13295
13296 If the types are of different sizes, and are both discrete types, then
13297 the effect is of a normal type conversion without any constraint checking.
13298 In particular if the result type has a larger size, the result will be
13299 zero or sign extended. If the result type has a smaller size, the result
13300 will be truncated by ignoring high order bits.
13301
13302 If the types are of different sizes, and are not both discrete types,
13303 then the conversion works as though pointers were created to the source
13304 and target, and the pointer value is converted. The effect is that bits
13305 are copied from successive low order storage units and bits of the source
13306 up to the length of the target type.
13307
13308 A warning is issued if the lengths differ, since the effect in this
13309 case is implementation dependent, and the above behavior may not match
13310 that of some other compiler.
13311
13312 A pointer to one type may be converted to a pointer to another type using
13313 unchecked conversion. The only case in which the effect is undefined is
13314 when one or both pointers are pointers to unconstrained array types. In
13315 this case, the bounds information may get incorrectly transferred, and in
13316 particular, GNAT uses double size pointers for such types, and it is
13317 meaningless to convert between such pointer types. GNAT will issue a
13318 warning if the alignment of the target designated type is more strict
13319 than the alignment of the source designated type (since the result may
13320 be unaligned in this case).
13321
13322 A pointer other than a pointer to an unconstrained array type may be
13323 converted to and from System.Address. Such usage is common in Ada 83
13324 programs, but note that Ada.Address_To_Access_Conversions is the
13325 preferred method of performing such conversions in Ada 95 and Ada 2005.
13326 Neither
13327 unchecked conversion nor Ada.Address_To_Access_Conversions should be
13328 used in conjunction with pointers to unconstrained objects, since
13329 the bounds information cannot be handled correctly in this case.
13330
13331 @item Ada.Unchecked_Deallocation (13.11.2)
13332 This generic package allows explicit freeing of storage previously
13333 allocated by use of an allocator.
13334
13335 @item Ada.Wide_Text_IO (A.11)
13336 This package is similar to @code{Ada.Text_IO}, except that the external
13337 file supports wide character representations, and the internal types are
13338 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13339 and @code{String}. It contains generic subpackages listed next.
13340
13341 @item Ada.Wide_Text_IO.Decimal_IO
13342 Provides input-output facilities for decimal fixed-point types
13343
13344 @item Ada.Wide_Text_IO.Enumeration_IO
13345 Provides input-output facilities for enumeration types.
13346
13347 @item Ada.Wide_Text_IO.Fixed_IO
13348 Provides input-output facilities for ordinary fixed-point types.
13349
13350 @item Ada.Wide_Text_IO.Float_IO
13351 Provides input-output facilities for float types. The following
13352 predefined instantiations of this generic package are available:
13353
13354 @table @code
13355 @item Short_Float
13356 @code{Short_Float_Wide_Text_IO}
13357 @item Float
13358 @code{Float_Wide_Text_IO}
13359 @item Long_Float
13360 @code{Long_Float_Wide_Text_IO}
13361 @end table
13362
13363 @item Ada.Wide_Text_IO.Integer_IO
13364 Provides input-output facilities for integer types. The following
13365 predefined instantiations of this generic package are available:
13366
13367 @table @code
13368 @item Short_Short_Integer
13369 @code{Ada.Short_Short_Integer_Wide_Text_IO}
13370 @item Short_Integer
13371 @code{Ada.Short_Integer_Wide_Text_IO}
13372 @item Integer
13373 @code{Ada.Integer_Wide_Text_IO}
13374 @item Long_Integer
13375 @code{Ada.Long_Integer_Wide_Text_IO}
13376 @item Long_Long_Integer
13377 @code{Ada.Long_Long_Integer_Wide_Text_IO}
13378 @end table
13379
13380 @item Ada.Wide_Text_IO.Modular_IO
13381 Provides input-output facilities for modular (unsigned) types
13382
13383 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
13384 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13385 external file supports wide character representations.
13386
13387 @item Ada.Wide_Text_IO.Editing (F.3.4)
13388 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13389 types are @code{Wide_Character} and @code{Wide_String} instead of
13390 @code{Character} and @code{String}.
13391
13392 @item Ada.Wide_Text_IO.Streams (A.12.3)
13393 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13394 types are @code{Wide_Character} and @code{Wide_String} instead of
13395 @code{Character} and @code{String}.
13396
13397 @item Ada.Wide_Wide_Text_IO (A.11)
13398 This package is similar to @code{Ada.Text_IO}, except that the external
13399 file supports wide character representations, and the internal types are
13400 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
13401 and @code{String}. It contains generic subpackages listed next.
13402
13403 @item Ada.Wide_Wide_Text_IO.Decimal_IO
13404 Provides input-output facilities for decimal fixed-point types
13405
13406 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
13407 Provides input-output facilities for enumeration types.
13408
13409 @item Ada.Wide_Wide_Text_IO.Fixed_IO
13410 Provides input-output facilities for ordinary fixed-point types.
13411
13412 @item Ada.Wide_Wide_Text_IO.Float_IO
13413 Provides input-output facilities for float types. The following
13414 predefined instantiations of this generic package are available:
13415
13416 @table @code
13417 @item Short_Float
13418 @code{Short_Float_Wide_Wide_Text_IO}
13419 @item Float
13420 @code{Float_Wide_Wide_Text_IO}
13421 @item Long_Float
13422 @code{Long_Float_Wide_Wide_Text_IO}
13423 @end table
13424
13425 @item Ada.Wide_Wide_Text_IO.Integer_IO
13426 Provides input-output facilities for integer types. The following
13427 predefined instantiations of this generic package are available:
13428
13429 @table @code
13430 @item Short_Short_Integer
13431 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
13432 @item Short_Integer
13433 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
13434 @item Integer
13435 @code{Ada.Integer_Wide_Wide_Text_IO}
13436 @item Long_Integer
13437 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
13438 @item Long_Long_Integer
13439 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
13440 @end table
13441
13442 @item Ada.Wide_Wide_Text_IO.Modular_IO
13443 Provides input-output facilities for modular (unsigned) types
13444
13445 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
13446 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
13447 external file supports wide character representations.
13448
13449 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
13450 This package is similar to @code{Ada.Text_IO.Editing}, except that the
13451 types are @code{Wide_Character} and @code{Wide_String} instead of
13452 @code{Character} and @code{String}.
13453
13454 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
13455 This package is similar to @code{Ada.Text_IO.Streams}, except that the
13456 types are @code{Wide_Character} and @code{Wide_String} instead of
13457 @code{Character} and @code{String}.
13458 @end table
13459
13460 @node The Implementation of Standard I/O
13461 @chapter The Implementation of Standard I/O
13462
13463 @noindent
13464 GNAT implements all the required input-output facilities described in
13465 A.6 through A.14. These sections of the Ada Reference Manual describe the
13466 required behavior of these packages from the Ada point of view, and if
13467 you are writing a portable Ada program that does not need to know the
13468 exact manner in which Ada maps to the outside world when it comes to
13469 reading or writing external files, then you do not need to read this
13470 chapter. As long as your files are all regular files (not pipes or
13471 devices), and as long as you write and read the files only from Ada, the
13472 description in the Ada Reference Manual is sufficient.
13473
13474 However, if you want to do input-output to pipes or other devices, such
13475 as the keyboard or screen, or if the files you are dealing with are
13476 either generated by some other language, or to be read by some other
13477 language, then you need to know more about the details of how the GNAT
13478 implementation of these input-output facilities behaves.
13479
13480 In this chapter we give a detailed description of exactly how GNAT
13481 interfaces to the file system. As always, the sources of the system are
13482 available to you for answering questions at an even more detailed level,
13483 but for most purposes the information in this chapter will suffice.
13484
13485 Another reason that you may need to know more about how input-output is
13486 implemented arises when you have a program written in mixed languages
13487 where, for example, files are shared between the C and Ada sections of
13488 the same program. GNAT provides some additional facilities, in the form
13489 of additional child library packages, that facilitate this sharing, and
13490 these additional facilities are also described in this chapter.
13491
13492 @menu
13493 * Standard I/O Packages::
13494 * FORM Strings::
13495 * Direct_IO::
13496 * Sequential_IO::
13497 * Text_IO::
13498 * Wide_Text_IO::
13499 * Wide_Wide_Text_IO::
13500 * Stream_IO::
13501 * Text Translation::
13502 * Shared Files::
13503 * Filenames encoding::
13504 * Open Modes::
13505 * Operations on C Streams::
13506 * Interfacing to C Streams::
13507 @end menu
13508
13509 @node Standard I/O Packages
13510 @section Standard I/O Packages
13511
13512 @noindent
13513 The Standard I/O packages described in Annex A for
13514
13515 @itemize @bullet
13516 @item
13517 Ada.Text_IO
13518 @item
13519 Ada.Text_IO.Complex_IO
13520 @item
13521 Ada.Text_IO.Text_Streams
13522 @item
13523 Ada.Wide_Text_IO
13524 @item
13525 Ada.Wide_Text_IO.Complex_IO
13526 @item
13527 Ada.Wide_Text_IO.Text_Streams
13528 @item
13529 Ada.Wide_Wide_Text_IO
13530 @item
13531 Ada.Wide_Wide_Text_IO.Complex_IO
13532 @item
13533 Ada.Wide_Wide_Text_IO.Text_Streams
13534 @item
13535 Ada.Stream_IO
13536 @item
13537 Ada.Sequential_IO
13538 @item
13539 Ada.Direct_IO
13540 @end itemize
13541
13542 @noindent
13543 are implemented using the C
13544 library streams facility; where
13545
13546 @itemize @bullet
13547 @item
13548 All files are opened using @code{fopen}.
13549 @item
13550 All input/output operations use @code{fread}/@code{fwrite}.
13551 @end itemize
13552
13553 @noindent
13554 There is no internal buffering of any kind at the Ada library level. The only
13555 buffering is that provided at the system level in the implementation of the
13556 library routines that support streams. This facilitates shared use of these
13557 streams by mixed language programs. Note though that system level buffering is
13558 explicitly enabled at elaboration of the standard I/O packages and that can
13559 have an impact on mixed language programs, in particular those using I/O before
13560 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
13561 the Ada elaboration routine before performing any I/O or when impractical,
13562 flush the common I/O streams and in particular Standard_Output before
13563 elaborating the Ada code.
13564
13565 @node FORM Strings
13566 @section FORM Strings
13567
13568 @noindent
13569 The format of a FORM string in GNAT is:
13570
13571 @smallexample
13572 "keyword=value,keyword=value,@dots{},keyword=value"
13573 @end smallexample
13574
13575 @noindent
13576 where letters may be in upper or lower case, and there are no spaces
13577 between values. The order of the entries is not important. Currently
13578 the following keywords defined.
13579
13580 @smallexample
13581 TEXT_TRANSLATION=[YES|NO]
13582 SHARED=[YES|NO]
13583 WCEM=[n|h|u|s|e|8|b]
13584 ENCODING=[UTF8|8BITS]
13585 @end smallexample
13586
13587 @noindent
13588 The use of these parameters is described later in this section.
13589
13590 @node Direct_IO
13591 @section Direct_IO
13592
13593 @noindent
13594 Direct_IO can only be instantiated for definite types. This is a
13595 restriction of the Ada language, which means that the records are fixed
13596 length (the length being determined by @code{@var{type}'Size}, rounded
13597 up to the next storage unit boundary if necessary).
13598
13599 The records of a Direct_IO file are simply written to the file in index
13600 sequence, with the first record starting at offset zero, and subsequent
13601 records following. There is no control information of any kind. For
13602 example, if 32-bit integers are being written, each record takes
13603 4-bytes, so the record at index @var{K} starts at offset
13604 (@var{K}@minus{}1)*4.
13605
13606 There is no limit on the size of Direct_IO files, they are expanded as
13607 necessary to accommodate whatever records are written to the file.
13608
13609 @node Sequential_IO
13610 @section Sequential_IO
13611
13612 @noindent
13613 Sequential_IO may be instantiated with either a definite (constrained)
13614 or indefinite (unconstrained) type.
13615
13616 For the definite type case, the elements written to the file are simply
13617 the memory images of the data values with no control information of any
13618 kind. The resulting file should be read using the same type, no validity
13619 checking is performed on input.
13620
13621 For the indefinite type case, the elements written consist of two
13622 parts. First is the size of the data item, written as the memory image
13623 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13624 the data value. The resulting file can only be read using the same
13625 (unconstrained) type. Normal assignment checks are performed on these
13626 read operations, and if these checks fail, @code{Data_Error} is
13627 raised. In particular, in the array case, the lengths must match, and in
13628 the variant record case, if the variable for a particular read operation
13629 is constrained, the discriminants must match.
13630
13631 Note that it is not possible to use Sequential_IO to write variable
13632 length array items, and then read the data back into different length
13633 arrays. For example, the following will raise @code{Data_Error}:
13634
13635 @smallexample @c ada
13636 package IO is new Sequential_IO (String);
13637 F : IO.File_Type;
13638 S : String (1..4);
13639 @dots{}
13640 IO.Create (F)
13641 IO.Write (F, "hello!")
13642 IO.Reset (F, Mode=>In_File);
13643 IO.Read (F, S);
13644 Put_Line (S);
13645
13646 @end smallexample
13647
13648 @noindent
13649 On some Ada implementations, this will print @code{hell}, but the program is
13650 clearly incorrect, since there is only one element in the file, and that
13651 element is the string @code{hello!}.
13652
13653 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13654 using Stream_IO, and this is the preferred mechanism. In particular, the
13655 above program fragment rewritten to use Stream_IO will work correctly.
13656
13657 @node Text_IO
13658 @section Text_IO
13659
13660 @noindent
13661 Text_IO files consist of a stream of characters containing the following
13662 special control characters:
13663
13664 @smallexample
13665 LF (line feed, 16#0A#) Line Mark
13666 FF (form feed, 16#0C#) Page Mark
13667 @end smallexample
13668
13669 @noindent
13670 A canonical Text_IO file is defined as one in which the following
13671 conditions are met:
13672
13673 @itemize @bullet
13674 @item
13675 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13676 of the line.
13677
13678 @item
13679 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13680 end of a page and consequently can appear only immediately following a
13681 @code{LF} (line mark) character.
13682
13683 @item
13684 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13685 (line mark, page mark). In the former case, the page mark is implicitly
13686 assumed to be present.
13687 @end itemize
13688
13689 @noindent
13690 A file written using Text_IO will be in canonical form provided that no
13691 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13692 or @code{Put_Line}. There will be no @code{FF} character at the end of
13693 the file unless an explicit @code{New_Page} operation was performed
13694 before closing the file.
13695
13696 A canonical Text_IO file that is a regular file (i.e., not a device or a
13697 pipe) can be read using any of the routines in Text_IO@. The
13698 semantics in this case will be exactly as defined in the Ada Reference
13699 Manual, and all the routines in Text_IO are fully implemented.
13700
13701 A text file that does not meet the requirements for a canonical Text_IO
13702 file has one of the following:
13703
13704 @itemize @bullet
13705 @item
13706 The file contains @code{FF} characters not immediately following a
13707 @code{LF} character.
13708
13709 @item
13710 The file contains @code{LF} or @code{FF} characters written by
13711 @code{Put} or @code{Put_Line}, which are not logically considered to be
13712 line marks or page marks.
13713
13714 @item
13715 The file ends in a character other than @code{LF} or @code{FF},
13716 i.e.@: there is no explicit line mark or page mark at the end of the file.
13717 @end itemize
13718
13719 @noindent
13720 Text_IO can be used to read such non-standard text files but subprograms
13721 to do with line or page numbers do not have defined meanings. In
13722 particular, a @code{FF} character that does not follow a @code{LF}
13723 character may or may not be treated as a page mark from the point of
13724 view of page and line numbering. Every @code{LF} character is considered
13725 to end a line, and there is an implied @code{LF} character at the end of
13726 the file.
13727
13728 @menu
13729 * Text_IO Stream Pointer Positioning::
13730 * Text_IO Reading and Writing Non-Regular Files::
13731 * Get_Immediate::
13732 * Treating Text_IO Files as Streams::
13733 * Text_IO Extensions::
13734 * Text_IO Facilities for Unbounded Strings::
13735 @end menu
13736
13737 @node Text_IO Stream Pointer Positioning
13738 @subsection Stream Pointer Positioning
13739
13740 @noindent
13741 @code{Ada.Text_IO} has a definition of current position for a file that
13742 is being read. No internal buffering occurs in Text_IO, and usually the
13743 physical position in the stream used to implement the file corresponds
13744 to this logical position defined by Text_IO@. There are two exceptions:
13745
13746 @itemize @bullet
13747 @item
13748 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13749 is positioned past the @code{LF} (line mark) that precedes the page
13750 mark. Text_IO maintains an internal flag so that subsequent read
13751 operations properly handle the logical position which is unchanged by
13752 the @code{End_Of_Page} call.
13753
13754 @item
13755 After a call to @code{End_Of_File} that returns @code{True}, if the
13756 Text_IO file was positioned before the line mark at the end of file
13757 before the call, then the logical position is unchanged, but the stream
13758 is physically positioned right at the end of file (past the line mark,
13759 and past a possible page mark following the line mark. Again Text_IO
13760 maintains internal flags so that subsequent read operations properly
13761 handle the logical position.
13762 @end itemize
13763
13764 @noindent
13765 These discrepancies have no effect on the observable behavior of
13766 Text_IO, but if a single Ada stream is shared between a C program and
13767 Ada program, or shared (using @samp{shared=yes} in the form string)
13768 between two Ada files, then the difference may be observable in some
13769 situations.
13770
13771 @node Text_IO Reading and Writing Non-Regular Files
13772 @subsection Reading and Writing Non-Regular Files
13773
13774 @noindent
13775 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
13776 can be used for reading and writing. Writing is not affected and the
13777 sequence of characters output is identical to the normal file case, but
13778 for reading, the behavior of Text_IO is modified to avoid undesirable
13779 look-ahead as follows:
13780
13781 An input file that is not a regular file is considered to have no page
13782 marks. Any @code{Ascii.FF} characters (the character normally used for a
13783 page mark) appearing in the file are considered to be data
13784 characters. In particular:
13785
13786 @itemize @bullet
13787 @item
13788 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13789 following a line mark. If a page mark appears, it will be treated as a
13790 data character.
13791
13792 @item
13793 This avoids the need to wait for an extra character to be typed or
13794 entered from the pipe to complete one of these operations.
13795
13796 @item
13797 @code{End_Of_Page} always returns @code{False}
13798
13799 @item
13800 @code{End_Of_File} will return @code{False} if there is a page mark at
13801 the end of the file.
13802 @end itemize
13803
13804 @noindent
13805 Output to non-regular files is the same as for regular files. Page marks
13806 may be written to non-regular files using @code{New_Page}, but as noted
13807 above they will not be treated as page marks on input if the output is
13808 piped to another Ada program.
13809
13810 Another important discrepancy when reading non-regular files is that the end
13811 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
13812 pressing the @key{EOT} key,
13813 then end of file
13814 is signaled once (i.e.@: the test @code{End_Of_File}
13815 will yield @code{True}, or a read will
13816 raise @code{End_Error}), but then reading can resume
13817 to read data past that end of
13818 file indication, until another end of file indication is entered.
13819
13820 @node Get_Immediate
13821 @subsection Get_Immediate
13822 @cindex Get_Immediate
13823
13824 @noindent
13825 Get_Immediate returns the next character (including control characters)
13826 from the input file. In particular, Get_Immediate will return LF or FF
13827 characters used as line marks or page marks. Such operations leave the
13828 file positioned past the control character, and it is thus not treated
13829 as having its normal function. This means that page, line and column
13830 counts after this kind of Get_Immediate call are set as though the mark
13831 did not occur. In the case where a Get_Immediate leaves the file
13832 positioned between the line mark and page mark (which is not normally
13833 possible), it is undefined whether the FF character will be treated as a
13834 page mark.
13835
13836 @node Treating Text_IO Files as Streams
13837 @subsection Treating Text_IO Files as Streams
13838 @cindex Stream files
13839
13840 @noindent
13841 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13842 as a stream. Data written to a Text_IO file in this stream mode is
13843 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
13844 16#0C# (@code{FF}), the resulting file may have non-standard
13845 format. Similarly if read operations are used to read from a Text_IO
13846 file treated as a stream, then @code{LF} and @code{FF} characters may be
13847 skipped and the effect is similar to that described above for
13848 @code{Get_Immediate}.
13849
13850 @node Text_IO Extensions
13851 @subsection Text_IO Extensions
13852 @cindex Text_IO extensions
13853
13854 @noindent
13855 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13856 to the standard @code{Text_IO} package:
13857
13858 @itemize @bullet
13859 @item function File_Exists (Name : String) return Boolean;
13860 Determines if a file of the given name exists.
13861
13862 @item function Get_Line return String;
13863 Reads a string from the standard input file. The value returned is exactly
13864 the length of the line that was read.
13865
13866 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13867 Similar, except that the parameter File specifies the file from which
13868 the string is to be read.
13869
13870 @end itemize
13871
13872 @node Text_IO Facilities for Unbounded Strings
13873 @subsection Text_IO Facilities for Unbounded Strings
13874 @cindex Text_IO for unbounded strings
13875 @cindex Unbounded_String, Text_IO operations
13876
13877 @noindent
13878 The package @code{Ada.Strings.Unbounded.Text_IO}
13879 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13880 subprograms useful for Text_IO operations on unbounded strings:
13881
13882 @itemize @bullet
13883
13884 @item function Get_Line (File : File_Type) return Unbounded_String;
13885 Reads a line from the specified file
13886 and returns the result as an unbounded string.
13887
13888 @item procedure Put (File : File_Type; U : Unbounded_String);
13889 Writes the value of the given unbounded string to the specified file
13890 Similar to the effect of
13891 @code{Put (To_String (U))} except that an extra copy is avoided.
13892
13893 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13894 Writes the value of the given unbounded string to the specified file,
13895 followed by a @code{New_Line}.
13896 Similar to the effect of @code{Put_Line (To_String (U))} except
13897 that an extra copy is avoided.
13898 @end itemize
13899
13900 @noindent
13901 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13902 and is optional. If the parameter is omitted, then the standard input or
13903 output file is referenced as appropriate.
13904
13905 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13906 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13907 @code{Wide_Text_IO} functionality for unbounded wide strings.
13908
13909 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13910 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13911 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13912
13913 @node Wide_Text_IO
13914 @section Wide_Text_IO
13915
13916 @noindent
13917 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13918 both input and output files may contain special sequences that represent
13919 wide character values. The encoding scheme for a given file may be
13920 specified using a FORM parameter:
13921
13922 @smallexample
13923 WCEM=@var{x}
13924 @end smallexample
13925
13926 @noindent
13927 as part of the FORM string (WCEM = wide character encoding method),
13928 where @var{x} is one of the following characters
13929
13930 @table @samp
13931 @item h
13932 Hex ESC encoding
13933 @item u
13934 Upper half encoding
13935 @item s
13936 Shift-JIS encoding
13937 @item e
13938 EUC Encoding
13939 @item 8
13940 UTF-8 encoding
13941 @item b
13942 Brackets encoding
13943 @end table
13944
13945 @noindent
13946 The encoding methods match those that
13947 can be used in a source
13948 program, but there is no requirement that the encoding method used for
13949 the source program be the same as the encoding method used for files,
13950 and different files may use different encoding methods.
13951
13952 The default encoding method for the standard files, and for opened files
13953 for which no WCEM parameter is given in the FORM string matches the
13954 wide character encoding specified for the main program (the default
13955 being brackets encoding if no coding method was specified with -gnatW).
13956
13957 @table @asis
13958 @item Hex Coding
13959 In this encoding, a wide character is represented by a five character
13960 sequence:
13961
13962 @smallexample
13963 ESC a b c d
13964 @end smallexample
13965
13966 @noindent
13967 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13968 characters (using upper case letters) of the wide character code. For
13969 example, ESC A345 is used to represent the wide character with code
13970 16#A345#. This scheme is compatible with use of the full
13971 @code{Wide_Character} set.
13972
13973 @item Upper Half Coding
13974 The wide character with encoding 16#abcd#, where the upper bit is on
13975 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13976 16#cd#. The second byte may never be a format control character, but is
13977 not required to be in the upper half. This method can be also used for
13978 shift-JIS or EUC where the internal coding matches the external coding.
13979
13980 @item Shift JIS Coding
13981 A wide character is represented by a two character sequence 16#ab# and
13982 16#cd#, with the restrictions described for upper half encoding as
13983 described above. The internal character code is the corresponding JIS
13984 character according to the standard algorithm for Shift-JIS
13985 conversion. Only characters defined in the JIS code set table can be
13986 used with this encoding method.
13987
13988 @item EUC Coding
13989 A wide character is represented by a two character sequence 16#ab# and
13990 16#cd#, with both characters being in the upper half. The internal
13991 character code is the corresponding JIS character according to the EUC
13992 encoding algorithm. Only characters defined in the JIS code set table
13993 can be used with this encoding method.
13994
13995 @item UTF-8 Coding
13996 A wide character is represented using
13997 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13998 10646-1/Am.2. Depending on the character value, the representation
13999 is a one, two, or three byte sequence:
14000
14001 @smallexample
14002 16#0000#-16#007f#: 2#0xxxxxxx#
14003 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14004 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14005 @end smallexample
14006
14007 @noindent
14008 where the @var{xxx} bits correspond to the left-padded bits of the
14009 16-bit character value. Note that all lower half ASCII characters
14010 are represented as ASCII bytes and all upper half characters and
14011 other wide characters are represented as sequences of upper-half
14012 (The full UTF-8 scheme allows for encoding 31-bit characters as
14013 6-byte sequences, but in this implementation, all UTF-8 sequences
14014 of four or more bytes length will raise a Constraint_Error, as
14015 will all invalid UTF-8 sequences.)
14016
14017 @item Brackets Coding
14018 In this encoding, a wide character is represented by the following eight
14019 character sequence:
14020
14021 @smallexample
14022 [ " a b c d " ]
14023 @end smallexample
14024
14025 @noindent
14026 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14027 characters (using uppercase letters) of the wide character code. For
14028 example, @code{["A345"]} is used to represent the wide character with code
14029 @code{16#A345#}.
14030 This scheme is compatible with use of the full Wide_Character set.
14031 On input, brackets coding can also be used for upper half characters,
14032 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14033 is only used for wide characters with a code greater than @code{16#FF#}.
14034
14035 Note that brackets coding is not normally used in the context of
14036 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14037 a portable way of encoding source files. In the context of Wide_Text_IO
14038 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14039 any instance of the left bracket character other than to encode wide
14040 character values using the brackets encoding method. In practice it is
14041 expected that some standard wide character encoding method such
14042 as UTF-8 will be used for text input output.
14043
14044 If brackets notation is used, then any occurrence of a left bracket
14045 in the input file which is not the start of a valid wide character
14046 sequence will cause Constraint_Error to be raised. It is possible to
14047 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14048 input will interpret this as a left bracket.
14049
14050 However, when a left bracket is output, it will be output as a left bracket
14051 and not as ["5B"]. We make this decision because for normal use of
14052 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14053 brackets. For example, if we write:
14054
14055 @smallexample
14056 Put_Line ("Start of output [first run]");
14057 @end smallexample
14058
14059 @noindent
14060 we really do not want to have the left bracket in this message clobbered so
14061 that the output reads:
14062
14063 @smallexample
14064 Start of output ["5B"]first run]
14065 @end smallexample
14066
14067 @noindent
14068 In practice brackets encoding is reasonably useful for normal Put_Line use
14069 since we won't get confused between left brackets and wide character
14070 sequences in the output. But for input, or when files are written out
14071 and read back in, it really makes better sense to use one of the standard
14072 encoding methods such as UTF-8.
14073
14074 @end table
14075
14076 @noindent
14077 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14078 not all wide character
14079 values can be represented. An attempt to output a character that cannot
14080 be represented using the encoding scheme for the file causes
14081 Constraint_Error to be raised. An invalid wide character sequence on
14082 input also causes Constraint_Error to be raised.
14083
14084 @menu
14085 * Wide_Text_IO Stream Pointer Positioning::
14086 * Wide_Text_IO Reading and Writing Non-Regular Files::
14087 @end menu
14088
14089 @node Wide_Text_IO Stream Pointer Positioning
14090 @subsection Stream Pointer Positioning
14091
14092 @noindent
14093 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14094 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14095 case:
14096
14097 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14098 normal lower ASCII set (i.e.@: a character in the range:
14099
14100 @smallexample @c ada
14101 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14102 @end smallexample
14103
14104 @noindent
14105 then although the logical position of the file pointer is unchanged by
14106 the @code{Look_Ahead} call, the stream is physically positioned past the
14107 wide character sequence. Again this is to avoid the need for buffering
14108 or backup, and all @code{Wide_Text_IO} routines check the internal
14109 indication that this situation has occurred so that this is not visible
14110 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14111 can be observed if the wide text file shares a stream with another file.
14112
14113 @node Wide_Text_IO Reading and Writing Non-Regular Files
14114 @subsection Reading and Writing Non-Regular Files
14115
14116 @noindent
14117 As in the case of Text_IO, when a non-regular file is read, it is
14118 assumed that the file contains no page marks (any form characters are
14119 treated as data characters), and @code{End_Of_Page} always returns
14120 @code{False}. Similarly, the end of file indication is not sticky, so
14121 it is possible to read beyond an end of file.
14122
14123 @node Wide_Wide_Text_IO
14124 @section Wide_Wide_Text_IO
14125
14126 @noindent
14127 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14128 both input and output files may contain special sequences that represent
14129 wide wide character values. The encoding scheme for a given file may be
14130 specified using a FORM parameter:
14131
14132 @smallexample
14133 WCEM=@var{x}
14134 @end smallexample
14135
14136 @noindent
14137 as part of the FORM string (WCEM = wide character encoding method),
14138 where @var{x} is one of the following characters
14139
14140 @table @samp
14141 @item h
14142 Hex ESC encoding
14143 @item u
14144 Upper half encoding
14145 @item s
14146 Shift-JIS encoding
14147 @item e
14148 EUC Encoding
14149 @item 8
14150 UTF-8 encoding
14151 @item b
14152 Brackets encoding
14153 @end table
14154
14155 @noindent
14156 The encoding methods match those that
14157 can be used in a source
14158 program, but there is no requirement that the encoding method used for
14159 the source program be the same as the encoding method used for files,
14160 and different files may use different encoding methods.
14161
14162 The default encoding method for the standard files, and for opened files
14163 for which no WCEM parameter is given in the FORM string matches the
14164 wide character encoding specified for the main program (the default
14165 being brackets encoding if no coding method was specified with -gnatW).
14166
14167 @table @asis
14168
14169 @item UTF-8 Coding
14170 A wide character is represented using
14171 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14172 10646-1/Am.2. Depending on the character value, the representation
14173 is a one, two, three, or four byte sequence:
14174
14175 @smallexample
14176 16#000000#-16#00007f#: 2#0xxxxxxx#
14177 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14178 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14179 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14180 @end smallexample
14181
14182 @noindent
14183 where the @var{xxx} bits correspond to the left-padded bits of the
14184 21-bit character value. Note that all lower half ASCII characters
14185 are represented as ASCII bytes and all upper half characters and
14186 other wide characters are represented as sequences of upper-half
14187 characters.
14188
14189 @item Brackets Coding
14190 In this encoding, a wide wide character is represented by the following eight
14191 character sequence if is in wide character range
14192
14193 @smallexample
14194 [ " a b c d " ]
14195 @end smallexample
14196
14197 and by the following ten character sequence if not
14198
14199 @smallexample
14200 [ " a b c d e f " ]
14201 @end smallexample
14202
14203 @noindent
14204 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14205 are the four or six hexadecimal
14206 characters (using uppercase letters) of the wide wide character code. For
14207 example, @code{["01A345"]} is used to represent the wide wide character
14208 with code @code{16#01A345#}.
14209
14210 This scheme is compatible with use of the full Wide_Wide_Character set.
14211 On input, brackets coding can also be used for upper half characters,
14212 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14213 is only used for wide characters with a code greater than @code{16#FF#}.
14214
14215 @end table
14216
14217 @noindent
14218 If is also possible to use the other Wide_Character encoding methods,
14219 such as Shift-JIS, but the other schemes cannot support the full range
14220 of wide wide characters.
14221 An attempt to output a character that cannot
14222 be represented using the encoding scheme for the file causes
14223 Constraint_Error to be raised. An invalid wide character sequence on
14224 input also causes Constraint_Error to be raised.
14225
14226 @menu
14227 * Wide_Wide_Text_IO Stream Pointer Positioning::
14228 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14229 @end menu
14230
14231 @node Wide_Wide_Text_IO Stream Pointer Positioning
14232 @subsection Stream Pointer Positioning
14233
14234 @noindent
14235 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14236 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14237 case:
14238
14239 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14240 normal lower ASCII set (i.e.@: a character in the range:
14241
14242 @smallexample @c ada
14243 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14244 @end smallexample
14245
14246 @noindent
14247 then although the logical position of the file pointer is unchanged by
14248 the @code{Look_Ahead} call, the stream is physically positioned past the
14249 wide character sequence. Again this is to avoid the need for buffering
14250 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14251 indication that this situation has occurred so that this is not visible
14252 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14253 can be observed if the wide text file shares a stream with another file.
14254
14255 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14256 @subsection Reading and Writing Non-Regular Files
14257
14258 @noindent
14259 As in the case of Text_IO, when a non-regular file is read, it is
14260 assumed that the file contains no page marks (any form characters are
14261 treated as data characters), and @code{End_Of_Page} always returns
14262 @code{False}. Similarly, the end of file indication is not sticky, so
14263 it is possible to read beyond an end of file.
14264
14265 @node Stream_IO
14266 @section Stream_IO
14267
14268 @noindent
14269 A stream file is a sequence of bytes, where individual elements are
14270 written to the file as described in the Ada Reference Manual. The type
14271 @code{Stream_Element} is simply a byte. There are two ways to read or
14272 write a stream file.
14273
14274 @itemize @bullet
14275 @item
14276 The operations @code{Read} and @code{Write} directly read or write a
14277 sequence of stream elements with no control information.
14278
14279 @item
14280 The stream attributes applied to a stream file transfer data in the
14281 manner described for stream attributes.
14282 @end itemize
14283
14284 @node Text Translation
14285 @section Text Translation
14286
14287 @noindent
14288 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14289 passed to Text_IO.Create and Text_IO.Open:
14290 @samp{Text_Translation=@var{Yes}} is the default, which means to
14291 translate LF to/from CR/LF on Windows systems.
14292 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
14293 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
14294 may be used to create Unix-style files on
14295 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
14296 systems.
14297
14298 @node Shared Files
14299 @section Shared Files
14300
14301 @noindent
14302 Section A.14 of the Ada Reference Manual allows implementations to
14303 provide a wide variety of behavior if an attempt is made to access the
14304 same external file with two or more internal files.
14305
14306 To provide a full range of functionality, while at the same time
14307 minimizing the problems of portability caused by this implementation
14308 dependence, GNAT handles file sharing as follows:
14309
14310 @itemize @bullet
14311 @item
14312 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
14313 to open two or more files with the same full name is considered an error
14314 and is not supported. The exception @code{Use_Error} will be
14315 raised. Note that a file that is not explicitly closed by the program
14316 remains open until the program terminates.
14317
14318 @item
14319 If the form parameter @samp{shared=no} appears in the form string, the
14320 file can be opened or created with its own separate stream identifier,
14321 regardless of whether other files sharing the same external file are
14322 opened. The exact effect depends on how the C stream routines handle
14323 multiple accesses to the same external files using separate streams.
14324
14325 @item
14326 If the form parameter @samp{shared=yes} appears in the form string for
14327 each of two or more files opened using the same full name, the same
14328 stream is shared between these files, and the semantics are as described
14329 in Ada Reference Manual, Section A.14.
14330 @end itemize
14331
14332 @noindent
14333 When a program that opens multiple files with the same name is ported
14334 from another Ada compiler to GNAT, the effect will be that
14335 @code{Use_Error} is raised.
14336
14337 The documentation of the original compiler and the documentation of the
14338 program should then be examined to determine if file sharing was
14339 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
14340 and @code{Create} calls as required.
14341
14342 When a program is ported from GNAT to some other Ada compiler, no
14343 special attention is required unless the @samp{shared=@var{xxx}} form
14344 parameter is used in the program. In this case, you must examine the
14345 documentation of the new compiler to see if it supports the required
14346 file sharing semantics, and form strings modified appropriately. Of
14347 course it may be the case that the program cannot be ported if the
14348 target compiler does not support the required functionality. The best
14349 approach in writing portable code is to avoid file sharing (and hence
14350 the use of the @samp{shared=@var{xxx}} parameter in the form string)
14351 completely.
14352
14353 One common use of file sharing in Ada 83 is the use of instantiations of
14354 Sequential_IO on the same file with different types, to achieve
14355 heterogeneous input-output. Although this approach will work in GNAT if
14356 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
14357 for this purpose (using the stream attributes)
14358
14359 @node Filenames encoding
14360 @section Filenames encoding
14361
14362 @noindent
14363 An encoding form parameter can be used to specify the filename
14364 encoding @samp{encoding=@var{xxx}}.
14365
14366 @itemize @bullet
14367 @item
14368 If the form parameter @samp{encoding=utf8} appears in the form string, the
14369 filename must be encoded in UTF-8.
14370
14371 @item
14372 If the form parameter @samp{encoding=8bits} appears in the form
14373 string, the filename must be a standard 8bits string.
14374 @end itemize
14375
14376 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
14377 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
14378 variable. And if not set @samp{utf8} is assumed.
14379
14380 @table @samp
14381 @item CP_ACP
14382 The current system Windows ANSI code page.
14383 @item CP_UTF8
14384 UTF-8 encoding
14385 @end table
14386
14387 This encoding form parameter is only supported on the Windows
14388 platform. On the other Operating Systems the run-time is supporting
14389 UTF-8 natively.
14390
14391 @node Open Modes
14392 @section Open Modes
14393
14394 @noindent
14395 @code{Open} and @code{Create} calls result in a call to @code{fopen}
14396 using the mode shown in the following table:
14397
14398 @sp 2
14399 @center @code{Open} and @code{Create} Call Modes
14400 @smallexample
14401 @b{OPEN } @b{CREATE}
14402 Append_File "r+" "w+"
14403 In_File "r" "w+"
14404 Out_File (Direct_IO) "r+" "w"
14405 Out_File (all other cases) "w" "w"
14406 Inout_File "r+" "w+"
14407 @end smallexample
14408
14409 @noindent
14410 If text file translation is required, then either @samp{b} or @samp{t}
14411 is added to the mode, depending on the setting of Text. Text file
14412 translation refers to the mapping of CR/LF sequences in an external file
14413 to LF characters internally. This mapping only occurs in DOS and
14414 DOS-like systems, and is not relevant to other systems.
14415
14416 A special case occurs with Stream_IO@. As shown in the above table, the
14417 file is initially opened in @samp{r} or @samp{w} mode for the
14418 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
14419 subsequently requires switching from reading to writing or vice-versa,
14420 then the file is reopened in @samp{r+} mode to permit the required operation.
14421
14422 @node Operations on C Streams
14423 @section Operations on C Streams
14424 The package @code{Interfaces.C_Streams} provides an Ada program with direct
14425 access to the C library functions for operations on C streams:
14426
14427 @smallexample @c adanocomment
14428 package Interfaces.C_Streams is
14429 -- Note: the reason we do not use the types that are in
14430 -- Interfaces.C is that we want to avoid dragging in the
14431 -- code in this unit if possible.
14432 subtype chars is System.Address;
14433 -- Pointer to null-terminated array of characters
14434 subtype FILEs is System.Address;
14435 -- Corresponds to the C type FILE*
14436 subtype voids is System.Address;
14437 -- Corresponds to the C type void*
14438 subtype int is Integer;
14439 subtype long is Long_Integer;
14440 -- Note: the above types are subtypes deliberately, and it
14441 -- is part of this spec that the above correspondences are
14442 -- guaranteed. This means that it is legitimate to, for
14443 -- example, use Integer instead of int. We provide these
14444 -- synonyms for clarity, but in some cases it may be
14445 -- convenient to use the underlying types (for example to
14446 -- avoid an unnecessary dependency of a spec on the spec
14447 -- of this unit).
14448 type size_t is mod 2 ** Standard'Address_Size;
14449 NULL_Stream : constant FILEs;
14450 -- Value returned (NULL in C) to indicate an
14451 -- fdopen/fopen/tmpfile error
14452 ----------------------------------
14453 -- Constants Defined in stdio.h --
14454 ----------------------------------
14455 EOF : constant int;
14456 -- Used by a number of routines to indicate error or
14457 -- end of file
14458 IOFBF : constant int;
14459 IOLBF : constant int;
14460 IONBF : constant int;
14461 -- Used to indicate buffering mode for setvbuf call
14462 SEEK_CUR : constant int;
14463 SEEK_END : constant int;
14464 SEEK_SET : constant int;
14465 -- Used to indicate origin for fseek call
14466 function stdin return FILEs;
14467 function stdout return FILEs;
14468 function stderr return FILEs;
14469 -- Streams associated with standard files
14470 --------------------------
14471 -- Standard C functions --
14472 --------------------------
14473 -- The functions selected below are ones that are
14474 -- available in UNIX (but not necessarily in ANSI C).
14475 -- These are very thin interfaces
14476 -- which copy exactly the C headers. For more
14477 -- documentation on these functions, see the Microsoft C
14478 -- "Run-Time Library Reference" (Microsoft Press, 1990,
14479 -- ISBN 1-55615-225-6), which includes useful information
14480 -- on system compatibility.
14481 procedure clearerr (stream : FILEs);
14482 function fclose (stream : FILEs) return int;
14483 function fdopen (handle : int; mode : chars) return FILEs;
14484 function feof (stream : FILEs) return int;
14485 function ferror (stream : FILEs) return int;
14486 function fflush (stream : FILEs) return int;
14487 function fgetc (stream : FILEs) return int;
14488 function fgets (strng : chars; n : int; stream : FILEs)
14489 return chars;
14490 function fileno (stream : FILEs) return int;
14491 function fopen (filename : chars; Mode : chars)
14492 return FILEs;
14493 -- Note: to maintain target independence, use
14494 -- text_translation_required, a boolean variable defined in
14495 -- a-sysdep.c to deal with the target dependent text
14496 -- translation requirement. If this variable is set,
14497 -- then b/t should be appended to the standard mode
14498 -- argument to set the text translation mode off or on
14499 -- as required.
14500 function fputc (C : int; stream : FILEs) return int;
14501 function fputs (Strng : chars; Stream : FILEs) return int;
14502 function fread
14503 (buffer : voids;
14504 size : size_t;
14505 count : size_t;
14506 stream : FILEs)
14507 return size_t;
14508 function freopen
14509 (filename : chars;
14510 mode : chars;
14511 stream : FILEs)
14512 return FILEs;
14513 function fseek
14514 (stream : FILEs;
14515 offset : long;
14516 origin : int)
14517 return int;
14518 function ftell (stream : FILEs) return long;
14519 function fwrite
14520 (buffer : voids;
14521 size : size_t;
14522 count : size_t;
14523 stream : FILEs)
14524 return size_t;
14525 function isatty (handle : int) return int;
14526 procedure mktemp (template : chars);
14527 -- The return value (which is just a pointer to template)
14528 -- is discarded
14529 procedure rewind (stream : FILEs);
14530 function rmtmp return int;
14531 function setvbuf
14532 (stream : FILEs;
14533 buffer : chars;
14534 mode : int;
14535 size : size_t)
14536 return int;
14537
14538 function tmpfile return FILEs;
14539 function ungetc (c : int; stream : FILEs) return int;
14540 function unlink (filename : chars) return int;
14541 ---------------------
14542 -- Extra functions --
14543 ---------------------
14544 -- These functions supply slightly thicker bindings than
14545 -- those above. They are derived from functions in the
14546 -- C Run-Time Library, but may do a bit more work than
14547 -- just directly calling one of the Library functions.
14548 function is_regular_file (handle : int) return int;
14549 -- Tests if given handle is for a regular file (result 1)
14550 -- or for a non-regular file (pipe or device, result 0).
14551 ---------------------------------
14552 -- Control of Text/Binary Mode --
14553 ---------------------------------
14554 -- If text_translation_required is true, then the following
14555 -- functions may be used to dynamically switch a file from
14556 -- binary to text mode or vice versa. These functions have
14557 -- no effect if text_translation_required is false (i.e.@: in
14558 -- normal UNIX mode). Use fileno to get a stream handle.
14559 procedure set_binary_mode (handle : int);
14560 procedure set_text_mode (handle : int);
14561 ----------------------------
14562 -- Full Path Name support --
14563 ----------------------------
14564 procedure full_name (nam : chars; buffer : chars);
14565 -- Given a NUL terminated string representing a file
14566 -- name, returns in buffer a NUL terminated string
14567 -- representing the full path name for the file name.
14568 -- On systems where it is relevant the drive is also
14569 -- part of the full path name. It is the responsibility
14570 -- of the caller to pass an actual parameter for buffer
14571 -- that is big enough for any full path name. Use
14572 -- max_path_len given below as the size of buffer.
14573 max_path_len : integer;
14574 -- Maximum length of an allowable full path name on the
14575 -- system, including a terminating NUL character.
14576 end Interfaces.C_Streams;
14577 @end smallexample
14578
14579 @node Interfacing to C Streams
14580 @section Interfacing to C Streams
14581
14582 @noindent
14583 The packages in this section permit interfacing Ada files to C Stream
14584 operations.
14585
14586 @smallexample @c ada
14587 with Interfaces.C_Streams;
14588 package Ada.Sequential_IO.C_Streams is
14589 function C_Stream (F : File_Type)
14590 return Interfaces.C_Streams.FILEs;
14591 procedure Open
14592 (File : in out File_Type;
14593 Mode : in File_Mode;
14594 C_Stream : in Interfaces.C_Streams.FILEs;
14595 Form : in String := "");
14596 end Ada.Sequential_IO.C_Streams;
14597
14598 with Interfaces.C_Streams;
14599 package Ada.Direct_IO.C_Streams is
14600 function C_Stream (F : File_Type)
14601 return Interfaces.C_Streams.FILEs;
14602 procedure Open
14603 (File : in out File_Type;
14604 Mode : in File_Mode;
14605 C_Stream : in Interfaces.C_Streams.FILEs;
14606 Form : in String := "");
14607 end Ada.Direct_IO.C_Streams;
14608
14609 with Interfaces.C_Streams;
14610 package Ada.Text_IO.C_Streams is
14611 function C_Stream (F : File_Type)
14612 return Interfaces.C_Streams.FILEs;
14613 procedure Open
14614 (File : in out File_Type;
14615 Mode : in File_Mode;
14616 C_Stream : in Interfaces.C_Streams.FILEs;
14617 Form : in String := "");
14618 end Ada.Text_IO.C_Streams;
14619
14620 with Interfaces.C_Streams;
14621 package Ada.Wide_Text_IO.C_Streams is
14622 function C_Stream (F : File_Type)
14623 return Interfaces.C_Streams.FILEs;
14624 procedure Open
14625 (File : in out File_Type;
14626 Mode : in File_Mode;
14627 C_Stream : in Interfaces.C_Streams.FILEs;
14628 Form : in String := "");
14629 end Ada.Wide_Text_IO.C_Streams;
14630
14631 with Interfaces.C_Streams;
14632 package Ada.Wide_Wide_Text_IO.C_Streams is
14633 function C_Stream (F : File_Type)
14634 return Interfaces.C_Streams.FILEs;
14635 procedure Open
14636 (File : in out File_Type;
14637 Mode : in File_Mode;
14638 C_Stream : in Interfaces.C_Streams.FILEs;
14639 Form : in String := "");
14640 end Ada.Wide_Wide_Text_IO.C_Streams;
14641
14642 with Interfaces.C_Streams;
14643 package Ada.Stream_IO.C_Streams is
14644 function C_Stream (F : File_Type)
14645 return Interfaces.C_Streams.FILEs;
14646 procedure Open
14647 (File : in out File_Type;
14648 Mode : in File_Mode;
14649 C_Stream : in Interfaces.C_Streams.FILEs;
14650 Form : in String := "");
14651 end Ada.Stream_IO.C_Streams;
14652 @end smallexample
14653
14654 @noindent
14655 In each of these six packages, the @code{C_Stream} function obtains the
14656 @code{FILE} pointer from a currently opened Ada file. It is then
14657 possible to use the @code{Interfaces.C_Streams} package to operate on
14658 this stream, or the stream can be passed to a C program which can
14659 operate on it directly. Of course the program is responsible for
14660 ensuring that only appropriate sequences of operations are executed.
14661
14662 One particular use of relevance to an Ada program is that the
14663 @code{setvbuf} function can be used to control the buffering of the
14664 stream used by an Ada file. In the absence of such a call the standard
14665 default buffering is used.
14666
14667 The @code{Open} procedures in these packages open a file giving an
14668 existing C Stream instead of a file name. Typically this stream is
14669 imported from a C program, allowing an Ada file to operate on an
14670 existing C file.
14671
14672 @node The GNAT Library
14673 @chapter The GNAT Library
14674
14675 @noindent
14676 The GNAT library contains a number of general and special purpose packages.
14677 It represents functionality that the GNAT developers have found useful, and
14678 which is made available to GNAT users. The packages described here are fully
14679 supported, and upwards compatibility will be maintained in future releases,
14680 so you can use these facilities with the confidence that the same functionality
14681 will be available in future releases.
14682
14683 The chapter here simply gives a brief summary of the facilities available.
14684 The full documentation is found in the spec file for the package. The full
14685 sources of these library packages, including both spec and body, are provided
14686 with all GNAT releases. For example, to find out the full specifications of
14687 the SPITBOL pattern matching capability, including a full tutorial and
14688 extensive examples, look in the @file{g-spipat.ads} file in the library.
14689
14690 For each entry here, the package name (as it would appear in a @code{with}
14691 clause) is given, followed by the name of the corresponding spec file in
14692 parentheses. The packages are children in four hierarchies, @code{Ada},
14693 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14694 GNAT-specific hierarchy.
14695
14696 Note that an application program should only use packages in one of these
14697 four hierarchies if the package is defined in the Ada Reference Manual,
14698 or is listed in this section of the GNAT Programmers Reference Manual.
14699 All other units should be considered internal implementation units and
14700 should not be directly @code{with}'ed by application code. The use of
14701 a @code{with} statement that references one of these internal implementation
14702 units makes an application potentially dependent on changes in versions
14703 of GNAT, and will generate a warning message.
14704
14705 @menu
14706 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14707 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14708 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14709 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14710 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14711 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14712 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14713 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14714 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14715 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14716 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14717 * Ada.Command_Line.Environment (a-colien.ads)::
14718 * Ada.Command_Line.Remove (a-colire.ads)::
14719 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14720 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14721 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14722 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14723 * Ada.Exceptions.Traceback (a-exctra.ads)::
14724 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14725 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14726 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14727 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14728 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14729 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14730 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14731 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14732 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14733 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14734 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14735 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14736 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14737 * GNAT.Altivec (g-altive.ads)::
14738 * GNAT.Altivec.Conversions (g-altcon.ads)::
14739 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14740 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14741 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14742 * GNAT.Array_Split (g-arrspl.ads)::
14743 * GNAT.AWK (g-awk.ads)::
14744 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14745 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14746 * GNAT.Bubble_Sort (g-bubsor.ads)::
14747 * GNAT.Bubble_Sort_A (g-busora.ads)::
14748 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14749 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14750 * GNAT.Byte_Swapping (g-bytswa.ads)::
14751 * GNAT.Calendar (g-calend.ads)::
14752 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14753 * GNAT.Case_Util (g-casuti.ads)::
14754 * GNAT.CGI (g-cgi.ads)::
14755 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14756 * GNAT.CGI.Debug (g-cgideb.ads)::
14757 * GNAT.Command_Line (g-comlin.ads)::
14758 * GNAT.Compiler_Version (g-comver.ads)::
14759 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14760 * GNAT.CRC32 (g-crc32.ads)::
14761 * GNAT.Current_Exception (g-curexc.ads)::
14762 * GNAT.Debug_Pools (g-debpoo.ads)::
14763 * GNAT.Debug_Utilities (g-debuti.ads)::
14764 * GNAT.Decode_String (g-decstr.ads)::
14765 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14766 * GNAT.Directory_Operations (g-dirope.ads)::
14767 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14768 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14769 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14770 * GNAT.Encode_String (g-encstr.ads)::
14771 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14772 * GNAT.Exception_Actions (g-excact.ads)::
14773 * GNAT.Exception_Traces (g-exctra.ads)::
14774 * GNAT.Exceptions (g-except.ads)::
14775 * GNAT.Expect (g-expect.ads)::
14776 * GNAT.Expect.TTY (g-exptty.ads)::
14777 * GNAT.Float_Control (g-flocon.ads)::
14778 * GNAT.Heap_Sort (g-heasor.ads)::
14779 * GNAT.Heap_Sort_A (g-hesora.ads)::
14780 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14781 * GNAT.HTable (g-htable.ads)::
14782 * GNAT.IO (g-io.ads)::
14783 * GNAT.IO_Aux (g-io_aux.ads)::
14784 * GNAT.Lock_Files (g-locfil.ads)::
14785 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14786 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14787 * GNAT.MD5 (g-md5.ads)::
14788 * GNAT.Memory_Dump (g-memdum.ads)::
14789 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14790 * GNAT.OS_Lib (g-os_lib.ads)::
14791 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14792 * GNAT.Random_Numbers (g-rannum.ads)::
14793 * GNAT.Regexp (g-regexp.ads)::
14794 * GNAT.Registry (g-regist.ads)::
14795 * GNAT.Regpat (g-regpat.ads)::
14796 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14797 * GNAT.Semaphores (g-semaph.ads)::
14798 * GNAT.Serial_Communications (g-sercom.ads)::
14799 * GNAT.SHA1 (g-sha1.ads)::
14800 * GNAT.SHA224 (g-sha224.ads)::
14801 * GNAT.SHA256 (g-sha256.ads)::
14802 * GNAT.SHA384 (g-sha384.ads)::
14803 * GNAT.SHA512 (g-sha512.ads)::
14804 * GNAT.Signals (g-signal.ads)::
14805 * GNAT.Sockets (g-socket.ads)::
14806 * GNAT.Source_Info (g-souinf.ads)::
14807 * GNAT.Spelling_Checker (g-speche.ads)::
14808 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14809 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14810 * GNAT.Spitbol (g-spitbo.ads)::
14811 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14812 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14813 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14814 * GNAT.SSE (g-sse.ads)::
14815 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14816 * GNAT.Strings (g-string.ads)::
14817 * GNAT.String_Split (g-strspl.ads)::
14818 * GNAT.Table (g-table.ads)::
14819 * GNAT.Task_Lock (g-tasloc.ads)::
14820 * GNAT.Threads (g-thread.ads)::
14821 * GNAT.Time_Stamp (g-timsta.ads)::
14822 * GNAT.Traceback (g-traceb.ads)::
14823 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14824 * GNAT.UTF_32 (g-utf_32.ads)::
14825 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14826 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14827 * GNAT.Wide_String_Split (g-wistsp.ads)::
14828 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14829 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14830 * Interfaces.C.Extensions (i-cexten.ads)::
14831 * Interfaces.C.Streams (i-cstrea.ads)::
14832 * Interfaces.CPP (i-cpp.ads)::
14833 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14834 * Interfaces.VxWorks (i-vxwork.ads)::
14835 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14836 * System.Address_Image (s-addima.ads)::
14837 * System.Assertions (s-assert.ads)::
14838 * System.Memory (s-memory.ads)::
14839 * System.Partition_Interface (s-parint.ads)::
14840 * System.Pool_Global (s-pooglo.ads)::
14841 * System.Pool_Local (s-pooloc.ads)::
14842 * System.Restrictions (s-restri.ads)::
14843 * System.Rident (s-rident.ads)::
14844 * System.Strings.Stream_Ops (s-ststop.ads)::
14845 * System.Task_Info (s-tasinf.ads)::
14846 * System.Wch_Cnv (s-wchcnv.ads)::
14847 * System.Wch_Con (s-wchcon.ads)::
14848 @end menu
14849
14850 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14851 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14852 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14853 @cindex Latin_9 constants for Character
14854
14855 @noindent
14856 This child of @code{Ada.Characters}
14857 provides a set of definitions corresponding to those in the
14858 RM-defined package @code{Ada.Characters.Latin_1} but with the
14859 few modifications required for @code{Latin-9}
14860 The provision of such a package
14861 is specifically authorized by the Ada Reference Manual
14862 (RM A.3.3(27)).
14863
14864 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14865 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14866 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14867 @cindex Latin_1 constants for Wide_Character
14868
14869 @noindent
14870 This child of @code{Ada.Characters}
14871 provides a set of definitions corresponding to those in the
14872 RM-defined package @code{Ada.Characters.Latin_1} but with the
14873 types of the constants being @code{Wide_Character}
14874 instead of @code{Character}. The provision of such a package
14875 is specifically authorized by the Ada Reference Manual
14876 (RM A.3.3(27)).
14877
14878 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14879 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14880 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14881 @cindex Latin_9 constants for Wide_Character
14882
14883 @noindent
14884 This child of @code{Ada.Characters}
14885 provides a set of definitions corresponding to those in the
14886 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14887 types of the constants being @code{Wide_Character}
14888 instead of @code{Character}. The provision of such a package
14889 is specifically authorized by the Ada Reference Manual
14890 (RM A.3.3(27)).
14891
14892 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14893 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14894 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14895 @cindex Latin_1 constants for Wide_Wide_Character
14896
14897 @noindent
14898 This child of @code{Ada.Characters}
14899 provides a set of definitions corresponding to those in the
14900 RM-defined package @code{Ada.Characters.Latin_1} but with the
14901 types of the constants being @code{Wide_Wide_Character}
14902 instead of @code{Character}. The provision of such a package
14903 is specifically authorized by the Ada Reference Manual
14904 (RM A.3.3(27)).
14905
14906 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14907 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14908 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14909 @cindex Latin_9 constants for Wide_Wide_Character
14910
14911 @noindent
14912 This child of @code{Ada.Characters}
14913 provides a set of definitions corresponding to those in the
14914 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14915 types of the constants being @code{Wide_Wide_Character}
14916 instead of @code{Character}. The provision of such a package
14917 is specifically authorized by the Ada Reference Manual
14918 (RM A.3.3(27)).
14919
14920 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14921 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14922 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14923 @cindex Formal container for doubly linked lists
14924
14925 @noindent
14926 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14927 container for doubly linked lists, meant to facilitate formal verification of
14928 code using such containers.
14929
14930 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14931 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14932 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14933 @cindex Formal container for hashed maps
14934
14935 @noindent
14936 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14937 container for hashed maps, meant to facilitate formal verification of
14938 code using such containers.
14939
14940 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14941 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14942 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14943 @cindex Formal container for hashed sets
14944
14945 @noindent
14946 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14947 container for hashed sets, meant to facilitate formal verification of
14948 code using such containers.
14949
14950 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14951 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14952 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14953 @cindex Formal container for ordered maps
14954
14955 @noindent
14956 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14957 container for ordered maps, meant to facilitate formal verification of
14958 code using such containers.
14959
14960 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14961 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14962 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14963 @cindex Formal container for ordered sets
14964
14965 @noindent
14966 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14967 container for ordered sets, meant to facilitate formal verification of
14968 code using such containers.
14969
14970 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14971 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14972 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14973 @cindex Formal container for vectors
14974
14975 @noindent
14976 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14977 container for vectors, meant to facilitate formal verification of
14978 code using such containers.
14979
14980 @node Ada.Command_Line.Environment (a-colien.ads)
14981 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14982 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14983 @cindex Environment entries
14984
14985 @noindent
14986 This child of @code{Ada.Command_Line}
14987 provides a mechanism for obtaining environment values on systems
14988 where this concept makes sense.
14989
14990 @node Ada.Command_Line.Remove (a-colire.ads)
14991 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14992 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14993 @cindex Removing command line arguments
14994 @cindex Command line, argument removal
14995
14996 @noindent
14997 This child of @code{Ada.Command_Line}
14998 provides a mechanism for logically removing
14999 arguments from the argument list. Once removed, an argument is not visible
15000 to further calls on the subprograms in @code{Ada.Command_Line} will not
15001 see the removed argument.
15002
15003 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15004 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15005 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15006 @cindex Response file for command line
15007 @cindex Command line, response file
15008 @cindex Command line, handling long command lines
15009
15010 @noindent
15011 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15012 getting command line arguments from a text file, called a "response file".
15013 Using a response file allow passing a set of arguments to an executable longer
15014 than the maximum allowed by the system on the command line.
15015
15016 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15017 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15018 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15019 @cindex C Streams, Interfacing with Direct_IO
15020
15021 @noindent
15022 This package provides subprograms that allow interfacing between
15023 C streams and @code{Direct_IO}. The stream identifier can be
15024 extracted from a file opened on the Ada side, and an Ada file
15025 can be constructed from a stream opened on the C side.
15026
15027 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15028 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15029 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15030 @cindex Null_Occurrence, testing for
15031
15032 @noindent
15033 This child subprogram provides a way of testing for the null
15034 exception occurrence (@code{Null_Occurrence}) without raising
15035 an exception.
15036
15037 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15038 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15039 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15040 @cindex Null_Occurrence, testing for
15041
15042 @noindent
15043 This child subprogram is used for handling otherwise unhandled
15044 exceptions (hence the name last chance), and perform clean ups before
15045 terminating the program. Note that this subprogram never returns.
15046
15047 @node Ada.Exceptions.Traceback (a-exctra.ads)
15048 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15049 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15050 @cindex Traceback for Exception Occurrence
15051
15052 @noindent
15053 This child package provides the subprogram (@code{Tracebacks}) to
15054 give a traceback array of addresses based on an exception
15055 occurrence.
15056
15057 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15058 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15059 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15060 @cindex C Streams, Interfacing with Sequential_IO
15061
15062 @noindent
15063 This package provides subprograms that allow interfacing between
15064 C streams and @code{Sequential_IO}. The stream identifier can be
15065 extracted from a file opened on the Ada side, and an Ada file
15066 can be constructed from a stream opened on the C side.
15067
15068 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15069 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15070 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15071 @cindex C Streams, Interfacing with Stream_IO
15072
15073 @noindent
15074 This package provides subprograms that allow interfacing between
15075 C streams and @code{Stream_IO}. The stream identifier can be
15076 extracted from a file opened on the Ada side, and an Ada file
15077 can be constructed from a stream opened on the C side.
15078
15079 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15080 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15081 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15082 @cindex @code{Unbounded_String}, IO support
15083 @cindex @code{Text_IO}, extensions for unbounded strings
15084
15085 @noindent
15086 This package provides subprograms for Text_IO for unbounded
15087 strings, avoiding the necessity for an intermediate operation
15088 with ordinary strings.
15089
15090 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15091 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15092 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15093 @cindex @code{Unbounded_Wide_String}, IO support
15094 @cindex @code{Text_IO}, extensions for unbounded wide strings
15095
15096 @noindent
15097 This package provides subprograms for Text_IO for unbounded
15098 wide strings, avoiding the necessity for an intermediate operation
15099 with ordinary wide strings.
15100
15101 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15102 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15103 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15104 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15105 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15106
15107 @noindent
15108 This package provides subprograms for Text_IO for unbounded
15109 wide wide strings, avoiding the necessity for an intermediate operation
15110 with ordinary wide wide strings.
15111
15112 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15113 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15114 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15115 @cindex C Streams, Interfacing with @code{Text_IO}
15116
15117 @noindent
15118 This package provides subprograms that allow interfacing between
15119 C streams and @code{Text_IO}. The stream identifier can be
15120 extracted from a file opened on the Ada side, and an Ada file
15121 can be constructed from a stream opened on the C side.
15122
15123 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15124 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15125 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15126 @cindex @code{Text_IO} resetting standard files
15127
15128 @noindent
15129 This procedure is used to reset the status of the standard files used
15130 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15131 embedded application) where the status of the files may change during
15132 execution (for example a standard input file may be redefined to be
15133 interactive).
15134
15135 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15136 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15137 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15138 @cindex Unicode categorization, Wide_Character
15139
15140 @noindent
15141 This package provides subprograms that allow categorization of
15142 Wide_Character values according to Unicode categories.
15143
15144 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15145 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15146 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15147 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15148
15149 @noindent
15150 This package provides subprograms that allow interfacing between
15151 C streams and @code{Wide_Text_IO}. The stream identifier can be
15152 extracted from a file opened on the Ada side, and an Ada file
15153 can be constructed from a stream opened on the C side.
15154
15155 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15156 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15157 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15158 @cindex @code{Wide_Text_IO} resetting standard files
15159
15160 @noindent
15161 This procedure is used to reset the status of the standard files used
15162 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15163 embedded application) where the status of the files may change during
15164 execution (for example a standard input file may be redefined to be
15165 interactive).
15166
15167 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15168 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15169 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15170 @cindex Unicode categorization, Wide_Wide_Character
15171
15172 @noindent
15173 This package provides subprograms that allow categorization of
15174 Wide_Wide_Character values according to Unicode categories.
15175
15176 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15177 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15178 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15179 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15180
15181 @noindent
15182 This package provides subprograms that allow interfacing between
15183 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15184 extracted from a file opened on the Ada side, and an Ada file
15185 can be constructed from a stream opened on the C side.
15186
15187 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15188 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15189 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15190 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15191
15192 @noindent
15193 This procedure is used to reset the status of the standard files used
15194 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15195 restart in an embedded application) where the status of the files may
15196 change during execution (for example a standard input file may be
15197 redefined to be interactive).
15198
15199 @node GNAT.Altivec (g-altive.ads)
15200 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15201 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15202 @cindex AltiVec
15203
15204 @noindent
15205 This is the root package of the GNAT AltiVec binding. It provides
15206 definitions of constants and types common to all the versions of the
15207 binding.
15208
15209 @node GNAT.Altivec.Conversions (g-altcon.ads)
15210 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15211 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15212 @cindex AltiVec
15213
15214 @noindent
15215 This package provides the Vector/View conversion routines.
15216
15217 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15218 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15219 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15220 @cindex AltiVec
15221
15222 @noindent
15223 This package exposes the Ada interface to the AltiVec operations on
15224 vector objects. A soft emulation is included by default in the GNAT
15225 library. The hard binding is provided as a separate package. This unit
15226 is common to both bindings.
15227
15228 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15229 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15230 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15231 @cindex AltiVec
15232
15233 @noindent
15234 This package exposes the various vector types part of the Ada binding
15235 to AltiVec facilities.
15236
15237 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15238 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15239 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15240 @cindex AltiVec
15241
15242 @noindent
15243 This package provides public 'View' data types from/to which private
15244 vector representations can be converted via
15245 GNAT.Altivec.Conversions. This allows convenient access to individual
15246 vector elements and provides a simple way to initialize vector
15247 objects.
15248
15249 @node GNAT.Array_Split (g-arrspl.ads)
15250 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15251 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15252 @cindex Array splitter
15253
15254 @noindent
15255 Useful array-manipulation routines: given a set of separators, split
15256 an array wherever the separators appear, and provide direct access
15257 to the resulting slices.
15258
15259 @node GNAT.AWK (g-awk.ads)
15260 @section @code{GNAT.AWK} (@file{g-awk.ads})
15261 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15262 @cindex Parsing
15263 @cindex AWK
15264
15265 @noindent
15266 Provides AWK-like parsing functions, with an easy interface for parsing one
15267 or more files containing formatted data. The file is viewed as a database
15268 where each record is a line and a field is a data element in this line.
15269
15270 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15271 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15272 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15273 @cindex Parsing
15274 @cindex Bounded Buffers
15275
15276 @noindent
15277 Provides a concurrent generic bounded buffer abstraction. Instances are
15278 useful directly or as parts of the implementations of other abstractions,
15279 such as mailboxes.
15280
15281 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15282 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15283 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15284 @cindex Parsing
15285 @cindex Mailboxes
15286
15287 @noindent
15288 Provides a thread-safe asynchronous intertask mailbox communication facility.
15289
15290 @node GNAT.Bubble_Sort (g-bubsor.ads)
15291 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15292 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
15293 @cindex Sorting
15294 @cindex Bubble sort
15295
15296 @noindent
15297 Provides a general implementation of bubble sort usable for sorting arbitrary
15298 data items. Exchange and comparison procedures are provided by passing
15299 access-to-procedure values.
15300
15301 @node GNAT.Bubble_Sort_A (g-busora.ads)
15302 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15303 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
15304 @cindex Sorting
15305 @cindex Bubble sort
15306
15307 @noindent
15308 Provides a general implementation of bubble sort usable for sorting arbitrary
15309 data items. Move and comparison procedures are provided by passing
15310 access-to-procedure values. This is an older version, retained for
15311 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
15312
15313 @node GNAT.Bubble_Sort_G (g-busorg.ads)
15314 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15315 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
15316 @cindex Sorting
15317 @cindex Bubble sort
15318
15319 @noindent
15320 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
15321 are provided as generic parameters, this improves efficiency, especially
15322 if the procedures can be inlined, at the expense of duplicating code for
15323 multiple instantiations.
15324
15325 @node GNAT.Byte_Order_Mark (g-byorma.ads)
15326 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15327 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
15328 @cindex UTF-8 representation
15329 @cindex Wide characte representations
15330
15331 @noindent
15332 Provides a routine which given a string, reads the start of the string to
15333 see whether it is one of the standard byte order marks (BOM's) which signal
15334 the encoding of the string. The routine includes detection of special XML
15335 sequences for various UCS input formats.
15336
15337 @node GNAT.Byte_Swapping (g-bytswa.ads)
15338 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15339 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
15340 @cindex Byte swapping
15341 @cindex Endian
15342
15343 @noindent
15344 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
15345 Machine-specific implementations are available in some cases.
15346
15347 @node GNAT.Calendar (g-calend.ads)
15348 @section @code{GNAT.Calendar} (@file{g-calend.ads})
15349 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
15350 @cindex @code{Calendar}
15351
15352 @noindent
15353 Extends the facilities provided by @code{Ada.Calendar} to include handling
15354 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
15355 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
15356 C @code{timeval} format.
15357
15358 @node GNAT.Calendar.Time_IO (g-catiio.ads)
15359 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15360 @cindex @code{Calendar}
15361 @cindex Time
15362 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
15363
15364 @node GNAT.CRC32 (g-crc32.ads)
15365 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
15366 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
15367 @cindex CRC32
15368 @cindex Cyclic Redundancy Check
15369
15370 @noindent
15371 This package implements the CRC-32 algorithm. For a full description
15372 of this algorithm see
15373 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
15374 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
15375 Aug.@: 1988. Sarwate, D.V@.
15376
15377 @node GNAT.Case_Util (g-casuti.ads)
15378 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
15379 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
15380 @cindex Casing utilities
15381 @cindex Character handling (@code{GNAT.Case_Util})
15382
15383 @noindent
15384 A set of simple routines for handling upper and lower casing of strings
15385 without the overhead of the full casing tables
15386 in @code{Ada.Characters.Handling}.
15387
15388 @node GNAT.CGI (g-cgi.ads)
15389 @section @code{GNAT.CGI} (@file{g-cgi.ads})
15390 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
15391 @cindex CGI (Common Gateway Interface)
15392
15393 @noindent
15394 This is a package for interfacing a GNAT program with a Web server via the
15395 Common Gateway Interface (CGI)@. Basically this package parses the CGI
15396 parameters, which are a set of key/value pairs sent by the Web server. It
15397 builds a table whose index is the key and provides some services to deal
15398 with this table.
15399
15400 @node GNAT.CGI.Cookie (g-cgicoo.ads)
15401 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15402 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
15403 @cindex CGI (Common Gateway Interface) cookie support
15404 @cindex Cookie support in CGI
15405
15406 @noindent
15407 This is a package to interface a GNAT program with a Web server via the
15408 Common Gateway Interface (CGI). It exports services to deal with Web
15409 cookies (piece of information kept in the Web client software).
15410
15411 @node GNAT.CGI.Debug (g-cgideb.ads)
15412 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15413 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
15414 @cindex CGI (Common Gateway Interface) debugging
15415
15416 @noindent
15417 This is a package to help debugging CGI (Common Gateway Interface)
15418 programs written in Ada.
15419
15420 @node GNAT.Command_Line (g-comlin.ads)
15421 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
15422 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
15423 @cindex Command line
15424
15425 @noindent
15426 Provides a high level interface to @code{Ada.Command_Line} facilities,
15427 including the ability to scan for named switches with optional parameters
15428 and expand file names using wild card notations.
15429
15430 @node GNAT.Compiler_Version (g-comver.ads)
15431 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15432 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
15433 @cindex Compiler Version
15434 @cindex Version, of compiler
15435
15436 @noindent
15437 Provides a routine for obtaining the version of the compiler used to
15438 compile the program. More accurately this is the version of the binder
15439 used to bind the program (this will normally be the same as the version
15440 of the compiler if a consistent tool set is used to compile all units
15441 of a partition).
15442
15443 @node GNAT.Ctrl_C (g-ctrl_c.ads)
15444 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15445 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
15446 @cindex Interrupt
15447
15448 @noindent
15449 Provides a simple interface to handle Ctrl-C keyboard events.
15450
15451 @node GNAT.Current_Exception (g-curexc.ads)
15452 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15453 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
15454 @cindex Current exception
15455 @cindex Exception retrieval
15456
15457 @noindent
15458 Provides access to information on the current exception that has been raised
15459 without the need for using the Ada 95 / Ada 2005 exception choice parameter
15460 specification syntax.
15461 This is particularly useful in simulating typical facilities for
15462 obtaining information about exceptions provided by Ada 83 compilers.
15463
15464 @node GNAT.Debug_Pools (g-debpoo.ads)
15465 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15466 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
15467 @cindex Debugging
15468 @cindex Debug pools
15469 @cindex Memory corruption debugging
15470
15471 @noindent
15472 Provide a debugging storage pools that helps tracking memory corruption
15473 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
15474 @value{EDITION} User's Guide}.
15475
15476 @node GNAT.Debug_Utilities (g-debuti.ads)
15477 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15478 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
15479 @cindex Debugging
15480
15481 @noindent
15482 Provides a few useful utilities for debugging purposes, including conversion
15483 to and from string images of address values. Supports both C and Ada formats
15484 for hexadecimal literals.
15485
15486 @node GNAT.Decode_String (g-decstr.ads)
15487 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
15488 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
15489 @cindex Decoding strings
15490 @cindex String decoding
15491 @cindex Wide character encoding
15492 @cindex UTF-8
15493 @cindex Unicode
15494
15495 @noindent
15496 A generic package providing routines for decoding wide character and wide wide
15497 character strings encoded as sequences of 8-bit characters using a specified
15498 encoding method. Includes validation routines, and also routines for stepping
15499 to next or previous encoded character in an encoded string.
15500 Useful in conjunction with Unicode character coding. Note there is a
15501 preinstantiation for UTF-8. See next entry.
15502
15503 @node GNAT.Decode_UTF8_String (g-deutst.ads)
15504 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15505 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
15506 @cindex Decoding strings
15507 @cindex Decoding UTF-8 strings
15508 @cindex UTF-8 string decoding
15509 @cindex Wide character decoding
15510 @cindex UTF-8
15511 @cindex Unicode
15512
15513 @noindent
15514 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
15515
15516 @node GNAT.Directory_Operations (g-dirope.ads)
15517 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15518 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
15519 @cindex Directory operations
15520
15521 @noindent
15522 Provides a set of routines for manipulating directories, including changing
15523 the current directory, making new directories, and scanning the files in a
15524 directory.
15525
15526 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
15527 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15528 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
15529 @cindex Directory operations iteration
15530
15531 @noindent
15532 A child unit of GNAT.Directory_Operations providing additional operations
15533 for iterating through directories.
15534
15535 @node GNAT.Dynamic_HTables (g-dynhta.ads)
15536 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15537 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
15538 @cindex Hash tables
15539
15540 @noindent
15541 A generic implementation of hash tables that can be used to hash arbitrary
15542 data. Provided in two forms, a simple form with built in hash functions,
15543 and a more complex form in which the hash function is supplied.
15544
15545 @noindent
15546 This package provides a facility similar to that of @code{GNAT.HTable},
15547 except that this package declares a type that can be used to define
15548 dynamic instances of the hash table, while an instantiation of
15549 @code{GNAT.HTable} creates a single instance of the hash table.
15550
15551 @node GNAT.Dynamic_Tables (g-dyntab.ads)
15552 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15553 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
15554 @cindex Table implementation
15555 @cindex Arrays, extendable
15556
15557 @noindent
15558 A generic package providing a single dimension array abstraction where the
15559 length of the array can be dynamically modified.
15560
15561 @noindent
15562 This package provides a facility similar to that of @code{GNAT.Table},
15563 except that this package declares a type that can be used to define
15564 dynamic instances of the table, while an instantiation of
15565 @code{GNAT.Table} creates a single instance of the table type.
15566
15567 @node GNAT.Encode_String (g-encstr.ads)
15568 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
15569 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
15570 @cindex Encoding strings
15571 @cindex String encoding
15572 @cindex Wide character encoding
15573 @cindex UTF-8
15574 @cindex Unicode
15575
15576 @noindent
15577 A generic package providing routines for encoding wide character and wide
15578 wide character strings as sequences of 8-bit characters using a specified
15579 encoding method. Useful in conjunction with Unicode character coding.
15580 Note there is a preinstantiation for UTF-8. See next entry.
15581
15582 @node GNAT.Encode_UTF8_String (g-enutst.ads)
15583 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15584 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
15585 @cindex Encoding strings
15586 @cindex Encoding UTF-8 strings
15587 @cindex UTF-8 string encoding
15588 @cindex Wide character encoding
15589 @cindex UTF-8
15590 @cindex Unicode
15591
15592 @noindent
15593 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
15594
15595 @node GNAT.Exception_Actions (g-excact.ads)
15596 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15597 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
15598 @cindex Exception actions
15599
15600 @noindent
15601 Provides callbacks when an exception is raised. Callbacks can be registered
15602 for specific exceptions, or when any exception is raised. This
15603 can be used for instance to force a core dump to ease debugging.
15604
15605 @node GNAT.Exception_Traces (g-exctra.ads)
15606 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15607 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15608 @cindex Exception traces
15609 @cindex Debugging
15610
15611 @noindent
15612 Provides an interface allowing to control automatic output upon exception
15613 occurrences.
15614
15615 @node GNAT.Exceptions (g-except.ads)
15616 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15617 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15618 @cindex Exceptions, Pure
15619 @cindex Pure packages, exceptions
15620
15621 @noindent
15622 Normally it is not possible to raise an exception with
15623 a message from a subprogram in a pure package, since the
15624 necessary types and subprograms are in @code{Ada.Exceptions}
15625 which is not a pure unit. @code{GNAT.Exceptions} provides a
15626 facility for getting around this limitation for a few
15627 predefined exceptions, and for example allow raising
15628 @code{Constraint_Error} with a message from a pure subprogram.
15629
15630 @node GNAT.Expect (g-expect.ads)
15631 @section @code{GNAT.Expect} (@file{g-expect.ads})
15632 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15633
15634 @noindent
15635 Provides a set of subprograms similar to what is available
15636 with the standard Tcl Expect tool.
15637 It allows you to easily spawn and communicate with an external process.
15638 You can send commands or inputs to the process, and compare the output
15639 with some expected regular expression. Currently @code{GNAT.Expect}
15640 is implemented on all native GNAT ports except for OpenVMS@.
15641 It is not implemented for cross ports, and in particular is not
15642 implemented for VxWorks or LynxOS@.
15643
15644 @node GNAT.Expect.TTY (g-exptty.ads)
15645 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15646 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15647
15648 @noindent
15649 As GNAT.Expect but using pseudo-terminal.
15650 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15651 ports except for OpenVMS@. It is not implemented for cross ports, and
15652 in particular is not implemented for VxWorks or LynxOS@.
15653
15654 @node GNAT.Float_Control (g-flocon.ads)
15655 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15656 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15657 @cindex Floating-Point Processor
15658
15659 @noindent
15660 Provides an interface for resetting the floating-point processor into the
15661 mode required for correct semantic operation in Ada. Some third party
15662 library calls may cause this mode to be modified, and the Reset procedure
15663 in this package can be used to reestablish the required mode.
15664
15665 @node GNAT.Heap_Sort (g-heasor.ads)
15666 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15667 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15668 @cindex Sorting
15669
15670 @noindent
15671 Provides a general implementation of heap sort usable for sorting arbitrary
15672 data items. Exchange and comparison procedures are provided by passing
15673 access-to-procedure values. The algorithm used is a modified heap sort
15674 that performs approximately N*log(N) comparisons in the worst case.
15675
15676 @node GNAT.Heap_Sort_A (g-hesora.ads)
15677 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15678 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15679 @cindex Sorting
15680
15681 @noindent
15682 Provides a general implementation of heap sort usable for sorting arbitrary
15683 data items. Move and comparison procedures are provided by passing
15684 access-to-procedure values. The algorithm used is a modified heap sort
15685 that performs approximately N*log(N) comparisons in the worst case.
15686 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15687 interface, but may be slightly more efficient.
15688
15689 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15690 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15691 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15692 @cindex Sorting
15693
15694 @noindent
15695 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15696 are provided as generic parameters, this improves efficiency, especially
15697 if the procedures can be inlined, at the expense of duplicating code for
15698 multiple instantiations.
15699
15700 @node GNAT.HTable (g-htable.ads)
15701 @section @code{GNAT.HTable} (@file{g-htable.ads})
15702 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15703 @cindex Hash tables
15704
15705 @noindent
15706 A generic implementation of hash tables that can be used to hash arbitrary
15707 data. Provides two approaches, one a simple static approach, and the other
15708 allowing arbitrary dynamic hash tables.
15709
15710 @node GNAT.IO (g-io.ads)
15711 @section @code{GNAT.IO} (@file{g-io.ads})
15712 @cindex @code{GNAT.IO} (@file{g-io.ads})
15713 @cindex Simple I/O
15714 @cindex Input/Output facilities
15715
15716 @noindent
15717 A simple preelaborable input-output package that provides a subset of
15718 simple Text_IO functions for reading characters and strings from
15719 Standard_Input, and writing characters, strings and integers to either
15720 Standard_Output or Standard_Error.
15721
15722 @node GNAT.IO_Aux (g-io_aux.ads)
15723 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15724 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15725 @cindex Text_IO
15726 @cindex Input/Output facilities
15727
15728 Provides some auxiliary functions for use with Text_IO, including a test
15729 for whether a file exists, and functions for reading a line of text.
15730
15731 @node GNAT.Lock_Files (g-locfil.ads)
15732 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15733 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15734 @cindex File locking
15735 @cindex Locking using files
15736
15737 @noindent
15738 Provides a general interface for using files as locks. Can be used for
15739 providing program level synchronization.
15740
15741 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15742 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15743 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15744 @cindex Random number generation
15745
15746 @noindent
15747 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
15748 a modified version of the Blum-Blum-Shub generator.
15749
15750 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15751 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15752 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15753 @cindex Random number generation
15754
15755 @noindent
15756 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
15757 a modified version of the Blum-Blum-Shub generator.
15758
15759 @node GNAT.MD5 (g-md5.ads)
15760 @section @code{GNAT.MD5} (@file{g-md5.ads})
15761 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15762 @cindex Message Digest MD5
15763
15764 @noindent
15765 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15766
15767 @node GNAT.Memory_Dump (g-memdum.ads)
15768 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15769 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15770 @cindex Dump Memory
15771
15772 @noindent
15773 Provides a convenient routine for dumping raw memory to either the
15774 standard output or standard error files. Uses GNAT.IO for actual
15775 output.
15776
15777 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15778 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15779 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15780 @cindex Exception, obtaining most recent
15781
15782 @noindent
15783 Provides access to the most recently raised exception. Can be used for
15784 various logging purposes, including duplicating functionality of some
15785 Ada 83 implementation dependent extensions.
15786
15787 @node GNAT.OS_Lib (g-os_lib.ads)
15788 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15789 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15790 @cindex Operating System interface
15791 @cindex Spawn capability
15792
15793 @noindent
15794 Provides a range of target independent operating system interface functions,
15795 including time/date management, file operations, subprocess management,
15796 including a portable spawn procedure, and access to environment variables
15797 and error return codes.
15798
15799 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15800 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15801 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15802 @cindex Hash functions
15803
15804 @noindent
15805 Provides a generator of static minimal perfect hash functions. No
15806 collisions occur and each item can be retrieved from the table in one
15807 probe (perfect property). The hash table size corresponds to the exact
15808 size of the key set and no larger (minimal property). The key set has to
15809 be know in advance (static property). The hash functions are also order
15810 preserving. If w2 is inserted after w1 in the generator, their
15811 hashcode are in the same order. These hashing functions are very
15812 convenient for use with realtime applications.
15813
15814 @node GNAT.Random_Numbers (g-rannum.ads)
15815 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15816 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15817 @cindex Random number generation
15818
15819 @noindent
15820 Provides random number capabilities which extend those available in the
15821 standard Ada library and are more convenient to use.
15822
15823 @node GNAT.Regexp (g-regexp.ads)
15824 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15825 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15826 @cindex Regular expressions
15827 @cindex Pattern matching
15828
15829 @noindent
15830 A simple implementation of regular expressions, using a subset of regular
15831 expression syntax copied from familiar Unix style utilities. This is the
15832 simples of the three pattern matching packages provided, and is particularly
15833 suitable for ``file globbing'' applications.
15834
15835 @node GNAT.Registry (g-regist.ads)
15836 @section @code{GNAT.Registry} (@file{g-regist.ads})
15837 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15838 @cindex Windows Registry
15839
15840 @noindent
15841 This is a high level binding to the Windows registry. It is possible to
15842 do simple things like reading a key value, creating a new key. For full
15843 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15844 package provided with the Win32Ada binding
15845
15846 @node GNAT.Regpat (g-regpat.ads)
15847 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15848 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15849 @cindex Regular expressions
15850 @cindex Pattern matching
15851
15852 @noindent
15853 A complete implementation of Unix-style regular expression matching, copied
15854 from the original V7 style regular expression library written in C by
15855 Henry Spencer (and binary compatible with this C library).
15856
15857 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15858 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15859 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15860 @cindex Secondary Stack Info
15861
15862 @noindent
15863 Provide the capability to query the high water mark of the current task's
15864 secondary stack.
15865
15866 @node GNAT.Semaphores (g-semaph.ads)
15867 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15868 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15869 @cindex Semaphores
15870
15871 @noindent
15872 Provides classic counting and binary semaphores using protected types.
15873
15874 @node GNAT.Serial_Communications (g-sercom.ads)
15875 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15876 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15877 @cindex Serial_Communications
15878
15879 @noindent
15880 Provides a simple interface to send and receive data over a serial
15881 port. This is only supported on GNU/Linux and Windows.
15882
15883 @node GNAT.SHA1 (g-sha1.ads)
15884 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15885 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15886 @cindex Secure Hash Algorithm SHA-1
15887
15888 @noindent
15889 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15890 and RFC 3174.
15891
15892 @node GNAT.SHA224 (g-sha224.ads)
15893 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15894 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15895 @cindex Secure Hash Algorithm SHA-224
15896
15897 @noindent
15898 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15899
15900 @node GNAT.SHA256 (g-sha256.ads)
15901 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15902 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15903 @cindex Secure Hash Algorithm SHA-256
15904
15905 @noindent
15906 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15907
15908 @node GNAT.SHA384 (g-sha384.ads)
15909 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15910 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15911 @cindex Secure Hash Algorithm SHA-384
15912
15913 @noindent
15914 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15915
15916 @node GNAT.SHA512 (g-sha512.ads)
15917 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15918 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15919 @cindex Secure Hash Algorithm SHA-512
15920
15921 @noindent
15922 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15923
15924 @node GNAT.Signals (g-signal.ads)
15925 @section @code{GNAT.Signals} (@file{g-signal.ads})
15926 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15927 @cindex Signals
15928
15929 @noindent
15930 Provides the ability to manipulate the blocked status of signals on supported
15931 targets.
15932
15933 @node GNAT.Sockets (g-socket.ads)
15934 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15935 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15936 @cindex Sockets
15937
15938 @noindent
15939 A high level and portable interface to develop sockets based applications.
15940 This package is based on the sockets thin binding found in
15941 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15942 on all native GNAT ports except for OpenVMS@. It is not implemented
15943 for the LynxOS@ cross port.
15944
15945 @node GNAT.Source_Info (g-souinf.ads)
15946 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15947 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15948 @cindex Source Information
15949
15950 @noindent
15951 Provides subprograms that give access to source code information known at
15952 compile time, such as the current file name and line number.
15953
15954 @node GNAT.Spelling_Checker (g-speche.ads)
15955 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15956 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15957 @cindex Spell checking
15958
15959 @noindent
15960 Provides a function for determining whether one string is a plausible
15961 near misspelling of another string.
15962
15963 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15964 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15965 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15966 @cindex Spell checking
15967
15968 @noindent
15969 Provides a generic function that can be instantiated with a string type for
15970 determining whether one string is a plausible near misspelling of another
15971 string.
15972
15973 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15974 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15975 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15976 @cindex SPITBOL pattern matching
15977 @cindex Pattern matching
15978
15979 @noindent
15980 A complete implementation of SNOBOL4 style pattern matching. This is the
15981 most elaborate of the pattern matching packages provided. It fully duplicates
15982 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15983 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15984
15985 @node GNAT.Spitbol (g-spitbo.ads)
15986 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15987 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15988 @cindex SPITBOL interface
15989
15990 @noindent
15991 The top level package of the collection of SPITBOL-style functionality, this
15992 package provides basic SNOBOL4 string manipulation functions, such as
15993 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15994 useful for constructing arbitrary mappings from strings in the style of
15995 the SNOBOL4 TABLE function.
15996
15997 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15998 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15999 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16000 @cindex Sets of strings
16001 @cindex SPITBOL Tables
16002
16003 @noindent
16004 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16005 for type @code{Standard.Boolean}, giving an implementation of sets of
16006 string values.
16007
16008 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16009 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16010 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16011 @cindex Integer maps
16012 @cindex Maps
16013 @cindex SPITBOL Tables
16014
16015 @noindent
16016 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16017 for type @code{Standard.Integer}, giving an implementation of maps
16018 from string to integer values.
16019
16020 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16021 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16022 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16023 @cindex String maps
16024 @cindex Maps
16025 @cindex SPITBOL Tables
16026
16027 @noindent
16028 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16029 a variable length string type, giving an implementation of general
16030 maps from strings to strings.
16031
16032 @node GNAT.SSE (g-sse.ads)
16033 @section @code{GNAT.SSE} (@file{g-sse.ads})
16034 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16035
16036 @noindent
16037 Root of a set of units aimed at offering Ada bindings to a subset of
16038 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16039 targets. It exposes vector component types together with a general
16040 introduction to the binding contents and use.
16041
16042 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16043 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16044 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16045
16046 @noindent
16047 SSE vector types for use with SSE related intrinsics.
16048
16049 @node GNAT.Strings (g-string.ads)
16050 @section @code{GNAT.Strings} (@file{g-string.ads})
16051 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16052
16053 @noindent
16054 Common String access types and related subprograms. Basically it
16055 defines a string access and an array of string access types.
16056
16057 @node GNAT.String_Split (g-strspl.ads)
16058 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16059 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16060 @cindex String splitter
16061
16062 @noindent
16063 Useful string manipulation routines: given a set of separators, split
16064 a string wherever the separators appear, and provide direct access
16065 to the resulting slices. This package is instantiated from
16066 @code{GNAT.Array_Split}.
16067
16068 @node GNAT.Table (g-table.ads)
16069 @section @code{GNAT.Table} (@file{g-table.ads})
16070 @cindex @code{GNAT.Table} (@file{g-table.ads})
16071 @cindex Table implementation
16072 @cindex Arrays, extendable
16073
16074 @noindent
16075 A generic package providing a single dimension array abstraction where the
16076 length of the array can be dynamically modified.
16077
16078 @noindent
16079 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16080 except that this package declares a single instance of the table type,
16081 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16082 used to define dynamic instances of the table.
16083
16084 @node GNAT.Task_Lock (g-tasloc.ads)
16085 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16086 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16087 @cindex Task synchronization
16088 @cindex Task locking
16089 @cindex Locking
16090
16091 @noindent
16092 A very simple facility for locking and unlocking sections of code using a
16093 single global task lock. Appropriate for use in situations where contention
16094 between tasks is very rarely expected.
16095
16096 @node GNAT.Time_Stamp (g-timsta.ads)
16097 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16098 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16099 @cindex Time stamp
16100 @cindex Current time
16101
16102 @noindent
16103 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16104 represents the current date and time in ISO 8601 format. This is a very simple
16105 routine with minimal code and there are no dependencies on any other unit.
16106
16107 @node GNAT.Threads (g-thread.ads)
16108 @section @code{GNAT.Threads} (@file{g-thread.ads})
16109 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16110 @cindex Foreign threads
16111 @cindex Threads, foreign
16112
16113 @noindent
16114 Provides facilities for dealing with foreign threads which need to be known
16115 by the GNAT run-time system. Consult the documentation of this package for
16116 further details if your program has threads that are created by a non-Ada
16117 environment which then accesses Ada code.
16118
16119 @node GNAT.Traceback (g-traceb.ads)
16120 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16121 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16122 @cindex Trace back facilities
16123
16124 @noindent
16125 Provides a facility for obtaining non-symbolic traceback information, useful
16126 in various debugging situations.
16127
16128 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16129 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16130 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16131 @cindex Trace back facilities
16132
16133 @node GNAT.UTF_32 (g-utf_32.ads)
16134 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16135 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16136 @cindex Wide character codes
16137
16138 @noindent
16139 This is a package intended to be used in conjunction with the
16140 @code{Wide_Character} type in Ada 95 and the
16141 @code{Wide_Wide_Character} type in Ada 2005 (available
16142 in @code{GNAT} in Ada 2005 mode). This package contains
16143 Unicode categorization routines, as well as lexical
16144 categorization routines corresponding to the Ada 2005
16145 lexical rules for identifiers and strings, and also a
16146 lower case to upper case fold routine corresponding to
16147 the Ada 2005 rules for identifier equivalence.
16148
16149 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16150 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16151 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16152 @cindex Spell checking
16153
16154 @noindent
16155 Provides a function for determining whether one wide wide string is a plausible
16156 near misspelling of another wide wide string, where the strings are represented
16157 using the UTF_32_String type defined in System.Wch_Cnv.
16158
16159 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16160 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16161 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16162 @cindex Spell checking
16163
16164 @noindent
16165 Provides a function for determining whether one wide string is a plausible
16166 near misspelling of another wide string.
16167
16168 @node GNAT.Wide_String_Split (g-wistsp.ads)
16169 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16170 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16171 @cindex Wide_String splitter
16172
16173 @noindent
16174 Useful wide string manipulation routines: given a set of separators, split
16175 a wide string wherever the separators appear, and provide direct access
16176 to the resulting slices. This package is instantiated from
16177 @code{GNAT.Array_Split}.
16178
16179 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16180 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16181 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16182 @cindex Spell checking
16183
16184 @noindent
16185 Provides a function for determining whether one wide wide string is a plausible
16186 near misspelling of another wide wide string.
16187
16188 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16189 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16190 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16191 @cindex Wide_Wide_String splitter
16192
16193 @noindent
16194 Useful wide wide string manipulation routines: given a set of separators, split
16195 a wide wide string wherever the separators appear, and provide direct access
16196 to the resulting slices. This package is instantiated from
16197 @code{GNAT.Array_Split}.
16198
16199 @node Interfaces.C.Extensions (i-cexten.ads)
16200 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16201 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16202
16203 @noindent
16204 This package contains additional C-related definitions, intended
16205 for use with either manually or automatically generated bindings
16206 to C libraries.
16207
16208 @node Interfaces.C.Streams (i-cstrea.ads)
16209 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16210 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16211 @cindex C streams, interfacing
16212
16213 @noindent
16214 This package is a binding for the most commonly used operations
16215 on C streams.
16216
16217 @node Interfaces.CPP (i-cpp.ads)
16218 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16219 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16220 @cindex C++ interfacing
16221 @cindex Interfacing, to C++
16222
16223 @noindent
16224 This package provides facilities for use in interfacing to C++. It
16225 is primarily intended to be used in connection with automated tools
16226 for the generation of C++ interfaces.
16227
16228 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16229 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16230 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16231 @cindex IBM Packed Format
16232 @cindex Packed Decimal
16233
16234 @noindent
16235 This package provides a set of routines for conversions to and
16236 from a packed decimal format compatible with that used on IBM
16237 mainframes.
16238
16239 @node Interfaces.VxWorks (i-vxwork.ads)
16240 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16241 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16242 @cindex Interfacing to VxWorks
16243 @cindex VxWorks, interfacing
16244
16245 @noindent
16246 This package provides a limited binding to the VxWorks API.
16247 In particular, it interfaces with the
16248 VxWorks hardware interrupt facilities.
16249
16250 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16251 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16252 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16253 @cindex Interfacing to VxWorks' I/O
16254 @cindex VxWorks, I/O interfacing
16255 @cindex VxWorks, Get_Immediate
16256 @cindex Get_Immediate, VxWorks
16257
16258 @noindent
16259 This package provides a binding to the ioctl (IO/Control)
16260 function of VxWorks, defining a set of option values and
16261 function codes. A particular use of this package is
16262 to enable the use of Get_Immediate under VxWorks.
16263
16264 @node System.Address_Image (s-addima.ads)
16265 @section @code{System.Address_Image} (@file{s-addima.ads})
16266 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16267 @cindex Address image
16268 @cindex Image, of an address
16269
16270 @noindent
16271 This function provides a useful debugging
16272 function that gives an (implementation dependent)
16273 string which identifies an address.
16274
16275 @node System.Assertions (s-assert.ads)
16276 @section @code{System.Assertions} (@file{s-assert.ads})
16277 @cindex @code{System.Assertions} (@file{s-assert.ads})
16278 @cindex Assertions
16279 @cindex Assert_Failure, exception
16280
16281 @noindent
16282 This package provides the declaration of the exception raised
16283 by an run-time assertion failure, as well as the routine that
16284 is used internally to raise this assertion.
16285
16286 @node System.Memory (s-memory.ads)
16287 @section @code{System.Memory} (@file{s-memory.ads})
16288 @cindex @code{System.Memory} (@file{s-memory.ads})
16289 @cindex Memory allocation
16290
16291 @noindent
16292 This package provides the interface to the low level routines used
16293 by the generated code for allocation and freeing storage for the
16294 default storage pool (analogous to the C routines malloc and free.
16295 It also provides a reallocation interface analogous to the C routine
16296 realloc. The body of this unit may be modified to provide alternative
16297 allocation mechanisms for the default pool, and in addition, direct
16298 calls to this unit may be made for low level allocation uses (for
16299 example see the body of @code{GNAT.Tables}).
16300
16301 @node System.Partition_Interface (s-parint.ads)
16302 @section @code{System.Partition_Interface} (@file{s-parint.ads})
16303 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
16304 @cindex Partition interfacing functions
16305
16306 @noindent
16307 This package provides facilities for partition interfacing. It
16308 is used primarily in a distribution context when using Annex E
16309 with @code{GLADE}.
16310
16311 @node System.Pool_Global (s-pooglo.ads)
16312 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
16313 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
16314 @cindex Storage pool, global
16315 @cindex Global storage pool
16316
16317 @noindent
16318 This package provides a storage pool that is equivalent to the default
16319 storage pool used for access types for which no pool is specifically
16320 declared. It uses malloc/free to allocate/free and does not attempt to
16321 do any automatic reclamation.
16322
16323 @node System.Pool_Local (s-pooloc.ads)
16324 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
16325 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
16326 @cindex Storage pool, local
16327 @cindex Local storage pool
16328
16329 @noindent
16330 This package provides a storage pool that is intended for use with locally
16331 defined access types. It uses malloc/free for allocate/free, and maintains
16332 a list of allocated blocks, so that all storage allocated for the pool can
16333 be freed automatically when the pool is finalized.
16334
16335 @node System.Restrictions (s-restri.ads)
16336 @section @code{System.Restrictions} (@file{s-restri.ads})
16337 @cindex @code{System.Restrictions} (@file{s-restri.ads})
16338 @cindex Run-time restrictions access
16339
16340 @noindent
16341 This package provides facilities for accessing at run time
16342 the status of restrictions specified at compile time for
16343 the partition. Information is available both with regard
16344 to actual restrictions specified, and with regard to
16345 compiler determined information on which restrictions
16346 are violated by one or more packages in the partition.
16347
16348 @node System.Rident (s-rident.ads)
16349 @section @code{System.Rident} (@file{s-rident.ads})
16350 @cindex @code{System.Rident} (@file{s-rident.ads})
16351 @cindex Restrictions definitions
16352
16353 @noindent
16354 This package provides definitions of the restrictions
16355 identifiers supported by GNAT, and also the format of
16356 the restrictions provided in package System.Restrictions.
16357 It is not normally necessary to @code{with} this generic package
16358 since the necessary instantiation is included in
16359 package System.Restrictions.
16360
16361 @node System.Strings.Stream_Ops (s-ststop.ads)
16362 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16363 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
16364 @cindex Stream operations
16365 @cindex String stream operations
16366
16367 @noindent
16368 This package provides a set of stream subprograms for standard string types.
16369 It is intended primarily to support implicit use of such subprograms when
16370 stream attributes are applied to string types, but the subprograms in this
16371 package can be used directly by application programs.
16372
16373 @node System.Task_Info (s-tasinf.ads)
16374 @section @code{System.Task_Info} (@file{s-tasinf.ads})
16375 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
16376 @cindex Task_Info pragma
16377
16378 @noindent
16379 This package provides target dependent functionality that is used
16380 to support the @code{Task_Info} pragma
16381
16382 @node System.Wch_Cnv (s-wchcnv.ads)
16383 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16384 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
16385 @cindex Wide Character, Representation
16386 @cindex Wide String, Conversion
16387 @cindex Representation of wide characters
16388
16389 @noindent
16390 This package provides routines for converting between
16391 wide and wide wide characters and a representation as a value of type
16392 @code{Standard.String}, using a specified wide character
16393 encoding method. It uses definitions in
16394 package @code{System.Wch_Con}.
16395
16396 @node System.Wch_Con (s-wchcon.ads)
16397 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
16398 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
16399
16400 @noindent
16401 This package provides definitions and descriptions of
16402 the various methods used for encoding wide characters
16403 in ordinary strings. These definitions are used by
16404 the package @code{System.Wch_Cnv}.
16405
16406 @node Interfacing to Other Languages
16407 @chapter Interfacing to Other Languages
16408 @noindent
16409 The facilities in annex B of the Ada Reference Manual are fully
16410 implemented in GNAT, and in addition, a full interface to C++ is
16411 provided.
16412
16413 @menu
16414 * Interfacing to C::
16415 * Interfacing to C++::
16416 * Interfacing to COBOL::
16417 * Interfacing to Fortran::
16418 * Interfacing to non-GNAT Ada code::
16419 @end menu
16420
16421 @node Interfacing to C
16422 @section Interfacing to C
16423
16424 @noindent
16425 Interfacing to C with GNAT can use one of two approaches:
16426
16427 @itemize @bullet
16428 @item
16429 The types in the package @code{Interfaces.C} may be used.
16430 @item
16431 Standard Ada types may be used directly. This may be less portable to
16432 other compilers, but will work on all GNAT compilers, which guarantee
16433 correspondence between the C and Ada types.
16434 @end itemize
16435
16436 @noindent
16437 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
16438 effect, since this is the default. The following table shows the
16439 correspondence between Ada scalar types and the corresponding C types.
16440
16441 @table @code
16442 @item Integer
16443 @code{int}
16444 @item Short_Integer
16445 @code{short}
16446 @item Short_Short_Integer
16447 @code{signed char}
16448 @item Long_Integer
16449 @code{long}
16450 @item Long_Long_Integer
16451 @code{long long}
16452 @item Short_Float
16453 @code{float}
16454 @item Float
16455 @code{float}
16456 @item Long_Float
16457 @code{double}
16458 @item Long_Long_Float
16459 This is the longest floating-point type supported by the hardware.
16460 @end table
16461
16462 @noindent
16463 Additionally, there are the following general correspondences between Ada
16464 and C types:
16465 @itemize @bullet
16466 @item
16467 Ada enumeration types map to C enumeration types directly if pragma
16468 @code{Convention C} is specified, which causes them to have int
16469 length. Without pragma @code{Convention C}, Ada enumeration types map to
16470 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
16471 @code{int}, respectively) depending on the number of values passed.
16472 This is the only case in which pragma @code{Convention C} affects the
16473 representation of an Ada type.
16474
16475 @item
16476 Ada access types map to C pointers, except for the case of pointers to
16477 unconstrained types in Ada, which have no direct C equivalent.
16478
16479 @item
16480 Ada arrays map directly to C arrays.
16481
16482 @item
16483 Ada records map directly to C structures.
16484
16485 @item
16486 Packed Ada records map to C structures where all members are bit fields
16487 of the length corresponding to the @code{@var{type}'Size} value in Ada.
16488 @end itemize
16489
16490 @node Interfacing to C++
16491 @section Interfacing to C++
16492
16493 @noindent
16494 The interface to C++ makes use of the following pragmas, which are
16495 primarily intended to be constructed automatically using a binding generator
16496 tool, although it is possible to construct them by hand. No suitable binding
16497 generator tool is supplied with GNAT though.
16498
16499 Using these pragmas it is possible to achieve complete
16500 inter-operability between Ada tagged types and C++ class definitions.
16501 See @ref{Implementation Defined Pragmas}, for more details.
16502
16503 @table @code
16504 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
16505 The argument denotes an entity in the current declarative region that is
16506 declared as a tagged or untagged record type. It indicates that the type
16507 corresponds to an externally declared C++ class type, and is to be laid
16508 out the same way that C++ would lay out the type.
16509
16510 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
16511 for backward compatibility but its functionality is available
16512 using pragma @code{Import} with @code{Convention} = @code{CPP}.
16513
16514 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
16515 This pragma identifies an imported function (imported in the usual way
16516 with pragma @code{Import}) as corresponding to a C++ constructor.
16517 @end table
16518
16519 @node Interfacing to COBOL
16520 @section Interfacing to COBOL
16521
16522 @noindent
16523 Interfacing to COBOL is achieved as described in section B.4 of
16524 the Ada Reference Manual.
16525
16526 @node Interfacing to Fortran
16527 @section Interfacing to Fortran
16528
16529 @noindent
16530 Interfacing to Fortran is achieved as described in section B.5 of the
16531 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
16532 multi-dimensional array causes the array to be stored in column-major
16533 order as required for convenient interface to Fortran.
16534
16535 @node Interfacing to non-GNAT Ada code
16536 @section Interfacing to non-GNAT Ada code
16537
16538 It is possible to specify the convention @code{Ada} in a pragma
16539 @code{Import} or pragma @code{Export}. However this refers to
16540 the calling conventions used by GNAT, which may or may not be
16541 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
16542 compiler to allow interoperation.
16543
16544 If arguments types are kept simple, and if the foreign compiler generally
16545 follows system calling conventions, then it may be possible to integrate
16546 files compiled by other Ada compilers, provided that the elaboration
16547 issues are adequately addressed (for example by eliminating the
16548 need for any load time elaboration).
16549
16550 In particular, GNAT running on VMS is designed to
16551 be highly compatible with the DEC Ada 83 compiler, so this is one
16552 case in which it is possible to import foreign units of this type,
16553 provided that the data items passed are restricted to simple scalar
16554 values or simple record types without variants, or simple array
16555 types with fixed bounds.
16556
16557 @node Specialized Needs Annexes
16558 @chapter Specialized Needs Annexes
16559
16560 @noindent
16561 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
16562 required in all implementations. However, as described in this chapter,
16563 GNAT implements all of these annexes:
16564
16565 @table @asis
16566 @item Systems Programming (Annex C)
16567 The Systems Programming Annex is fully implemented.
16568
16569 @item Real-Time Systems (Annex D)
16570 The Real-Time Systems Annex is fully implemented.
16571
16572 @item Distributed Systems (Annex E)
16573 Stub generation is fully implemented in the GNAT compiler. In addition,
16574 a complete compatible PCS is available as part of the GLADE system,
16575 a separate product. When the two
16576 products are used in conjunction, this annex is fully implemented.
16577
16578 @item Information Systems (Annex F)
16579 The Information Systems annex is fully implemented.
16580
16581 @item Numerics (Annex G)
16582 The Numerics Annex is fully implemented.
16583
16584 @item Safety and Security / High-Integrity Systems (Annex H)
16585 The Safety and Security Annex (termed the High-Integrity Systems Annex
16586 in Ada 2005) is fully implemented.
16587 @end table
16588
16589 @node Implementation of Specific Ada Features
16590 @chapter Implementation of Specific Ada Features
16591
16592 @noindent
16593 This chapter describes the GNAT implementation of several Ada language
16594 facilities.
16595
16596 @menu
16597 * Machine Code Insertions::
16598 * GNAT Implementation of Tasking::
16599 * GNAT Implementation of Shared Passive Packages::
16600 * Code Generation for Array Aggregates::
16601 * The Size of Discriminated Records with Default Discriminants::
16602 * Strict Conformance to the Ada Reference Manual::
16603 @end menu
16604
16605 @node Machine Code Insertions
16606 @section Machine Code Insertions
16607 @cindex Machine Code insertions
16608
16609 @noindent
16610 Package @code{Machine_Code} provides machine code support as described
16611 in the Ada Reference Manual in two separate forms:
16612 @itemize @bullet
16613 @item
16614 Machine code statements, consisting of qualified expressions that
16615 fit the requirements of RM section 13.8.
16616 @item
16617 An intrinsic callable procedure, providing an alternative mechanism of
16618 including machine instructions in a subprogram.
16619 @end itemize
16620
16621 @noindent
16622 The two features are similar, and both are closely related to the mechanism
16623 provided by the asm instruction in the GNU C compiler. Full understanding
16624 and use of the facilities in this package requires understanding the asm
16625 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16626 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16627
16628 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16629 semantic restrictions and effects as described below. Both are provided so
16630 that the procedure call can be used as a statement, and the function call
16631 can be used to form a code_statement.
16632
16633 The first example given in the GCC documentation is the C @code{asm}
16634 instruction:
16635 @smallexample
16636 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16637 @end smallexample
16638
16639 @noindent
16640 The equivalent can be written for GNAT as:
16641
16642 @smallexample @c ada
16643 Asm ("fsinx %1 %0",
16644 My_Float'Asm_Output ("=f", result),
16645 My_Float'Asm_Input ("f", angle));
16646 @end smallexample
16647
16648 @noindent
16649 The first argument to @code{Asm} is the assembler template, and is
16650 identical to what is used in GNU C@. This string must be a static
16651 expression. The second argument is the output operand list. It is
16652 either a single @code{Asm_Output} attribute reference, or a list of such
16653 references enclosed in parentheses (technically an array aggregate of
16654 such references).
16655
16656 The @code{Asm_Output} attribute denotes a function that takes two
16657 parameters. The first is a string, the second is the name of a variable
16658 of the type designated by the attribute prefix. The first (string)
16659 argument is required to be a static expression and designates the
16660 constraint for the parameter (e.g.@: what kind of register is
16661 required). The second argument is the variable to be updated with the
16662 result. The possible values for constraint are the same as those used in
16663 the RTL, and are dependent on the configuration file used to build the
16664 GCC back end. If there are no output operands, then this argument may
16665 either be omitted, or explicitly given as @code{No_Output_Operands}.
16666
16667 The second argument of @code{@var{my_float}'Asm_Output} functions as
16668 though it were an @code{out} parameter, which is a little curious, but
16669 all names have the form of expressions, so there is no syntactic
16670 irregularity, even though normally functions would not be permitted
16671 @code{out} parameters. The third argument is the list of input
16672 operands. It is either a single @code{Asm_Input} attribute reference, or
16673 a list of such references enclosed in parentheses (technically an array
16674 aggregate of such references).
16675
16676 The @code{Asm_Input} attribute denotes a function that takes two
16677 parameters. The first is a string, the second is an expression of the
16678 type designated by the prefix. The first (string) argument is required
16679 to be a static expression, and is the constraint for the parameter,
16680 (e.g.@: what kind of register is required). The second argument is the
16681 value to be used as the input argument. The possible values for the
16682 constant are the same as those used in the RTL, and are dependent on
16683 the configuration file used to built the GCC back end.
16684
16685 If there are no input operands, this argument may either be omitted, or
16686 explicitly given as @code{No_Input_Operands}. The fourth argument, not
16687 present in the above example, is a list of register names, called the
16688 @dfn{clobber} argument. This argument, if given, must be a static string
16689 expression, and is a space or comma separated list of names of registers
16690 that must be considered destroyed as a result of the @code{Asm} call. If
16691 this argument is the null string (the default value), then the code
16692 generator assumes that no additional registers are destroyed.
16693
16694 The fifth argument, not present in the above example, called the
16695 @dfn{volatile} argument, is by default @code{False}. It can be set to
16696 the literal value @code{True} to indicate to the code generator that all
16697 optimizations with respect to the instruction specified should be
16698 suppressed, and that in particular, for an instruction that has outputs,
16699 the instruction will still be generated, even if none of the outputs are
16700 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16701 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16702 Generally it is strongly advisable to use Volatile for any ASM statement
16703 that is missing either input or output operands, or when two or more ASM
16704 statements appear in sequence, to avoid unwanted optimizations. A warning
16705 is generated if this advice is not followed.
16706
16707 The @code{Asm} subprograms may be used in two ways. First the procedure
16708 forms can be used anywhere a procedure call would be valid, and
16709 correspond to what the RM calls ``intrinsic'' routines. Such calls can
16710 be used to intersperse machine instructions with other Ada statements.
16711 Second, the function forms, which return a dummy value of the limited
16712 private type @code{Asm_Insn}, can be used in code statements, and indeed
16713 this is the only context where such calls are allowed. Code statements
16714 appear as aggregates of the form:
16715
16716 @smallexample @c ada
16717 Asm_Insn'(Asm (@dots{}));
16718 Asm_Insn'(Asm_Volatile (@dots{}));
16719 @end smallexample
16720
16721 @noindent
16722 In accordance with RM rules, such code statements are allowed only
16723 within subprograms whose entire body consists of such statements. It is
16724 not permissible to intermix such statements with other Ada statements.
16725
16726 Typically the form using intrinsic procedure calls is more convenient
16727 and more flexible. The code statement form is provided to meet the RM
16728 suggestion that such a facility should be made available. The following
16729 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16730 is used, the arguments may be given in arbitrary order, following the
16731 normal rules for use of positional and named arguments)
16732
16733 @smallexample
16734 ASM_CALL ::= Asm (
16735 [Template =>] static_string_EXPRESSION
16736 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
16737 [,[Inputs =>] INPUT_OPERAND_LIST ]
16738 [,[Clobber =>] static_string_EXPRESSION ]
16739 [,[Volatile =>] static_boolean_EXPRESSION] )
16740
16741 OUTPUT_OPERAND_LIST ::=
16742 [PREFIX.]No_Output_Operands
16743 | OUTPUT_OPERAND_ATTRIBUTE
16744 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16745
16746 OUTPUT_OPERAND_ATTRIBUTE ::=
16747 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16748
16749 INPUT_OPERAND_LIST ::=
16750 [PREFIX.]No_Input_Operands
16751 | INPUT_OPERAND_ATTRIBUTE
16752 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16753
16754 INPUT_OPERAND_ATTRIBUTE ::=
16755 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16756 @end smallexample
16757
16758 @noindent
16759 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16760 are declared in the package @code{Machine_Code} and must be referenced
16761 according to normal visibility rules. In particular if there is no
16762 @code{use} clause for this package, then appropriate package name
16763 qualification is required.
16764
16765 @node GNAT Implementation of Tasking
16766 @section GNAT Implementation of Tasking
16767
16768 @noindent
16769 This chapter outlines the basic GNAT approach to tasking (in particular,
16770 a multi-layered library for portability) and discusses issues related
16771 to compliance with the Real-Time Systems Annex.
16772
16773 @menu
16774 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16775 * Ensuring Compliance with the Real-Time Annex::
16776 @end menu
16777
16778 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16779 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16780
16781 @noindent
16782 GNAT's run-time support comprises two layers:
16783
16784 @itemize @bullet
16785 @item GNARL (GNAT Run-time Layer)
16786 @item GNULL (GNAT Low-level Library)
16787 @end itemize
16788
16789 @noindent
16790 In GNAT, Ada's tasking services rely on a platform and OS independent
16791 layer known as GNARL@. This code is responsible for implementing the
16792 correct semantics of Ada's task creation, rendezvous, protected
16793 operations etc.
16794
16795 GNARL decomposes Ada's tasking semantics into simpler lower level
16796 operations such as create a thread, set the priority of a thread,
16797 yield, create a lock, lock/unlock, etc. The spec for these low-level
16798 operations constitutes GNULLI, the GNULL Interface. This interface is
16799 directly inspired from the POSIX real-time API@.
16800
16801 If the underlying executive or OS implements the POSIX standard
16802 faithfully, the GNULL Interface maps as is to the services offered by
16803 the underlying kernel. Otherwise, some target dependent glue code maps
16804 the services offered by the underlying kernel to the semantics expected
16805 by GNARL@.
16806
16807 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16808 key point is that each Ada task is mapped on a thread in the underlying
16809 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
16810
16811 In addition Ada task priorities map onto the underlying thread priorities.
16812 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16813
16814 @itemize @bullet
16815 @item
16816 The underlying scheduler is used to schedule the Ada tasks. This
16817 makes Ada tasks as efficient as kernel threads from a scheduling
16818 standpoint.
16819
16820 @item
16821 Interaction with code written in C containing threads is eased
16822 since at the lowest level Ada tasks and C threads map onto the same
16823 underlying kernel concept.
16824
16825 @item
16826 When an Ada task is blocked during I/O the remaining Ada tasks are
16827 able to proceed.
16828
16829 @item
16830 On multiprocessor systems Ada tasks can execute in parallel.
16831 @end itemize
16832
16833 @noindent
16834 Some threads libraries offer a mechanism to fork a new process, with the
16835 child process duplicating the threads from the parent.
16836 GNAT does not
16837 support this functionality when the parent contains more than one task.
16838 @cindex Forking a new process
16839
16840 @node Ensuring Compliance with the Real-Time Annex
16841 @subsection Ensuring Compliance with the Real-Time Annex
16842 @cindex Real-Time Systems Annex compliance
16843
16844 @noindent
16845 Although mapping Ada tasks onto
16846 the underlying threads has significant advantages, it does create some
16847 complications when it comes to respecting the scheduling semantics
16848 specified in the real-time annex (Annex D).
16849
16850 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16851 scheduling policy states:
16852
16853 @quotation
16854 @emph{When the active priority of a ready task that is not running
16855 changes, or the setting of its base priority takes effect, the
16856 task is removed from the ready queue for its old active priority
16857 and is added at the tail of the ready queue for its new active
16858 priority, except in the case where the active priority is lowered
16859 due to the loss of inherited priority, in which case the task is
16860 added at the head of the ready queue for its new active priority.}
16861 @end quotation
16862
16863 @noindent
16864 While most kernels do put tasks at the end of the priority queue when
16865 a task changes its priority, (which respects the main
16866 FIFO_Within_Priorities requirement), almost none keep a thread at the
16867 beginning of its priority queue when its priority drops from the loss
16868 of inherited priority.
16869
16870 As a result most vendors have provided incomplete Annex D implementations.
16871
16872 The GNAT run-time, has a nice cooperative solution to this problem
16873 which ensures that accurate FIFO_Within_Priorities semantics are
16874 respected.
16875
16876 The principle is as follows. When an Ada task T is about to start
16877 running, it checks whether some other Ada task R with the same
16878 priority as T has been suspended due to the loss of priority
16879 inheritance. If this is the case, T yields and is placed at the end of
16880 its priority queue. When R arrives at the front of the queue it
16881 executes.
16882
16883 Note that this simple scheme preserves the relative order of the tasks
16884 that were ready to execute in the priority queue where R has been
16885 placed at the end.
16886
16887 @node GNAT Implementation of Shared Passive Packages
16888 @section GNAT Implementation of Shared Passive Packages
16889 @cindex Shared passive packages
16890
16891 @noindent
16892 GNAT fully implements the pragma @code{Shared_Passive} for
16893 @cindex pragma @code{Shared_Passive}
16894 the purpose of designating shared passive packages.
16895 This allows the use of passive partitions in the
16896 context described in the Ada Reference Manual; i.e., for communication
16897 between separate partitions of a distributed application using the
16898 features in Annex E.
16899 @cindex Annex E
16900 @cindex Distribution Systems Annex
16901
16902 However, the implementation approach used by GNAT provides for more
16903 extensive usage as follows:
16904
16905 @table @emph
16906 @item Communication between separate programs
16907
16908 This allows separate programs to access the data in passive
16909 partitions, using protected objects for synchronization where
16910 needed. The only requirement is that the two programs have a
16911 common shared file system. It is even possible for programs
16912 running on different machines with different architectures
16913 (e.g.@: different endianness) to communicate via the data in
16914 a passive partition.
16915
16916 @item Persistence between program runs
16917
16918 The data in a passive package can persist from one run of a
16919 program to another, so that a later program sees the final
16920 values stored by a previous run of the same program.
16921
16922 @end table
16923
16924 @noindent
16925 The implementation approach used is to store the data in files. A
16926 separate stream file is created for each object in the package, and
16927 an access to an object causes the corresponding file to be read or
16928 written.
16929
16930 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16931 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16932 set to the directory to be used for these files.
16933 The files in this directory
16934 have names that correspond to their fully qualified names. For
16935 example, if we have the package
16936
16937 @smallexample @c ada
16938 package X is
16939 pragma Shared_Passive (X);
16940 Y : Integer;
16941 Z : Float;
16942 end X;
16943 @end smallexample
16944
16945 @noindent
16946 and the environment variable is set to @code{/stemp/}, then the files created
16947 will have the names:
16948
16949 @smallexample
16950 /stemp/x.y
16951 /stemp/x.z
16952 @end smallexample
16953
16954 @noindent
16955 These files are created when a value is initially written to the object, and
16956 the files are retained until manually deleted. This provides the persistence
16957 semantics. If no file exists, it means that no partition has assigned a value
16958 to the variable; in this case the initial value declared in the package
16959 will be used. This model ensures that there are no issues in synchronizing
16960 the elaboration process, since elaboration of passive packages elaborates the
16961 initial values, but does not create the files.
16962
16963 The files are written using normal @code{Stream_IO} access.
16964 If you want to be able
16965 to communicate between programs or partitions running on different
16966 architectures, then you should use the XDR versions of the stream attribute
16967 routines, since these are architecture independent.
16968
16969 If active synchronization is required for access to the variables in the
16970 shared passive package, then as described in the Ada Reference Manual, the
16971 package may contain protected objects used for this purpose. In this case
16972 a lock file (whose name is @file{___lock} (three underscores)
16973 is created in the shared memory directory.
16974 @cindex @file{___lock} file (for shared passive packages)
16975 This is used to provide the required locking
16976 semantics for proper protected object synchronization.
16977
16978 As of January 2003, GNAT supports shared passive packages on all platforms
16979 except for OpenVMS.
16980
16981 @node Code Generation for Array Aggregates
16982 @section Code Generation for Array Aggregates
16983
16984 @menu
16985 * Static constant aggregates with static bounds::
16986 * Constant aggregates with unconstrained nominal types::
16987 * Aggregates with static bounds::
16988 * Aggregates with non-static bounds::
16989 * Aggregates in assignment statements::
16990 @end menu
16991
16992 @noindent
16993 Aggregates have a rich syntax and allow the user to specify the values of
16994 complex data structures by means of a single construct. As a result, the
16995 code generated for aggregates can be quite complex and involve loops, case
16996 statements and multiple assignments. In the simplest cases, however, the
16997 compiler will recognize aggregates whose components and constraints are
16998 fully static, and in those cases the compiler will generate little or no
16999 executable code. The following is an outline of the code that GNAT generates
17000 for various aggregate constructs. For further details, you will find it
17001 useful to examine the output produced by the -gnatG flag to see the expanded
17002 source that is input to the code generator. You may also want to examine
17003 the assembly code generated at various levels of optimization.
17004
17005 The code generated for aggregates depends on the context, the component values,
17006 and the type. In the context of an object declaration the code generated is
17007 generally simpler than in the case of an assignment. As a general rule, static
17008 component values and static subtypes also lead to simpler code.
17009
17010 @node Static constant aggregates with static bounds
17011 @subsection Static constant aggregates with static bounds
17012
17013 @noindent
17014 For the declarations:
17015 @smallexample @c ada
17016 type One_Dim is array (1..10) of integer;
17017 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17018 @end smallexample
17019
17020 @noindent
17021 GNAT generates no executable code: the constant ar0 is placed in static memory.
17022 The same is true for constant aggregates with named associations:
17023
17024 @smallexample @c ada
17025 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17026 Cr3 : constant One_Dim := (others => 7777);
17027 @end smallexample
17028
17029 @noindent
17030 The same is true for multidimensional constant arrays such as:
17031
17032 @smallexample @c ada
17033 type two_dim is array (1..3, 1..3) of integer;
17034 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17035 @end smallexample
17036
17037 @noindent
17038 The same is true for arrays of one-dimensional arrays: the following are
17039 static:
17040
17041 @smallexample @c ada
17042 type ar1b is array (1..3) of boolean;
17043 type ar_ar is array (1..3) of ar1b;
17044 None : constant ar1b := (others => false); -- fully static
17045 None2 : constant ar_ar := (1..3 => None); -- fully static
17046 @end smallexample
17047
17048 @noindent
17049 However, for multidimensional aggregates with named associations, GNAT will
17050 generate assignments and loops, even if all associations are static. The
17051 following two declarations generate a loop for the first dimension, and
17052 individual component assignments for the second dimension:
17053
17054 @smallexample @c ada
17055 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17056 Zero2: constant two_dim := (others => (others => 0));
17057 @end smallexample
17058
17059 @node Constant aggregates with unconstrained nominal types
17060 @subsection Constant aggregates with unconstrained nominal types
17061
17062 @noindent
17063 In such cases the aggregate itself establishes the subtype, so that
17064 associations with @code{others} cannot be used. GNAT determines the
17065 bounds for the actual subtype of the aggregate, and allocates the
17066 aggregate statically as well. No code is generated for the following:
17067
17068 @smallexample @c ada
17069 type One_Unc is array (natural range <>) of integer;
17070 Cr_Unc : constant One_Unc := (12,24,36);
17071 @end smallexample
17072
17073 @node Aggregates with static bounds
17074 @subsection Aggregates with static bounds
17075
17076 @noindent
17077 In all previous examples the aggregate was the initial (and immutable) value
17078 of a constant. If the aggregate initializes a variable, then code is generated
17079 for it as a combination of individual assignments and loops over the target
17080 object. The declarations
17081
17082 @smallexample @c ada
17083 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17084 Cr_Var2 : One_Dim := (others > -1);
17085 @end smallexample
17086
17087 @noindent
17088 generate the equivalent of
17089
17090 @smallexample @c ada
17091 Cr_Var1 (1) := 2;
17092 Cr_Var1 (2) := 3;
17093 Cr_Var1 (3) := 5;
17094 Cr_Var1 (4) := 11;
17095
17096 for I in Cr_Var2'range loop
17097 Cr_Var2 (I) := -1;
17098 end loop;
17099 @end smallexample
17100
17101 @node Aggregates with non-static bounds
17102 @subsection Aggregates with non-static bounds
17103
17104 @noindent
17105 If the bounds of the aggregate are not statically compatible with the bounds
17106 of the nominal subtype of the target, then constraint checks have to be
17107 generated on the bounds. For a multidimensional array, constraint checks may
17108 have to be applied to sub-arrays individually, if they do not have statically
17109 compatible subtypes.
17110
17111 @node Aggregates in assignment statements
17112 @subsection Aggregates in assignment statements
17113
17114 @noindent
17115 In general, aggregate assignment requires the construction of a temporary,
17116 and a copy from the temporary to the target of the assignment. This is because
17117 it is not always possible to convert the assignment into a series of individual
17118 component assignments. For example, consider the simple case:
17119
17120 @smallexample @c ada
17121 A := (A(2), A(1));
17122 @end smallexample
17123
17124 @noindent
17125 This cannot be converted into:
17126
17127 @smallexample @c ada
17128 A(1) := A(2);
17129 A(2) := A(1);
17130 @end smallexample
17131
17132 @noindent
17133 So the aggregate has to be built first in a separate location, and then
17134 copied into the target. GNAT recognizes simple cases where this intermediate
17135 step is not required, and the assignments can be performed in place, directly
17136 into the target. The following sufficient criteria are applied:
17137
17138 @itemize @bullet
17139 @item
17140 The bounds of the aggregate are static, and the associations are static.
17141 @item
17142 The components of the aggregate are static constants, names of
17143 simple variables that are not renamings, or expressions not involving
17144 indexed components whose operands obey these rules.
17145 @end itemize
17146
17147 @noindent
17148 If any of these conditions are violated, the aggregate will be built in
17149 a temporary (created either by the front-end or the code generator) and then
17150 that temporary will be copied onto the target.
17151
17152 @node The Size of Discriminated Records with Default Discriminants
17153 @section The Size of Discriminated Records with Default Discriminants
17154
17155 @noindent
17156 If a discriminated type @code{T} has discriminants with default values, it is
17157 possible to declare an object of this type without providing an explicit
17158 constraint:
17159
17160 @smallexample @c ada
17161 @group
17162 type Size is range 1..100;
17163
17164 type Rec (D : Size := 15) is record
17165 Name : String (1..D);
17166 end T;
17167
17168 Word : Rec;
17169 @end group
17170 @end smallexample
17171
17172 @noindent
17173 Such an object is said to be @emph{unconstrained}.
17174 The discriminant of the object
17175 can be modified by a full assignment to the object, as long as it preserves the
17176 relation between the value of the discriminant, and the value of the components
17177 that depend on it:
17178
17179 @smallexample @c ada
17180 @group
17181 Word := (3, "yes");
17182
17183 Word := (5, "maybe");
17184
17185 Word := (5, "no"); -- raises Constraint_Error
17186 @end group
17187 @end smallexample
17188
17189 @noindent
17190 In order to support this behavior efficiently, an unconstrained object is
17191 given the maximum size that any value of the type requires. In the case
17192 above, @code{Word} has storage for the discriminant and for
17193 a @code{String} of length 100.
17194 It is important to note that unconstrained objects do not require dynamic
17195 allocation. It would be an improper implementation to place on the heap those
17196 components whose size depends on discriminants. (This improper implementation
17197 was used by some Ada83 compilers, where the @code{Name} component above
17198 would have
17199 been stored as a pointer to a dynamic string). Following the principle that
17200 dynamic storage management should never be introduced implicitly,
17201 an Ada compiler should reserve the full size for an unconstrained declared
17202 object, and place it on the stack.
17203
17204 This maximum size approach
17205 has been a source of surprise to some users, who expect the default
17206 values of the discriminants to determine the size reserved for an
17207 unconstrained object: ``If the default is 15, why should the object occupy
17208 a larger size?''
17209 The answer, of course, is that the discriminant may be later modified,
17210 and its full range of values must be taken into account. This is why the
17211 declaration:
17212
17213 @smallexample
17214 @group
17215 type Rec (D : Positive := 15) is record
17216 Name : String (1..D);
17217 end record;
17218
17219 Too_Large : Rec;
17220 @end group
17221 @end smallexample
17222
17223 @noindent
17224 is flagged by the compiler with a warning:
17225 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17226 because the required size includes @code{Positive'Last}
17227 bytes. As the first example indicates, the proper approach is to declare an
17228 index type of ``reasonable'' range so that unconstrained objects are not too
17229 large.
17230
17231 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17232 created in the heap by means of an allocator, then it is @emph{not}
17233 unconstrained:
17234 it is constrained by the default values of the discriminants, and those values
17235 cannot be modified by full assignment. This is because in the presence of
17236 aliasing all views of the object (which may be manipulated by different tasks,
17237 say) must be consistent, so it is imperative that the object, once created,
17238 remain invariant.
17239
17240 @node Strict Conformance to the Ada Reference Manual
17241 @section Strict Conformance to the Ada Reference Manual
17242
17243 @noindent
17244 The dynamic semantics defined by the Ada Reference Manual impose a set of
17245 run-time checks to be generated. By default, the GNAT compiler will insert many
17246 run-time checks into the compiled code, including most of those required by the
17247 Ada Reference Manual. However, there are three checks that are not enabled
17248 in the default mode for efficiency reasons: arithmetic overflow checking for
17249 integer operations (including division by zero), checks for access before
17250 elaboration on subprogram calls, and stack overflow checking (most operating
17251 systems do not perform this check by default).
17252
17253 Strict conformance to the Ada Reference Manual can be achieved by adding
17254 three compiler options for overflow checking for integer operations
17255 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17256 calls and generic instantiations (@option{-gnatE}), and stack overflow
17257 checking (@option{-fstack-check}).
17258
17259 Note that the result of a floating point arithmetic operation in overflow and
17260 invalid situations, when the @code{Machine_Overflows} attribute of the result
17261 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17262 case for machines compliant with the IEEE floating-point standard, but on
17263 machines that are not fully compliant with this standard, such as Alpha, the
17264 @option{-mieee} compiler flag must be used for achieving IEEE confirming
17265 behavior (although at the cost of a significant performance penalty), so
17266 infinite and NaN values are properly generated.
17267
17268
17269 @node Implementation of Ada 2012 Features
17270 @chapter Implementation of Ada 2012 Features
17271 @cindex Ada 2012 implementation status
17272
17273 This chapter contains a complete list of Ada 2012 features that have been
17274 implemented as of GNAT version 6.4. Generally, these features are only
17275 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
17276 @cindex @option{-gnat12} option
17277 or if the configuration pragma @code{Ada_2012} is used.
17278 @cindex pragma @code{Ada_2012}
17279 @cindex configuration pragma @code{Ada_2012}
17280 @cindex @code{Ada_2012} configuration pragma
17281 However, new pragmas, attributes, and restrictions are
17282 unconditionally available, since the Ada 95 standard allows the addition of
17283 new pragmas, attributes, and restrictions (there are exceptions, which are
17284 documented in the individual descriptions), and also certain packages
17285 were made available in earlier versions of Ada.
17286
17287 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
17288 This date shows the implementation date of the feature. Any wavefront
17289 subsequent to this date will contain the indicated feature, as will any
17290 subsequent releases. A date of 0000-00-00 means that GNAT has always
17291 implemented the feature, or implemented it as soon as it appeared as a
17292 binding interpretation.
17293
17294 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
17295 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
17296 The features are ordered based on the relevant sections of the Ada
17297 Reference Manual (``RM''). When a given AI relates to multiple points
17298 in the RM, the earliest is used.
17299
17300 A complete description of the AIs may be found in
17301 @url{www.ada-auth.org/ai05-summary.html}.
17302
17303 @itemize @bullet
17304
17305 @item
17306 @emph{AI-0176 Quantified expressions (2010-09-29)}
17307 @cindex AI-0176 (Ada 2012 feature)
17308
17309 @noindent
17310 Both universally and existentially quantified expressions are implemented.
17311 They use the new syntax for iterators proposed in AI05-139-2, as well as
17312 the standard Ada loop syntax.
17313
17314 @noindent
17315 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
17316
17317 @item
17318 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
17319 @cindex AI-0079 (Ada 2012 feature)
17320
17321 @noindent
17322 Wide characters in the unicode category @i{other_format} are now allowed in
17323 source programs between tokens, but not within a token such as an identifier.
17324
17325 @noindent
17326 RM References: 2.01 (4/2) 2.02 (7)
17327
17328 @item
17329 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
17330 @cindex AI-0091 (Ada 2012 feature)
17331
17332 @noindent
17333 Wide characters in the unicode category @i{other_format} are not permitted
17334 within an identifier, since this can be a security problem. The error
17335 message for this case has been improved to be more specific, but GNAT has
17336 never allowed such characters to appear in identifiers.
17337
17338 @noindent
17339 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)
17340
17341 @item
17342 @emph{AI-0100 Placement of pragmas (2010-07-01)}
17343 @cindex AI-0100 (Ada 2012 feature)
17344
17345 @noindent
17346 This AI is an earlier version of AI-163. It simplifies the rules
17347 for legal placement of pragmas. In the case of lists that allow pragmas, if
17348 the list may have no elements, then the list may consist solely of pragmas.
17349
17350 @noindent
17351 RM References: 2.08 (7)
17352
17353 @item
17354 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
17355 @cindex AI-0163 (Ada 2012 feature)
17356
17357 @noindent
17358 A statement sequence may be composed entirely of pragmas. It is no longer
17359 necessary to add a dummy @code{null} statement to make the sequence legal.
17360
17361 @noindent
17362 RM References: 2.08 (7) 2.08 (16)
17363
17364
17365 @item
17366 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
17367 @cindex AI-0080 (Ada 2012 feature)
17368
17369 @noindent
17370 This is an editorial change only, described as non-testable in the AI.
17371
17372 @noindent
17373 RM References: 3.01 (7)
17374
17375
17376 @item
17377 @emph{AI-0183 Aspect specifications (2010-08-16)}
17378 @cindex AI-0183 (Ada 2012 feature)
17379
17380 @noindent
17381 Aspect specifications have been fully implemented except for pre and post-
17382 conditions, and type invariants, which have their own separate AI's. All
17383 forms of declarations listed in the AI are supported. The following is a
17384 list of the aspects supported (with GNAT implementation aspects marked)
17385
17386 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
17387 @item @code{Ada_2005} @tab -- GNAT
17388 @item @code{Ada_2012} @tab -- GNAT
17389 @item @code{Address} @tab
17390 @item @code{Alignment} @tab
17391 @item @code{Atomic} @tab
17392 @item @code{Atomic_Components} @tab
17393 @item @code{Bit_Order} @tab
17394 @item @code{Component_Size} @tab
17395 @item @code{Discard_Names} @tab
17396 @item @code{External_Tag} @tab
17397 @item @code{Favor_Top_Level} @tab -- GNAT
17398 @item @code{Inline} @tab
17399 @item @code{Inline_Always} @tab -- GNAT
17400 @item @code{Invariant} @tab
17401 @item @code{Machine_Radix} @tab
17402 @item @code{No_Return} @tab
17403 @item @code{Object_Size} @tab -- GNAT
17404 @item @code{Pack} @tab
17405 @item @code{Persistent_BSS} @tab -- GNAT
17406 @item @code{Post} @tab
17407 @item @code{Pre} @tab
17408 @item @code{Predicate} @tab
17409 @item @code{Preelaborable_Initialization} @tab
17410 @item @code{Pure_Function} @tab -- GNAT
17411 @item @code{Remote_Access_Type} @tab -- GNAT
17412 @item @code{Shared} @tab -- GNAT
17413 @item @code{Size} @tab
17414 @item @code{Storage_Pool} @tab
17415 @item @code{Storage_Size} @tab
17416 @item @code{Stream_Size} @tab
17417 @item @code{Suppress} @tab
17418 @item @code{Suppress_Debug_Info} @tab -- GNAT
17419 @item @code{Test_Case} @tab -- GNAT
17420 @item @code{Unchecked_Union} @tab
17421 @item @code{Universal_Aliasing} @tab -- GNAT
17422 @item @code{Unmodified} @tab -- GNAT
17423 @item @code{Unreferenced} @tab -- GNAT
17424 @item @code{Unreferenced_Objects} @tab -- GNAT
17425 @item @code{Unsuppress} @tab
17426 @item @code{Value_Size} @tab -- GNAT
17427 @item @code{Volatile} @tab
17428 @item @code{Volatile_Components}
17429 @item @code{Warnings} @tab -- GNAT
17430 @end multitable
17431
17432 @noindent
17433 Note that for aspects with an expression, e.g. @code{Size}, the expression is
17434 treated like a default expression (visibility is analyzed at the point of
17435 occurrence of the aspect, but evaluation of the expression occurs at the
17436 freeze point of the entity involved.
17437
17438 @noindent
17439 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
17440 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
17441 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
17442 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
17443 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
17444 13.03.01 (0)
17445
17446
17447 @item
17448 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
17449 @cindex AI-0128 (Ada 2012 feature)
17450
17451 @noindent
17452 If an equality operator ("=") is declared for a type, then the implicitly
17453 declared inequality operator ("/=") is a primitive operation of the type.
17454 This is the only reasonable interpretation, and is the one always implemented
17455 by GNAT, but the RM was not entirely clear in making this point.
17456
17457 @noindent
17458 RM References: 3.02.03 (6) 6.06 (6)
17459
17460 @item
17461 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
17462 @cindex AI-0003 (Ada 2012 feature)
17463
17464 @noindent
17465 In Ada 2012, a qualified expression is considered to be syntactically a name,
17466 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
17467 useful in disambiguating some cases of overloading.
17468
17469 @noindent
17470 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
17471 5.04 (7)
17472
17473 @item
17474 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
17475 @cindex AI-0120 (Ada 2012 feature)
17476
17477 @noindent
17478 This is an RM editorial change only. The section that lists objects that are
17479 constant failed to include the current instance of a protected object
17480 within a protected function. This has always been treated as a constant
17481 in GNAT.
17482
17483 @noindent
17484 RM References: 3.03 (21)
17485
17486 @item
17487 @emph{AI-0008 General access to constrained objects (0000-00-00)}
17488 @cindex AI-0008 (Ada 2012 feature)
17489
17490 @noindent
17491 The wording in the RM implied that if you have a general access to a
17492 constrained object, it could be used to modify the discriminants. This was
17493 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
17494 has always done so in this situation.
17495
17496 @noindent
17497 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
17498
17499
17500 @item
17501 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
17502 @cindex AI-0093 (Ada 2012 feature)
17503
17504 @noindent
17505 This is an editorial change only, to make more widespread use of the Ada 2012
17506 ``immutably limited''.
17507
17508 @noindent
17509 RM References: 3.03 (23.4/3)
17510
17511
17512
17513 @item
17514 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
17515 @cindex AI-0096 (Ada 2012 feature)
17516
17517 @noindent
17518 In general it is illegal for a type derived from a formal limited type to be
17519 nonlimited. This AI makes an exception to this rule: derivation is legal
17520 if it appears in the private part of the generic, and the formal type is not
17521 tagged. If the type is tagged, the legality check must be applied to the
17522 private part of the package.
17523
17524 @noindent
17525 RM References: 3.04 (5.1/2) 6.02 (7)
17526
17527
17528 @item
17529 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
17530 @cindex AI-0181 (Ada 2012 feature)
17531
17532 @noindent
17533 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
17534 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
17535 @code{Image} and @code{Value} attributes for the character types. Strictly
17536 speaking this is an inconsistency with Ada 95, but in practice the use of
17537 these attributes is so obscure that it will not cause problems.
17538
17539 @noindent
17540 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
17541
17542
17543 @item
17544 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
17545 @cindex AI-0182 (Ada 2012 feature)
17546
17547 @noindent
17548 This AI allows @code{Character'Value} to accept the string @code{'?'} where
17549 @code{?} is any character including non-graphic control characters. GNAT has
17550 always accepted such strings. It also allows strings such as
17551 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
17552 permission and raises @code{Constraint_Error}, as is certainly still
17553 permitted.
17554
17555 @noindent
17556 RM References: 3.05 (56/2)
17557
17558
17559 @item
17560 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
17561 @cindex AI-0214 (Ada 2012 feature)
17562
17563 @noindent
17564 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
17565 to have default expressions by allowing them when the type is limited. It
17566 is often useful to define a default value for a discriminant even though
17567 it can't be changed by assignment.
17568
17569 @noindent
17570 RM References: 3.07 (9.1/2) 3.07.02 (3)
17571
17572
17573 @item
17574 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
17575 @cindex AI-0102 (Ada 2012 feature)
17576
17577 @noindent
17578 It is illegal to assign an anonymous access constant to an anonymous access
17579 variable. The RM did not have a clear rule to prevent this, but GNAT has
17580 always generated an error for this usage.
17581
17582 @noindent
17583 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
17584
17585
17586 @item
17587 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
17588 @cindex AI-0158 (Ada 2012 feature)
17589
17590 @noindent
17591 This AI extends the syntax of membership tests to simplify complex conditions
17592 that can be expressed as membership in a subset of values of any type. It
17593 introduces syntax for a list of expressions that may be used in loop contexts
17594 as well.
17595
17596 @noindent
17597 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
17598
17599
17600 @item
17601 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
17602 @cindex AI-0173 (Ada 2012 feature)
17603
17604 @noindent
17605 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17606 with the tag of an abstract type, and @code{False} otherwise.
17607
17608 @noindent
17609 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
17610
17611
17612
17613 @item
17614 @emph{AI-0076 function with controlling result (0000-00-00)}
17615 @cindex AI-0076 (Ada 2012 feature)
17616
17617 @noindent
17618 This is an editorial change only. The RM defines calls with controlling
17619 results, but uses the term ``function with controlling result'' without an
17620 explicit definition.
17621
17622 @noindent
17623 RM References: 3.09.02 (2/2)
17624
17625
17626 @item
17627 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17628 @cindex AI-0126 (Ada 2012 feature)
17629
17630 @noindent
17631 This AI clarifies dispatching rules, and simply confirms that dispatching
17632 executes the operation of the parent type when there is no explicitly or
17633 implicitly declared operation for the descendant type. This has always been
17634 the case in all versions of GNAT.
17635
17636 @noindent
17637 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
17638
17639
17640 @item
17641 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17642 @cindex AI-0097 (Ada 2012 feature)
17643
17644 @noindent
17645 The RM as written implied that in some cases it was possible to create an
17646 object of an abstract type, by having an abstract extension inherit a non-
17647 abstract constructor from its parent type. This mistake has been corrected
17648 in GNAT and in the RM, and this construct is now illegal.
17649
17650 @noindent
17651 RM References: 3.09.03 (4/2)
17652
17653
17654 @item
17655 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17656 @cindex AI-0203 (Ada 2012 feature)
17657
17658 @noindent
17659 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17660 permitted such usage.
17661
17662 @noindent
17663 RM References: 3.09.03 (8/3)
17664
17665
17666 @item
17667 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
17668 @cindex AI-0198 (Ada 2012 feature)
17669
17670 @noindent
17671 This AI resolves a conflict between two rules involving inherited abstract
17672 operations and predefined operators. If a derived numeric type inherits
17673 an abstract operator, it overrides the predefined one. This interpretation
17674 was always the one implemented in GNAT.
17675
17676 @noindent
17677 RM References: 3.09.03 (4/3)
17678
17679 @item
17680 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17681 @cindex AI-0073 (Ada 2012 feature)
17682
17683 @noindent
17684 This AI covers a number of issues regarding returning abstract types. In
17685 particular generic functions cannot have abstract result types or access
17686 result types designated an abstract type. There are some other cases which
17687 are detailed in the AI. Note that this binding interpretation has not been
17688 retrofitted to operate before Ada 2012 mode, since it caused a significant
17689 number of regressions.
17690
17691 @noindent
17692 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
17693
17694
17695 @item
17696 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17697 @cindex AI-0070 (Ada 2012 feature)
17698
17699 @noindent
17700 This is an editorial change only, there are no testable consequences short of
17701 checking for the absence of generated code for an interface declaration.
17702
17703 @noindent
17704 RM References: 3.09.04 (18/2)
17705
17706
17707 @item
17708 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17709 @cindex AI-0208 (Ada 2012 feature)
17710
17711 @noindent
17712 The wording in the Ada 2005 RM concerning characteristics of incomplete views
17713 was incorrect and implied that some programs intended to be legal were now
17714 illegal. GNAT had never considered such programs illegal, so it has always
17715 implemented the intent of this AI.
17716
17717 @noindent
17718 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
17719
17720
17721 @item
17722 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17723 @cindex AI-0162 (Ada 2012 feature)
17724
17725 @noindent
17726 Incomplete types are made more useful by allowing them to be completed by
17727 private types and private extensions.
17728
17729 @noindent
17730 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
17731
17732
17733
17734 @item
17735 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17736 @cindex AI-0098 (Ada 2012 feature)
17737
17738 @noindent
17739 An unintentional omission in the RM implied some inconsistent restrictions on
17740 the use of anonymous access to subprogram values. These restrictions were not
17741 intentional, and have never been enforced by GNAT.
17742
17743 @noindent
17744 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
17745
17746
17747 @item
17748 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17749 @cindex AI-0199 (Ada 2012 feature)
17750
17751 @noindent
17752 A choice list in a record aggregate can include several components of
17753 (distinct) anonymous access types as long as they have matching designated
17754 subtypes.
17755
17756 @noindent
17757 RM References: 4.03.01 (16)
17758
17759
17760 @item
17761 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17762 @cindex AI-0220 (Ada 2012 feature)
17763
17764 @noindent
17765 This AI addresses a wording problem in the RM that appears to permit some
17766 complex cases of aggregates with non-static discriminants. GNAT has always
17767 implemented the intended semantics.
17768
17769 @noindent
17770 RM References: 4.03.01 (17)
17771
17772 @item
17773 @emph{AI-0147 Conditional expressions (2009-03-29)}
17774 @cindex AI-0147 (Ada 2012 feature)
17775
17776 @noindent
17777 Conditional expressions are permitted. The form of such an expression is:
17778
17779 @smallexample
17780 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17781 @end smallexample
17782
17783 The parentheses can be omitted in contexts where parentheses are present
17784 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17785 clause is omitted, @b{else True} is assumed;
17786 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17787 @emph{(A implies B)} in standard logic.
17788
17789 @noindent
17790 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
17791 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
17792
17793
17794 @item
17795 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17796 @cindex AI-0037 (Ada 2012 feature)
17797
17798 @noindent
17799 This AI confirms that an association of the form @code{Indx => <>} in an
17800 array aggregate must raise @code{Constraint_Error} if @code{Indx}
17801 is out of range. The RM specified a range check on other associations, but
17802 not when the value of the association was defaulted. GNAT has always inserted
17803 a constraint check on the index value.
17804
17805 @noindent
17806 RM References: 4.03.03 (29)
17807
17808
17809 @item
17810 @emph{AI-0123 Composability of equality (2010-04-13)}
17811 @cindex AI-0123 (Ada 2012 feature)
17812
17813 @noindent
17814 Equality of untagged record composes, so that the predefined equality for a
17815 composite type that includes a component of some untagged record type
17816 @code{R} uses the equality operation of @code{R} (which may be user-defined
17817 or predefined). This makes the behavior of untagged records identical to that
17818 of tagged types in this respect.
17819
17820 This change is an incompatibility with previous versions of Ada, but it
17821 corrects a non-uniformity that was often a source of confusion. Analysis of
17822 a large number of industrial programs indicates that in those rare cases
17823 where a composite type had an untagged record component with a user-defined
17824 equality, either there was no use of the composite equality, or else the code
17825 expected the same composability as for tagged types, and thus had a bug that
17826 would be fixed by this change.
17827
17828 @noindent
17829 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
17830 8.05.04 (8)
17831
17832
17833 @item
17834 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17835 @cindex AI-0088 (Ada 2012 feature)
17836
17837 @noindent
17838 This AI clarifies the equivalence rule given for the dynamic semantics of
17839 exponentiation: the value of the operation can be obtained by repeated
17840 multiplication, but the operation can be implemented otherwise (for example
17841 using the familiar divide-by-two-and-square algorithm, even if this is less
17842 accurate), and does not imply repeated reads of a volatile base.
17843
17844 @noindent
17845 RM References: 4.05.06 (11)
17846
17847 @item
17848 @emph{AI-0188 Case expressions (2010-01-09)}
17849 @cindex AI-0188 (Ada 2012 feature)
17850
17851 @noindent
17852 Case expressions are permitted. This allows use of constructs such as:
17853 @smallexample
17854 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17855 @end smallexample
17856
17857 @noindent
17858 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
17859
17860 @item
17861 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17862 @cindex AI-0104 (Ada 2012 feature)
17863
17864 @noindent
17865 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17866 @code{Constraint_Error} because the default value of the allocated object is
17867 @b{null}. This useless construct is illegal in Ada 2012.
17868
17869 @noindent
17870 RM References: 4.08 (2)
17871
17872 @item
17873 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17874 @cindex AI-0157 (Ada 2012 feature)
17875
17876 @noindent
17877 Allocation and Deallocation from an empty storage pool (i.e. allocation or
17878 deallocation of a pointer for which a static storage size clause of zero
17879 has been given) is now illegal and is detected as such. GNAT
17880 previously gave a warning but not an error.
17881
17882 @noindent
17883 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
17884
17885 @item
17886 @emph{AI-0179 Statement not required after label (2010-04-10)}
17887 @cindex AI-0179 (Ada 2012 feature)
17888
17889 @noindent
17890 It is not necessary to have a statement following a label, so a label
17891 can appear at the end of a statement sequence without the need for putting a
17892 null statement afterwards, but it is not allowable to have only labels and
17893 no real statements in a statement sequence.
17894
17895 @noindent
17896 RM References: 5.01 (2)
17897
17898
17899 @item
17900 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17901 @cindex AI-139-2 (Ada 2012 feature)
17902
17903 @noindent
17904 The new syntax for iterating over arrays and containers is now implemented.
17905 Iteration over containers is for now limited to read-only iterators. Only
17906 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
17907
17908 @noindent
17909 RM References: 5.05
17910
17911 @item
17912 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17913 @cindex AI-0134 (Ada 2012 feature)
17914
17915 @noindent
17916 For full conformance, the profiles of anonymous-access-to-subprogram
17917 parameters must match. GNAT has always enforced this rule.
17918
17919 @noindent
17920 RM References: 6.03.01 (18)
17921
17922 @item
17923 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17924 @cindex AI-0207 (Ada 2012 feature)
17925
17926 @noindent
17927 This AI confirms that access_to_constant indication must match for mode
17928 conformance. This was implemented in GNAT when the qualifier was originally
17929 introduced in Ada 2005.
17930
17931 @noindent
17932 RM References: 6.03.01 (16/2)
17933
17934
17935 @item
17936 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17937 @cindex AI-0046 (Ada 2012 feature)
17938
17939 @noindent
17940 For full conformance, in the case of access parameters, the null exclusion
17941 must match (either both or neither must have @code{@b{not null}}).
17942
17943 @noindent
17944 RM References: 6.03.02 (18)
17945
17946
17947 @item
17948 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17949 @cindex AI-0118 (Ada 2012 feature)
17950
17951 @noindent
17952 This AI clarifies the rules for named associations in subprogram calls and
17953 generic instantiations. The rules have been in place since Ada 83.
17954
17955 @noindent
17956 RM References: 6.04.01 (2) 12.03 (9)
17957
17958
17959 @item
17960 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17961 @cindex AI-0196 (Ada 2012 feature)
17962
17963 @noindent
17964 Null exclusion checks are not made for @code{@b{out}} parameters when
17965 evaluating the actual parameters. GNAT has never generated these checks.
17966
17967 @noindent
17968 RM References: 6.04.01 (13)
17969
17970 @item
17971 @emph{AI-0015 Constant return objects (0000-00-00)}
17972 @cindex AI-0015 (Ada 2012 feature)
17973
17974 @noindent
17975 The return object declared in an @i{extended_return_statement} may be
17976 declared constant. This was always intended, and GNAT has always allowed it.
17977
17978 @noindent
17979 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
17980 6.05 (5.7/2)
17981
17982
17983 @item
17984 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17985 @cindex AI-0032 (Ada 2012 feature)
17986
17987 @noindent
17988 If a function returns a class-wide type, the object of an extended return
17989 statement can be declared with a specific type that is covered by the class-
17990 wide type. This has been implemented in GNAT since the introduction of
17991 extended returns. Note AI-0103 complements this AI by imposing matching
17992 rules for constrained return types.
17993
17994 @noindent
17995 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
17996 6.05 (8/2)
17997
17998 @item
17999 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18000 @cindex AI-0103 (Ada 2012 feature)
18001
18002 @noindent
18003 If the return subtype of a function is an elementary type or a constrained
18004 type, the subtype indication in an extended return statement must match
18005 statically this return subtype.
18006
18007 @noindent
18008 RM References: 6.05 (5.2/2)
18009
18010
18011 @item
18012 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18013 @cindex AI-0058 (Ada 2012 feature)
18014
18015 @noindent
18016 The RM had some incorrect wording implying wrong treatment of abnormal
18017 completion in an extended return. GNAT has always implemented the intended
18018 correct semantics as described by this AI.
18019
18020 @noindent
18021 RM References: 6.05 (22/2)
18022
18023
18024 @item
18025 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18026 @cindex AI-0050 (Ada 2012 feature)
18027
18028 @noindent
18029 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
18030 not take advantage of these incorrect permissions in any case.
18031
18032 @noindent
18033 RM References: 6.05 (24/2)
18034
18035
18036 @item
18037 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18038 @cindex AI-0125 (Ada 2012 feature)
18039
18040 @noindent
18041 In Ada 2012, the declaration of a primitive operation of a type extension
18042 or private extension can also override an inherited primitive that is not
18043 visible at the point of this declaration.
18044
18045 @noindent
18046 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18047
18048 @item
18049 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18050 @cindex AI-0062 (Ada 2012 feature)
18051
18052 @noindent
18053 A full constant may have a null exclusion even if its associated deferred
18054 constant does not. GNAT has always allowed this.
18055
18056 @noindent
18057 RM References: 7.04 (6/2) 7.04 (7.1/2)
18058
18059
18060 @item
18061 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18062 @cindex AI-0178 (Ada 2012 feature)
18063
18064 @noindent
18065 This AI clarifies the role of incomplete views and plugs an omission in the
18066 RM. GNAT always correctly restricted the use of incomplete views and types.
18067
18068 @noindent
18069 RM References: 7.05 (3/2) 7.05 (6/2)
18070
18071 @item
18072 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18073 @cindex AI-0087 (Ada 2012 feature)
18074
18075 @noindent
18076 The actual for a formal nonlimited derived type cannot be limited. In
18077 particular, a formal derived type that extends a limited interface but which
18078 is not explicitly limited cannot be instantiated with a limited type.
18079
18080 @noindent
18081 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18082
18083 @item
18084 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18085 @cindex AI-0099 (Ada 2012 feature)
18086
18087 @noindent
18088 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18089 and therefore depends on the run-time characteristics of an object (i.e. its
18090 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18091 this to affect any implementation''.
18092
18093 @noindent
18094 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18095
18096
18097
18098 @item
18099 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18100 @cindex AI-0064 (Ada 2012 feature)
18101
18102 @noindent
18103 This is an editorial change only. The intended behavior is already checked
18104 by an existing ACATS test, which GNAT has always executed correctly.
18105
18106 @noindent
18107 RM References: 7.06.01 (17.1/1)
18108
18109 @item
18110 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18111 @cindex AI-0026 (Ada 2012 feature)
18112
18113 @noindent
18114 Record representation clauses concerning Unchecked_Union types cannot mention
18115 the discriminant of the type. The type of a component declared in the variant
18116 part of an Unchecked_Union cannot be controlled, have controlled components,
18117 nor have protected or task parts. If an Unchecked_Union type is declared
18118 within the body of a generic unit or its descendants, then the type of a
18119 component declared in the variant part cannot be a formal private type or a
18120 formal private extension declared within the same generic unit.
18121
18122 @noindent
18123 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18124
18125
18126 @item
18127 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18128 @cindex AI-0205 (Ada 2012 feature)
18129
18130 @noindent
18131 This AI corrects a simple omission in the RM. Return objects have always
18132 been visible within an extended return statement.
18133
18134 @noindent
18135 RM References: 8.03 (17)
18136
18137
18138 @item
18139 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18140 @cindex AI-0042 (Ada 2012 feature)
18141
18142 @noindent
18143 This AI fixes a wording gap in the RM. An operation of a synchronized
18144 interface can be implemented by a protected or task entry, but the abstract
18145 operation is not being overridden in the usual sense, and it must be stated
18146 separately that this implementation is legal. This has always been the case
18147 in GNAT.
18148
18149 @noindent
18150 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18151
18152 @item
18153 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18154 @cindex AI-0030 (Ada 2012 feature)
18155
18156 @noindent
18157 Requeue is permitted to a protected, synchronized or task interface primitive
18158 providing it is known that the overriding operation is an entry. Otherwise
18159 the requeue statement has the same effect as a procedure call. Use of pragma
18160 @code{Implemented} provides a way to impose a static requirement on the
18161 overriding operation by adhering to one of the implementation kinds: entry,
18162 protected procedure or any of the above.
18163
18164 @noindent
18165 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18166 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18167
18168
18169 @item
18170 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18171 @cindex AI-0201 (Ada 2012 feature)
18172
18173 @noindent
18174 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18175 attribute, then individual components may not be addressable by independent
18176 tasks. However, if the representation clause has no effect (is confirming),
18177 then independence is not compromised. Furthermore, in GNAT, specification of
18178 other appropriately addressable component sizes (e.g. 16 for 8-bit
18179 characters) also preserves independence. GNAT now gives very clear warnings
18180 both for the declaration of such a type, and for any assignment to its components.
18181
18182 @noindent
18183 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18184
18185 @item
18186 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18187 @cindex AI-0009 (Ada 2012 feature)
18188
18189 @noindent
18190 This AI introduces the new pragmas @code{Independent} and
18191 @code{Independent_Components},
18192 which control guaranteeing independence of access to objects and components.
18193 The AI also requires independence not unaffected by confirming rep clauses.
18194
18195 @noindent
18196 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18197 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18198
18199
18200 @item
18201 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18202 @cindex AI-0072 (Ada 2012 feature)
18203
18204 @noindent
18205 This AI clarifies that task signalling for reading @code{'Terminated} only
18206 occurs if the result is True. GNAT semantics has always been consistent with
18207 this notion of task signalling.
18208
18209 @noindent
18210 RM References: 9.10 (6.1/1)
18211
18212 @item
18213 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18214 @cindex AI-0108 (Ada 2012 feature)
18215
18216 @noindent
18217 This AI confirms that an incomplete type from a limited view does not have
18218 discriminants. This has always been the case in GNAT.
18219
18220 @noindent
18221 RM References: 10.01.01 (12.3/2)
18222
18223 @item
18224 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18225 @cindex AI-0129 (Ada 2012 feature)
18226
18227 @noindent
18228 This AI clarifies the description of limited views: a limited view of a
18229 package includes only one view of a type that has an incomplete declaration
18230 and a full declaration (there is no possible ambiguity in a client package).
18231 This AI also fixes an omission: a nested package in the private part has no
18232 limited view. GNAT always implemented this correctly.
18233
18234 @noindent
18235 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18236
18237
18238
18239 @item
18240 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18241 @cindex AI-0077 (Ada 2012 feature)
18242
18243 @noindent
18244 This AI clarifies that a declaration does not include a context clause,
18245 and confirms that it is illegal to have a context in which both a limited
18246 and a nonlimited view of a package are accessible. Such double visibility
18247 was always rejected by GNAT.
18248
18249 @noindent
18250 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18251
18252 @item
18253 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18254 @cindex AI-0122 (Ada 2012 feature)
18255
18256 @noindent
18257 This AI clarifies the visibility of private children of generic units within
18258 instantiations of a parent. GNAT has always handled this correctly.
18259
18260 @noindent
18261 RM References: 10.01.02 (12/2)
18262
18263
18264
18265 @item
18266 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
18267 @cindex AI-0040 (Ada 2012 feature)
18268
18269 @noindent
18270 This AI confirms that a limited with clause in a child unit cannot name
18271 an ancestor of the unit. This has always been checked in GNAT.
18272
18273 @noindent
18274 RM References: 10.01.02 (20/2)
18275
18276 @item
18277 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
18278 @cindex AI-0132 (Ada 2012 feature)
18279
18280 @noindent
18281 This AI fills a gap in the description of library unit pragmas. The pragma
18282 clearly must apply to a library unit, even if it does not carry the name
18283 of the enclosing unit. GNAT has always enforced the required check.
18284
18285 @noindent
18286 RM References: 10.01.05 (7)
18287
18288
18289 @item
18290 @emph{AI-0034 Categorization of limited views (0000-00-00)}
18291 @cindex AI-0034 (Ada 2012 feature)
18292
18293 @noindent
18294 The RM makes certain limited with clauses illegal because of categorization
18295 considerations, when the corresponding normal with would be legal. This is
18296 not intended, and GNAT has always implemented the recommended behavior.
18297
18298 @noindent
18299 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
18300
18301
18302 @item
18303 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
18304 @cindex AI-0035 (Ada 2012 feature)
18305
18306 @noindent
18307 This AI remedies some inconsistencies in the legality rules for Pure units.
18308 Derived access types are legal in a pure unit (on the assumption that the
18309 rule for a zero storage pool size has been enforced on the ancestor type).
18310 The rules are enforced in generic instances and in subunits. GNAT has always
18311 implemented the recommended behavior.
18312
18313 @noindent
18314 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)
18315
18316
18317 @item
18318 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
18319 @cindex AI-0219 (Ada 2012 feature)
18320
18321 @noindent
18322 This AI refines the rules for the cases with limited parameters which do not
18323 allow the implementations to omit ``redundant''. GNAT now properly conforms
18324 to the requirements of this binding interpretation.
18325
18326 @noindent
18327 RM References: 10.02.01 (18/2)
18328
18329 @item
18330 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
18331 @cindex AI-0043 (Ada 2012 feature)
18332
18333 @noindent
18334 This AI covers various omissions in the RM regarding the raising of
18335 exceptions. GNAT has always implemented the intended semantics.
18336
18337 @noindent
18338 RM References: 11.04.01 (10.1/2) 11 (2)
18339
18340
18341 @item
18342 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
18343 @cindex AI-0200 (Ada 2012 feature)
18344
18345 @noindent
18346 This AI plugs a gap in the RM which appeared to allow some obviously intended
18347 illegal instantiations. GNAT has never allowed these instantiations.
18348
18349 @noindent
18350 RM References: 12.07 (16)
18351
18352
18353 @item
18354 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
18355 @cindex AI-0112 (Ada 2012 feature)
18356
18357 @noindent
18358 This AI concerns giving names to various representation aspects, but the
18359 practical effect is simply to make the use of duplicate
18360 @code{Atomic}[@code{_Components}],
18361 @code{Volatile}[@code{_Components}] and
18362 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
18363 now performs this required check.
18364
18365 @noindent
18366 RM References: 13.01 (8)
18367
18368 @item
18369 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
18370 @cindex AI-0106 (Ada 2012 feature)
18371
18372 @noindent
18373 The RM appeared to allow representation pragmas on generic formal parameters,
18374 but this was not intended, and GNAT has never permitted this usage.
18375
18376 @noindent
18377 RM References: 13.01 (9.1/1)
18378
18379
18380 @item
18381 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
18382 @cindex AI-0012 (Ada 2012 feature)
18383
18384 @noindent
18385 It is now illegal to give an inappropriate component size or a pragma
18386 @code{Pack} that attempts to change the component size in the case of atomic
18387 or aliased components. Previously GNAT ignored such an attempt with a
18388 warning.
18389
18390 @noindent
18391 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
18392
18393
18394 @item
18395 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
18396 @cindex AI-0039 (Ada 2012 feature)
18397
18398 @noindent
18399 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
18400 for stream attributes, but these were never useful and are now illegal. GNAT
18401 has always regarded such expressions as illegal.
18402
18403 @noindent
18404 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
18405
18406
18407 @item
18408 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
18409 @cindex AI-0095 (Ada 2012 feature)
18410
18411 @noindent
18412 The prefix of @code{'Address} cannot statically denote a subprogram with
18413 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
18414 @code{Program_Error} if the prefix denotes a subprogram with convention
18415 @code{Intrinsic}.
18416
18417 @noindent
18418 RM References: 13.03 (11/1)
18419
18420
18421 @item
18422 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
18423 @cindex AI-0116 (Ada 2012 feature)
18424
18425 @noindent
18426 This AI requires that the alignment of a class-wide object be no greater
18427 than the alignment of any type in the class. GNAT has always followed this
18428 recommendation.
18429
18430 @noindent
18431 RM References: 13.03 (29) 13.11 (16)
18432
18433
18434 @item
18435 @emph{AI-0146 Type invariants (2009-09-21)}
18436 @cindex AI-0146 (Ada 2012 feature)
18437
18438 @noindent
18439 Type invariants may be specified for private types using the aspect notation.
18440 Aspect @code{Invariant} may be specified for any private type,
18441 @code{Invariant'Class} can
18442 only be specified for tagged types, and is inherited by any descendent of the
18443 tagged types. The invariant is a boolean expression that is tested for being
18444 true in the following situations: conversions to the private type, object
18445 declarations for the private type that are default initialized, and
18446 [@b{in}] @b{out}
18447 parameters and returned result on return from any primitive operation for
18448 the type that is visible to a client.
18449
18450 @noindent
18451 RM References: 13.03.03 (00)
18452
18453 @item
18454 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
18455 @cindex AI-0078 (Ada 2012 feature)
18456
18457 @noindent
18458 In Ada 2012, compilers are required to support unchecked conversion where the
18459 target alignment is a multiple of the source alignment. GNAT always supported
18460 this case (and indeed all cases of differing alignments, doing copies where
18461 required if the alignment was reduced).
18462
18463 @noindent
18464 RM References: 13.09 (7)
18465
18466
18467 @item
18468 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
18469 @cindex AI-0195 (Ada 2012 feature)
18470
18471 @noindent
18472 The handling of invalid values is now designated to be implementation
18473 defined. This is a documentation change only, requiring Annex M in the GNAT
18474 Reference Manual to document this handling.
18475 In GNAT, checks for invalid values are made
18476 only when necessary to avoid erroneous behavior. Operations like assignments
18477 which cannot cause erroneous behavior ignore the possibility of invalid
18478 values and do not do a check. The date given above applies only to the
18479 documentation change, this behavior has always been implemented by GNAT.
18480
18481 @noindent
18482 RM References: 13.09.01 (10)
18483
18484 @item
18485 @emph{AI-0193 Alignment of allocators (2010-09-16)}
18486 @cindex AI-0193 (Ada 2012 feature)
18487
18488 @noindent
18489 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
18490 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
18491 of size.
18492
18493 @noindent
18494 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
18495 13.11.01 (2) 13.11.01 (3)
18496
18497
18498 @item
18499 @emph{AI-0177 Parameterized expressions (2010-07-10)}
18500 @cindex AI-0177 (Ada 2012 feature)
18501
18502 @noindent
18503 The new Ada 2012 notion of parameterized expressions is implemented. The form
18504 is:
18505 @smallexample
18506 @i{function specification} @b{is} (@i{expression})
18507 @end smallexample
18508
18509 @noindent
18510 This is exactly equivalent to the
18511 corresponding function body that returns the expression, but it can appear
18512 in a package spec. Note that the expression must be parenthesized.
18513
18514 @noindent
18515 RM References: 13.11.01 (3/2)
18516
18517 @item
18518 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
18519 @cindex AI-0033 (Ada 2012 feature)
18520
18521 @noindent
18522 Neither of these two pragmas may appear within a generic template, because
18523 the generic might be instantiated at other than the library level.
18524
18525 @noindent
18526 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
18527
18528
18529 @item
18530 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
18531 @cindex AI-0161 (Ada 2012 feature)
18532
18533 @noindent
18534 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
18535 of the default stream attributes for elementary types. If this restriction is
18536 in force, then it is necessary to provide explicit subprograms for any
18537 stream attributes used.
18538
18539 @noindent
18540 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
18541
18542 @item
18543 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
18544 @cindex AI-0194 (Ada 2012 feature)
18545
18546 @noindent
18547 The @code{Stream_Size} attribute returns the default number of bits in the
18548 stream representation of the given type.
18549 This value is not affected by the presence
18550 of stream subprogram attributes for the type. GNAT has always implemented
18551 this interpretation.
18552
18553 @noindent
18554 RM References: 13.13.02 (1.2/2)
18555
18556 @item
18557 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
18558 @cindex AI-0109 (Ada 2012 feature)
18559
18560 @noindent
18561 This AI is an editorial change only. It removes the need for a tag check
18562 that can never fail.
18563
18564 @noindent
18565 RM References: 13.13.02 (34/2)
18566
18567 @item
18568 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
18569 @cindex AI-0007 (Ada 2012 feature)
18570
18571 @noindent
18572 The RM as written appeared to limit the possibilities of declaring read
18573 attribute procedures for private scalar types. This limitation was not
18574 intended, and has never been enforced by GNAT.
18575
18576 @noindent
18577 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
18578
18579
18580 @item
18581 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
18582 @cindex AI-0065 (Ada 2012 feature)
18583
18584 @noindent
18585 This AI clarifies the fact that all remote access types support external
18586 streaming. This fixes an obvious oversight in the definition of the
18587 language, and GNAT always implemented the intended correct rules.
18588
18589 @noindent
18590 RM References: 13.13.02 (52/2)
18591
18592 @item
18593 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
18594 @cindex AI-0019 (Ada 2012 feature)
18595
18596 @noindent
18597 The RM suggests that primitive subprograms of a specific tagged type are
18598 frozen when the tagged type is frozen. This would be an incompatible change
18599 and is not intended. GNAT has never attempted this kind of freezing and its
18600 behavior is consistent with the recommendation of this AI.
18601
18602 @noindent
18603 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)
18604
18605 @item
18606 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18607 @cindex AI-0017 (Ada 2012 feature)
18608
18609 @noindent
18610 So-called ``Taft-amendment types'' (i.e., types that are completed in package
18611 bodies) are not frozen by the occurrence of bodies in the
18612 enclosing declarative part. GNAT always implemented this properly.
18613
18614 @noindent
18615 RM References: 13.14 (3/1)
18616
18617
18618 @item
18619 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18620 @cindex AI-0060 (Ada 2012 feature)
18621
18622 @noindent
18623 This AI extends the definition of remote access types to include access
18624 to limited, synchronized, protected or task class-wide interface types.
18625 GNAT already implemented this extension.
18626
18627 @noindent
18628 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
18629
18630 @item
18631 @emph{AI-0114 Classification of letters (0000-00-00)}
18632 @cindex AI-0114 (Ada 2012 feature)
18633
18634 @noindent
18635 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18636 181 (@code{MICRO SIGN}), and
18637 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18638 lower case letters by Unicode.
18639 However, they are not allowed in identifiers, and they
18640 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18641 This behavior is consistent with that defined in Ada 95.
18642
18643 @noindent
18644 RM References: A.03.02 (59) A.04.06 (7)
18645
18646
18647 @item
18648 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18649 @cindex AI-0185 (Ada 2012 feature)
18650
18651 @noindent
18652 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18653 classification functions for @code{Wide_Character} and
18654 @code{Wide_Wide_Character}, as well as providing
18655 case folding routines for @code{Wide_[Wide_]Character} and
18656 @code{Wide_[Wide_]String}.
18657
18658 @noindent
18659 RM References: A.03.05 (0) A.03.06 (0)
18660
18661
18662 @item
18663 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18664 @cindex AI-0031 (Ada 2012 feature)
18665
18666 @noindent
18667 A new version of @code{Find_Token} is added to all relevant string packages,
18668 with an extra parameter @code{From}. Instead of starting at the first
18669 character of the string, the search for a matching Token starts at the
18670 character indexed by the value of @code{From}.
18671 These procedures are available in all versions of Ada
18672 but if used in versions earlier than Ada 2012 they will generate a warning
18673 that an Ada 2012 subprogram is being used.
18674
18675 @noindent
18676 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
18677 A.04.05 (46)
18678
18679
18680 @item
18681 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18682 @cindex AI-0056 (Ada 2012 feature)
18683
18684 @noindent
18685 The wording in the Ada 2005 RM implied an incompatible handling of the
18686 @code{Index} functions, resulting in raising an exception instead of
18687 returning zero in some situations.
18688 This was not intended and has been corrected.
18689 GNAT always returned zero, and is thus consistent with this AI.
18690
18691 @noindent
18692 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
18693
18694
18695 @item
18696 @emph{AI-0137 String encoding package (2010-03-25)}
18697 @cindex AI-0137 (Ada 2012 feature)
18698
18699 @noindent
18700 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18701 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18702 and @code{Wide_Wide_Strings} have been
18703 implemented. These packages (whose documentation can be found in the spec
18704 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18705 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18706 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18707 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18708 UTF-16), as well as conversions between the different UTF encodings. With
18709 the exception of @code{Wide_Wide_Strings}, these packages are available in
18710 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18711 The @code{Wide_Wide_Strings package}
18712 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18713 mode since it uses @code{Wide_Wide_Character}).
18714
18715 @noindent
18716 RM References: A.04.11
18717
18718 @item
18719 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18720 @cindex AI-0038 (Ada 2012 feature)
18721
18722 @noindent
18723 These are minor errors in the description on three points. The intent on
18724 all these points has always been clear, and GNAT has always implemented the
18725 correct intended semantics.
18726
18727 @noindent
18728 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)
18729
18730 @item
18731 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18732 @cindex AI-0044 (Ada 2012 feature)
18733
18734 @noindent
18735 This AI places restrictions on allowed instantiations of generic containers.
18736 These restrictions are not checked by the compiler, so there is nothing to
18737 change in the implementation. This affects only the RM documentation.
18738
18739 @noindent
18740 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)
18741
18742 @item
18743 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18744 @cindex AI-0127 (Ada 2012 feature)
18745
18746 @noindent
18747 This package provides an interface for identifying the current locale.
18748
18749 @noindent
18750 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
18751 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
18752
18753
18754
18755 @item
18756 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18757 @cindex AI-0002 (Ada 2012 feature)
18758
18759 @noindent
18760 The compiler is not required to support exporting an Ada subprogram with
18761 convention C if there are parameters or a return type of an unconstrained
18762 array type (such as @code{String}). GNAT allows such declarations but
18763 generates warnings. It is possible, but complicated, to write the
18764 corresponding C code and certainly such code would be specific to GNAT and
18765 non-portable.
18766
18767 @noindent
18768 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
18769
18770
18771 @item
18772 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18773 @cindex AI05-0216 (Ada 2012 feature)
18774
18775 @noindent
18776 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18777 forbid tasks declared locally within subprograms, or functions returning task
18778 objects, and that is the implementation that GNAT has always provided.
18779 However the language in the RM was not sufficiently clear on this point.
18780 Thus this is a documentation change in the RM only.
18781
18782 @noindent
18783 RM References: D.07 (3/3)
18784
18785 @item
18786 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18787 @cindex AI-0211 (Ada 2012 feature)
18788
18789 @noindent
18790 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18791 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18792
18793 @noindent
18794 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
18795
18796 @item
18797 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18798 @cindex AI-0190 (Ada 2012 feature)
18799
18800 @noindent
18801 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18802 used to control storage pools globally.
18803 In particular, you can force every access
18804 type that is used for allocation (@b{new}) to have an explicit storage pool,
18805 or you can declare a pool globally to be used for all access types that lack
18806 an explicit one.
18807
18808 @noindent
18809 RM References: D.07 (8)
18810
18811 @item
18812 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18813 @cindex AI-0189 (Ada 2012 feature)
18814
18815 @noindent
18816 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18817 which says that no dynamic allocation will occur once elaboration is
18818 completed.
18819 In general this requires a run-time check, which is not required, and which
18820 GNAT does not attempt. But the static cases of allocators in a task body or
18821 in the body of the main program are detected and flagged at compile or bind
18822 time.
18823
18824 @noindent
18825 RM References: D.07 (19.1/2) H.04 (23.3/2)
18826
18827 @item
18828 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18829 @cindex AI-0171 (Ada 2012 feature)
18830
18831 @noindent
18832 A new package @code{System.Multiprocessors} is added, together with the
18833 definition of pragma @code{CPU} for controlling task affinity. A new no
18834 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18835 is added to the Ravenscar profile.
18836
18837 @noindent
18838 RM References: D.13.01 (4/2) D.16
18839
18840
18841 @item
18842 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18843 @cindex AI-0210 (Ada 2012 feature)
18844
18845 @noindent
18846 This is a documentation only issue regarding wording of metric requirements,
18847 that does not affect the implementation of the compiler.
18848
18849 @noindent
18850 RM References: D.15 (24/2)
18851
18852
18853 @item
18854 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18855 @cindex AI-0206 (Ada 2012 feature)
18856
18857 @noindent
18858 Remote types packages are now allowed to depend on preelaborated packages.
18859 This was formerly considered illegal.
18860
18861 @noindent
18862 RM References: E.02.02 (6)
18863
18864
18865
18866 @item
18867 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18868 @cindex AI-0152 (Ada 2012 feature)
18869
18870 @noindent
18871 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18872 where the type of the returned value is an anonymous access type.
18873
18874 @noindent
18875 RM References: H.04 (8/1)
18876 @end itemize
18877
18878
18879 @node Obsolescent Features
18880 @chapter Obsolescent Features
18881
18882 @noindent
18883 This chapter describes features that are provided by GNAT, but are
18884 considered obsolescent since there are preferred ways of achieving
18885 the same effect. These features are provided solely for historical
18886 compatibility purposes.
18887
18888 @menu
18889 * pragma No_Run_Time::
18890 * pragma Ravenscar::
18891 * pragma Restricted_Run_Time::
18892 @end menu
18893
18894 @node pragma No_Run_Time
18895 @section pragma No_Run_Time
18896
18897 The pragma @code{No_Run_Time} is used to achieve an affect similar
18898 to the use of the "Zero Foot Print" configurable run time, but without
18899 requiring a specially configured run time. The result of using this
18900 pragma, which must be used for all units in a partition, is to restrict
18901 the use of any language features requiring run-time support code. The
18902 preferred usage is to use an appropriately configured run-time that
18903 includes just those features that are to be made accessible.
18904
18905 @node pragma Ravenscar
18906 @section pragma Ravenscar
18907
18908 The pragma @code{Ravenscar} has exactly the same effect as pragma
18909 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18910 is part of the new Ada 2005 standard.
18911
18912 @node pragma Restricted_Run_Time
18913 @section pragma Restricted_Run_Time
18914
18915 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18916 pragma @code{Profile (Restricted)}. The latter usage is
18917 preferred since the Ada 2005 pragma @code{Profile} is intended for
18918 this kind of implementation dependent addition.
18919
18920 @include fdl.texi
18921 @c GNU Free Documentation License
18922
18923 @node Index,,GNU Free Documentation License, Top
18924 @unnumbered Index
18925
18926 @printindex cp
18927
18928 @contents
18929
18930 @bye