da262f1f4ab6394e0f3503119a4b9c26c2155e91
[gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename gnat_rm.info
4 @documentencoding UTF-8
5 @ifinfo
6 @*Generated by Sphinx 1.4.6.@*
7 @end ifinfo
8 @settitle GNAT Reference Manual
9 @defindex ge
10 @paragraphindent 0
11 @exampleindent 4
12 @finalout
13 @dircategory GNU Ada Tools
14 @direntry
15 * gnat_rm: (gnat_rm.info). gnat_rm
16 @end direntry
17
18 @definfoenclose strong,`,'
19 @definfoenclose emph,`,'
20 @c %**end of header
21
22 @copying
23 @quotation
24 GNAT Reference Manual , Sep 29, 2020
25
26 AdaCore
27
28 Copyright @copyright{} 2008-2020, Free Software Foundation
29 @end quotation
30
31 @end copying
32
33 @titlepage
34 @title GNAT Reference Manual
35 @insertcopying
36 @end titlepage
37 @contents
38
39 @c %** start of user preamble
40
41 @c %** end of user preamble
42
43 @ifnottex
44 @node Top
45 @top GNAT Reference Manual
46 @insertcopying
47 @end ifnottex
48
49 @c %**start of body
50 @anchor{gnat_rm doc}@anchor{0}
51 @emph{GNAT, The GNU Ada Development Environment}
52
53
54 @include gcc-common.texi
55 GCC version @value{version-GCC}@*
56 AdaCore
57
58 Permission is granted to copy, distribute and/or modify this document
59 under the terms of the GNU Free Documentation License, Version 1.3 or
60 any later version published by the Free Software Foundation; with no
61 Invariant Sections, with the Front-Cover Texts being "GNAT Reference
62 Manual", and with no Back-Cover Texts. A copy of the license is
63 included in the section entitled @ref{1,,GNU Free Documentation License}.
64
65 @menu
66 * About This Guide::
67 * Implementation Defined Pragmas::
68 * Implementation Defined Aspects::
69 * Implementation Defined Attributes::
70 * Standard and Implementation Defined Restrictions::
71 * Implementation Advice::
72 * Implementation Defined Characteristics::
73 * Intrinsic Subprograms::
74 * Representation Clauses and Pragmas::
75 * Standard Library Routines::
76 * The Implementation of Standard I/O::
77 * The GNAT Library::
78 * Interfacing to Other Languages::
79 * Specialized Needs Annexes::
80 * Implementation of Specific Ada Features::
81 * Implementation of Ada 2012 Features::
82 * Obsolescent Features::
83 * Compatibility and Porting Guide::
84 * GNU Free Documentation License::
85 * Index::
86
87 @detailmenu
88 --- The Detailed Node Listing ---
89
90 About This Guide
91
92 * What This Reference Manual Contains::
93 * Conventions::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Abstract_State::
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 Aggregate_Individually_Assign::
107 * Pragma Allow_Integer_Address::
108 * Pragma Annotate::
109 * Pragma Assert::
110 * Pragma Assert_And_Cut::
111 * Pragma Assertion_Policy::
112 * Pragma Assume::
113 * Pragma Assume_No_Invalid_Values::
114 * Pragma Async_Readers::
115 * Pragma Async_Writers::
116 * Pragma Attribute_Definition::
117 * Pragma C_Pass_By_Copy::
118 * Pragma Check::
119 * Pragma Check_Float_Overflow::
120 * Pragma Check_Name::
121 * Pragma Check_Policy::
122 * Pragma Comment::
123 * Pragma Common_Object::
124 * Pragma Compile_Time_Error::
125 * Pragma Compile_Time_Warning::
126 * Pragma Compiler_Unit::
127 * Pragma Compiler_Unit_Warning::
128 * Pragma Complete_Representation::
129 * Pragma Complex_Representation::
130 * Pragma Component_Alignment::
131 * Pragma Constant_After_Elaboration::
132 * Pragma Contract_Cases::
133 * Pragma Convention_Identifier::
134 * Pragma CPP_Class::
135 * Pragma CPP_Constructor::
136 * Pragma CPP_Virtual::
137 * Pragma CPP_Vtable::
138 * Pragma CPU::
139 * Pragma Deadline_Floor::
140 * Pragma Default_Initial_Condition::
141 * Pragma Debug::
142 * Pragma Debug_Policy::
143 * Pragma Default_Scalar_Storage_Order::
144 * Pragma Default_Storage_Pool::
145 * Pragma Depends::
146 * Pragma Detect_Blocking::
147 * Pragma Disable_Atomic_Synchronization::
148 * Pragma Dispatching_Domain::
149 * Pragma Effective_Reads::
150 * Pragma Effective_Writes::
151 * Pragma Elaboration_Checks::
152 * Pragma Eliminate::
153 * Pragma Enable_Atomic_Synchronization::
154 * Pragma Export_Function::
155 * Pragma Export_Object::
156 * Pragma Export_Procedure::
157 * Pragma Export_Value::
158 * Pragma Export_Valued_Procedure::
159 * Pragma Extend_System::
160 * Pragma Extensions_Allowed::
161 * Pragma Extensions_Visible::
162 * Pragma External::
163 * Pragma External_Name_Casing::
164 * Pragma Fast_Math::
165 * Pragma Favor_Top_Level::
166 * Pragma Finalize_Storage_Only::
167 * Pragma Float_Representation::
168 * Pragma Ghost::
169 * Pragma Global::
170 * Pragma Ident::
171 * Pragma Ignore_Pragma::
172 * Pragma Implementation_Defined::
173 * Pragma Implemented::
174 * Pragma Implicit_Packing::
175 * Pragma Import_Function::
176 * Pragma Import_Object::
177 * Pragma Import_Procedure::
178 * Pragma Import_Valued_Procedure::
179 * Pragma Independent::
180 * Pragma Independent_Components::
181 * Pragma Initial_Condition::
182 * Pragma Initialize_Scalars::
183 * Pragma Initializes::
184 * Pragma Inline_Always::
185 * Pragma Inline_Generic::
186 * Pragma Interface::
187 * Pragma Interface_Name::
188 * Pragma Interrupt_Handler::
189 * Pragma Interrupt_State::
190 * Pragma Invariant::
191 * Pragma Keep_Names::
192 * Pragma License::
193 * Pragma Link_With::
194 * Pragma Linker_Alias::
195 * Pragma Linker_Constructor::
196 * Pragma Linker_Destructor::
197 * Pragma Linker_Section::
198 * Pragma Lock_Free::
199 * Pragma Loop_Invariant::
200 * Pragma Loop_Optimize::
201 * Pragma Loop_Variant::
202 * Pragma Machine_Attribute::
203 * Pragma Main::
204 * Pragma Main_Storage::
205 * Pragma Max_Queue_Length::
206 * Pragma No_Body::
207 * Pragma No_Caching::
208 * Pragma No_Component_Reordering::
209 * Pragma No_Elaboration_Code_All::
210 * Pragma No_Heap_Finalization::
211 * Pragma No_Inline::
212 * Pragma No_Return::
213 * Pragma No_Strict_Aliasing::
214 * Pragma No_Tagged_Streams::
215 * Pragma Normalize_Scalars::
216 * Pragma Obsolescent::
217 * Pragma Optimize_Alignment::
218 * Pragma Ordered::
219 * Pragma Overflow_Mode::
220 * Pragma Overriding_Renamings::
221 * Pragma Partition_Elaboration_Policy::
222 * Pragma Part_Of::
223 * Pragma Passive::
224 * Pragma Persistent_BSS::
225 * Pragma Post::
226 * Pragma Postcondition::
227 * Pragma Post_Class::
228 * Pragma Rename_Pragma::
229 * Pragma Pre::
230 * Pragma Precondition::
231 * Pragma Predicate::
232 * Pragma Predicate_Failure::
233 * Pragma Preelaborable_Initialization::
234 * Pragma Prefix_Exception_Messages::
235 * Pragma Pre_Class::
236 * Pragma Priority_Specific_Dispatching::
237 * Pragma Profile::
238 * Pragma Profile_Warnings::
239 * Pragma Propagate_Exceptions::
240 * Pragma Provide_Shift_Operators::
241 * Pragma Psect_Object::
242 * Pragma Pure_Function::
243 * Pragma Rational::
244 * Pragma Ravenscar::
245 * Pragma Refined_Depends::
246 * Pragma Refined_Global::
247 * Pragma Refined_Post::
248 * Pragma Refined_State::
249 * Pragma Relative_Deadline::
250 * Pragma Remote_Access_Type::
251 * Pragma Restricted_Run_Time::
252 * Pragma Restriction_Warnings::
253 * Pragma Reviewable::
254 * Pragma Secondary_Stack_Size::
255 * Pragma Share_Generic::
256 * Pragma Shared::
257 * Pragma Short_Circuit_And_Or::
258 * Pragma Short_Descriptors::
259 * Pragma Simple_Storage_Pool_Type::
260 * Pragma Source_File_Name::
261 * Pragma Source_File_Name_Project::
262 * Pragma Source_Reference::
263 * Pragma SPARK_Mode::
264 * Pragma Static_Elaboration_Desired::
265 * Pragma Stream_Convert::
266 * Pragma Style_Checks::
267 * Pragma Subtitle::
268 * Pragma Suppress::
269 * Pragma Suppress_All::
270 * Pragma Suppress_Debug_Info::
271 * Pragma Suppress_Exception_Locations::
272 * Pragma Suppress_Initialization::
273 * Pragma Task_Name::
274 * Pragma Task_Storage::
275 * Pragma Test_Case::
276 * Pragma Thread_Local_Storage::
277 * Pragma Time_Slice::
278 * Pragma Title::
279 * Pragma Type_Invariant::
280 * Pragma Type_Invariant_Class::
281 * Pragma Unchecked_Union::
282 * Pragma Unevaluated_Use_Of_Old::
283 * Pragma Unimplemented_Unit::
284 * Pragma Universal_Aliasing::
285 * Pragma Universal_Data::
286 * Pragma Unmodified::
287 * Pragma Unreferenced::
288 * Pragma Unreferenced_Objects::
289 * Pragma Unreserve_All_Interrupts::
290 * Pragma Unsuppress::
291 * Pragma Use_VADS_Size::
292 * Pragma Unused::
293 * Pragma Validity_Checks::
294 * Pragma Volatile::
295 * Pragma Volatile_Full_Access::
296 * Pragma Volatile_Function::
297 * Pragma Warning_As_Error::
298 * Pragma Warnings::
299 * Pragma Weak_External::
300 * Pragma Wide_Character_Encoding::
301
302 Implementation Defined Aspects
303
304 * Aspect Abstract_State::
305 * Aspect Annotate::
306 * Aspect Async_Readers::
307 * Aspect Async_Writers::
308 * Aspect Constant_After_Elaboration::
309 * Aspect Contract_Cases::
310 * Aspect Depends::
311 * Aspect Default_Initial_Condition::
312 * Aspect Dimension::
313 * Aspect Dimension_System::
314 * Aspect Disable_Controlled::
315 * Aspect Effective_Reads::
316 * Aspect Effective_Writes::
317 * Aspect Extensions_Visible::
318 * Aspect Favor_Top_Level::
319 * Aspect Ghost::
320 * Aspect Global::
321 * Aspect Initial_Condition::
322 * Aspect Initializes::
323 * Aspect Inline_Always::
324 * Aspect Invariant::
325 * Aspect Invariant'Class::
326 * Aspect Iterable::
327 * Aspect Linker_Section::
328 * Aspect Lock_Free::
329 * Aspect Max_Queue_Length::
330 * Aspect No_Caching::
331 * Aspect No_Elaboration_Code_All::
332 * Aspect No_Inline::
333 * Aspect No_Tagged_Streams::
334 * Aspect Object_Size::
335 * Aspect Obsolescent::
336 * Aspect Part_Of::
337 * Aspect Persistent_BSS::
338 * Aspect Predicate::
339 * Aspect Pure_Function::
340 * Aspect Refined_Depends::
341 * Aspect Refined_Global::
342 * Aspect Refined_Post::
343 * Aspect Refined_State::
344 * Aspect Relaxed_Initialization::
345 * Aspect Remote_Access_Type::
346 * Aspect Secondary_Stack_Size::
347 * Aspect Scalar_Storage_Order::
348 * Aspect Shared::
349 * Aspect Simple_Storage_Pool::
350 * Aspect Simple_Storage_Pool_Type::
351 * Aspect SPARK_Mode::
352 * Aspect Suppress_Debug_Info::
353 * Aspect Suppress_Initialization::
354 * Aspect Test_Case::
355 * Aspect Thread_Local_Storage::
356 * Aspect Universal_Aliasing::
357 * Aspect Universal_Data::
358 * Aspect Unmodified::
359 * Aspect Unreferenced::
360 * Aspect Unreferenced_Objects::
361 * Aspect Value_Size::
362 * Aspect Volatile_Full_Access::
363 * Aspect Volatile_Function::
364 * Aspect Warnings::
365
366 Implementation Defined Attributes
367
368 * Attribute Abort_Signal::
369 * Attribute Address_Size::
370 * Attribute Asm_Input::
371 * Attribute Asm_Output::
372 * Attribute Atomic_Always_Lock_Free::
373 * Attribute Bit::
374 * Attribute Bit_Position::
375 * Attribute Code_Address::
376 * Attribute Compiler_Version::
377 * Attribute Constrained::
378 * Attribute Default_Bit_Order::
379 * Attribute Default_Scalar_Storage_Order::
380 * Attribute Deref::
381 * Attribute Descriptor_Size::
382 * Attribute Elaborated::
383 * Attribute Elab_Body::
384 * Attribute Elab_Spec::
385 * Attribute Elab_Subp_Body::
386 * Attribute Emax::
387 * Attribute Enabled::
388 * Attribute Enum_Rep::
389 * Attribute Enum_Val::
390 * Attribute Epsilon::
391 * Attribute Fast_Math::
392 * Attribute Finalization_Size::
393 * Attribute Fixed_Value::
394 * Attribute From_Any::
395 * Attribute Has_Access_Values::
396 * Attribute Has_Discriminants::
397 * Attribute Img::
398 * Attribute Initialized::
399 * Attribute Integer_Value::
400 * Attribute Invalid_Value::
401 * Attribute Iterable::
402 * Attribute Large::
403 * Attribute Library_Level::
404 * Attribute Lock_Free::
405 * Attribute Loop_Entry::
406 * Attribute Machine_Size::
407 * Attribute Mantissa::
408 * Attribute Maximum_Alignment::
409 * Attribute Max_Integer_Size::
410 * Attribute Mechanism_Code::
411 * Attribute Null_Parameter::
412 * Attribute Object_Size::
413 * Attribute Old::
414 * Attribute Passed_By_Reference::
415 * Attribute Pool_Address::
416 * Attribute Range_Length::
417 * Attribute Restriction_Set::
418 * Attribute Result::
419 * Attribute Safe_Emax::
420 * Attribute Safe_Large::
421 * Attribute Safe_Small::
422 * Attribute Scalar_Storage_Order::
423 * Attribute Simple_Storage_Pool::
424 * Attribute Small::
425 * Attribute Storage_Unit::
426 * Attribute Stub_Type::
427 * Attribute System_Allocator_Alignment::
428 * Attribute Target_Name::
429 * Attribute To_Address::
430 * Attribute To_Any::
431 * Attribute Type_Class::
432 * Attribute Type_Key::
433 * Attribute TypeCode::
434 * Attribute Unconstrained_Array::
435 * Attribute Universal_Literal_String::
436 * Attribute Unrestricted_Access::
437 * Attribute Update::
438 * Attribute Valid_Scalars::
439 * Attribute VADS_Size::
440 * Attribute Value_Size::
441 * Attribute Wchar_T_Size::
442 * Attribute Word_Size::
443
444 Standard and Implementation Defined Restrictions
445
446 * Partition-Wide Restrictions::
447 * Program Unit Level Restrictions::
448
449 Partition-Wide Restrictions
450
451 * Immediate_Reclamation::
452 * Max_Asynchronous_Select_Nesting::
453 * Max_Entry_Queue_Length::
454 * Max_Protected_Entries::
455 * Max_Select_Alternatives::
456 * Max_Storage_At_Blocking::
457 * Max_Task_Entries::
458 * Max_Tasks::
459 * No_Abort_Statements::
460 * No_Access_Parameter_Allocators::
461 * No_Access_Subprograms::
462 * No_Allocators::
463 * No_Anonymous_Allocators::
464 * No_Asynchronous_Control::
465 * No_Calendar::
466 * No_Coextensions::
467 * No_Default_Initialization::
468 * No_Delay::
469 * No_Dependence::
470 * No_Direct_Boolean_Operators::
471 * No_Dispatch::
472 * No_Dispatching_Calls::
473 * No_Dynamic_Attachment::
474 * No_Dynamic_Priorities::
475 * No_Entry_Calls_In_Elaboration_Code::
476 * No_Enumeration_Maps::
477 * No_Exception_Handlers::
478 * No_Exception_Propagation::
479 * No_Exception_Registration::
480 * No_Exceptions::
481 * No_Finalization::
482 * No_Fixed_Point::
483 * No_Floating_Point::
484 * No_Implicit_Conditionals::
485 * No_Implicit_Dynamic_Code::
486 * No_Implicit_Heap_Allocations::
487 * No_Implicit_Protected_Object_Allocations::
488 * No_Implicit_Task_Allocations::
489 * No_Initialize_Scalars::
490 * No_IO::
491 * No_Local_Allocators::
492 * No_Local_Protected_Objects::
493 * No_Local_Timing_Events::
494 * No_Long_Long_Integers::
495 * No_Multiple_Elaboration::
496 * No_Nested_Finalization::
497 * No_Protected_Type_Allocators::
498 * No_Protected_Types::
499 * No_Recursion::
500 * No_Reentrancy::
501 * No_Relative_Delay::
502 * No_Requeue_Statements::
503 * No_Secondary_Stack::
504 * No_Select_Statements::
505 * No_Specific_Termination_Handlers::
506 * No_Specification_of_Aspect::
507 * No_Standard_Allocators_After_Elaboration::
508 * No_Standard_Storage_Pools::
509 * No_Stream_Optimizations::
510 * No_Streams::
511 * No_Task_Allocators::
512 * No_Task_At_Interrupt_Priority::
513 * No_Task_Attributes_Package::
514 * No_Task_Hierarchy::
515 * No_Task_Termination::
516 * No_Tasking::
517 * No_Terminate_Alternatives::
518 * No_Unchecked_Access::
519 * No_Unchecked_Conversion::
520 * No_Unchecked_Deallocation::
521 * No_Use_Of_Entity::
522 * Pure_Barriers::
523 * Simple_Barriers::
524 * Static_Priorities::
525 * Static_Storage_Size::
526
527 Program Unit Level Restrictions
528
529 * No_Elaboration_Code::
530 * No_Dynamic_Sized_Objects::
531 * No_Entry_Queue::
532 * No_Implementation_Aspect_Specifications::
533 * No_Implementation_Attributes::
534 * No_Implementation_Identifiers::
535 * No_Implementation_Pragmas::
536 * No_Implementation_Restrictions::
537 * No_Implementation_Units::
538 * No_Implicit_Aliasing::
539 * No_Implicit_Loops::
540 * No_Obsolescent_Features::
541 * No_Wide_Characters::
542 * Static_Dispatch_Tables::
543 * SPARK_05::
544
545 Implementation Advice
546
547 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection.
548 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units.
549 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors.
550 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas.
551 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas.
552 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets.
553 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types.
554 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types.
555 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values.
556 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types.
557 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays.
558 * RM 9.6(30-31); Duration'Small: RM 9 6 30-31 Duration'Small.
559 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation.
560 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information.
561 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks.
562 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses.
563 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types.
564 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses.
565 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses.
566 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses.
567 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses.
568 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses.
569 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses.
570 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses.
571 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes.
572 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering.
573 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private.
574 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations.
575 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion.
576 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage.
577 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation.
578 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes.
579 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types.
580 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling.
581 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling.
582 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation.
583 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate.
584 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export.
585 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces.
586 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C.
587 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL.
588 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran.
589 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations.
590 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations.
591 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support.
592 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers.
593 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts.
594 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements.
595 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names.
596 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes.
597 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies.
598 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies.
599 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort.
600 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions.
601 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time.
602 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem.
603 * RM F(7); COBOL Support: RM F 7 COBOL Support.
604 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support.
605 * RM G; Numerics: RM G Numerics.
606 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types.
607 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions.
608 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements.
609 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy.
610 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy.
611
612 Intrinsic Subprograms
613
614 * Intrinsic Operators::
615 * Compilation_ISO_Date::
616 * Compilation_Date::
617 * Compilation_Time::
618 * Enclosing_Entity::
619 * Exception_Information::
620 * Exception_Message::
621 * Exception_Name::
622 * File::
623 * Line::
624 * Shifts and Rotates::
625 * Source_Location::
626
627 Representation Clauses and Pragmas
628
629 * Alignment Clauses::
630 * Size Clauses::
631 * Storage_Size Clauses::
632 * Size of Variant Record Objects::
633 * Biased Representation::
634 * Value_Size and Object_Size Clauses::
635 * Component_Size Clauses::
636 * Bit_Order Clauses::
637 * Effect of Bit_Order on Byte Ordering::
638 * Pragma Pack for Arrays::
639 * Pragma Pack for Records::
640 * Record Representation Clauses::
641 * Handling of Records with Holes::
642 * Enumeration Clauses::
643 * Address Clauses::
644 * Use of Address Clauses for Memory-Mapped I/O::
645 * Effect of Convention on Representation::
646 * Conventions and Anonymous Access Types::
647 * Determining the Representations chosen by GNAT::
648
649 The Implementation of Standard I/O
650
651 * Standard I/O Packages::
652 * FORM Strings::
653 * Direct_IO::
654 * Sequential_IO::
655 * Text_IO::
656 * Wide_Text_IO::
657 * Wide_Wide_Text_IO::
658 * Stream_IO::
659 * Text Translation::
660 * Shared Files::
661 * Filenames encoding::
662 * File content encoding::
663 * Open Modes::
664 * Operations on C Streams::
665 * Interfacing to C Streams::
666
667 Text_IO
668
669 * Stream Pointer Positioning::
670 * Reading and Writing Non-Regular Files::
671 * Get_Immediate::
672 * Treating Text_IO Files as Streams::
673 * Text_IO Extensions::
674 * Text_IO Facilities for Unbounded Strings::
675
676 Wide_Text_IO
677
678 * Stream Pointer Positioning: Stream Pointer Positioning<2>.
679 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>.
680
681 Wide_Wide_Text_IO
682
683 * Stream Pointer Positioning: Stream Pointer Positioning<3>.
684 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>.
685
686 The GNAT Library
687
688 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads.
689 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads.
690 * Ada.Characters.Wide_Latin_9 (a-cwila1.ads): Ada Characters Wide_Latin_9 a-cwila1 ads.
691 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads.
692 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads.
693 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads): Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads.
694 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads): Ada Containers Formal_Hashed_Maps a-cfhama ads.
695 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads): Ada Containers Formal_Hashed_Sets a-cfhase ads.
696 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads): Ada Containers Formal_Ordered_Maps a-cforma ads.
697 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads): Ada Containers Formal_Ordered_Sets a-cforse ads.
698 * Ada.Containers.Formal_Vectors (a-cofove.ads): Ada Containers Formal_Vectors a-cofove ads.
699 * Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads): Ada Containers Formal_Indefinite_Vectors a-cfinve ads.
700 * Ada.Containers.Functional_Vectors (a-cofuve.ads): Ada Containers Functional_Vectors a-cofuve ads.
701 * Ada.Containers.Functional_Sets (a-cofuse.ads): Ada Containers Functional_Sets a-cofuse ads.
702 * Ada.Containers.Functional_Maps (a-cofuma.ads): Ada Containers Functional_Maps a-cofuma ads.
703 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads.
704 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads.
705 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads.
706 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads.
707 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads.
708 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads.
709 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads.
710 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads.
711 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads.
712 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads.
713 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads.
714 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads.
715 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads.
716 * Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads.
717 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads.
718 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads.
719 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads.
720 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads.
721 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads.
722 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads.
723 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads.
724 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads.
725 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads.
726 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads.
727 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads.
728 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads.
729 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads.
730 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads.
731 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads.
732 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads.
733 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads.
734 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads.
735 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads.
736 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads.
737 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads.
738 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads.
739 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads.
740 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads.
741 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads.
742 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads.
743 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads.
744 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads.
745 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads.
746 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads.
747 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads.
748 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads.
749 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads.
750 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads.
751 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads.
752 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads.
753 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads.
754 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads.
755 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads.
756 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads.
757 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads.
758 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads.
759 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads.
760 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads.
761 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads.
762 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads.
763 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads.
764 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads.
765 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads.
766 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads.
767 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads.
768 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads.
769 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads.
770 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads.
771 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads.
772 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads.
773 * GNAT.IO (g-io.ads): GNAT IO g-io ads.
774 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads.
775 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads.
776 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads.
777 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads.
778 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads.
779 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads.
780 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads.
781 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads.
782 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads.
783 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads.
784 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads.
785 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads.
786 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads.
787 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads.
788 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads.
789 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads.
790 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads.
791 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads.
792 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads.
793 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads.
794 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads.
795 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads.
796 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads.
797 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads.
798 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads.
799 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads.
800 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads.
801 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads.
802 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads.
803 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads.
804 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads.
805 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads.
806 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads.
807 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads.
808 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads.
809 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads.
810 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads.
811 * GNAT.Table (g-table.ads): GNAT Table g-table ads.
812 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads.
813 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads.
814 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads.
815 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads.
816 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads.
817 * GNAT.UTF_32 (g-table.ads): GNAT UTF_32 g-table ads.
818 * GNAT.Wide_Spelling_Checker (g-u3spch.ads): GNAT Wide_Spelling_Checker g-u3spch ads.
819 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads.
820 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads.
821 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads.
822 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads.
823 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads.
824 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads.
825 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads.
826 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads.
827 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads.
828 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads.
829 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads.
830 * System.Assertions (s-assert.ads): System Assertions s-assert ads.
831 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads.
832 * System.Memory (s-memory.ads): System Memory s-memory ads.
833 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads.
834 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads.
835 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads.
836 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads.
837 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads.
838 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads.
839 * System.Rident (s-rident.ads): System Rident s-rident ads.
840 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads.
841 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads.
842 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads.
843 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads.
844
845 Interfacing to Other Languages
846
847 * Interfacing to C::
848 * Interfacing to C++::
849 * Interfacing to COBOL::
850 * Interfacing to Fortran::
851 * Interfacing to non-GNAT Ada code::
852
853 Implementation of Specific Ada Features
854
855 * Machine Code Insertions::
856 * GNAT Implementation of Tasking::
857 * GNAT Implementation of Shared Passive Packages::
858 * Code Generation for Array Aggregates::
859 * The Size of Discriminated Records with Default Discriminants::
860 * Strict Conformance to the Ada Reference Manual::
861
862 GNAT Implementation of Tasking
863
864 * Mapping Ada Tasks onto the Underlying Kernel Threads::
865 * Ensuring Compliance with the Real-Time Annex::
866 * Support for Locking Policies::
867
868 Code Generation for Array Aggregates
869
870 * Static constant aggregates with static bounds::
871 * Constant aggregates with unconstrained nominal types::
872 * Aggregates with static bounds::
873 * Aggregates with nonstatic bounds::
874 * Aggregates in assignment statements::
875
876 Obsolescent Features
877
878 * pragma No_Run_Time::
879 * pragma Ravenscar::
880 * pragma Restricted_Run_Time::
881 * pragma Task_Info::
882 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads.
883
884 Compatibility and Porting Guide
885
886 * Writing Portable Fixed-Point Declarations::
887 * Compatibility with Ada 83::
888 * Compatibility between Ada 95 and Ada 2005::
889 * Implementation-dependent characteristics::
890 * Compatibility with Other Ada Systems::
891 * Representation Clauses::
892 * Compatibility with HP Ada 83::
893
894 Compatibility with Ada 83
895
896 * Legal Ada 83 programs that are illegal in Ada 95::
897 * More deterministic semantics::
898 * Changed semantics::
899 * Other language compatibility issues::
900
901 Implementation-dependent characteristics
902
903 * Implementation-defined pragmas::
904 * Implementation-defined attributes::
905 * Libraries::
906 * Elaboration order::
907 * Target-specific aspects::
908
909 @end detailmenu
910 @end menu
911
912 @node About This Guide,Implementation Defined Pragmas,Top,Top
913 @anchor{gnat_rm/about_this_guide about-this-guide}@anchor{2}@anchor{gnat_rm/about_this_guide doc}@anchor{3}@anchor{gnat_rm/about_this_guide gnat-reference-manual}@anchor{4}@anchor{gnat_rm/about_this_guide id1}@anchor{5}
914 @chapter About This Guide
915
916
917
918 This manual contains useful information in writing programs using the
919 GNAT compiler. It includes information on implementation dependent
920 characteristics of GNAT, including all the information required by
921 Annex M of the Ada language standard.
922
923 GNAT implements Ada 95, Ada 2005 and Ada 2012, and it may also be
924 invoked in Ada 83 compatibility mode.
925 By default, GNAT assumes Ada 2012,
926 but you can override with a compiler switch
927 to explicitly specify the language version.
928 (Please refer to the @emph{GNAT User's Guide} for details on these switches.)
929 Throughout this manual, references to 'Ada' without a year suffix
930 apply to all the Ada versions of the language.
931
932 Ada is designed to be highly portable.
933 In general, a program will have the same effect even when compiled by
934 different compilers on different platforms.
935 However, since Ada is designed to be used in a
936 wide variety of applications, it also contains a number of system
937 dependent features to be used in interfacing to the external world.
938
939 @geindex Implementation-dependent features
940
941 @geindex Portability
942
943 Note: Any program that makes use of implementation-dependent features
944 may be non-portable. You should follow good programming practice and
945 isolate and clearly document any sections of your program that make use
946 of these features in a non-portable manner.
947
948 @menu
949 * What This Reference Manual Contains::
950 * Conventions::
951 * Related Information::
952
953 @end menu
954
955 @node What This Reference Manual Contains,Conventions,,About This Guide
956 @anchor{gnat_rm/about_this_guide what-this-reference-manual-contains}@anchor{6}
957 @section What This Reference Manual Contains
958
959
960 This reference manual contains the following chapters:
961
962
963 @itemize *
964
965 @item
966 @ref{7,,Implementation Defined Pragmas}, lists GNAT implementation-dependent
967 pragmas, which can be used to extend and enhance the functionality of the
968 compiler.
969
970 @item
971 @ref{8,,Implementation Defined Attributes}, lists GNAT
972 implementation-dependent attributes, which can be used to extend and
973 enhance the functionality of the compiler.
974
975 @item
976 @ref{9,,Standard and Implementation Defined Restrictions}, lists GNAT
977 implementation-dependent restrictions, which can be used to extend and
978 enhance the functionality of the compiler.
979
980 @item
981 @ref{a,,Implementation Advice}, provides information on generally
982 desirable behavior which are not requirements that all compilers must
983 follow since it cannot be provided on all systems, or which may be
984 undesirable on some systems.
985
986 @item
987 @ref{b,,Implementation Defined Characteristics}, provides a guide to
988 minimizing implementation dependent features.
989
990 @item
991 @ref{c,,Intrinsic Subprograms}, describes the intrinsic subprograms
992 implemented by GNAT, and how they can be imported into user
993 application programs.
994
995 @item
996 @ref{d,,Representation Clauses and Pragmas}, describes in detail the
997 way that GNAT represents data, and in particular the exact set
998 of representation clauses and pragmas that is accepted.
999
1000 @item
1001 @ref{e,,Standard Library Routines}, provides a listing of packages and a
1002 brief description of the functionality that is provided by Ada's
1003 extensive set of standard library routines as implemented by GNAT.
1004
1005 @item
1006 @ref{f,,The Implementation of Standard I/O}, details how the GNAT
1007 implementation of the input-output facilities.
1008
1009 @item
1010 @ref{10,,The GNAT Library}, is a catalog of packages that complement
1011 the Ada predefined library.
1012
1013 @item
1014 @ref{11,,Interfacing to Other Languages}, describes how programs
1015 written in Ada using GNAT can be interfaced to other programming
1016 languages.
1017
1018 @item
1019 @ref{12,,Specialized Needs Annexes}, describes the GNAT implementation of all
1020 of the specialized needs annexes.
1021
1022 @item
1023 @ref{13,,Implementation of Specific Ada Features}, discusses issues related
1024 to GNAT's implementation of machine code insertions, tasking, and several
1025 other features.
1026
1027 @item
1028 @ref{14,,Implementation of Ada 2012 Features}, describes the status of the
1029 GNAT implementation of the Ada 2012 language standard.
1030
1031 @item
1032 @ref{15,,Obsolescent Features} documents implementation dependent features,
1033 including pragmas and attributes, which are considered obsolescent, since
1034 there are other preferred ways of achieving the same results. These
1035 obsolescent forms are retained for backwards compatibility.
1036
1037 @item
1038 @ref{16,,Compatibility and Porting Guide} presents some guidelines for
1039 developing portable Ada code, describes the compatibility issues that
1040 may arise between GNAT and other Ada compilation systems (including those
1041 for Ada 83), and shows how GNAT can expedite porting applications
1042 developed in other Ada environments.
1043
1044 @item
1045 @ref{1,,GNU Free Documentation License} contains the license for this document.
1046 @end itemize
1047
1048 @geindex Ada 95 Language Reference Manual
1049
1050 @geindex Ada 2005 Language Reference Manual
1051
1052 This reference manual assumes a basic familiarity with the Ada 95 language, as
1053 described in the
1054 @cite{International Standard ANSI/ISO/IEC-8652:1995}.
1055 It does not require knowledge of the new features introduced by Ada 2005 or
1056 Ada 2012.
1057 All three reference manuals are included in the GNAT documentation
1058 package.
1059
1060 @node Conventions,Related Information,What This Reference Manual Contains,About This Guide
1061 @anchor{gnat_rm/about_this_guide conventions}@anchor{17}
1062 @section Conventions
1063
1064
1065 @geindex Conventions
1066 @geindex typographical
1067
1068 @geindex Typographical conventions
1069
1070 Following are examples of the typographical and graphic conventions used
1071 in this guide:
1072
1073
1074 @itemize *
1075
1076 @item
1077 @code{Functions}, @code{utility program names}, @code{standard names},
1078 and @code{classes}.
1079
1080 @item
1081 @code{Option flags}
1082
1083 @item
1084 @code{File names}
1085
1086 @item
1087 @code{Variables}
1088
1089 @item
1090 @emph{Emphasis}
1091
1092 @item
1093 [optional information or parameters]
1094
1095 @item
1096 Examples are described by text
1097
1098 @example
1099 and then shown this way.
1100 @end example
1101
1102 @item
1103 Commands that are entered by the user are shown as preceded by a prompt string
1104 comprising the @code{$} character followed by a space.
1105 @end itemize
1106
1107 @node Related Information,,Conventions,About This Guide
1108 @anchor{gnat_rm/about_this_guide related-information}@anchor{18}
1109 @section Related Information
1110
1111
1112 See the following documents for further information on GNAT:
1113
1114
1115 @itemize *
1116
1117 @item
1118 @cite{GNAT User's Guide for Native Platforms},
1119 which provides information on how to use the
1120 GNAT development environment.
1121
1122 @item
1123 @cite{Ada 95 Reference Manual}, the Ada 95 programming language standard.
1124
1125 @item
1126 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
1127 of the Ada 95 standard. The annotations describe
1128 detailed aspects of the design decision, and in particular contain useful
1129 sections on Ada 83 compatibility.
1130
1131 @item
1132 @cite{Ada 2005 Reference Manual}, the Ada 2005 programming language standard.
1133
1134 @item
1135 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
1136 of the Ada 2005 standard. The annotations describe
1137 detailed aspects of the design decision.
1138
1139 @item
1140 @cite{Ada 2012 Reference Manual}, the Ada 2012 programming language standard.
1141
1142 @item
1143 @cite{DEC Ada@comma{} Technical Overview and Comparison on DIGITAL Platforms},
1144 which contains specific information on compatibility between GNAT and
1145 DEC Ada 83 systems.
1146
1147 @item
1148 @cite{DEC Ada@comma{} Language Reference Manual}, part number AA-PYZAB-TK, which
1149 describes in detail the pragmas and attributes provided by the DEC Ada 83
1150 compiler system.
1151 @end itemize
1152
1153 @node Implementation Defined Pragmas,Implementation Defined Aspects,About This Guide,Top
1154 @anchor{gnat_rm/implementation_defined_pragmas implementation-defined-pragmas}@anchor{7}@anchor{gnat_rm/implementation_defined_pragmas doc}@anchor{19}@anchor{gnat_rm/implementation_defined_pragmas id1}@anchor{1a}
1155 @chapter Implementation Defined Pragmas
1156
1157
1158 Ada defines a set of pragmas that can be used to supply additional
1159 information to the compiler. These language defined pragmas are
1160 implemented in GNAT and work as described in the Ada Reference Manual.
1161
1162 In addition, Ada allows implementations to define additional pragmas
1163 whose meaning is defined by the implementation. GNAT provides a number
1164 of these implementation-defined pragmas, which can be used to extend
1165 and enhance the functionality of the compiler. This section of the GNAT
1166 Reference Manual describes these additional pragmas.
1167
1168 Note that any program using these pragmas might not be portable to other
1169 compilers (although GNAT implements this set of pragmas on all
1170 platforms). Therefore if portability to other compilers is an important
1171 consideration, the use of these pragmas should be minimized.
1172
1173 @menu
1174 * Pragma Abort_Defer::
1175 * Pragma Abstract_State::
1176 * Pragma Ada_83::
1177 * Pragma Ada_95::
1178 * Pragma Ada_05::
1179 * Pragma Ada_2005::
1180 * Pragma Ada_12::
1181 * Pragma Ada_2012::
1182 * Pragma Aggregate_Individually_Assign::
1183 * Pragma Allow_Integer_Address::
1184 * Pragma Annotate::
1185 * Pragma Assert::
1186 * Pragma Assert_And_Cut::
1187 * Pragma Assertion_Policy::
1188 * Pragma Assume::
1189 * Pragma Assume_No_Invalid_Values::
1190 * Pragma Async_Readers::
1191 * Pragma Async_Writers::
1192 * Pragma Attribute_Definition::
1193 * Pragma C_Pass_By_Copy::
1194 * Pragma Check::
1195 * Pragma Check_Float_Overflow::
1196 * Pragma Check_Name::
1197 * Pragma Check_Policy::
1198 * Pragma Comment::
1199 * Pragma Common_Object::
1200 * Pragma Compile_Time_Error::
1201 * Pragma Compile_Time_Warning::
1202 * Pragma Compiler_Unit::
1203 * Pragma Compiler_Unit_Warning::
1204 * Pragma Complete_Representation::
1205 * Pragma Complex_Representation::
1206 * Pragma Component_Alignment::
1207 * Pragma Constant_After_Elaboration::
1208 * Pragma Contract_Cases::
1209 * Pragma Convention_Identifier::
1210 * Pragma CPP_Class::
1211 * Pragma CPP_Constructor::
1212 * Pragma CPP_Virtual::
1213 * Pragma CPP_Vtable::
1214 * Pragma CPU::
1215 * Pragma Deadline_Floor::
1216 * Pragma Default_Initial_Condition::
1217 * Pragma Debug::
1218 * Pragma Debug_Policy::
1219 * Pragma Default_Scalar_Storage_Order::
1220 * Pragma Default_Storage_Pool::
1221 * Pragma Depends::
1222 * Pragma Detect_Blocking::
1223 * Pragma Disable_Atomic_Synchronization::
1224 * Pragma Dispatching_Domain::
1225 * Pragma Effective_Reads::
1226 * Pragma Effective_Writes::
1227 * Pragma Elaboration_Checks::
1228 * Pragma Eliminate::
1229 * Pragma Enable_Atomic_Synchronization::
1230 * Pragma Export_Function::
1231 * Pragma Export_Object::
1232 * Pragma Export_Procedure::
1233 * Pragma Export_Value::
1234 * Pragma Export_Valued_Procedure::
1235 * Pragma Extend_System::
1236 * Pragma Extensions_Allowed::
1237 * Pragma Extensions_Visible::
1238 * Pragma External::
1239 * Pragma External_Name_Casing::
1240 * Pragma Fast_Math::
1241 * Pragma Favor_Top_Level::
1242 * Pragma Finalize_Storage_Only::
1243 * Pragma Float_Representation::
1244 * Pragma Ghost::
1245 * Pragma Global::
1246 * Pragma Ident::
1247 * Pragma Ignore_Pragma::
1248 * Pragma Implementation_Defined::
1249 * Pragma Implemented::
1250 * Pragma Implicit_Packing::
1251 * Pragma Import_Function::
1252 * Pragma Import_Object::
1253 * Pragma Import_Procedure::
1254 * Pragma Import_Valued_Procedure::
1255 * Pragma Independent::
1256 * Pragma Independent_Components::
1257 * Pragma Initial_Condition::
1258 * Pragma Initialize_Scalars::
1259 * Pragma Initializes::
1260 * Pragma Inline_Always::
1261 * Pragma Inline_Generic::
1262 * Pragma Interface::
1263 * Pragma Interface_Name::
1264 * Pragma Interrupt_Handler::
1265 * Pragma Interrupt_State::
1266 * Pragma Invariant::
1267 * Pragma Keep_Names::
1268 * Pragma License::
1269 * Pragma Link_With::
1270 * Pragma Linker_Alias::
1271 * Pragma Linker_Constructor::
1272 * Pragma Linker_Destructor::
1273 * Pragma Linker_Section::
1274 * Pragma Lock_Free::
1275 * Pragma Loop_Invariant::
1276 * Pragma Loop_Optimize::
1277 * Pragma Loop_Variant::
1278 * Pragma Machine_Attribute::
1279 * Pragma Main::
1280 * Pragma Main_Storage::
1281 * Pragma Max_Queue_Length::
1282 * Pragma No_Body::
1283 * Pragma No_Caching::
1284 * Pragma No_Component_Reordering::
1285 * Pragma No_Elaboration_Code_All::
1286 * Pragma No_Heap_Finalization::
1287 * Pragma No_Inline::
1288 * Pragma No_Return::
1289 * Pragma No_Strict_Aliasing::
1290 * Pragma No_Tagged_Streams::
1291 * Pragma Normalize_Scalars::
1292 * Pragma Obsolescent::
1293 * Pragma Optimize_Alignment::
1294 * Pragma Ordered::
1295 * Pragma Overflow_Mode::
1296 * Pragma Overriding_Renamings::
1297 * Pragma Partition_Elaboration_Policy::
1298 * Pragma Part_Of::
1299 * Pragma Passive::
1300 * Pragma Persistent_BSS::
1301 * Pragma Post::
1302 * Pragma Postcondition::
1303 * Pragma Post_Class::
1304 * Pragma Rename_Pragma::
1305 * Pragma Pre::
1306 * Pragma Precondition::
1307 * Pragma Predicate::
1308 * Pragma Predicate_Failure::
1309 * Pragma Preelaborable_Initialization::
1310 * Pragma Prefix_Exception_Messages::
1311 * Pragma Pre_Class::
1312 * Pragma Priority_Specific_Dispatching::
1313 * Pragma Profile::
1314 * Pragma Profile_Warnings::
1315 * Pragma Propagate_Exceptions::
1316 * Pragma Provide_Shift_Operators::
1317 * Pragma Psect_Object::
1318 * Pragma Pure_Function::
1319 * Pragma Rational::
1320 * Pragma Ravenscar::
1321 * Pragma Refined_Depends::
1322 * Pragma Refined_Global::
1323 * Pragma Refined_Post::
1324 * Pragma Refined_State::
1325 * Pragma Relative_Deadline::
1326 * Pragma Remote_Access_Type::
1327 * Pragma Restricted_Run_Time::
1328 * Pragma Restriction_Warnings::
1329 * Pragma Reviewable::
1330 * Pragma Secondary_Stack_Size::
1331 * Pragma Share_Generic::
1332 * Pragma Shared::
1333 * Pragma Short_Circuit_And_Or::
1334 * Pragma Short_Descriptors::
1335 * Pragma Simple_Storage_Pool_Type::
1336 * Pragma Source_File_Name::
1337 * Pragma Source_File_Name_Project::
1338 * Pragma Source_Reference::
1339 * Pragma SPARK_Mode::
1340 * Pragma Static_Elaboration_Desired::
1341 * Pragma Stream_Convert::
1342 * Pragma Style_Checks::
1343 * Pragma Subtitle::
1344 * Pragma Suppress::
1345 * Pragma Suppress_All::
1346 * Pragma Suppress_Debug_Info::
1347 * Pragma Suppress_Exception_Locations::
1348 * Pragma Suppress_Initialization::
1349 * Pragma Task_Name::
1350 * Pragma Task_Storage::
1351 * Pragma Test_Case::
1352 * Pragma Thread_Local_Storage::
1353 * Pragma Time_Slice::
1354 * Pragma Title::
1355 * Pragma Type_Invariant::
1356 * Pragma Type_Invariant_Class::
1357 * Pragma Unchecked_Union::
1358 * Pragma Unevaluated_Use_Of_Old::
1359 * Pragma Unimplemented_Unit::
1360 * Pragma Universal_Aliasing::
1361 * Pragma Universal_Data::
1362 * Pragma Unmodified::
1363 * Pragma Unreferenced::
1364 * Pragma Unreferenced_Objects::
1365 * Pragma Unreserve_All_Interrupts::
1366 * Pragma Unsuppress::
1367 * Pragma Use_VADS_Size::
1368 * Pragma Unused::
1369 * Pragma Validity_Checks::
1370 * Pragma Volatile::
1371 * Pragma Volatile_Full_Access::
1372 * Pragma Volatile_Function::
1373 * Pragma Warning_As_Error::
1374 * Pragma Warnings::
1375 * Pragma Weak_External::
1376 * Pragma Wide_Character_Encoding::
1377
1378 @end menu
1379
1380 @node Pragma Abort_Defer,Pragma Abstract_State,,Implementation Defined Pragmas
1381 @anchor{gnat_rm/implementation_defined_pragmas pragma-abort-defer}@anchor{1b}
1382 @section Pragma Abort_Defer
1383
1384
1385 @geindex Deferring aborts
1386
1387 Syntax:
1388
1389 @example
1390 pragma Abort_Defer;
1391 @end example
1392
1393 This pragma must appear at the start of the statement sequence of a
1394 handled sequence of statements (right after the @code{begin}). It has
1395 the effect of deferring aborts for the sequence of statements (but not
1396 for the declarations or handlers, if any, associated with this statement
1397 sequence).
1398
1399 @node Pragma Abstract_State,Pragma Ada_83,Pragma Abort_Defer,Implementation Defined Pragmas
1400 @anchor{gnat_rm/implementation_defined_pragmas pragma-abstract-state}@anchor{1c}@anchor{gnat_rm/implementation_defined_pragmas id2}@anchor{1d}
1401 @section Pragma Abstract_State
1402
1403
1404 Syntax:
1405
1406 @example
1407 pragma Abstract_State (ABSTRACT_STATE_LIST);
1408
1409 ABSTRACT_STATE_LIST ::=
1410 null
1411 | STATE_NAME_WITH_OPTIONS
1412 | (STATE_NAME_WITH_OPTIONS @{, STATE_NAME_WITH_OPTIONS@} )
1413
1414 STATE_NAME_WITH_OPTIONS ::=
1415 STATE_NAME
1416 | (STATE_NAME with OPTION_LIST)
1417
1418 OPTION_LIST ::= OPTION @{, OPTION@}
1419
1420 OPTION ::=
1421 SIMPLE_OPTION
1422 | NAME_VALUE_OPTION
1423
1424 SIMPLE_OPTION ::= Ghost | Synchronous
1425
1426 NAME_VALUE_OPTION ::=
1427 Part_Of => ABSTRACT_STATE
1428 | External [=> EXTERNAL_PROPERTY_LIST]
1429
1430 EXTERNAL_PROPERTY_LIST ::=
1431 EXTERNAL_PROPERTY
1432 | (EXTERNAL_PROPERTY @{, EXTERNAL_PROPERTY@} )
1433
1434 EXTERNAL_PROPERTY ::=
1435 Async_Readers [=> boolean_EXPRESSION]
1436 | Async_Writers [=> boolean_EXPRESSION]
1437 | Effective_Reads [=> boolean_EXPRESSION]
1438 | Effective_Writes [=> boolean_EXPRESSION]
1439 others => boolean_EXPRESSION
1440
1441 STATE_NAME ::= defining_identifier
1442
1443 ABSTRACT_STATE ::= name
1444 @end example
1445
1446 For the semantics of this pragma, see the entry for aspect @code{Abstract_State} in
1447 the SPARK 2014 Reference Manual, section 7.1.4.
1448
1449 @node Pragma Ada_83,Pragma Ada_95,Pragma Abstract_State,Implementation Defined Pragmas
1450 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-83}@anchor{1e}
1451 @section Pragma Ada_83
1452
1453
1454 Syntax:
1455
1456 @example
1457 pragma Ada_83;
1458 @end example
1459
1460 A configuration pragma that establishes Ada 83 mode for the unit to
1461 which it applies, regardless of the mode set by the command line
1462 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1463 the syntax and semantics of Ada 83, as defined in the original Ada
1464 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1465 and Ada 2005 are not recognized, optional package bodies are allowed,
1466 and generics may name types with unknown discriminants without using
1467 the @code{(<>)} notation. In addition, some but not all of the additional
1468 restrictions of Ada 83 are enforced.
1469
1470 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1471 Ada 83 code to be compiled and adapted to GNAT with less effort.
1472 Secondly, it aids in keeping code backwards compatible with Ada 83.
1473 However, there is no guarantee that code that is processed correctly
1474 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1475 83 compiler, since GNAT does not enforce all the additional checks
1476 required by Ada 83.
1477
1478 @node Pragma Ada_95,Pragma Ada_05,Pragma Ada_83,Implementation Defined Pragmas
1479 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-95}@anchor{1f}
1480 @section Pragma Ada_95
1481
1482
1483 Syntax:
1484
1485 @example
1486 pragma Ada_95;
1487 @end example
1488
1489 A configuration pragma that establishes Ada 95 mode for the unit to which
1490 it applies, regardless of the mode set by the command line switches.
1491 This mode is set automatically for the @code{Ada} and @code{System}
1492 packages and their children, so you need not specify it in these
1493 contexts. This pragma is useful when writing a reusable component that
1494 itself uses Ada 95 features, but which is intended to be usable from
1495 either Ada 83 or Ada 95 programs.
1496
1497 @node Pragma Ada_05,Pragma Ada_2005,Pragma Ada_95,Implementation Defined Pragmas
1498 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-05}@anchor{20}
1499 @section Pragma Ada_05
1500
1501
1502 Syntax:
1503
1504 @example
1505 pragma Ada_05;
1506 pragma Ada_05 (local_NAME);
1507 @end example
1508
1509 A configuration pragma that establishes Ada 2005 mode for the unit to which
1510 it applies, regardless of the mode set by the command line switches.
1511 This pragma is useful when writing a reusable component that
1512 itself uses Ada 2005 features, but which is intended to be usable from
1513 either Ada 83 or Ada 95 programs.
1514
1515 The one argument form (which is not a configuration pragma)
1516 is used for managing the transition from
1517 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1518 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1519 mode will generate a warning. In addition, in Ada_83 or Ada_95
1520 mode, a preference rule is established which does not choose
1521 such an entity unless it is unambiguously specified. This avoids
1522 extra subprograms marked this way from generating ambiguities in
1523 otherwise legal pre-Ada_2005 programs. The one argument form is
1524 intended for exclusive use in the GNAT run-time library.
1525
1526 @node Pragma Ada_2005,Pragma Ada_12,Pragma Ada_05,Implementation Defined Pragmas
1527 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2005}@anchor{21}
1528 @section Pragma Ada_2005
1529
1530
1531 Syntax:
1532
1533 @example
1534 pragma Ada_2005;
1535 @end example
1536
1537 This configuration pragma is a synonym for pragma Ada_05 and has the
1538 same syntax and effect.
1539
1540 @node Pragma Ada_12,Pragma Ada_2012,Pragma Ada_2005,Implementation Defined Pragmas
1541 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-12}@anchor{22}
1542 @section Pragma Ada_12
1543
1544
1545 Syntax:
1546
1547 @example
1548 pragma Ada_12;
1549 pragma Ada_12 (local_NAME);
1550 @end example
1551
1552 A configuration pragma that establishes Ada 2012 mode for the unit to which
1553 it applies, regardless of the mode set by the command line switches.
1554 This mode is set automatically for the @code{Ada} and @code{System}
1555 packages and their children, so you need not specify it in these
1556 contexts. This pragma is useful when writing a reusable component that
1557 itself uses Ada 2012 features, but which is intended to be usable from
1558 Ada 83, Ada 95, or Ada 2005 programs.
1559
1560 The one argument form, which is not a configuration pragma,
1561 is used for managing the transition from Ada
1562 2005 to Ada 2012 in the run-time library. If an entity is marked
1563 as Ada_2012 only, then referencing the entity in any pre-Ada_2012
1564 mode will generate a warning. In addition, in any pre-Ada_2012
1565 mode, a preference rule is established which does not choose
1566 such an entity unless it is unambiguously specified. This avoids
1567 extra subprograms marked this way from generating ambiguities in
1568 otherwise legal pre-Ada_2012 programs. The one argument form is
1569 intended for exclusive use in the GNAT run-time library.
1570
1571 @node Pragma Ada_2012,Pragma Aggregate_Individually_Assign,Pragma Ada_12,Implementation Defined Pragmas
1572 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2012}@anchor{23}
1573 @section Pragma Ada_2012
1574
1575
1576 Syntax:
1577
1578 @example
1579 pragma Ada_2012;
1580 @end example
1581
1582 This configuration pragma is a synonym for pragma Ada_12 and has the
1583 same syntax and effect.
1584
1585 @node Pragma Aggregate_Individually_Assign,Pragma Allow_Integer_Address,Pragma Ada_2012,Implementation Defined Pragmas
1586 @anchor{gnat_rm/implementation_defined_pragmas pragma-aggregate-individually-assign}@anchor{24}
1587 @section Pragma Aggregate_Individually_Assign
1588
1589
1590 Syntax:
1591
1592 @example
1593 pragma Aggregate_Individually_Assign;
1594 @end example
1595
1596 Where possible, GNAT will store the binary representation of a record aggregate
1597 in memory for space and performance reasons. This configuration pragma changes
1598 this behavior so that record aggregates are instead always converted into
1599 individual assignment statements.
1600
1601 @node Pragma Allow_Integer_Address,Pragma Annotate,Pragma Aggregate_Individually_Assign,Implementation Defined Pragmas
1602 @anchor{gnat_rm/implementation_defined_pragmas pragma-allow-integer-address}@anchor{25}
1603 @section Pragma Allow_Integer_Address
1604
1605
1606 Syntax:
1607
1608 @example
1609 pragma Allow_Integer_Address;
1610 @end example
1611
1612 In almost all versions of GNAT, @code{System.Address} is a private
1613 type in accordance with the implementation advice in the RM. This
1614 means that integer values,
1615 in particular integer literals, are not allowed as address values.
1616 If the configuration pragma
1617 @code{Allow_Integer_Address} is given, then integer expressions may
1618 be used anywhere a value of type @code{System.Address} is required.
1619 The effect is to introduce an implicit unchecked conversion from the
1620 integer value to type @code{System.Address}. The reverse case of using
1621 an address where an integer type is required is handled analogously.
1622 The following example compiles without errors:
1623
1624 @example
1625 pragma Allow_Integer_Address;
1626 with System; use System;
1627 package AddrAsInt is
1628 X : Integer;
1629 Y : Integer;
1630 for X'Address use 16#1240#;
1631 for Y use at 16#3230#;
1632 m : Address := 16#4000#;
1633 n : constant Address := 4000;
1634 p : constant Address := Address (X + Y);
1635 v : Integer := y'Address;
1636 w : constant Integer := Integer (Y'Address);
1637 type R is new integer;
1638 RR : R := 1000;
1639 Z : Integer;
1640 for Z'Address use RR;
1641 end AddrAsInt;
1642 @end example
1643
1644 Note that pragma @code{Allow_Integer_Address} is ignored if @code{System.Address}
1645 is not a private type. In implementations of @code{GNAT} where
1646 System.Address is a visible integer type,
1647 this pragma serves no purpose but is ignored
1648 rather than rejected to allow common sets of sources to be used
1649 in the two situations.
1650
1651 @node Pragma Annotate,Pragma Assert,Pragma Allow_Integer_Address,Implementation Defined Pragmas
1652 @anchor{gnat_rm/implementation_defined_pragmas pragma-annotate}@anchor{26}@anchor{gnat_rm/implementation_defined_pragmas id3}@anchor{27}
1653 @section Pragma Annotate
1654
1655
1656 Syntax:
1657
1658 @example
1659 pragma Annotate (IDENTIFIER [, IDENTIFIER @{, ARG@}] [, entity => local_NAME]);
1660
1661 ARG ::= NAME | EXPRESSION
1662 @end example
1663
1664 This pragma is used to annotate programs. IDENTIFIER identifies
1665 the type of annotation. GNAT verifies that it is an identifier, but does
1666 not otherwise analyze it. The second optional identifier is also left
1667 unanalyzed, and by convention is used to control the action of the tool to
1668 which the annotation is addressed. The remaining ARG arguments
1669 can be either string literals or more generally expressions.
1670 String literals (and concatenations of string literals) are assumed to be
1671 either of type
1672 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1673 depending on the character literals they contain.
1674 All other kinds of arguments are analyzed as expressions, and must be
1675 unambiguous. The last argument if present must have the identifier
1676 @code{Entity} and GNAT verifies that a local name is given.
1677
1678 The analyzed pragma is retained in the tree, but not otherwise processed
1679 by any part of the GNAT compiler, except to generate corresponding note
1680 lines in the generated ALI file. For the format of these note lines, see
1681 the compiler source file lib-writ.ads. This pragma is intended for use by
1682 external tools, including ASIS. The use of pragma Annotate does not
1683 affect the compilation process in any way. This pragma may be used as
1684 a configuration pragma.
1685
1686 @node Pragma Assert,Pragma Assert_And_Cut,Pragma Annotate,Implementation Defined Pragmas
1687 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert}@anchor{28}
1688 @section Pragma Assert
1689
1690
1691 Syntax:
1692
1693 @example
1694 pragma Assert (
1695 boolean_EXPRESSION
1696 [, string_EXPRESSION]);
1697 @end example
1698
1699 The effect of this pragma depends on whether the corresponding command
1700 line switch is set to activate assertions. The pragma expands into code
1701 equivalent to the following:
1702
1703 @example
1704 if assertions-enabled then
1705 if not boolean_EXPRESSION then
1706 System.Assertions.Raise_Assert_Failure
1707 (string_EXPRESSION);
1708 end if;
1709 end if;
1710 @end example
1711
1712 The string argument, if given, is the message that will be associated
1713 with the exception occurrence if the exception is raised. If no second
1714 argument is given, the default message is @code{file}:@code{nnn},
1715 where @code{file} is the name of the source file containing the assert,
1716 and @code{nnn} is the line number of the assert.
1717
1718 Note that, as with the @code{if} statement to which it is equivalent, the
1719 type of the expression is either @code{Standard.Boolean}, or any type derived
1720 from this standard type.
1721
1722 Assert checks can be either checked or ignored. By default they are ignored.
1723 They will be checked if either the command line switch @emph{-gnata} is
1724 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1725 to enable @code{Assert_Checks}.
1726
1727 If assertions are ignored, then there
1728 is no run-time effect (and in particular, any side effects from the
1729 expression will not occur at run time). (The expression is still
1730 analyzed at compile time, and may cause types to be frozen if they are
1731 mentioned here for the first time).
1732
1733 If assertions are checked, then the given expression is tested, and if
1734 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1735 which results in the raising of @code{Assert_Failure} with the given message.
1736
1737 You should generally avoid side effects in the expression arguments of
1738 this pragma, because these side effects will turn on and off with the
1739 setting of the assertions mode, resulting in assertions that have an
1740 effect on the program. However, the expressions are analyzed for
1741 semantic correctness whether or not assertions are enabled, so turning
1742 assertions on and off cannot affect the legality of a program.
1743
1744 Note that the implementation defined policy @code{DISABLE}, given in a
1745 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1746
1747 Note: this is a standard language-defined pragma in versions
1748 of Ada from 2005 on. In GNAT, it is implemented in all versions
1749 of Ada, and the DISABLE policy is an implementation-defined
1750 addition.
1751
1752 @node Pragma Assert_And_Cut,Pragma Assertion_Policy,Pragma Assert,Implementation Defined Pragmas
1753 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert-and-cut}@anchor{29}
1754 @section Pragma Assert_And_Cut
1755
1756
1757 Syntax:
1758
1759 @example
1760 pragma Assert_And_Cut (
1761 boolean_EXPRESSION
1762 [, string_EXPRESSION]);
1763 @end example
1764
1765 The effect of this pragma is identical to that of pragma @code{Assert},
1766 except that in an @code{Assertion_Policy} pragma, the identifier
1767 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1768 (or disabled).
1769
1770 The intention is that this be used within a subprogram when the
1771 given test expresion sums up all the work done so far in the
1772 subprogram, so that the rest of the subprogram can be verified
1773 (informally or formally) using only the entry preconditions,
1774 and the expression in this pragma. This allows dividing up
1775 a subprogram into sections for the purposes of testing or
1776 formal verification. The pragma also serves as useful
1777 documentation.
1778
1779 @node Pragma Assertion_Policy,Pragma Assume,Pragma Assert_And_Cut,Implementation Defined Pragmas
1780 @anchor{gnat_rm/implementation_defined_pragmas pragma-assertion-policy}@anchor{2a}
1781 @section Pragma Assertion_Policy
1782
1783
1784 Syntax:
1785
1786 @example
1787 pragma Assertion_Policy (CHECK | DISABLE | IGNORE | SUPPRESSIBLE);
1788
1789 pragma Assertion_Policy (
1790 ASSERTION_KIND => POLICY_IDENTIFIER
1791 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1792
1793 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1794
1795 RM_ASSERTION_KIND ::= Assert |
1796 Static_Predicate |
1797 Dynamic_Predicate |
1798 Pre |
1799 Pre'Class |
1800 Post |
1801 Post'Class |
1802 Type_Invariant |
1803 Type_Invariant'Class
1804
1805 ID_ASSERTION_KIND ::= Assertions |
1806 Assert_And_Cut |
1807 Assume |
1808 Contract_Cases |
1809 Debug |
1810 Ghost |
1811 Invariant |
1812 Invariant'Class |
1813 Loop_Invariant |
1814 Loop_Variant |
1815 Postcondition |
1816 Precondition |
1817 Predicate |
1818 Refined_Post |
1819 Statement_Assertions
1820
1821 POLICY_IDENTIFIER ::= Check | Disable | Ignore | Suppressible
1822 @end example
1823
1824 This is a standard Ada 2012 pragma that is available as an
1825 implementation-defined pragma in earlier versions of Ada.
1826 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1827 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1828 are implementation defined additions recognized by the GNAT compiler.
1829
1830 The pragma applies in both cases to pragmas and aspects with matching
1831 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1832 applies to both the @code{Precondition} pragma
1833 and the aspect @code{Precondition}. Note that the identifiers for
1834 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
1835 Pre_Class and Post_Class), since these pragmas are intended to be
1836 identical to the corresponding aspects).
1837
1838 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1839 the corresponding pragma or aspect is activated.
1840 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1841 the corresponding pragma or aspect is deactivated.
1842 This pragma overrides the effect of the @emph{-gnata} switch on the
1843 command line.
1844 If the policy is @code{SUPPRESSIBLE}, then assertions are enabled by default,
1845 however, if the @emph{-gnatp} switch is specified all assertions are ignored.
1846
1847 The implementation defined policy @code{DISABLE} is like
1848 @code{IGNORE} except that it completely disables semantic
1849 checking of the corresponding pragma or aspect. This is
1850 useful when the pragma or aspect argument references subprograms
1851 in a with'ed package which is replaced by a dummy package
1852 for the final build.
1853
1854 The implementation defined assertion kind @code{Assertions} applies to all
1855 assertion kinds. The form with no assertion kind given implies this
1856 choice, so it applies to all assertion kinds (RM defined, and
1857 implementation defined).
1858
1859 The implementation defined assertion kind @code{Statement_Assertions}
1860 applies to @code{Assert}, @code{Assert_And_Cut},
1861 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
1862
1863 @node Pragma Assume,Pragma Assume_No_Invalid_Values,Pragma Assertion_Policy,Implementation Defined Pragmas
1864 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume}@anchor{2b}
1865 @section Pragma Assume
1866
1867
1868 Syntax:
1869
1870 @example
1871 pragma Assume (
1872 boolean_EXPRESSION
1873 [, string_EXPRESSION]);
1874 @end example
1875
1876 The effect of this pragma is identical to that of pragma @code{Assert},
1877 except that in an @code{Assertion_Policy} pragma, the identifier
1878 @code{Assume} is used to control whether it is ignored or checked
1879 (or disabled).
1880
1881 The intention is that this be used for assumptions about the
1882 external environment. So you cannot expect to verify formally
1883 or informally that the condition is met, this must be
1884 established by examining things outside the program itself.
1885 For example, we may have code that depends on the size of
1886 @code{Long_Long_Integer} being at least 64. So we could write:
1887
1888 @example
1889 pragma Assume (Long_Long_Integer'Size >= 64);
1890 @end example
1891
1892 This assumption cannot be proved from the program itself,
1893 but it acts as a useful run-time check that the assumption
1894 is met, and documents the need to ensure that it is met by
1895 reference to information outside the program.
1896
1897 @node Pragma Assume_No_Invalid_Values,Pragma Async_Readers,Pragma Assume,Implementation Defined Pragmas
1898 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume-no-invalid-values}@anchor{2c}
1899 @section Pragma Assume_No_Invalid_Values
1900
1901
1902 @geindex Invalid representations
1903
1904 @geindex Invalid values
1905
1906 Syntax:
1907
1908 @example
1909 pragma Assume_No_Invalid_Values (On | Off);
1910 @end example
1911
1912 This is a configuration pragma that controls the assumptions made by the
1913 compiler about the occurrence of invalid representations (invalid values)
1914 in the code.
1915
1916 The default behavior (corresponding to an Off argument for this pragma), is
1917 to assume that values may in general be invalid unless the compiler can
1918 prove they are valid. Consider the following example:
1919
1920 @example
1921 V1 : Integer range 1 .. 10;
1922 V2 : Integer range 11 .. 20;
1923 ...
1924 for J in V2 .. V1 loop
1925 ...
1926 end loop;
1927 @end example
1928
1929 if V1 and V2 have valid values, then the loop is known at compile
1930 time not to execute since the lower bound must be greater than the
1931 upper bound. However in default mode, no such assumption is made,
1932 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1933 is given, the compiler will assume that any occurrence of a variable
1934 other than in an explicit @code{'Valid} test always has a valid
1935 value, and the loop above will be optimized away.
1936
1937 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1938 you know your code is free of uninitialized variables and other
1939 possible sources of invalid representations, and may result in
1940 more efficient code. A program that accesses an invalid representation
1941 with this pragma in effect is erroneous, so no guarantees can be made
1942 about its behavior.
1943
1944 It is peculiar though permissible to use this pragma in conjunction
1945 with validity checking (-gnatVa). In such cases, accessing invalid
1946 values will generally give an exception, though formally the program
1947 is erroneous so there are no guarantees that this will always be the
1948 case, and it is recommended that these two options not be used together.
1949
1950 @node Pragma Async_Readers,Pragma Async_Writers,Pragma Assume_No_Invalid_Values,Implementation Defined Pragmas
1951 @anchor{gnat_rm/implementation_defined_pragmas pragma-async-readers}@anchor{2d}@anchor{gnat_rm/implementation_defined_pragmas id4}@anchor{2e}
1952 @section Pragma Async_Readers
1953
1954
1955 Syntax:
1956
1957 @example
1958 pragma Async_Readers [ (boolean_EXPRESSION) ];
1959 @end example
1960
1961 For the semantics of this pragma, see the entry for aspect @code{Async_Readers} in
1962 the SPARK 2014 Reference Manual, section 7.1.2.
1963
1964 @node Pragma Async_Writers,Pragma Attribute_Definition,Pragma Async_Readers,Implementation Defined Pragmas
1965 @anchor{gnat_rm/implementation_defined_pragmas id5}@anchor{2f}@anchor{gnat_rm/implementation_defined_pragmas pragma-async-writers}@anchor{30}
1966 @section Pragma Async_Writers
1967
1968
1969 Syntax:
1970
1971 @example
1972 pragma Async_Writers [ (boolean_EXPRESSION) ];
1973 @end example
1974
1975 For the semantics of this pragma, see the entry for aspect @code{Async_Writers} in
1976 the SPARK 2014 Reference Manual, section 7.1.2.
1977
1978 @node Pragma Attribute_Definition,Pragma C_Pass_By_Copy,Pragma Async_Writers,Implementation Defined Pragmas
1979 @anchor{gnat_rm/implementation_defined_pragmas pragma-attribute-definition}@anchor{31}
1980 @section Pragma Attribute_Definition
1981
1982
1983 Syntax:
1984
1985 @example
1986 pragma Attribute_Definition
1987 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1988 [Entity =>] LOCAL_NAME,
1989 [Expression =>] EXPRESSION | NAME);
1990 @end example
1991
1992 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1993 the attribute definition clause:
1994
1995 @example
1996 for Entity'Attribute use Expression;
1997 @end example
1998
1999 If @code{Attribute} is not a recognized attribute name, the pragma is
2000 ignored, and a warning is emitted. This allows source
2001 code to be written that takes advantage of some new attribute, while remaining
2002 compilable with earlier compilers.
2003
2004 @node Pragma C_Pass_By_Copy,Pragma Check,Pragma Attribute_Definition,Implementation Defined Pragmas
2005 @anchor{gnat_rm/implementation_defined_pragmas pragma-c-pass-by-copy}@anchor{32}
2006 @section Pragma C_Pass_By_Copy
2007
2008
2009 @geindex Passing by copy
2010
2011 Syntax:
2012
2013 @example
2014 pragma C_Pass_By_Copy
2015 ([Max_Size =>] static_integer_EXPRESSION);
2016 @end example
2017
2018 Normally the default mechanism for passing C convention records to C
2019 convention subprograms is to pass them by reference, as suggested by RM
2020 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
2021 this default, by requiring that record formal parameters be passed by
2022 copy if all of the following conditions are met:
2023
2024
2025 @itemize *
2026
2027 @item
2028 The size of the record type does not exceed the value specified for
2029 @code{Max_Size}.
2030
2031 @item
2032 The record type has @code{Convention C}.
2033
2034 @item
2035 The formal parameter has this record type, and the subprogram has a
2036 foreign (non-Ada) convention.
2037 @end itemize
2038
2039 If these conditions are met the argument is passed by copy; i.e., in a
2040 manner consistent with what C expects if the corresponding formal in the
2041 C prototype is a struct (rather than a pointer to a struct).
2042
2043 You can also pass records by copy by specifying the convention
2044 @code{C_Pass_By_Copy} for the record type, or by using the extended
2045 @code{Import} and @code{Export} pragmas, which allow specification of
2046 passing mechanisms on a parameter by parameter basis.
2047
2048 @node Pragma Check,Pragma Check_Float_Overflow,Pragma C_Pass_By_Copy,Implementation Defined Pragmas
2049 @anchor{gnat_rm/implementation_defined_pragmas pragma-check}@anchor{33}
2050 @section Pragma Check
2051
2052
2053 @geindex Assertions
2054
2055 @geindex Named assertions
2056
2057 Syntax:
2058
2059 @example
2060 pragma Check (
2061 [Name =>] CHECK_KIND,
2062 [Check =>] Boolean_EXPRESSION
2063 [, [Message =>] string_EXPRESSION] );
2064
2065 CHECK_KIND ::= IDENTIFIER |
2066 Pre'Class |
2067 Post'Class |
2068 Type_Invariant'Class |
2069 Invariant'Class
2070 @end example
2071
2072 This pragma is similar to the predefined pragma @code{Assert} except that an
2073 extra identifier argument is present. In conjunction with pragma
2074 @code{Check_Policy}, this can be used to define groups of assertions that can
2075 be independently controlled. The identifier @code{Assertion} is special, it
2076 refers to the normal set of pragma @code{Assert} statements.
2077
2078 Checks introduced by this pragma are normally deactivated by default. They can
2079 be activated either by the command line option @emph{-gnata}, which turns on
2080 all checks, or individually controlled using pragma @code{Check_Policy}.
2081
2082 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
2083 permitted as check kinds, since this would cause confusion with the use
2084 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
2085 pragmas, where they are used to refer to sets of assertions.
2086
2087 @node Pragma Check_Float_Overflow,Pragma Check_Name,Pragma Check,Implementation Defined Pragmas
2088 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-float-overflow}@anchor{34}
2089 @section Pragma Check_Float_Overflow
2090
2091
2092 @geindex Floating-point overflow
2093
2094 Syntax:
2095
2096 @example
2097 pragma Check_Float_Overflow;
2098 @end example
2099
2100 In Ada, the predefined floating-point types (@code{Short_Float},
2101 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
2102 defined to be @emph{unconstrained}. This means that even though each
2103 has a well-defined base range, an operation that delivers a result
2104 outside this base range is not required to raise an exception.
2105 This implementation permission accommodates the notion
2106 of infinities in IEEE floating-point, and corresponds to the
2107 efficient execution mode on most machines. GNAT will not raise
2108 overflow exceptions on these machines; instead it will generate
2109 infinities and NaN's as defined in the IEEE standard.
2110
2111 Generating infinities, although efficient, is not always desirable.
2112 Often the preferable approach is to check for overflow, even at the
2113 (perhaps considerable) expense of run-time performance.
2114 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
2115 range constraints -- and indeed such a subtype
2116 can have the same base range as its base type. For example:
2117
2118 @example
2119 subtype My_Float is Float range Float'Range;
2120 @end example
2121
2122 Here @code{My_Float} has the same range as
2123 @code{Float} but is constrained, so operations on
2124 @code{My_Float} values will be checked for overflow
2125 against this range.
2126
2127 This style will achieve the desired goal, but
2128 it is often more convenient to be able to simply use
2129 the standard predefined floating-point types as long
2130 as overflow checking could be guaranteed.
2131 The @code{Check_Float_Overflow}
2132 configuration pragma achieves this effect. If a unit is compiled
2133 subject to this configuration pragma, then all operations
2134 on predefined floating-point types including operations on
2135 base types of these floating-point types will be treated as
2136 though those types were constrained, and overflow checks
2137 will be generated. The @code{Constraint_Error}
2138 exception is raised if the result is out of range.
2139
2140 This mode can also be set by use of the compiler
2141 switch @emph{-gnateF}.
2142
2143 @node Pragma Check_Name,Pragma Check_Policy,Pragma Check_Float_Overflow,Implementation Defined Pragmas
2144 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-name}@anchor{35}
2145 @section Pragma Check_Name
2146
2147
2148 @geindex Defining check names
2149
2150 @geindex Check names
2151 @geindex defining
2152
2153 Syntax:
2154
2155 @example
2156 pragma Check_Name (check_name_IDENTIFIER);
2157 @end example
2158
2159 This is a configuration pragma that defines a new implementation
2160 defined check name (unless IDENTIFIER matches one of the predefined
2161 check names, in which case the pragma has no effect). Check names
2162 are global to a partition, so if two or more configuration pragmas
2163 are present in a partition mentioning the same name, only one new
2164 check name is introduced.
2165
2166 An implementation defined check name introduced with this pragma may
2167 be used in only three contexts: @code{pragma Suppress},
2168 @code{pragma Unsuppress},
2169 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
2170 any of these three cases, the check name must be visible. A check
2171 name is visible if it is in the configuration pragmas applying to
2172 the current unit, or if it appears at the start of any unit that
2173 is part of the dependency set of the current unit (e.g., units that
2174 are mentioned in @code{with} clauses).
2175
2176 Check names introduced by this pragma are subject to control by compiler
2177 switches (in particular -gnatp) in the usual manner.
2178
2179 @node Pragma Check_Policy,Pragma Comment,Pragma Check_Name,Implementation Defined Pragmas
2180 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-policy}@anchor{36}
2181 @section Pragma Check_Policy
2182
2183
2184 @geindex Controlling assertions
2185
2186 @geindex Assertions
2187 @geindex control
2188
2189 @geindex Check pragma control
2190
2191 @geindex Named assertions
2192
2193 Syntax:
2194
2195 @example
2196 pragma Check_Policy
2197 ([Name =>] CHECK_KIND,
2198 [Policy =>] POLICY_IDENTIFIER);
2199
2200 pragma Check_Policy (
2201 CHECK_KIND => POLICY_IDENTIFIER
2202 @{, CHECK_KIND => POLICY_IDENTIFIER@});
2203
2204 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
2205
2206 CHECK_KIND ::= IDENTIFIER |
2207 Pre'Class |
2208 Post'Class |
2209 Type_Invariant'Class |
2210 Invariant'Class
2211
2212 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
2213 avoids confusion between the two possible syntax forms for this pragma.
2214
2215 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
2216 @end example
2217
2218 This pragma is used to set the checking policy for assertions (specified
2219 by aspects or pragmas), the @code{Debug} pragma, or additional checks
2220 to be checked using the @code{Check} pragma. It may appear either as
2221 a configuration pragma, or within a declarative part of package. In the
2222 latter case, it applies from the point where it appears to the end of
2223 the declarative region (like pragma @code{Suppress}).
2224
2225 The @code{Check_Policy} pragma is similar to the
2226 predefined @code{Assertion_Policy} pragma,
2227 and if the check kind corresponds to one of the assertion kinds that
2228 are allowed by @code{Assertion_Policy}, then the effect is identical.
2229
2230 If the first argument is Debug, then the policy applies to Debug pragmas,
2231 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
2232 @code{IGNORE}, and allowing them to execute with normal semantics if
2233 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
2234 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
2235 be totally ignored and not analyzed semantically.
2236
2237 Finally the first argument may be some other identifier than the above
2238 possibilities, in which case it controls a set of named assertions
2239 that can be checked using pragma @code{Check}. For example, if the pragma:
2240
2241 @example
2242 pragma Check_Policy (Critical_Error, OFF);
2243 @end example
2244
2245 is given, then subsequent @code{Check} pragmas whose first argument is also
2246 @code{Critical_Error} will be disabled.
2247
2248 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
2249 to turn on corresponding checks. The default for a set of checks for which no
2250 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
2251 @emph{-gnata} is given, which turns on all checks by default.
2252
2253 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
2254 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
2255 compatibility with the standard @code{Assertion_Policy} pragma. The check
2256 policy setting @code{DISABLE} causes the second argument of a corresponding
2257 @code{Check} pragma to be completely ignored and not analyzed.
2258
2259 @node Pragma Comment,Pragma Common_Object,Pragma Check_Policy,Implementation Defined Pragmas
2260 @anchor{gnat_rm/implementation_defined_pragmas pragma-comment}@anchor{37}
2261 @section Pragma Comment
2262
2263
2264 Syntax:
2265
2266 @example
2267 pragma Comment (static_string_EXPRESSION);
2268 @end example
2269
2270 This is almost identical in effect to pragma @code{Ident}. It allows the
2271 placement of a comment into the object file and hence into the
2272 executable file if the operating system permits such usage. The
2273 difference is that @code{Comment}, unlike @code{Ident}, has
2274 no limitations on placement of the pragma (it can be placed
2275 anywhere in the main source unit), and if more than one pragma
2276 is used, all comments are retained.
2277
2278 @node Pragma Common_Object,Pragma Compile_Time_Error,Pragma Comment,Implementation Defined Pragmas
2279 @anchor{gnat_rm/implementation_defined_pragmas pragma-common-object}@anchor{38}
2280 @section Pragma Common_Object
2281
2282
2283 Syntax:
2284
2285 @example
2286 pragma Common_Object (
2287 [Internal =>] LOCAL_NAME
2288 [, [External =>] EXTERNAL_SYMBOL]
2289 [, [Size =>] EXTERNAL_SYMBOL] );
2290
2291 EXTERNAL_SYMBOL ::=
2292 IDENTIFIER
2293 | static_string_EXPRESSION
2294 @end example
2295
2296 This pragma enables the shared use of variables stored in overlaid
2297 linker areas corresponding to the use of @code{COMMON}
2298 in Fortran. The single
2299 object @code{LOCAL_NAME} is assigned to the area designated by
2300 the @code{External} argument.
2301 You may define a record to correspond to a series
2302 of fields. The @code{Size} argument
2303 is syntax checked in GNAT, but otherwise ignored.
2304
2305 @code{Common_Object} is not supported on all platforms. If no
2306 support is available, then the code generator will issue a message
2307 indicating that the necessary attribute for implementation of this
2308 pragma is not available.
2309
2310 @node Pragma Compile_Time_Error,Pragma Compile_Time_Warning,Pragma Common_Object,Implementation Defined Pragmas
2311 @anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-error}@anchor{39}@anchor{gnat_rm/implementation_defined_pragmas compile-time-error}@anchor{3a}
2312 @section Pragma Compile_Time_Error
2313
2314
2315 Syntax:
2316
2317 @example
2318 pragma Compile_Time_Error
2319 (boolean_EXPRESSION, static_string_EXPRESSION);
2320 @end example
2321
2322 This pragma can be used to generate additional compile time
2323 error messages. It
2324 is particularly useful in generics, where errors can be issued for
2325 specific problematic instantiations. The first parameter is a boolean
2326 expression. The pragma ensures that the value of an expression
2327 is known at compile time, and has the value False. The set of expressions
2328 whose values are known at compile time includes all static boolean
2329 expressions, and also other values which the compiler can determine
2330 at compile time (e.g., the size of a record type set by an explicit
2331 size representation clause, or the value of a variable which was
2332 initialized to a constant and is known not to have been modified).
2333 If these conditions are not met, an error message is generated using
2334 the value given as the second argument. This string value may contain
2335 embedded ASCII.LF characters to break the message into multiple lines.
2336
2337 @node Pragma Compile_Time_Warning,Pragma Compiler_Unit,Pragma Compile_Time_Error,Implementation Defined Pragmas
2338 @anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-warning}@anchor{3b}
2339 @section Pragma Compile_Time_Warning
2340
2341
2342 Syntax:
2343
2344 @example
2345 pragma Compile_Time_Warning
2346 (boolean_EXPRESSION, static_string_EXPRESSION);
2347 @end example
2348
2349 Same as pragma Compile_Time_Error, except a warning is issued instead
2350 of an error message. If switch @emph{-gnatw_C} is used, a warning is only issued
2351 if the value of the expression is known to be True at compile time, not when
2352 the value of the expression is not known at compile time.
2353 Note that if this pragma is used in a package that
2354 is with'ed by a client, the client will get the warning even though it
2355 is issued by a with'ed package (normally warnings in with'ed units are
2356 suppressed, but this is a special exception to that rule).
2357
2358 One typical use is within a generic where compile time known characteristics
2359 of formal parameters are tested, and warnings given appropriately. Another use
2360 with a first parameter of True is to warn a client about use of a package,
2361 for example that it is not fully implemented.
2362
2363 In previous versions of the compiler, combining @emph{-gnatwe} with
2364 Compile_Time_Warning resulted in a fatal error. Now the compiler always emits
2365 a warning. You can use @ref{3a,,Pragma Compile_Time_Error} to force the generation of
2366 an error.
2367
2368 @node Pragma Compiler_Unit,Pragma Compiler_Unit_Warning,Pragma Compile_Time_Warning,Implementation Defined Pragmas
2369 @anchor{gnat_rm/implementation_defined_pragmas pragma-compiler-unit}@anchor{3c}
2370 @section Pragma Compiler_Unit
2371
2372
2373 Syntax:
2374
2375 @example
2376 pragma Compiler_Unit;
2377 @end example
2378
2379 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2380 retained so that old versions of the GNAT run-time that use this pragma can
2381 be compiled with newer versions of the compiler.
2382
2383 @node Pragma Compiler_Unit_Warning,Pragma Complete_Representation,Pragma Compiler_Unit,Implementation Defined Pragmas
2384 @anchor{gnat_rm/implementation_defined_pragmas pragma-compiler-unit-warning}@anchor{3d}
2385 @section Pragma Compiler_Unit_Warning
2386
2387
2388 Syntax:
2389
2390 @example
2391 pragma Compiler_Unit_Warning;
2392 @end example
2393
2394 This pragma is intended only for internal use in the GNAT run-time library.
2395 It indicates that the unit is used as part of the compiler build. The effect
2396 is to generate warnings for the use of constructs (for example, conditional
2397 expressions) that would cause trouble when bootstrapping using an older
2398 version of GNAT. For the exact list of restrictions, see the compiler sources
2399 and references to Check_Compiler_Unit.
2400
2401 @node Pragma Complete_Representation,Pragma Complex_Representation,Pragma Compiler_Unit_Warning,Implementation Defined Pragmas
2402 @anchor{gnat_rm/implementation_defined_pragmas pragma-complete-representation}@anchor{3e}
2403 @section Pragma Complete_Representation
2404
2405
2406 Syntax:
2407
2408 @example
2409 pragma Complete_Representation;
2410 @end example
2411
2412 This pragma must appear immediately within a record representation
2413 clause. Typical placements are before the first component clause
2414 or after the last component clause. The effect is to give an error
2415 message if any component is missing a component clause. This pragma
2416 may be used to ensure that a record representation clause is
2417 complete, and that this invariant is maintained if fields are
2418 added to the record in the future.
2419
2420 @node Pragma Complex_Representation,Pragma Component_Alignment,Pragma Complete_Representation,Implementation Defined Pragmas
2421 @anchor{gnat_rm/implementation_defined_pragmas pragma-complex-representation}@anchor{3f}
2422 @section Pragma Complex_Representation
2423
2424
2425 Syntax:
2426
2427 @example
2428 pragma Complex_Representation
2429 ([Entity =>] LOCAL_NAME);
2430 @end example
2431
2432 The @code{Entity} argument must be the name of a record type which has
2433 two fields of the same floating-point type. The effect of this pragma is
2434 to force gcc to use the special internal complex representation form for
2435 this record, which may be more efficient. Note that this may result in
2436 the code for this type not conforming to standard ABI (application
2437 binary interface) requirements for the handling of record types. For
2438 example, in some environments, there is a requirement for passing
2439 records by pointer, and the use of this pragma may result in passing
2440 this type in floating-point registers.
2441
2442 @node Pragma Component_Alignment,Pragma Constant_After_Elaboration,Pragma Complex_Representation,Implementation Defined Pragmas
2443 @anchor{gnat_rm/implementation_defined_pragmas pragma-component-alignment}@anchor{40}
2444 @section Pragma Component_Alignment
2445
2446
2447 @geindex Alignments of components
2448
2449 @geindex Pragma Component_Alignment
2450
2451 Syntax:
2452
2453 @example
2454 pragma Component_Alignment (
2455 [Form =>] ALIGNMENT_CHOICE
2456 [, [Name =>] type_LOCAL_NAME]);
2457
2458 ALIGNMENT_CHOICE ::=
2459 Component_Size
2460 | Component_Size_4
2461 | Storage_Unit
2462 | Default
2463 @end example
2464
2465 Specifies the alignment of components in array or record types.
2466 The meaning of the @code{Form} argument is as follows:
2467
2468 @quotation
2469
2470 @geindex Component_Size (in pragma Component_Alignment)
2471 @end quotation
2472
2473
2474 @table @asis
2475
2476 @item @emph{Component_Size}
2477
2478 Aligns scalar components and subcomponents of the array or record type
2479 on boundaries appropriate to their inherent size (naturally
2480 aligned). For example, 1-byte components are aligned on byte boundaries,
2481 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2482 integer components are aligned on 4-byte boundaries and so on. These
2483 alignment rules correspond to the normal rules for C compilers on all
2484 machines except the VAX.
2485
2486 @geindex Component_Size_4 (in pragma Component_Alignment)
2487
2488 @item @emph{Component_Size_4}
2489
2490 Naturally aligns components with a size of four or fewer
2491 bytes. Components that are larger than 4 bytes are placed on the next
2492 4-byte boundary.
2493
2494 @geindex Storage_Unit (in pragma Component_Alignment)
2495
2496 @item @emph{Storage_Unit}
2497
2498 Specifies that array or record components are byte aligned, i.e.,
2499 aligned on boundaries determined by the value of the constant
2500 @code{System.Storage_Unit}.
2501
2502 @geindex Default (in pragma Component_Alignment)
2503
2504 @item @emph{Default}
2505
2506 Specifies that array or record components are aligned on default
2507 boundaries, appropriate to the underlying hardware or operating system or
2508 both. The @code{Default} choice is the same as @code{Component_Size} (natural
2509 alignment).
2510 @end table
2511
2512 If the @code{Name} parameter is present, @code{type_LOCAL_NAME} must
2513 refer to a local record or array type, and the specified alignment
2514 choice applies to the specified type. The use of
2515 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2516 @code{Component_Alignment} pragma to be ignored. The use of
2517 @code{Component_Alignment} together with a record representation clause
2518 is only effective for fields not specified by the representation clause.
2519
2520 If the @code{Name} parameter is absent, the pragma can be used as either
2521 a configuration pragma, in which case it applies to one or more units in
2522 accordance with the normal rules for configuration pragmas, or it can be
2523 used within a declarative part, in which case it applies to types that
2524 are declared within this declarative part, or within any nested scope
2525 within this declarative part. In either case it specifies the alignment
2526 to be applied to any record or array type which has otherwise standard
2527 representation.
2528
2529 If the alignment for a record or array type is not specified (using
2530 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2531 clause), the GNAT uses the default alignment as described previously.
2532
2533 @node Pragma Constant_After_Elaboration,Pragma Contract_Cases,Pragma Component_Alignment,Implementation Defined Pragmas
2534 @anchor{gnat_rm/implementation_defined_pragmas id6}@anchor{41}@anchor{gnat_rm/implementation_defined_pragmas pragma-constant-after-elaboration}@anchor{42}
2535 @section Pragma Constant_After_Elaboration
2536
2537
2538 Syntax:
2539
2540 @example
2541 pragma Constant_After_Elaboration [ (boolean_EXPRESSION) ];
2542 @end example
2543
2544 For the semantics of this pragma, see the entry for aspect
2545 @code{Constant_After_Elaboration} in the SPARK 2014 Reference Manual, section 3.3.1.
2546
2547 @node Pragma Contract_Cases,Pragma Convention_Identifier,Pragma Constant_After_Elaboration,Implementation Defined Pragmas
2548 @anchor{gnat_rm/implementation_defined_pragmas id7}@anchor{43}@anchor{gnat_rm/implementation_defined_pragmas pragma-contract-cases}@anchor{44}
2549 @section Pragma Contract_Cases
2550
2551
2552 @geindex Contract cases
2553
2554 Syntax:
2555
2556 @example
2557 pragma Contract_Cases ((CONTRACT_CASE @{, CONTRACT_CASE));
2558
2559 CONTRACT_CASE ::= CASE_GUARD => CONSEQUENCE
2560
2561 CASE_GUARD ::= boolean_EXPRESSION | others
2562
2563 CONSEQUENCE ::= boolean_EXPRESSION
2564 @end example
2565
2566 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2567 that can complement or replace the contract given by a precondition and a
2568 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2569 by testing and formal verification tools. The compiler checks its validity and,
2570 depending on the assertion policy at the point of declaration of the pragma,
2571 it may insert a check in the executable. For code generation, the contract
2572 cases
2573
2574 @example
2575 pragma Contract_Cases (
2576 Cond1 => Pred1,
2577 Cond2 => Pred2);
2578 @end example
2579
2580 are equivalent to
2581
2582 @example
2583 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2584 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2585 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2586 pragma Postcondition (if C1 then Pred1);
2587 pragma Postcondition (if C2 then Pred2);
2588 @end example
2589
2590 The precondition ensures that one and only one of the case guards is
2591 satisfied on entry to the subprogram.
2592 The postcondition ensures that for the case guard that was True on entry,
2593 the corresponding consequence is True on exit. Other consequence expressions
2594 are not evaluated.
2595
2596 A precondition @code{P} and postcondition @code{Q} can also be
2597 expressed as contract cases:
2598
2599 @example
2600 pragma Contract_Cases (P => Q);
2601 @end example
2602
2603 The placement and visibility rules for @code{Contract_Cases} pragmas are
2604 identical to those described for preconditions and postconditions.
2605
2606 The compiler checks that boolean expressions given in case guards and
2607 consequences are valid, where the rules for case guards are the same as
2608 the rule for an expression in @code{Precondition} and the rules for
2609 consequences are the same as the rule for an expression in
2610 @code{Postcondition}. In particular, attributes @code{'Old} and
2611 @code{'Result} can only be used within consequence expressions.
2612 The case guard for the last contract case may be @code{others}, to denote
2613 any case not captured by the previous cases. The
2614 following is an example of use within a package spec:
2615
2616 @example
2617 package Math_Functions is
2618 ...
2619 function Sqrt (Arg : Float) return Float;
2620 pragma Contract_Cases (((Arg in 0.0 .. 99.0) => Sqrt'Result < 10.0,
2621 Arg >= 100.0 => Sqrt'Result >= 10.0,
2622 others => Sqrt'Result = 0.0));
2623 ...
2624 end Math_Functions;
2625 @end example
2626
2627 The meaning of contract cases is that only one case should apply at each
2628 call, as determined by the corresponding case guard evaluating to True,
2629 and that the consequence for this case should hold when the subprogram
2630 returns.
2631
2632 @node Pragma Convention_Identifier,Pragma CPP_Class,Pragma Contract_Cases,Implementation Defined Pragmas
2633 @anchor{gnat_rm/implementation_defined_pragmas pragma-convention-identifier}@anchor{45}
2634 @section Pragma Convention_Identifier
2635
2636
2637 @geindex Conventions
2638 @geindex synonyms
2639
2640 Syntax:
2641
2642 @example
2643 pragma Convention_Identifier (
2644 [Name =>] IDENTIFIER,
2645 [Convention =>] convention_IDENTIFIER);
2646 @end example
2647
2648 This pragma provides a mechanism for supplying synonyms for existing
2649 convention identifiers. The @code{Name} identifier can subsequently
2650 be used as a synonym for the given convention in other pragmas (including
2651 for example pragma @code{Import} or another @code{Convention_Identifier}
2652 pragma). As an example of the use of this, suppose you had legacy code
2653 which used Fortran77 as the identifier for Fortran. Then the pragma:
2654
2655 @example
2656 pragma Convention_Identifier (Fortran77, Fortran);
2657 @end example
2658
2659 would allow the use of the convention identifier @code{Fortran77} in
2660 subsequent code, avoiding the need to modify the sources. As another
2661 example, you could use this to parameterize convention requirements
2662 according to systems. Suppose you needed to use @code{Stdcall} on
2663 windows systems, and @code{C} on some other system, then you could
2664 define a convention identifier @code{Library} and use a single
2665 @code{Convention_Identifier} pragma to specify which convention
2666 would be used system-wide.
2667
2668 @node Pragma CPP_Class,Pragma CPP_Constructor,Pragma Convention_Identifier,Implementation Defined Pragmas
2669 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-class}@anchor{46}
2670 @section Pragma CPP_Class
2671
2672
2673 @geindex Interfacing with C++
2674
2675 Syntax:
2676
2677 @example
2678 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2679 @end example
2680
2681 The argument denotes an entity in the current declarative region that is
2682 declared as a record type. It indicates that the type corresponds to an
2683 externally declared C++ class type, and is to be laid out the same way
2684 that C++ would lay out the type. If the C++ class has virtual primitives
2685 then the record must be declared as a tagged record type.
2686
2687 Types for which @code{CPP_Class} is specified do not have assignment or
2688 equality operators defined (such operations can be imported or declared
2689 as subprograms as required). Initialization is allowed only by constructor
2690 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2691 limited if not explicitly declared as limited or derived from a limited
2692 type, and an error is issued in that case.
2693
2694 See @ref{47,,Interfacing to C++} for related information.
2695
2696 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2697 for backward compatibility but its functionality is available
2698 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2699
2700 @node Pragma CPP_Constructor,Pragma CPP_Virtual,Pragma CPP_Class,Implementation Defined Pragmas
2701 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-constructor}@anchor{48}
2702 @section Pragma CPP_Constructor
2703
2704
2705 @geindex Interfacing with C++
2706
2707 Syntax:
2708
2709 @example
2710 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2711 [, [External_Name =>] static_string_EXPRESSION ]
2712 [, [Link_Name =>] static_string_EXPRESSION ]);
2713 @end example
2714
2715 This pragma identifies an imported function (imported in the usual way
2716 with pragma @code{Import}) as corresponding to a C++ constructor. If
2717 @code{External_Name} and @code{Link_Name} are not specified then the
2718 @code{Entity} argument is a name that must have been previously mentioned
2719 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2720 must be of one of the following forms:
2721
2722
2723 @itemize *
2724
2725 @item
2726 @strong{function} @code{Fname} @strong{return} T`
2727
2728 @item
2729 @strong{function} @code{Fname} @strong{return} T'Class
2730
2731 @item
2732 @strong{function} @code{Fname} (...) @strong{return} T`
2733
2734 @item
2735 @strong{function} @code{Fname} (...) @strong{return} T'Class
2736 @end itemize
2737
2738 where @code{T} is a limited record type imported from C++ with pragma
2739 @code{Import} and @code{Convention} = @code{CPP}.
2740
2741 The first two forms import the default constructor, used when an object
2742 of type @code{T} is created on the Ada side with no explicit constructor.
2743 The latter two forms cover all the non-default constructors of the type.
2744 See the GNAT User's Guide for details.
2745
2746 If no constructors are imported, it is impossible to create any objects
2747 on the Ada side and the type is implicitly declared abstract.
2748
2749 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2750 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2751 GCC switch).
2752 See @ref{47,,Interfacing to C++} for more related information.
2753
2754 Note: The use of functions returning class-wide types for constructors is
2755 currently obsolete. They are supported for backward compatibility. The
2756 use of functions returning the type T leave the Ada sources more clear
2757 because the imported C++ constructors always return an object of type T;
2758 that is, they never return an object whose type is a descendant of type T.
2759
2760 @node Pragma CPP_Virtual,Pragma CPP_Vtable,Pragma CPP_Constructor,Implementation Defined Pragmas
2761 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-virtual}@anchor{49}
2762 @section Pragma CPP_Virtual
2763
2764
2765 @geindex Interfacing to C++
2766
2767 This pragma is now obsolete and, other than generating a warning if warnings
2768 on obsolescent features are enabled, is completely ignored.
2769 It is retained for compatibility
2770 purposes. It used to be required to ensure compoatibility with C++, but
2771 is no longer required for that purpose because GNAT generates
2772 the same object layout as the G++ compiler by default.
2773
2774 See @ref{47,,Interfacing to C++} for related information.
2775
2776 @node Pragma CPP_Vtable,Pragma CPU,Pragma CPP_Virtual,Implementation Defined Pragmas
2777 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-vtable}@anchor{4a}
2778 @section Pragma CPP_Vtable
2779
2780
2781 @geindex Interfacing with C++
2782
2783 This pragma is now obsolete and, other than generating a warning if warnings
2784 on obsolescent features are enabled, is completely ignored.
2785 It used to be required to ensure compatibility with C++, but
2786 is no longer required for that purpose because GNAT generates
2787 the same object layout as the G++ compiler by default.
2788
2789 See @ref{47,,Interfacing to C++} for related information.
2790
2791 @node Pragma CPU,Pragma Deadline_Floor,Pragma CPP_Vtable,Implementation Defined Pragmas
2792 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpu}@anchor{4b}
2793 @section Pragma CPU
2794
2795
2796 Syntax:
2797
2798 @example
2799 pragma CPU (EXPRESSION);
2800 @end example
2801
2802 This pragma is standard in Ada 2012, but is available in all earlier
2803 versions of Ada as an implementation-defined pragma.
2804 See Ada 2012 Reference Manual for details.
2805
2806 @node Pragma Deadline_Floor,Pragma Default_Initial_Condition,Pragma CPU,Implementation Defined Pragmas
2807 @anchor{gnat_rm/implementation_defined_pragmas pragma-deadline-floor}@anchor{4c}
2808 @section Pragma Deadline_Floor
2809
2810
2811 Syntax:
2812
2813 @example
2814 pragma Deadline_Floor (time_span_EXPRESSION);
2815 @end example
2816
2817 This pragma applies only to protected types and specifies the floor
2818 deadline inherited by a task when the task enters a protected object.
2819 It is effective only when the EDF scheduling policy is used.
2820
2821 @node Pragma Default_Initial_Condition,Pragma Debug,Pragma Deadline_Floor,Implementation Defined Pragmas
2822 @anchor{gnat_rm/implementation_defined_pragmas id8}@anchor{4d}@anchor{gnat_rm/implementation_defined_pragmas pragma-default-initial-condition}@anchor{4e}
2823 @section Pragma Default_Initial_Condition
2824
2825
2826 Syntax:
2827
2828 @example
2829 pragma Default_Initial_Condition [ (null | boolean_EXPRESSION) ];
2830 @end example
2831
2832 For the semantics of this pragma, see the entry for aspect
2833 @code{Default_Initial_Condition} in the SPARK 2014 Reference Manual, section 7.3.3.
2834
2835 @node Pragma Debug,Pragma Debug_Policy,Pragma Default_Initial_Condition,Implementation Defined Pragmas
2836 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug}@anchor{4f}
2837 @section Pragma Debug
2838
2839
2840 Syntax:
2841
2842 @example
2843 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2844
2845 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2846 PROCEDURE_NAME
2847 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2848 @end example
2849
2850 The procedure call argument has the syntactic form of an expression, meeting
2851 the syntactic requirements for pragmas.
2852
2853 If debug pragmas are not enabled or if the condition is present and evaluates
2854 to False, this pragma has no effect. If debug pragmas are enabled, the
2855 semantics of the pragma is exactly equivalent to the procedure call statement
2856 corresponding to the argument with a terminating semicolon. Pragmas are
2857 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2858 intersperse calls to debug procedures in the middle of declarations. Debug
2859 pragmas can be enabled either by use of the command line switch @emph{-gnata}
2860 or by use of the pragma @code{Check_Policy} with a first argument of
2861 @code{Debug}.
2862
2863 @node Pragma Debug_Policy,Pragma Default_Scalar_Storage_Order,Pragma Debug,Implementation Defined Pragmas
2864 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug-policy}@anchor{50}
2865 @section Pragma Debug_Policy
2866
2867
2868 Syntax:
2869
2870 @example
2871 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2872 @end example
2873
2874 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2875 with a first argument of @code{Debug}. It is retained for historical
2876 compatibility reasons.
2877
2878 @node Pragma Default_Scalar_Storage_Order,Pragma Default_Storage_Pool,Pragma Debug_Policy,Implementation Defined Pragmas
2879 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-scalar-storage-order}@anchor{51}
2880 @section Pragma Default_Scalar_Storage_Order
2881
2882
2883 @geindex Default_Scalar_Storage_Order
2884
2885 @geindex Scalar_Storage_Order
2886
2887 Syntax:
2888
2889 @example
2890 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
2891 @end example
2892
2893 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
2894 type or array type, then the scalar storage order defaults to the ordinary
2895 default for the target. But this default may be overridden using this pragma.
2896 The pragma may appear as a configuration pragma, or locally within a package
2897 spec or declarative part. In the latter case, it applies to all subsequent
2898 types declared within that package spec or declarative part.
2899
2900 The following example shows the use of this pragma:
2901
2902 @example
2903 pragma Default_Scalar_Storage_Order (High_Order_First);
2904 with System; use System;
2905 package DSSO1 is
2906 type H1 is record
2907 a : Integer;
2908 end record;
2909
2910 type L2 is record
2911 a : Integer;
2912 end record;
2913 for L2'Scalar_Storage_Order use Low_Order_First;
2914
2915 type L2a is new L2;
2916
2917 package Inner is
2918 type H3 is record
2919 a : Integer;
2920 end record;
2921
2922 pragma Default_Scalar_Storage_Order (Low_Order_First);
2923
2924 type L4 is record
2925 a : Integer;
2926 end record;
2927 end Inner;
2928
2929 type H4a is new Inner.L4;
2930
2931 type H5 is record
2932 a : Integer;
2933 end record;
2934 end DSSO1;
2935 @end example
2936
2937 In this example record types with names starting with @emph{L} have @cite{Low_Order_First} scalar
2938 storage order, and record types with names starting with @emph{H} have @code{High_Order_First}.
2939 Note that in the case of @code{H4a}, the order is not inherited
2940 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
2941 gets inherited on type derivation.
2942
2943 If this pragma is used as a configuration pragma which appears within a
2944 configuration pragma file (as opposed to appearing explicitly at the start
2945 of a single unit), then the binder will require that all units in a partition
2946 be compiled in a similar manner, other than run-time units, which are not
2947 affected by this pragma. Note that the use of this form is discouraged because
2948 it may significantly degrade the run-time performance of the software, instead
2949 the default scalar storage order ought to be changed only on a local basis.
2950
2951 @node Pragma Default_Storage_Pool,Pragma Depends,Pragma Default_Scalar_Storage_Order,Implementation Defined Pragmas
2952 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-storage-pool}@anchor{52}
2953 @section Pragma Default_Storage_Pool
2954
2955
2956 @geindex Default_Storage_Pool
2957
2958 Syntax:
2959
2960 @example
2961 pragma Default_Storage_Pool (storage_pool_NAME | null);
2962 @end example
2963
2964 This pragma is standard in Ada 2012, but is available in all earlier
2965 versions of Ada as an implementation-defined pragma.
2966 See Ada 2012 Reference Manual for details.
2967
2968 @node Pragma Depends,Pragma Detect_Blocking,Pragma Default_Storage_Pool,Implementation Defined Pragmas
2969 @anchor{gnat_rm/implementation_defined_pragmas pragma-depends}@anchor{53}@anchor{gnat_rm/implementation_defined_pragmas id9}@anchor{54}
2970 @section Pragma Depends
2971
2972
2973 Syntax:
2974
2975 @example
2976 pragma Depends (DEPENDENCY_RELATION);
2977
2978 DEPENDENCY_RELATION ::=
2979 null
2980 | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
2981
2982 DEPENDENCY_CLAUSE ::=
2983 OUTPUT_LIST =>[+] INPUT_LIST
2984 | NULL_DEPENDENCY_CLAUSE
2985
2986 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
2987
2988 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
2989
2990 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
2991
2992 OUTPUT ::= NAME | FUNCTION_RESULT
2993 INPUT ::= NAME
2994
2995 where FUNCTION_RESULT is a function Result attribute_reference
2996 @end example
2997
2998 For the semantics of this pragma, see the entry for aspect @code{Depends} in the
2999 SPARK 2014 Reference Manual, section 6.1.5.
3000
3001 @node Pragma Detect_Blocking,Pragma Disable_Atomic_Synchronization,Pragma Depends,Implementation Defined Pragmas
3002 @anchor{gnat_rm/implementation_defined_pragmas pragma-detect-blocking}@anchor{55}
3003 @section Pragma Detect_Blocking
3004
3005
3006 Syntax:
3007
3008 @example
3009 pragma Detect_Blocking;
3010 @end example
3011
3012 This is a standard pragma in Ada 2005, that is available in all earlier
3013 versions of Ada as an implementation-defined pragma.
3014
3015 This is a configuration pragma that forces the detection of potentially
3016 blocking operations within a protected operation, and to raise Program_Error
3017 if that happens.
3018
3019 @node Pragma Disable_Atomic_Synchronization,Pragma Dispatching_Domain,Pragma Detect_Blocking,Implementation Defined Pragmas
3020 @anchor{gnat_rm/implementation_defined_pragmas pragma-disable-atomic-synchronization}@anchor{56}
3021 @section Pragma Disable_Atomic_Synchronization
3022
3023
3024 @geindex Atomic Synchronization
3025
3026 Syntax:
3027
3028 @example
3029 pragma Disable_Atomic_Synchronization [(Entity)];
3030 @end example
3031
3032 Ada requires that accesses (reads or writes) of an atomic variable be
3033 regarded as synchronization points in the case of multiple tasks.
3034 Particularly in the case of multi-processors this may require special
3035 handling, e.g. the generation of memory barriers. This capability may
3036 be turned off using this pragma in cases where it is known not to be
3037 required.
3038
3039 The placement and scope rules for this pragma are the same as those
3040 for @code{pragma Suppress}. In particular it can be used as a
3041 configuration pragma, or in a declaration sequence where it applies
3042 till the end of the scope. If an @code{Entity} argument is present,
3043 the action applies only to that entity.
3044
3045 @node Pragma Dispatching_Domain,Pragma Effective_Reads,Pragma Disable_Atomic_Synchronization,Implementation Defined Pragmas
3046 @anchor{gnat_rm/implementation_defined_pragmas pragma-dispatching-domain}@anchor{57}
3047 @section Pragma Dispatching_Domain
3048
3049
3050 Syntax:
3051
3052 @example
3053 pragma Dispatching_Domain (EXPRESSION);
3054 @end example
3055
3056 This pragma is standard in Ada 2012, but is available in all earlier
3057 versions of Ada as an implementation-defined pragma.
3058 See Ada 2012 Reference Manual for details.
3059
3060 @node Pragma Effective_Reads,Pragma Effective_Writes,Pragma Dispatching_Domain,Implementation Defined Pragmas
3061 @anchor{gnat_rm/implementation_defined_pragmas id10}@anchor{58}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-reads}@anchor{59}
3062 @section Pragma Effective_Reads
3063
3064
3065 Syntax:
3066
3067 @example
3068 pragma Effective_Reads [ (boolean_EXPRESSION) ];
3069 @end example
3070
3071 For the semantics of this pragma, see the entry for aspect @code{Effective_Reads} in
3072 the SPARK 2014 Reference Manual, section 7.1.2.
3073
3074 @node Pragma Effective_Writes,Pragma Elaboration_Checks,Pragma Effective_Reads,Implementation Defined Pragmas
3075 @anchor{gnat_rm/implementation_defined_pragmas id11}@anchor{5a}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-writes}@anchor{5b}
3076 @section Pragma Effective_Writes
3077
3078
3079 Syntax:
3080
3081 @example
3082 pragma Effective_Writes [ (boolean_EXPRESSION) ];
3083 @end example
3084
3085 For the semantics of this pragma, see the entry for aspect @code{Effective_Writes}
3086 in the SPARK 2014 Reference Manual, section 7.1.2.
3087
3088 @node Pragma Elaboration_Checks,Pragma Eliminate,Pragma Effective_Writes,Implementation Defined Pragmas
3089 @anchor{gnat_rm/implementation_defined_pragmas pragma-elaboration-checks}@anchor{5c}
3090 @section Pragma Elaboration_Checks
3091
3092
3093 @geindex Elaboration control
3094
3095 Syntax:
3096
3097 @example
3098 pragma Elaboration_Checks (Dynamic | Static);
3099 @end example
3100
3101 This is a configuration pragma which specifies the elaboration model to be
3102 used during compilation. For more information on the elaboration models of
3103 GNAT, consult the chapter on elaboration order handling in the @emph{GNAT User's
3104 Guide}.
3105
3106 The pragma may appear in the following contexts:
3107
3108
3109 @itemize *
3110
3111 @item
3112 Configuration pragmas file
3113
3114 @item
3115 Prior to the context clauses of a compilation unit's initial declaration
3116 @end itemize
3117
3118 Any other placement of the pragma will result in a warning and the effects of
3119 the offending pragma will be ignored.
3120
3121 If the pragma argument is @code{Dynamic}, then the dynamic elaboration model is in
3122 effect. If the pragma argument is @code{Static}, then the static elaboration model
3123 is in effect.
3124
3125 @node Pragma Eliminate,Pragma Enable_Atomic_Synchronization,Pragma Elaboration_Checks,Implementation Defined Pragmas
3126 @anchor{gnat_rm/implementation_defined_pragmas pragma-eliminate}@anchor{5d}
3127 @section Pragma Eliminate
3128
3129
3130 @geindex Elimination of unused subprograms
3131
3132 Syntax:
3133
3134 @example
3135 pragma Eliminate (
3136 [ Unit_Name => ] IDENTIFIER | SELECTED_COMPONENT ,
3137 [ Entity => ] IDENTIFIER |
3138 SELECTED_COMPONENT |
3139 STRING_LITERAL
3140 [, Source_Location => SOURCE_TRACE ] );
3141
3142 SOURCE_TRACE ::= STRING_LITERAL
3143 @end example
3144
3145 This pragma indicates that the given entity is not used in the program to be
3146 compiled and built, thus allowing the compiler to
3147 eliminate the code or data associated with the named entity. Any reference to
3148 an eliminated entity causes a compile-time or link-time error.
3149
3150 The pragma has the following semantics, where @code{U} is the unit specified by
3151 the @code{Unit_Name} argument and @code{E} is the entity specified by the @code{Entity}
3152 argument:
3153
3154
3155 @itemize *
3156
3157 @item
3158 @code{E} must be a subprogram that is explicitly declared either:
3159
3160 o Within @code{U}, or
3161
3162 o Within a generic package that is instantiated in @code{U}, or
3163
3164 o As an instance of generic subprogram instantiated in @code{U}.
3165
3166 Otherwise the pragma is ignored.
3167
3168 @item
3169 If @code{E} is overloaded within @code{U} then, in the absence of a
3170 @code{Source_Location} argument, all overloadings are eliminated.
3171
3172 @item
3173 If @code{E} is overloaded within @code{U} and only some overloadings
3174 are to be eliminated, then each overloading to be eliminated
3175 must be specified in a corresponding pragma @code{Eliminate}
3176 with a @code{Source_Location} argument identifying the line where the
3177 declaration appears, as described below.
3178
3179 @item
3180 If @code{E} is declared as the result of a generic instantiation, then
3181 a @code{Source_Location} argument is needed, as described below
3182 @end itemize
3183
3184 Pragma @code{Eliminate} allows a program to be compiled in a system-independent
3185 manner, so that unused entities are eliminated but without
3186 needing to modify the source text. Normally the required set of
3187 @code{Eliminate} pragmas is constructed automatically using the @code{gnatelim} tool.
3188
3189 Any source file change that removes, splits, or
3190 adds lines may make the set of @code{Eliminate} pragmas invalid because their
3191 @code{Source_Location} argument values may get out of date.
3192
3193 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
3194 operation. In this case all the subprograms to which the given operation can
3195 dispatch are considered to be unused (are never called as a result of a direct
3196 or a dispatching call).
3197
3198 The string literal given for the source location specifies the line number
3199 of the declaration of the entity, using the following syntax for @code{SOURCE_TRACE}:
3200
3201 @example
3202 SOURCE_TRACE ::= SOURCE_REFERENCE [ LBRACKET SOURCE_TRACE RBRACKET ]
3203
3204 LBRACKET ::= '['
3205 RBRACKET ::= ']'
3206
3207 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
3208
3209 LINE_NUMBER ::= DIGIT @{DIGIT@}
3210 @end example
3211
3212 Spaces around the colon in a @code{SOURCE_REFERENCE} are optional.
3213
3214 The source trace that is given as the @code{Source_Location} must obey the
3215 following rules (or else the pragma is ignored), where @code{U} is
3216 the unit @code{U} specified by the @code{Unit_Name} argument and @code{E} is the
3217 subprogram specified by the @code{Entity} argument:
3218
3219
3220 @itemize *
3221
3222 @item
3223 @code{FILE_NAME} is the short name (with no directory
3224 information) of the Ada source file for @code{U}, using the required syntax
3225 for the underlying file system (e.g. case is significant if the underlying
3226 operating system is case sensitive).
3227 If @code{U} is a package and @code{E} is a subprogram declared in the package
3228 specification and its full declaration appears in the package body,
3229 then the relevant source file is the one for the package specification;
3230 analogously if @code{U} is a generic package.
3231
3232 @item
3233 If @code{E} is not declared in a generic instantiation (this includes
3234 generic subprogram instances), the source trace includes only one source
3235 line reference. @code{LINE_NUMBER} gives the line number of the occurrence
3236 of the declaration of @code{E} within the source file (as a decimal literal
3237 without an exponent or point).
3238
3239 @item
3240 If @code{E} is declared by a generic instantiation, its source trace
3241 (from left to right) starts with the source location of the
3242 declaration of @code{E} in the generic unit and ends with the source
3243 location of the instantiation, given in square brackets. This approach is
3244 applied recursively with nested instantiations: the rightmost (nested
3245 most deeply in square brackets) element of the source trace is the location
3246 of the outermost instantiation, and the leftmost element (that is, outside
3247 of any square brackets) is the location of the declaration of @code{E} in
3248 the generic unit.
3249 @end itemize
3250
3251 Examples:
3252
3253 @quotation
3254
3255 @example
3256 pragma Eliminate (Pkg0, Proc);
3257 -- Eliminate (all overloadings of) Proc in Pkg0
3258
3259 pragma Eliminate (Pkg1, Proc,
3260 Source_Location => "pkg1.ads:8");
3261 -- Eliminate overloading of Proc at line 8 in pkg1.ads
3262
3263 -- Assume the following file contents:
3264 -- gen_pkg.ads
3265 -- 1: generic
3266 -- 2: type T is private;
3267 -- 3: package Gen_Pkg is
3268 -- 4: procedure Proc(N : T);
3269 -- ... ...
3270 -- ... end Gen_Pkg;
3271 --
3272 -- q.adb
3273 -- 1: with Gen_Pkg;
3274 -- 2: procedure Q is
3275 -- 3: package Inst_Pkg is new Gen_Pkg(Integer);
3276 -- ... -- No calls on Inst_Pkg.Proc
3277 -- ... end Q;
3278
3279 -- The following pragma eliminates Inst_Pkg.Proc from Q
3280 pragma Eliminate (Q, Proc,
3281 Source_Location => "gen_pkg.ads:4[q.adb:3]");
3282 @end example
3283 @end quotation
3284
3285 @node Pragma Enable_Atomic_Synchronization,Pragma Export_Function,Pragma Eliminate,Implementation Defined Pragmas
3286 @anchor{gnat_rm/implementation_defined_pragmas pragma-enable-atomic-synchronization}@anchor{5e}
3287 @section Pragma Enable_Atomic_Synchronization
3288
3289
3290 @geindex Atomic Synchronization
3291
3292 Syntax:
3293
3294 @example
3295 pragma Enable_Atomic_Synchronization [(Entity)];
3296 @end example
3297
3298 Ada requires that accesses (reads or writes) of an atomic variable be
3299 regarded as synchronization points in the case of multiple tasks.
3300 Particularly in the case of multi-processors this may require special
3301 handling, e.g. the generation of memory barriers. This synchronization
3302 is performed by default, but can be turned off using
3303 @code{pragma Disable_Atomic_Synchronization}. The
3304 @code{Enable_Atomic_Synchronization} pragma can be used to turn
3305 it back on.
3306
3307 The placement and scope rules for this pragma are the same as those
3308 for @code{pragma Unsuppress}. In particular it can be used as a
3309 configuration pragma, or in a declaration sequence where it applies
3310 till the end of the scope. If an @code{Entity} argument is present,
3311 the action applies only to that entity.
3312
3313 @node Pragma Export_Function,Pragma Export_Object,Pragma Enable_Atomic_Synchronization,Implementation Defined Pragmas
3314 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-function}@anchor{5f}
3315 @section Pragma Export_Function
3316
3317
3318 @geindex Argument passing mechanisms
3319
3320 Syntax:
3321
3322 @example
3323 pragma Export_Function (
3324 [Internal =>] LOCAL_NAME
3325 [, [External =>] EXTERNAL_SYMBOL]
3326 [, [Parameter_Types =>] PARAMETER_TYPES]
3327 [, [Result_Type =>] result_SUBTYPE_MARK]
3328 [, [Mechanism =>] MECHANISM]
3329 [, [Result_Mechanism =>] MECHANISM_NAME]);
3330
3331 EXTERNAL_SYMBOL ::=
3332 IDENTIFIER
3333 | static_string_EXPRESSION
3334 | ""
3335
3336 PARAMETER_TYPES ::=
3337 null
3338 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3339
3340 TYPE_DESIGNATOR ::=
3341 subtype_NAME
3342 | subtype_Name ' Access
3343
3344 MECHANISM ::=
3345 MECHANISM_NAME
3346 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3347
3348 MECHANISM_ASSOCIATION ::=
3349 [formal_parameter_NAME =>] MECHANISM_NAME
3350
3351 MECHANISM_NAME ::= Value | Reference
3352 @end example
3353
3354 Use this pragma to make a function externally callable and optionally
3355 provide information on mechanisms to be used for passing parameter and
3356 result values. We recommend, for the purposes of improving portability,
3357 this pragma always be used in conjunction with a separate pragma
3358 @code{Export}, which must precede the pragma @code{Export_Function}.
3359 GNAT does not require a separate pragma @code{Export}, but if none is
3360 present, @code{Convention Ada} is assumed, which is usually
3361 not what is wanted, so it is usually appropriate to use this
3362 pragma in conjunction with a @code{Export} or @code{Convention}
3363 pragma that specifies the desired foreign convention.
3364 Pragma @code{Export_Function}
3365 (and @code{Export}, if present) must appear in the same declarative
3366 region as the function to which they apply.
3367
3368 The @code{internal_name} must uniquely designate the function to which the
3369 pragma applies. If more than one function name exists of this name in
3370 the declarative part you must use the @code{Parameter_Types} and
3371 @code{Result_Type} parameters to achieve the required
3372 unique designation. The @cite{subtype_mark}s in these parameters must
3373 exactly match the subtypes in the corresponding function specification,
3374 using positional notation to match parameters with subtype marks.
3375 The form with an @code{'Access} attribute can be used to match an
3376 anonymous access parameter.
3377
3378 @geindex Suppressing external name
3379
3380 Special treatment is given if the EXTERNAL is an explicit null
3381 string or a static string expressions that evaluates to the null
3382 string. In this case, no external name is generated. This form
3383 still allows the specification of parameter mechanisms.
3384
3385 @node Pragma Export_Object,Pragma Export_Procedure,Pragma Export_Function,Implementation Defined Pragmas
3386 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-object}@anchor{60}
3387 @section Pragma Export_Object
3388
3389
3390 Syntax:
3391
3392 @example
3393 pragma Export_Object
3394 [Internal =>] LOCAL_NAME
3395 [, [External =>] EXTERNAL_SYMBOL]
3396 [, [Size =>] EXTERNAL_SYMBOL]
3397
3398 EXTERNAL_SYMBOL ::=
3399 IDENTIFIER
3400 | static_string_EXPRESSION
3401 @end example
3402
3403 This pragma designates an object as exported, and apart from the
3404 extended rules for external symbols, is identical in effect to the use of
3405 the normal @code{Export} pragma applied to an object. You may use a
3406 separate Export pragma (and you probably should from the point of view
3407 of portability), but it is not required. @code{Size} is syntax checked,
3408 but otherwise ignored by GNAT.
3409
3410 @node Pragma Export_Procedure,Pragma Export_Value,Pragma Export_Object,Implementation Defined Pragmas
3411 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-procedure}@anchor{61}
3412 @section Pragma Export_Procedure
3413
3414
3415 Syntax:
3416
3417 @example
3418 pragma Export_Procedure (
3419 [Internal =>] LOCAL_NAME
3420 [, [External =>] EXTERNAL_SYMBOL]
3421 [, [Parameter_Types =>] PARAMETER_TYPES]
3422 [, [Mechanism =>] MECHANISM]);
3423
3424 EXTERNAL_SYMBOL ::=
3425 IDENTIFIER
3426 | static_string_EXPRESSION
3427 | ""
3428
3429 PARAMETER_TYPES ::=
3430 null
3431 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3432
3433 TYPE_DESIGNATOR ::=
3434 subtype_NAME
3435 | subtype_Name ' Access
3436
3437 MECHANISM ::=
3438 MECHANISM_NAME
3439 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3440
3441 MECHANISM_ASSOCIATION ::=
3442 [formal_parameter_NAME =>] MECHANISM_NAME
3443
3444 MECHANISM_NAME ::= Value | Reference
3445 @end example
3446
3447 This pragma is identical to @code{Export_Function} except that it
3448 applies to a procedure rather than a function and the parameters
3449 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3450 GNAT does not require a separate pragma @code{Export}, but if none is
3451 present, @code{Convention Ada} is assumed, which is usually
3452 not what is wanted, so it is usually appropriate to use this
3453 pragma in conjunction with a @code{Export} or @code{Convention}
3454 pragma that specifies the desired foreign convention.
3455
3456 @geindex Suppressing external name
3457
3458 Special treatment is given if the EXTERNAL is an explicit null
3459 string or a static string expressions that evaluates to the null
3460 string. In this case, no external name is generated. This form
3461 still allows the specification of parameter mechanisms.
3462
3463 @node Pragma Export_Value,Pragma Export_Valued_Procedure,Pragma Export_Procedure,Implementation Defined Pragmas
3464 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-value}@anchor{62}
3465 @section Pragma Export_Value
3466
3467
3468 Syntax:
3469
3470 @example
3471 pragma Export_Value (
3472 [Value =>] static_integer_EXPRESSION,
3473 [Link_Name =>] static_string_EXPRESSION);
3474 @end example
3475
3476 This pragma serves to export a static integer value for external use.
3477 The first argument specifies the value to be exported. The Link_Name
3478 argument specifies the symbolic name to be associated with the integer
3479 value. This pragma is useful for defining a named static value in Ada
3480 that can be referenced in assembly language units to be linked with
3481 the application. This pragma is currently supported only for the
3482 AAMP target and is ignored for other targets.
3483
3484 @node Pragma Export_Valued_Procedure,Pragma Extend_System,Pragma Export_Value,Implementation Defined Pragmas
3485 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-valued-procedure}@anchor{63}
3486 @section Pragma Export_Valued_Procedure
3487
3488
3489 Syntax:
3490
3491 @example
3492 pragma Export_Valued_Procedure (
3493 [Internal =>] LOCAL_NAME
3494 [, [External =>] EXTERNAL_SYMBOL]
3495 [, [Parameter_Types =>] PARAMETER_TYPES]
3496 [, [Mechanism =>] MECHANISM]);
3497
3498 EXTERNAL_SYMBOL ::=
3499 IDENTIFIER
3500 | static_string_EXPRESSION
3501 | ""
3502
3503 PARAMETER_TYPES ::=
3504 null
3505 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3506
3507 TYPE_DESIGNATOR ::=
3508 subtype_NAME
3509 | subtype_Name ' Access
3510
3511 MECHANISM ::=
3512 MECHANISM_NAME
3513 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3514
3515 MECHANISM_ASSOCIATION ::=
3516 [formal_parameter_NAME =>] MECHANISM_NAME
3517
3518 MECHANISM_NAME ::= Value | Reference
3519 @end example
3520
3521 This pragma is identical to @code{Export_Procedure} except that the
3522 first parameter of @code{LOCAL_NAME}, which must be present, must be of
3523 mode @code{out}, and externally the subprogram is treated as a function
3524 with this parameter as the result of the function. GNAT provides for
3525 this capability to allow the use of @code{out} and @code{in out}
3526 parameters in interfacing to external functions (which are not permitted
3527 in Ada functions).
3528 GNAT does not require a separate pragma @code{Export}, but if none is
3529 present, @code{Convention Ada} is assumed, which is almost certainly
3530 not what is wanted since the whole point of this pragma is to interface
3531 with foreign language functions, so it is usually appropriate to use this
3532 pragma in conjunction with a @code{Export} or @code{Convention}
3533 pragma that specifies the desired foreign convention.
3534
3535 @geindex Suppressing external name
3536
3537 Special treatment is given if the EXTERNAL is an explicit null
3538 string or a static string expressions that evaluates to the null
3539 string. In this case, no external name is generated. This form
3540 still allows the specification of parameter mechanisms.
3541
3542 @node Pragma Extend_System,Pragma Extensions_Allowed,Pragma Export_Valued_Procedure,Implementation Defined Pragmas
3543 @anchor{gnat_rm/implementation_defined_pragmas pragma-extend-system}@anchor{64}
3544 @section Pragma Extend_System
3545
3546
3547 @geindex System
3548 @geindex extending
3549
3550 @geindex DEC Ada 83
3551
3552 Syntax:
3553
3554 @example
3555 pragma Extend_System ([Name =>] IDENTIFIER);
3556 @end example
3557
3558 This pragma is used to provide backwards compatibility with other
3559 implementations that extend the facilities of package @code{System}. In
3560 GNAT, @code{System} contains only the definitions that are present in
3561 the Ada RM. However, other implementations, notably the DEC Ada 83
3562 implementation, provide many extensions to package @code{System}.
3563
3564 For each such implementation accommodated by this pragma, GNAT provides a
3565 package @code{Aux_@emph{xxx}}, e.g., @code{Aux_DEC} for the DEC Ada 83
3566 implementation, which provides the required additional definitions. You
3567 can use this package in two ways. You can @code{with} it in the normal
3568 way and access entities either by selection or using a @code{use}
3569 clause. In this case no special processing is required.
3570
3571 However, if existing code contains references such as
3572 @code{System.@emph{xxx}} where @emph{xxx} is an entity in the extended
3573 definitions provided in package @code{System}, you may use this pragma
3574 to extend visibility in @code{System} in a non-standard way that
3575 provides greater compatibility with the existing code. Pragma
3576 @code{Extend_System} is a configuration pragma whose single argument is
3577 the name of the package containing the extended definition
3578 (e.g., @code{Aux_DEC} for the DEC Ada case). A unit compiled under
3579 control of this pragma will be processed using special visibility
3580 processing that looks in package @code{System.Aux_@emph{xxx}} where
3581 @code{Aux_@emph{xxx}} is the pragma argument for any entity referenced in
3582 package @code{System}, but not found in package @code{System}.
3583
3584 You can use this pragma either to access a predefined @code{System}
3585 extension supplied with the compiler, for example @code{Aux_DEC} or
3586 you can construct your own extension unit following the above
3587 definition. Note that such a package is a child of @code{System}
3588 and thus is considered part of the implementation.
3589 To compile it you will have to use the @emph{-gnatg} switch
3590 for compiling System units, as explained in the
3591 GNAT User's Guide.
3592
3593 @node Pragma Extensions_Allowed,Pragma Extensions_Visible,Pragma Extend_System,Implementation Defined Pragmas
3594 @anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-allowed}@anchor{65}
3595 @section Pragma Extensions_Allowed
3596
3597
3598 @geindex Ada Extensions
3599
3600 @geindex GNAT Extensions
3601
3602 Syntax:
3603
3604 @example
3605 pragma Extensions_Allowed (On | Off);
3606 @end example
3607
3608 This configuration pragma enables or disables the implementation
3609 extension mode (the use of Off as a parameter cancels the effect
3610 of the @emph{-gnatX} command switch).
3611
3612 In extension mode, the latest version of the Ada language is
3613 implemented (currently Ada 202x), and in addition a small number
3614 of GNAT specific extensions are recognized as follows:
3615
3616
3617 @itemize *
3618
3619 @item
3620 Constrained attribute for generic objects
3621
3622 The @code{Constrained} attribute is permitted for objects of
3623 generic types. The result indicates if the corresponding actual
3624 is constrained.
3625
3626 @item
3627 @code{Static} aspect on intrinsic functions
3628
3629 The Ada 202x @code{Static} aspect can be specified on Intrinsic imported
3630 functions and the compiler will evaluate some of these intrinsic statically,
3631 in particular the @code{Shift_Left} and @code{Shift_Right} intrinsics.
3632
3633 @item
3634 @code{'Reduce} attribute
3635
3636 This attribute part of the Ada 202x language definition is provided for
3637 now under -gnatX to confirm and potentially refine its usage and syntax.
3638
3639 @item
3640 @code{[]} aggregates
3641
3642 This new aggregate syntax for arrays and containers is provided under -gnatX
3643 to experiment and confirm this new language syntax.
3644 @end itemize
3645
3646 @node Pragma Extensions_Visible,Pragma External,Pragma Extensions_Allowed,Implementation Defined Pragmas
3647 @anchor{gnat_rm/implementation_defined_pragmas id12}@anchor{66}@anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-visible}@anchor{67}
3648 @section Pragma Extensions_Visible
3649
3650
3651 Syntax:
3652
3653 @example
3654 pragma Extensions_Visible [ (boolean_EXPRESSION) ];
3655 @end example
3656
3657 For the semantics of this pragma, see the entry for aspect @code{Extensions_Visible}
3658 in the SPARK 2014 Reference Manual, section 6.1.7.
3659
3660 @node Pragma External,Pragma External_Name_Casing,Pragma Extensions_Visible,Implementation Defined Pragmas
3661 @anchor{gnat_rm/implementation_defined_pragmas pragma-external}@anchor{68}
3662 @section Pragma External
3663
3664
3665 Syntax:
3666
3667 @example
3668 pragma External (
3669 [ Convention =>] convention_IDENTIFIER,
3670 [ Entity =>] LOCAL_NAME
3671 [, [External_Name =>] static_string_EXPRESSION ]
3672 [, [Link_Name =>] static_string_EXPRESSION ]);
3673 @end example
3674
3675 This pragma is identical in syntax and semantics to pragma
3676 @code{Export} as defined in the Ada Reference Manual. It is
3677 provided for compatibility with some Ada 83 compilers that
3678 used this pragma for exactly the same purposes as pragma
3679 @code{Export} before the latter was standardized.
3680
3681 @node Pragma External_Name_Casing,Pragma Fast_Math,Pragma External,Implementation Defined Pragmas
3682 @anchor{gnat_rm/implementation_defined_pragmas pragma-external-name-casing}@anchor{69}
3683 @section Pragma External_Name_Casing
3684
3685
3686 @geindex Dec Ada 83 casing compatibility
3687
3688 @geindex External Names
3689 @geindex casing
3690
3691 @geindex Casing of External names
3692
3693 Syntax:
3694
3695 @example
3696 pragma External_Name_Casing (
3697 Uppercase | Lowercase
3698 [, Uppercase | Lowercase | As_Is]);
3699 @end example
3700
3701 This pragma provides control over the casing of external names associated
3702 with Import and Export pragmas. There are two cases to consider:
3703
3704
3705 @itemize *
3706
3707 @item
3708 Implicit external names
3709
3710 Implicit external names are derived from identifiers. The most common case
3711 arises when a standard Ada Import or Export pragma is used with only two
3712 arguments, as in:
3713
3714 @example
3715 pragma Import (C, C_Routine);
3716 @end example
3717
3718 Since Ada is a case-insensitive language, the spelling of the identifier in
3719 the Ada source program does not provide any information on the desired
3720 casing of the external name, and so a convention is needed. In GNAT the
3721 default treatment is that such names are converted to all lower case
3722 letters. This corresponds to the normal C style in many environments.
3723 The first argument of pragma @code{External_Name_Casing} can be used to
3724 control this treatment. If @code{Uppercase} is specified, then the name
3725 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3726 then the normal default of all lower case letters will be used.
3727
3728 This same implicit treatment is also used in the case of extended DEC Ada 83
3729 compatible Import and Export pragmas where an external name is explicitly
3730 specified using an identifier rather than a string.
3731
3732 @item
3733 Explicit external names
3734
3735 Explicit external names are given as string literals. The most common case
3736 arises when a standard Ada Import or Export pragma is used with three
3737 arguments, as in:
3738
3739 @example
3740 pragma Import (C, C_Routine, "C_routine");
3741 @end example
3742
3743 In this case, the string literal normally provides the exact casing required
3744 for the external name. The second argument of pragma
3745 @code{External_Name_Casing} may be used to modify this behavior.
3746 If @code{Uppercase} is specified, then the name
3747 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3748 then the name will be forced to all lowercase letters. A specification of
3749 @code{As_Is} provides the normal default behavior in which the casing is
3750 taken from the string provided.
3751 @end itemize
3752
3753 This pragma may appear anywhere that a pragma is valid. In particular, it
3754 can be used as a configuration pragma in the @code{gnat.adc} file, in which
3755 case it applies to all subsequent compilations, or it can be used as a program
3756 unit pragma, in which case it only applies to the current unit, or it can
3757 be used more locally to control individual Import/Export pragmas.
3758
3759 It was primarily intended for use with OpenVMS systems, where many
3760 compilers convert all symbols to upper case by default. For interfacing to
3761 such compilers (e.g., the DEC C compiler), it may be convenient to use
3762 the pragma:
3763
3764 @example
3765 pragma External_Name_Casing (Uppercase, Uppercase);
3766 @end example
3767
3768 to enforce the upper casing of all external symbols.
3769
3770 @node Pragma Fast_Math,Pragma Favor_Top_Level,Pragma External_Name_Casing,Implementation Defined Pragmas
3771 @anchor{gnat_rm/implementation_defined_pragmas pragma-fast-math}@anchor{6a}
3772 @section Pragma Fast_Math
3773
3774
3775 Syntax:
3776
3777 @example
3778 pragma Fast_Math;
3779 @end example
3780
3781 This is a configuration pragma which activates a mode in which speed is
3782 considered more important for floating-point operations than absolutely
3783 accurate adherence to the requirements of the standard. Currently the
3784 following operations are affected:
3785
3786
3787 @table @asis
3788
3789 @item @emph{Complex Multiplication}
3790
3791 The normal simple formula for complex multiplication can result in intermediate
3792 overflows for numbers near the end of the range. The Ada standard requires that
3793 this situation be detected and corrected by scaling, but in Fast_Math mode such
3794 cases will simply result in overflow. Note that to take advantage of this you
3795 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3796 under control of the pragma, rather than use the preinstantiated versions.
3797 @end table
3798
3799 @node Pragma Favor_Top_Level,Pragma Finalize_Storage_Only,Pragma Fast_Math,Implementation Defined Pragmas
3800 @anchor{gnat_rm/implementation_defined_pragmas id13}@anchor{6b}@anchor{gnat_rm/implementation_defined_pragmas pragma-favor-top-level}@anchor{6c}
3801 @section Pragma Favor_Top_Level
3802
3803
3804 Syntax:
3805
3806 @example
3807 pragma Favor_Top_Level (type_NAME);
3808 @end example
3809
3810 The argument of pragma @code{Favor_Top_Level} must be a named access-to-subprogram
3811 type. This pragma is an efficiency hint to the compiler, regarding the use of
3812 @code{'Access} or @code{'Unrestricted_Access} on nested (non-library-level) subprograms.
3813 The pragma means that nested subprograms are not used with this type, or are
3814 rare, so that the generated code should be efficient in the top-level case.
3815 When this pragma is used, dynamically generated trampolines may be used on some
3816 targets for nested subprograms. See restriction @code{No_Implicit_Dynamic_Code}.
3817
3818 @node Pragma Finalize_Storage_Only,Pragma Float_Representation,Pragma Favor_Top_Level,Implementation Defined Pragmas
3819 @anchor{gnat_rm/implementation_defined_pragmas pragma-finalize-storage-only}@anchor{6d}
3820 @section Pragma Finalize_Storage_Only
3821
3822
3823 Syntax:
3824
3825 @example
3826 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3827 @end example
3828
3829 The argument of pragma @code{Finalize_Storage_Only} must denote a local type which
3830 is derived from @code{Ada.Finalization.Controlled} or @code{Limited_Controlled}. The
3831 pragma suppresses the call to @code{Finalize} for declared library-level objects
3832 of the argument type. This is mostly useful for types where finalization is
3833 only used to deal with storage reclamation since in most environments it is
3834 not necessary to reclaim memory just before terminating execution, hence the
3835 name. Note that this pragma does not suppress Finalize calls for library-level
3836 heap-allocated objects (see pragma @code{No_Heap_Finalization}).
3837
3838 @node Pragma Float_Representation,Pragma Ghost,Pragma Finalize_Storage_Only,Implementation Defined Pragmas
3839 @anchor{gnat_rm/implementation_defined_pragmas pragma-float-representation}@anchor{6e}
3840 @section Pragma Float_Representation
3841
3842
3843 Syntax:
3844
3845 @example
3846 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3847
3848 FLOAT_REP ::= VAX_Float | IEEE_Float
3849 @end example
3850
3851 In the one argument form, this pragma is a configuration pragma which
3852 allows control over the internal representation chosen for the predefined
3853 floating point types declared in the packages @code{Standard} and
3854 @code{System}. This pragma is only provided for compatibility and has no effect.
3855
3856 The two argument form specifies the representation to be used for
3857 the specified floating-point type. The argument must
3858 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
3859
3860
3861 @itemize *
3862
3863 @item
3864 For a digits value of 6, 32-bit IEEE short format will be used.
3865
3866 @item
3867 For a digits value of 15, 64-bit IEEE long format will be used.
3868
3869 @item
3870 No other value of digits is permitted.
3871 @end itemize
3872
3873 @node Pragma Ghost,Pragma Global,Pragma Float_Representation,Implementation Defined Pragmas
3874 @anchor{gnat_rm/implementation_defined_pragmas pragma-ghost}@anchor{6f}@anchor{gnat_rm/implementation_defined_pragmas id14}@anchor{70}
3875 @section Pragma Ghost
3876
3877
3878 Syntax:
3879
3880 @example
3881 pragma Ghost [ (boolean_EXPRESSION) ];
3882 @end example
3883
3884 For the semantics of this pragma, see the entry for aspect @code{Ghost} in the SPARK
3885 2014 Reference Manual, section 6.9.
3886
3887 @node Pragma Global,Pragma Ident,Pragma Ghost,Implementation Defined Pragmas
3888 @anchor{gnat_rm/implementation_defined_pragmas pragma-global}@anchor{71}@anchor{gnat_rm/implementation_defined_pragmas id15}@anchor{72}
3889 @section Pragma Global
3890
3891
3892 Syntax:
3893
3894 @example
3895 pragma Global (GLOBAL_SPECIFICATION);
3896
3897 GLOBAL_SPECIFICATION ::=
3898 null
3899 | (GLOBAL_LIST)
3900 | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
3901
3902 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
3903
3904 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
3905 GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
3906 GLOBAL_ITEM ::= NAME
3907 @end example
3908
3909 For the semantics of this pragma, see the entry for aspect @code{Global} in the
3910 SPARK 2014 Reference Manual, section 6.1.4.
3911
3912 @node Pragma Ident,Pragma Ignore_Pragma,Pragma Global,Implementation Defined Pragmas
3913 @anchor{gnat_rm/implementation_defined_pragmas pragma-ident}@anchor{73}
3914 @section Pragma Ident
3915
3916
3917 Syntax:
3918
3919 @example
3920 pragma Ident (static_string_EXPRESSION);
3921 @end example
3922
3923 This pragma is identical in effect to pragma @code{Comment}. It is provided
3924 for compatibility with other Ada compilers providing this pragma.
3925
3926 @node Pragma Ignore_Pragma,Pragma Implementation_Defined,Pragma Ident,Implementation Defined Pragmas
3927 @anchor{gnat_rm/implementation_defined_pragmas pragma-ignore-pragma}@anchor{74}
3928 @section Pragma Ignore_Pragma
3929
3930
3931 Syntax:
3932
3933 @example
3934 pragma Ignore_Pragma (pragma_IDENTIFIER);
3935 @end example
3936
3937 This is a configuration pragma
3938 that takes a single argument that is a simple identifier. Any subsequent
3939 use of a pragma whose pragma identifier matches this argument will be
3940 silently ignored. This may be useful when legacy code or code intended
3941 for compilation with some other compiler contains pragmas that match the
3942 name, but not the exact implementation, of a GNAT pragma. The use of this
3943 pragma allows such pragmas to be ignored, which may be useful in CodePeer
3944 mode, or during porting of legacy code.
3945
3946 @node Pragma Implementation_Defined,Pragma Implemented,Pragma Ignore_Pragma,Implementation Defined Pragmas
3947 @anchor{gnat_rm/implementation_defined_pragmas pragma-implementation-defined}@anchor{75}
3948 @section Pragma Implementation_Defined
3949
3950
3951 Syntax:
3952
3953 @example
3954 pragma Implementation_Defined (local_NAME);
3955 @end example
3956
3957 This pragma marks a previously declared entity as implementation-defined.
3958 For an overloaded entity, applies to the most recent homonym.
3959
3960 @example
3961 pragma Implementation_Defined;
3962 @end example
3963
3964 The form with no arguments appears anywhere within a scope, most
3965 typically a package spec, and indicates that all entities that are
3966 defined within the package spec are Implementation_Defined.
3967
3968 This pragma is used within the GNAT runtime library to identify
3969 implementation-defined entities introduced in language-defined units,
3970 for the purpose of implementing the No_Implementation_Identifiers
3971 restriction.
3972
3973 @node Pragma Implemented,Pragma Implicit_Packing,Pragma Implementation_Defined,Implementation Defined Pragmas
3974 @anchor{gnat_rm/implementation_defined_pragmas pragma-implemented}@anchor{76}
3975 @section Pragma Implemented
3976
3977
3978 Syntax:
3979
3980 @example
3981 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
3982
3983 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
3984 @end example
3985
3986 This is an Ada 2012 representation pragma which applies to protected, task
3987 and synchronized interface primitives. The use of pragma Implemented provides
3988 a way to impose a static requirement on the overriding operation by adhering
3989 to one of the three implementation kinds: entry, protected procedure or any of
3990 the above. This pragma is available in all earlier versions of Ada as an
3991 implementation-defined pragma.
3992
3993 @example
3994 type Synch_Iface is synchronized interface;
3995 procedure Prim_Op (Obj : in out Iface) is abstract;
3996 pragma Implemented (Prim_Op, By_Protected_Procedure);
3997
3998 protected type Prot_1 is new Synch_Iface with
3999 procedure Prim_Op; -- Legal
4000 end Prot_1;
4001
4002 protected type Prot_2 is new Synch_Iface with
4003 entry Prim_Op; -- Illegal
4004 end Prot_2;
4005
4006 task type Task_Typ is new Synch_Iface with
4007 entry Prim_Op; -- Illegal
4008 end Task_Typ;
4009 @end example
4010
4011 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
4012 Implemented determines the runtime behavior of the requeue. Implementation kind
4013 By_Entry guarantees that the action of requeueing will proceed from an entry to
4014 another entry. Implementation kind By_Protected_Procedure transforms the
4015 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
4016 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
4017 the target's overriding subprogram kind.
4018
4019 @node Pragma Implicit_Packing,Pragma Import_Function,Pragma Implemented,Implementation Defined Pragmas
4020 @anchor{gnat_rm/implementation_defined_pragmas pragma-implicit-packing}@anchor{77}
4021 @section Pragma Implicit_Packing
4022
4023
4024 @geindex Rational Profile
4025
4026 Syntax:
4027
4028 @example
4029 pragma Implicit_Packing;
4030 @end example
4031
4032 This is a configuration pragma that requests implicit packing for packed
4033 arrays for which a size clause is given but no explicit pragma Pack or
4034 specification of Component_Size is present. It also applies to records
4035 where no record representation clause is present. Consider this example:
4036
4037 @example
4038 type R is array (0 .. 7) of Boolean;
4039 for R'Size use 8;
4040 @end example
4041
4042 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
4043 does not change the layout of a composite object. So the Size clause in the
4044 above example is normally rejected, since the default layout of the array uses
4045 8-bit components, and thus the array requires a minimum of 64 bits.
4046
4047 If this declaration is compiled in a region of code covered by an occurrence
4048 of the configuration pragma Implicit_Packing, then the Size clause in this
4049 and similar examples will cause implicit packing and thus be accepted. For
4050 this implicit packing to occur, the type in question must be an array of small
4051 components whose size is known at compile time, and the Size clause must
4052 specify the exact size that corresponds to the number of elements in the array
4053 multiplied by the size in bits of the component type (both single and
4054 multi-dimensioned arrays can be controlled with this pragma).
4055
4056 @geindex Array packing
4057
4058 Similarly, the following example shows the use in the record case
4059
4060 @example
4061 type r is record
4062 a, b, c, d, e, f, g, h : boolean;
4063 chr : character;
4064 end record;
4065 for r'size use 16;
4066 @end example
4067
4068 Without a pragma Pack, each Boolean field requires 8 bits, so the
4069 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
4070 sufficient. The use of pragma Implicit_Packing allows this record
4071 declaration to compile without an explicit pragma Pack.
4072
4073 @node Pragma Import_Function,Pragma Import_Object,Pragma Implicit_Packing,Implementation Defined Pragmas
4074 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-function}@anchor{78}
4075 @section Pragma Import_Function
4076
4077
4078 Syntax:
4079
4080 @example
4081 pragma Import_Function (
4082 [Internal =>] LOCAL_NAME,
4083 [, [External =>] EXTERNAL_SYMBOL]
4084 [, [Parameter_Types =>] PARAMETER_TYPES]
4085 [, [Result_Type =>] SUBTYPE_MARK]
4086 [, [Mechanism =>] MECHANISM]
4087 [, [Result_Mechanism =>] MECHANISM_NAME]);
4088
4089 EXTERNAL_SYMBOL ::=
4090 IDENTIFIER
4091 | static_string_EXPRESSION
4092
4093 PARAMETER_TYPES ::=
4094 null
4095 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4096
4097 TYPE_DESIGNATOR ::=
4098 subtype_NAME
4099 | subtype_Name ' Access
4100
4101 MECHANISM ::=
4102 MECHANISM_NAME
4103 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4104
4105 MECHANISM_ASSOCIATION ::=
4106 [formal_parameter_NAME =>] MECHANISM_NAME
4107
4108 MECHANISM_NAME ::=
4109 Value
4110 | Reference
4111 @end example
4112
4113 This pragma is used in conjunction with a pragma @code{Import} to
4114 specify additional information for an imported function. The pragma
4115 @code{Import} (or equivalent pragma @code{Interface}) must precede the
4116 @code{Import_Function} pragma and both must appear in the same
4117 declarative part as the function specification.
4118
4119 The @code{Internal} argument must uniquely designate
4120 the function to which the
4121 pragma applies. If more than one function name exists of this name in
4122 the declarative part you must use the @code{Parameter_Types} and
4123 @code{Result_Type} parameters to achieve the required unique
4124 designation. Subtype marks in these parameters must exactly match the
4125 subtypes in the corresponding function specification, using positional
4126 notation to match parameters with subtype marks.
4127 The form with an @code{'Access} attribute can be used to match an
4128 anonymous access parameter.
4129
4130 You may optionally use the @code{Mechanism} and @code{Result_Mechanism}
4131 parameters to specify passing mechanisms for the
4132 parameters and result. If you specify a single mechanism name, it
4133 applies to all parameters. Otherwise you may specify a mechanism on a
4134 parameter by parameter basis using either positional or named
4135 notation. If the mechanism is not specified, the default mechanism
4136 is used.
4137
4138 @node Pragma Import_Object,Pragma Import_Procedure,Pragma Import_Function,Implementation Defined Pragmas
4139 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-object}@anchor{79}
4140 @section Pragma Import_Object
4141
4142
4143 Syntax:
4144
4145 @example
4146 pragma Import_Object
4147 [Internal =>] LOCAL_NAME
4148 [, [External =>] EXTERNAL_SYMBOL]
4149 [, [Size =>] EXTERNAL_SYMBOL]);
4150
4151 EXTERNAL_SYMBOL ::=
4152 IDENTIFIER
4153 | static_string_EXPRESSION
4154 @end example
4155
4156 This pragma designates an object as imported, and apart from the
4157 extended rules for external symbols, is identical in effect to the use of
4158 the normal @code{Import} pragma applied to an object. Unlike the
4159 subprogram case, you need not use a separate @code{Import} pragma,
4160 although you may do so (and probably should do so from a portability
4161 point of view). @code{size} is syntax checked, but otherwise ignored by
4162 GNAT.
4163
4164 @node Pragma Import_Procedure,Pragma Import_Valued_Procedure,Pragma Import_Object,Implementation Defined Pragmas
4165 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-procedure}@anchor{7a}
4166 @section Pragma Import_Procedure
4167
4168
4169 Syntax:
4170
4171 @example
4172 pragma Import_Procedure (
4173 [Internal =>] LOCAL_NAME
4174 [, [External =>] EXTERNAL_SYMBOL]
4175 [, [Parameter_Types =>] PARAMETER_TYPES]
4176 [, [Mechanism =>] MECHANISM]);
4177
4178 EXTERNAL_SYMBOL ::=
4179 IDENTIFIER
4180 | static_string_EXPRESSION
4181
4182 PARAMETER_TYPES ::=
4183 null
4184 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4185
4186 TYPE_DESIGNATOR ::=
4187 subtype_NAME
4188 | subtype_Name ' Access
4189
4190 MECHANISM ::=
4191 MECHANISM_NAME
4192 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4193
4194 MECHANISM_ASSOCIATION ::=
4195 [formal_parameter_NAME =>] MECHANISM_NAME
4196
4197 MECHANISM_NAME ::= Value | Reference
4198 @end example
4199
4200 This pragma is identical to @code{Import_Function} except that it
4201 applies to a procedure rather than a function and the parameters
4202 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
4203
4204 @node Pragma Import_Valued_Procedure,Pragma Independent,Pragma Import_Procedure,Implementation Defined Pragmas
4205 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-valued-procedure}@anchor{7b}
4206 @section Pragma Import_Valued_Procedure
4207
4208
4209 Syntax:
4210
4211 @example
4212 pragma Import_Valued_Procedure (
4213 [Internal =>] LOCAL_NAME
4214 [, [External =>] EXTERNAL_SYMBOL]
4215 [, [Parameter_Types =>] PARAMETER_TYPES]
4216 [, [Mechanism =>] MECHANISM]);
4217
4218 EXTERNAL_SYMBOL ::=
4219 IDENTIFIER
4220 | static_string_EXPRESSION
4221
4222 PARAMETER_TYPES ::=
4223 null
4224 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4225
4226 TYPE_DESIGNATOR ::=
4227 subtype_NAME
4228 | subtype_Name ' Access
4229
4230 MECHANISM ::=
4231 MECHANISM_NAME
4232 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4233
4234 MECHANISM_ASSOCIATION ::=
4235 [formal_parameter_NAME =>] MECHANISM_NAME
4236
4237 MECHANISM_NAME ::= Value | Reference
4238 @end example
4239
4240 This pragma is identical to @code{Import_Procedure} except that the
4241 first parameter of @code{LOCAL_NAME}, which must be present, must be of
4242 mode @code{out}, and externally the subprogram is treated as a function
4243 with this parameter as the result of the function. The purpose of this
4244 capability is to allow the use of @code{out} and @code{in out}
4245 parameters in interfacing to external functions (which are not permitted
4246 in Ada functions). You may optionally use the @code{Mechanism}
4247 parameters to specify passing mechanisms for the parameters.
4248 If you specify a single mechanism name, it applies to all parameters.
4249 Otherwise you may specify a mechanism on a parameter by parameter
4250 basis using either positional or named notation. If the mechanism is not
4251 specified, the default mechanism is used.
4252
4253 Note that it is important to use this pragma in conjunction with a separate
4254 pragma Import that specifies the desired convention, since otherwise the
4255 default convention is Ada, which is almost certainly not what is required.
4256
4257 @node Pragma Independent,Pragma Independent_Components,Pragma Import_Valued_Procedure,Implementation Defined Pragmas
4258 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent}@anchor{7c}
4259 @section Pragma Independent
4260
4261
4262 Syntax:
4263
4264 @example
4265 pragma Independent (Local_NAME);
4266 @end example
4267
4268 This pragma is standard in Ada 2012 mode (which also provides an aspect
4269 of the same name). It is also available as an implementation-defined
4270 pragma in all earlier versions. It specifies that the
4271 designated object or all objects of the designated type must be
4272 independently addressable. This means that separate tasks can safely
4273 manipulate such objects. For example, if two components of a record are
4274 independent, then two separate tasks may access these two components.
4275 This may place
4276 constraints on the representation of the object (for instance prohibiting
4277 tight packing).
4278
4279 @node Pragma Independent_Components,Pragma Initial_Condition,Pragma Independent,Implementation Defined Pragmas
4280 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent-components}@anchor{7d}
4281 @section Pragma Independent_Components
4282
4283
4284 Syntax:
4285
4286 @example
4287 pragma Independent_Components (Local_NAME);
4288 @end example
4289
4290 This pragma is standard in Ada 2012 mode (which also provides an aspect
4291 of the same name). It is also available as an implementation-defined
4292 pragma in all earlier versions. It specifies that the components of the
4293 designated object, or the components of each object of the designated
4294 type, must be
4295 independently addressable. This means that separate tasks can safely
4296 manipulate separate components in the composite object. This may place
4297 constraints on the representation of the object (for instance prohibiting
4298 tight packing).
4299
4300 @node Pragma Initial_Condition,Pragma Initialize_Scalars,Pragma Independent_Components,Implementation Defined Pragmas
4301 @anchor{gnat_rm/implementation_defined_pragmas id16}@anchor{7e}@anchor{gnat_rm/implementation_defined_pragmas pragma-initial-condition}@anchor{7f}
4302 @section Pragma Initial_Condition
4303
4304
4305 Syntax:
4306
4307 @example
4308 pragma Initial_Condition (boolean_EXPRESSION);
4309 @end example
4310
4311 For the semantics of this pragma, see the entry for aspect @code{Initial_Condition}
4312 in the SPARK 2014 Reference Manual, section 7.1.6.
4313
4314 @node Pragma Initialize_Scalars,Pragma Initializes,Pragma Initial_Condition,Implementation Defined Pragmas
4315 @anchor{gnat_rm/implementation_defined_pragmas pragma-initialize-scalars}@anchor{80}
4316 @section Pragma Initialize_Scalars
4317
4318
4319 @geindex debugging with Initialize_Scalars
4320
4321 Syntax:
4322
4323 @example
4324 pragma Initialize_Scalars
4325 [ ( TYPE_VALUE_PAIR @{, TYPE_VALUE_PAIR@} ) ];
4326
4327 TYPE_VALUE_PAIR ::=
4328 SCALAR_TYPE => static_EXPRESSION
4329
4330 SCALAR_TYPE :=
4331 Short_Float
4332 | Float
4333 | Long_Float
4334 | Long_Long_Flat
4335 | Signed_8
4336 | Signed_16
4337 | Signed_32
4338 | Signed_64
4339 | Unsigned_8
4340 | Unsigned_16
4341 | Unsigned_32
4342 | Unsigned_64
4343 @end example
4344
4345 This pragma is similar to @code{Normalize_Scalars} conceptually but has two
4346 important differences.
4347
4348 First, there is no requirement for the pragma to be used uniformly in all units
4349 of a partition. In particular, it is fine to use this just for some or all of
4350 the application units of a partition, without needing to recompile the run-time
4351 library. In the case where some units are compiled with the pragma, and some
4352 without, then a declaration of a variable where the type is defined in package
4353 Standard or is locally declared will always be subject to initialization, as
4354 will any declaration of a scalar variable. For composite variables, whether the
4355 variable is initialized may also depend on whether the package in which the
4356 type of the variable is declared is compiled with the pragma.
4357
4358 The other important difference is that the programmer can control the value
4359 used for initializing scalar objects. This effect can be achieved in several
4360 different ways:
4361
4362
4363 @itemize *
4364
4365 @item
4366 At compile time, the programmer can specify the invalid value for a
4367 particular family of scalar types using the optional arguments of the pragma.
4368
4369 The compile-time approach is intended to optimize the generated code for the
4370 pragma, by possibly using fast operations such as @code{memset}. Note that such
4371 optimizations require using values where the bytes all have the same binary
4372 representation.
4373
4374 @item
4375 At bind time, the programmer has several options:
4376
4377
4378 @itemize *
4379
4380 @item
4381 Initialization with invalid values (similar to Normalize_Scalars, though
4382 for Initialize_Scalars it is not always possible to determine the invalid
4383 values in complex cases like signed component fields with nonstandard
4384 sizes).
4385
4386 @item
4387 Initialization with high values.
4388
4389 @item
4390 Initialization with low values.
4391
4392 @item
4393 Initialization with a specific bit pattern.
4394 @end itemize
4395
4396 See the GNAT User's Guide for binder options for specifying these cases.
4397
4398 The bind-time approach is intended to provide fast turnaround for testing
4399 with different values, without having to recompile the program.
4400
4401 @item
4402 At execution time, the programmer can specify the invalid values using an
4403 environment variable. See the GNAT User's Guide for details.
4404
4405 The execution-time approach is intended to provide fast turnaround for
4406 testing with different values, without having to recompile and rebind the
4407 program.
4408 @end itemize
4409
4410 Note that pragma @code{Initialize_Scalars} is particularly useful in conjunction
4411 with the enhanced validity checking that is now provided in GNAT, which checks
4412 for invalid values under more conditions. Using this feature (see description
4413 of the @emph{-gnatV} flag in the GNAT User's Guide) in conjunction with pragma
4414 @code{Initialize_Scalars} provides a powerful new tool to assist in the detection
4415 of problems caused by uninitialized variables.
4416
4417 Note: the use of @code{Initialize_Scalars} has a fairly extensive effect on the
4418 generated code. This may cause your code to be substantially larger. It may
4419 also cause an increase in the amount of stack required, so it is probably a
4420 good idea to turn on stack checking (see description of stack checking in the
4421 GNAT User's Guide) when using this pragma.
4422
4423 @node Pragma Initializes,Pragma Inline_Always,Pragma Initialize_Scalars,Implementation Defined Pragmas
4424 @anchor{gnat_rm/implementation_defined_pragmas pragma-initializes}@anchor{81}@anchor{gnat_rm/implementation_defined_pragmas id17}@anchor{82}
4425 @section Pragma Initializes
4426
4427
4428 Syntax:
4429
4430 @example
4431 pragma Initializes (INITIALIZATION_LIST);
4432
4433 INITIALIZATION_LIST ::=
4434 null
4435 | (INITIALIZATION_ITEM @{, INITIALIZATION_ITEM@})
4436
4437 INITIALIZATION_ITEM ::= name [=> INPUT_LIST]
4438
4439 INPUT_LIST ::=
4440 null
4441 | INPUT
4442 | (INPUT @{, INPUT@})
4443
4444 INPUT ::= name
4445 @end example
4446
4447 For the semantics of this pragma, see the entry for aspect @code{Initializes} in the
4448 SPARK 2014 Reference Manual, section 7.1.5.
4449
4450 @node Pragma Inline_Always,Pragma Inline_Generic,Pragma Initializes,Implementation Defined Pragmas
4451 @anchor{gnat_rm/implementation_defined_pragmas id18}@anchor{83}@anchor{gnat_rm/implementation_defined_pragmas pragma-inline-always}@anchor{84}
4452 @section Pragma Inline_Always
4453
4454
4455 Syntax:
4456
4457 @example
4458 pragma Inline_Always (NAME [, NAME]);
4459 @end example
4460
4461 Similar to pragma @code{Inline} except that inlining is unconditional.
4462 Inline_Always instructs the compiler to inline every direct call to the
4463 subprogram or else to emit a compilation error, independently of any
4464 option, in particular @emph{-gnatn} or @emph{-gnatN} or the optimization level.
4465 It is an error to take the address or access of @code{NAME}. It is also an error to
4466 apply this pragma to a primitive operation of a tagged type. Thanks to such
4467 restrictions, the compiler is allowed to remove the out-of-line body of @code{NAME}.
4468
4469 @node Pragma Inline_Generic,Pragma Interface,Pragma Inline_Always,Implementation Defined Pragmas
4470 @anchor{gnat_rm/implementation_defined_pragmas pragma-inline-generic}@anchor{85}
4471 @section Pragma Inline_Generic
4472
4473
4474 Syntax:
4475
4476 @example
4477 pragma Inline_Generic (GNAME @{, GNAME@});
4478
4479 GNAME ::= generic_unit_NAME | generic_instance_NAME
4480 @end example
4481
4482 This pragma is provided for compatibility with Dec Ada 83. It has
4483 no effect in GNAT (which always inlines generics), other
4484 than to check that the given names are all names of generic units or
4485 generic instances.
4486
4487 @node Pragma Interface,Pragma Interface_Name,Pragma Inline_Generic,Implementation Defined Pragmas
4488 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface}@anchor{86}
4489 @section Pragma Interface
4490
4491
4492 Syntax:
4493
4494 @example
4495 pragma Interface (
4496 [Convention =>] convention_identifier,
4497 [Entity =>] local_NAME
4498 [, [External_Name =>] static_string_expression]
4499 [, [Link_Name =>] static_string_expression]);
4500 @end example
4501
4502 This pragma is identical in syntax and semantics to
4503 the standard Ada pragma @code{Import}. It is provided for compatibility
4504 with Ada 83. The definition is upwards compatible both with pragma
4505 @code{Interface} as defined in the Ada 83 Reference Manual, and also
4506 with some extended implementations of this pragma in certain Ada 83
4507 implementations. The only difference between pragma @code{Interface}
4508 and pragma @code{Import} is that there is special circuitry to allow
4509 both pragmas to appear for the same subprogram entity (normally it
4510 is illegal to have multiple @code{Import} pragmas. This is useful in
4511 maintaining Ada 83/Ada 95 compatibility and is compatible with other
4512 Ada 83 compilers.
4513
4514 @node Pragma Interface_Name,Pragma Interrupt_Handler,Pragma Interface,Implementation Defined Pragmas
4515 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface-name}@anchor{87}
4516 @section Pragma Interface_Name
4517
4518
4519 Syntax:
4520
4521 @example
4522 pragma Interface_Name (
4523 [Entity =>] LOCAL_NAME
4524 [, [External_Name =>] static_string_EXPRESSION]
4525 [, [Link_Name =>] static_string_EXPRESSION]);
4526 @end example
4527
4528 This pragma provides an alternative way of specifying the interface name
4529 for an interfaced subprogram, and is provided for compatibility with Ada
4530 83 compilers that use the pragma for this purpose. You must provide at
4531 least one of @code{External_Name} or @code{Link_Name}.
4532
4533 @node Pragma Interrupt_Handler,Pragma Interrupt_State,Pragma Interface_Name,Implementation Defined Pragmas
4534 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-handler}@anchor{88}
4535 @section Pragma Interrupt_Handler
4536
4537
4538 Syntax:
4539
4540 @example
4541 pragma Interrupt_Handler (procedure_LOCAL_NAME);
4542 @end example
4543
4544 This program unit pragma is supported for parameterless protected procedures
4545 as described in Annex C of the Ada Reference Manual. On the AAMP target
4546 the pragma can also be specified for nonprotected parameterless procedures
4547 that are declared at the library level (which includes procedures
4548 declared at the top level of a library package). In the case of AAMP,
4549 when this pragma is applied to a nonprotected procedure, the instruction
4550 @code{IERET} is generated for returns from the procedure, enabling
4551 maskable interrupts, in place of the normal return instruction.
4552
4553 @node Pragma Interrupt_State,Pragma Invariant,Pragma Interrupt_Handler,Implementation Defined Pragmas
4554 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-state}@anchor{89}
4555 @section Pragma Interrupt_State
4556
4557
4558 Syntax:
4559
4560 @example
4561 pragma Interrupt_State
4562 ([Name =>] value,
4563 [State =>] SYSTEM | RUNTIME | USER);
4564 @end example
4565
4566 Normally certain interrupts are reserved to the implementation. Any attempt
4567 to attach an interrupt causes Program_Error to be raised, as described in
4568 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4569 many systems for an @code{Ctrl-C} interrupt. Normally this interrupt is
4570 reserved to the implementation, so that @code{Ctrl-C} can be used to
4571 interrupt execution. Additionally, signals such as @code{SIGSEGV},
4572 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
4573 Ada exceptions, or used to implement run-time functions such as the
4574 @code{abort} statement and stack overflow checking.
4575
4576 Pragma @code{Interrupt_State} provides a general mechanism for overriding
4577 such uses of interrupts. It subsumes the functionality of pragma
4578 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
4579 available on Windows. On all other platforms than VxWorks,
4580 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
4581 and may be used to mark interrupts required by the board support package
4582 as reserved.
4583
4584 Interrupts can be in one of three states:
4585
4586
4587 @itemize *
4588
4589 @item
4590 System
4591
4592 The interrupt is reserved (no Ada handler can be installed), and the
4593 Ada run-time may not install a handler. As a result you are guaranteed
4594 standard system default action if this interrupt is raised. This also allows
4595 installing a low level handler via C APIs such as sigaction(), outside
4596 of Ada control.
4597
4598 @item
4599 Runtime
4600
4601 The interrupt is reserved (no Ada handler can be installed). The run time
4602 is allowed to install a handler for internal control purposes, but is
4603 not required to do so.
4604
4605 @item
4606 User
4607
4608 The interrupt is unreserved. The user may install an Ada handler via
4609 Ada.Interrupts and pragma Interrupt_Handler or Attach_Handler to provide
4610 some other action.
4611 @end itemize
4612
4613 These states are the allowed values of the @code{State} parameter of the
4614 pragma. The @code{Name} parameter is a value of the type
4615 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
4616 @code{Ada.Interrupts.Names}.
4617
4618 This is a configuration pragma, and the binder will check that there
4619 are no inconsistencies between different units in a partition in how a
4620 given interrupt is specified. It may appear anywhere a pragma is legal.
4621
4622 The effect is to move the interrupt to the specified state.
4623
4624 By declaring interrupts to be SYSTEM, you guarantee the standard system
4625 action, such as a core dump.
4626
4627 By declaring interrupts to be USER, you guarantee that you can install
4628 a handler.
4629
4630 Note that certain signals on many operating systems cannot be caught and
4631 handled by applications. In such cases, the pragma is ignored. See the
4632 operating system documentation, or the value of the array @code{Reserved}
4633 declared in the spec of package @code{System.OS_Interface}.
4634
4635 Overriding the default state of signals used by the Ada runtime may interfere
4636 with an application's runtime behavior in the cases of the synchronous signals,
4637 and in the case of the signal used to implement the @code{abort} statement.
4638
4639 @node Pragma Invariant,Pragma Keep_Names,Pragma Interrupt_State,Implementation Defined Pragmas
4640 @anchor{gnat_rm/implementation_defined_pragmas id19}@anchor{8a}@anchor{gnat_rm/implementation_defined_pragmas pragma-invariant}@anchor{8b}
4641 @section Pragma Invariant
4642
4643
4644 Syntax:
4645
4646 @example
4647 pragma Invariant
4648 ([Entity =>] private_type_LOCAL_NAME,
4649 [Check =>] EXPRESSION
4650 [,[Message =>] String_Expression]);
4651 @end example
4652
4653 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4654 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4655 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4656 requires the use of the aspect syntax, which is not available except in 2012
4657 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4658 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4659 note that the aspect Invariant is a synonym in GNAT for the aspect
4660 Type_Invariant, but there is no pragma Type_Invariant.
4661
4662 The pragma must appear within the visible part of the package specification,
4663 after the type to which its Entity argument appears. As with the Invariant
4664 aspect, the Check expression is not analyzed until the end of the visible
4665 part of the package, so it may contain forward references. The Message
4666 argument, if present, provides the exception message used if the invariant
4667 is violated. If no Message parameter is provided, a default message that
4668 identifies the line on which the pragma appears is used.
4669
4670 It is permissible to have multiple Invariants for the same type entity, in
4671 which case they are and'ed together. It is permissible to use this pragma
4672 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4673 invariant pragma for the same entity.
4674
4675 For further details on the use of this pragma, see the Ada 2012 documentation
4676 of the Type_Invariant aspect.
4677
4678 @node Pragma Keep_Names,Pragma License,Pragma Invariant,Implementation Defined Pragmas
4679 @anchor{gnat_rm/implementation_defined_pragmas pragma-keep-names}@anchor{8c}
4680 @section Pragma Keep_Names
4681
4682
4683 Syntax:
4684
4685 @example
4686 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4687 @end example
4688
4689 The @code{LOCAL_NAME} argument
4690 must refer to an enumeration first subtype
4691 in the current declarative part. The effect is to retain the enumeration
4692 literal names for use by @code{Image} and @code{Value} even if a global
4693 @code{Discard_Names} pragma applies. This is useful when you want to
4694 generally suppress enumeration literal names and for example you therefore
4695 use a @code{Discard_Names} pragma in the @code{gnat.adc} file, but you
4696 want to retain the names for specific enumeration types.
4697
4698 @node Pragma License,Pragma Link_With,Pragma Keep_Names,Implementation Defined Pragmas
4699 @anchor{gnat_rm/implementation_defined_pragmas pragma-license}@anchor{8d}
4700 @section Pragma License
4701
4702
4703 @geindex License checking
4704
4705 Syntax:
4706
4707 @example
4708 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4709 @end example
4710
4711 This pragma is provided to allow automated checking for appropriate license
4712 conditions with respect to the standard and modified GPL. A pragma
4713 @code{License}, which is a configuration pragma that typically appears at
4714 the start of a source file or in a separate @code{gnat.adc} file, specifies
4715 the licensing conditions of a unit as follows:
4716
4717
4718 @itemize *
4719
4720 @item
4721 Unrestricted
4722 This is used for a unit that can be freely used with no license restrictions.
4723 Examples of such units are public domain units, and units from the Ada
4724 Reference Manual.
4725
4726 @item
4727 GPL
4728 This is used for a unit that is licensed under the unmodified GPL, and which
4729 therefore cannot be @code{with}ed by a restricted unit.
4730
4731 @item
4732 Modified_GPL
4733 This is used for a unit licensed under the GNAT modified GPL that includes
4734 a special exception paragraph that specifically permits the inclusion of
4735 the unit in programs without requiring the entire program to be released
4736 under the GPL.
4737
4738 @item
4739 Restricted
4740 This is used for a unit that is restricted in that it is not permitted to
4741 depend on units that are licensed under the GPL. Typical examples are
4742 proprietary code that is to be released under more restrictive license
4743 conditions. Note that restricted units are permitted to @code{with} units
4744 which are licensed under the modified GPL (this is the whole point of the
4745 modified GPL).
4746 @end itemize
4747
4748 Normally a unit with no @code{License} pragma is considered to have an
4749 unknown license, and no checking is done. However, standard GNAT headers
4750 are recognized, and license information is derived from them as follows.
4751
4752 A GNAT license header starts with a line containing 78 hyphens. The following
4753 comment text is searched for the appearance of any of the following strings.
4754
4755 If the string 'GNU General Public License' is found, then the unit is assumed
4756 to have GPL license, unless the string 'As a special exception' follows, in
4757 which case the license is assumed to be modified GPL.
4758
4759 If one of the strings
4760 'This specification is adapted from the Ada Semantic Interface' or
4761 'This specification is derived from the Ada Reference Manual' is found
4762 then the unit is assumed to be unrestricted.
4763
4764 These default actions means that a program with a restricted license pragma
4765 will automatically get warnings if a GPL unit is inappropriately
4766 @code{with}ed. For example, the program:
4767
4768 @example
4769 with Sem_Ch3;
4770 with GNAT.Sockets;
4771 procedure Secret_Stuff is
4772 ...
4773 end Secret_Stuff
4774 @end example
4775
4776 if compiled with pragma @code{License} (@code{Restricted}) in a
4777 @code{gnat.adc} file will generate the warning:
4778
4779 @example
4780 1. with Sem_Ch3;
4781 |
4782 >>> license of withed unit "Sem_Ch3" is incompatible
4783
4784 2. with GNAT.Sockets;
4785 3. procedure Secret_Stuff is
4786 @end example
4787
4788 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4789 compiler and is licensed under the
4790 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4791 run time, and is therefore licensed under the modified GPL.
4792
4793 @node Pragma Link_With,Pragma Linker_Alias,Pragma License,Implementation Defined Pragmas
4794 @anchor{gnat_rm/implementation_defined_pragmas pragma-link-with}@anchor{8e}
4795 @section Pragma Link_With
4796
4797
4798 Syntax:
4799
4800 @example
4801 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4802 @end example
4803
4804 This pragma is provided for compatibility with certain Ada 83 compilers.
4805 It has exactly the same effect as pragma @code{Linker_Options} except
4806 that spaces occurring within one of the string expressions are treated
4807 as separators. For example, in the following case:
4808
4809 @example
4810 pragma Link_With ("-labc -ldef");
4811 @end example
4812
4813 results in passing the strings @code{-labc} and @code{-ldef} as two
4814 separate arguments to the linker. In addition pragma Link_With allows
4815 multiple arguments, with the same effect as successive pragmas.
4816
4817 @node Pragma Linker_Alias,Pragma Linker_Constructor,Pragma Link_With,Implementation Defined Pragmas
4818 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-alias}@anchor{8f}
4819 @section Pragma Linker_Alias
4820
4821
4822 Syntax:
4823
4824 @example
4825 pragma Linker_Alias (
4826 [Entity =>] LOCAL_NAME,
4827 [Target =>] static_string_EXPRESSION);
4828 @end example
4829
4830 @code{LOCAL_NAME} must refer to an object that is declared at the library
4831 level. This pragma establishes the given entity as a linker alias for the
4832 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4833 and causes @code{LOCAL_NAME} to be emitted as an alias for the symbol
4834 @code{static_string_EXPRESSION} in the object file, that is to say no space
4835 is reserved for @code{LOCAL_NAME} by the assembler and it will be resolved
4836 to the same address as @code{static_string_EXPRESSION} by the linker.
4837
4838 The actual linker name for the target must be used (e.g., the fully
4839 encoded name with qualification in Ada, or the mangled name in C++),
4840 or it must be declared using the C convention with @code{pragma Import}
4841 or @code{pragma Export}.
4842
4843 Not all target machines support this pragma. On some of them it is accepted
4844 only if @code{pragma Weak_External} has been applied to @code{LOCAL_NAME}.
4845
4846 @example
4847 -- Example of the use of pragma Linker_Alias
4848
4849 package p is
4850 i : Integer := 1;
4851 pragma Export (C, i);
4852
4853 new_name_for_i : Integer;
4854 pragma Linker_Alias (new_name_for_i, "i");
4855 end p;
4856 @end example
4857
4858 @node Pragma Linker_Constructor,Pragma Linker_Destructor,Pragma Linker_Alias,Implementation Defined Pragmas
4859 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-constructor}@anchor{90}
4860 @section Pragma Linker_Constructor
4861
4862
4863 Syntax:
4864
4865 @example
4866 pragma Linker_Constructor (procedure_LOCAL_NAME);
4867 @end example
4868
4869 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4870 is declared at the library level. A procedure to which this pragma is
4871 applied will be treated as an initialization routine by the linker.
4872 It is equivalent to @code{__attribute__((constructor))} in GNU C and
4873 causes @code{procedure_LOCAL_NAME} to be invoked before the entry point
4874 of the executable is called (or immediately after the shared library is
4875 loaded if the procedure is linked in a shared library), in particular
4876 before the Ada run-time environment is set up.
4877
4878 Because of these specific contexts, the set of operations such a procedure
4879 can perform is very limited and the type of objects it can manipulate is
4880 essentially restricted to the elementary types. In particular, it must only
4881 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
4882
4883 This pragma is used by GNAT to implement auto-initialization of shared Stand
4884 Alone Libraries, which provides a related capability without the restrictions
4885 listed above. Where possible, the use of Stand Alone Libraries is preferable
4886 to the use of this pragma.
4887
4888 @node Pragma Linker_Destructor,Pragma Linker_Section,Pragma Linker_Constructor,Implementation Defined Pragmas
4889 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-destructor}@anchor{91}
4890 @section Pragma Linker_Destructor
4891
4892
4893 Syntax:
4894
4895 @example
4896 pragma Linker_Destructor (procedure_LOCAL_NAME);
4897 @end example
4898
4899 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
4900 is declared at the library level. A procedure to which this pragma is
4901 applied will be treated as a finalization routine by the linker.
4902 It is equivalent to @code{__attribute__((destructor))} in GNU C and
4903 causes @code{procedure_LOCAL_NAME} to be invoked after the entry point
4904 of the executable has exited (or immediately before the shared library
4905 is unloaded if the procedure is linked in a shared library), in particular
4906 after the Ada run-time environment is shut down.
4907
4908 See @code{pragma Linker_Constructor} for the set of restrictions that apply
4909 because of these specific contexts.
4910
4911 @node Pragma Linker_Section,Pragma Lock_Free,Pragma Linker_Destructor,Implementation Defined Pragmas
4912 @anchor{gnat_rm/implementation_defined_pragmas id20}@anchor{92}@anchor{gnat_rm/implementation_defined_pragmas pragma-linker-section}@anchor{93}
4913 @section Pragma Linker_Section
4914
4915
4916 Syntax:
4917
4918 @example
4919 pragma Linker_Section (
4920 [Entity =>] LOCAL_NAME,
4921 [Section =>] static_string_EXPRESSION);
4922 @end example
4923
4924 @code{LOCAL_NAME} must refer to an object, type, or subprogram that is
4925 declared at the library level. This pragma specifies the name of the
4926 linker section for the given entity. It is equivalent to
4927 @code{__attribute__((section))} in GNU C and causes @code{LOCAL_NAME} to
4928 be placed in the @code{static_string_EXPRESSION} section of the
4929 executable (assuming the linker doesn't rename the section).
4930 GNAT also provides an implementation defined aspect of the same name.
4931
4932 In the case of specifying this aspect for a type, the effect is to
4933 specify the corresponding section for all library-level objects of
4934 the type that do not have an explicit linker section set. Note that
4935 this only applies to whole objects, not to components of composite objects.
4936
4937 In the case of a subprogram, the linker section applies to all previously
4938 declared matching overloaded subprograms in the current declarative part
4939 which do not already have a linker section assigned. The linker section
4940 aspect is useful in this case for specifying different linker sections
4941 for different elements of such an overloaded set.
4942
4943 Note that an empty string specifies that no linker section is specified.
4944 This is not quite the same as omitting the pragma or aspect, since it
4945 can be used to specify that one element of an overloaded set of subprograms
4946 has the default linker section, or that one object of a type for which a
4947 linker section is specified should has the default linker section.
4948
4949 The compiler normally places library-level entities in standard sections
4950 depending on the class: procedures and functions generally go in the
4951 @code{.text} section, initialized variables in the @code{.data} section
4952 and uninitialized variables in the @code{.bss} section.
4953
4954 Other, special sections may exist on given target machines to map special
4955 hardware, for example I/O ports or flash memory. This pragma is a means to
4956 defer the final layout of the executable to the linker, thus fully working
4957 at the symbolic level with the compiler.
4958
4959 Some file formats do not support arbitrary sections so not all target
4960 machines support this pragma. The use of this pragma may cause a program
4961 execution to be erroneous if it is used to place an entity into an
4962 inappropriate section (e.g., a modified variable into the @code{.text}
4963 section). See also @code{pragma Persistent_BSS}.
4964
4965 @example
4966 -- Example of the use of pragma Linker_Section
4967
4968 package IO_Card is
4969 Port_A : Integer;
4970 pragma Volatile (Port_A);
4971 pragma Linker_Section (Port_A, ".bss.port_a");
4972
4973 Port_B : Integer;
4974 pragma Volatile (Port_B);
4975 pragma Linker_Section (Port_B, ".bss.port_b");
4976
4977 type Port_Type is new Integer with Linker_Section => ".bss";
4978 PA : Port_Type with Linker_Section => ".bss.PA";
4979 PB : Port_Type; -- ends up in linker section ".bss"
4980
4981 procedure Q with Linker_Section => "Qsection";
4982 end IO_Card;
4983 @end example
4984
4985 @node Pragma Lock_Free,Pragma Loop_Invariant,Pragma Linker_Section,Implementation Defined Pragmas
4986 @anchor{gnat_rm/implementation_defined_pragmas id21}@anchor{94}@anchor{gnat_rm/implementation_defined_pragmas pragma-lock-free}@anchor{95}
4987 @section Pragma Lock_Free
4988
4989
4990 Syntax:
4991 This pragma may be specified for protected types or objects. It specifies that
4992 the implementation of protected operations must be implemented without locks.
4993 Compilation fails if the compiler cannot generate lock-free code for the
4994 operations.
4995
4996 The current conditions required to support this pragma are:
4997
4998
4999 @itemize *
5000
5001 @item
5002 Protected type declarations may not contain entries
5003
5004 @item
5005 Protected subprogram declarations may not have nonelementary parameters
5006 @end itemize
5007
5008 In addition, each protected subprogram body must satisfy:
5009
5010
5011 @itemize *
5012
5013 @item
5014 May reference only one protected component
5015
5016 @item
5017 May not reference nonconstant entities outside the protected subprogram
5018 scope.
5019
5020 @item
5021 May not contain address representation items, allocators, or quantified
5022 expressions.
5023
5024 @item
5025 May not contain delay, goto, loop, or procedure-call statements.
5026
5027 @item
5028 May not contain exported and imported entities
5029
5030 @item
5031 May not dereferenced access values
5032
5033 @item
5034 Function calls and attribute references must be static
5035 @end itemize
5036
5037 @node Pragma Loop_Invariant,Pragma Loop_Optimize,Pragma Lock_Free,Implementation Defined Pragmas
5038 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-invariant}@anchor{96}
5039 @section Pragma Loop_Invariant
5040
5041
5042 Syntax:
5043
5044 @example
5045 pragma Loop_Invariant ( boolean_EXPRESSION );
5046 @end example
5047
5048 The effect of this pragma is similar to that of pragma @code{Assert},
5049 except that in an @code{Assertion_Policy} pragma, the identifier
5050 @code{Loop_Invariant} is used to control whether it is ignored or checked
5051 (or disabled).
5052
5053 @code{Loop_Invariant} can only appear as one of the items in the sequence
5054 of statements of a loop body, or nested inside block statements that
5055 appear in the sequence of statements of a loop body.
5056 The intention is that it be used to
5057 represent a "loop invariant" assertion, i.e. something that is true each
5058 time through the loop, and which can be used to show that the loop is
5059 achieving its purpose.
5060
5061 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5062 apply to the same loop should be grouped in the same sequence of
5063 statements.
5064
5065 To aid in writing such invariants, the special attribute @code{Loop_Entry}
5066 may be used to refer to the value of an expression on entry to the loop. This
5067 attribute can only be used within the expression of a @code{Loop_Invariant}
5068 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
5069
5070 @node Pragma Loop_Optimize,Pragma Loop_Variant,Pragma Loop_Invariant,Implementation Defined Pragmas
5071 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-optimize}@anchor{97}
5072 @section Pragma Loop_Optimize
5073
5074
5075 Syntax:
5076
5077 @example
5078 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
5079
5080 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
5081 @end example
5082
5083 This pragma must appear immediately within a loop statement. It allows the
5084 programmer to specify optimization hints for the enclosing loop. The hints
5085 are not mutually exclusive and can be freely mixed, but not all combinations
5086 will yield a sensible outcome.
5087
5088 There are five supported optimization hints for a loop:
5089
5090
5091 @itemize *
5092
5093 @item
5094 Ivdep
5095
5096 The programmer asserts that there are no loop-carried dependencies
5097 which would prevent consecutive iterations of the loop from being
5098 executed simultaneously.
5099
5100 @item
5101 No_Unroll
5102
5103 The loop must not be unrolled. This is a strong hint: the compiler will not
5104 unroll a loop marked with this hint.
5105
5106 @item
5107 Unroll
5108
5109 The loop should be unrolled. This is a weak hint: the compiler will try to
5110 apply unrolling to this loop preferably to other optimizations, notably
5111 vectorization, but there is no guarantee that the loop will be unrolled.
5112
5113 @item
5114 No_Vector
5115
5116 The loop must not be vectorized. This is a strong hint: the compiler will not
5117 vectorize a loop marked with this hint.
5118
5119 @item
5120 Vector
5121
5122 The loop should be vectorized. This is a weak hint: the compiler will try to
5123 apply vectorization to this loop preferably to other optimizations, notably
5124 unrolling, but there is no guarantee that the loop will be vectorized.
5125 @end itemize
5126
5127 These hints do not remove the need to pass the appropriate switches to the
5128 compiler in order to enable the relevant optimizations, that is to say
5129 @emph{-funroll-loops} for unrolling and @emph{-ftree-vectorize} for
5130 vectorization.
5131
5132 @node Pragma Loop_Variant,Pragma Machine_Attribute,Pragma Loop_Optimize,Implementation Defined Pragmas
5133 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-variant}@anchor{98}
5134 @section Pragma Loop_Variant
5135
5136
5137 Syntax:
5138
5139 @example
5140 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
5141 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
5142 CHANGE_DIRECTION ::= Increases | Decreases
5143 @end example
5144
5145 @code{Loop_Variant} can only appear as one of the items in the sequence
5146 of statements of a loop body, or nested inside block statements that
5147 appear in the sequence of statements of a loop body.
5148 It allows the specification of quantities which must always
5149 decrease or increase in successive iterations of the loop. In its simplest
5150 form, just one expression is specified, whose value must increase or decrease
5151 on each iteration of the loop.
5152
5153 In a more complex form, multiple arguments can be given which are intepreted
5154 in a nesting lexicographic manner. For example:
5155
5156 @example
5157 pragma Loop_Variant (Increases => X, Decreases => Y);
5158 @end example
5159
5160 specifies that each time through the loop either X increases, or X stays
5161 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
5162 loop is making progress. It can be useful in helping to show informally
5163 or prove formally that the loop always terminates.
5164
5165 @code{Loop_Variant} is an assertion whose effect can be controlled using
5166 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
5167 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
5168 to ignore the check (in which case the pragma has no effect on the program),
5169 or @code{Disable} in which case the pragma is not even checked for correct
5170 syntax.
5171
5172 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5173 apply to the same loop should be grouped in the same sequence of
5174 statements.
5175
5176 The @code{Loop_Entry} attribute may be used within the expressions of the
5177 @code{Loop_Variant} pragma to refer to values on entry to the loop.
5178
5179 @node Pragma Machine_Attribute,Pragma Main,Pragma Loop_Variant,Implementation Defined Pragmas
5180 @anchor{gnat_rm/implementation_defined_pragmas pragma-machine-attribute}@anchor{99}
5181 @section Pragma Machine_Attribute
5182
5183
5184 Syntax:
5185
5186 @example
5187 pragma Machine_Attribute (
5188 [Entity =>] LOCAL_NAME,
5189 [Attribute_Name =>] static_string_EXPRESSION
5190 [, [Info =>] static_EXPRESSION @{, static_EXPRESSION@}] );
5191 @end example
5192
5193 Machine-dependent attributes can be specified for types and/or
5194 declarations. This pragma is semantically equivalent to
5195 @code{__attribute__((@emph{attribute_name}))} (if @code{info} is not
5196 specified) or @code{__attribute__((@emph{attribute_name(info})))}
5197 or @code{__attribute__((@emph{attribute_name(info,...})))} in GNU C,
5198 where @emph{attribute_name} is recognized by the compiler middle-end
5199 or the @code{TARGET_ATTRIBUTE_TABLE} machine specific macro. Note
5200 that a string literal for the optional parameter @code{info} or the
5201 following ones is transformed by default into an identifier,
5202 which may make this pragma unusable for some attributes.
5203 For further information see @cite{GNU Compiler Collection (GCC) Internals}.
5204
5205 @node Pragma Main,Pragma Main_Storage,Pragma Machine_Attribute,Implementation Defined Pragmas
5206 @anchor{gnat_rm/implementation_defined_pragmas pragma-main}@anchor{9a}
5207 @section Pragma Main
5208
5209
5210 Syntax:
5211
5212 @example
5213 pragma Main
5214 (MAIN_OPTION [, MAIN_OPTION]);
5215
5216 MAIN_OPTION ::=
5217 [Stack_Size =>] static_integer_EXPRESSION
5218 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
5219 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
5220 @end example
5221
5222 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
5223 no effect in GNAT, other than being syntax checked.
5224
5225 @node Pragma Main_Storage,Pragma Max_Queue_Length,Pragma Main,Implementation Defined Pragmas
5226 @anchor{gnat_rm/implementation_defined_pragmas pragma-main-storage}@anchor{9b}
5227 @section Pragma Main_Storage
5228
5229
5230 Syntax:
5231
5232 @example
5233 pragma Main_Storage
5234 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
5235
5236 MAIN_STORAGE_OPTION ::=
5237 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
5238 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
5239 @end example
5240
5241 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
5242 no effect in GNAT, other than being syntax checked.
5243
5244 @node Pragma Max_Queue_Length,Pragma No_Body,Pragma Main_Storage,Implementation Defined Pragmas
5245 @anchor{gnat_rm/implementation_defined_pragmas id22}@anchor{9c}@anchor{gnat_rm/implementation_defined_pragmas pragma-max-queue-length}@anchor{9d}
5246 @section Pragma Max_Queue_Length
5247
5248
5249 Syntax:
5250
5251 @example
5252 pragma Max_Entry_Queue (static_integer_EXPRESSION);
5253 @end example
5254
5255 This pragma is used to specify the maximum callers per entry queue for
5256 individual protected entries and entry families. It accepts a single
5257 integer (-1 or more) as a parameter and must appear after the declaration of an
5258 entry.
5259
5260 A value of -1 represents no additional restriction on queue length.
5261
5262 @node Pragma No_Body,Pragma No_Caching,Pragma Max_Queue_Length,Implementation Defined Pragmas
5263 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-body}@anchor{9e}
5264 @section Pragma No_Body
5265
5266
5267 Syntax:
5268
5269 @example
5270 pragma No_Body;
5271 @end example
5272
5273 There are a number of cases in which a package spec does not require a body,
5274 and in fact a body is not permitted. GNAT will not permit the spec to be
5275 compiled if there is a body around. The pragma No_Body allows you to provide
5276 a body file, even in a case where no body is allowed. The body file must
5277 contain only comments and a single No_Body pragma. This is recognized by
5278 the compiler as indicating that no body is logically present.
5279
5280 This is particularly useful during maintenance when a package is modified in
5281 such a way that a body needed before is no longer needed. The provision of a
5282 dummy body with a No_Body pragma ensures that there is no interference from
5283 earlier versions of the package body.
5284
5285 @node Pragma No_Caching,Pragma No_Component_Reordering,Pragma No_Body,Implementation Defined Pragmas
5286 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-caching}@anchor{9f}@anchor{gnat_rm/implementation_defined_pragmas id23}@anchor{a0}
5287 @section Pragma No_Caching
5288
5289
5290 Syntax:
5291
5292 @example
5293 pragma No_Caching [ (boolean_EXPRESSION) ];
5294 @end example
5295
5296 For the semantics of this pragma, see the entry for aspect @code{No_Caching} in
5297 the SPARK 2014 Reference Manual, section 7.1.2.
5298
5299 @node Pragma No_Component_Reordering,Pragma No_Elaboration_Code_All,Pragma No_Caching,Implementation Defined Pragmas
5300 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-component-reordering}@anchor{a1}
5301 @section Pragma No_Component_Reordering
5302
5303
5304 Syntax:
5305
5306 @example
5307 pragma No_Component_Reordering [([Entity =>] type_LOCAL_NAME)];
5308 @end example
5309
5310 @code{type_LOCAL_NAME} must refer to a record type declaration in the current
5311 declarative part. The effect is to preclude any reordering of components
5312 for the layout of the record, i.e. the record is laid out by the compiler
5313 in the order in which the components are declared textually. The form with
5314 no argument is a configuration pragma which applies to all record types
5315 declared in units to which the pragma applies and there is a requirement
5316 that this pragma be used consistently within a partition.
5317
5318 @node Pragma No_Elaboration_Code_All,Pragma No_Heap_Finalization,Pragma No_Component_Reordering,Implementation Defined Pragmas
5319 @anchor{gnat_rm/implementation_defined_pragmas id24}@anchor{a2}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-elaboration-code-all}@anchor{a3}
5320 @section Pragma No_Elaboration_Code_All
5321
5322
5323 Syntax:
5324
5325 @example
5326 pragma No_Elaboration_Code_All [(program_unit_NAME)];
5327 @end example
5328
5329 This is a program unit pragma (there is also an equivalent aspect of the
5330 same name) that establishes the restriction @code{No_Elaboration_Code} for
5331 the current unit and any extended main source units (body and subunits).
5332 It also has the effect of enforcing a transitive application of this
5333 aspect, so that if any unit is implicitly or explicitly with'ed by the
5334 current unit, it must also have the No_Elaboration_Code_All aspect set.
5335 It may be applied to package or subprogram specs or their generic versions.
5336
5337 @node Pragma No_Heap_Finalization,Pragma No_Inline,Pragma No_Elaboration_Code_All,Implementation Defined Pragmas
5338 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-heap-finalization}@anchor{a4}
5339 @section Pragma No_Heap_Finalization
5340
5341
5342 Syntax:
5343
5344 @example
5345 pragma No_Heap_Finalization [ (first_subtype_LOCAL_NAME) ];
5346 @end example
5347
5348 Pragma @code{No_Heap_Finalization} may be used as a configuration pragma or as a
5349 type-specific pragma.
5350
5351 In its configuration form, the pragma must appear within a configuration file
5352 such as gnat.adc, without an argument. The pragma suppresses the call to
5353 @code{Finalize} for heap-allocated objects created through library-level named
5354 access-to-object types in cases where the designated type requires finalization
5355 actions.
5356
5357 In its type-specific form, the argument of the pragma must denote a
5358 library-level named access-to-object type. The pragma suppresses the call to
5359 @code{Finalize} for heap-allocated objects created through the specific access type
5360 in cases where the designated type requires finalization actions.
5361
5362 It is still possible to finalize such heap-allocated objects by explicitly
5363 deallocating them.
5364
5365 A library-level named access-to-object type declared within a generic unit will
5366 lose its @code{No_Heap_Finalization} pragma when the corresponding instance does not
5367 appear at the library level.
5368
5369 @node Pragma No_Inline,Pragma No_Return,Pragma No_Heap_Finalization,Implementation Defined Pragmas
5370 @anchor{gnat_rm/implementation_defined_pragmas id25}@anchor{a5}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-inline}@anchor{a6}
5371 @section Pragma No_Inline
5372
5373
5374 Syntax:
5375
5376 @example
5377 pragma No_Inline (NAME @{, NAME@});
5378 @end example
5379
5380 This pragma suppresses inlining for the callable entity or the instances of
5381 the generic subprogram designated by @code{NAME}, including inlining that
5382 results from the use of pragma @code{Inline}. This pragma is always active,
5383 in particular it is not subject to the use of option @emph{-gnatn} or
5384 @emph{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
5385 pragma @code{Inline_Always} for the same @code{NAME}.
5386
5387 @node Pragma No_Return,Pragma No_Strict_Aliasing,Pragma No_Inline,Implementation Defined Pragmas
5388 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-return}@anchor{a7}
5389 @section Pragma No_Return
5390
5391
5392 Syntax:
5393
5394 @example
5395 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
5396 @end example
5397
5398 Each @code{procedure_LOCAL_NAME} argument must refer to one or more procedure
5399 declarations in the current declarative part. A procedure to which this
5400 pragma is applied may not contain any explicit @code{return} statements.
5401 In addition, if the procedure contains any implicit returns from falling
5402 off the end of a statement sequence, then execution of that implicit
5403 return will cause Program_Error to be raised.
5404
5405 One use of this pragma is to identify procedures whose only purpose is to raise
5406 an exception. Another use of this pragma is to suppress incorrect warnings
5407 about missing returns in functions, where the last statement of a function
5408 statement sequence is a call to such a procedure.
5409
5410 Note that in Ada 2005 mode, this pragma is part of the language. It is
5411 available in all earlier versions of Ada as an implementation-defined
5412 pragma.
5413
5414 @node Pragma No_Strict_Aliasing,Pragma No_Tagged_Streams,Pragma No_Return,Implementation Defined Pragmas
5415 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-strict-aliasing}@anchor{a8}
5416 @section Pragma No_Strict_Aliasing
5417
5418
5419 Syntax:
5420
5421 @example
5422 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
5423 @end example
5424
5425 @code{type_LOCAL_NAME} must refer to an access type
5426 declaration in the current declarative part. The effect is to inhibit
5427 strict aliasing optimization for the given type. The form with no
5428 arguments is a configuration pragma which applies to all access types
5429 declared in units to which the pragma applies. For a detailed
5430 description of the strict aliasing optimization, and the situations
5431 in which it must be suppressed, see the section on Optimization and Strict Aliasing
5432 in the @cite{GNAT User's Guide}.
5433
5434 This pragma currently has no effects on access to unconstrained array types.
5435
5436 @node Pragma No_Tagged_Streams,Pragma Normalize_Scalars,Pragma No_Strict_Aliasing,Implementation Defined Pragmas
5437 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-tagged-streams}@anchor{a9}@anchor{gnat_rm/implementation_defined_pragmas id26}@anchor{aa}
5438 @section Pragma No_Tagged_Streams
5439
5440
5441 Syntax:
5442
5443 @example
5444 pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
5445 @end example
5446
5447 Normally when a tagged type is introduced using a full type declaration,
5448 part of the processing includes generating stream access routines to be
5449 used by stream attributes referencing the type (or one of its subtypes
5450 or derived types). This can involve the generation of significant amounts
5451 of code which is wasted space if stream routines are not needed for the
5452 type in question.
5453
5454 The @code{No_Tagged_Streams} pragma causes the generation of these stream
5455 routines to be skipped, and any attempt to use stream operations on
5456 types subject to this pragma will be statically rejected as illegal.
5457
5458 There are two forms of the pragma. The form with no arguments must appear
5459 in a declarative sequence or in the declarations of a package spec. This
5460 pragma affects all subsequent root tagged types declared in the declaration
5461 sequence, and specifies that no stream routines be generated. The form with
5462 an argument (for which there is also a corresponding aspect) specifies a
5463 single root tagged type for which stream routines are not to be generated.
5464
5465 Once the pragma has been given for a particular root tagged type, all subtypes
5466 and derived types of this type inherit the pragma automatically, so the effect
5467 applies to a complete hierarchy (this is necessary to deal with the class-wide
5468 dispatching versions of the stream routines).
5469
5470 When pragmas @code{Discard_Names} and @code{No_Tagged_Streams} are simultaneously
5471 applied to a tagged type its Expanded_Name and External_Tag are initialized
5472 with empty strings. This is useful to avoid exposing entity names at binary
5473 level but has a negative impact on the debuggability of tagged types.
5474
5475 @node Pragma Normalize_Scalars,Pragma Obsolescent,Pragma No_Tagged_Streams,Implementation Defined Pragmas
5476 @anchor{gnat_rm/implementation_defined_pragmas pragma-normalize-scalars}@anchor{ab}
5477 @section Pragma Normalize_Scalars
5478
5479
5480 Syntax:
5481
5482 @example
5483 pragma Normalize_Scalars;
5484 @end example
5485
5486 This is a language defined pragma which is fully implemented in GNAT. The
5487 effect is to cause all scalar objects that are not otherwise initialized
5488 to be initialized. The initial values are implementation dependent and
5489 are as follows:
5490
5491
5492 @table @asis
5493
5494 @item @emph{Standard.Character}
5495
5496 Objects whose root type is Standard.Character are initialized to
5497 Character'Last unless the subtype range excludes NUL (in which case
5498 NUL is used). This choice will always generate an invalid value if
5499 one exists.
5500
5501 @item @emph{Standard.Wide_Character}
5502
5503 Objects whose root type is Standard.Wide_Character are initialized to
5504 Wide_Character'Last unless the subtype range excludes NUL (in which case
5505 NUL is used). This choice will always generate an invalid value if
5506 one exists.
5507
5508 @item @emph{Standard.Wide_Wide_Character}
5509
5510 Objects whose root type is Standard.Wide_Wide_Character are initialized to
5511 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
5512 which case NUL is used). This choice will always generate an invalid value if
5513 one exists.
5514
5515 @item @emph{Integer types}
5516
5517 Objects of an integer type are treated differently depending on whether
5518 negative values are present in the subtype. If no negative values are
5519 present, then all one bits is used as the initial value except in the
5520 special case where zero is excluded from the subtype, in which case
5521 all zero bits are used. This choice will always generate an invalid
5522 value if one exists.
5523
5524 For subtypes with negative values present, the largest negative number
5525 is used, except in the unusual case where this largest negative number
5526 is in the subtype, and the largest positive number is not, in which case
5527 the largest positive value is used. This choice will always generate
5528 an invalid value if one exists.
5529
5530 @item @emph{Floating-Point Types}
5531
5532 Objects of all floating-point types are initialized to all 1-bits. For
5533 standard IEEE format, this corresponds to a NaN (not a number) which is
5534 indeed an invalid value.
5535
5536 @item @emph{Fixed-Point Types}
5537
5538 Objects of all fixed-point types are treated as described above for integers,
5539 with the rules applying to the underlying integer value used to represent
5540 the fixed-point value.
5541
5542 @item @emph{Modular types}
5543
5544 Objects of a modular type are initialized to all one bits, except in
5545 the special case where zero is excluded from the subtype, in which
5546 case all zero bits are used. This choice will always generate an
5547 invalid value if one exists.
5548
5549 @item @emph{Enumeration types}
5550
5551 Objects of an enumeration type are initialized to all one-bits, i.e., to
5552 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
5553 whose Pos value is zero, in which case a code of zero is used. This choice
5554 will always generate an invalid value if one exists.
5555 @end table
5556
5557 @node Pragma Obsolescent,Pragma Optimize_Alignment,Pragma Normalize_Scalars,Implementation Defined Pragmas
5558 @anchor{gnat_rm/implementation_defined_pragmas pragma-obsolescent}@anchor{ac}@anchor{gnat_rm/implementation_defined_pragmas id27}@anchor{ad}
5559 @section Pragma Obsolescent
5560
5561
5562 Syntax:
5563
5564 @example
5565 pragma Obsolescent;
5566
5567 pragma Obsolescent (
5568 [Message =>] static_string_EXPRESSION
5569 [,[Version =>] Ada_05]]);
5570
5571 pragma Obsolescent (
5572 [Entity =>] NAME
5573 [,[Message =>] static_string_EXPRESSION
5574 [,[Version =>] Ada_05]] );
5575 @end example
5576
5577 This pragma can occur immediately following a declaration of an entity,
5578 including the case of a record component. If no Entity argument is present,
5579 then this declaration is the one to which the pragma applies. If an Entity
5580 parameter is present, it must either match the name of the entity in this
5581 declaration, or alternatively, the pragma can immediately follow an enumeration
5582 type declaration, where the Entity argument names one of the enumeration
5583 literals.
5584
5585 This pragma is used to indicate that the named entity
5586 is considered obsolescent and should not be used. Typically this is
5587 used when an API must be modified by eventually removing or modifying
5588 existing subprograms or other entities. The pragma can be used at an
5589 intermediate stage when the entity is still present, but will be
5590 removed later.
5591
5592 The effect of this pragma is to output a warning message on a reference to
5593 an entity thus marked that the subprogram is obsolescent if the appropriate
5594 warning option in the compiler is activated. If the @code{Message} parameter is
5595 present, then a second warning message is given containing this text. In
5596 addition, a reference to the entity is considered to be a violation of pragma
5597 @code{Restrictions (No_Obsolescent_Features)}.
5598
5599 This pragma can also be used as a program unit pragma for a package,
5600 in which case the entity name is the name of the package, and the
5601 pragma indicates that the entire package is considered
5602 obsolescent. In this case a client @code{with}ing such a package
5603 violates the restriction, and the @code{with} clause is
5604 flagged with warnings if the warning option is set.
5605
5606 If the @code{Version} parameter is present (which must be exactly
5607 the identifier @code{Ada_05}, no other argument is allowed), then the
5608 indication of obsolescence applies only when compiling in Ada 2005
5609 mode. This is primarily intended for dealing with the situations
5610 in the predefined library where subprograms or packages
5611 have become defined as obsolescent in Ada 2005
5612 (e.g., in @code{Ada.Characters.Handling}), but may be used anywhere.
5613
5614 The following examples show typical uses of this pragma:
5615
5616 @example
5617 package p is
5618 pragma Obsolescent (p, Message => "use pp instead of p");
5619 end p;
5620
5621 package q is
5622 procedure q2;
5623 pragma Obsolescent ("use q2new instead");
5624
5625 type R is new integer;
5626 pragma Obsolescent
5627 (Entity => R,
5628 Message => "use RR in Ada 2005",
5629 Version => Ada_05);
5630
5631 type M is record
5632 F1 : Integer;
5633 F2 : Integer;
5634 pragma Obsolescent;
5635 F3 : Integer;
5636 end record;
5637
5638 type E is (a, bc, 'd', quack);
5639 pragma Obsolescent (Entity => bc)
5640 pragma Obsolescent (Entity => 'd')
5641
5642 function "+"
5643 (a, b : character) return character;
5644 pragma Obsolescent (Entity => "+");
5645 end;
5646 @end example
5647
5648 Note that, as for all pragmas, if you use a pragma argument identifier,
5649 then all subsequent parameters must also use a pragma argument identifier.
5650 So if you specify @code{Entity =>} for the @code{Entity} argument, and a @code{Message}
5651 argument is present, it must be preceded by @code{Message =>}.
5652
5653 @node Pragma Optimize_Alignment,Pragma Ordered,Pragma Obsolescent,Implementation Defined Pragmas
5654 @anchor{gnat_rm/implementation_defined_pragmas pragma-optimize-alignment}@anchor{ae}
5655 @section Pragma Optimize_Alignment
5656
5657
5658 @geindex Alignment
5659 @geindex default settings
5660
5661 Syntax:
5662
5663 @example
5664 pragma Optimize_Alignment (TIME | SPACE | OFF);
5665 @end example
5666
5667 This is a configuration pragma which affects the choice of default alignments
5668 for types and objects where no alignment is explicitly specified. There is a
5669 time/space trade-off in the selection of these values. Large alignments result
5670 in more efficient code, at the expense of larger data space, since sizes have
5671 to be increased to match these alignments. Smaller alignments save space, but
5672 the access code is slower. The normal choice of default alignments for types
5673 and individual alignment promotions for objects (which is what you get if you
5674 do not use this pragma, or if you use an argument of OFF), tries to balance
5675 these two requirements.
5676
5677 Specifying SPACE causes smaller default alignments to be chosen in two cases.
5678 First any packed record is given an alignment of 1. Second, if a size is given
5679 for the type, then the alignment is chosen to avoid increasing this size. For
5680 example, consider:
5681
5682 @example
5683 type R is record
5684 X : Integer;
5685 Y : Character;
5686 end record;
5687
5688 for R'Size use 5*8;
5689 @end example
5690
5691 In the default mode, this type gets an alignment of 4, so that access to the
5692 Integer field X are efficient. But this means that objects of the type end up
5693 with a size of 8 bytes. This is a valid choice, since sizes of objects are
5694 allowed to be bigger than the size of the type, but it can waste space if for
5695 example fields of type R appear in an enclosing record. If the above type is
5696 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
5697
5698 However, there is one case in which SPACE is ignored. If a variable length
5699 record (that is a discriminated record with a component which is an array
5700 whose length depends on a discriminant), has a pragma Pack, then it is not
5701 in general possible to set the alignment of such a record to one, so the
5702 pragma is ignored in this case (with a warning).
5703
5704 Specifying SPACE also disables alignment promotions for standalone objects,
5705 which occur when the compiler increases the alignment of a specific object
5706 without changing the alignment of its type.
5707
5708 Specifying SPACE also disables component reordering in unpacked record types,
5709 which can result in larger sizes in order to meet alignment requirements.
5710
5711 Specifying TIME causes larger default alignments to be chosen in the case of
5712 small types with sizes that are not a power of 2. For example, consider:
5713
5714 @example
5715 type R is record
5716 A : Character;
5717 B : Character;
5718 C : Boolean;
5719 end record;
5720
5721 pragma Pack (R);
5722 for R'Size use 17;
5723 @end example
5724
5725 The default alignment for this record is normally 1, but if this type is
5726 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5727 to 4, which wastes space for objects of the type, since they are now 4 bytes
5728 long, but results in more efficient access when the whole record is referenced.
5729
5730 As noted above, this is a configuration pragma, and there is a requirement
5731 that all units in a partition be compiled with a consistent setting of the
5732 optimization setting. This would normally be achieved by use of a configuration
5733 pragma file containing the appropriate setting. The exception to this rule is
5734 that units with an explicit configuration pragma in the same file as the source
5735 unit are excluded from the consistency check, as are all predefined units. The
5736 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5737 pragma appears at the start of the file.
5738
5739 @node Pragma Ordered,Pragma Overflow_Mode,Pragma Optimize_Alignment,Implementation Defined Pragmas
5740 @anchor{gnat_rm/implementation_defined_pragmas pragma-ordered}@anchor{af}
5741 @section Pragma Ordered
5742
5743
5744 Syntax:
5745
5746 @example
5747 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5748 @end example
5749
5750 Most enumeration types are from a conceptual point of view unordered.
5751 For example, consider:
5752
5753 @example
5754 type Color is (Red, Blue, Green, Yellow);
5755 @end example
5756
5757 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5758 but really these relations make no sense; the enumeration type merely
5759 specifies a set of possible colors, and the order is unimportant.
5760
5761 For unordered enumeration types, it is generally a good idea if
5762 clients avoid comparisons (other than equality or inequality) and
5763 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5764 other than the unit where the type is declared, its body, and its subunits.)
5765 For example, if code buried in some client says:
5766
5767 @example
5768 if Current_Color < Yellow then ...
5769 if Current_Color in Blue .. Green then ...
5770 @end example
5771
5772 then the client code is relying on the order, which is undesirable.
5773 It makes the code hard to read and creates maintenance difficulties if
5774 entries have to be added to the enumeration type. Instead,
5775 the code in the client should list the possibilities, or an
5776 appropriate subtype should be declared in the unit that declares
5777 the original enumeration type. E.g., the following subtype could
5778 be declared along with the type @code{Color}:
5779
5780 @example
5781 subtype RBG is Color range Red .. Green;
5782 @end example
5783
5784 and then the client could write:
5785
5786 @example
5787 if Current_Color in RBG then ...
5788 if Current_Color = Blue or Current_Color = Green then ...
5789 @end example
5790
5791 However, some enumeration types are legitimately ordered from a conceptual
5792 point of view. For example, if you declare:
5793
5794 @example
5795 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5796 @end example
5797
5798 then the ordering imposed by the language is reasonable, and
5799 clients can depend on it, writing for example:
5800
5801 @example
5802 if D in Mon .. Fri then ...
5803 if D < Wed then ...
5804 @end example
5805
5806 The pragma @emph{Ordered} is provided to mark enumeration types that
5807 are conceptually ordered, alerting the reader that clients may depend
5808 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5809 rather than one to mark them as unordered, since in our experience,
5810 the great majority of enumeration types are conceptually unordered.
5811
5812 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5813 and @code{Wide_Wide_Character}
5814 are considered to be ordered types, so each is declared with a
5815 pragma @code{Ordered} in package @code{Standard}.
5816
5817 Normally pragma @code{Ordered} serves only as documentation and a guide for
5818 coding standards, but GNAT provides a warning switch @emph{-gnatw.u} that
5819 requests warnings for inappropriate uses (comparisons and explicit
5820 subranges) for unordered types. If this switch is used, then any
5821 enumeration type not marked with pragma @code{Ordered} will be considered
5822 as unordered, and will generate warnings for inappropriate uses.
5823
5824 Note that generic types are not considered ordered or unordered (since the
5825 template can be instantiated for both cases), so we never generate warnings
5826 for the case of generic enumerated types.
5827
5828 For additional information please refer to the description of the
5829 @emph{-gnatw.u} switch in the GNAT User's Guide.
5830
5831 @node Pragma Overflow_Mode,Pragma Overriding_Renamings,Pragma Ordered,Implementation Defined Pragmas
5832 @anchor{gnat_rm/implementation_defined_pragmas pragma-overflow-mode}@anchor{b0}
5833 @section Pragma Overflow_Mode
5834
5835
5836 Syntax:
5837
5838 @example
5839 pragma Overflow_Mode
5840 ( [General =>] MODE
5841 [,[Assertions =>] MODE]);
5842
5843 MODE ::= STRICT | MINIMIZED | ELIMINATED
5844 @end example
5845
5846 This pragma sets the current overflow mode to the given setting. For details
5847 of the meaning of these modes, please refer to the
5848 'Overflow Check Handling in GNAT' appendix in the
5849 GNAT User's Guide. If only the @code{General} parameter is present,
5850 the given mode applies to all expressions. If both parameters are present,
5851 the @code{General} mode applies to expressions outside assertions, and
5852 the @code{Eliminated} mode applies to expressions within assertions.
5853
5854 The case of the @code{MODE} parameter is ignored,
5855 so @code{MINIMIZED}, @code{Minimized} and
5856 @code{minimized} all have the same effect.
5857
5858 The @code{Overflow_Mode} pragma has the same scoping and placement
5859 rules as pragma @code{Suppress}, so it can occur either as a
5860 configuration pragma, specifying a default for the whole
5861 program, or in a declarative scope, where it applies to the
5862 remaining declarations and statements in that scope.
5863
5864 The pragma @code{Suppress (Overflow_Check)} suppresses
5865 overflow checking, but does not affect the overflow mode.
5866
5867 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
5868 overflow checking, but does not affect the overflow mode.
5869
5870 @node Pragma Overriding_Renamings,Pragma Partition_Elaboration_Policy,Pragma Overflow_Mode,Implementation Defined Pragmas
5871 @anchor{gnat_rm/implementation_defined_pragmas pragma-overriding-renamings}@anchor{b1}
5872 @section Pragma Overriding_Renamings
5873
5874
5875 @geindex Rational profile
5876
5877 @geindex Rational compatibility
5878
5879 Syntax:
5880
5881 @example
5882 pragma Overriding_Renamings;
5883 @end example
5884
5885 This is a GNAT configuration pragma to simplify porting
5886 legacy code accepted by the Rational
5887 Ada compiler. In the presence of this pragma, a renaming declaration that
5888 renames an inherited operation declared in the same scope is legal if selected
5889 notation is used as in:
5890
5891 @example
5892 pragma Overriding_Renamings;
5893 ...
5894 package R is
5895 function F (..);
5896 ...
5897 function F (..) renames R.F;
5898 end R;
5899 @end example
5900
5901 even though
5902 RM 8.3 (15) stipulates that an overridden operation is not visible within the
5903 declaration of the overriding operation.
5904
5905 @node Pragma Partition_Elaboration_Policy,Pragma Part_Of,Pragma Overriding_Renamings,Implementation Defined Pragmas
5906 @anchor{gnat_rm/implementation_defined_pragmas pragma-partition-elaboration-policy}@anchor{b2}
5907 @section Pragma Partition_Elaboration_Policy
5908
5909
5910 Syntax:
5911
5912 @example
5913 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
5914
5915 POLICY_IDENTIFIER ::= Concurrent | Sequential
5916 @end example
5917
5918 This pragma is standard in Ada 2005, but is available in all earlier
5919 versions of Ada as an implementation-defined pragma.
5920 See Ada 2012 Reference Manual for details.
5921
5922 @node Pragma Part_Of,Pragma Passive,Pragma Partition_Elaboration_Policy,Implementation Defined Pragmas
5923 @anchor{gnat_rm/implementation_defined_pragmas id28}@anchor{b3}@anchor{gnat_rm/implementation_defined_pragmas pragma-part-of}@anchor{b4}
5924 @section Pragma Part_Of
5925
5926
5927 Syntax:
5928
5929 @example
5930 pragma Part_Of (ABSTRACT_STATE);
5931
5932 ABSTRACT_STATE ::= NAME
5933 @end example
5934
5935 For the semantics of this pragma, see the entry for aspect @code{Part_Of} in the
5936 SPARK 2014 Reference Manual, section 7.2.6.
5937
5938 @node Pragma Passive,Pragma Persistent_BSS,Pragma Part_Of,Implementation Defined Pragmas
5939 @anchor{gnat_rm/implementation_defined_pragmas pragma-passive}@anchor{b5}
5940 @section Pragma Passive
5941
5942
5943 Syntax:
5944
5945 @example
5946 pragma Passive [(Semaphore | No)];
5947 @end example
5948
5949 Syntax checked, but otherwise ignored by GNAT. This is recognized for
5950 compatibility with DEC Ada 83 implementations, where it is used within a
5951 task definition to request that a task be made passive. If the argument
5952 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
5953 treats the pragma as an assertion that the containing task is passive
5954 and that optimization of context switch with this task is permitted and
5955 desired. If the argument @code{No} is present, the task must not be
5956 optimized. GNAT does not attempt to optimize any tasks in this manner
5957 (since protected objects are available in place of passive tasks).
5958
5959 For more information on the subject of passive tasks, see the section
5960 'Passive Task Optimization' in the GNAT Users Guide.
5961
5962 @node Pragma Persistent_BSS,Pragma Post,Pragma Passive,Implementation Defined Pragmas
5963 @anchor{gnat_rm/implementation_defined_pragmas id29}@anchor{b6}@anchor{gnat_rm/implementation_defined_pragmas pragma-persistent-bss}@anchor{b7}
5964 @section Pragma Persistent_BSS
5965
5966
5967 Syntax:
5968
5969 @example
5970 pragma Persistent_BSS [(LOCAL_NAME)]
5971 @end example
5972
5973 This pragma allows selected objects to be placed in the @code{.persistent_bss}
5974 section. On some targets the linker and loader provide for special
5975 treatment of this section, allowing a program to be reloaded without
5976 affecting the contents of this data (hence the name persistent).
5977
5978 There are two forms of usage. If an argument is given, it must be the
5979 local name of a library-level object, with no explicit initialization
5980 and whose type is potentially persistent. If no argument is given, then
5981 the pragma is a configuration pragma, and applies to all library-level
5982 objects with no explicit initialization of potentially persistent types.
5983
5984 A potentially persistent type is a scalar type, or an untagged,
5985 non-discriminated record, all of whose components have no explicit
5986 initialization and are themselves of a potentially persistent type,
5987 or an array, all of whose constraints are static, and whose component
5988 type is potentially persistent.
5989
5990 If this pragma is used on a target where this feature is not supported,
5991 then the pragma will be ignored. See also @code{pragma Linker_Section}.
5992
5993 @node Pragma Post,Pragma Postcondition,Pragma Persistent_BSS,Implementation Defined Pragmas
5994 @anchor{gnat_rm/implementation_defined_pragmas pragma-post}@anchor{b8}
5995 @section Pragma Post
5996
5997
5998 @geindex Post
5999
6000 @geindex Checks
6001 @geindex postconditions
6002
6003 Syntax:
6004
6005 @example
6006 pragma Post (Boolean_Expression);
6007 @end example
6008
6009 The @code{Post} pragma is intended to be an exact replacement for
6010 the language-defined
6011 @code{Post} aspect, and shares its restrictions and semantics.
6012 It must appear either immediately following the corresponding
6013 subprogram declaration (only other pragmas may intervene), or
6014 if there is no separate subprogram declaration, then it can
6015 appear at the start of the declarations in a subprogram body
6016 (preceded only by other pragmas).
6017
6018 @node Pragma Postcondition,Pragma Post_Class,Pragma Post,Implementation Defined Pragmas
6019 @anchor{gnat_rm/implementation_defined_pragmas pragma-postcondition}@anchor{b9}
6020 @section Pragma Postcondition
6021
6022
6023 @geindex Postcondition
6024
6025 @geindex Checks
6026 @geindex postconditions
6027
6028 Syntax:
6029
6030 @example
6031 pragma Postcondition (
6032 [Check =>] Boolean_Expression
6033 [,[Message =>] String_Expression]);
6034 @end example
6035
6036 The @code{Postcondition} pragma allows specification of automatic
6037 postcondition checks for subprograms. These checks are similar to
6038 assertions, but are automatically inserted just prior to the return
6039 statements of the subprogram with which they are associated (including
6040 implicit returns at the end of procedure bodies and associated
6041 exception handlers).
6042
6043 In addition, the boolean expression which is the condition which
6044 must be true may contain references to function'Result in the case
6045 of a function to refer to the returned value.
6046
6047 @code{Postcondition} pragmas may appear either immediately following the
6048 (separate) declaration of a subprogram, or at the start of the
6049 declarations of a subprogram body. Only other pragmas may intervene
6050 (that is appear between the subprogram declaration and its
6051 postconditions, or appear before the postcondition in the
6052 declaration sequence in a subprogram body). In the case of a
6053 postcondition appearing after a subprogram declaration, the
6054 formal arguments of the subprogram are visible, and can be
6055 referenced in the postcondition expressions.
6056
6057 The postconditions are collected and automatically tested just
6058 before any return (implicit or explicit) in the subprogram body.
6059 A postcondition is only recognized if postconditions are active
6060 at the time the pragma is encountered. The compiler switch @emph{gnata}
6061 turns on all postconditions by default, and pragma @code{Check_Policy}
6062 with an identifier of @code{Postcondition} can also be used to
6063 control whether postconditions are active.
6064
6065 The general approach is that postconditions are placed in the spec
6066 if they represent functional aspects which make sense to the client.
6067 For example we might have:
6068
6069 @example
6070 function Direction return Integer;
6071 pragma Postcondition
6072 (Direction'Result = +1
6073 or else
6074 Direction'Result = -1);
6075 @end example
6076
6077 which serves to document that the result must be +1 or -1, and
6078 will test that this is the case at run time if postcondition
6079 checking is active.
6080
6081 Postconditions within the subprogram body can be used to
6082 check that some internal aspect of the implementation,
6083 not visible to the client, is operating as expected.
6084 For instance if a square root routine keeps an internal
6085 counter of the number of times it is called, then we
6086 might have the following postcondition:
6087
6088 @example
6089 Sqrt_Calls : Natural := 0;
6090
6091 function Sqrt (Arg : Float) return Float is
6092 pragma Postcondition
6093 (Sqrt_Calls = Sqrt_Calls'Old + 1);
6094 ...
6095 end Sqrt
6096 @end example
6097
6098 As this example, shows, the use of the @code{Old} attribute
6099 is often useful in postconditions to refer to the state on
6100 entry to the subprogram.
6101
6102 Note that postconditions are only checked on normal returns
6103 from the subprogram. If an abnormal return results from
6104 raising an exception, then the postconditions are not checked.
6105
6106 If a postcondition fails, then the exception
6107 @code{System.Assertions.Assert_Failure} is raised. If
6108 a message argument was supplied, then the given string
6109 will be used as the exception message. If no message
6110 argument was supplied, then the default message has
6111 the form "Postcondition failed at file_name:line". The
6112 exception is raised in the context of the subprogram
6113 body, so it is possible to catch postcondition failures
6114 within the subprogram body itself.
6115
6116 Within a package spec, normal visibility rules
6117 in Ada would prevent forward references within a
6118 postcondition pragma to functions defined later in
6119 the same package. This would introduce undesirable
6120 ordering constraints. To avoid this problem, all
6121 postcondition pragmas are analyzed at the end of
6122 the package spec, allowing forward references.
6123
6124 The following example shows that this even allows
6125 mutually recursive postconditions as in:
6126
6127 @example
6128 package Parity_Functions is
6129 function Odd (X : Natural) return Boolean;
6130 pragma Postcondition
6131 (Odd'Result =
6132 (x = 1
6133 or else
6134 (x /= 0 and then Even (X - 1))));
6135
6136 function Even (X : Natural) return Boolean;
6137 pragma Postcondition
6138 (Even'Result =
6139 (x = 0
6140 or else
6141 (x /= 1 and then Odd (X - 1))));
6142
6143 end Parity_Functions;
6144 @end example
6145
6146 There are no restrictions on the complexity or form of
6147 conditions used within @code{Postcondition} pragmas.
6148 The following example shows that it is even possible
6149 to verify performance behavior.
6150
6151 @example
6152 package Sort is
6153
6154 Performance : constant Float;
6155 -- Performance constant set by implementation
6156 -- to match target architecture behavior.
6157
6158 procedure Treesort (Arg : String);
6159 -- Sorts characters of argument using N*logN sort
6160 pragma Postcondition
6161 (Float (Clock - Clock'Old) <=
6162 Float (Arg'Length) *
6163 log (Float (Arg'Length)) *
6164 Performance);
6165 end Sort;
6166 @end example
6167
6168 Note: postcondition pragmas associated with subprograms that are
6169 marked as Inline_Always, or those marked as Inline with front-end
6170 inlining (-gnatN option set) are accepted and legality-checked
6171 by the compiler, but are ignored at run-time even if postcondition
6172 checking is enabled.
6173
6174 Note that pragma @code{Postcondition} differs from the language-defined
6175 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
6176 multiple occurrences, allowing occurences in the body even if there
6177 is a separate spec, and allowing a second string parameter, and the
6178 use of the pragma identifier @code{Check}. Historically, pragma
6179 @code{Postcondition} was implemented prior to the development of
6180 Ada 2012, and has been retained in its original form for
6181 compatibility purposes.
6182
6183 @node Pragma Post_Class,Pragma Rename_Pragma,Pragma Postcondition,Implementation Defined Pragmas
6184 @anchor{gnat_rm/implementation_defined_pragmas pragma-post-class}@anchor{ba}
6185 @section Pragma Post_Class
6186
6187
6188 @geindex Post
6189
6190 @geindex Checks
6191 @geindex postconditions
6192
6193 Syntax:
6194
6195 @example
6196 pragma Post_Class (Boolean_Expression);
6197 @end example
6198
6199 The @code{Post_Class} pragma is intended to be an exact replacement for
6200 the language-defined
6201 @code{Post'Class} aspect, and shares its restrictions and semantics.
6202 It must appear either immediately following the corresponding
6203 subprogram declaration (only other pragmas may intervene), or
6204 if there is no separate subprogram declaration, then it can
6205 appear at the start of the declarations in a subprogram body
6206 (preceded only by other pragmas).
6207
6208 Note: This pragma is called @code{Post_Class} rather than
6209 @code{Post'Class} because the latter would not be strictly
6210 conforming to the allowed syntax for pragmas. The motivation
6211 for provinding pragmas equivalent to the aspects is to allow a program
6212 to be written using the pragmas, and then compiled if necessary
6213 using an Ada compiler that does not recognize the pragmas or
6214 aspects, but is prepared to ignore the pragmas. The assertion
6215 policy that controls this pragma is @code{Post'Class}, not
6216 @code{Post_Class}.
6217
6218 @node Pragma Rename_Pragma,Pragma Pre,Pragma Post_Class,Implementation Defined Pragmas
6219 @anchor{gnat_rm/implementation_defined_pragmas pragma-rename-pragma}@anchor{bb}
6220 @section Pragma Rename_Pragma
6221
6222
6223 @geindex Pragmas
6224 @geindex synonyms
6225
6226 Syntax:
6227
6228 @example
6229 pragma Rename_Pragma (
6230 [New_Name =>] IDENTIFIER,
6231 [Renamed =>] pragma_IDENTIFIER);
6232 @end example
6233
6234 This pragma provides a mechanism for supplying new names for existing
6235 pragmas. The @code{New_Name} identifier can subsequently be used as a synonym for
6236 the Renamed pragma. For example, suppose you have code that was originally
6237 developed on a compiler that supports Inline_Only as an implementation defined
6238 pragma. And suppose the semantics of pragma Inline_Only are identical to (or at
6239 least very similar to) the GNAT implementation defined pragma
6240 Inline_Always. You could globally replace Inline_Only with Inline_Always.
6241
6242 However, to avoid that source modification, you could instead add a
6243 configuration pragma:
6244
6245 @example
6246 pragma Rename_Pragma (
6247 New_Name => Inline_Only,
6248 Renamed => Inline_Always);
6249 @end example
6250
6251 Then GNAT will treat "pragma Inline_Only ..." as if you had written
6252 "pragma Inline_Always ...".
6253
6254 Pragma Inline_Only will not necessarily mean the same thing as the other Ada
6255 compiler; it's up to you to make sure the semantics are close enough.
6256
6257 @node Pragma Pre,Pragma Precondition,Pragma Rename_Pragma,Implementation Defined Pragmas
6258 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre}@anchor{bc}
6259 @section Pragma Pre
6260
6261
6262 @geindex Pre
6263
6264 @geindex Checks
6265 @geindex preconditions
6266
6267 Syntax:
6268
6269 @example
6270 pragma Pre (Boolean_Expression);
6271 @end example
6272
6273 The @code{Pre} pragma is intended to be an exact replacement for
6274 the language-defined
6275 @code{Pre} aspect, and shares its restrictions and semantics.
6276 It must appear either immediately following the corresponding
6277 subprogram declaration (only other pragmas may intervene), or
6278 if there is no separate subprogram declaration, then it can
6279 appear at the start of the declarations in a subprogram body
6280 (preceded only by other pragmas).
6281
6282 @node Pragma Precondition,Pragma Predicate,Pragma Pre,Implementation Defined Pragmas
6283 @anchor{gnat_rm/implementation_defined_pragmas pragma-precondition}@anchor{bd}
6284 @section Pragma Precondition
6285
6286
6287 @geindex Preconditions
6288
6289 @geindex Checks
6290 @geindex preconditions
6291
6292 Syntax:
6293
6294 @example
6295 pragma Precondition (
6296 [Check =>] Boolean_Expression
6297 [,[Message =>] String_Expression]);
6298 @end example
6299
6300 The @code{Precondition} pragma is similar to @code{Postcondition}
6301 except that the corresponding checks take place immediately upon
6302 entry to the subprogram, and if a precondition fails, the exception
6303 is raised in the context of the caller, and the attribute 'Result
6304 cannot be used within the precondition expression.
6305
6306 Otherwise, the placement and visibility rules are identical to those
6307 described for postconditions. The following is an example of use
6308 within a package spec:
6309
6310 @example
6311 package Math_Functions is
6312 ...
6313 function Sqrt (Arg : Float) return Float;
6314 pragma Precondition (Arg >= 0.0)
6315 ...
6316 end Math_Functions;
6317 @end example
6318
6319 @code{Precondition} pragmas may appear either immediately following the
6320 (separate) declaration of a subprogram, or at the start of the
6321 declarations of a subprogram body. Only other pragmas may intervene
6322 (that is appear between the subprogram declaration and its
6323 postconditions, or appear before the postcondition in the
6324 declaration sequence in a subprogram body).
6325
6326 Note: precondition pragmas associated with subprograms that are
6327 marked as Inline_Always, or those marked as Inline with front-end
6328 inlining (-gnatN option set) are accepted and legality-checked
6329 by the compiler, but are ignored at run-time even if precondition
6330 checking is enabled.
6331
6332 Note that pragma @code{Precondition} differs from the language-defined
6333 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
6334 multiple occurrences, allowing occurences in the body even if there
6335 is a separate spec, and allowing a second string parameter, and the
6336 use of the pragma identifier @code{Check}. Historically, pragma
6337 @code{Precondition} was implemented prior to the development of
6338 Ada 2012, and has been retained in its original form for
6339 compatibility purposes.
6340
6341 @node Pragma Predicate,Pragma Predicate_Failure,Pragma Precondition,Implementation Defined Pragmas
6342 @anchor{gnat_rm/implementation_defined_pragmas pragma-predicate}@anchor{be}@anchor{gnat_rm/implementation_defined_pragmas id30}@anchor{bf}
6343 @section Pragma Predicate
6344
6345
6346 Syntax:
6347
6348 @example
6349 pragma Predicate
6350 ([Entity =>] type_LOCAL_NAME,
6351 [Check =>] EXPRESSION);
6352 @end example
6353
6354 This pragma (available in all versions of Ada in GNAT) encompasses both
6355 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
6356 Ada 2012. A predicate is regarded as static if it has an allowed form
6357 for @code{Static_Predicate} and is otherwise treated as a
6358 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
6359 pragma behave exactly as described in the Ada 2012 reference manual.
6360 For example, if we have
6361
6362 @example
6363 type R is range 1 .. 10;
6364 subtype S is R;
6365 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
6366 subtype Q is R
6367 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
6368 @end example
6369
6370 the effect is identical to the following Ada 2012 code:
6371
6372 @example
6373 type R is range 1 .. 10;
6374 subtype S is R with
6375 Static_Predicate => S not in 4 .. 6;
6376 subtype Q is R with
6377 Dynamic_Predicate => F(Q) or G(Q);
6378 @end example
6379
6380 Note that there are no pragmas @code{Dynamic_Predicate}
6381 or @code{Static_Predicate}. That is
6382 because these pragmas would affect legality and semantics of
6383 the program and thus do not have a neutral effect if ignored.
6384 The motivation behind providing pragmas equivalent to
6385 corresponding aspects is to allow a program to be written
6386 using the pragmas, and then compiled with a compiler that
6387 will ignore the pragmas. That doesn't work in the case of
6388 static and dynamic predicates, since if the corresponding
6389 pragmas are ignored, then the behavior of the program is
6390 fundamentally changed (for example a membership test
6391 @code{A in B} would not take into account a predicate
6392 defined for subtype B). When following this approach, the
6393 use of predicates should be avoided.
6394
6395 @node Pragma Predicate_Failure,Pragma Preelaborable_Initialization,Pragma Predicate,Implementation Defined Pragmas
6396 @anchor{gnat_rm/implementation_defined_pragmas pragma-predicate-failure}@anchor{c0}
6397 @section Pragma Predicate_Failure
6398
6399
6400 Syntax:
6401
6402 @example
6403 pragma Predicate_Failure
6404 ([Entity =>] type_LOCAL_NAME,
6405 [Message =>] String_Expression);
6406 @end example
6407
6408 The @code{Predicate_Failure} pragma is intended to be an exact replacement for
6409 the language-defined
6410 @code{Predicate_Failure} aspect, and shares its restrictions and semantics.
6411
6412 @node Pragma Preelaborable_Initialization,Pragma Prefix_Exception_Messages,Pragma Predicate_Failure,Implementation Defined Pragmas
6413 @anchor{gnat_rm/implementation_defined_pragmas pragma-preelaborable-initialization}@anchor{c1}
6414 @section Pragma Preelaborable_Initialization
6415
6416
6417 Syntax:
6418
6419 @example
6420 pragma Preelaborable_Initialization (DIRECT_NAME);
6421 @end example
6422
6423 This pragma is standard in Ada 2005, but is available in all earlier
6424 versions of Ada as an implementation-defined pragma.
6425 See Ada 2012 Reference Manual for details.
6426
6427 @node Pragma Prefix_Exception_Messages,Pragma Pre_Class,Pragma Preelaborable_Initialization,Implementation Defined Pragmas
6428 @anchor{gnat_rm/implementation_defined_pragmas pragma-prefix-exception-messages}@anchor{c2}
6429 @section Pragma Prefix_Exception_Messages
6430
6431
6432 @geindex Prefix_Exception_Messages
6433
6434 @geindex exception
6435
6436 @geindex Exception_Message
6437
6438 Syntax:
6439
6440 @example
6441 pragma Prefix_Exception_Messages;
6442 @end example
6443
6444 This is an implementation-defined configuration pragma that affects the
6445 behavior of raise statements with a message given as a static string
6446 constant (typically a string literal). In such cases, the string will
6447 be automatically prefixed by the name of the enclosing entity (giving
6448 the package and subprogram containing the raise statement). This helps
6449 to identify where messages are coming from, and this mode is automatic
6450 for the run-time library.
6451
6452 The pragma has no effect if the message is computed with an expression other
6453 than a static string constant, since the assumption in this case is that
6454 the program computes exactly the string it wants. If you still want the
6455 prefixing in this case, you can always call
6456 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
6457
6458 @node Pragma Pre_Class,Pragma Priority_Specific_Dispatching,Pragma Prefix_Exception_Messages,Implementation Defined Pragmas
6459 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre-class}@anchor{c3}
6460 @section Pragma Pre_Class
6461
6462
6463 @geindex Pre_Class
6464
6465 @geindex Checks
6466 @geindex preconditions
6467
6468 Syntax:
6469
6470 @example
6471 pragma Pre_Class (Boolean_Expression);
6472 @end example
6473
6474 The @code{Pre_Class} pragma is intended to be an exact replacement for
6475 the language-defined
6476 @code{Pre'Class} aspect, and shares its restrictions and semantics.
6477 It must appear either immediately following the corresponding
6478 subprogram declaration (only other pragmas may intervene), or
6479 if there is no separate subprogram declaration, then it can
6480 appear at the start of the declarations in a subprogram body
6481 (preceded only by other pragmas).
6482
6483 Note: This pragma is called @code{Pre_Class} rather than
6484 @code{Pre'Class} because the latter would not be strictly
6485 conforming to the allowed syntax for pragmas. The motivation
6486 for providing pragmas equivalent to the aspects is to allow a program
6487 to be written using the pragmas, and then compiled if necessary
6488 using an Ada compiler that does not recognize the pragmas or
6489 aspects, but is prepared to ignore the pragmas. The assertion
6490 policy that controls this pragma is @code{Pre'Class}, not
6491 @code{Pre_Class}.
6492
6493 @node Pragma Priority_Specific_Dispatching,Pragma Profile,Pragma Pre_Class,Implementation Defined Pragmas
6494 @anchor{gnat_rm/implementation_defined_pragmas pragma-priority-specific-dispatching}@anchor{c4}
6495 @section Pragma Priority_Specific_Dispatching
6496
6497
6498 Syntax:
6499
6500 @example
6501 pragma Priority_Specific_Dispatching (
6502 POLICY_IDENTIFIER,
6503 first_priority_EXPRESSION,
6504 last_priority_EXPRESSION)
6505
6506 POLICY_IDENTIFIER ::=
6507 EDF_Across_Priorities |
6508 FIFO_Within_Priorities |
6509 Non_Preemptive_Within_Priorities |
6510 Round_Robin_Within_Priorities
6511 @end example
6512
6513 This pragma is standard in Ada 2005, but is available in all earlier
6514 versions of Ada as an implementation-defined pragma.
6515 See Ada 2012 Reference Manual for details.
6516
6517 @node Pragma Profile,Pragma Profile_Warnings,Pragma Priority_Specific_Dispatching,Implementation Defined Pragmas
6518 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile}@anchor{c5}
6519 @section Pragma Profile
6520
6521
6522 Syntax:
6523
6524 @example
6525 pragma Profile (Ravenscar | Restricted | Rational |
6526 GNAT_Extended_Ravenscar | GNAT_Ravenscar_EDF );
6527 @end example
6528
6529 This pragma is standard in Ada 2005, but is available in all earlier
6530 versions of Ada as an implementation-defined pragma. This is a
6531 configuration pragma that establishes a set of configuration pragmas
6532 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
6533 The other possibilities (@code{Restricted}, @code{Rational},
6534 @code{GNAT_Extended_Ravenscar}, @code{GNAT_Ravenscar_EDF})
6535 are implementation-defined. The set of configuration pragmas
6536 is defined in the following sections.
6537
6538
6539 @itemize *
6540
6541 @item
6542 Pragma Profile (Ravenscar)
6543
6544 The @code{Ravenscar} profile is standard in Ada 2005,
6545 but is available in all earlier
6546 versions of Ada as an implementation-defined pragma. This profile
6547 establishes the following set of configuration pragmas:
6548
6549
6550 @itemize *
6551
6552 @item
6553 @code{Task_Dispatching_Policy (FIFO_Within_Priorities)}
6554
6555 [RM D.2.2] Tasks are dispatched following a preemptive
6556 priority-ordered scheduling policy.
6557
6558 @item
6559 @code{Locking_Policy (Ceiling_Locking)}
6560
6561 [RM D.3] While tasks and interrupts execute a protected action, they inherit
6562 the ceiling priority of the corresponding protected object.
6563
6564 @item
6565 @code{Detect_Blocking}
6566
6567 This pragma forces the detection of potentially blocking operations within a
6568 protected operation, and to raise Program_Error if that happens.
6569 @end itemize
6570
6571 plus the following set of restrictions:
6572
6573
6574 @itemize *
6575
6576 @item
6577 @code{Max_Entry_Queue_Length => 1}
6578
6579 No task can be queued on a protected entry.
6580
6581 @item
6582 @code{Max_Protected_Entries => 1}
6583
6584 @item
6585 @code{Max_Task_Entries => 0}
6586
6587 No rendezvous statements are allowed.
6588
6589 @item
6590 @code{No_Abort_Statements}
6591
6592 @item
6593 @code{No_Dynamic_Attachment}
6594
6595 @item
6596 @code{No_Dynamic_Priorities}
6597
6598 @item
6599 @code{No_Implicit_Heap_Allocations}
6600
6601 @item
6602 @code{No_Local_Protected_Objects}
6603
6604 @item
6605 @code{No_Local_Timing_Events}
6606
6607 @item
6608 @code{No_Protected_Type_Allocators}
6609
6610 @item
6611 @code{No_Relative_Delay}
6612
6613 @item
6614 @code{No_Requeue_Statements}
6615
6616 @item
6617 @code{No_Select_Statements}
6618
6619 @item
6620 @code{No_Specific_Termination_Handlers}
6621
6622 @item
6623 @code{No_Task_Allocators}
6624
6625 @item
6626 @code{No_Task_Hierarchy}
6627
6628 @item
6629 @code{No_Task_Termination}
6630
6631 @item
6632 @code{Simple_Barriers}
6633 @end itemize
6634
6635 The Ravenscar profile also includes the following restrictions that specify
6636 that there are no semantic dependences on the corresponding predefined
6637 packages:
6638
6639
6640 @itemize *
6641
6642 @item
6643 @code{No_Dependence => Ada.Asynchronous_Task_Control}
6644
6645 @item
6646 @code{No_Dependence => Ada.Calendar}
6647
6648 @item
6649 @code{No_Dependence => Ada.Execution_Time.Group_Budget}
6650
6651 @item
6652 @code{No_Dependence => Ada.Execution_Time.Timers}
6653
6654 @item
6655 @code{No_Dependence => Ada.Task_Attributes}
6656
6657 @item
6658 @code{No_Dependence => System.Multiprocessors.Dispatching_Domains}
6659 @end itemize
6660
6661 This set of configuration pragmas and restrictions correspond to the
6662 definition of the 'Ravenscar Profile' for limited tasking, devised and
6663 published by the @cite{International Real-Time Ada Workshop@comma{} 1997}.
6664 A description is also available at
6665 @indicateurl{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
6666
6667 The original definition of the profile was revised at subsequent IRTAW
6668 meetings. It has been included in the ISO
6669 @cite{Guide for the Use of the Ada Programming Language in High Integrity Systems},
6670 and was made part of the Ada 2005 standard.
6671 The formal definition given by
6672 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
6673 AI-305) available at
6674 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
6675 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
6676
6677 The above set is a superset of the restrictions provided by pragma
6678 @code{Profile (Restricted)}, it includes six additional restrictions
6679 (@code{Simple_Barriers}, @code{No_Select_Statements},
6680 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
6681 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
6682 that pragma @code{Profile (Ravenscar)}, like the pragma
6683 @code{Profile (Restricted)},
6684 automatically causes the use of a simplified,
6685 more efficient version of the tasking run-time library.
6686
6687 @item
6688 Pragma Profile (GNAT_Extended_Ravenscar)
6689
6690 This profile corresponds to a GNAT specific extension of the
6691 Ravenscar profile. The profile may change in the future although
6692 only in a compatible way: some restrictions may be removed or
6693 relaxed. It is defined as a variation of the Ravenscar profile.
6694
6695 The @code{No_Implicit_Heap_Allocations} restriction has been replaced
6696 by @code{No_Implicit_Task_Allocations} and
6697 @code{No_Implicit_Protected_Object_Allocations}.
6698
6699 The @code{Simple_Barriers} restriction has been replaced by
6700 @code{Pure_Barriers}.
6701
6702 The @code{Max_Protected_Entries}, @code{Max_Entry_Queue_Length}, and
6703 @code{No_Relative_Delay} restrictions have been removed.
6704
6705 @item
6706 Pragma Profile (GNAT_Ravenscar_EDF)
6707
6708 This profile corresponds to the Ravenscar profile but using
6709 EDF_Across_Priority as the Task_Scheduling_Policy.
6710
6711 @item
6712 Pragma Profile (Restricted)
6713
6714 This profile corresponds to the GNAT restricted run time. It
6715 establishes the following set of restrictions:
6716
6717
6718 @itemize *
6719
6720 @item
6721 @code{No_Abort_Statements}
6722
6723 @item
6724 @code{No_Entry_Queue}
6725
6726 @item
6727 @code{No_Task_Hierarchy}
6728
6729 @item
6730 @code{No_Task_Allocators}
6731
6732 @item
6733 @code{No_Dynamic_Priorities}
6734
6735 @item
6736 @code{No_Terminate_Alternatives}
6737
6738 @item
6739 @code{No_Dynamic_Attachment}
6740
6741 @item
6742 @code{No_Protected_Type_Allocators}
6743
6744 @item
6745 @code{No_Local_Protected_Objects}
6746
6747 @item
6748 @code{No_Requeue_Statements}
6749
6750 @item
6751 @code{No_Task_Attributes_Package}
6752
6753 @item
6754 @code{Max_Asynchronous_Select_Nesting = 0}
6755
6756 @item
6757 @code{Max_Task_Entries = 0}
6758
6759 @item
6760 @code{Max_Protected_Entries = 1}
6761
6762 @item
6763 @code{Max_Select_Alternatives = 0}
6764 @end itemize
6765
6766 This set of restrictions causes the automatic selection of a simplified
6767 version of the run time that provides improved performance for the
6768 limited set of tasking functionality permitted by this set of restrictions.
6769
6770 @item
6771 Pragma Profile (Rational)
6772
6773 The Rational profile is intended to facilitate porting legacy code that
6774 compiles with the Rational APEX compiler, even when the code includes non-
6775 conforming Ada constructs. The profile enables the following three pragmas:
6776
6777
6778 @itemize *
6779
6780 @item
6781 @code{pragma Implicit_Packing}
6782
6783 @item
6784 @code{pragma Overriding_Renamings}
6785
6786 @item
6787 @code{pragma Use_VADS_Size}
6788 @end itemize
6789 @end itemize
6790
6791 @node Pragma Profile_Warnings,Pragma Propagate_Exceptions,Pragma Profile,Implementation Defined Pragmas
6792 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile-warnings}@anchor{c6}
6793 @section Pragma Profile_Warnings
6794
6795
6796 Syntax:
6797
6798 @example
6799 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
6800 @end example
6801
6802 This is an implementation-defined pragma that is similar in
6803 effect to @code{pragma Profile} except that instead of
6804 generating @code{Restrictions} pragmas, it generates
6805 @code{Restriction_Warnings} pragmas. The result is that
6806 violations of the profile generate warning messages instead
6807 of error messages.
6808
6809 @node Pragma Propagate_Exceptions,Pragma Provide_Shift_Operators,Pragma Profile_Warnings,Implementation Defined Pragmas
6810 @anchor{gnat_rm/implementation_defined_pragmas pragma-propagate-exceptions}@anchor{c7}
6811 @section Pragma Propagate_Exceptions
6812
6813
6814 @geindex Interfacing to C++
6815
6816 Syntax:
6817
6818 @example
6819 pragma Propagate_Exceptions;
6820 @end example
6821
6822 This pragma is now obsolete and, other than generating a warning if warnings
6823 on obsolescent features are enabled, is ignored.
6824 It is retained for compatibility
6825 purposes. It used to be used in connection with optimization of
6826 a now-obsolete mechanism for implementation of exceptions.
6827
6828 @node Pragma Provide_Shift_Operators,Pragma Psect_Object,Pragma Propagate_Exceptions,Implementation Defined Pragmas
6829 @anchor{gnat_rm/implementation_defined_pragmas pragma-provide-shift-operators}@anchor{c8}
6830 @section Pragma Provide_Shift_Operators
6831
6832
6833 @geindex Shift operators
6834
6835 Syntax:
6836
6837 @example
6838 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
6839 @end example
6840
6841 This pragma can be applied to a first subtype local name that specifies
6842 either an unsigned or signed type. It has the effect of providing the
6843 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
6844 Rotate_Left and Rotate_Right) for the given type. It is similar to
6845 including the function declarations for these five operators, together
6846 with the pragma Import (Intrinsic, ...) statements.
6847
6848 @node Pragma Psect_Object,Pragma Pure_Function,Pragma Provide_Shift_Operators,Implementation Defined Pragmas
6849 @anchor{gnat_rm/implementation_defined_pragmas pragma-psect-object}@anchor{c9}
6850 @section Pragma Psect_Object
6851
6852
6853 Syntax:
6854
6855 @example
6856 pragma Psect_Object (
6857 [Internal =>] LOCAL_NAME,
6858 [, [External =>] EXTERNAL_SYMBOL]
6859 [, [Size =>] EXTERNAL_SYMBOL]);
6860
6861 EXTERNAL_SYMBOL ::=
6862 IDENTIFIER
6863 | static_string_EXPRESSION
6864 @end example
6865
6866 This pragma is identical in effect to pragma @code{Common_Object}.
6867
6868 @node Pragma Pure_Function,Pragma Rational,Pragma Psect_Object,Implementation Defined Pragmas
6869 @anchor{gnat_rm/implementation_defined_pragmas pragma-pure-function}@anchor{ca}@anchor{gnat_rm/implementation_defined_pragmas id31}@anchor{cb}
6870 @section Pragma Pure_Function
6871
6872
6873 Syntax:
6874
6875 @example
6876 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
6877 @end example
6878
6879 This pragma appears in the same declarative part as a function
6880 declaration (or a set of function declarations if more than one
6881 overloaded declaration exists, in which case the pragma applies
6882 to all entities). It specifies that the function @code{Entity} is
6883 to be considered pure for the purposes of code generation. This means
6884 that the compiler can assume that there are no side effects, and
6885 in particular that two calls with identical arguments produce the
6886 same result. It also means that the function can be used in an
6887 address clause.
6888
6889 Note that, quite deliberately, there are no static checks to try
6890 to ensure that this promise is met, so @code{Pure_Function} can be used
6891 with functions that are conceptually pure, even if they do modify
6892 global variables. For example, a square root function that is
6893 instrumented to count the number of times it is called is still
6894 conceptually pure, and can still be optimized, even though it
6895 modifies a global variable (the count). Memo functions are another
6896 example (where a table of previous calls is kept and consulted to
6897 avoid re-computation).
6898
6899 Note also that the normal rules excluding optimization of subprograms
6900 in pure units (when parameter types are descended from System.Address,
6901 or when the full view of a parameter type is limited), do not apply
6902 for the Pure_Function case. If you explicitly specify Pure_Function,
6903 the compiler may optimize away calls with identical arguments, and
6904 if that results in unexpected behavior, the proper action is not to
6905 use the pragma for subprograms that are not (conceptually) pure.
6906
6907 Note: Most functions in a @code{Pure} package are automatically pure, and
6908 there is no need to use pragma @code{Pure_Function} for such functions. One
6909 exception is any function that has at least one formal of type
6910 @code{System.Address} or a type derived from it. Such functions are not
6911 considered pure by default, since the compiler assumes that the
6912 @code{Address} parameter may be functioning as a pointer and that the
6913 referenced data may change even if the address value does not.
6914 Similarly, imported functions are not considered to be pure by default,
6915 since there is no way of checking that they are in fact pure. The use
6916 of pragma @code{Pure_Function} for such a function will override these default
6917 assumption, and cause the compiler to treat a designated subprogram as pure
6918 in these cases.
6919
6920 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
6921 applies to the underlying renamed function. This can be used to
6922 disambiguate cases of overloading where some but not all functions
6923 in a set of overloaded functions are to be designated as pure.
6924
6925 If pragma @code{Pure_Function} is applied to a library-level function, the
6926 function is also considered pure from an optimization point of view, but the
6927 unit is not a Pure unit in the categorization sense. So for example, a function
6928 thus marked is free to @code{with} non-pure units.
6929
6930 @node Pragma Rational,Pragma Ravenscar,Pragma Pure_Function,Implementation Defined Pragmas
6931 @anchor{gnat_rm/implementation_defined_pragmas pragma-rational}@anchor{cc}
6932 @section Pragma Rational
6933
6934
6935 Syntax:
6936
6937 @example
6938 pragma Rational;
6939 @end example
6940
6941 This pragma is considered obsolescent, but is retained for
6942 compatibility purposes. It is equivalent to:
6943
6944 @example
6945 pragma Profile (Rational);
6946 @end example
6947
6948 @node Pragma Ravenscar,Pragma Refined_Depends,Pragma Rational,Implementation Defined Pragmas
6949 @anchor{gnat_rm/implementation_defined_pragmas pragma-ravenscar}@anchor{cd}
6950 @section Pragma Ravenscar
6951
6952
6953 Syntax:
6954
6955 @example
6956 pragma Ravenscar;
6957 @end example
6958
6959 This pragma is considered obsolescent, but is retained for
6960 compatibility purposes. It is equivalent to:
6961
6962 @example
6963 pragma Profile (Ravenscar);
6964 @end example
6965
6966 which is the preferred method of setting the @code{Ravenscar} profile.
6967
6968 @node Pragma Refined_Depends,Pragma Refined_Global,Pragma Ravenscar,Implementation Defined Pragmas
6969 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-depends}@anchor{ce}@anchor{gnat_rm/implementation_defined_pragmas id32}@anchor{cf}
6970 @section Pragma Refined_Depends
6971
6972
6973 Syntax:
6974
6975 @example
6976 pragma Refined_Depends (DEPENDENCY_RELATION);
6977
6978 DEPENDENCY_RELATION ::=
6979 null
6980 | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
6981
6982 DEPENDENCY_CLAUSE ::=
6983 OUTPUT_LIST =>[+] INPUT_LIST
6984 | NULL_DEPENDENCY_CLAUSE
6985
6986 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
6987
6988 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
6989
6990 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
6991
6992 OUTPUT ::= NAME | FUNCTION_RESULT
6993 INPUT ::= NAME
6994
6995 where FUNCTION_RESULT is a function Result attribute_reference
6996 @end example
6997
6998 For the semantics of this pragma, see the entry for aspect @code{Refined_Depends} in
6999 the SPARK 2014 Reference Manual, section 6.1.5.
7000
7001 @node Pragma Refined_Global,Pragma Refined_Post,Pragma Refined_Depends,Implementation Defined Pragmas
7002 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-global}@anchor{d0}@anchor{gnat_rm/implementation_defined_pragmas id33}@anchor{d1}
7003 @section Pragma Refined_Global
7004
7005
7006 Syntax:
7007
7008 @example
7009 pragma Refined_Global (GLOBAL_SPECIFICATION);
7010
7011 GLOBAL_SPECIFICATION ::=
7012 null
7013 | (GLOBAL_LIST)
7014 | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
7015
7016 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
7017
7018 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
7019 GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
7020 GLOBAL_ITEM ::= NAME
7021 @end example
7022
7023 For the semantics of this pragma, see the entry for aspect @code{Refined_Global} in
7024 the SPARK 2014 Reference Manual, section 6.1.4.
7025
7026 @node Pragma Refined_Post,Pragma Refined_State,Pragma Refined_Global,Implementation Defined Pragmas
7027 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-post}@anchor{d2}@anchor{gnat_rm/implementation_defined_pragmas id34}@anchor{d3}
7028 @section Pragma Refined_Post
7029
7030
7031 Syntax:
7032
7033 @example
7034 pragma Refined_Post (boolean_EXPRESSION);
7035 @end example
7036
7037 For the semantics of this pragma, see the entry for aspect @code{Refined_Post} in
7038 the SPARK 2014 Reference Manual, section 7.2.7.
7039
7040 @node Pragma Refined_State,Pragma Relative_Deadline,Pragma Refined_Post,Implementation Defined Pragmas
7041 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-state}@anchor{d4}@anchor{gnat_rm/implementation_defined_pragmas id35}@anchor{d5}
7042 @section Pragma Refined_State
7043
7044
7045 Syntax:
7046
7047 @example
7048 pragma Refined_State (REFINEMENT_LIST);
7049
7050 REFINEMENT_LIST ::=
7051 (REFINEMENT_CLAUSE @{, REFINEMENT_CLAUSE@})
7052
7053 REFINEMENT_CLAUSE ::= state_NAME => CONSTITUENT_LIST
7054
7055 CONSTITUENT_LIST ::=
7056 null
7057 | CONSTITUENT
7058 | (CONSTITUENT @{, CONSTITUENT@})
7059
7060 CONSTITUENT ::= object_NAME | state_NAME
7061 @end example
7062
7063 For the semantics of this pragma, see the entry for aspect @code{Refined_State} in
7064 the SPARK 2014 Reference Manual, section 7.2.2.
7065
7066 @node Pragma Relative_Deadline,Pragma Remote_Access_Type,Pragma Refined_State,Implementation Defined Pragmas
7067 @anchor{gnat_rm/implementation_defined_pragmas pragma-relative-deadline}@anchor{d6}
7068 @section Pragma Relative_Deadline
7069
7070
7071 Syntax:
7072
7073 @example
7074 pragma Relative_Deadline (time_span_EXPRESSION);
7075 @end example
7076
7077 This pragma is standard in Ada 2005, but is available in all earlier
7078 versions of Ada as an implementation-defined pragma.
7079 See Ada 2012 Reference Manual for details.
7080
7081 @node Pragma Remote_Access_Type,Pragma Restricted_Run_Time,Pragma Relative_Deadline,Implementation Defined Pragmas
7082 @anchor{gnat_rm/implementation_defined_pragmas id36}@anchor{d7}@anchor{gnat_rm/implementation_defined_pragmas pragma-remote-access-type}@anchor{d8}
7083 @section Pragma Remote_Access_Type
7084
7085
7086 Syntax:
7087
7088 @example
7089 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
7090 @end example
7091
7092 This pragma appears in the formal part of a generic declaration.
7093 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
7094 the use of a remote access to class-wide type as actual for a formal
7095 access type.
7096
7097 When this pragma applies to a formal access type @code{Entity}, that
7098 type is treated as a remote access to class-wide type in the generic.
7099 It must be a formal general access type, and its designated type must
7100 be the class-wide type of a formal tagged limited private type from the
7101 same generic declaration.
7102
7103 In the generic unit, the formal type is subject to all restrictions
7104 pertaining to remote access to class-wide types. At instantiation, the
7105 actual type must be a remote access to class-wide type.
7106
7107 @node Pragma Restricted_Run_Time,Pragma Restriction_Warnings,Pragma Remote_Access_Type,Implementation Defined Pragmas
7108 @anchor{gnat_rm/implementation_defined_pragmas pragma-restricted-run-time}@anchor{d9}
7109 @section Pragma Restricted_Run_Time
7110
7111
7112 Syntax:
7113
7114 @example
7115 pragma Restricted_Run_Time;
7116 @end example
7117
7118 This pragma is considered obsolescent, but is retained for
7119 compatibility purposes. It is equivalent to:
7120
7121 @example
7122 pragma Profile (Restricted);
7123 @end example
7124
7125 which is the preferred method of setting the restricted run time
7126 profile.
7127
7128 @node Pragma Restriction_Warnings,Pragma Reviewable,Pragma Restricted_Run_Time,Implementation Defined Pragmas
7129 @anchor{gnat_rm/implementation_defined_pragmas pragma-restriction-warnings}@anchor{da}
7130 @section Pragma Restriction_Warnings
7131
7132
7133 Syntax:
7134
7135 @example
7136 pragma Restriction_Warnings
7137 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
7138 @end example
7139
7140 This pragma allows a series of restriction identifiers to be
7141 specified (the list of allowed identifiers is the same as for
7142 pragma @code{Restrictions}). For each of these identifiers
7143 the compiler checks for violations of the restriction, but
7144 generates a warning message rather than an error message
7145 if the restriction is violated.
7146
7147 One use of this is in situations where you want to know
7148 about violations of a restriction, but you want to ignore some of
7149 these violations. Consider this example, where you want to set
7150 Ada_95 mode and enable style checks, but you want to know about
7151 any other use of implementation pragmas:
7152
7153 @example
7154 pragma Restriction_Warnings (No_Implementation_Pragmas);
7155 pragma Warnings (Off, "violation of No_Implementation_Pragmas");
7156 pragma Ada_95;
7157 pragma Style_Checks ("2bfhkM160");
7158 pragma Warnings (On, "violation of No_Implementation_Pragmas");
7159 @end example
7160
7161 By including the above lines in a configuration pragmas file,
7162 the Ada_95 and Style_Checks pragmas are accepted without
7163 generating a warning, but any other use of implementation
7164 defined pragmas will cause a warning to be generated.
7165
7166 @node Pragma Reviewable,Pragma Secondary_Stack_Size,Pragma Restriction_Warnings,Implementation Defined Pragmas
7167 @anchor{gnat_rm/implementation_defined_pragmas pragma-reviewable}@anchor{db}
7168 @section Pragma Reviewable
7169
7170
7171 Syntax:
7172
7173 @example
7174 pragma Reviewable;
7175 @end example
7176
7177 This pragma is an RM-defined standard pragma, but has no effect on the
7178 program being compiled, or on the code generated for the program.
7179
7180 To obtain the required output specified in RM H.3.1, the compiler must be
7181 run with various special switches as follows:
7182
7183
7184 @itemize *
7185
7186 @item
7187 @emph{Where compiler-generated run-time checks remain}
7188
7189 The switch @emph{-gnatGL}
7190 may be used to list the expanded code in pseudo-Ada form.
7191 Runtime checks show up in the listing either as explicit
7192 checks or operators marked with @{@} to indicate a check is present.
7193
7194 @item
7195 @emph{An identification of known exceptions at compile time}
7196
7197 If the program is compiled with @emph{-gnatwa},
7198 the compiler warning messages will indicate all cases where the compiler
7199 detects that an exception is certain to occur at run time.
7200
7201 @item
7202 @emph{Possible reads of uninitialized variables}
7203
7204 The compiler warns of many such cases, but its output is incomplete.
7205 @end itemize
7206
7207
7208 A supplemental static analysis tool
7209 may be used to obtain a comprehensive list of all
7210 possible points at which uninitialized data may be read.
7211
7212
7213 @itemize *
7214
7215 @item
7216 @emph{Where run-time support routines are implicitly invoked}
7217
7218 In the output from @emph{-gnatGL},
7219 run-time calls are explicitly listed as calls to the relevant
7220 run-time routine.
7221
7222 @item
7223 @emph{Object code listing}
7224
7225 This may be obtained either by using the @emph{-S} switch,
7226 or the objdump utility.
7227
7228 @item
7229 @emph{Constructs known to be erroneous at compile time}
7230
7231 These are identified by warnings issued by the compiler (use @emph{-gnatwa}).
7232
7233 @item
7234 @emph{Stack usage information}
7235
7236 Static stack usage data (maximum per-subprogram) can be obtained via the
7237 @emph{-fstack-usage} switch to the compiler.
7238 Dynamic stack usage data (per task) can be obtained via the @emph{-u} switch
7239 to gnatbind
7240 @end itemize
7241
7242
7243
7244 @itemize *
7245
7246 @item
7247 @emph{Object code listing of entire partition}
7248
7249 This can be obtained by compiling the partition with @emph{-S},
7250 or by applying objdump
7251 to all the object files that are part of the partition.
7252
7253 @item
7254 @emph{A description of the run-time model}
7255
7256 The full sources of the run-time are available, and the documentation of
7257 these routines describes how these run-time routines interface to the
7258 underlying operating system facilities.
7259
7260 @item
7261 @emph{Control and data-flow information}
7262 @end itemize
7263
7264
7265 A supplemental static analysis tool
7266 may be used to obtain complete control and data-flow information, as well as
7267 comprehensive messages identifying possible problems based on this
7268 information.
7269
7270 @node Pragma Secondary_Stack_Size,Pragma Share_Generic,Pragma Reviewable,Implementation Defined Pragmas
7271 @anchor{gnat_rm/implementation_defined_pragmas id37}@anchor{dc}@anchor{gnat_rm/implementation_defined_pragmas pragma-secondary-stack-size}@anchor{dd}
7272 @section Pragma Secondary_Stack_Size
7273
7274
7275 Syntax:
7276
7277 @example
7278 pragma Secondary_Stack_Size (integer_EXPRESSION);
7279 @end example
7280
7281 This pragma appears within the task definition of a single task declaration
7282 or a task type declaration (like pragma @code{Storage_Size}) and applies to all
7283 task objects of that type. The argument specifies the size of the secondary
7284 stack to be used by these task objects, and must be of an integer type. The
7285 secondary stack is used to handle functions that return a variable-sized
7286 result, for example a function returning an unconstrained String.
7287
7288 Note this pragma only applies to targets using fixed secondary stacks, like
7289 VxWorks 653 and bare board targets, where a fixed block for the
7290 secondary stack is allocated from the primary stack of the task. By default,
7291 these targets assign a percentage of the primary stack for the secondary stack,
7292 as defined by @code{System.Parameter.Sec_Stack_Percentage}. With this pragma,
7293 an @code{integer_EXPRESSION} of bytes is assigned from the primary stack instead.
7294
7295 For most targets, the pragma does not apply as the secondary stack grows on
7296 demand: allocated as a chain of blocks in the heap. The default size of these
7297 blocks can be modified via the @code{-D} binder option as described in
7298 @cite{GNAT User's Guide}.
7299
7300 Note that no check is made to see if the secondary stack can fit inside the
7301 primary stack.
7302
7303 Note the pragma cannot appear when the restriction @code{No_Secondary_Stack}
7304 is in effect.
7305
7306 @node Pragma Share_Generic,Pragma Shared,Pragma Secondary_Stack_Size,Implementation Defined Pragmas
7307 @anchor{gnat_rm/implementation_defined_pragmas pragma-share-generic}@anchor{de}
7308 @section Pragma Share_Generic
7309
7310
7311 Syntax:
7312
7313 @example
7314 pragma Share_Generic (GNAME @{, GNAME@});
7315
7316 GNAME ::= generic_unit_NAME | generic_instance_NAME
7317 @end example
7318
7319 This pragma is provided for compatibility with Dec Ada 83. It has
7320 no effect in GNAT (which does not implement shared generics), other
7321 than to check that the given names are all names of generic units or
7322 generic instances.
7323
7324 @node Pragma Shared,Pragma Short_Circuit_And_Or,Pragma Share_Generic,Implementation Defined Pragmas
7325 @anchor{gnat_rm/implementation_defined_pragmas id38}@anchor{df}@anchor{gnat_rm/implementation_defined_pragmas pragma-shared}@anchor{e0}
7326 @section Pragma Shared
7327
7328
7329 This pragma is provided for compatibility with Ada 83. The syntax and
7330 semantics are identical to pragma Atomic.
7331
7332 @node Pragma Short_Circuit_And_Or,Pragma Short_Descriptors,Pragma Shared,Implementation Defined Pragmas
7333 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-circuit-and-or}@anchor{e1}
7334 @section Pragma Short_Circuit_And_Or
7335
7336
7337 Syntax:
7338
7339 @example
7340 pragma Short_Circuit_And_Or;
7341 @end example
7342
7343 This configuration pragma causes any occurrence of the AND operator applied to
7344 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
7345 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
7346 may be useful in the context of certification protocols requiring the use of
7347 short-circuited logical operators. If this configuration pragma occurs locally
7348 within the file being compiled, it applies only to the file being compiled.
7349 There is no requirement that all units in a partition use this option.
7350
7351 @node Pragma Short_Descriptors,Pragma Simple_Storage_Pool_Type,Pragma Short_Circuit_And_Or,Implementation Defined Pragmas
7352 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-descriptors}@anchor{e2}
7353 @section Pragma Short_Descriptors
7354
7355
7356 Syntax:
7357
7358 @example
7359 pragma Short_Descriptors
7360 @end example
7361
7362 This pragma is provided for compatibility with other Ada implementations. It
7363 is recognized but ignored by all current versions of GNAT.
7364
7365 @node Pragma Simple_Storage_Pool_Type,Pragma Source_File_Name,Pragma Short_Descriptors,Implementation Defined Pragmas
7366 @anchor{gnat_rm/implementation_defined_pragmas pragma-simple-storage-pool-type}@anchor{e3}@anchor{gnat_rm/implementation_defined_pragmas id39}@anchor{e4}
7367 @section Pragma Simple_Storage_Pool_Type
7368
7369
7370 @geindex Storage pool
7371 @geindex simple
7372
7373 @geindex Simple storage pool
7374
7375 Syntax:
7376
7377 @example
7378 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
7379 @end example
7380
7381 A type can be established as a 'simple storage pool type' by applying
7382 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
7383 A type named in the pragma must be a library-level immutably limited record
7384 type or limited tagged type declared immediately within a package declaration.
7385 The type can also be a limited private type whose full type is allowed as
7386 a simple storage pool type.
7387
7388 For a simple storage pool type @code{SSP}, nonabstract primitive subprograms
7389 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
7390 are subtype conformant with the following subprogram declarations:
7391
7392 @example
7393 procedure Allocate
7394 (Pool : in out SSP;
7395 Storage_Address : out System.Address;
7396 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7397 Alignment : System.Storage_Elements.Storage_Count);
7398
7399 procedure Deallocate
7400 (Pool : in out SSP;
7401 Storage_Address : System.Address;
7402 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7403 Alignment : System.Storage_Elements.Storage_Count);
7404
7405 function Storage_Size (Pool : SSP)
7406 return System.Storage_Elements.Storage_Count;
7407 @end example
7408
7409 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
7410 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
7411 applying an unchecked deallocation has no effect other than to set its actual
7412 parameter to null. If @code{Storage_Size} is not declared, then the
7413 @code{Storage_Size} attribute applied to an access type associated with
7414 a pool object of type SSP returns zero. Additional operations can be declared
7415 for a simple storage pool type (such as for supporting a mark/release
7416 storage-management discipline).
7417
7418 An object of a simple storage pool type can be associated with an access
7419 type by specifying the attribute
7420 @ref{e5,,Simple_Storage_Pool}. For example:
7421
7422 @example
7423 My_Pool : My_Simple_Storage_Pool_Type;
7424
7425 type Acc is access My_Data_Type;
7426
7427 for Acc'Simple_Storage_Pool use My_Pool;
7428 @end example
7429
7430 See attribute @ref{e5,,Simple_Storage_Pool}
7431 for further details.
7432
7433 @node Pragma Source_File_Name,Pragma Source_File_Name_Project,Pragma Simple_Storage_Pool_Type,Implementation Defined Pragmas
7434 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name}@anchor{e6}@anchor{gnat_rm/implementation_defined_pragmas id40}@anchor{e7}
7435 @section Pragma Source_File_Name
7436
7437
7438 Syntax:
7439
7440 @example
7441 pragma Source_File_Name (
7442 [Unit_Name =>] unit_NAME,
7443 Spec_File_Name => STRING_LITERAL,
7444 [Index => INTEGER_LITERAL]);
7445
7446 pragma Source_File_Name (
7447 [Unit_Name =>] unit_NAME,
7448 Body_File_Name => STRING_LITERAL,
7449 [Index => INTEGER_LITERAL]);
7450 @end example
7451
7452 Use this to override the normal naming convention. It is a configuration
7453 pragma, and so has the usual applicability of configuration pragmas
7454 (i.e., it applies to either an entire partition, or to all units in a
7455 compilation, or to a single unit, depending on how it is used.
7456 @code{unit_name} is mapped to @code{file_name_literal}. The identifier for
7457 the second argument is required, and indicates whether this is the file
7458 name for the spec or for the body.
7459
7460 The optional Index argument should be used when a file contains multiple
7461 units, and when you do not want to use @code{gnatchop} to separate then
7462 into multiple files (which is the recommended procedure to limit the
7463 number of recompilations that are needed when some sources change).
7464 For instance, if the source file @code{source.ada} contains
7465
7466 @example
7467 package B is
7468 ...
7469 end B;
7470
7471 with B;
7472 procedure A is
7473 begin
7474 ..
7475 end A;
7476 @end example
7477
7478 you could use the following configuration pragmas:
7479
7480 @example
7481 pragma Source_File_Name
7482 (B, Spec_File_Name => "source.ada", Index => 1);
7483 pragma Source_File_Name
7484 (A, Body_File_Name => "source.ada", Index => 2);
7485 @end example
7486
7487 Note that the @code{gnatname} utility can also be used to generate those
7488 configuration pragmas.
7489
7490 Another form of the @code{Source_File_Name} pragma allows
7491 the specification of patterns defining alternative file naming schemes
7492 to apply to all files.
7493
7494 @example
7495 pragma Source_File_Name
7496 ( [Spec_File_Name =>] STRING_LITERAL
7497 [,[Casing =>] CASING_SPEC]
7498 [,[Dot_Replacement =>] STRING_LITERAL]);
7499
7500 pragma Source_File_Name
7501 ( [Body_File_Name =>] STRING_LITERAL
7502 [,[Casing =>] CASING_SPEC]
7503 [,[Dot_Replacement =>] STRING_LITERAL]);
7504
7505 pragma Source_File_Name
7506 ( [Subunit_File_Name =>] STRING_LITERAL
7507 [,[Casing =>] CASING_SPEC]
7508 [,[Dot_Replacement =>] STRING_LITERAL]);
7509
7510 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
7511 @end example
7512
7513 The first argument is a pattern that contains a single asterisk indicating
7514 the point at which the unit name is to be inserted in the pattern string
7515 to form the file name. The second argument is optional. If present it
7516 specifies the casing of the unit name in the resulting file name string.
7517 The default is lower case. Finally the third argument allows for systematic
7518 replacement of any dots in the unit name by the specified string literal.
7519
7520 Note that Source_File_Name pragmas should not be used if you are using
7521 project files. The reason for this rule is that the project manager is not
7522 aware of these pragmas, and so other tools that use the projet file would not
7523 be aware of the intended naming conventions. If you are using project files,
7524 file naming is controlled by Source_File_Name_Project pragmas, which are
7525 usually supplied automatically by the project manager. A pragma
7526 Source_File_Name cannot appear after a @ref{e8,,Pragma Source_File_Name_Project}.
7527
7528 For more details on the use of the @code{Source_File_Name} pragma, see the
7529 sections on @cite{Using Other File Names} and @cite{Alternative File Naming Schemes}
7530 in the @cite{GNAT User's Guide}.
7531
7532 @node Pragma Source_File_Name_Project,Pragma Source_Reference,Pragma Source_File_Name,Implementation Defined Pragmas
7533 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name-project}@anchor{e8}@anchor{gnat_rm/implementation_defined_pragmas id41}@anchor{e9}
7534 @section Pragma Source_File_Name_Project
7535
7536
7537 This pragma has the same syntax and semantics as pragma Source_File_Name.
7538 It is only allowed as a stand-alone configuration pragma.
7539 It cannot appear after a @ref{e6,,Pragma Source_File_Name}, and
7540 most importantly, once pragma Source_File_Name_Project appears,
7541 no further Source_File_Name pragmas are allowed.
7542
7543 The intention is that Source_File_Name_Project pragmas are always
7544 generated by the Project Manager in a manner consistent with the naming
7545 specified in a project file, and when naming is controlled in this manner,
7546 it is not permissible to attempt to modify this naming scheme using
7547 Source_File_Name or Source_File_Name_Project pragmas (which would not be
7548 known to the project manager).
7549
7550 @node Pragma Source_Reference,Pragma SPARK_Mode,Pragma Source_File_Name_Project,Implementation Defined Pragmas
7551 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-reference}@anchor{ea}
7552 @section Pragma Source_Reference
7553
7554
7555 Syntax:
7556
7557 @example
7558 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
7559 @end example
7560
7561 This pragma must appear as the first line of a source file.
7562 @code{integer_literal} is the logical line number of the line following
7563 the pragma line (for use in error messages and debugging
7564 information). @code{string_literal} is a static string constant that
7565 specifies the file name to be used in error messages and debugging
7566 information. This is most notably used for the output of @code{gnatchop}
7567 with the @emph{-r} switch, to make sure that the original unchopped
7568 source file is the one referred to.
7569
7570 The second argument must be a string literal, it cannot be a static
7571 string expression other than a string literal. This is because its value
7572 is needed for error messages issued by all phases of the compiler.
7573
7574 @node Pragma SPARK_Mode,Pragma Static_Elaboration_Desired,Pragma Source_Reference,Implementation Defined Pragmas
7575 @anchor{gnat_rm/implementation_defined_pragmas pragma-spark-mode}@anchor{eb}@anchor{gnat_rm/implementation_defined_pragmas id42}@anchor{ec}
7576 @section Pragma SPARK_Mode
7577
7578
7579 Syntax:
7580
7581 @example
7582 pragma SPARK_Mode [(On | Off)] ;
7583 @end example
7584
7585 In general a program can have some parts that are in SPARK 2014 (and
7586 follow all the rules in the SPARK Reference Manual), and some parts
7587 that are full Ada 2012.
7588
7589 The SPARK_Mode pragma is used to identify which parts are in SPARK
7590 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
7591 be used in the following places:
7592
7593
7594 @itemize *
7595
7596 @item
7597 As a configuration pragma, in which case it sets the default mode for
7598 all units compiled with this pragma.
7599
7600 @item
7601 Immediately following a library-level subprogram spec
7602
7603 @item
7604 Immediately within a library-level package body
7605
7606 @item
7607 Immediately following the @code{private} keyword of a library-level
7608 package spec
7609
7610 @item
7611 Immediately following the @code{begin} keyword of a library-level
7612 package body
7613
7614 @item
7615 Immediately within a library-level subprogram body
7616 @end itemize
7617
7618 Normally a subprogram or package spec/body inherits the current mode
7619 that is active at the point it is declared. But this can be overridden
7620 by pragma within the spec or body as above.
7621
7622 The basic consistency rule is that you can't turn SPARK_Mode back
7623 @code{On}, once you have explicitly (with a pragma) turned if
7624 @code{Off}. So the following rules apply:
7625
7626 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
7627 also have SPARK_Mode @code{Off}.
7628
7629 For a package, we have four parts:
7630
7631
7632 @itemize *
7633
7634 @item
7635 the package public declarations
7636
7637 @item
7638 the package private part
7639
7640 @item
7641 the body of the package
7642
7643 @item
7644 the elaboration code after @code{begin}
7645 @end itemize
7646
7647 For a package, the rule is that if you explicitly turn SPARK_Mode
7648 @code{Off} for any part, then all the following parts must have
7649 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
7650 SPARK_Mode (@code{Off}) in the body. For example, if we have a
7651 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
7652 default everywhere, and one particular package spec has pragma
7653 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
7654 the package body.
7655
7656 @node Pragma Static_Elaboration_Desired,Pragma Stream_Convert,Pragma SPARK_Mode,Implementation Defined Pragmas
7657 @anchor{gnat_rm/implementation_defined_pragmas pragma-static-elaboration-desired}@anchor{ed}
7658 @section Pragma Static_Elaboration_Desired
7659
7660
7661 Syntax:
7662
7663 @example
7664 pragma Static_Elaboration_Desired;
7665 @end example
7666
7667 This pragma is used to indicate that the compiler should attempt to initialize
7668 statically the objects declared in the library unit to which the pragma applies,
7669 when these objects are initialized (explicitly or implicitly) by an aggregate.
7670 In the absence of this pragma, aggregates in object declarations are expanded
7671 into assignments and loops, even when the aggregate components are static
7672 constants. When the aggregate is present the compiler builds a static expression
7673 that requires no run-time code, so that the initialized object can be placed in
7674 read-only data space. If the components are not static, or the aggregate has
7675 more that 100 components, the compiler emits a warning that the pragma cannot
7676 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
7677 construction of larger aggregates with static components that include an others
7678 choice.)
7679
7680 @node Pragma Stream_Convert,Pragma Style_Checks,Pragma Static_Elaboration_Desired,Implementation Defined Pragmas
7681 @anchor{gnat_rm/implementation_defined_pragmas pragma-stream-convert}@anchor{ee}
7682 @section Pragma Stream_Convert
7683
7684
7685 Syntax:
7686
7687 @example
7688 pragma Stream_Convert (
7689 [Entity =>] type_LOCAL_NAME,
7690 [Read =>] function_NAME,
7691 [Write =>] function_NAME);
7692 @end example
7693
7694 This pragma provides an efficient way of providing user-defined stream
7695 attributes. Not only is it simpler to use than specifying the attributes
7696 directly, but more importantly, it allows the specification to be made in such
7697 a way that the predefined unit Ada.Streams is not loaded unless it is actually
7698 needed (i.e. unless the stream attributes are actually used); the use of
7699 the Stream_Convert pragma adds no overhead at all, unless the stream
7700 attributes are actually used on the designated type.
7701
7702 The first argument specifies the type for which stream functions are
7703 provided. The second parameter provides a function used to read values
7704 of this type. It must name a function whose argument type may be any
7705 subtype, and whose returned type must be the type given as the first
7706 argument to the pragma.
7707
7708 The meaning of the @code{Read} parameter is that if a stream attribute directly
7709 or indirectly specifies reading of the type given as the first parameter,
7710 then a value of the type given as the argument to the Read function is
7711 read from the stream, and then the Read function is used to convert this
7712 to the required target type.
7713
7714 Similarly the @code{Write} parameter specifies how to treat write attributes
7715 that directly or indirectly apply to the type given as the first parameter.
7716 It must have an input parameter of the type specified by the first parameter,
7717 and the return type must be the same as the input type of the Read function.
7718 The effect is to first call the Write function to convert to the given stream
7719 type, and then write the result type to the stream.
7720
7721 The Read and Write functions must not be overloaded subprograms. If necessary
7722 renamings can be supplied to meet this requirement.
7723 The usage of this attribute is best illustrated by a simple example, taken
7724 from the GNAT implementation of package Ada.Strings.Unbounded:
7725
7726 @example
7727 function To_Unbounded (S : String) return Unbounded_String
7728 renames To_Unbounded_String;
7729
7730 pragma Stream_Convert
7731 (Unbounded_String, To_Unbounded, To_String);
7732 @end example
7733
7734 The specifications of the referenced functions, as given in the Ada
7735 Reference Manual are:
7736
7737 @example
7738 function To_Unbounded_String (Source : String)
7739 return Unbounded_String;
7740
7741 function To_String (Source : Unbounded_String)
7742 return String;
7743 @end example
7744
7745 The effect is that if the value of an unbounded string is written to a stream,
7746 then the representation of the item in the stream is in the same format that
7747 would be used for @code{Standard.String'Output}, and this same representation
7748 is expected when a value of this type is read from the stream. Note that the
7749 value written always includes the bounds, even for Unbounded_String'Write,
7750 since Unbounded_String is not an array type.
7751
7752 Note that the @code{Stream_Convert} pragma is not effective in the case of
7753 a derived type of a non-limited tagged type. If such a type is specified then
7754 the pragma is silently ignored, and the default implementation of the stream
7755 attributes is used instead.
7756
7757 @node Pragma Style_Checks,Pragma Subtitle,Pragma Stream_Convert,Implementation Defined Pragmas
7758 @anchor{gnat_rm/implementation_defined_pragmas pragma-style-checks}@anchor{ef}
7759 @section Pragma Style_Checks
7760
7761
7762 Syntax:
7763
7764 @example
7765 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
7766 On | Off [, LOCAL_NAME]);
7767 @end example
7768
7769 This pragma is used in conjunction with compiler switches to control the
7770 built in style checking provided by GNAT. The compiler switches, if set,
7771 provide an initial setting for the switches, and this pragma may be used
7772 to modify these settings, or the settings may be provided entirely by
7773 the use of the pragma. This pragma can be used anywhere that a pragma
7774 is legal, including use as a configuration pragma (including use in
7775 the @code{gnat.adc} file).
7776
7777 The form with a string literal specifies which style options are to be
7778 activated. These are additive, so they apply in addition to any previously
7779 set style check options. The codes for the options are the same as those
7780 used in the @emph{-gnaty} switch to @emph{gcc} or @emph{gnatmake}.
7781 For example the following two methods can be used to enable
7782 layout checking:
7783
7784
7785 @itemize *
7786
7787 @item
7788 @example
7789 pragma Style_Checks ("l");
7790 @end example
7791
7792 @item
7793 @example
7794 gcc -c -gnatyl ...
7795 @end example
7796 @end itemize
7797
7798 The form @code{ALL_CHECKS} activates all standard checks (its use is equivalent
7799 to the use of the @code{gnaty} switch with no options.
7800 See the @cite{GNAT User's Guide} for details.)
7801
7802 Note: the behavior is slightly different in GNAT mode (@code{-gnatg} used).
7803 In this case, @code{ALL_CHECKS} implies the standard set of GNAT mode style check
7804 options (i.e. equivalent to @code{-gnatyg}).
7805
7806 The forms with @code{Off} and @code{On}
7807 can be used to temporarily disable style checks
7808 as shown in the following example:
7809
7810 @example
7811 pragma Style_Checks ("k"); -- requires keywords in lower case
7812 pragma Style_Checks (Off); -- turn off style checks
7813 NULL; -- this will not generate an error message
7814 pragma Style_Checks (On); -- turn style checks back on
7815 NULL; -- this will generate an error message
7816 @end example
7817
7818 Finally the two argument form is allowed only if the first argument is
7819 @code{On} or @code{Off}. The effect is to turn of semantic style checks
7820 for the specified entity, as shown in the following example:
7821
7822 @example
7823 pragma Style_Checks ("r"); -- require consistency of identifier casing
7824 Arg : Integer;
7825 Rf1 : Integer := ARG; -- incorrect, wrong case
7826 pragma Style_Checks (Off, Arg);
7827 Rf2 : Integer := ARG; -- OK, no error
7828 @end example
7829
7830 @node Pragma Subtitle,Pragma Suppress,Pragma Style_Checks,Implementation Defined Pragmas
7831 @anchor{gnat_rm/implementation_defined_pragmas pragma-subtitle}@anchor{f0}
7832 @section Pragma Subtitle
7833
7834
7835 Syntax:
7836
7837 @example
7838 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
7839 @end example
7840
7841 This pragma is recognized for compatibility with other Ada compilers
7842 but is ignored by GNAT.
7843
7844 @node Pragma Suppress,Pragma Suppress_All,Pragma Subtitle,Implementation Defined Pragmas
7845 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress}@anchor{f1}
7846 @section Pragma Suppress
7847
7848
7849 Syntax:
7850
7851 @example
7852 pragma Suppress (Identifier [, [On =>] Name]);
7853 @end example
7854
7855 This is a standard pragma, and supports all the check names required in
7856 the RM. It is included here because GNAT recognizes some additional check
7857 names that are implementation defined (as permitted by the RM):
7858
7859
7860 @itemize *
7861
7862 @item
7863 @code{Alignment_Check} can be used to suppress alignment checks
7864 on addresses used in address clauses. Such checks can also be suppressed
7865 by suppressing range checks, but the specific use of @code{Alignment_Check}
7866 allows suppression of alignment checks without suppressing other range checks.
7867 Note that @code{Alignment_Check} is suppressed by default on machines (such as
7868 the x86) with non-strict alignment.
7869
7870 @item
7871 @code{Atomic_Synchronization} can be used to suppress the special memory
7872 synchronization instructions that are normally generated for access to
7873 @code{Atomic} variables to ensure correct synchronization between tasks
7874 that use such variables for synchronization purposes.
7875
7876 @item
7877 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
7878 for a duplicated tag value when a tagged type is declared.
7879
7880 @item
7881 @code{Container_Checks} Can be used to suppress all checks within Ada.Containers
7882 and instances of its children, including Tampering_Check.
7883
7884 @item
7885 @code{Tampering_Check} Can be used to suppress tampering check in the containers.
7886
7887 @item
7888 @code{Predicate_Check} can be used to control whether predicate checks are
7889 active. It is applicable only to predicates for which the policy is
7890 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
7891 predicate is ignored or checked for the whole program, the use of
7892 @code{Suppress} and @code{Unsuppress} with this check name allows a given
7893 predicate to be turned on and off at specific points in the program.
7894
7895 @item
7896 @code{Validity_Check} can be used specifically to control validity checks.
7897 If @code{Suppress} is used to suppress validity checks, then no validity
7898 checks are performed, including those specified by the appropriate compiler
7899 switch or the @code{Validity_Checks} pragma.
7900
7901 @item
7902 Additional check names previously introduced by use of the @code{Check_Name}
7903 pragma are also allowed.
7904 @end itemize
7905
7906 Note that pragma Suppress gives the compiler permission to omit
7907 checks, but does not require the compiler to omit checks. The compiler
7908 will generate checks if they are essentially free, even when they are
7909 suppressed. In particular, if the compiler can prove that a certain
7910 check will necessarily fail, it will generate code to do an
7911 unconditional 'raise', even if checks are suppressed. The compiler
7912 warns in this case.
7913
7914 Of course, run-time checks are omitted whenever the compiler can prove
7915 that they will not fail, whether or not checks are suppressed.
7916
7917 @node Pragma Suppress_All,Pragma Suppress_Debug_Info,Pragma Suppress,Implementation Defined Pragmas
7918 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-all}@anchor{f2}
7919 @section Pragma Suppress_All
7920
7921
7922 Syntax:
7923
7924 @example
7925 pragma Suppress_All;
7926 @end example
7927
7928 This pragma can appear anywhere within a unit.
7929 The effect is to apply @code{Suppress (All_Checks)} to the unit
7930 in which it appears. This pragma is implemented for compatibility with DEC
7931 Ada 83 usage where it appears at the end of a unit, and for compatibility
7932 with Rational Ada, where it appears as a program unit pragma.
7933 The use of the standard Ada pragma @code{Suppress (All_Checks)}
7934 as a normal configuration pragma is the preferred usage in GNAT.
7935
7936 @node Pragma Suppress_Debug_Info,Pragma Suppress_Exception_Locations,Pragma Suppress_All,Implementation Defined Pragmas
7937 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-debug-info}@anchor{f3}@anchor{gnat_rm/implementation_defined_pragmas id43}@anchor{f4}
7938 @section Pragma Suppress_Debug_Info
7939
7940
7941 Syntax:
7942
7943 @example
7944 pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
7945 @end example
7946
7947 This pragma can be used to suppress generation of debug information
7948 for the specified entity. It is intended primarily for use in debugging
7949 the debugger, and navigating around debugger problems.
7950
7951 @node Pragma Suppress_Exception_Locations,Pragma Suppress_Initialization,Pragma Suppress_Debug_Info,Implementation Defined Pragmas
7952 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-exception-locations}@anchor{f5}
7953 @section Pragma Suppress_Exception_Locations
7954
7955
7956 Syntax:
7957
7958 @example
7959 pragma Suppress_Exception_Locations;
7960 @end example
7961
7962 In normal mode, a raise statement for an exception by default generates
7963 an exception message giving the file name and line number for the location
7964 of the raise. This is useful for debugging and logging purposes, but this
7965 entails extra space for the strings for the messages. The configuration
7966 pragma @code{Suppress_Exception_Locations} can be used to suppress the
7967 generation of these strings, with the result that space is saved, but the
7968 exception message for such raises is null. This configuration pragma may
7969 appear in a global configuration pragma file, or in a specific unit as
7970 usual. It is not required that this pragma be used consistently within
7971 a partition, so it is fine to have some units within a partition compiled
7972 with this pragma and others compiled in normal mode without it.
7973
7974 @node Pragma Suppress_Initialization,Pragma Task_Name,Pragma Suppress_Exception_Locations,Implementation Defined Pragmas
7975 @anchor{gnat_rm/implementation_defined_pragmas id44}@anchor{f6}@anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-initialization}@anchor{f7}
7976 @section Pragma Suppress_Initialization
7977
7978
7979 @geindex Suppressing initialization
7980
7981 @geindex Initialization
7982 @geindex suppression of
7983
7984 Syntax:
7985
7986 @example
7987 pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
7988 @end example
7989
7990 Here variable_or_subtype_Name is the name introduced by a type declaration
7991 or subtype declaration or the name of a variable introduced by an
7992 object declaration.
7993
7994 In the case of a type or subtype
7995 this pragma suppresses any implicit or explicit initialization
7996 for all variables of the given type or subtype,
7997 including initialization resulting from the use of pragmas
7998 Normalize_Scalars or Initialize_Scalars.
7999
8000 This is considered a representation item, so it cannot be given after
8001 the type is frozen. It applies to all subsequent object declarations,
8002 and also any allocator that creates objects of the type.
8003
8004 If the pragma is given for the first subtype, then it is considered
8005 to apply to the base type and all its subtypes. If the pragma is given
8006 for other than a first subtype, then it applies only to the given subtype.
8007 The pragma may not be given after the type is frozen.
8008
8009 Note that this includes eliminating initialization of discriminants
8010 for discriminated types, and tags for tagged types. In these cases,
8011 you will have to use some non-portable mechanism (e.g. address
8012 overlays or unchecked conversion) to achieve required initialization
8013 of these fields before accessing any object of the corresponding type.
8014
8015 For the variable case, implicit initialization for the named variable
8016 is suppressed, just as though its subtype had been given in a pragma
8017 Suppress_Initialization, as described above.
8018
8019 @node Pragma Task_Name,Pragma Task_Storage,Pragma Suppress_Initialization,Implementation Defined Pragmas
8020 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-name}@anchor{f8}
8021 @section Pragma Task_Name
8022
8023
8024 Syntax
8025
8026 @example
8027 pragma Task_Name (string_EXPRESSION);
8028 @end example
8029
8030 This pragma appears within a task definition (like pragma
8031 @code{Priority}) and applies to the task in which it appears. The
8032 argument must be of type String, and provides a name to be used for
8033 the task instance when the task is created. Note that this expression
8034 is not required to be static, and in particular, it can contain
8035 references to task discriminants. This facility can be used to
8036 provide different names for different tasks as they are created,
8037 as illustrated in the example below.
8038
8039 The task name is recorded internally in the run-time structures
8040 and is accessible to tools like the debugger. In addition the
8041 routine @code{Ada.Task_Identification.Image} will return this
8042 string, with a unique task address appended.
8043
8044 @example
8045 -- Example of the use of pragma Task_Name
8046
8047 with Ada.Task_Identification;
8048 use Ada.Task_Identification;
8049 with Text_IO; use Text_IO;
8050 procedure t3 is
8051
8052 type Astring is access String;
8053
8054 task type Task_Typ (Name : access String) is
8055 pragma Task_Name (Name.all);
8056 end Task_Typ;
8057
8058 task body Task_Typ is
8059 Nam : constant String := Image (Current_Task);
8060 begin
8061 Put_Line ("-->" & Nam (1 .. 14) & "<--");
8062 end Task_Typ;
8063
8064 type Ptr_Task is access Task_Typ;
8065 Task_Var : Ptr_Task;
8066
8067 begin
8068 Task_Var :=
8069 new Task_Typ (new String'("This is task 1"));
8070 Task_Var :=
8071 new Task_Typ (new String'("This is task 2"));
8072 end;
8073 @end example
8074
8075 @node Pragma Task_Storage,Pragma Test_Case,Pragma Task_Name,Implementation Defined Pragmas
8076 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-storage}@anchor{f9}
8077 @section Pragma Task_Storage
8078
8079
8080 Syntax:
8081
8082 @example
8083 pragma Task_Storage (
8084 [Task_Type =>] LOCAL_NAME,
8085 [Top_Guard =>] static_integer_EXPRESSION);
8086 @end example
8087
8088 This pragma specifies the length of the guard area for tasks. The guard
8089 area is an additional storage area allocated to a task. A value of zero
8090 means that either no guard area is created or a minimal guard area is
8091 created, depending on the target. This pragma can appear anywhere a
8092 @code{Storage_Size} attribute definition clause is allowed for a task
8093 type.
8094
8095 @node Pragma Test_Case,Pragma Thread_Local_Storage,Pragma Task_Storage,Implementation Defined Pragmas
8096 @anchor{gnat_rm/implementation_defined_pragmas pragma-test-case}@anchor{fa}@anchor{gnat_rm/implementation_defined_pragmas id45}@anchor{fb}
8097 @section Pragma Test_Case
8098
8099
8100 @geindex Test cases
8101
8102 Syntax:
8103
8104 @example
8105 pragma Test_Case (
8106 [Name =>] static_string_Expression
8107 ,[Mode =>] (Nominal | Robustness)
8108 [, Requires => Boolean_Expression]
8109 [, Ensures => Boolean_Expression]);
8110 @end example
8111
8112 The @code{Test_Case} pragma allows defining fine-grain specifications
8113 for use by testing tools.
8114 The compiler checks the validity of the @code{Test_Case} pragma, but its
8115 presence does not lead to any modification of the code generated by the
8116 compiler.
8117
8118 @code{Test_Case} pragmas may only appear immediately following the
8119 (separate) declaration of a subprogram in a package declaration, inside
8120 a package spec unit. Only other pragmas may intervene (that is appear
8121 between the subprogram declaration and a test case).
8122
8123 The compiler checks that boolean expressions given in @code{Requires} and
8124 @code{Ensures} are valid, where the rules for @code{Requires} are the
8125 same as the rule for an expression in @code{Precondition} and the rules
8126 for @code{Ensures} are the same as the rule for an expression in
8127 @code{Postcondition}. In particular, attributes @code{'Old} and
8128 @code{'Result} can only be used within the @code{Ensures}
8129 expression. The following is an example of use within a package spec:
8130
8131 @example
8132 package Math_Functions is
8133 ...
8134 function Sqrt (Arg : Float) return Float;
8135 pragma Test_Case (Name => "Test 1",
8136 Mode => Nominal,
8137 Requires => Arg < 10000,
8138 Ensures => Sqrt'Result < 10);
8139 ...
8140 end Math_Functions;
8141 @end example
8142
8143 The meaning of a test case is that there is at least one context where
8144 @code{Requires} holds such that, if the associated subprogram is executed in
8145 that context, then @code{Ensures} holds when the subprogram returns.
8146 Mode @code{Nominal} indicates that the input context should also satisfy the
8147 precondition of the subprogram, and the output context should also satisfy its
8148 postcondition. Mode @code{Robustness} indicates that the precondition and
8149 postcondition of the subprogram should be ignored for this test case.
8150
8151 @node Pragma Thread_Local_Storage,Pragma Time_Slice,Pragma Test_Case,Implementation Defined Pragmas
8152 @anchor{gnat_rm/implementation_defined_pragmas pragma-thread-local-storage}@anchor{fc}@anchor{gnat_rm/implementation_defined_pragmas id46}@anchor{fd}
8153 @section Pragma Thread_Local_Storage
8154
8155
8156 @geindex Task specific storage
8157
8158 @geindex TLS (Thread Local Storage)
8159
8160 @geindex Task_Attributes
8161
8162 Syntax:
8163
8164 @example
8165 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
8166 @end example
8167
8168 This pragma specifies that the specified entity, which must be
8169 a variable declared in a library-level package, is to be marked as
8170 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
8171 include Windows, Solaris, GNU/Linux, and VxWorks 6), this causes each
8172 thread (and hence each Ada task) to see a distinct copy of the variable.
8173
8174 The variable must not have default initialization, and if there is
8175 an explicit initialization, it must be either @code{null} for an
8176 access variable, a static expression for a scalar variable, or a fully
8177 static aggregate for a composite type, that is to say, an aggregate all
8178 of whose components are static, and which does not include packed or
8179 discriminated components.
8180
8181 This provides a low-level mechanism similar to that provided by
8182 the @code{Ada.Task_Attributes} package, but much more efficient
8183 and is also useful in writing interface code that will interact
8184 with foreign threads.
8185
8186 If this pragma is used on a system where @code{TLS} is not supported,
8187 then an error message will be generated and the program will be rejected.
8188
8189 @node Pragma Time_Slice,Pragma Title,Pragma Thread_Local_Storage,Implementation Defined Pragmas
8190 @anchor{gnat_rm/implementation_defined_pragmas pragma-time-slice}@anchor{fe}
8191 @section Pragma Time_Slice
8192
8193
8194 Syntax:
8195
8196 @example
8197 pragma Time_Slice (static_duration_EXPRESSION);
8198 @end example
8199
8200 For implementations of GNAT on operating systems where it is possible
8201 to supply a time slice value, this pragma may be used for this purpose.
8202 It is ignored if it is used in a system that does not allow this control,
8203 or if it appears in other than the main program unit.
8204
8205 @node Pragma Title,Pragma Type_Invariant,Pragma Time_Slice,Implementation Defined Pragmas
8206 @anchor{gnat_rm/implementation_defined_pragmas pragma-title}@anchor{ff}
8207 @section Pragma Title
8208
8209
8210 Syntax:
8211
8212 @example
8213 pragma Title (TITLING_OPTION [, TITLING OPTION]);
8214
8215 TITLING_OPTION ::=
8216 [Title =>] STRING_LITERAL,
8217 | [Subtitle =>] STRING_LITERAL
8218 @end example
8219
8220 Syntax checked but otherwise ignored by GNAT. This is a listing control
8221 pragma used in DEC Ada 83 implementations to provide a title and/or
8222 subtitle for the program listing. The program listing generated by GNAT
8223 does not have titles or subtitles.
8224
8225 Unlike other pragmas, the full flexibility of named notation is allowed
8226 for this pragma, i.e., the parameters may be given in any order if named
8227 notation is used, and named and positional notation can be mixed
8228 following the normal rules for procedure calls in Ada.
8229
8230 @node Pragma Type_Invariant,Pragma Type_Invariant_Class,Pragma Title,Implementation Defined Pragmas
8231 @anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant}@anchor{100}
8232 @section Pragma Type_Invariant
8233
8234
8235 Syntax:
8236
8237 @example
8238 pragma Type_Invariant
8239 ([Entity =>] type_LOCAL_NAME,
8240 [Check =>] EXPRESSION);
8241 @end example
8242
8243 The @code{Type_Invariant} pragma is intended to be an exact
8244 replacement for the language-defined @code{Type_Invariant}
8245 aspect, and shares its restrictions and semantics. It differs
8246 from the language defined @code{Invariant} pragma in that it
8247 does not permit a string parameter, and it is
8248 controlled by the assertion identifier @code{Type_Invariant}
8249 rather than @code{Invariant}.
8250
8251 @node Pragma Type_Invariant_Class,Pragma Unchecked_Union,Pragma Type_Invariant,Implementation Defined Pragmas
8252 @anchor{gnat_rm/implementation_defined_pragmas id47}@anchor{101}@anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant-class}@anchor{102}
8253 @section Pragma Type_Invariant_Class
8254
8255
8256 Syntax:
8257
8258 @example
8259 pragma Type_Invariant_Class
8260 ([Entity =>] type_LOCAL_NAME,
8261 [Check =>] EXPRESSION);
8262 @end example
8263
8264 The @code{Type_Invariant_Class} pragma is intended to be an exact
8265 replacement for the language-defined @code{Type_Invariant'Class}
8266 aspect, and shares its restrictions and semantics.
8267
8268 Note: This pragma is called @code{Type_Invariant_Class} rather than
8269 @code{Type_Invariant'Class} because the latter would not be strictly
8270 conforming to the allowed syntax for pragmas. The motivation
8271 for providing pragmas equivalent to the aspects is to allow a program
8272 to be written using the pragmas, and then compiled if necessary
8273 using an Ada compiler that does not recognize the pragmas or
8274 aspects, but is prepared to ignore the pragmas. The assertion
8275 policy that controls this pragma is @code{Type_Invariant'Class},
8276 not @code{Type_Invariant_Class}.
8277
8278 @node Pragma Unchecked_Union,Pragma Unevaluated_Use_Of_Old,Pragma Type_Invariant_Class,Implementation Defined Pragmas
8279 @anchor{gnat_rm/implementation_defined_pragmas pragma-unchecked-union}@anchor{103}
8280 @section Pragma Unchecked_Union
8281
8282
8283 @geindex Unions in C
8284
8285 Syntax:
8286
8287 @example
8288 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
8289 @end example
8290
8291 This pragma is used to specify a representation of a record type that is
8292 equivalent to a C union. It was introduced as a GNAT implementation defined
8293 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
8294 pragma, making it language defined, and GNAT fully implements this extended
8295 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
8296 details, consult the Ada 2012 Reference Manual, section B.3.3.
8297
8298 @node Pragma Unevaluated_Use_Of_Old,Pragma Unimplemented_Unit,Pragma Unchecked_Union,Implementation Defined Pragmas
8299 @anchor{gnat_rm/implementation_defined_pragmas pragma-unevaluated-use-of-old}@anchor{104}
8300 @section Pragma Unevaluated_Use_Of_Old
8301
8302
8303 @geindex Attribute Old
8304
8305 @geindex Attribute Loop_Entry
8306
8307 @geindex Unevaluated_Use_Of_Old
8308
8309 Syntax:
8310
8311 @example
8312 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
8313 @end example
8314
8315 This pragma controls the processing of attributes Old and Loop_Entry.
8316 If either of these attributes is used in a potentially unevaluated
8317 expression (e.g. the then or else parts of an if expression), then
8318 normally this usage is considered illegal if the prefix of the attribute
8319 is other than an entity name. The language requires this
8320 behavior for Old, and GNAT copies the same rule for Loop_Entry.
8321
8322 The reason for this rule is that otherwise, we can have a situation
8323 where we save the Old value, and this results in an exception, even
8324 though we might not evaluate the attribute. Consider this example:
8325
8326 @example
8327 package UnevalOld is
8328 K : Character;
8329 procedure U (A : String; C : Boolean) -- ERROR
8330 with Post => (if C then A(1)'Old = K else True);
8331 end;
8332 @end example
8333
8334 If procedure U is called with a string with a lower bound of 2, and
8335 C false, then an exception would be raised trying to evaluate A(1)
8336 on entry even though the value would not be actually used.
8337
8338 Although the rule guarantees against this possibility, it is sometimes
8339 too restrictive. For example if we know that the string has a lower
8340 bound of 1, then we will never raise an exception.
8341 The pragma @code{Unevaluated_Use_Of_Old} can be
8342 used to modify this behavior. If the argument is @code{Error} then an
8343 error is given (this is the default RM behavior). If the argument is
8344 @code{Warn} then the usage is allowed as legal but with a warning
8345 that an exception might be raised. If the argument is @code{Allow}
8346 then the usage is allowed as legal without generating a warning.
8347
8348 This pragma may appear as a configuration pragma, or in a declarative
8349 part or package specification. In the latter case it applies to
8350 uses up to the end of the corresponding statement sequence or
8351 sequence of package declarations.
8352
8353 @node Pragma Unimplemented_Unit,Pragma Universal_Aliasing,Pragma Unevaluated_Use_Of_Old,Implementation Defined Pragmas
8354 @anchor{gnat_rm/implementation_defined_pragmas pragma-unimplemented-unit}@anchor{105}
8355 @section Pragma Unimplemented_Unit
8356
8357
8358 Syntax:
8359
8360 @example
8361 pragma Unimplemented_Unit;
8362 @end example
8363
8364 If this pragma occurs in a unit that is processed by the compiler, GNAT
8365 aborts with the message @code{xxx not implemented}, where
8366 @code{xxx} is the name of the current compilation unit. This pragma is
8367 intended to allow the compiler to handle unimplemented library units in
8368 a clean manner.
8369
8370 The abort only happens if code is being generated. Thus you can use
8371 specs of unimplemented packages in syntax or semantic checking mode.
8372
8373 @node Pragma Universal_Aliasing,Pragma Universal_Data,Pragma Unimplemented_Unit,Implementation Defined Pragmas
8374 @anchor{gnat_rm/implementation_defined_pragmas pragma-universal-aliasing}@anchor{106}@anchor{gnat_rm/implementation_defined_pragmas id48}@anchor{107}
8375 @section Pragma Universal_Aliasing
8376
8377
8378 Syntax:
8379
8380 @example
8381 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
8382 @end example
8383
8384 @code{type_LOCAL_NAME} must refer to a type declaration in the current
8385 declarative part. The effect is to inhibit strict type-based aliasing
8386 optimization for the given type. In other words, the effect is as though
8387 access types designating this type were subject to pragma No_Strict_Aliasing.
8388 For a detailed description of the strict aliasing optimization, and the
8389 situations in which it must be suppressed, see the section on
8390 @code{Optimization and Strict Aliasing} in the @cite{GNAT User's Guide}.
8391
8392 @node Pragma Universal_Data,Pragma Unmodified,Pragma Universal_Aliasing,Implementation Defined Pragmas
8393 @anchor{gnat_rm/implementation_defined_pragmas pragma-universal-data}@anchor{108}@anchor{gnat_rm/implementation_defined_pragmas id49}@anchor{109}
8394 @section Pragma Universal_Data
8395
8396
8397 Syntax:
8398
8399 @example
8400 pragma Universal_Data [(library_unit_Name)];
8401 @end example
8402
8403 This pragma is supported only for the AAMP target and is ignored for
8404 other targets. The pragma specifies that all library-level objects
8405 (Counter 0 data) associated with the library unit are to be accessed
8406 and updated using universal addressing (24-bit addresses for AAMP5)
8407 rather than the default of 16-bit Data Environment (DENV) addressing.
8408 Use of this pragma will generally result in less efficient code for
8409 references to global data associated with the library unit, but
8410 allows such data to be located anywhere in memory. This pragma is
8411 a library unit pragma, but can also be used as a configuration pragma
8412 (including use in the @code{gnat.adc} file). The functionality
8413 of this pragma is also available by applying the -univ switch on the
8414 compilations of units where universal addressing of the data is desired.
8415
8416 @node Pragma Unmodified,Pragma Unreferenced,Pragma Universal_Data,Implementation Defined Pragmas
8417 @anchor{gnat_rm/implementation_defined_pragmas id50}@anchor{10a}@anchor{gnat_rm/implementation_defined_pragmas pragma-unmodified}@anchor{10b}
8418 @section Pragma Unmodified
8419
8420
8421 @geindex Warnings
8422 @geindex unmodified
8423
8424 Syntax:
8425
8426 @example
8427 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
8428 @end example
8429
8430 This pragma signals that the assignable entities (variables,
8431 @code{out} parameters, @code{in out} parameters) whose names are listed are
8432 deliberately not assigned in the current source unit. This
8433 suppresses warnings about the
8434 entities being referenced but not assigned, and in addition a warning will be
8435 generated if one of these entities is in fact assigned in the
8436 same unit as the pragma (or in the corresponding body, or one
8437 of its subunits).
8438
8439 This is particularly useful for clearly signaling that a particular
8440 parameter is not modified, even though the spec suggests that it might
8441 be.
8442
8443 For the variable case, warnings are never given for unreferenced variables
8444 whose name contains one of the substrings
8445 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8446 are typically to be used in cases where such warnings are expected.
8447 Thus it is never necessary to use @code{pragma Unmodified} for such
8448 variables, though it is harmless to do so.
8449
8450 @node Pragma Unreferenced,Pragma Unreferenced_Objects,Pragma Unmodified,Implementation Defined Pragmas
8451 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced}@anchor{10c}@anchor{gnat_rm/implementation_defined_pragmas id51}@anchor{10d}
8452 @section Pragma Unreferenced
8453
8454
8455 @geindex Warnings
8456 @geindex unreferenced
8457
8458 Syntax:
8459
8460 @example
8461 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
8462 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
8463 @end example
8464
8465 This pragma signals that the entities whose names are listed are
8466 deliberately not referenced in the current source unit after the
8467 occurrence of the pragma. This
8468 suppresses warnings about the
8469 entities being unreferenced, and in addition a warning will be
8470 generated if one of these entities is in fact subsequently referenced in the
8471 same unit as the pragma (or in the corresponding body, or one
8472 of its subunits).
8473
8474 This is particularly useful for clearly signaling that a particular
8475 parameter is not referenced in some particular subprogram implementation
8476 and that this is deliberate. It can also be useful in the case of
8477 objects declared only for their initialization or finalization side
8478 effects.
8479
8480 If @code{LOCAL_NAME} identifies more than one matching homonym in the
8481 current scope, then the entity most recently declared is the one to which
8482 the pragma applies. Note that in the case of accept formals, the pragma
8483 Unreferenced may appear immediately after the keyword @code{do} which
8484 allows the indication of whether or not accept formals are referenced
8485 or not to be given individually for each accept statement.
8486
8487 The left hand side of an assignment does not count as a reference for the
8488 purpose of this pragma. Thus it is fine to assign to an entity for which
8489 pragma Unreferenced is given.
8490
8491 Note that if a warning is desired for all calls to a given subprogram,
8492 regardless of whether they occur in the same unit as the subprogram
8493 declaration, then this pragma should not be used (calls from another
8494 unit would not be flagged); pragma Obsolescent can be used instead
8495 for this purpose, see @ref{ac,,Pragma Obsolescent}.
8496
8497 The second form of pragma @code{Unreferenced} is used within a context
8498 clause. In this case the arguments must be unit names of units previously
8499 mentioned in @code{with} clauses (similar to the usage of pragma
8500 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
8501 units and unreferenced entities within these units.
8502
8503 For the variable case, warnings are never given for unreferenced variables
8504 whose name contains one of the substrings
8505 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8506 are typically to be used in cases where such warnings are expected.
8507 Thus it is never necessary to use @code{pragma Unreferenced} for such
8508 variables, though it is harmless to do so.
8509
8510 @node Pragma Unreferenced_Objects,Pragma Unreserve_All_Interrupts,Pragma Unreferenced,Implementation Defined Pragmas
8511 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced-objects}@anchor{10e}@anchor{gnat_rm/implementation_defined_pragmas id52}@anchor{10f}
8512 @section Pragma Unreferenced_Objects
8513
8514
8515 @geindex Warnings
8516 @geindex unreferenced
8517
8518 Syntax:
8519
8520 @example
8521 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
8522 @end example
8523
8524 This pragma signals that for the types or subtypes whose names are
8525 listed, objects which are declared with one of these types or subtypes may
8526 not be referenced, and if no references appear, no warnings are given.
8527
8528 This is particularly useful for objects which are declared solely for their
8529 initialization and finalization effect. Such variables are sometimes referred
8530 to as RAII variables (Resource Acquisition Is Initialization). Using this
8531 pragma on the relevant type (most typically a limited controlled type), the
8532 compiler will automatically suppress unwanted warnings about these variables
8533 not being referenced.
8534
8535 @node Pragma Unreserve_All_Interrupts,Pragma Unsuppress,Pragma Unreferenced_Objects,Implementation Defined Pragmas
8536 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreserve-all-interrupts}@anchor{110}
8537 @section Pragma Unreserve_All_Interrupts
8538
8539
8540 Syntax:
8541
8542 @example
8543 pragma Unreserve_All_Interrupts;
8544 @end example
8545
8546 Normally certain interrupts are reserved to the implementation. Any attempt
8547 to attach an interrupt causes Program_Error to be raised, as described in
8548 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
8549 many systems for a @code{Ctrl-C} interrupt. Normally this interrupt is
8550 reserved to the implementation, so that @code{Ctrl-C} can be used to
8551 interrupt execution.
8552
8553 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
8554 a program, then all such interrupts are unreserved. This allows the
8555 program to handle these interrupts, but disables their standard
8556 functions. For example, if this pragma is used, then pressing
8557 @code{Ctrl-C} will not automatically interrupt execution. However,
8558 a program can then handle the @code{SIGINT} interrupt as it chooses.
8559
8560 For a full list of the interrupts handled in a specific implementation,
8561 see the source code for the spec of @code{Ada.Interrupts.Names} in
8562 file @code{a-intnam.ads}. This is a target dependent file that contains the
8563 list of interrupts recognized for a given target. The documentation in
8564 this file also specifies what interrupts are affected by the use of
8565 the @code{Unreserve_All_Interrupts} pragma.
8566
8567 For a more general facility for controlling what interrupts can be
8568 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
8569 of the @code{Unreserve_All_Interrupts} pragma.
8570
8571 @node Pragma Unsuppress,Pragma Use_VADS_Size,Pragma Unreserve_All_Interrupts,Implementation Defined Pragmas
8572 @anchor{gnat_rm/implementation_defined_pragmas pragma-unsuppress}@anchor{111}
8573 @section Pragma Unsuppress
8574
8575
8576 Syntax:
8577
8578 @example
8579 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
8580 @end example
8581
8582 This pragma undoes the effect of a previous pragma @code{Suppress}. If
8583 there is no corresponding pragma @code{Suppress} in effect, it has no
8584 effect. The range of the effect is the same as for pragma
8585 @code{Suppress}. The meaning of the arguments is identical to that used
8586 in pragma @code{Suppress}.
8587
8588 One important application is to ensure that checks are on in cases where
8589 code depends on the checks for its correct functioning, so that the code
8590 will compile correctly even if the compiler switches are set to suppress
8591 checks. For example, in a program that depends on external names of tagged
8592 types and wants to ensure that the duplicated tag check occurs even if all
8593 run-time checks are suppressed by a compiler switch, the following
8594 configuration pragma will ensure this test is not suppressed:
8595
8596 @example
8597 pragma Unsuppress (Duplicated_Tag_Check);
8598 @end example
8599
8600 This pragma is standard in Ada 2005. It is available in all earlier versions
8601 of Ada as an implementation-defined pragma.
8602
8603 Note that in addition to the checks defined in the Ada RM, GNAT recogizes a
8604 number of implementation-defined check names. See the description of pragma
8605 @code{Suppress} for full details.
8606
8607 @node Pragma Use_VADS_Size,Pragma Unused,Pragma Unsuppress,Implementation Defined Pragmas
8608 @anchor{gnat_rm/implementation_defined_pragmas pragma-use-vads-size}@anchor{112}
8609 @section Pragma Use_VADS_Size
8610
8611
8612 @geindex Size
8613 @geindex VADS compatibility
8614
8615 @geindex Rational profile
8616
8617 Syntax:
8618
8619 @example
8620 pragma Use_VADS_Size;
8621 @end example
8622
8623 This is a configuration pragma. In a unit to which it applies, any use
8624 of the 'Size attribute is automatically interpreted as a use of the
8625 'VADS_Size attribute. Note that this may result in incorrect semantic
8626 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
8627 the handling of existing code which depends on the interpretation of Size
8628 as implemented in the VADS compiler. See description of the VADS_Size
8629 attribute for further details.
8630
8631 @node Pragma Unused,Pragma Validity_Checks,Pragma Use_VADS_Size,Implementation Defined Pragmas
8632 @anchor{gnat_rm/implementation_defined_pragmas pragma-unused}@anchor{113}@anchor{gnat_rm/implementation_defined_pragmas id53}@anchor{114}
8633 @section Pragma Unused
8634
8635
8636 @geindex Warnings
8637 @geindex unused
8638
8639 Syntax:
8640
8641 @example
8642 pragma Unused (LOCAL_NAME @{, LOCAL_NAME@});
8643 @end example
8644
8645 This pragma signals that the assignable entities (variables,
8646 @code{out} parameters, and @code{in out} parameters) whose names are listed
8647 deliberately do not get assigned or referenced in the current source unit
8648 after the occurrence of the pragma in the current source unit. This
8649 suppresses warnings about the entities that are unreferenced and/or not
8650 assigned, and, in addition, a warning will be generated if one of these
8651 entities gets assigned or subsequently referenced in the same unit as the
8652 pragma (in the corresponding body or one of its subunits).
8653
8654 This is particularly useful for clearly signaling that a particular
8655 parameter is not modified or referenced, even though the spec suggests
8656 that it might be.
8657
8658 For the variable case, warnings are never given for unreferenced
8659 variables whose name contains one of the substrings
8660 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8661 are typically to be used in cases where such warnings are expected.
8662 Thus it is never necessary to use @code{pragma Unmodified} for such
8663 variables, though it is harmless to do so.
8664
8665 @node Pragma Validity_Checks,Pragma Volatile,Pragma Unused,Implementation Defined Pragmas
8666 @anchor{gnat_rm/implementation_defined_pragmas pragma-validity-checks}@anchor{115}
8667 @section Pragma Validity_Checks
8668
8669
8670 Syntax:
8671
8672 @example
8673 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
8674 @end example
8675
8676 This pragma is used in conjunction with compiler switches to control the
8677 built-in validity checking provided by GNAT. The compiler switches, if set
8678 provide an initial setting for the switches, and this pragma may be used
8679 to modify these settings, or the settings may be provided entirely by
8680 the use of the pragma. This pragma can be used anywhere that a pragma
8681 is legal, including use as a configuration pragma (including use in
8682 the @code{gnat.adc} file).
8683
8684 The form with a string literal specifies which validity options are to be
8685 activated. The validity checks are first set to include only the default
8686 reference manual settings, and then a string of letters in the string
8687 specifies the exact set of options required. The form of this string
8688 is exactly as described for the @emph{-gnatVx} compiler switch (see the
8689 GNAT User's Guide for details). For example the following two
8690 methods can be used to enable validity checking for mode @code{in} and
8691 @code{in out} subprogram parameters:
8692
8693
8694 @itemize *
8695
8696 @item
8697 @example
8698 pragma Validity_Checks ("im");
8699 @end example
8700
8701 @item
8702 @example
8703 $ gcc -c -gnatVim ...
8704 @end example
8705 @end itemize
8706
8707 The form ALL_CHECKS activates all standard checks (its use is equivalent
8708 to the use of the @code{gnatVa} switch).
8709
8710 The forms with @code{Off} and @code{On} can be used to temporarily disable
8711 validity checks as shown in the following example:
8712
8713 @example
8714 pragma Validity_Checks ("c"); -- validity checks for copies
8715 pragma Validity_Checks (Off); -- turn off validity checks
8716 A := B; -- B will not be validity checked
8717 pragma Validity_Checks (On); -- turn validity checks back on
8718 A := C; -- C will be validity checked
8719 @end example
8720
8721 @node Pragma Volatile,Pragma Volatile_Full_Access,Pragma Validity_Checks,Implementation Defined Pragmas
8722 @anchor{gnat_rm/implementation_defined_pragmas id54}@anchor{116}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile}@anchor{117}
8723 @section Pragma Volatile
8724
8725
8726 Syntax:
8727
8728 @example
8729 pragma Volatile (LOCAL_NAME);
8730 @end example
8731
8732 This pragma is defined by the Ada Reference Manual, and the GNAT
8733 implementation is fully conformant with this definition. The reason it
8734 is mentioned in this section is that a pragma of the same name was supplied
8735 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
8736 implementation of pragma Volatile is upwards compatible with the
8737 implementation in DEC Ada 83.
8738
8739 @node Pragma Volatile_Full_Access,Pragma Volatile_Function,Pragma Volatile,Implementation Defined Pragmas
8740 @anchor{gnat_rm/implementation_defined_pragmas id55}@anchor{118}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-full-access}@anchor{119}
8741 @section Pragma Volatile_Full_Access
8742
8743
8744 Syntax:
8745
8746 @example
8747 pragma Volatile_Full_Access (LOCAL_NAME);
8748 @end example
8749
8750 This is similar in effect to pragma Volatile, except that any reference to the
8751 object is guaranteed to be done only with instructions that read or write all
8752 the bits of the object. Furthermore, if the object is of a composite type,
8753 then any reference to a subcomponent of the object is guaranteed to read
8754 and/or write all the bits of the object.
8755
8756 The intention is that this be suitable for use with memory-mapped I/O devices
8757 on some machines. Note that there are two important respects in which this is
8758 different from @code{pragma Atomic}. First a reference to a @code{Volatile_Full_Access}
8759 object is not a sequential action in the RM 9.10 sense and, therefore, does
8760 not create a synchronization point. Second, in the case of @code{pragma Atomic},
8761 there is no guarantee that all the bits will be accessed if the reference
8762 is not to the whole object; the compiler is allowed (and generally will)
8763 access only part of the object in this case.
8764
8765 It is not permissible to specify @code{Atomic} and @code{Volatile_Full_Access} for
8766 the same type or object.
8767
8768 It is not permissible to specify @code{Volatile_Full_Access} for a composite
8769 (record or array) type or object that has an @code{Aliased} subcomponent.
8770
8771 @node Pragma Volatile_Function,Pragma Warning_As_Error,Pragma Volatile_Full_Access,Implementation Defined Pragmas
8772 @anchor{gnat_rm/implementation_defined_pragmas id56}@anchor{11a}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-function}@anchor{11b}
8773 @section Pragma Volatile_Function
8774
8775
8776 Syntax:
8777
8778 @example
8779 pragma Volatile_Function [ (boolean_EXPRESSION) ];
8780 @end example
8781
8782 For the semantics of this pragma, see the entry for aspect @code{Volatile_Function}
8783 in the SPARK 2014 Reference Manual, section 7.1.2.
8784
8785 @node Pragma Warning_As_Error,Pragma Warnings,Pragma Volatile_Function,Implementation Defined Pragmas
8786 @anchor{gnat_rm/implementation_defined_pragmas pragma-warning-as-error}@anchor{11c}
8787 @section Pragma Warning_As_Error
8788
8789
8790 Syntax:
8791
8792 @example
8793 pragma Warning_As_Error (static_string_EXPRESSION);
8794 @end example
8795
8796 This configuration pragma allows the programmer to specify a set
8797 of warnings that will be treated as errors. Any warning that
8798 matches the pattern given by the pragma argument will be treated
8799 as an error. This gives more precise control than -gnatwe,
8800 which treats warnings as errors.
8801
8802 This pragma can apply to regular warnings (messages enabled by -gnatw)
8803 and to style warnings (messages that start with "(style)",
8804 enabled by -gnaty).
8805
8806 The pattern may contain asterisks, which match zero or more characters
8807 in the message. For example, you can use @code{pragma Warning_As_Error
8808 ("bits of*unused")} to treat the warning message @code{warning: 960 bits of
8809 "a" unused} as an error. All characters other than asterisk are treated
8810 as literal characters in the match. The match is case insensitive; for
8811 example XYZ matches xyz.
8812
8813 Note that the pattern matches if it occurs anywhere within the warning
8814 message string (it is not necessary to put an asterisk at the start and
8815 the end of the message, since this is implied).
8816
8817 Another possibility for the static_string_EXPRESSION which works whether
8818 or not error tags are enabled (@emph{-gnatw.d}) is to use a single
8819 @emph{-gnatw} tag string, enclosed in brackets,
8820 as shown in the example below, to treat one category of warnings as errors.
8821 Note that if you want to treat multiple categories of warnings as errors,
8822 you can use multiple pragma Warning_As_Error.
8823
8824 The above use of patterns to match the message applies only to warning
8825 messages generated by the front end. This pragma can also be applied to
8826 warnings provided by the back end and mentioned in @ref{11d,,Pragma Warnings}.
8827 By using a single full @emph{-Wxxx} switch in the pragma, such warnings
8828 can also be treated as errors.
8829
8830 The pragma can appear either in a global configuration pragma file
8831 (e.g. @code{gnat.adc}), or at the start of a file. Given a global
8832 configuration pragma file containing:
8833
8834 @example
8835 pragma Warning_As_Error ("[-gnatwj]");
8836 @end example
8837
8838 which will treat all obsolescent feature warnings as errors, the
8839 following program compiles as shown (compile options here are
8840 @emph{-gnatwa.d -gnatl -gnatj55}).
8841
8842 @example
8843 1. pragma Warning_As_Error ("*never assigned*");
8844 2. function Warnerr return String is
8845 3. X : Integer;
8846 |
8847 >>> error: variable "X" is never read and
8848 never assigned [-gnatwv] [warning-as-error]
8849
8850 4. Y : Integer;
8851 |
8852 >>> warning: variable "Y" is assigned but
8853 never read [-gnatwu]
8854
8855 5. begin
8856 6. Y := 0;
8857 7. return %ABC%;
8858 |
8859 >>> error: use of "%" is an obsolescent
8860 feature (RM J.2(4)), use """ instead
8861 [-gnatwj] [warning-as-error]
8862
8863 8. end;
8864
8865 8 lines: No errors, 3 warnings (2 treated as errors)
8866 @end example
8867
8868 Note that this pragma does not affect the set of warnings issued in
8869 any way, it merely changes the effect of a matching warning if one
8870 is produced as a result of other warnings options. As shown in this
8871 example, if the pragma results in a warning being treated as an error,
8872 the tag is changed from "warning:" to "error:" and the string
8873 "[warning-as-error]" is appended to the end of the message.
8874
8875 @node Pragma Warnings,Pragma Weak_External,Pragma Warning_As_Error,Implementation Defined Pragmas
8876 @anchor{gnat_rm/implementation_defined_pragmas id57}@anchor{11e}@anchor{gnat_rm/implementation_defined_pragmas pragma-warnings}@anchor{11d}
8877 @section Pragma Warnings
8878
8879
8880 Syntax:
8881
8882 @example
8883 pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
8884
8885 DETAILS ::= On | Off
8886 DETAILS ::= On | Off, local_NAME
8887 DETAILS ::= static_string_EXPRESSION
8888 DETAILS ::= On | Off, static_string_EXPRESSION
8889
8890 TOOL_NAME ::= GNAT | GNATprove
8891
8892 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
8893 @end example
8894
8895 Note: in Ada 83 mode, a string literal may be used in place of a static string
8896 expression (which does not exist in Ada 83).
8897
8898 Note if the second argument of @code{DETAILS} is a @code{local_NAME} then the
8899 second form is always understood. If the intention is to use
8900 the fourth form, then you can write @code{NAME & ""} to force the
8901 intepretation as a @emph{static_string_EXPRESSION}.
8902
8903 Note: if the first argument is a valid @code{TOOL_NAME}, it will be interpreted
8904 that way. The use of the @code{TOOL_NAME} argument is relevant only to users
8905 of SPARK and GNATprove, see last part of this section for details.
8906
8907 Normally warnings are enabled, with the output being controlled by
8908 the command line switch. Warnings (@code{Off}) turns off generation of
8909 warnings until a Warnings (@code{On}) is encountered or the end of the
8910 current unit. If generation of warnings is turned off using this
8911 pragma, then some or all of the warning messages are suppressed,
8912 regardless of the setting of the command line switches.
8913
8914 The @code{Reason} parameter may optionally appear as the last argument
8915 in any of the forms of this pragma. It is intended purely for the
8916 purposes of documenting the reason for the @code{Warnings} pragma.
8917 The compiler will check that the argument is a static string but
8918 otherwise ignore this argument. Other tools may provide specialized
8919 processing for this string.
8920
8921 The form with a single argument (or two arguments if Reason present),
8922 where the first argument is @code{ON} or @code{OFF}
8923 may be used as a configuration pragma.
8924
8925 If the @code{LOCAL_NAME} parameter is present, warnings are suppressed for
8926 the specified entity. This suppression is effective from the point where
8927 it occurs till the end of the extended scope of the variable (similar to
8928 the scope of @code{Suppress}). This form cannot be used as a configuration
8929 pragma.
8930
8931 In the case where the first argument is other than @code{ON} or
8932 @code{OFF},
8933 the third form with a single static_string_EXPRESSION argument (and possible
8934 reason) provides more precise
8935 control over which warnings are active. The string is a list of letters
8936 specifying which warnings are to be activated and which deactivated. The
8937 code for these letters is the same as the string used in the command
8938 line switch controlling warnings. For a brief summary, use the gnatmake
8939 command with no arguments, which will generate usage information containing
8940 the list of warnings switches supported. For
8941 full details see the section on @code{Warning Message Control} in the
8942 @cite{GNAT User's Guide}.
8943 This form can also be used as a configuration pragma.
8944
8945 The warnings controlled by the @code{-gnatw} switch are generated by the
8946 front end of the compiler. The GCC back end can provide additional warnings
8947 and they are controlled by the @code{-W} switch. Such warnings can be
8948 identified by the appearance of a string of the form @code{[-W@{xxx@}]} in the
8949 message which designates the @code{-W@emph{xxx}} switch that controls the message.
8950 The form with a single @emph{static_string_EXPRESSION} argument also works for these
8951 warnings, but the string must be a single full @code{-W@emph{xxx}} switch in this
8952 case. The above reference lists a few examples of these additional warnings.
8953
8954 The specified warnings will be in effect until the end of the program
8955 or another pragma @code{Warnings} is encountered. The effect of the pragma is
8956 cumulative. Initially the set of warnings is the standard default set
8957 as possibly modified by compiler switches. Then each pragma Warning
8958 modifies this set of warnings as specified. This form of the pragma may
8959 also be used as a configuration pragma.
8960
8961 The fourth form, with an @code{On|Off} parameter and a string, is used to
8962 control individual messages, based on their text. The string argument
8963 is a pattern that is used to match against the text of individual
8964 warning messages (not including the initial "warning: " tag).
8965
8966 The pattern may contain asterisks, which match zero or more characters in
8967 the message. For example, you can use
8968 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
8969 message @code{warning: 960 bits of "a" unused}. No other regular
8970 expression notations are permitted. All characters other than asterisk in
8971 these three specific cases are treated as literal characters in the match.
8972 The match is case insensitive, for example XYZ matches xyz.
8973
8974 Note that the pattern matches if it occurs anywhere within the warning
8975 message string (it is not necessary to put an asterisk at the start and
8976 the end of the message, since this is implied).
8977
8978 The above use of patterns to match the message applies only to warning
8979 messages generated by the front end. This form of the pragma with a string
8980 argument can also be used to control warnings provided by the back end and
8981 mentioned above. By using a single full @code{-W@emph{xxx}} switch in the pragma,
8982 such warnings can be turned on and off.
8983
8984 There are two ways to use the pragma in this form. The OFF form can be used
8985 as a configuration pragma. The effect is to suppress all warnings (if any)
8986 that match the pattern string throughout the compilation (or match the
8987 -W switch in the back end case).
8988
8989 The second usage is to suppress a warning locally, and in this case, two
8990 pragmas must appear in sequence:
8991
8992 @example
8993 pragma Warnings (Off, Pattern);
8994 ... code where given warning is to be suppressed
8995 pragma Warnings (On, Pattern);
8996 @end example
8997
8998 In this usage, the pattern string must match in the Off and On
8999 pragmas, and (if @emph{-gnatw.w} is given) at least one matching
9000 warning must be suppressed.
9001
9002 Note: if the ON form is not found, then the effect of the OFF form extends
9003 until the end of the file (pragma Warnings is purely textual, so its effect
9004 does not stop at the end of the enclosing scope).
9005
9006 Note: to write a string that will match any warning, use the string
9007 @code{"***"}. It will not work to use a single asterisk or two
9008 asterisks since this looks like an operator name. This form with three
9009 asterisks is similar in effect to specifying @code{pragma Warnings (Off)} except (if @code{-gnatw.w} is given) that a matching
9010 @code{pragma Warnings (On, "***")} will be required. This can be
9011 helpful in avoiding forgetting to turn warnings back on.
9012
9013 Note: the debug flag @code{-gnatd.i} can be
9014 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
9015 be useful in checking whether obsolete pragmas in existing programs are hiding
9016 real problems.
9017
9018 Note: pragma Warnings does not affect the processing of style messages. See
9019 separate entry for pragma Style_Checks for control of style messages.
9020
9021 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
9022 use the version of the pragma with a @code{TOOL_NAME} parameter.
9023
9024 If present, @code{TOOL_NAME} is the name of a tool, currently either @code{GNAT} for the
9025 compiler or @code{GNATprove} for the formal verification tool. A given tool only
9026 takes into account pragma Warnings that do not specify a tool name, or that
9027 specify the matching tool name. This makes it possible to disable warnings
9028 selectively for each tool, and as a consequence to detect useless pragma
9029 Warnings with switch @code{-gnatw.w}.
9030
9031 @node Pragma Weak_External,Pragma Wide_Character_Encoding,Pragma Warnings,Implementation Defined Pragmas
9032 @anchor{gnat_rm/implementation_defined_pragmas pragma-weak-external}@anchor{11f}
9033 @section Pragma Weak_External
9034
9035
9036 Syntax:
9037
9038 @example
9039 pragma Weak_External ([Entity =>] LOCAL_NAME);
9040 @end example
9041
9042 @code{LOCAL_NAME} must refer to an object that is declared at the library
9043 level. This pragma specifies that the given entity should be marked as a
9044 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
9045 in GNU C and causes @code{LOCAL_NAME} to be emitted as a weak symbol instead
9046 of a regular symbol, that is to say a symbol that does not have to be
9047 resolved by the linker if used in conjunction with a pragma Import.
9048
9049 When a weak symbol is not resolved by the linker, its address is set to
9050 zero. This is useful in writing interfaces to external modules that may
9051 or may not be linked in the final executable, for example depending on
9052 configuration settings.
9053
9054 If a program references at run time an entity to which this pragma has been
9055 applied, and the corresponding symbol was not resolved at link time, then
9056 the execution of the program is erroneous. It is not erroneous to take the
9057 Address of such an entity, for example to guard potential references,
9058 as shown in the example below.
9059
9060 Some file formats do not support weak symbols so not all target machines
9061 support this pragma.
9062
9063 @example
9064 -- Example of the use of pragma Weak_External
9065
9066 package External_Module is
9067 key : Integer;
9068 pragma Import (C, key);
9069 pragma Weak_External (key);
9070 function Present return boolean;
9071 end External_Module;
9072
9073 with System; use System;
9074 package body External_Module is
9075 function Present return boolean is
9076 begin
9077 return key'Address /= System.Null_Address;
9078 end Present;
9079 end External_Module;
9080 @end example
9081
9082 @node Pragma Wide_Character_Encoding,,Pragma Weak_External,Implementation Defined Pragmas
9083 @anchor{gnat_rm/implementation_defined_pragmas pragma-wide-character-encoding}@anchor{120}
9084 @section Pragma Wide_Character_Encoding
9085
9086
9087 Syntax:
9088
9089 @example
9090 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
9091 @end example
9092
9093 This pragma specifies the wide character encoding to be used in program
9094 source text appearing subsequently. It is a configuration pragma, but may
9095 also be used at any point that a pragma is allowed, and it is permissible
9096 to have more than one such pragma in a file, allowing multiple encodings
9097 to appear within the same file.
9098
9099 However, note that the pragma cannot immediately precede the relevant
9100 wide character, because then the previous encoding will still be in
9101 effect, causing "illegal character" errors.
9102
9103 The argument can be an identifier or a character literal. In the identifier
9104 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
9105 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
9106 case it is correspondingly one of the characters @code{h}, @code{u},
9107 @code{s}, @code{e}, @code{8}, or @code{b}.
9108
9109 Note that when the pragma is used within a file, it affects only the
9110 encoding within that file, and does not affect withed units, specs,
9111 or subunits.
9112
9113 @node Implementation Defined Aspects,Implementation Defined Attributes,Implementation Defined Pragmas,Top
9114 @anchor{gnat_rm/implementation_defined_aspects implementation-defined-aspects}@anchor{121}@anchor{gnat_rm/implementation_defined_aspects doc}@anchor{122}@anchor{gnat_rm/implementation_defined_aspects id1}@anchor{123}
9115 @chapter Implementation Defined Aspects
9116
9117
9118 Ada defines (throughout the Ada 2012 reference manual, summarized
9119 in Annex K) a set of aspects that can be specified for certain entities.
9120 These language defined aspects are implemented in GNAT in Ada 2012 mode
9121 and work as described in the Ada 2012 Reference Manual.
9122
9123 In addition, Ada 2012 allows implementations to define additional aspects
9124 whose meaning is defined by the implementation. GNAT provides
9125 a number of these implementation-defined aspects which can be used
9126 to extend and enhance the functionality of the compiler. This section of
9127 the GNAT reference manual describes these additional aspects.
9128
9129 Note that any program using these aspects may not be portable to
9130 other compilers (although GNAT implements this set of aspects on all
9131 platforms). Therefore if portability to other compilers is an important
9132 consideration, you should minimize the use of these aspects.
9133
9134 Note that for many of these aspects, the effect is essentially similar
9135 to the use of a pragma or attribute specification with the same name
9136 applied to the entity. For example, if we write:
9137
9138 @example
9139 type R is range 1 .. 100
9140 with Value_Size => 10;
9141 @end example
9142
9143 then the effect is the same as:
9144
9145 @example
9146 type R is range 1 .. 100;
9147 for R'Value_Size use 10;
9148 @end example
9149
9150 and if we write:
9151
9152 @example
9153 type R is new Integer
9154 with Shared => True;
9155 @end example
9156
9157 then the effect is the same as:
9158
9159 @example
9160 type R is new Integer;
9161 pragma Shared (R);
9162 @end example
9163
9164 In the documentation below, such cases are simply marked
9165 as being boolean aspects equivalent to the corresponding pragma
9166 or attribute definition clause.
9167
9168 @menu
9169 * Aspect Abstract_State::
9170 * Aspect Annotate::
9171 * Aspect Async_Readers::
9172 * Aspect Async_Writers::
9173 * Aspect Constant_After_Elaboration::
9174 * Aspect Contract_Cases::
9175 * Aspect Depends::
9176 * Aspect Default_Initial_Condition::
9177 * Aspect Dimension::
9178 * Aspect Dimension_System::
9179 * Aspect Disable_Controlled::
9180 * Aspect Effective_Reads::
9181 * Aspect Effective_Writes::
9182 * Aspect Extensions_Visible::
9183 * Aspect Favor_Top_Level::
9184 * Aspect Ghost::
9185 * Aspect Global::
9186 * Aspect Initial_Condition::
9187 * Aspect Initializes::
9188 * Aspect Inline_Always::
9189 * Aspect Invariant::
9190 * Aspect Invariant'Class::
9191 * Aspect Iterable::
9192 * Aspect Linker_Section::
9193 * Aspect Lock_Free::
9194 * Aspect Max_Queue_Length::
9195 * Aspect No_Caching::
9196 * Aspect No_Elaboration_Code_All::
9197 * Aspect No_Inline::
9198 * Aspect No_Tagged_Streams::
9199 * Aspect Object_Size::
9200 * Aspect Obsolescent::
9201 * Aspect Part_Of::
9202 * Aspect Persistent_BSS::
9203 * Aspect Predicate::
9204 * Aspect Pure_Function::
9205 * Aspect Refined_Depends::
9206 * Aspect Refined_Global::
9207 * Aspect Refined_Post::
9208 * Aspect Refined_State::
9209 * Aspect Relaxed_Initialization::
9210 * Aspect Remote_Access_Type::
9211 * Aspect Secondary_Stack_Size::
9212 * Aspect Scalar_Storage_Order::
9213 * Aspect Shared::
9214 * Aspect Simple_Storage_Pool::
9215 * Aspect Simple_Storage_Pool_Type::
9216 * Aspect SPARK_Mode::
9217 * Aspect Suppress_Debug_Info::
9218 * Aspect Suppress_Initialization::
9219 * Aspect Test_Case::
9220 * Aspect Thread_Local_Storage::
9221 * Aspect Universal_Aliasing::
9222 * Aspect Universal_Data::
9223 * Aspect Unmodified::
9224 * Aspect Unreferenced::
9225 * Aspect Unreferenced_Objects::
9226 * Aspect Value_Size::
9227 * Aspect Volatile_Full_Access::
9228 * Aspect Volatile_Function::
9229 * Aspect Warnings::
9230
9231 @end menu
9232
9233 @node Aspect Abstract_State,Aspect Annotate,,Implementation Defined Aspects
9234 @anchor{gnat_rm/implementation_defined_aspects aspect-abstract-state}@anchor{124}
9235 @section Aspect Abstract_State
9236
9237
9238 @geindex Abstract_State
9239
9240 This aspect is equivalent to @ref{1c,,pragma Abstract_State}.
9241
9242 @node Aspect Annotate,Aspect Async_Readers,Aspect Abstract_State,Implementation Defined Aspects
9243 @anchor{gnat_rm/implementation_defined_aspects aspect-annotate}@anchor{125}
9244 @section Aspect Annotate
9245
9246
9247 @geindex Annotate
9248
9249 There are three forms of this aspect (where ID is an identifier,
9250 and ARG is a general expression),
9251 corresponding to @ref{26,,pragma Annotate}.
9252
9253
9254 @table @asis
9255
9256 @item @emph{Annotate => ID}
9257
9258 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9259
9260 @item @emph{Annotate => (ID)}
9261
9262 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9263
9264 @item @emph{Annotate => (ID ,ID @{, ARG@})}
9265
9266 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
9267 @end table
9268
9269 @node Aspect Async_Readers,Aspect Async_Writers,Aspect Annotate,Implementation Defined Aspects
9270 @anchor{gnat_rm/implementation_defined_aspects aspect-async-readers}@anchor{126}
9271 @section Aspect Async_Readers
9272
9273
9274 @geindex Async_Readers
9275
9276 This boolean aspect is equivalent to @ref{2d,,pragma Async_Readers}.
9277
9278 @node Aspect Async_Writers,Aspect Constant_After_Elaboration,Aspect Async_Readers,Implementation Defined Aspects
9279 @anchor{gnat_rm/implementation_defined_aspects aspect-async-writers}@anchor{127}
9280 @section Aspect Async_Writers
9281
9282
9283 @geindex Async_Writers
9284
9285 This boolean aspect is equivalent to @ref{30,,pragma Async_Writers}.
9286
9287 @node Aspect Constant_After_Elaboration,Aspect Contract_Cases,Aspect Async_Writers,Implementation Defined Aspects
9288 @anchor{gnat_rm/implementation_defined_aspects aspect-constant-after-elaboration}@anchor{128}
9289 @section Aspect Constant_After_Elaboration
9290
9291
9292 @geindex Constant_After_Elaboration
9293
9294 This aspect is equivalent to @ref{42,,pragma Constant_After_Elaboration}.
9295
9296 @node Aspect Contract_Cases,Aspect Depends,Aspect Constant_After_Elaboration,Implementation Defined Aspects
9297 @anchor{gnat_rm/implementation_defined_aspects aspect-contract-cases}@anchor{129}
9298 @section Aspect Contract_Cases
9299
9300
9301 @geindex Contract_Cases
9302
9303 This aspect is equivalent to @ref{44,,pragma Contract_Cases}, the sequence
9304 of clauses being enclosed in parentheses so that syntactically it is an
9305 aggregate.
9306
9307 @node Aspect Depends,Aspect Default_Initial_Condition,Aspect Contract_Cases,Implementation Defined Aspects
9308 @anchor{gnat_rm/implementation_defined_aspects aspect-depends}@anchor{12a}
9309 @section Aspect Depends
9310
9311
9312 @geindex Depends
9313
9314 This aspect is equivalent to @ref{53,,pragma Depends}.
9315
9316 @node Aspect Default_Initial_Condition,Aspect Dimension,Aspect Depends,Implementation Defined Aspects
9317 @anchor{gnat_rm/implementation_defined_aspects aspect-default-initial-condition}@anchor{12b}
9318 @section Aspect Default_Initial_Condition
9319
9320
9321 @geindex Default_Initial_Condition
9322
9323 This aspect is equivalent to @ref{4e,,pragma Default_Initial_Condition}.
9324
9325 @node Aspect Dimension,Aspect Dimension_System,Aspect Default_Initial_Condition,Implementation Defined Aspects
9326 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension}@anchor{12c}
9327 @section Aspect Dimension
9328
9329
9330 @geindex Dimension
9331
9332 The @code{Dimension} aspect is used to specify the dimensions of a given
9333 subtype of a dimensioned numeric type. The aspect also specifies a symbol
9334 used when doing formatted output of dimensioned quantities. The syntax is:
9335
9336 @example
9337 with Dimension =>
9338 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
9339
9340 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
9341
9342 DIMENSION_VALUE ::=
9343 RATIONAL
9344 | others => RATIONAL
9345 | DISCRETE_CHOICE_LIST => RATIONAL
9346
9347 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
9348 @end example
9349
9350 This aspect can only be applied to a subtype whose parent type has
9351 a @code{Dimension_System} aspect. The aspect must specify values for
9352 all dimensions of the system. The rational values are the powers of the
9353 corresponding dimensions that are used by the compiler to verify that
9354 physical (numeric) computations are dimensionally consistent. For example,
9355 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
9356 For further examples of the usage
9357 of this aspect, see package @code{System.Dim.Mks}.
9358 Note that when the dimensioned type is an integer type, then any
9359 dimension value must be an integer literal.
9360
9361 @node Aspect Dimension_System,Aspect Disable_Controlled,Aspect Dimension,Implementation Defined Aspects
9362 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension-system}@anchor{12d}
9363 @section Aspect Dimension_System
9364
9365
9366 @geindex Dimension_System
9367
9368 The @code{Dimension_System} aspect is used to define a system of
9369 dimensions that will be used in subsequent subtype declarations with
9370 @code{Dimension} aspects that reference this system. The syntax is:
9371
9372 @example
9373 with Dimension_System => (DIMENSION @{, DIMENSION@});
9374
9375 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
9376 [Unit_Symbol =>] SYMBOL,
9377 [Dim_Symbol =>] SYMBOL)
9378
9379 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
9380 @end example
9381
9382 This aspect is applied to a type, which must be a numeric derived type
9383 (typically a floating-point type), that
9384 will represent values within the dimension system. Each @code{DIMENSION}
9385 corresponds to one particular dimension. A maximum of 7 dimensions may
9386 be specified. @code{Unit_Name} is the name of the dimension (for example
9387 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
9388 of this dimension (for example @code{m} for @code{Meter}).
9389 @code{Dim_Symbol} gives
9390 the identification within the dimension system (typically this is a
9391 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
9392 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
9393 The @code{Dim_Symbol} is used in error messages when numeric operations have
9394 inconsistent dimensions.
9395
9396 GNAT provides the standard definition of the International MKS system in
9397 the run-time package @code{System.Dim.Mks}. You can easily define
9398 similar packages for cgs units or British units, and define conversion factors
9399 between values in different systems. The MKS system is characterized by the
9400 following aspect:
9401
9402 @example
9403 type Mks_Type is new Long_Long_Float with
9404 Dimension_System => (
9405 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
9406 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
9407 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
9408 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
9409 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => '@@'),
9410 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
9411 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
9412 @end example
9413
9414 Note that in the above type definition, we use the @code{at} symbol (@code{@@}) to
9415 represent a theta character (avoiding the use of extended Latin-1
9416 characters in this context).
9417
9418 See section 'Performing Dimensionality Analysis in GNAT' in the GNAT Users
9419 Guide for detailed examples of use of the dimension system.
9420
9421 @node Aspect Disable_Controlled,Aspect Effective_Reads,Aspect Dimension_System,Implementation Defined Aspects
9422 @anchor{gnat_rm/implementation_defined_aspects aspect-disable-controlled}@anchor{12e}
9423 @section Aspect Disable_Controlled
9424
9425
9426 @geindex Disable_Controlled
9427
9428 The aspect @code{Disable_Controlled} is defined for controlled record types. If
9429 active, this aspect causes suppression of all related calls to @code{Initialize},
9430 @code{Adjust}, and @code{Finalize}. The intended use is for conditional compilation,
9431 where for example you might want a record to be controlled or not depending on
9432 whether some run-time check is enabled or suppressed.
9433
9434 @node Aspect Effective_Reads,Aspect Effective_Writes,Aspect Disable_Controlled,Implementation Defined Aspects
9435 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-reads}@anchor{12f}
9436 @section Aspect Effective_Reads
9437
9438
9439 @geindex Effective_Reads
9440
9441 This aspect is equivalent to @ref{59,,pragma Effective_Reads}.
9442
9443 @node Aspect Effective_Writes,Aspect Extensions_Visible,Aspect Effective_Reads,Implementation Defined Aspects
9444 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-writes}@anchor{130}
9445 @section Aspect Effective_Writes
9446
9447
9448 @geindex Effective_Writes
9449
9450 This aspect is equivalent to @ref{5b,,pragma Effective_Writes}.
9451
9452 @node Aspect Extensions_Visible,Aspect Favor_Top_Level,Aspect Effective_Writes,Implementation Defined Aspects
9453 @anchor{gnat_rm/implementation_defined_aspects aspect-extensions-visible}@anchor{131}
9454 @section Aspect Extensions_Visible
9455
9456
9457 @geindex Extensions_Visible
9458
9459 This aspect is equivalent to @ref{67,,pragma Extensions_Visible}.
9460
9461 @node Aspect Favor_Top_Level,Aspect Ghost,Aspect Extensions_Visible,Implementation Defined Aspects
9462 @anchor{gnat_rm/implementation_defined_aspects aspect-favor-top-level}@anchor{132}
9463 @section Aspect Favor_Top_Level
9464
9465
9466 @geindex Favor_Top_Level
9467
9468 This boolean aspect is equivalent to @ref{6c,,pragma Favor_Top_Level}.
9469
9470 @node Aspect Ghost,Aspect Global,Aspect Favor_Top_Level,Implementation Defined Aspects
9471 @anchor{gnat_rm/implementation_defined_aspects aspect-ghost}@anchor{133}
9472 @section Aspect Ghost
9473
9474
9475 @geindex Ghost
9476
9477 This aspect is equivalent to @ref{6f,,pragma Ghost}.
9478
9479 @node Aspect Global,Aspect Initial_Condition,Aspect Ghost,Implementation Defined Aspects
9480 @anchor{gnat_rm/implementation_defined_aspects aspect-global}@anchor{134}
9481 @section Aspect Global
9482
9483
9484 @geindex Global
9485
9486 This aspect is equivalent to @ref{71,,pragma Global}.
9487
9488 @node Aspect Initial_Condition,Aspect Initializes,Aspect Global,Implementation Defined Aspects
9489 @anchor{gnat_rm/implementation_defined_aspects aspect-initial-condition}@anchor{135}
9490 @section Aspect Initial_Condition
9491
9492
9493 @geindex Initial_Condition
9494
9495 This aspect is equivalent to @ref{7f,,pragma Initial_Condition}.
9496
9497 @node Aspect Initializes,Aspect Inline_Always,Aspect Initial_Condition,Implementation Defined Aspects
9498 @anchor{gnat_rm/implementation_defined_aspects aspect-initializes}@anchor{136}
9499 @section Aspect Initializes
9500
9501
9502 @geindex Initializes
9503
9504 This aspect is equivalent to @ref{81,,pragma Initializes}.
9505
9506 @node Aspect Inline_Always,Aspect Invariant,Aspect Initializes,Implementation Defined Aspects
9507 @anchor{gnat_rm/implementation_defined_aspects aspect-inline-always}@anchor{137}
9508 @section Aspect Inline_Always
9509
9510
9511 @geindex Inline_Always
9512
9513 This boolean aspect is equivalent to @ref{84,,pragma Inline_Always}.
9514
9515 @node Aspect Invariant,Aspect Invariant'Class,Aspect Inline_Always,Implementation Defined Aspects
9516 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant}@anchor{138}
9517 @section Aspect Invariant
9518
9519
9520 @geindex Invariant
9521
9522 This aspect is equivalent to @ref{8b,,pragma Invariant}. It is a
9523 synonym for the language defined aspect @code{Type_Invariant} except
9524 that it is separately controllable using pragma @code{Assertion_Policy}.
9525
9526 @node Aspect Invariant'Class,Aspect Iterable,Aspect Invariant,Implementation Defined Aspects
9527 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant-class}@anchor{139}
9528 @section Aspect Invariant'Class
9529
9530
9531 @geindex Invariant'Class
9532
9533 This aspect is equivalent to @ref{102,,pragma Type_Invariant_Class}. It is a
9534 synonym for the language defined aspect @code{Type_Invariant'Class} except
9535 that it is separately controllable using pragma @code{Assertion_Policy}.
9536
9537 @node Aspect Iterable,Aspect Linker_Section,Aspect Invariant'Class,Implementation Defined Aspects
9538 @anchor{gnat_rm/implementation_defined_aspects aspect-iterable}@anchor{13a}
9539 @section Aspect Iterable
9540
9541
9542 @geindex Iterable
9543
9544 This aspect provides a light-weight mechanism for loops and quantified
9545 expressions over container types, without the overhead imposed by the tampering
9546 checks of standard Ada 2012 iterators. The value of the aspect is an aggregate
9547 with six named components, of which the last three are optional: @code{First},
9548 @code{Next}, @code{Has_Element}, @code{Element}, @code{Last}, and @code{Previous}.
9549 When only the first three components are specified, only the
9550 @code{for .. in} form of iteration over cursors is available. When @code{Element}
9551 is specified, both this form and the @code{for .. of} form of iteration over
9552 elements are available. If the last two components are specified, reverse
9553 iterations over the container can be specified (analogous to what can be done
9554 over predefined containers that support the @code{Reverse_Iterator} interface).
9555 The following is a typical example of use:
9556
9557 @example
9558 type List is private with
9559 Iterable => (First => First_Cursor,
9560 Next => Advance,
9561 Has_Element => Cursor_Has_Element,
9562 [Element => Get_Element]);
9563 @end example
9564
9565
9566 @itemize *
9567
9568 @item
9569 The value denoted by @code{First} must denote a primitive operation of the
9570 container type that returns a @code{Cursor}, which must a be a type declared in
9571 the container package or visible from it. For example:
9572 @end itemize
9573
9574 @example
9575 function First_Cursor (Cont : Container) return Cursor;
9576 @end example
9577
9578
9579 @itemize *
9580
9581 @item
9582 The value of @code{Next} is a primitive operation of the container type that takes
9583 both a container and a cursor and yields a cursor. For example:
9584 @end itemize
9585
9586 @example
9587 function Advance (Cont : Container; Position : Cursor) return Cursor;
9588 @end example
9589
9590
9591 @itemize *
9592
9593 @item
9594 The value of @code{Has_Element} is a primitive operation of the container type
9595 that takes both a container and a cursor and yields a boolean. For example:
9596 @end itemize
9597
9598 @example
9599 function Cursor_Has_Element (Cont : Container; Position : Cursor) return Boolean;
9600 @end example
9601
9602
9603 @itemize *
9604
9605 @item
9606 The value of @code{Element} is a primitive operation of the container type that
9607 takes both a container and a cursor and yields an @code{Element_Type}, which must
9608 be a type declared in the container package or visible from it. For example:
9609 @end itemize
9610
9611 @example
9612 function Get_Element (Cont : Container; Position : Cursor) return Element_Type;
9613 @end example
9614
9615 This aspect is used in the GNAT-defined formal container packages.
9616
9617 @node Aspect Linker_Section,Aspect Lock_Free,Aspect Iterable,Implementation Defined Aspects
9618 @anchor{gnat_rm/implementation_defined_aspects aspect-linker-section}@anchor{13b}
9619 @section Aspect Linker_Section
9620
9621
9622 @geindex Linker_Section
9623
9624 This aspect is equivalent to @ref{93,,pragma Linker_Section}.
9625
9626 @node Aspect Lock_Free,Aspect Max_Queue_Length,Aspect Linker_Section,Implementation Defined Aspects
9627 @anchor{gnat_rm/implementation_defined_aspects aspect-lock-free}@anchor{13c}
9628 @section Aspect Lock_Free
9629
9630
9631 @geindex Lock_Free
9632
9633 This boolean aspect is equivalent to @ref{95,,pragma Lock_Free}.
9634
9635 @node Aspect Max_Queue_Length,Aspect No_Caching,Aspect Lock_Free,Implementation Defined Aspects
9636 @anchor{gnat_rm/implementation_defined_aspects aspect-max-queue-length}@anchor{13d}
9637 @section Aspect Max_Queue_Length
9638
9639
9640 @geindex Max_Queue_Length
9641
9642 This aspect is equivalent to @ref{9d,,pragma Max_Queue_Length}.
9643
9644 @node Aspect No_Caching,Aspect No_Elaboration_Code_All,Aspect Max_Queue_Length,Implementation Defined Aspects
9645 @anchor{gnat_rm/implementation_defined_aspects aspect-no-caching}@anchor{13e}
9646 @section Aspect No_Caching
9647
9648
9649 @geindex No_Caching
9650
9651 This boolean aspect is equivalent to @ref{9f,,pragma No_Caching}.
9652
9653 @node Aspect No_Elaboration_Code_All,Aspect No_Inline,Aspect No_Caching,Implementation Defined Aspects
9654 @anchor{gnat_rm/implementation_defined_aspects aspect-no-elaboration-code-all}@anchor{13f}
9655 @section Aspect No_Elaboration_Code_All
9656
9657
9658 @geindex No_Elaboration_Code_All
9659
9660 This aspect is equivalent to @ref{a3,,pragma No_Elaboration_Code_All}
9661 for a program unit.
9662
9663 @node Aspect No_Inline,Aspect No_Tagged_Streams,Aspect No_Elaboration_Code_All,Implementation Defined Aspects
9664 @anchor{gnat_rm/implementation_defined_aspects aspect-no-inline}@anchor{140}
9665 @section Aspect No_Inline
9666
9667
9668 @geindex No_Inline
9669
9670 This boolean aspect is equivalent to @ref{a6,,pragma No_Inline}.
9671
9672 @node Aspect No_Tagged_Streams,Aspect Object_Size,Aspect No_Inline,Implementation Defined Aspects
9673 @anchor{gnat_rm/implementation_defined_aspects aspect-no-tagged-streams}@anchor{141}
9674 @section Aspect No_Tagged_Streams
9675
9676
9677 @geindex No_Tagged_Streams
9678
9679 This aspect is equivalent to @ref{a9,,pragma No_Tagged_Streams} with an
9680 argument specifying a root tagged type (thus this aspect can only be
9681 applied to such a type).
9682
9683 @node Aspect Object_Size,Aspect Obsolescent,Aspect No_Tagged_Streams,Implementation Defined Aspects
9684 @anchor{gnat_rm/implementation_defined_aspects aspect-object-size}@anchor{142}
9685 @section Aspect Object_Size
9686
9687
9688 @geindex Object_Size
9689
9690 This aspect is equivalent to @ref{143,,attribute Object_Size}.
9691
9692 @node Aspect Obsolescent,Aspect Part_Of,Aspect Object_Size,Implementation Defined Aspects
9693 @anchor{gnat_rm/implementation_defined_aspects aspect-obsolescent}@anchor{144}
9694 @section Aspect Obsolescent
9695
9696
9697 @geindex Obsolsecent
9698
9699 This aspect is equivalent to @ref{ac,,pragma Obsolescent}. Note that the
9700 evaluation of this aspect happens at the point of occurrence, it is not
9701 delayed until the freeze point.
9702
9703 @node Aspect Part_Of,Aspect Persistent_BSS,Aspect Obsolescent,Implementation Defined Aspects
9704 @anchor{gnat_rm/implementation_defined_aspects aspect-part-of}@anchor{145}
9705 @section Aspect Part_Of
9706
9707
9708 @geindex Part_Of
9709
9710 This aspect is equivalent to @ref{b4,,pragma Part_Of}.
9711
9712 @node Aspect Persistent_BSS,Aspect Predicate,Aspect Part_Of,Implementation Defined Aspects
9713 @anchor{gnat_rm/implementation_defined_aspects aspect-persistent-bss}@anchor{146}
9714 @section Aspect Persistent_BSS
9715
9716
9717 @geindex Persistent_BSS
9718
9719 This boolean aspect is equivalent to @ref{b7,,pragma Persistent_BSS}.
9720
9721 @node Aspect Predicate,Aspect Pure_Function,Aspect Persistent_BSS,Implementation Defined Aspects
9722 @anchor{gnat_rm/implementation_defined_aspects aspect-predicate}@anchor{147}
9723 @section Aspect Predicate
9724
9725
9726 @geindex Predicate
9727
9728 This aspect is equivalent to @ref{be,,pragma Predicate}. It is thus
9729 similar to the language defined aspects @code{Dynamic_Predicate}
9730 and @code{Static_Predicate} except that whether the resulting
9731 predicate is static or dynamic is controlled by the form of the
9732 expression. It is also separately controllable using pragma
9733 @code{Assertion_Policy}.
9734
9735 @node Aspect Pure_Function,Aspect Refined_Depends,Aspect Predicate,Implementation Defined Aspects
9736 @anchor{gnat_rm/implementation_defined_aspects aspect-pure-function}@anchor{148}
9737 @section Aspect Pure_Function
9738
9739
9740 @geindex Pure_Function
9741
9742 This boolean aspect is equivalent to @ref{ca,,pragma Pure_Function}.
9743
9744 @node Aspect Refined_Depends,Aspect Refined_Global,Aspect Pure_Function,Implementation Defined Aspects
9745 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-depends}@anchor{149}
9746 @section Aspect Refined_Depends
9747
9748
9749 @geindex Refined_Depends
9750
9751 This aspect is equivalent to @ref{ce,,pragma Refined_Depends}.
9752
9753 @node Aspect Refined_Global,Aspect Refined_Post,Aspect Refined_Depends,Implementation Defined Aspects
9754 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-global}@anchor{14a}
9755 @section Aspect Refined_Global
9756
9757
9758 @geindex Refined_Global
9759
9760 This aspect is equivalent to @ref{d0,,pragma Refined_Global}.
9761
9762 @node Aspect Refined_Post,Aspect Refined_State,Aspect Refined_Global,Implementation Defined Aspects
9763 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-post}@anchor{14b}
9764 @section Aspect Refined_Post
9765
9766
9767 @geindex Refined_Post
9768
9769 This aspect is equivalent to @ref{d2,,pragma Refined_Post}.
9770
9771 @node Aspect Refined_State,Aspect Relaxed_Initialization,Aspect Refined_Post,Implementation Defined Aspects
9772 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-state}@anchor{14c}
9773 @section Aspect Refined_State
9774
9775
9776 @geindex Refined_State
9777
9778 This aspect is equivalent to @ref{d4,,pragma Refined_State}.
9779
9780 @node Aspect Relaxed_Initialization,Aspect Remote_Access_Type,Aspect Refined_State,Implementation Defined Aspects
9781 @anchor{gnat_rm/implementation_defined_aspects aspect-relaxed-initialization}@anchor{14d}
9782 @section Aspect Relaxed_Initialization
9783
9784
9785 @geindex Refined_Initialization
9786
9787 For the syntax and semantics of this aspect, see the SPARK 2014 Reference
9788 Manual, section 6.10.
9789
9790 @node Aspect Remote_Access_Type,Aspect Secondary_Stack_Size,Aspect Relaxed_Initialization,Implementation Defined Aspects
9791 @anchor{gnat_rm/implementation_defined_aspects aspect-remote-access-type}@anchor{14e}
9792 @section Aspect Remote_Access_Type
9793
9794
9795 @geindex Remote_Access_Type
9796
9797 This aspect is equivalent to @ref{d8,,pragma Remote_Access_Type}.
9798
9799 @node Aspect Secondary_Stack_Size,Aspect Scalar_Storage_Order,Aspect Remote_Access_Type,Implementation Defined Aspects
9800 @anchor{gnat_rm/implementation_defined_aspects aspect-secondary-stack-size}@anchor{14f}
9801 @section Aspect Secondary_Stack_Size
9802
9803
9804 @geindex Secondary_Stack_Size
9805
9806 This aspect is equivalent to @ref{dd,,pragma Secondary_Stack_Size}.
9807
9808 @node Aspect Scalar_Storage_Order,Aspect Shared,Aspect Secondary_Stack_Size,Implementation Defined Aspects
9809 @anchor{gnat_rm/implementation_defined_aspects aspect-scalar-storage-order}@anchor{150}
9810 @section Aspect Scalar_Storage_Order
9811
9812
9813 @geindex Scalar_Storage_Order
9814
9815 This aspect is equivalent to a @ref{151,,attribute Scalar_Storage_Order}.
9816
9817 @node Aspect Shared,Aspect Simple_Storage_Pool,Aspect Scalar_Storage_Order,Implementation Defined Aspects
9818 @anchor{gnat_rm/implementation_defined_aspects aspect-shared}@anchor{152}
9819 @section Aspect Shared
9820
9821
9822 @geindex Shared
9823
9824 This boolean aspect is equivalent to @ref{e0,,pragma Shared}
9825 and is thus a synonym for aspect @code{Atomic}.
9826
9827 @node Aspect Simple_Storage_Pool,Aspect Simple_Storage_Pool_Type,Aspect Shared,Implementation Defined Aspects
9828 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool}@anchor{153}
9829 @section Aspect Simple_Storage_Pool
9830
9831
9832 @geindex Simple_Storage_Pool
9833
9834 This aspect is equivalent to @ref{e5,,attribute Simple_Storage_Pool}.
9835
9836 @node Aspect Simple_Storage_Pool_Type,Aspect SPARK_Mode,Aspect Simple_Storage_Pool,Implementation Defined Aspects
9837 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool-type}@anchor{154}
9838 @section Aspect Simple_Storage_Pool_Type
9839
9840
9841 @geindex Simple_Storage_Pool_Type
9842
9843 This boolean aspect is equivalent to @ref{e3,,pragma Simple_Storage_Pool_Type}.
9844
9845 @node Aspect SPARK_Mode,Aspect Suppress_Debug_Info,Aspect Simple_Storage_Pool_Type,Implementation Defined Aspects
9846 @anchor{gnat_rm/implementation_defined_aspects aspect-spark-mode}@anchor{155}
9847 @section Aspect SPARK_Mode
9848
9849
9850 @geindex SPARK_Mode
9851
9852 This aspect is equivalent to @ref{eb,,pragma SPARK_Mode} and
9853 may be specified for either or both of the specification and body
9854 of a subprogram or package.
9855
9856 @node Aspect Suppress_Debug_Info,Aspect Suppress_Initialization,Aspect SPARK_Mode,Implementation Defined Aspects
9857 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-debug-info}@anchor{156}
9858 @section Aspect Suppress_Debug_Info
9859
9860
9861 @geindex Suppress_Debug_Info
9862
9863 This boolean aspect is equivalent to @ref{f3,,pragma Suppress_Debug_Info}.
9864
9865 @node Aspect Suppress_Initialization,Aspect Test_Case,Aspect Suppress_Debug_Info,Implementation Defined Aspects
9866 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-initialization}@anchor{157}
9867 @section Aspect Suppress_Initialization
9868
9869
9870 @geindex Suppress_Initialization
9871
9872 This boolean aspect is equivalent to @ref{f7,,pragma Suppress_Initialization}.
9873
9874 @node Aspect Test_Case,Aspect Thread_Local_Storage,Aspect Suppress_Initialization,Implementation Defined Aspects
9875 @anchor{gnat_rm/implementation_defined_aspects aspect-test-case}@anchor{158}
9876 @section Aspect Test_Case
9877
9878
9879 @geindex Test_Case
9880
9881 This aspect is equivalent to @ref{fa,,pragma Test_Case}.
9882
9883 @node Aspect Thread_Local_Storage,Aspect Universal_Aliasing,Aspect Test_Case,Implementation Defined Aspects
9884 @anchor{gnat_rm/implementation_defined_aspects aspect-thread-local-storage}@anchor{159}
9885 @section Aspect Thread_Local_Storage
9886
9887
9888 @geindex Thread_Local_Storage
9889
9890 This boolean aspect is equivalent to @ref{fc,,pragma Thread_Local_Storage}.
9891
9892 @node Aspect Universal_Aliasing,Aspect Universal_Data,Aspect Thread_Local_Storage,Implementation Defined Aspects
9893 @anchor{gnat_rm/implementation_defined_aspects aspect-universal-aliasing}@anchor{15a}
9894 @section Aspect Universal_Aliasing
9895
9896
9897 @geindex Universal_Aliasing
9898
9899 This boolean aspect is equivalent to @ref{106,,pragma Universal_Aliasing}.
9900
9901 @node Aspect Universal_Data,Aspect Unmodified,Aspect Universal_Aliasing,Implementation Defined Aspects
9902 @anchor{gnat_rm/implementation_defined_aspects aspect-universal-data}@anchor{15b}
9903 @section Aspect Universal_Data
9904
9905
9906 @geindex Universal_Data
9907
9908 This aspect is equivalent to @ref{108,,pragma Universal_Data}.
9909
9910 @node Aspect Unmodified,Aspect Unreferenced,Aspect Universal_Data,Implementation Defined Aspects
9911 @anchor{gnat_rm/implementation_defined_aspects aspect-unmodified}@anchor{15c}
9912 @section Aspect Unmodified
9913
9914
9915 @geindex Unmodified
9916
9917 This boolean aspect is equivalent to @ref{10b,,pragma Unmodified}.
9918
9919 @node Aspect Unreferenced,Aspect Unreferenced_Objects,Aspect Unmodified,Implementation Defined Aspects
9920 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced}@anchor{15d}
9921 @section Aspect Unreferenced
9922
9923
9924 @geindex Unreferenced
9925
9926 This boolean aspect is equivalent to @ref{10c,,pragma Unreferenced}.
9927
9928 When using the @code{-gnatX} switch, this aspect is also supported on formal
9929 parameters, which is in particular the only form possible for expression
9930 functions.
9931
9932 @node Aspect Unreferenced_Objects,Aspect Value_Size,Aspect Unreferenced,Implementation Defined Aspects
9933 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced-objects}@anchor{15e}
9934 @section Aspect Unreferenced_Objects
9935
9936
9937 @geindex Unreferenced_Objects
9938
9939 This boolean aspect is equivalent to @ref{10e,,pragma Unreferenced_Objects}.
9940
9941 @node Aspect Value_Size,Aspect Volatile_Full_Access,Aspect Unreferenced_Objects,Implementation Defined Aspects
9942 @anchor{gnat_rm/implementation_defined_aspects aspect-value-size}@anchor{15f}
9943 @section Aspect Value_Size
9944
9945
9946 @geindex Value_Size
9947
9948 This aspect is equivalent to @ref{160,,attribute Value_Size}.
9949
9950 @node Aspect Volatile_Full_Access,Aspect Volatile_Function,Aspect Value_Size,Implementation Defined Aspects
9951 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-full-access}@anchor{161}
9952 @section Aspect Volatile_Full_Access
9953
9954
9955 @geindex Volatile_Full_Access
9956
9957 This boolean aspect is equivalent to @ref{119,,pragma Volatile_Full_Access}.
9958
9959 @node Aspect Volatile_Function,Aspect Warnings,Aspect Volatile_Full_Access,Implementation Defined Aspects
9960 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-function}@anchor{162}
9961 @section Aspect Volatile_Function
9962
9963
9964 @geindex Volatile_Function
9965
9966 This boolean aspect is equivalent to @ref{11b,,pragma Volatile_Function}.
9967
9968 @node Aspect Warnings,,Aspect Volatile_Function,Implementation Defined Aspects
9969 @anchor{gnat_rm/implementation_defined_aspects aspect-warnings}@anchor{163}
9970 @section Aspect Warnings
9971
9972
9973 @geindex Warnings
9974
9975 This aspect is equivalent to the two argument form of @ref{11d,,pragma Warnings},
9976 where the first argument is @code{ON} or @code{OFF} and the second argument
9977 is the entity.
9978
9979 @node Implementation Defined Attributes,Standard and Implementation Defined Restrictions,Implementation Defined Aspects,Top
9980 @anchor{gnat_rm/implementation_defined_attributes doc}@anchor{164}@anchor{gnat_rm/implementation_defined_attributes implementation-defined-attributes}@anchor{8}@anchor{gnat_rm/implementation_defined_attributes id1}@anchor{165}
9981 @chapter Implementation Defined Attributes
9982
9983
9984 Ada defines (throughout the Ada reference manual,
9985 summarized in Annex K),
9986 a set of attributes that provide useful additional functionality in all
9987 areas of the language. These language defined attributes are implemented
9988 in GNAT and work as described in the Ada Reference Manual.
9989
9990 In addition, Ada allows implementations to define additional
9991 attributes whose meaning is defined by the implementation. GNAT provides
9992 a number of these implementation-dependent attributes which can be used
9993 to extend and enhance the functionality of the compiler. This section of
9994 the GNAT reference manual describes these additional attributes. It also
9995 describes additional implementation-dependent features of standard
9996 language-defined attributes.
9997
9998 Note that any program using these attributes may not be portable to
9999 other compilers (although GNAT implements this set of attributes on all
10000 platforms). Therefore if portability to other compilers is an important
10001 consideration, you should minimize the use of these attributes.
10002
10003 @menu
10004 * Attribute Abort_Signal::
10005 * Attribute Address_Size::
10006 * Attribute Asm_Input::
10007 * Attribute Asm_Output::
10008 * Attribute Atomic_Always_Lock_Free::
10009 * Attribute Bit::
10010 * Attribute Bit_Position::
10011 * Attribute Code_Address::
10012 * Attribute Compiler_Version::
10013 * Attribute Constrained::
10014 * Attribute Default_Bit_Order::
10015 * Attribute Default_Scalar_Storage_Order::
10016 * Attribute Deref::
10017 * Attribute Descriptor_Size::
10018 * Attribute Elaborated::
10019 * Attribute Elab_Body::
10020 * Attribute Elab_Spec::
10021 * Attribute Elab_Subp_Body::
10022 * Attribute Emax::
10023 * Attribute Enabled::
10024 * Attribute Enum_Rep::
10025 * Attribute Enum_Val::
10026 * Attribute Epsilon::
10027 * Attribute Fast_Math::
10028 * Attribute Finalization_Size::
10029 * Attribute Fixed_Value::
10030 * Attribute From_Any::
10031 * Attribute Has_Access_Values::
10032 * Attribute Has_Discriminants::
10033 * Attribute Img::
10034 * Attribute Initialized::
10035 * Attribute Integer_Value::
10036 * Attribute Invalid_Value::
10037 * Attribute Iterable::
10038 * Attribute Large::
10039 * Attribute Library_Level::
10040 * Attribute Lock_Free::
10041 * Attribute Loop_Entry::
10042 * Attribute Machine_Size::
10043 * Attribute Mantissa::
10044 * Attribute Maximum_Alignment::
10045 * Attribute Max_Integer_Size::
10046 * Attribute Mechanism_Code::
10047 * Attribute Null_Parameter::
10048 * Attribute Object_Size::
10049 * Attribute Old::
10050 * Attribute Passed_By_Reference::
10051 * Attribute Pool_Address::
10052 * Attribute Range_Length::
10053 * Attribute Restriction_Set::
10054 * Attribute Result::
10055 * Attribute Safe_Emax::
10056 * Attribute Safe_Large::
10057 * Attribute Safe_Small::
10058 * Attribute Scalar_Storage_Order::
10059 * Attribute Simple_Storage_Pool::
10060 * Attribute Small::
10061 * Attribute Storage_Unit::
10062 * Attribute Stub_Type::
10063 * Attribute System_Allocator_Alignment::
10064 * Attribute Target_Name::
10065 * Attribute To_Address::
10066 * Attribute To_Any::
10067 * Attribute Type_Class::
10068 * Attribute Type_Key::
10069 * Attribute TypeCode::
10070 * Attribute Unconstrained_Array::
10071 * Attribute Universal_Literal_String::
10072 * Attribute Unrestricted_Access::
10073 * Attribute Update::
10074 * Attribute Valid_Scalars::
10075 * Attribute VADS_Size::
10076 * Attribute Value_Size::
10077 * Attribute Wchar_T_Size::
10078 * Attribute Word_Size::
10079
10080 @end menu
10081
10082 @node Attribute Abort_Signal,Attribute Address_Size,,Implementation Defined Attributes
10083 @anchor{gnat_rm/implementation_defined_attributes attribute-abort-signal}@anchor{166}
10084 @section Attribute Abort_Signal
10085
10086
10087 @geindex Abort_Signal
10088
10089 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
10090 prefix) provides the entity for the special exception used to signal
10091 task abort or asynchronous transfer of control. Normally this attribute
10092 should only be used in the tasking runtime (it is highly peculiar, and
10093 completely outside the normal semantics of Ada, for a user program to
10094 intercept the abort exception).
10095
10096 @node Attribute Address_Size,Attribute Asm_Input,Attribute Abort_Signal,Implementation Defined Attributes
10097 @anchor{gnat_rm/implementation_defined_attributes attribute-address-size}@anchor{167}
10098 @section Attribute Address_Size
10099
10100
10101 @geindex Size of `@w{`}Address`@w{`}
10102
10103 @geindex Address_Size
10104
10105 @code{Standard'Address_Size} (@code{Standard} is the only allowed
10106 prefix) is a static constant giving the number of bits in an
10107 @code{Address}. It is the same value as System.Address'Size,
10108 but has the advantage of being static, while a direct
10109 reference to System.Address'Size is nonstatic because Address
10110 is a private type.
10111
10112 @node Attribute Asm_Input,Attribute Asm_Output,Attribute Address_Size,Implementation Defined Attributes
10113 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-input}@anchor{168}
10114 @section Attribute Asm_Input
10115
10116
10117 @geindex Asm_Input
10118
10119 The @code{Asm_Input} attribute denotes a function that takes two
10120 parameters. The first is a string, the second is an expression of the
10121 type designated by the prefix. The first (string) argument is required
10122 to be a static expression, and is the constraint for the parameter,
10123 (e.g., what kind of register is required). The second argument is the
10124 value to be used as the input argument. The possible values for the
10125 constant are the same as those used in the RTL, and are dependent on
10126 the configuration file used to built the GCC back end.
10127 @ref{169,,Machine Code Insertions}
10128
10129 @node Attribute Asm_Output,Attribute Atomic_Always_Lock_Free,Attribute Asm_Input,Implementation Defined Attributes
10130 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-output}@anchor{16a}
10131 @section Attribute Asm_Output
10132
10133
10134 @geindex Asm_Output
10135
10136 The @code{Asm_Output} attribute denotes a function that takes two
10137 parameters. The first is a string, the second is the name of a variable
10138 of the type designated by the attribute prefix. The first (string)
10139 argument is required to be a static expression and designates the
10140 constraint for the parameter (e.g., what kind of register is
10141 required). The second argument is the variable to be updated with the
10142 result. The possible values for constraint are the same as those used in
10143 the RTL, and are dependent on the configuration file used to build the
10144 GCC back end. If there are no output operands, then this argument may
10145 either be omitted, or explicitly given as @code{No_Output_Operands}.
10146 @ref{169,,Machine Code Insertions}
10147
10148 @node Attribute Atomic_Always_Lock_Free,Attribute Bit,Attribute Asm_Output,Implementation Defined Attributes
10149 @anchor{gnat_rm/implementation_defined_attributes attribute-atomic-always-lock-free}@anchor{16b}
10150 @section Attribute Atomic_Always_Lock_Free
10151
10152
10153 @geindex Atomic_Always_Lock_Free
10154
10155 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
10156 The result is a Boolean value which is True if the type has discriminants,
10157 and False otherwise. The result indicate whether atomic operations are
10158 supported by the target for the given type.
10159
10160 @node Attribute Bit,Attribute Bit_Position,Attribute Atomic_Always_Lock_Free,Implementation Defined Attributes
10161 @anchor{gnat_rm/implementation_defined_attributes attribute-bit}@anchor{16c}
10162 @section Attribute Bit
10163
10164
10165 @geindex Bit
10166
10167 @code{obj'Bit}, where @code{obj} is any object, yields the bit
10168 offset within the storage unit (byte) that contains the first bit of
10169 storage allocated for the object. The value of this attribute is of the
10170 type @emph{universal_integer} and is always a nonnegative number smaller
10171 than @code{System.Storage_Unit}.
10172
10173 For an object that is a variable or a constant allocated in a register,
10174 the value is zero. (The use of this attribute does not force the
10175 allocation of a variable to memory).
10176
10177 For an object that is a formal parameter, this attribute applies
10178 to either the matching actual parameter or to a copy of the
10179 matching actual parameter.
10180
10181 For an access object the value is zero. Note that
10182 @code{obj.all'Bit} is subject to an @code{Access_Check} for the
10183 designated object. Similarly for a record component
10184 @code{X.C'Bit} is subject to a discriminant check and
10185 @code{X(I).Bit} and @code{X(I1..I2)'Bit}
10186 are subject to index checks.
10187
10188 This attribute is designed to be compatible with the DEC Ada 83 definition
10189 and implementation of the @code{Bit} attribute.
10190
10191 @node Attribute Bit_Position,Attribute Code_Address,Attribute Bit,Implementation Defined Attributes
10192 @anchor{gnat_rm/implementation_defined_attributes attribute-bit-position}@anchor{16d}
10193 @section Attribute Bit_Position
10194
10195
10196 @geindex Bit_Position
10197
10198 @code{R.C'Bit_Position}, where @code{R} is a record object and @code{C} is one
10199 of the fields of the record type, yields the bit
10200 offset within the record contains the first bit of
10201 storage allocated for the object. The value of this attribute is of the
10202 type @emph{universal_integer}. The value depends only on the field
10203 @code{C} and is independent of the alignment of
10204 the containing record @code{R}.
10205
10206 @node Attribute Code_Address,Attribute Compiler_Version,Attribute Bit_Position,Implementation Defined Attributes
10207 @anchor{gnat_rm/implementation_defined_attributes attribute-code-address}@anchor{16e}
10208 @section Attribute Code_Address
10209
10210
10211 @geindex Code_Address
10212
10213 @geindex Subprogram address
10214
10215 @geindex Address of subprogram code
10216
10217 The @code{'Address}
10218 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
10219 intended effect seems to be to provide
10220 an address value which can be used to call the subprogram by means of
10221 an address clause as in the following example:
10222
10223 @example
10224 procedure K is ...
10225
10226 procedure L;
10227 for L'Address use K'Address;
10228 pragma Import (Ada, L);
10229 @end example
10230
10231 A call to @code{L} is then expected to result in a call to @code{K}.
10232 In Ada 83, where there were no access-to-subprogram values, this was
10233 a common work-around for getting the effect of an indirect call.
10234 GNAT implements the above use of @code{Address} and the technique
10235 illustrated by the example code works correctly.
10236
10237 However, for some purposes, it is useful to have the address of the start
10238 of the generated code for the subprogram. On some architectures, this is
10239 not necessarily the same as the @code{Address} value described above.
10240 For example, the @code{Address} value may reference a subprogram
10241 descriptor rather than the subprogram itself.
10242
10243 The @code{'Code_Address} attribute, which can only be applied to
10244 subprogram entities, always returns the address of the start of the
10245 generated code of the specified subprogram, which may or may not be
10246 the same value as is returned by the corresponding @code{'Address}
10247 attribute.
10248
10249 @node Attribute Compiler_Version,Attribute Constrained,Attribute Code_Address,Implementation Defined Attributes
10250 @anchor{gnat_rm/implementation_defined_attributes attribute-compiler-version}@anchor{16f}
10251 @section Attribute Compiler_Version
10252
10253
10254 @geindex Compiler_Version
10255
10256 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
10257 prefix) yields a static string identifying the version of the compiler
10258 being used to compile the unit containing the attribute reference.
10259
10260 @node Attribute Constrained,Attribute Default_Bit_Order,Attribute Compiler_Version,Implementation Defined Attributes
10261 @anchor{gnat_rm/implementation_defined_attributes attribute-constrained}@anchor{170}
10262 @section Attribute Constrained
10263
10264
10265 @geindex Constrained
10266
10267 In addition to the usage of this attribute in the Ada RM, GNAT
10268 also permits the use of the @code{'Constrained} attribute
10269 in a generic template
10270 for any type, including types without discriminants. The value of this
10271 attribute in the generic instance when applied to a scalar type or a
10272 record type without discriminants is always @code{True}. This usage is
10273 compatible with older Ada compilers, including notably DEC Ada.
10274
10275 @node Attribute Default_Bit_Order,Attribute Default_Scalar_Storage_Order,Attribute Constrained,Implementation Defined Attributes
10276 @anchor{gnat_rm/implementation_defined_attributes attribute-default-bit-order}@anchor{171}
10277 @section Attribute Default_Bit_Order
10278
10279
10280 @geindex Big endian
10281
10282 @geindex Little endian
10283
10284 @geindex Default_Bit_Order
10285
10286 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
10287 permissible prefix), provides the value @code{System.Default_Bit_Order}
10288 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
10289 @code{Low_Order_First}). This is used to construct the definition of
10290 @code{Default_Bit_Order} in package @code{System}.
10291
10292 @node Attribute Default_Scalar_Storage_Order,Attribute Deref,Attribute Default_Bit_Order,Implementation Defined Attributes
10293 @anchor{gnat_rm/implementation_defined_attributes attribute-default-scalar-storage-order}@anchor{172}
10294 @section Attribute Default_Scalar_Storage_Order
10295
10296
10297 @geindex Big endian
10298
10299 @geindex Little endian
10300
10301 @geindex Default_Scalar_Storage_Order
10302
10303 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
10304 permissible prefix), provides the current value of the default scalar storage
10305 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
10306 equal to @code{Default_Bit_Order} if unspecified) as a
10307 @code{System.Bit_Order} value. This is a static attribute.
10308
10309 @node Attribute Deref,Attribute Descriptor_Size,Attribute Default_Scalar_Storage_Order,Implementation Defined Attributes
10310 @anchor{gnat_rm/implementation_defined_attributes attribute-deref}@anchor{173}
10311 @section Attribute Deref
10312
10313
10314 @geindex Deref
10315
10316 The attribute @code{typ'Deref(expr)} where @code{expr} is of type @code{System.Address} yields
10317 the variable of type @code{typ} that is located at the given address. It is similar
10318 to @code{(totyp (expr).all)}, where @code{totyp} is an unchecked conversion from address to
10319 a named access-to-@cite{typ} type, except that it yields a variable, so it can be
10320 used on the left side of an assignment.
10321
10322 @node Attribute Descriptor_Size,Attribute Elaborated,Attribute Deref,Implementation Defined Attributes
10323 @anchor{gnat_rm/implementation_defined_attributes attribute-descriptor-size}@anchor{174}
10324 @section Attribute Descriptor_Size
10325
10326
10327 @geindex Descriptor
10328
10329 @geindex Dope vector
10330
10331 @geindex Descriptor_Size
10332
10333 Nonstatic attribute @code{Descriptor_Size} returns the size in bits of the
10334 descriptor allocated for a type. The result is non-zero only for unconstrained
10335 array types and the returned value is of type universal integer. In GNAT, an
10336 array descriptor contains bounds information and is located immediately before
10337 the first element of the array.
10338
10339 @example
10340 type Unconstr_Array is array (Short_Short_Integer range <>) of Positive;
10341 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
10342 @end example
10343
10344 The attribute takes into account any padding due to the alignment of the
10345 component type. In the example above, the descriptor contains two values
10346 of type @code{Short_Short_Integer} representing the low and high bound. But,
10347 since @code{Positive} has an alignment of 4, the size of the descriptor is
10348 @code{2 * Short_Short_Integer'Size} rounded up to the next multiple of 32,
10349 which yields a size of 32 bits, i.e. including 16 bits of padding.
10350
10351 @node Attribute Elaborated,Attribute Elab_Body,Attribute Descriptor_Size,Implementation Defined Attributes
10352 @anchor{gnat_rm/implementation_defined_attributes attribute-elaborated}@anchor{175}
10353 @section Attribute Elaborated
10354
10355
10356 @geindex Elaborated
10357
10358 The prefix of the @code{'Elaborated} attribute must be a unit name. The
10359 value is a Boolean which indicates whether or not the given unit has been
10360 elaborated. This attribute is primarily intended for internal use by the
10361 generated code for dynamic elaboration checking, but it can also be used
10362 in user programs. The value will always be True once elaboration of all
10363 units has been completed. An exception is for units which need no
10364 elaboration, the value is always False for such units.
10365
10366 @node Attribute Elab_Body,Attribute Elab_Spec,Attribute Elaborated,Implementation Defined Attributes
10367 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-body}@anchor{176}
10368 @section Attribute Elab_Body
10369
10370
10371 @geindex Elab_Body
10372
10373 This attribute can only be applied to a program unit name. It returns
10374 the entity for the corresponding elaboration procedure for elaborating
10375 the body of the referenced unit. This is used in the main generated
10376 elaboration procedure by the binder and is not normally used in any
10377 other context. However, there may be specialized situations in which it
10378 is useful to be able to call this elaboration procedure from Ada code,
10379 e.g., if it is necessary to do selective re-elaboration to fix some
10380 error.
10381
10382 @node Attribute Elab_Spec,Attribute Elab_Subp_Body,Attribute Elab_Body,Implementation Defined Attributes
10383 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-spec}@anchor{177}
10384 @section Attribute Elab_Spec
10385
10386
10387 @geindex Elab_Spec
10388
10389 This attribute can only be applied to a program unit name. It returns
10390 the entity for the corresponding elaboration procedure for elaborating
10391 the spec of the referenced unit. This is used in the main
10392 generated elaboration procedure by the binder and is not normally used
10393 in any other context. However, there may be specialized situations in
10394 which it is useful to be able to call this elaboration procedure from
10395 Ada code, e.g., if it is necessary to do selective re-elaboration to fix
10396 some error.
10397
10398 @node Attribute Elab_Subp_Body,Attribute Emax,Attribute Elab_Spec,Implementation Defined Attributes
10399 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-subp-body}@anchor{178}
10400 @section Attribute Elab_Subp_Body
10401
10402
10403 @geindex Elab_Subp_Body
10404
10405 This attribute can only be applied to a library level subprogram
10406 name and is only allowed in CodePeer mode. It returns the entity
10407 for the corresponding elaboration procedure for elaborating the body
10408 of the referenced subprogram unit. This is used in the main generated
10409 elaboration procedure by the binder in CodePeer mode only and is unrecognized
10410 otherwise.
10411
10412 @node Attribute Emax,Attribute Enabled,Attribute Elab_Subp_Body,Implementation Defined Attributes
10413 @anchor{gnat_rm/implementation_defined_attributes attribute-emax}@anchor{179}
10414 @section Attribute Emax
10415
10416
10417 @geindex Ada 83 attributes
10418
10419 @geindex Emax
10420
10421 The @code{Emax} attribute is provided for compatibility with Ada 83. See
10422 the Ada 83 reference manual for an exact description of the semantics of
10423 this attribute.
10424
10425 @node Attribute Enabled,Attribute Enum_Rep,Attribute Emax,Implementation Defined Attributes
10426 @anchor{gnat_rm/implementation_defined_attributes attribute-enabled}@anchor{17a}
10427 @section Attribute Enabled
10428
10429
10430 @geindex Enabled
10431
10432 The @code{Enabled} attribute allows an application program to check at compile
10433 time to see if the designated check is currently enabled. The prefix is a
10434 simple identifier, referencing any predefined check name (other than
10435 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
10436 no argument is given for the attribute, the check is for the general state
10437 of the check, if an argument is given, then it is an entity name, and the
10438 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
10439 given naming the entity (if not, then the argument is ignored).
10440
10441 Note that instantiations inherit the check status at the point of the
10442 instantiation, so a useful idiom is to have a library package that
10443 introduces a check name with @code{pragma Check_Name}, and then contains
10444 generic packages or subprograms which use the @code{Enabled} attribute
10445 to see if the check is enabled. A user of this package can then issue
10446 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
10447 the package or subprogram, controlling whether the check will be present.
10448
10449 @node Attribute Enum_Rep,Attribute Enum_Val,Attribute Enabled,Implementation Defined Attributes
10450 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-rep}@anchor{17b}
10451 @section Attribute Enum_Rep
10452
10453
10454 @geindex Representation of enums
10455
10456 @geindex Enum_Rep
10457
10458 Note that this attribute is now standard in Ada 202x and is available
10459 as an implementation defined attribute for earlier Ada versions.
10460
10461 For every enumeration subtype @code{S}, @code{S'Enum_Rep} denotes a
10462 function with the following spec:
10463
10464 @example
10465 function S'Enum_Rep (Arg : S'Base) return <Universal_Integer>;
10466 @end example
10467
10468 It is also allowable to apply @code{Enum_Rep} directly to an object of an
10469 enumeration type or to a non-overloaded enumeration
10470 literal. In this case @code{S'Enum_Rep} is equivalent to
10471 @code{typ'Enum_Rep(S)} where @code{typ} is the type of the
10472 enumeration literal or object.
10473
10474 The function returns the representation value for the given enumeration
10475 value. This will be equal to value of the @code{Pos} attribute in the
10476 absence of an enumeration representation clause. This is a static
10477 attribute (i.e., the result is static if the argument is static).
10478
10479 @code{S'Enum_Rep} can also be used with integer types and objects,
10480 in which case it simply returns the integer value. The reason for this
10481 is to allow it to be used for @code{(<>)} discrete formal arguments in
10482 a generic unit that can be instantiated with either enumeration types
10483 or integer types. Note that if @code{Enum_Rep} is used on a modular
10484 type whose upper bound exceeds the upper bound of the largest signed
10485 integer type, and the argument is a variable, so that the universal
10486 integer calculation is done at run time, then the call to @code{Enum_Rep}
10487 may raise @code{Constraint_Error}.
10488
10489 @node Attribute Enum_Val,Attribute Epsilon,Attribute Enum_Rep,Implementation Defined Attributes
10490 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-val}@anchor{17c}
10491 @section Attribute Enum_Val
10492
10493
10494 @geindex Representation of enums
10495
10496 @geindex Enum_Val
10497
10498 Note that this attribute is now standard in Ada 202x and is available
10499 as an implementation defined attribute for earlier Ada versions.
10500
10501 For every enumeration subtype @code{S}, @code{S'Enum_Val} denotes a
10502 function with the following spec:
10503
10504 @example
10505 function S'Enum_Val (Arg : <Universal_Integer>) return S'Base;
10506 @end example
10507
10508 The function returns the enumeration value whose representation matches the
10509 argument, or raises Constraint_Error if no enumeration literal of the type
10510 has the matching value.
10511 This will be equal to value of the @code{Val} attribute in the
10512 absence of an enumeration representation clause. This is a static
10513 attribute (i.e., the result is static if the argument is static).
10514
10515 @node Attribute Epsilon,Attribute Fast_Math,Attribute Enum_Val,Implementation Defined Attributes
10516 @anchor{gnat_rm/implementation_defined_attributes attribute-epsilon}@anchor{17d}
10517 @section Attribute Epsilon
10518
10519
10520 @geindex Ada 83 attributes
10521
10522 @geindex Epsilon
10523
10524 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
10525 the Ada 83 reference manual for an exact description of the semantics of
10526 this attribute.
10527
10528 @node Attribute Fast_Math,Attribute Finalization_Size,Attribute Epsilon,Implementation Defined Attributes
10529 @anchor{gnat_rm/implementation_defined_attributes attribute-fast-math}@anchor{17e}
10530 @section Attribute Fast_Math
10531
10532
10533 @geindex Fast_Math
10534
10535 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
10536 prefix) yields a static Boolean value that is True if pragma
10537 @code{Fast_Math} is active, and False otherwise.
10538
10539 @node Attribute Finalization_Size,Attribute Fixed_Value,Attribute Fast_Math,Implementation Defined Attributes
10540 @anchor{gnat_rm/implementation_defined_attributes attribute-finalization-size}@anchor{17f}
10541 @section Attribute Finalization_Size
10542
10543
10544 @geindex Finalization_Size
10545
10546 The prefix of attribute @code{Finalization_Size} must be an object or
10547 a non-class-wide type. This attribute returns the size of any hidden data
10548 reserved by the compiler to handle finalization-related actions. The type of
10549 the attribute is @emph{universal_integer}.
10550
10551 @code{Finalization_Size} yields a value of zero for a type with no controlled
10552 parts, an object whose type has no controlled parts, or an object of a
10553 class-wide type whose tag denotes a type with no controlled parts.
10554
10555 Note that only heap-allocated objects contain finalization data.
10556
10557 @node Attribute Fixed_Value,Attribute From_Any,Attribute Finalization_Size,Implementation Defined Attributes
10558 @anchor{gnat_rm/implementation_defined_attributes attribute-fixed-value}@anchor{180}
10559 @section Attribute Fixed_Value
10560
10561
10562 @geindex Fixed_Value
10563
10564 For every fixed-point type @code{S}, @code{S'Fixed_Value} denotes a
10565 function with the following specification:
10566
10567 @example
10568 function S'Fixed_Value (Arg : <Universal_Integer>) return S;
10569 @end example
10570
10571 The value returned is the fixed-point value @code{V} such that:
10572
10573 @example
10574 V = Arg * S'Small
10575 @end example
10576
10577 The effect is thus similar to first converting the argument to the
10578 integer type used to represent @code{S}, and then doing an unchecked
10579 conversion to the fixed-point type. The difference is
10580 that there are full range checks, to ensure that the result is in range.
10581 This attribute is primarily intended for use in implementation of the
10582 input-output functions for fixed-point values.
10583
10584 @node Attribute From_Any,Attribute Has_Access_Values,Attribute Fixed_Value,Implementation Defined Attributes
10585 @anchor{gnat_rm/implementation_defined_attributes attribute-from-any}@anchor{181}
10586 @section Attribute From_Any
10587
10588
10589 @geindex From_Any
10590
10591 This internal attribute is used for the generation of remote subprogram
10592 stubs in the context of the Distributed Systems Annex.
10593
10594 @node Attribute Has_Access_Values,Attribute Has_Discriminants,Attribute From_Any,Implementation Defined Attributes
10595 @anchor{gnat_rm/implementation_defined_attributes attribute-has-access-values}@anchor{182}
10596 @section Attribute Has_Access_Values
10597
10598
10599 @geindex Access values
10600 @geindex testing for
10601
10602 @geindex Has_Access_Values
10603
10604 The prefix of the @code{Has_Access_Values} attribute is a type. The result
10605 is a Boolean value which is True if the is an access type, or is a composite
10606 type with a component (at any nesting depth) that is an access type, and is
10607 False otherwise.
10608 The intended use of this attribute is in conjunction with generic
10609 definitions. If the attribute is applied to a generic private type, it
10610 indicates whether or not the corresponding actual type has access values.
10611
10612 @node Attribute Has_Discriminants,Attribute Img,Attribute Has_Access_Values,Implementation Defined Attributes
10613 @anchor{gnat_rm/implementation_defined_attributes attribute-has-discriminants}@anchor{183}
10614 @section Attribute Has_Discriminants
10615
10616
10617 @geindex Discriminants
10618 @geindex testing for
10619
10620 @geindex Has_Discriminants
10621
10622 The prefix of the @code{Has_Discriminants} attribute is a type. The result
10623 is a Boolean value which is True if the type has discriminants, and False
10624 otherwise. The intended use of this attribute is in conjunction with generic
10625 definitions. If the attribute is applied to a generic private type, it
10626 indicates whether or not the corresponding actual type has discriminants.
10627
10628 @node Attribute Img,Attribute Initialized,Attribute Has_Discriminants,Implementation Defined Attributes
10629 @anchor{gnat_rm/implementation_defined_attributes attribute-img}@anchor{184}
10630 @section Attribute Img
10631
10632
10633 @geindex Img
10634
10635 The @code{Img} attribute differs from @code{Image} in that, while both can be
10636 applied directly to an object, @code{Img} cannot be applied to types.
10637
10638 Example usage of the attribute:
10639
10640 @example
10641 Put_Line ("X = " & X'Img);
10642 @end example
10643
10644 which has the same meaning as the more verbose:
10645
10646 @example
10647 Put_Line ("X = " & T'Image (X));
10648 @end example
10649
10650 where @code{T} is the (sub)type of the object @code{X}.
10651
10652 Note that technically, in analogy to @code{Image},
10653 @code{X'Img} returns a parameterless function
10654 that returns the appropriate string when called. This means that
10655 @code{X'Img} can be renamed as a function-returning-string, or used
10656 in an instantiation as a function parameter.
10657
10658 @node Attribute Initialized,Attribute Integer_Value,Attribute Img,Implementation Defined Attributes
10659 @anchor{gnat_rm/implementation_defined_attributes attribute-initialized}@anchor{185}
10660 @section Attribute Initialized
10661
10662
10663 @geindex Initialized
10664
10665 For the syntax and semantics of this attribute, see the SPARK 2014 Reference
10666 Manual, section 6.10.
10667
10668 @node Attribute Integer_Value,Attribute Invalid_Value,Attribute Initialized,Implementation Defined Attributes
10669 @anchor{gnat_rm/implementation_defined_attributes attribute-integer-value}@anchor{186}
10670 @section Attribute Integer_Value
10671
10672
10673 @geindex Integer_Value
10674
10675 For every integer type @code{S}, @code{S'Integer_Value} denotes a
10676 function with the following spec:
10677
10678 @example
10679 function S'Integer_Value (Arg : <Universal_Fixed>) return S;
10680 @end example
10681
10682 The value returned is the integer value @code{V}, such that:
10683
10684 @example
10685 Arg = V * T'Small
10686 @end example
10687
10688 where @code{T} is the type of @code{Arg}.
10689 The effect is thus similar to first doing an unchecked conversion from
10690 the fixed-point type to its corresponding implementation type, and then
10691 converting the result to the target integer type. The difference is
10692 that there are full range checks, to ensure that the result is in range.
10693 This attribute is primarily intended for use in implementation of the
10694 standard input-output functions for fixed-point values.
10695
10696 @node Attribute Invalid_Value,Attribute Iterable,Attribute Integer_Value,Implementation Defined Attributes
10697 @anchor{gnat_rm/implementation_defined_attributes attribute-invalid-value}@anchor{187}
10698 @section Attribute Invalid_Value
10699
10700
10701 @geindex Invalid_Value
10702
10703 For every scalar type S, S'Invalid_Value returns an undefined value of the
10704 type. If possible this value is an invalid representation for the type. The
10705 value returned is identical to the value used to initialize an otherwise
10706 uninitialized value of the type if pragma Initialize_Scalars is used,
10707 including the ability to modify the value with the binder -Sxx flag and
10708 relevant environment variables at run time.
10709
10710 @node Attribute Iterable,Attribute Large,Attribute Invalid_Value,Implementation Defined Attributes
10711 @anchor{gnat_rm/implementation_defined_attributes attribute-iterable}@anchor{188}
10712 @section Attribute Iterable
10713
10714
10715 @geindex Iterable
10716
10717 Equivalent to Aspect Iterable.
10718
10719 @node Attribute Large,Attribute Library_Level,Attribute Iterable,Implementation Defined Attributes
10720 @anchor{gnat_rm/implementation_defined_attributes attribute-large}@anchor{189}
10721 @section Attribute Large
10722
10723
10724 @geindex Ada 83 attributes
10725
10726 @geindex Large
10727
10728 The @code{Large} attribute is provided for compatibility with Ada 83. See
10729 the Ada 83 reference manual for an exact description of the semantics of
10730 this attribute.
10731
10732 @node Attribute Library_Level,Attribute Lock_Free,Attribute Large,Implementation Defined Attributes
10733 @anchor{gnat_rm/implementation_defined_attributes attribute-library-level}@anchor{18a}
10734 @section Attribute Library_Level
10735
10736
10737 @geindex Library_Level
10738
10739 @code{P'Library_Level}, where P is an entity name,
10740 returns a Boolean value which is True if the entity is declared
10741 at the library level, and False otherwise. Note that within a
10742 generic instantition, the name of the generic unit denotes the
10743 instance, which means that this attribute can be used to test
10744 if a generic is instantiated at the library level, as shown
10745 in this example:
10746
10747 @example
10748 generic
10749 ...
10750 package Gen is
10751 pragma Compile_Time_Error
10752 (not Gen'Library_Level,
10753 "Gen can only be instantiated at library level");
10754 ...
10755 end Gen;
10756 @end example
10757
10758 @node Attribute Lock_Free,Attribute Loop_Entry,Attribute Library_Level,Implementation Defined Attributes
10759 @anchor{gnat_rm/implementation_defined_attributes attribute-lock-free}@anchor{18b}
10760 @section Attribute Lock_Free
10761
10762
10763 @geindex Lock_Free
10764
10765 @code{P'Lock_Free}, where P is a protected object, returns True if a
10766 pragma @code{Lock_Free} applies to P.
10767
10768 @node Attribute Loop_Entry,Attribute Machine_Size,Attribute Lock_Free,Implementation Defined Attributes
10769 @anchor{gnat_rm/implementation_defined_attributes attribute-loop-entry}@anchor{18c}
10770 @section Attribute Loop_Entry
10771
10772
10773 @geindex Loop_Entry
10774
10775 Syntax:
10776
10777 @example
10778 X'Loop_Entry [(loop_name)]
10779 @end example
10780
10781 The @code{Loop_Entry} attribute is used to refer to the value that an
10782 expression had upon entry to a given loop in much the same way that the
10783 @code{Old} attribute in a subprogram postcondition can be used to refer
10784 to the value an expression had upon entry to the subprogram. The
10785 relevant loop is either identified by the given loop name, or it is the
10786 innermost enclosing loop when no loop name is given.
10787
10788 A @code{Loop_Entry} attribute can only occur within a
10789 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
10790 @code{Loop_Entry} is to compare the current value of objects with their
10791 initial value at loop entry, in a @code{Loop_Invariant} pragma.
10792
10793 The effect of using @code{X'Loop_Entry} is the same as declaring
10794 a constant initialized with the initial value of @code{X} at loop
10795 entry. This copy is not performed if the loop is not entered, or if the
10796 corresponding pragmas are ignored or disabled.
10797
10798 @node Attribute Machine_Size,Attribute Mantissa,Attribute Loop_Entry,Implementation Defined Attributes
10799 @anchor{gnat_rm/implementation_defined_attributes attribute-machine-size}@anchor{18d}
10800 @section Attribute Machine_Size
10801
10802
10803 @geindex Machine_Size
10804
10805 This attribute is identical to the @code{Object_Size} attribute. It is
10806 provided for compatibility with the DEC Ada 83 attribute of this name.
10807
10808 @node Attribute Mantissa,Attribute Maximum_Alignment,Attribute Machine_Size,Implementation Defined Attributes
10809 @anchor{gnat_rm/implementation_defined_attributes attribute-mantissa}@anchor{18e}
10810 @section Attribute Mantissa
10811
10812
10813 @geindex Ada 83 attributes
10814
10815 @geindex Mantissa
10816
10817 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
10818 the Ada 83 reference manual for an exact description of the semantics of
10819 this attribute.
10820
10821 @node Attribute Maximum_Alignment,Attribute Max_Integer_Size,Attribute Mantissa,Implementation Defined Attributes
10822 @anchor{gnat_rm/implementation_defined_attributes attribute-maximum-alignment}@anchor{18f}@anchor{gnat_rm/implementation_defined_attributes id2}@anchor{190}
10823 @section Attribute Maximum_Alignment
10824
10825
10826 @geindex Alignment
10827 @geindex maximum
10828
10829 @geindex Maximum_Alignment
10830
10831 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
10832 permissible prefix) provides the maximum useful alignment value for the
10833 target. This is a static value that can be used to specify the alignment
10834 for an object, guaranteeing that it is properly aligned in all
10835 cases.
10836
10837 @node Attribute Max_Integer_Size,Attribute Mechanism_Code,Attribute Maximum_Alignment,Implementation Defined Attributes
10838 @anchor{gnat_rm/implementation_defined_attributes attribute-max-integer-size}@anchor{191}
10839 @section Attribute Max_Integer_Size
10840
10841
10842 @geindex Max_Integer_Size
10843
10844 @code{Standard'Max_Integer_Size} (@code{Standard} is the only permissible
10845 prefix) provides the size of the largest supported integer type for
10846 the target. The result is a static constant.
10847
10848 @node Attribute Mechanism_Code,Attribute Null_Parameter,Attribute Max_Integer_Size,Implementation Defined Attributes
10849 @anchor{gnat_rm/implementation_defined_attributes attribute-mechanism-code}@anchor{192}
10850 @section Attribute Mechanism_Code
10851
10852
10853 @geindex Return values
10854 @geindex passing mechanism
10855
10856 @geindex Parameters
10857 @geindex passing mechanism
10858
10859 @geindex Mechanism_Code
10860
10861 @code{func'Mechanism_Code} yields an integer code for the
10862 mechanism used for the result of function @code{func}, and
10863 @code{subprog'Mechanism_Code (n)} yields the mechanism
10864 used for formal parameter number @emph{n} (a static integer value, with 1
10865 meaning the first parameter) of subprogram @code{subprog}. The code returned is:
10866
10867
10868 @table @asis
10869
10870 @item @emph{1}
10871
10872 by copy (value)
10873
10874 @item @emph{2}
10875
10876 by reference
10877 @end table
10878
10879 @node Attribute Null_Parameter,Attribute Object_Size,Attribute Mechanism_Code,Implementation Defined Attributes
10880 @anchor{gnat_rm/implementation_defined_attributes attribute-null-parameter}@anchor{193}
10881 @section Attribute Null_Parameter
10882
10883
10884 @geindex Zero address
10885 @geindex passing
10886
10887 @geindex Null_Parameter
10888
10889 A reference @code{T'Null_Parameter} denotes an imaginary object of
10890 type or subtype @code{T} allocated at machine address zero. The attribute
10891 is allowed only as the default expression of a formal parameter, or as
10892 an actual expression of a subprogram call. In either case, the
10893 subprogram must be imported.
10894
10895 The identity of the object is represented by the address zero in the
10896 argument list, independent of the passing mechanism (explicit or
10897 default).
10898
10899 This capability is needed to specify that a zero address should be
10900 passed for a record or other composite object passed by reference.
10901 There is no way of indicating this without the @code{Null_Parameter}
10902 attribute.
10903
10904 @node Attribute Object_Size,Attribute Old,Attribute Null_Parameter,Implementation Defined Attributes
10905 @anchor{gnat_rm/implementation_defined_attributes attribute-object-size}@anchor{143}@anchor{gnat_rm/implementation_defined_attributes id3}@anchor{194}
10906 @section Attribute Object_Size
10907
10908
10909 @geindex Size
10910 @geindex used for objects
10911
10912 @geindex Object_Size
10913
10914 The size of an object is not necessarily the same as the size of the type
10915 of an object. This is because by default object sizes are increased to be
10916 a multiple of the alignment of the object. For example,
10917 @code{Natural'Size} is
10918 31, but by default objects of type @code{Natural} will have a size of 32 bits.
10919 Similarly, a record containing an integer and a character:
10920
10921 @example
10922 type Rec is record
10923 I : Integer;
10924 C : Character;
10925 end record;
10926 @end example
10927
10928 will have a size of 40 (that is @code{Rec'Size} will be 40). The
10929 alignment will be 4, because of the
10930 integer field, and so the default size of record objects for this type
10931 will be 64 (8 bytes).
10932
10933 If the alignment of the above record is specified to be 1, then the
10934 object size will be 40 (5 bytes). This is true by default, and also
10935 an object size of 40 can be explicitly specified in this case.
10936
10937 A consequence of this capability is that different object sizes can be
10938 given to subtypes that would otherwise be considered in Ada to be
10939 statically matching. But it makes no sense to consider such subtypes
10940 as statically matching. Consequently, GNAT adds a rule
10941 to the static matching rules that requires object sizes to match.
10942 Consider this example:
10943
10944 @example
10945 1. procedure BadAVConvert is
10946 2. type R is new Integer;
10947 3. subtype R1 is R range 1 .. 10;
10948 4. subtype R2 is R range 1 .. 10;
10949 5. for R1'Object_Size use 8;
10950 6. for R2'Object_Size use 16;
10951 7. type R1P is access all R1;
10952 8. type R2P is access all R2;
10953 9. R1PV : R1P := new R1'(4);
10954 10. R2PV : R2P;
10955 11. begin
10956 12. R2PV := R2P (R1PV);
10957 |
10958 >>> target designated subtype not compatible with
10959 type "R1" defined at line 3
10960
10961 13. end;
10962 @end example
10963
10964 In the absence of lines 5 and 6,
10965 types @code{R1} and @code{R2} statically match and
10966 hence the conversion on line 12 is legal. But since lines 5 and 6
10967 cause the object sizes to differ, GNAT considers that types
10968 @code{R1} and @code{R2} are not statically matching, and line 12
10969 generates the diagnostic shown above.
10970
10971 Similar additional checks are performed in other contexts requiring
10972 statically matching subtypes.
10973
10974 @node Attribute Old,Attribute Passed_By_Reference,Attribute Object_Size,Implementation Defined Attributes
10975 @anchor{gnat_rm/implementation_defined_attributes attribute-old}@anchor{195}
10976 @section Attribute Old
10977
10978
10979 @geindex Old
10980
10981 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
10982 within @code{Post} aspect), GNAT also permits the use of this attribute
10983 in implementation defined pragmas @code{Postcondition},
10984 @code{Contract_Cases} and @code{Test_Case}. Also usages of
10985 @code{Old} which would be illegal according to the Ada 2012 RM
10986 definition are allowed under control of
10987 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
10988
10989 @node Attribute Passed_By_Reference,Attribute Pool_Address,Attribute Old,Implementation Defined Attributes
10990 @anchor{gnat_rm/implementation_defined_attributes attribute-passed-by-reference}@anchor{196}
10991 @section Attribute Passed_By_Reference
10992
10993
10994 @geindex Parameters
10995 @geindex when passed by reference
10996
10997 @geindex Passed_By_Reference
10998
10999 @code{typ'Passed_By_Reference} for any subtype @cite{typ} returns
11000 a value of type @code{Boolean} value that is @code{True} if the type is
11001 normally passed by reference and @code{False} if the type is normally
11002 passed by copy in calls. For scalar types, the result is always @code{False}
11003 and is static. For non-scalar types, the result is nonstatic.
11004
11005 @node Attribute Pool_Address,Attribute Range_Length,Attribute Passed_By_Reference,Implementation Defined Attributes
11006 @anchor{gnat_rm/implementation_defined_attributes attribute-pool-address}@anchor{197}
11007 @section Attribute Pool_Address
11008
11009
11010 @geindex Parameters
11011 @geindex when passed by reference
11012
11013 @geindex Pool_Address
11014
11015 @code{X'Pool_Address} for any object @code{X} returns the address
11016 of X within its storage pool. This is the same as
11017 @code{X'Address}, except that for an unconstrained array whose
11018 bounds are allocated just before the first component,
11019 @code{X'Pool_Address} returns the address of those bounds,
11020 whereas @code{X'Address} returns the address of the first
11021 component.
11022
11023 Here, we are interpreting 'storage pool' broadly to mean
11024 @code{wherever the object is allocated}, which could be a
11025 user-defined storage pool,
11026 the global heap, on the stack, or in a static memory area.
11027 For an object created by @code{new}, @code{Ptr.all'Pool_Address} is
11028 what is passed to @code{Allocate} and returned from @code{Deallocate}.
11029
11030 @node Attribute Range_Length,Attribute Restriction_Set,Attribute Pool_Address,Implementation Defined Attributes
11031 @anchor{gnat_rm/implementation_defined_attributes attribute-range-length}@anchor{198}
11032 @section Attribute Range_Length
11033
11034
11035 @geindex Range_Length
11036
11037 @code{typ'Range_Length} for any discrete type @cite{typ} yields
11038 the number of values represented by the subtype (zero for a null
11039 range). The result is static for static subtypes. @code{Range_Length}
11040 applied to the index subtype of a one dimensional array always gives the
11041 same result as @code{Length} applied to the array itself.
11042
11043 @node Attribute Restriction_Set,Attribute Result,Attribute Range_Length,Implementation Defined Attributes
11044 @anchor{gnat_rm/implementation_defined_attributes attribute-restriction-set}@anchor{199}
11045 @section Attribute Restriction_Set
11046
11047
11048 @geindex Restriction_Set
11049
11050 @geindex Restrictions
11051
11052 This attribute allows compile time testing of restrictions that
11053 are currently in effect. It is primarily intended for specializing
11054 code in the run-time based on restrictions that are active (e.g.
11055 don't need to save fpt registers if restriction No_Floating_Point
11056 is known to be in effect), but can be used anywhere.
11057
11058 There are two forms:
11059
11060 @example
11061 System'Restriction_Set (partition_boolean_restriction_NAME)
11062 System'Restriction_Set (No_Dependence => library_unit_NAME);
11063 @end example
11064
11065 In the case of the first form, the only restriction names
11066 allowed are parameterless restrictions that are checked
11067 for consistency at bind time. For a complete list see the
11068 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
11069
11070 The result returned is True if the restriction is known to
11071 be in effect, and False if the restriction is known not to
11072 be in effect. An important guarantee is that the value of
11073 a Restriction_Set attribute is known to be consistent throughout
11074 all the code of a partition.
11075
11076 This is trivially achieved if the entire partition is compiled
11077 with a consistent set of restriction pragmas. However, the
11078 compilation model does not require this. It is possible to
11079 compile one set of units with one set of pragmas, and another
11080 set of units with another set of pragmas. It is even possible
11081 to compile a spec with one set of pragmas, and then WITH the
11082 same spec with a different set of pragmas. Inconsistencies
11083 in the actual use of the restriction are checked at bind time.
11084
11085 In order to achieve the guarantee of consistency for the
11086 Restriction_Set pragma, we consider that a use of the pragma
11087 that yields False is equivalent to a violation of the
11088 restriction.
11089
11090 So for example if you write
11091
11092 @example
11093 if System'Restriction_Set (No_Floating_Point) then
11094 ...
11095 else
11096 ...
11097 end if;
11098 @end example
11099
11100 And the result is False, so that the else branch is executed,
11101 you can assume that this restriction is not set for any unit
11102 in the partition. This is checked by considering this use of
11103 the restriction pragma to be a violation of the restriction
11104 No_Floating_Point. This means that no other unit can attempt
11105 to set this restriction (if some unit does attempt to set it,
11106 the binder will refuse to bind the partition).
11107
11108 Technical note: The restriction name and the unit name are
11109 intepreted entirely syntactically, as in the corresponding
11110 Restrictions pragma, they are not analyzed semantically,
11111 so they do not have a type.
11112
11113 @node Attribute Result,Attribute Safe_Emax,Attribute Restriction_Set,Implementation Defined Attributes
11114 @anchor{gnat_rm/implementation_defined_attributes attribute-result}@anchor{19a}
11115 @section Attribute Result
11116
11117
11118 @geindex Result
11119
11120 @code{function'Result} can only be used with in a Postcondition pragma
11121 for a function. The prefix must be the name of the corresponding function. This
11122 is used to refer to the result of the function in the postcondition expression.
11123 For a further discussion of the use of this attribute and examples of its use,
11124 see the description of pragma Postcondition.
11125
11126 @node Attribute Safe_Emax,Attribute Safe_Large,Attribute Result,Implementation Defined Attributes
11127 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-emax}@anchor{19b}
11128 @section Attribute Safe_Emax
11129
11130
11131 @geindex Ada 83 attributes
11132
11133 @geindex Safe_Emax
11134
11135 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
11136 the Ada 83 reference manual for an exact description of the semantics of
11137 this attribute.
11138
11139 @node Attribute Safe_Large,Attribute Safe_Small,Attribute Safe_Emax,Implementation Defined Attributes
11140 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-large}@anchor{19c}
11141 @section Attribute Safe_Large
11142
11143
11144 @geindex Ada 83 attributes
11145
11146 @geindex Safe_Large
11147
11148 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
11149 the Ada 83 reference manual for an exact description of the semantics of
11150 this attribute.
11151
11152 @node Attribute Safe_Small,Attribute Scalar_Storage_Order,Attribute Safe_Large,Implementation Defined Attributes
11153 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-small}@anchor{19d}
11154 @section Attribute Safe_Small
11155
11156
11157 @geindex Ada 83 attributes
11158
11159 @geindex Safe_Small
11160
11161 The @code{Safe_Small} attribute is provided for compatibility with Ada 83. See
11162 the Ada 83 reference manual for an exact description of the semantics of
11163 this attribute.
11164
11165 @node Attribute Scalar_Storage_Order,Attribute Simple_Storage_Pool,Attribute Safe_Small,Implementation Defined Attributes
11166 @anchor{gnat_rm/implementation_defined_attributes id4}@anchor{19e}@anchor{gnat_rm/implementation_defined_attributes attribute-scalar-storage-order}@anchor{151}
11167 @section Attribute Scalar_Storage_Order
11168
11169
11170 @geindex Endianness
11171
11172 @geindex Scalar storage order
11173
11174 @geindex Scalar_Storage_Order
11175
11176 For every array or record type @code{S}, the representation attribute
11177 @code{Scalar_Storage_Order} denotes the order in which storage elements
11178 that make up scalar components are ordered within S. The value given must
11179 be a static expression of type System.Bit_Order. The following is an example
11180 of the use of this feature:
11181
11182 @example
11183 -- Component type definitions
11184
11185 subtype Yr_Type is Natural range 0 .. 127;
11186 subtype Mo_Type is Natural range 1 .. 12;
11187 subtype Da_Type is Natural range 1 .. 31;
11188
11189 -- Record declaration
11190
11191 type Date is record
11192 Years_Since_1980 : Yr_Type;
11193 Month : Mo_Type;
11194 Day_Of_Month : Da_Type;
11195 end record;
11196
11197 -- Record representation clause
11198
11199 for Date use record
11200 Years_Since_1980 at 0 range 0 .. 6;
11201 Month at 0 range 7 .. 10;
11202 Day_Of_Month at 0 range 11 .. 15;
11203 end record;
11204
11205 -- Attribute definition clauses
11206
11207 for Date'Bit_Order use System.High_Order_First;
11208 for Date'Scalar_Storage_Order use System.High_Order_First;
11209 -- If Scalar_Storage_Order is specified, it must be consistent with
11210 -- Bit_Order, so it's best to always define the latter explicitly if
11211 -- the former is used.
11212 @end example
11213
11214 Other properties are as for the standard representation attribute @code{Bit_Order}
11215 defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
11216
11217 For a record type @code{T}, if @code{T'Scalar_Storage_Order} is
11218 specified explicitly, it shall be equal to @code{T'Bit_Order}. Note:
11219 this means that if a @code{Scalar_Storage_Order} attribute definition
11220 clause is not confirming, then the type's @code{Bit_Order} shall be
11221 specified explicitly and set to the same value.
11222
11223 Derived types inherit an explicitly set scalar storage order from their parent
11224 types. This may be overridden for the derived type by giving an explicit scalar
11225 storage order for it. However, for a record extension, the derived type must
11226 have the same scalar storage order as the parent type.
11227
11228 A component of a record type that is itself a record or an array and that does
11229 not start and end on a byte boundary must have have the same scalar storage
11230 order as the record type. A component of a bit-packed array type that is itself
11231 a record or an array must have the same scalar storage order as the array type.
11232
11233 No component of a type that has an explicit @code{Scalar_Storage_Order}
11234 attribute definition may be aliased.
11235
11236 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
11237 with a value equal to @code{System.Default_Bit_Order}) has no effect.
11238
11239 If the opposite storage order is specified, then whenever the value of
11240 a scalar component of an object of type @code{S} is read, the storage
11241 elements of the enclosing machine scalar are first reversed (before
11242 retrieving the component value, possibly applying some shift and mask
11243 operatings on the enclosing machine scalar), and the opposite operation
11244 is done for writes.
11245
11246 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
11247 are relaxed. Instead, the following rules apply:
11248
11249
11250 @itemize *
11251
11252 @item
11253 the underlying storage elements are those at positions
11254 @code{(position + first_bit / storage_element_size) .. (position + (last_bit + storage_element_size - 1) / storage_element_size)}
11255
11256 @item
11257 the sequence of underlying storage elements shall have
11258 a size no greater than the largest machine scalar
11259
11260 @item
11261 the enclosing machine scalar is defined as the smallest machine
11262 scalar starting at a position no greater than
11263 @code{position + first_bit / storage_element_size} and covering
11264 storage elements at least up to @code{position + (last_bit + storage_element_size - 1) / storage_element_size`}
11265
11266 @item
11267 the position of the component is interpreted relative to that machine
11268 scalar.
11269 @end itemize
11270
11271 If no scalar storage order is specified for a type (either directly, or by
11272 inheritance in the case of a derived type), then the default is normally
11273 the native ordering of the target, but this default can be overridden using
11274 pragma @code{Default_Scalar_Storage_Order}.
11275
11276 If a component of @code{T} is itself of a record or array type, the specfied
11277 @code{Scalar_Storage_Order} does @emph{not} apply to that nested type: an explicit
11278 attribute definition clause must be provided for the component type as well
11279 if desired.
11280
11281 Note that the scalar storage order only affects the in-memory data
11282 representation. It has no effect on the representation used by stream
11283 attributes.
11284
11285 Note that debuggers may be unable to display the correct value of scalar
11286 components of a type for which the opposite storage order is specified.
11287
11288 @node Attribute Simple_Storage_Pool,Attribute Small,Attribute Scalar_Storage_Order,Implementation Defined Attributes
11289 @anchor{gnat_rm/implementation_defined_attributes attribute-simple-storage-pool}@anchor{e5}@anchor{gnat_rm/implementation_defined_attributes id5}@anchor{19f}
11290 @section Attribute Simple_Storage_Pool
11291
11292
11293 @geindex Storage pool
11294 @geindex simple
11295
11296 @geindex Simple storage pool
11297
11298 @geindex Simple_Storage_Pool
11299
11300 For every nonformal, nonderived access-to-object type @code{Acc}, the
11301 representation attribute @code{Simple_Storage_Pool} may be specified
11302 via an attribute_definition_clause (or by specifying the equivalent aspect):
11303
11304 @example
11305 My_Pool : My_Simple_Storage_Pool_Type;
11306
11307 type Acc is access My_Data_Type;
11308
11309 for Acc'Simple_Storage_Pool use My_Pool;
11310 @end example
11311
11312 The name given in an attribute_definition_clause for the
11313 @code{Simple_Storage_Pool} attribute shall denote a variable of
11314 a 'simple storage pool type' (see pragma @cite{Simple_Storage_Pool_Type}).
11315
11316 The use of this attribute is only allowed for a prefix denoting a type
11317 for which it has been specified. The type of the attribute is the type
11318 of the variable specified as the simple storage pool of the access type,
11319 and the attribute denotes that variable.
11320
11321 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
11322 for the same access type.
11323
11324 If the @code{Simple_Storage_Pool} attribute has been specified for an access
11325 type, then applying the @code{Storage_Pool} attribute to the type is flagged
11326 with a warning and its evaluation raises the exception @code{Program_Error}.
11327
11328 If the Simple_Storage_Pool attribute has been specified for an access
11329 type @code{S}, then the evaluation of the attribute @code{S'Storage_Size}
11330 returns the result of calling @code{Storage_Size (S'Simple_Storage_Pool)},
11331 which is intended to indicate the number of storage elements reserved for
11332 the simple storage pool. If the Storage_Size function has not been defined
11333 for the simple storage pool type, then this attribute returns zero.
11334
11335 If an access type @code{S} has a specified simple storage pool of type
11336 @code{SSP}, then the evaluation of an allocator for that access type calls
11337 the primitive @code{Allocate} procedure for type @code{SSP}, passing
11338 @code{S'Simple_Storage_Pool} as the pool parameter. The detailed
11339 semantics of such allocators is the same as those defined for allocators
11340 in section 13.11 of the @cite{Ada Reference Manual}, with the term
11341 @emph{simple storage pool} substituted for @emph{storage pool}.
11342
11343 If an access type @code{S} has a specified simple storage pool of type
11344 @code{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
11345 for that access type invokes the primitive @code{Deallocate} procedure
11346 for type @code{SSP}, passing @code{S'Simple_Storage_Pool} as the pool
11347 parameter. The detailed semantics of such unchecked deallocations is the same
11348 as defined in section 13.11.2 of the Ada Reference Manual, except that the
11349 term @emph{simple storage pool} is substituted for @emph{storage pool}.
11350
11351 @node Attribute Small,Attribute Storage_Unit,Attribute Simple_Storage_Pool,Implementation Defined Attributes
11352 @anchor{gnat_rm/implementation_defined_attributes attribute-small}@anchor{1a0}
11353 @section Attribute Small
11354
11355
11356 @geindex Ada 83 attributes
11357
11358 @geindex Small
11359
11360 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
11361 fixed-point types.
11362 GNAT also allows this attribute to be applied to floating-point types
11363 for compatibility with Ada 83. See
11364 the Ada 83 reference manual for an exact description of the semantics of
11365 this attribute when applied to floating-point types.
11366
11367 @node Attribute Storage_Unit,Attribute Stub_Type,Attribute Small,Implementation Defined Attributes
11368 @anchor{gnat_rm/implementation_defined_attributes attribute-storage-unit}@anchor{1a1}
11369 @section Attribute Storage_Unit
11370
11371
11372 @geindex Storage_Unit
11373
11374 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
11375 prefix) provides the same value as @code{System.Storage_Unit}.
11376
11377 @node Attribute Stub_Type,Attribute System_Allocator_Alignment,Attribute Storage_Unit,Implementation Defined Attributes
11378 @anchor{gnat_rm/implementation_defined_attributes attribute-stub-type}@anchor{1a2}
11379 @section Attribute Stub_Type
11380
11381
11382 @geindex Stub_Type
11383
11384 The GNAT implementation of remote access-to-classwide types is
11385 organized as described in AARM section E.4 (20.t): a value of an RACW type
11386 (designating a remote object) is represented as a normal access
11387 value, pointing to a "stub" object which in turn contains the
11388 necessary information to contact the designated remote object. A
11389 call on any dispatching operation of such a stub object does the
11390 remote call, if necessary, using the information in the stub object
11391 to locate the target partition, etc.
11392
11393 For a prefix @code{T} that denotes a remote access-to-classwide type,
11394 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
11395
11396 By construction, the layout of @code{T'Stub_Type} is identical to that of
11397 type @code{RACW_Stub_Type} declared in the internal implementation-defined
11398 unit @code{System.Partition_Interface}. Use of this attribute will create
11399 an implicit dependency on this unit.
11400
11401 @node Attribute System_Allocator_Alignment,Attribute Target_Name,Attribute Stub_Type,Implementation Defined Attributes
11402 @anchor{gnat_rm/implementation_defined_attributes attribute-system-allocator-alignment}@anchor{1a3}
11403 @section Attribute System_Allocator_Alignment
11404
11405
11406 @geindex Alignment
11407 @geindex allocator
11408
11409 @geindex System_Allocator_Alignment
11410
11411 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
11412 permissible prefix) provides the observable guaranted to be honored by
11413 the system allocator (malloc). This is a static value that can be used
11414 in user storage pools based on malloc either to reject allocation
11415 with alignment too large or to enable a realignment circuitry if the
11416 alignment request is larger than this value.
11417
11418 @node Attribute Target_Name,Attribute To_Address,Attribute System_Allocator_Alignment,Implementation Defined Attributes
11419 @anchor{gnat_rm/implementation_defined_attributes attribute-target-name}@anchor{1a4}
11420 @section Attribute Target_Name
11421
11422
11423 @geindex Target_Name
11424
11425 @code{Standard'Target_Name} (@code{Standard} is the only permissible
11426 prefix) provides a static string value that identifies the target
11427 for the current compilation. For GCC implementations, this is the
11428 standard gcc target name without the terminating slash (for
11429 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
11430
11431 @node Attribute To_Address,Attribute To_Any,Attribute Target_Name,Implementation Defined Attributes
11432 @anchor{gnat_rm/implementation_defined_attributes attribute-to-address}@anchor{1a5}
11433 @section Attribute To_Address
11434
11435
11436 @geindex To_Address
11437
11438 The @code{System'To_Address}
11439 (@code{System} is the only permissible prefix)
11440 denotes a function identical to
11441 @code{System.Storage_Elements.To_Address} except that
11442 it is a static attribute. This means that if its argument is
11443 a static expression, then the result of the attribute is a
11444 static expression. This means that such an expression can be
11445 used in contexts (e.g., preelaborable packages) which require a
11446 static expression and where the function call could not be used
11447 (since the function call is always nonstatic, even if its
11448 argument is static). The argument must be in the range
11449 -(2**(m-1)) .. 2**m-1, where m is the memory size
11450 (typically 32 or 64). Negative values are intepreted in a
11451 modular manner (e.g., -1 means the same as 16#FFFF_FFFF# on
11452 a 32 bits machine).
11453
11454 @node Attribute To_Any,Attribute Type_Class,Attribute To_Address,Implementation Defined Attributes
11455 @anchor{gnat_rm/implementation_defined_attributes attribute-to-any}@anchor{1a6}
11456 @section Attribute To_Any
11457
11458
11459 @geindex To_Any
11460
11461 This internal attribute is used for the generation of remote subprogram
11462 stubs in the context of the Distributed Systems Annex.
11463
11464 @node Attribute Type_Class,Attribute Type_Key,Attribute To_Any,Implementation Defined Attributes
11465 @anchor{gnat_rm/implementation_defined_attributes attribute-type-class}@anchor{1a7}
11466 @section Attribute Type_Class
11467
11468
11469 @geindex Type_Class
11470
11471 @code{typ'Type_Class} for any type or subtype @cite{typ} yields
11472 the value of the type class for the full type of @cite{typ}. If
11473 @cite{typ} is a generic formal type, the value is the value for the
11474 corresponding actual subtype. The value of this attribute is of type
11475 @code{System.Aux_DEC.Type_Class}, which has the following definition:
11476
11477 @example
11478 type Type_Class is
11479 (Type_Class_Enumeration,
11480 Type_Class_Integer,
11481 Type_Class_Fixed_Point,
11482 Type_Class_Floating_Point,
11483 Type_Class_Array,
11484 Type_Class_Record,
11485 Type_Class_Access,
11486 Type_Class_Task,
11487 Type_Class_Address);
11488 @end example
11489
11490 Protected types yield the value @code{Type_Class_Task}, which thus
11491 applies to all concurrent types. This attribute is designed to
11492 be compatible with the DEC Ada 83 attribute of the same name.
11493
11494 @node Attribute Type_Key,Attribute TypeCode,Attribute Type_Class,Implementation Defined Attributes
11495 @anchor{gnat_rm/implementation_defined_attributes attribute-type-key}@anchor{1a8}
11496 @section Attribute Type_Key
11497
11498
11499 @geindex Type_Key
11500
11501 The @code{Type_Key} attribute is applicable to a type or subtype and
11502 yields a value of type Standard.String containing encoded information
11503 about the type or subtype. This provides improved compatibility with
11504 other implementations that support this attribute.
11505
11506 @node Attribute TypeCode,Attribute Unconstrained_Array,Attribute Type_Key,Implementation Defined Attributes
11507 @anchor{gnat_rm/implementation_defined_attributes attribute-typecode}@anchor{1a9}
11508 @section Attribute TypeCode
11509
11510
11511 @geindex TypeCode
11512
11513 This internal attribute is used for the generation of remote subprogram
11514 stubs in the context of the Distributed Systems Annex.
11515
11516 @node Attribute Unconstrained_Array,Attribute Universal_Literal_String,Attribute TypeCode,Implementation Defined Attributes
11517 @anchor{gnat_rm/implementation_defined_attributes attribute-unconstrained-array}@anchor{1aa}
11518 @section Attribute Unconstrained_Array
11519
11520
11521 @geindex Unconstrained_Array
11522
11523 The @code{Unconstrained_Array} attribute can be used with a prefix that
11524 denotes any type or subtype. It is a static attribute that yields
11525 @code{True} if the prefix designates an unconstrained array,
11526 and @code{False} otherwise. In a generic instance, the result is
11527 still static, and yields the result of applying this test to the
11528 generic actual.
11529
11530 @node Attribute Universal_Literal_String,Attribute Unrestricted_Access,Attribute Unconstrained_Array,Implementation Defined Attributes
11531 @anchor{gnat_rm/implementation_defined_attributes attribute-universal-literal-string}@anchor{1ab}
11532 @section Attribute Universal_Literal_String
11533
11534
11535 @geindex Named numbers
11536 @geindex representation of
11537
11538 @geindex Universal_Literal_String
11539
11540 The prefix of @code{Universal_Literal_String} must be a named
11541 number. The static result is the string consisting of the characters of
11542 the number as defined in the original source. This allows the user
11543 program to access the actual text of named numbers without intermediate
11544 conversions and without the need to enclose the strings in quotes (which
11545 would preclude their use as numbers).
11546
11547 For example, the following program prints the first 50 digits of pi:
11548
11549 @example
11550 with Text_IO; use Text_IO;
11551 with Ada.Numerics;
11552 procedure Pi is
11553 begin
11554 Put (Ada.Numerics.Pi'Universal_Literal_String);
11555 end;
11556 @end example
11557
11558 @node Attribute Unrestricted_Access,Attribute Update,Attribute Universal_Literal_String,Implementation Defined Attributes
11559 @anchor{gnat_rm/implementation_defined_attributes attribute-unrestricted-access}@anchor{1ac}
11560 @section Attribute Unrestricted_Access
11561
11562
11563 @geindex Access
11564 @geindex unrestricted
11565
11566 @geindex Unrestricted_Access
11567
11568 The @code{Unrestricted_Access} attribute is similar to @code{Access}
11569 except that all accessibility and aliased view checks are omitted. This
11570 is a user-beware attribute.
11571
11572 For objects, it is similar to @code{Address}, for which it is a
11573 desirable replacement where the value desired is an access type.
11574 In other words, its effect is similar to first applying the
11575 @code{Address} attribute and then doing an unchecked conversion to a
11576 desired access type.
11577
11578 For subprograms, @code{P'Unrestricted_Access} may be used where
11579 @code{P'Access} would be illegal, to construct a value of a
11580 less-nested named access type that designates a more-nested
11581 subprogram. This value may be used in indirect calls, so long as the
11582 more-nested subprogram still exists; once the subprogram containing it
11583 has returned, such calls are erroneous. For example:
11584
11585 @example
11586 package body P is
11587
11588 type Less_Nested is not null access procedure;
11589 Global : Less_Nested;
11590
11591 procedure P1 is
11592 begin
11593 Global.all;
11594 end P1;
11595
11596 procedure P2 is
11597 Local_Var : Integer;
11598
11599 procedure More_Nested is
11600 begin
11601 ... Local_Var ...
11602 end More_Nested;
11603 begin
11604 Global := More_Nested'Unrestricted_Access;
11605 P1;
11606 end P2;
11607
11608 end P;
11609 @end example
11610
11611 When P1 is called from P2, the call via Global is OK, but if P1 were
11612 called after P2 returns, it would be an erroneous use of a dangling
11613 pointer.
11614
11615 For objects, it is possible to use @code{Unrestricted_Access} for any
11616 type. However, if the result is of an access-to-unconstrained array
11617 subtype, then the resulting pointer has the same scope as the context
11618 of the attribute, and must not be returned to some enclosing scope.
11619 For instance, if a function uses @code{Unrestricted_Access} to create
11620 an access-to-unconstrained-array and returns that value to the caller,
11621 the result will involve dangling pointers. In addition, it is only
11622 valid to create pointers to unconstrained arrays using this attribute
11623 if the pointer has the normal default 'fat' representation where a
11624 pointer has two components, one points to the array and one points to
11625 the bounds. If a size clause is used to force 'thin' representation
11626 for a pointer to unconstrained where there is only space for a single
11627 pointer, then the resulting pointer is not usable.
11628
11629 In the simple case where a direct use of Unrestricted_Access attempts
11630 to make a thin pointer for a non-aliased object, the compiler will
11631 reject the use as illegal, as shown in the following example:
11632
11633 @example
11634 with System; use System;
11635 procedure SliceUA2 is
11636 type A is access all String;
11637 for A'Size use Standard'Address_Size;
11638
11639 procedure P (Arg : A) is
11640 begin
11641 null;
11642 end P;
11643
11644 X : String := "hello world!";
11645 X2 : aliased String := "hello world!";
11646
11647 AV : A := X'Unrestricted_Access; -- ERROR
11648 |
11649 >>> illegal use of Unrestricted_Access attribute
11650 >>> attempt to generate thin pointer to unaliased object
11651
11652 begin
11653 P (X'Unrestricted_Access); -- ERROR
11654 |
11655 >>> illegal use of Unrestricted_Access attribute
11656 >>> attempt to generate thin pointer to unaliased object
11657
11658 P (X(7 .. 12)'Unrestricted_Access); -- ERROR
11659 |
11660 >>> illegal use of Unrestricted_Access attribute
11661 >>> attempt to generate thin pointer to unaliased object
11662
11663 P (X2'Unrestricted_Access); -- OK
11664 end;
11665 @end example
11666
11667 but other cases cannot be detected by the compiler, and are
11668 considered to be erroneous. Consider the following example:
11669
11670 @example
11671 with System; use System;
11672 with System; use System;
11673 procedure SliceUA is
11674 type AF is access all String;
11675
11676 type A is access all String;
11677 for A'Size use Standard'Address_Size;
11678
11679 procedure P (Arg : A) is
11680 begin
11681 if Arg'Length /= 6 then
11682 raise Program_Error;
11683 end if;
11684 end P;
11685
11686 X : String := "hello world!";
11687 Y : AF := X (7 .. 12)'Unrestricted_Access;
11688
11689 begin
11690 P (A (Y));
11691 end;
11692 @end example
11693
11694 A normal unconstrained array value
11695 or a constrained array object marked as aliased has the bounds in memory
11696 just before the array, so a thin pointer can retrieve both the data and
11697 the bounds. But in this case, the non-aliased object @code{X} does not have the
11698 bounds before the string. If the size clause for type @code{A}
11699 were not present, then the pointer
11700 would be a fat pointer, where one component is a pointer to the bounds,
11701 and all would be well. But with the size clause present, the conversion from
11702 fat pointer to thin pointer in the call loses the bounds, and so this
11703 is erroneous, and the program likely raises a @code{Program_Error} exception.
11704
11705 In general, it is advisable to completely
11706 avoid mixing the use of thin pointers and the use of
11707 @code{Unrestricted_Access} where the designated type is an
11708 unconstrained array. The use of thin pointers should be restricted to
11709 cases of porting legacy code that implicitly assumes the size of pointers,
11710 and such code should not in any case be using this attribute.
11711
11712 Another erroneous situation arises if the attribute is
11713 applied to a constant. The resulting pointer can be used to access the
11714 constant, but the effect of trying to modify a constant in this manner
11715 is not well-defined. Consider this example:
11716
11717 @example
11718 P : constant Integer := 4;
11719 type R is access all Integer;
11720 RV : R := P'Unrestricted_Access;
11721 ..
11722 RV.all := 3;
11723 @end example
11724
11725 Here we attempt to modify the constant P from 4 to 3, but the compiler may
11726 or may not notice this attempt, and subsequent references to P may yield
11727 either the value 3 or the value 4 or the assignment may blow up if the
11728 compiler decides to put P in read-only memory. One particular case where
11729 @code{Unrestricted_Access} can be used in this way is to modify the
11730 value of an @code{in} parameter:
11731
11732 @example
11733 procedure K (S : in String) is
11734 type R is access all Character;
11735 RV : R := S (3)'Unrestricted_Access;
11736 begin
11737 RV.all := 'a';
11738 end;
11739 @end example
11740
11741 In general this is a risky approach. It may appear to "work" but such uses of
11742 @code{Unrestricted_Access} are potentially non-portable, even from one version
11743 of GNAT to another, so are best avoided if possible.
11744
11745 @node Attribute Update,Attribute Valid_Scalars,Attribute Unrestricted_Access,Implementation Defined Attributes
11746 @anchor{gnat_rm/implementation_defined_attributes attribute-update}@anchor{1ad}
11747 @section Attribute Update
11748
11749
11750 @geindex Update
11751
11752 The @code{Update} attribute creates a copy of an array or record value
11753 with one or more modified components. The syntax is:
11754
11755 @example
11756 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
11757 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
11758 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
11759 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
11760
11761 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
11762 INDEX_EXPRESSION_LIST_LIST ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
11763 INDEX_EXPRESSION_LIST ::= ( EXPRESSION @{, EXPRESSION @} )
11764 @end example
11765
11766 where @code{PREFIX} is the name of an array or record object, the
11767 association list in parentheses does not contain an @code{others}
11768 choice and the box symbol @code{<>} may not appear in any
11769 expression. The effect is to yield a copy of the array or record value
11770 which is unchanged apart from the components mentioned in the
11771 association list, which are changed to the indicated value. The
11772 original value of the array or record value is not affected. For
11773 example:
11774
11775 @example
11776 type Arr is Array (1 .. 5) of Integer;
11777 ...
11778 Avar1 : Arr := (1,2,3,4,5);
11779 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
11780 @end example
11781
11782 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
11783 begin unmodified. Similarly:
11784
11785 @example
11786 type Rec is A, B, C : Integer;
11787 ...
11788 Rvar1 : Rec := (A => 1, B => 2, C => 3);
11789 Rvar2 : Rec := Rvar1'Update (B => 20);
11790 @end example
11791
11792 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
11793 with @code{Rvar1} being unmodifed.
11794 Note that the value of the attribute reference is computed
11795 completely before it is used. This means that if you write:
11796
11797 @example
11798 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
11799 @end example
11800
11801 then the value of @code{Avar1} is not modified if @code{Function_Call}
11802 raises an exception, unlike the effect of a series of direct assignments
11803 to elements of @code{Avar1}. In general this requires that
11804 two extra complete copies of the object are required, which should be
11805 kept in mind when considering efficiency.
11806
11807 The @code{Update} attribute cannot be applied to prefixes of a limited
11808 type, and cannot reference discriminants in the case of a record type.
11809 The accessibility level of an Update attribute result object is defined
11810 as for an aggregate.
11811
11812 In the record case, no component can be mentioned more than once. In
11813 the array case, two overlapping ranges can appear in the association list,
11814 in which case the modifications are processed left to right.
11815
11816 Multi-dimensional arrays can be modified, as shown by this example:
11817
11818 @example
11819 A : array (1 .. 10, 1 .. 10) of Integer;
11820 ..
11821 A := A'Update ((1, 2) => 20, (3, 4) => 30);
11822 @end example
11823
11824 which changes element (1,2) to 20 and (3,4) to 30.
11825
11826 @node Attribute Valid_Scalars,Attribute VADS_Size,Attribute Update,Implementation Defined Attributes
11827 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1ae}
11828 @section Attribute Valid_Scalars
11829
11830
11831 @geindex Valid_Scalars
11832
11833 The @code{'Valid_Scalars} attribute is intended to make it easier to check the
11834 validity of scalar subcomponents of composite objects. The attribute is defined
11835 for any prefix @code{P} which denotes an object. Prefix @code{P} can be any type
11836 except for tagged private or @code{Unchecked_Union} types. The value of the
11837 attribute is of type @code{Boolean}.
11838
11839 @code{P'Valid_Scalars} yields @code{True} if and only if the evaluation of
11840 @code{C'Valid} yields @code{True} for every scalar subcomponent @code{C} of @code{P}, or if
11841 @code{P} has no scalar subcomponents. Attribute @code{'Valid_Scalars} is equivalent
11842 to attribute @code{'Valid} for scalar types.
11843
11844 It is not specified in what order the subcomponents are checked, nor whether
11845 any more are checked after any one of them is determined to be invalid. If the
11846 prefix @code{P} is of a class-wide type @code{T'Class} (where @code{T} is the associated
11847 specific type), or if the prefix @code{P} is of a specific tagged type @code{T}, then
11848 only the subcomponents of @code{T} are checked; in other words, components of
11849 extensions of @code{T} are not checked even if @code{T'Class (P)'Tag /= T'Tag}.
11850
11851 The compiler will issue a warning if it can be determined at compile time that
11852 the prefix of the attribute has no scalar subcomponents.
11853
11854 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case of
11855 a large variant record. If the attribute is called in many places in the same
11856 program applied to objects of the same type, it can reduce program size to
11857 write a function with a single use of the attribute, and then call that
11858 function from multiple places.
11859
11860 @node Attribute VADS_Size,Attribute Value_Size,Attribute Valid_Scalars,Implementation Defined Attributes
11861 @anchor{gnat_rm/implementation_defined_attributes attribute-vads-size}@anchor{1af}
11862 @section Attribute VADS_Size
11863
11864
11865 @geindex Size
11866 @geindex VADS compatibility
11867
11868 @geindex VADS_Size
11869
11870 The @code{'VADS_Size} attribute is intended to make it easier to port
11871 legacy code which relies on the semantics of @code{'Size} as implemented
11872 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
11873 same semantic interpretation. In particular, @code{'VADS_Size} applied
11874 to a predefined or other primitive type with no Size clause yields the
11875 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
11876 typical machines). In addition @code{'VADS_Size} applied to an object
11877 gives the result that would be obtained by applying the attribute to
11878 the corresponding type.
11879
11880 @node Attribute Value_Size,Attribute Wchar_T_Size,Attribute VADS_Size,Implementation Defined Attributes
11881 @anchor{gnat_rm/implementation_defined_attributes id6}@anchor{1b0}@anchor{gnat_rm/implementation_defined_attributes attribute-value-size}@anchor{160}
11882 @section Attribute Value_Size
11883
11884
11885 @geindex Size
11886 @geindex setting for not-first subtype
11887
11888 @geindex Value_Size
11889
11890 @code{type'Value_Size} is the number of bits required to represent
11891 a value of the given subtype. It is the same as @code{type'Size},
11892 but, unlike @code{Size}, may be set for non-first subtypes.
11893
11894 @node Attribute Wchar_T_Size,Attribute Word_Size,Attribute Value_Size,Implementation Defined Attributes
11895 @anchor{gnat_rm/implementation_defined_attributes attribute-wchar-t-size}@anchor{1b1}
11896 @section Attribute Wchar_T_Size
11897
11898
11899 @geindex Wchar_T_Size
11900
11901 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
11902 prefix) provides the size in bits of the C @code{wchar_t} type
11903 primarily for constructing the definition of this type in
11904 package @code{Interfaces.C}. The result is a static constant.
11905
11906 @node Attribute Word_Size,,Attribute Wchar_T_Size,Implementation Defined Attributes
11907 @anchor{gnat_rm/implementation_defined_attributes attribute-word-size}@anchor{1b2}
11908 @section Attribute Word_Size
11909
11910
11911 @geindex Word_Size
11912
11913 @code{Standard'Word_Size} (@code{Standard} is the only permissible
11914 prefix) provides the value @code{System.Word_Size}. The result is
11915 a static constant.
11916
11917 @node Standard and Implementation Defined Restrictions,Implementation Advice,Implementation Defined Attributes,Top
11918 @anchor{gnat_rm/standard_and_implementation_defined_restrictions standard-and-implementation-defined-restrictions}@anchor{9}@anchor{gnat_rm/standard_and_implementation_defined_restrictions doc}@anchor{1b3}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id1}@anchor{1b4}
11919 @chapter Standard and Implementation Defined Restrictions
11920
11921
11922 All Ada Reference Manual-defined Restriction identifiers are implemented:
11923
11924
11925 @itemize *
11926
11927 @item
11928 language-defined restrictions (see 13.12.1)
11929
11930 @item
11931 tasking restrictions (see D.7)
11932
11933 @item
11934 high integrity restrictions (see H.4)
11935 @end itemize
11936
11937 GNAT implements additional restriction identifiers. All restrictions, whether
11938 language defined or GNAT-specific, are listed in the following.
11939
11940 @menu
11941 * Partition-Wide Restrictions::
11942 * Program Unit Level Restrictions::
11943
11944 @end menu
11945
11946 @node Partition-Wide Restrictions,Program Unit Level Restrictions,,Standard and Implementation Defined Restrictions
11947 @anchor{gnat_rm/standard_and_implementation_defined_restrictions partition-wide-restrictions}@anchor{1b5}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id2}@anchor{1b6}
11948 @section Partition-Wide Restrictions
11949
11950
11951 There are two separate lists of restriction identifiers. The first
11952 set requires consistency throughout a partition (in other words, if the
11953 restriction identifier is used for any compilation unit in the partition,
11954 then all compilation units in the partition must obey the restriction).
11955
11956 @menu
11957 * Immediate_Reclamation::
11958 * Max_Asynchronous_Select_Nesting::
11959 * Max_Entry_Queue_Length::
11960 * Max_Protected_Entries::
11961 * Max_Select_Alternatives::
11962 * Max_Storage_At_Blocking::
11963 * Max_Task_Entries::
11964 * Max_Tasks::
11965 * No_Abort_Statements::
11966 * No_Access_Parameter_Allocators::
11967 * No_Access_Subprograms::
11968 * No_Allocators::
11969 * No_Anonymous_Allocators::
11970 * No_Asynchronous_Control::
11971 * No_Calendar::
11972 * No_Coextensions::
11973 * No_Default_Initialization::
11974 * No_Delay::
11975 * No_Dependence::
11976 * No_Direct_Boolean_Operators::
11977 * No_Dispatch::
11978 * No_Dispatching_Calls::
11979 * No_Dynamic_Attachment::
11980 * No_Dynamic_Priorities::
11981 * No_Entry_Calls_In_Elaboration_Code::
11982 * No_Enumeration_Maps::
11983 * No_Exception_Handlers::
11984 * No_Exception_Propagation::
11985 * No_Exception_Registration::
11986 * No_Exceptions::
11987 * No_Finalization::
11988 * No_Fixed_Point::
11989 * No_Floating_Point::
11990 * No_Implicit_Conditionals::
11991 * No_Implicit_Dynamic_Code::
11992 * No_Implicit_Heap_Allocations::
11993 * No_Implicit_Protected_Object_Allocations::
11994 * No_Implicit_Task_Allocations::
11995 * No_Initialize_Scalars::
11996 * No_IO::
11997 * No_Local_Allocators::
11998 * No_Local_Protected_Objects::
11999 * No_Local_Timing_Events::
12000 * No_Long_Long_Integers::
12001 * No_Multiple_Elaboration::
12002 * No_Nested_Finalization::
12003 * No_Protected_Type_Allocators::
12004 * No_Protected_Types::
12005 * No_Recursion::
12006 * No_Reentrancy::
12007 * No_Relative_Delay::
12008 * No_Requeue_Statements::
12009 * No_Secondary_Stack::
12010 * No_Select_Statements::
12011 * No_Specific_Termination_Handlers::
12012 * No_Specification_of_Aspect::
12013 * No_Standard_Allocators_After_Elaboration::
12014 * No_Standard_Storage_Pools::
12015 * No_Stream_Optimizations::
12016 * No_Streams::
12017 * No_Task_Allocators::
12018 * No_Task_At_Interrupt_Priority::
12019 * No_Task_Attributes_Package::
12020 * No_Task_Hierarchy::
12021 * No_Task_Termination::
12022 * No_Tasking::
12023 * No_Terminate_Alternatives::
12024 * No_Unchecked_Access::
12025 * No_Unchecked_Conversion::
12026 * No_Unchecked_Deallocation::
12027 * No_Use_Of_Entity::
12028 * Pure_Barriers::
12029 * Simple_Barriers::
12030 * Static_Priorities::
12031 * Static_Storage_Size::
12032
12033 @end menu
12034
12035 @node Immediate_Reclamation,Max_Asynchronous_Select_Nesting,,Partition-Wide Restrictions
12036 @anchor{gnat_rm/standard_and_implementation_defined_restrictions immediate-reclamation}@anchor{1b7}
12037 @subsection Immediate_Reclamation
12038
12039
12040 @geindex Immediate_Reclamation
12041
12042 [RM H.4] This restriction ensures that, except for storage occupied by
12043 objects created by allocators and not deallocated via unchecked
12044 deallocation, any storage reserved at run time for an object is
12045 immediately reclaimed when the object no longer exists.
12046
12047 @node Max_Asynchronous_Select_Nesting,Max_Entry_Queue_Length,Immediate_Reclamation,Partition-Wide Restrictions
12048 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-asynchronous-select-nesting}@anchor{1b8}
12049 @subsection Max_Asynchronous_Select_Nesting
12050
12051
12052 @geindex Max_Asynchronous_Select_Nesting
12053
12054 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
12055 selects. Violations of this restriction with a value of zero are
12056 detected at compile time. Violations of this restriction with values
12057 other than zero cause Storage_Error to be raised.
12058
12059 @node Max_Entry_Queue_Length,Max_Protected_Entries,Max_Asynchronous_Select_Nesting,Partition-Wide Restrictions
12060 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-entry-queue-length}@anchor{1b9}
12061 @subsection Max_Entry_Queue_Length
12062
12063
12064 @geindex Max_Entry_Queue_Length
12065
12066 [RM D.7] This restriction is a declaration that any protected entry compiled in
12067 the scope of the restriction has at most the specified number of
12068 tasks waiting on the entry at any one time, and so no queue is required.
12069 Note that this restriction is checked at run time. Violation of this
12070 restriction results in the raising of Program_Error exception at the point of
12071 the call.
12072
12073 @geindex Max_Entry_Queue_Depth
12074
12075 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
12076 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
12077 compatibility purposes (and a warning will be generated for its use if
12078 warnings on obsolescent features are activated).
12079
12080 @node Max_Protected_Entries,Max_Select_Alternatives,Max_Entry_Queue_Length,Partition-Wide Restrictions
12081 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-protected-entries}@anchor{1ba}
12082 @subsection Max_Protected_Entries
12083
12084
12085 @geindex Max_Protected_Entries
12086
12087 [RM D.7] Specifies the maximum number of entries per protected type. The
12088 bounds of every entry family of a protected unit shall be static, or shall be
12089 defined by a discriminant of a subtype whose corresponding bound is static.
12090
12091 @node Max_Select_Alternatives,Max_Storage_At_Blocking,Max_Protected_Entries,Partition-Wide Restrictions
12092 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-select-alternatives}@anchor{1bb}
12093 @subsection Max_Select_Alternatives
12094
12095
12096 @geindex Max_Select_Alternatives
12097
12098 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
12099
12100 @node Max_Storage_At_Blocking,Max_Task_Entries,Max_Select_Alternatives,Partition-Wide Restrictions
12101 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-storage-at-blocking}@anchor{1bc}
12102 @subsection Max_Storage_At_Blocking
12103
12104
12105 @geindex Max_Storage_At_Blocking
12106
12107 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
12108 Storage_Size that can be retained by a blocked task. A violation of this
12109 restriction causes Storage_Error to be raised.
12110
12111 @node Max_Task_Entries,Max_Tasks,Max_Storage_At_Blocking,Partition-Wide Restrictions
12112 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-task-entries}@anchor{1bd}
12113 @subsection Max_Task_Entries
12114
12115
12116 @geindex Max_Task_Entries
12117
12118 [RM D.7] Specifies the maximum number of entries
12119 per task. The bounds of every entry family
12120 of a task unit shall be static, or shall be
12121 defined by a discriminant of a subtype whose
12122 corresponding bound is static.
12123
12124 @node Max_Tasks,No_Abort_Statements,Max_Task_Entries,Partition-Wide Restrictions
12125 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-tasks}@anchor{1be}
12126 @subsection Max_Tasks
12127
12128
12129 @geindex Max_Tasks
12130
12131 [RM D.7] Specifies the maximum number of task that may be created, not
12132 counting the creation of the environment task. Violations of this
12133 restriction with a value of zero are detected at compile
12134 time. Violations of this restriction with values other than zero cause
12135 Storage_Error to be raised.
12136
12137 @node No_Abort_Statements,No_Access_Parameter_Allocators,Max_Tasks,Partition-Wide Restrictions
12138 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-abort-statements}@anchor{1bf}
12139 @subsection No_Abort_Statements
12140
12141
12142 @geindex No_Abort_Statements
12143
12144 [RM D.7] There are no abort_statements, and there are
12145 no calls to Task_Identification.Abort_Task.
12146
12147 @node No_Access_Parameter_Allocators,No_Access_Subprograms,No_Abort_Statements,Partition-Wide Restrictions
12148 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-parameter-allocators}@anchor{1c0}
12149 @subsection No_Access_Parameter_Allocators
12150
12151
12152 @geindex No_Access_Parameter_Allocators
12153
12154 [RM H.4] This restriction ensures at compile time that there are no
12155 occurrences of an allocator as the actual parameter to an access
12156 parameter.
12157
12158 @node No_Access_Subprograms,No_Allocators,No_Access_Parameter_Allocators,Partition-Wide Restrictions
12159 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-subprograms}@anchor{1c1}
12160 @subsection No_Access_Subprograms
12161
12162
12163 @geindex No_Access_Subprograms
12164
12165 [RM H.4] This restriction ensures at compile time that there are no
12166 declarations of access-to-subprogram types.
12167
12168 @node No_Allocators,No_Anonymous_Allocators,No_Access_Subprograms,Partition-Wide Restrictions
12169 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-allocators}@anchor{1c2}
12170 @subsection No_Allocators
12171
12172
12173 @geindex No_Allocators
12174
12175 [RM H.4] This restriction ensures at compile time that there are no
12176 occurrences of an allocator.
12177
12178 @node No_Anonymous_Allocators,No_Asynchronous_Control,No_Allocators,Partition-Wide Restrictions
12179 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-anonymous-allocators}@anchor{1c3}
12180 @subsection No_Anonymous_Allocators
12181
12182
12183 @geindex No_Anonymous_Allocators
12184
12185 [RM H.4] This restriction ensures at compile time that there are no
12186 occurrences of an allocator of anonymous access type.
12187
12188 @node No_Asynchronous_Control,No_Calendar,No_Anonymous_Allocators,Partition-Wide Restrictions
12189 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-asynchronous-control}@anchor{1c4}
12190 @subsection No_Asynchronous_Control
12191
12192
12193 @geindex No_Asynchronous_Control
12194
12195 [RM J.13] This restriction ensures at compile time that there are no semantic
12196 dependences on the predefined package Asynchronous_Task_Control.
12197
12198 @node No_Calendar,No_Coextensions,No_Asynchronous_Control,Partition-Wide Restrictions
12199 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-calendar}@anchor{1c5}
12200 @subsection No_Calendar
12201
12202
12203 @geindex No_Calendar
12204
12205 [GNAT] This restriction ensures at compile time that there are no semantic
12206 dependences on package Calendar.
12207
12208 @node No_Coextensions,No_Default_Initialization,No_Calendar,Partition-Wide Restrictions
12209 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-coextensions}@anchor{1c6}
12210 @subsection No_Coextensions
12211
12212
12213 @geindex No_Coextensions
12214
12215 [RM H.4] This restriction ensures at compile time that there are no
12216 coextensions. See 3.10.2.
12217
12218 @node No_Default_Initialization,No_Delay,No_Coextensions,Partition-Wide Restrictions
12219 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-default-initialization}@anchor{1c7}
12220 @subsection No_Default_Initialization
12221
12222
12223 @geindex No_Default_Initialization
12224
12225 [GNAT] This restriction prohibits any instance of default initialization
12226 of variables. The binder implements a consistency rule which prevents
12227 any unit compiled without the restriction from with'ing a unit with the
12228 restriction (this allows the generation of initialization procedures to
12229 be skipped, since you can be sure that no call is ever generated to an
12230 initialization procedure in a unit with the restriction active). If used
12231 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
12232 is to prohibit all cases of variables declared without a specific
12233 initializer (including the case of OUT scalar parameters).
12234
12235 @node No_Delay,No_Dependence,No_Default_Initialization,Partition-Wide Restrictions
12236 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-delay}@anchor{1c8}
12237 @subsection No_Delay
12238
12239
12240 @geindex No_Delay
12241
12242 [RM H.4] This restriction ensures at compile time that there are no
12243 delay statements and no semantic dependences on package Calendar.
12244
12245 @node No_Dependence,No_Direct_Boolean_Operators,No_Delay,Partition-Wide Restrictions
12246 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dependence}@anchor{1c9}
12247 @subsection No_Dependence
12248
12249
12250 @geindex No_Dependence
12251
12252 [RM 13.12.1] This restriction ensures at compile time that there are no
12253 dependences on a library unit.
12254
12255 @node No_Direct_Boolean_Operators,No_Dispatch,No_Dependence,Partition-Wide Restrictions
12256 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-direct-boolean-operators}@anchor{1ca}
12257 @subsection No_Direct_Boolean_Operators
12258
12259
12260 @geindex No_Direct_Boolean_Operators
12261
12262 [GNAT] This restriction ensures that no logical operators (and/or/xor)
12263 are used on operands of type Boolean (or any type derived from Boolean).
12264 This is intended for use in safety critical programs where the certification
12265 protocol requires the use of short-circuit (and then, or else) forms for all
12266 composite boolean operations.
12267
12268 @node No_Dispatch,No_Dispatching_Calls,No_Direct_Boolean_Operators,Partition-Wide Restrictions
12269 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatch}@anchor{1cb}
12270 @subsection No_Dispatch
12271
12272
12273 @geindex No_Dispatch
12274
12275 [RM H.4] This restriction ensures at compile time that there are no
12276 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
12277
12278 @node No_Dispatching_Calls,No_Dynamic_Attachment,No_Dispatch,Partition-Wide Restrictions
12279 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatching-calls}@anchor{1cc}
12280 @subsection No_Dispatching_Calls
12281
12282
12283 @geindex No_Dispatching_Calls
12284
12285 [GNAT] This restriction ensures at compile time that the code generated by the
12286 compiler involves no dispatching calls. The use of this restriction allows the
12287 safe use of record extensions, classwide membership tests and other classwide
12288 features not involving implicit dispatching. This restriction ensures that
12289 the code contains no indirect calls through a dispatching mechanism. Note that
12290 this includes internally-generated calls created by the compiler, for example
12291 in the implementation of class-wide objects assignments. The
12292 membership test is allowed in the presence of this restriction, because its
12293 implementation requires no dispatching.
12294 This restriction is comparable to the official Ada restriction
12295 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
12296 all classwide constructs that do not imply dispatching.
12297 The following example indicates constructs that violate this restriction.
12298
12299 @example
12300 package Pkg is
12301 type T is tagged record
12302 Data : Natural;
12303 end record;
12304 procedure P (X : T);
12305
12306 type DT is new T with record
12307 More_Data : Natural;
12308 end record;
12309 procedure Q (X : DT);
12310 end Pkg;
12311
12312 with Pkg; use Pkg;
12313 procedure Example is
12314 procedure Test (O : T'Class) is
12315 N : Natural := O'Size;-- Error: Dispatching call
12316 C : T'Class := O; -- Error: implicit Dispatching Call
12317 begin
12318 if O in DT'Class then -- OK : Membership test
12319 Q (DT (O)); -- OK : Type conversion plus direct call
12320 else
12321 P (O); -- Error: Dispatching call
12322 end if;
12323 end Test;
12324
12325 Obj : DT;
12326 begin
12327 P (Obj); -- OK : Direct call
12328 P (T (Obj)); -- OK : Type conversion plus direct call
12329 P (T'Class (Obj)); -- Error: Dispatching call
12330
12331 Test (Obj); -- OK : Type conversion
12332
12333 if Obj in T'Class then -- OK : Membership test
12334 null;
12335 end if;
12336 end Example;
12337 @end example
12338
12339 @node No_Dynamic_Attachment,No_Dynamic_Priorities,No_Dispatching_Calls,Partition-Wide Restrictions
12340 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-attachment}@anchor{1cd}
12341 @subsection No_Dynamic_Attachment
12342
12343
12344 @geindex No_Dynamic_Attachment
12345
12346 [RM D.7] This restriction ensures that there is no call to any of the
12347 operations defined in package Ada.Interrupts
12348 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
12349 Detach_Handler, and Reference).
12350
12351 @geindex No_Dynamic_Interrupts
12352
12353 The restriction @code{No_Dynamic_Interrupts} is recognized as a
12354 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
12355 compatibility purposes (and a warning will be generated for its use if
12356 warnings on obsolescent features are activated).
12357
12358 @node No_Dynamic_Priorities,No_Entry_Calls_In_Elaboration_Code,No_Dynamic_Attachment,Partition-Wide Restrictions
12359 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-priorities}@anchor{1ce}
12360 @subsection No_Dynamic_Priorities
12361
12362
12363 @geindex No_Dynamic_Priorities
12364
12365 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
12366
12367 @node No_Entry_Calls_In_Elaboration_Code,No_Enumeration_Maps,No_Dynamic_Priorities,Partition-Wide Restrictions
12368 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-calls-in-elaboration-code}@anchor{1cf}
12369 @subsection No_Entry_Calls_In_Elaboration_Code
12370
12371
12372 @geindex No_Entry_Calls_In_Elaboration_Code
12373
12374 [GNAT] This restriction ensures at compile time that no task or protected entry
12375 calls are made during elaboration code. As a result of the use of this
12376 restriction, the compiler can assume that no code past an accept statement
12377 in a task can be executed at elaboration time.
12378
12379 @node No_Enumeration_Maps,No_Exception_Handlers,No_Entry_Calls_In_Elaboration_Code,Partition-Wide Restrictions
12380 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-enumeration-maps}@anchor{1d0}
12381 @subsection No_Enumeration_Maps
12382
12383
12384 @geindex No_Enumeration_Maps
12385
12386 [GNAT] This restriction ensures at compile time that no operations requiring
12387 enumeration maps are used (that is Image and Value attributes applied
12388 to enumeration types).
12389
12390 @node No_Exception_Handlers,No_Exception_Propagation,No_Enumeration_Maps,Partition-Wide Restrictions
12391 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-handlers}@anchor{1d1}
12392 @subsection No_Exception_Handlers
12393
12394
12395 @geindex No_Exception_Handlers
12396
12397 [GNAT] This restriction ensures at compile time that there are no explicit
12398 exception handlers. It also indicates that no exception propagation will
12399 be provided. In this mode, exceptions may be raised but will result in
12400 an immediate call to the last chance handler, a routine that the user
12401 must define with the following profile:
12402
12403 @example
12404 procedure Last_Chance_Handler
12405 (Source_Location : System.Address; Line : Integer);
12406 pragma Export (C, Last_Chance_Handler,
12407 "__gnat_last_chance_handler");
12408 @end example
12409
12410 The parameter is a C null-terminated string representing a message to be
12411 associated with the exception (typically the source location of the raise
12412 statement generated by the compiler). The Line parameter when nonzero
12413 represents the line number in the source program where the raise occurs.
12414
12415 @node No_Exception_Propagation,No_Exception_Registration,No_Exception_Handlers,Partition-Wide Restrictions
12416 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-propagation}@anchor{1d2}
12417 @subsection No_Exception_Propagation
12418
12419
12420 @geindex No_Exception_Propagation
12421
12422 [GNAT] This restriction guarantees that exceptions are never propagated
12423 to an outer subprogram scope. The only case in which an exception may
12424 be raised is when the handler is statically in the same subprogram, so
12425 that the effect of a raise is essentially like a goto statement. Any
12426 other raise statement (implicit or explicit) will be considered
12427 unhandled. Exception handlers are allowed, but may not contain an
12428 exception occurrence identifier (exception choice). In addition, use of
12429 the package GNAT.Current_Exception is not permitted, and reraise
12430 statements (raise with no operand) are not permitted.
12431
12432 @node No_Exception_Registration,No_Exceptions,No_Exception_Propagation,Partition-Wide Restrictions
12433 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-registration}@anchor{1d3}
12434 @subsection No_Exception_Registration
12435
12436
12437 @geindex No_Exception_Registration
12438
12439 [GNAT] This restriction ensures at compile time that no stream operations for
12440 types Exception_Id or Exception_Occurrence are used. This also makes it
12441 impossible to pass exceptions to or from a partition with this restriction
12442 in a distributed environment. If this restriction is active, the generated
12443 code is simplified by omitting the otherwise-required global registration
12444 of exceptions when they are declared.
12445
12446 @node No_Exceptions,No_Finalization,No_Exception_Registration,Partition-Wide Restrictions
12447 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exceptions}@anchor{1d4}
12448 @subsection No_Exceptions
12449
12450
12451 @geindex No_Exceptions
12452
12453 [RM H.4] This restriction ensures at compile time that there are no
12454 raise statements and no exception handlers and also suppresses the
12455 generation of language-defined run-time checks.
12456
12457 @node No_Finalization,No_Fixed_Point,No_Exceptions,Partition-Wide Restrictions
12458 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-finalization}@anchor{1d5}
12459 @subsection No_Finalization
12460
12461
12462 @geindex No_Finalization
12463
12464 [GNAT] This restriction disables the language features described in
12465 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
12466 performed by the compiler to support these features. The following types
12467 are no longer considered controlled when this restriction is in effect:
12468
12469
12470 @itemize *
12471
12472 @item
12473 @code{Ada.Finalization.Controlled}
12474
12475 @item
12476 @code{Ada.Finalization.Limited_Controlled}
12477
12478 @item
12479 Derivations from @code{Controlled} or @code{Limited_Controlled}
12480
12481 @item
12482 Class-wide types
12483
12484 @item
12485 Protected types
12486
12487 @item
12488 Task types
12489
12490 @item
12491 Array and record types with controlled components
12492 @end itemize
12493
12494 The compiler no longer generates code to initialize, finalize or adjust an
12495 object or a nested component, either declared on the stack or on the heap. The
12496 deallocation of a controlled object no longer finalizes its contents.
12497
12498 @node No_Fixed_Point,No_Floating_Point,No_Finalization,Partition-Wide Restrictions
12499 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-fixed-point}@anchor{1d6}
12500 @subsection No_Fixed_Point
12501
12502
12503 @geindex No_Fixed_Point
12504
12505 [RM H.4] This restriction ensures at compile time that there are no
12506 occurrences of fixed point types and operations.
12507
12508 @node No_Floating_Point,No_Implicit_Conditionals,No_Fixed_Point,Partition-Wide Restrictions
12509 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-floating-point}@anchor{1d7}
12510 @subsection No_Floating_Point
12511
12512
12513 @geindex No_Floating_Point
12514
12515 [RM H.4] This restriction ensures at compile time that there are no
12516 occurrences of floating point types and operations.
12517
12518 @node No_Implicit_Conditionals,No_Implicit_Dynamic_Code,No_Floating_Point,Partition-Wide Restrictions
12519 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-conditionals}@anchor{1d8}
12520 @subsection No_Implicit_Conditionals
12521
12522
12523 @geindex No_Implicit_Conditionals
12524
12525 [GNAT] This restriction ensures that the generated code does not contain any
12526 implicit conditionals, either by modifying the generated code where possible,
12527 or by rejecting any construct that would otherwise generate an implicit
12528 conditional. Note that this check does not include run time constraint
12529 checks, which on some targets may generate implicit conditionals as
12530 well. To control the latter, constraint checks can be suppressed in the
12531 normal manner. Constructs generating implicit conditionals include comparisons
12532 of composite objects and the Max/Min attributes.
12533
12534 @node No_Implicit_Dynamic_Code,No_Implicit_Heap_Allocations,No_Implicit_Conditionals,Partition-Wide Restrictions
12535 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-dynamic-code}@anchor{1d9}
12536 @subsection No_Implicit_Dynamic_Code
12537
12538
12539 @geindex No_Implicit_Dynamic_Code
12540
12541 @geindex trampoline
12542
12543 [GNAT] This restriction prevents the compiler from building 'trampolines'.
12544 This is a structure that is built on the stack and contains dynamic
12545 code to be executed at run time. On some targets, a trampoline is
12546 built for the following features: @code{Access},
12547 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
12548 nested task bodies; primitive operations of nested tagged types.
12549 Trampolines do not work on machines that prevent execution of stack
12550 data. For example, on windows systems, enabling DEP (data execution
12551 protection) will cause trampolines to raise an exception.
12552 Trampolines are also quite slow at run time.
12553
12554 On many targets, trampolines have been largely eliminated. Look at the
12555 version of system.ads for your target --- if it has
12556 Always_Compatible_Rep equal to False, then trampolines are largely
12557 eliminated. In particular, a trampoline is built for the following
12558 features: @code{Address} of a nested subprogram;
12559 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
12560 but only if pragma Favor_Top_Level applies, or the access type has a
12561 foreign-language convention; primitive operations of nested tagged
12562 types.
12563
12564 @node No_Implicit_Heap_Allocations,No_Implicit_Protected_Object_Allocations,No_Implicit_Dynamic_Code,Partition-Wide Restrictions
12565 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-heap-allocations}@anchor{1da}
12566 @subsection No_Implicit_Heap_Allocations
12567
12568
12569 @geindex No_Implicit_Heap_Allocations
12570
12571 [RM D.7] No constructs are allowed to cause implicit heap allocation.
12572
12573 @node No_Implicit_Protected_Object_Allocations,No_Implicit_Task_Allocations,No_Implicit_Heap_Allocations,Partition-Wide Restrictions
12574 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-protected-object-allocations}@anchor{1db}
12575 @subsection No_Implicit_Protected_Object_Allocations
12576
12577
12578 @geindex No_Implicit_Protected_Object_Allocations
12579
12580 [GNAT] No constructs are allowed to cause implicit heap allocation of a
12581 protected object.
12582
12583 @node No_Implicit_Task_Allocations,No_Initialize_Scalars,No_Implicit_Protected_Object_Allocations,Partition-Wide Restrictions
12584 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-task-allocations}@anchor{1dc}
12585 @subsection No_Implicit_Task_Allocations
12586
12587
12588 @geindex No_Implicit_Task_Allocations
12589
12590 [GNAT] No constructs are allowed to cause implicit heap allocation of a task.
12591
12592 @node No_Initialize_Scalars,No_IO,No_Implicit_Task_Allocations,Partition-Wide Restrictions
12593 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-initialize-scalars}@anchor{1dd}
12594 @subsection No_Initialize_Scalars
12595
12596
12597 @geindex No_Initialize_Scalars
12598
12599 [GNAT] This restriction ensures that no unit in the partition is compiled with
12600 pragma Initialize_Scalars. This allows the generation of more efficient
12601 code, and in particular eliminates dummy null initialization routines that
12602 are otherwise generated for some record and array types.
12603
12604 @node No_IO,No_Local_Allocators,No_Initialize_Scalars,Partition-Wide Restrictions
12605 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-io}@anchor{1de}
12606 @subsection No_IO
12607
12608
12609 @geindex No_IO
12610
12611 [RM H.4] This restriction ensures at compile time that there are no
12612 dependences on any of the library units Sequential_IO, Direct_IO,
12613 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
12614
12615 @node No_Local_Allocators,No_Local_Protected_Objects,No_IO,Partition-Wide Restrictions
12616 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-allocators}@anchor{1df}
12617 @subsection No_Local_Allocators
12618
12619
12620 @geindex No_Local_Allocators
12621
12622 [RM H.4] This restriction ensures at compile time that there are no
12623 occurrences of an allocator in subprograms, generic subprograms, tasks,
12624 and entry bodies.
12625
12626 @node No_Local_Protected_Objects,No_Local_Timing_Events,No_Local_Allocators,Partition-Wide Restrictions
12627 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-protected-objects}@anchor{1e0}
12628 @subsection No_Local_Protected_Objects
12629
12630
12631 @geindex No_Local_Protected_Objects
12632
12633 [RM D.7] This restriction ensures at compile time that protected objects are
12634 only declared at the library level.
12635
12636 @node No_Local_Timing_Events,No_Long_Long_Integers,No_Local_Protected_Objects,Partition-Wide Restrictions
12637 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-timing-events}@anchor{1e1}
12638 @subsection No_Local_Timing_Events
12639
12640
12641 @geindex No_Local_Timing_Events
12642
12643 [RM D.7] All objects of type Ada.Real_Time.Timing_Events.Timing_Event are
12644 declared at the library level.
12645
12646 @node No_Long_Long_Integers,No_Multiple_Elaboration,No_Local_Timing_Events,Partition-Wide Restrictions
12647 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-long-long-integers}@anchor{1e2}
12648 @subsection No_Long_Long_Integers
12649
12650
12651 @geindex No_Long_Long_Integers
12652
12653 [GNAT] This partition-wide restriction forbids any explicit reference to
12654 type Standard.Long_Long_Integer, and also forbids declaring range types whose
12655 implicit base type is Long_Long_Integer, and modular types whose size exceeds
12656 Long_Integer'Size.
12657
12658 @node No_Multiple_Elaboration,No_Nested_Finalization,No_Long_Long_Integers,Partition-Wide Restrictions
12659 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-multiple-elaboration}@anchor{1e3}
12660 @subsection No_Multiple_Elaboration
12661
12662
12663 @geindex No_Multiple_Elaboration
12664
12665 [GNAT] When this restriction is active and the static elaboration model is
12666 used, and -fpreserve-control-flow is not used, the compiler is allowed to
12667 suppress the elaboration counter normally associated with the unit, even if
12668 the unit has elaboration code. This counter is typically used to check for
12669 access before elaboration and to control multiple elaboration attempts. If the
12670 restriction is used, then the situations in which multiple elaboration is
12671 possible, including non-Ada main programs and Stand Alone libraries, are not
12672 permitted and will be diagnosed by the binder.
12673
12674 @node No_Nested_Finalization,No_Protected_Type_Allocators,No_Multiple_Elaboration,Partition-Wide Restrictions
12675 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-nested-finalization}@anchor{1e4}
12676 @subsection No_Nested_Finalization
12677
12678
12679 @geindex No_Nested_Finalization
12680
12681 [RM D.7] All objects requiring finalization are declared at the library level.
12682
12683 @node No_Protected_Type_Allocators,No_Protected_Types,No_Nested_Finalization,Partition-Wide Restrictions
12684 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-type-allocators}@anchor{1e5}
12685 @subsection No_Protected_Type_Allocators
12686
12687
12688 @geindex No_Protected_Type_Allocators
12689
12690 [RM D.7] This restriction ensures at compile time that there are no allocator
12691 expressions that attempt to allocate protected objects.
12692
12693 @node No_Protected_Types,No_Recursion,No_Protected_Type_Allocators,Partition-Wide Restrictions
12694 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-types}@anchor{1e6}
12695 @subsection No_Protected_Types
12696
12697
12698 @geindex No_Protected_Types
12699
12700 [RM H.4] This restriction ensures at compile time that there are no
12701 declarations of protected types or protected objects.
12702
12703 @node No_Recursion,No_Reentrancy,No_Protected_Types,Partition-Wide Restrictions
12704 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-recursion}@anchor{1e7}
12705 @subsection No_Recursion
12706
12707
12708 @geindex No_Recursion
12709
12710 [RM H.4] A program execution is erroneous if a subprogram is invoked as
12711 part of its execution.
12712
12713 @node No_Reentrancy,No_Relative_Delay,No_Recursion,Partition-Wide Restrictions
12714 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-reentrancy}@anchor{1e8}
12715 @subsection No_Reentrancy
12716
12717
12718 @geindex No_Reentrancy
12719
12720 [RM H.4] A program execution is erroneous if a subprogram is executed by
12721 two tasks at the same time.
12722
12723 @node No_Relative_Delay,No_Requeue_Statements,No_Reentrancy,Partition-Wide Restrictions
12724 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-relative-delay}@anchor{1e9}
12725 @subsection No_Relative_Delay
12726
12727
12728 @geindex No_Relative_Delay
12729
12730 [RM D.7] This restriction ensures at compile time that there are no delay
12731 relative statements and prevents expressions such as @code{delay 1.23;} from
12732 appearing in source code.
12733
12734 @node No_Requeue_Statements,No_Secondary_Stack,No_Relative_Delay,Partition-Wide Restrictions
12735 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-requeue-statements}@anchor{1ea}
12736 @subsection No_Requeue_Statements
12737
12738
12739 @geindex No_Requeue_Statements
12740
12741 [RM D.7] This restriction ensures at compile time that no requeue statements
12742 are permitted and prevents keyword @code{requeue} from being used in source
12743 code.
12744
12745 @geindex No_Requeue
12746
12747 The restriction @code{No_Requeue} is recognized as a
12748 synonym for @code{No_Requeue_Statements}. This is retained for historical
12749 compatibility purposes (and a warning will be generated for its use if
12750 warnings on oNobsolescent features are activated).
12751
12752 @node No_Secondary_Stack,No_Select_Statements,No_Requeue_Statements,Partition-Wide Restrictions
12753 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-secondary-stack}@anchor{1eb}
12754 @subsection No_Secondary_Stack
12755
12756
12757 @geindex No_Secondary_Stack
12758
12759 [GNAT] This restriction ensures at compile time that the generated code
12760 does not contain any reference to the secondary stack. The secondary
12761 stack is used to implement functions returning unconstrained objects
12762 (arrays or records) on some targets. Suppresses the allocation of
12763 secondary stacks for tasks (excluding the environment task) at run time.
12764
12765 @node No_Select_Statements,No_Specific_Termination_Handlers,No_Secondary_Stack,Partition-Wide Restrictions
12766 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-select-statements}@anchor{1ec}
12767 @subsection No_Select_Statements
12768
12769
12770 @geindex No_Select_Statements
12771
12772 [RM D.7] This restriction ensures at compile time no select statements of any
12773 kind are permitted, that is the keyword @code{select} may not appear.
12774
12775 @node No_Specific_Termination_Handlers,No_Specification_of_Aspect,No_Select_Statements,Partition-Wide Restrictions
12776 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specific-termination-handlers}@anchor{1ed}
12777 @subsection No_Specific_Termination_Handlers
12778
12779
12780 @geindex No_Specific_Termination_Handlers
12781
12782 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
12783 or to Ada.Task_Termination.Specific_Handler.
12784
12785 @node No_Specification_of_Aspect,No_Standard_Allocators_After_Elaboration,No_Specific_Termination_Handlers,Partition-Wide Restrictions
12786 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specification-of-aspect}@anchor{1ee}
12787 @subsection No_Specification_of_Aspect
12788
12789
12790 @geindex No_Specification_of_Aspect
12791
12792 [RM 13.12.1] This restriction checks at compile time that no aspect
12793 specification, attribute definition clause, or pragma is given for a
12794 given aspect.
12795
12796 @node No_Standard_Allocators_After_Elaboration,No_Standard_Storage_Pools,No_Specification_of_Aspect,Partition-Wide Restrictions
12797 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-allocators-after-elaboration}@anchor{1ef}
12798 @subsection No_Standard_Allocators_After_Elaboration
12799
12800
12801 @geindex No_Standard_Allocators_After_Elaboration
12802
12803 [RM D.7] Specifies that an allocator using a standard storage pool
12804 should never be evaluated at run time after the elaboration of the
12805 library items of the partition has completed. Otherwise, Storage_Error
12806 is raised.
12807
12808 @node No_Standard_Storage_Pools,No_Stream_Optimizations,No_Standard_Allocators_After_Elaboration,Partition-Wide Restrictions
12809 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-storage-pools}@anchor{1f0}
12810 @subsection No_Standard_Storage_Pools
12811
12812
12813 @geindex No_Standard_Storage_Pools
12814
12815 [GNAT] This restriction ensures at compile time that no access types
12816 use the standard default storage pool. Any access type declared must
12817 have an explicit Storage_Pool attribute defined specifying a
12818 user-defined storage pool.
12819
12820 @node No_Stream_Optimizations,No_Streams,No_Standard_Storage_Pools,Partition-Wide Restrictions
12821 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-stream-optimizations}@anchor{1f1}
12822 @subsection No_Stream_Optimizations
12823
12824
12825 @geindex No_Stream_Optimizations
12826
12827 [GNAT] This restriction affects the performance of stream operations on types
12828 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
12829 compiler uses block reads and writes when manipulating @code{String} objects
12830 due to their superior performance. When this restriction is in effect, the
12831 compiler performs all IO operations on a per-character basis.
12832
12833 @node No_Streams,No_Task_Allocators,No_Stream_Optimizations,Partition-Wide Restrictions
12834 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-streams}@anchor{1f2}
12835 @subsection No_Streams
12836
12837
12838 @geindex No_Streams
12839
12840 [GNAT] This restriction ensures at compile/bind time that there are no
12841 stream objects created and no use of stream attributes.
12842 This restriction does not forbid dependences on the package
12843 @code{Ada.Streams}. So it is permissible to with
12844 @code{Ada.Streams} (or another package that does so itself)
12845 as long as no actual stream objects are created and no
12846 stream attributes are used.
12847
12848 Note that the use of restriction allows optimization of tagged types,
12849 since they do not need to worry about dispatching stream operations.
12850 To take maximum advantage of this space-saving optimization, any
12851 unit declaring a tagged type should be compiled with the restriction,
12852 though this is not required.
12853
12854 @node No_Task_Allocators,No_Task_At_Interrupt_Priority,No_Streams,Partition-Wide Restrictions
12855 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-allocators}@anchor{1f3}
12856 @subsection No_Task_Allocators
12857
12858
12859 @geindex No_Task_Allocators
12860
12861 [RM D.7] There are no allocators for task types
12862 or types containing task subcomponents.
12863
12864 @node No_Task_At_Interrupt_Priority,No_Task_Attributes_Package,No_Task_Allocators,Partition-Wide Restrictions
12865 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-at-interrupt-priority}@anchor{1f4}
12866 @subsection No_Task_At_Interrupt_Priority
12867
12868
12869 @geindex No_Task_At_Interrupt_Priority
12870
12871 [GNAT] This restriction ensures at compile time that there is no
12872 Interrupt_Priority aspect or pragma for a task or a task type. As
12873 a consequence, the tasks are always created with a priority below
12874 that an interrupt priority.
12875
12876 @node No_Task_Attributes_Package,No_Task_Hierarchy,No_Task_At_Interrupt_Priority,Partition-Wide Restrictions
12877 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-attributes-package}@anchor{1f5}
12878 @subsection No_Task_Attributes_Package
12879
12880
12881 @geindex No_Task_Attributes_Package
12882
12883 [GNAT] This restriction ensures at compile time that there are no implicit or
12884 explicit dependencies on the package @code{Ada.Task_Attributes}.
12885
12886 @geindex No_Task_Attributes
12887
12888 The restriction @code{No_Task_Attributes} is recognized as a synonym
12889 for @code{No_Task_Attributes_Package}. This is retained for historical
12890 compatibility purposes (and a warning will be generated for its use if
12891 warnings on obsolescent features are activated).
12892
12893 @node No_Task_Hierarchy,No_Task_Termination,No_Task_Attributes_Package,Partition-Wide Restrictions
12894 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-hierarchy}@anchor{1f6}
12895 @subsection No_Task_Hierarchy
12896
12897
12898 @geindex No_Task_Hierarchy
12899
12900 [RM D.7] All (non-environment) tasks depend
12901 directly on the environment task of the partition.
12902
12903 @node No_Task_Termination,No_Tasking,No_Task_Hierarchy,Partition-Wide Restrictions
12904 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-termination}@anchor{1f7}
12905 @subsection No_Task_Termination
12906
12907
12908 @geindex No_Task_Termination
12909
12910 [RM D.7] Tasks that terminate are erroneous.
12911
12912 @node No_Tasking,No_Terminate_Alternatives,No_Task_Termination,Partition-Wide Restrictions
12913 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tasking}@anchor{1f8}
12914 @subsection No_Tasking
12915
12916
12917 @geindex No_Tasking
12918
12919 [GNAT] This restriction prevents the declaration of tasks or task types
12920 throughout the partition. It is similar in effect to the use of
12921 @code{Max_Tasks => 0} except that violations are caught at compile time
12922 and cause an error message to be output either by the compiler or
12923 binder.
12924
12925 @node No_Terminate_Alternatives,No_Unchecked_Access,No_Tasking,Partition-Wide Restrictions
12926 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-terminate-alternatives}@anchor{1f9}
12927 @subsection No_Terminate_Alternatives
12928
12929
12930 @geindex No_Terminate_Alternatives
12931
12932 [RM D.7] There are no selective accepts with terminate alternatives.
12933
12934 @node No_Unchecked_Access,No_Unchecked_Conversion,No_Terminate_Alternatives,Partition-Wide Restrictions
12935 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-access}@anchor{1fa}
12936 @subsection No_Unchecked_Access
12937
12938
12939 @geindex No_Unchecked_Access
12940
12941 [RM H.4] This restriction ensures at compile time that there are no
12942 occurrences of the Unchecked_Access attribute.
12943
12944 @node No_Unchecked_Conversion,No_Unchecked_Deallocation,No_Unchecked_Access,Partition-Wide Restrictions
12945 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-conversion}@anchor{1fb}
12946 @subsection No_Unchecked_Conversion
12947
12948
12949 @geindex No_Unchecked_Conversion
12950
12951 [RM J.13] This restriction ensures at compile time that there are no semantic
12952 dependences on the predefined generic function Unchecked_Conversion.
12953
12954 @node No_Unchecked_Deallocation,No_Use_Of_Entity,No_Unchecked_Conversion,Partition-Wide Restrictions
12955 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-deallocation}@anchor{1fc}
12956 @subsection No_Unchecked_Deallocation
12957
12958
12959 @geindex No_Unchecked_Deallocation
12960
12961 [RM J.13] This restriction ensures at compile time that there are no semantic
12962 dependences on the predefined generic procedure Unchecked_Deallocation.
12963
12964 @node No_Use_Of_Entity,Pure_Barriers,No_Unchecked_Deallocation,Partition-Wide Restrictions
12965 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-entity}@anchor{1fd}
12966 @subsection No_Use_Of_Entity
12967
12968
12969 @geindex No_Use_Of_Entity
12970
12971 [GNAT] This restriction ensures at compile time that there are no references
12972 to the entity given in the form
12973
12974 @example
12975 No_Use_Of_Entity => Name
12976 @end example
12977
12978 where @code{Name} is the fully qualified entity, for example
12979
12980 @example
12981 No_Use_Of_Entity => Ada.Text_IO.Put_Line
12982 @end example
12983
12984 @node Pure_Barriers,Simple_Barriers,No_Use_Of_Entity,Partition-Wide Restrictions
12985 @anchor{gnat_rm/standard_and_implementation_defined_restrictions pure-barriers}@anchor{1fe}
12986 @subsection Pure_Barriers
12987
12988
12989 @geindex Pure_Barriers
12990
12991 [GNAT] This restriction ensures at compile time that protected entry
12992 barriers are restricted to:
12993
12994
12995 @itemize *
12996
12997 @item
12998 components of the protected object (excluding selection from dereferences),
12999
13000 @item
13001 constant declarations,
13002
13003 @item
13004 named numbers,
13005
13006 @item
13007 enumeration literals,
13008
13009 @item
13010 integer literals,
13011
13012 @item
13013 real literals,
13014
13015 @item
13016 character literals,
13017
13018 @item
13019 implicitly defined comparison operators,
13020
13021 @item
13022 uses of the Standard."not" operator,
13023
13024 @item
13025 short-circuit operator,
13026
13027 @item
13028 the Count attribute
13029 @end itemize
13030
13031 This restriction is a relaxation of the Simple_Barriers restriction,
13032 but still ensures absence of side effects, exceptions, and recursion
13033 during the evaluation of the barriers.
13034
13035 @node Simple_Barriers,Static_Priorities,Pure_Barriers,Partition-Wide Restrictions
13036 @anchor{gnat_rm/standard_and_implementation_defined_restrictions simple-barriers}@anchor{1ff}
13037 @subsection Simple_Barriers
13038
13039
13040 @geindex Simple_Barriers
13041
13042 [RM D.7] This restriction ensures at compile time that barriers in entry
13043 declarations for protected types are restricted to either static boolean
13044 expressions or references to simple boolean variables defined in the private
13045 part of the protected type. No other form of entry barriers is permitted.
13046
13047 @geindex Boolean_Entry_Barriers
13048
13049 The restriction @code{Boolean_Entry_Barriers} is recognized as a
13050 synonym for @code{Simple_Barriers}. This is retained for historical
13051 compatibility purposes (and a warning will be generated for its use if
13052 warnings on obsolescent features are activated).
13053
13054 @node Static_Priorities,Static_Storage_Size,Simple_Barriers,Partition-Wide Restrictions
13055 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-priorities}@anchor{200}
13056 @subsection Static_Priorities
13057
13058
13059 @geindex Static_Priorities
13060
13061 [GNAT] This restriction ensures at compile time that all priority expressions
13062 are static, and that there are no dependences on the package
13063 @code{Ada.Dynamic_Priorities}.
13064
13065 @node Static_Storage_Size,,Static_Priorities,Partition-Wide Restrictions
13066 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-storage-size}@anchor{201}
13067 @subsection Static_Storage_Size
13068
13069
13070 @geindex Static_Storage_Size
13071
13072 [GNAT] This restriction ensures at compile time that any expression appearing
13073 in a Storage_Size pragma or attribute definition clause is static.
13074
13075 @node Program Unit Level Restrictions,,Partition-Wide Restrictions,Standard and Implementation Defined Restrictions
13076 @anchor{gnat_rm/standard_and_implementation_defined_restrictions program-unit-level-restrictions}@anchor{202}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id3}@anchor{203}
13077 @section Program Unit Level Restrictions
13078
13079
13080 The second set of restriction identifiers
13081 does not require partition-wide consistency.
13082 The restriction may be enforced for a single
13083 compilation unit without any effect on any of the
13084 other compilation units in the partition.
13085
13086 @menu
13087 * No_Elaboration_Code::
13088 * No_Dynamic_Sized_Objects::
13089 * No_Entry_Queue::
13090 * No_Implementation_Aspect_Specifications::
13091 * No_Implementation_Attributes::
13092 * No_Implementation_Identifiers::
13093 * No_Implementation_Pragmas::
13094 * No_Implementation_Restrictions::
13095 * No_Implementation_Units::
13096 * No_Implicit_Aliasing::
13097 * No_Implicit_Loops::
13098 * No_Obsolescent_Features::
13099 * No_Wide_Characters::
13100 * Static_Dispatch_Tables::
13101 * SPARK_05::
13102
13103 @end menu
13104
13105 @node No_Elaboration_Code,No_Dynamic_Sized_Objects,,Program Unit Level Restrictions
13106 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-elaboration-code}@anchor{204}
13107 @subsection No_Elaboration_Code
13108
13109
13110 @geindex No_Elaboration_Code
13111
13112 [GNAT] This restriction ensures at compile time that no elaboration code is
13113 generated. Note that this is not the same condition as is enforced
13114 by pragma @code{Preelaborate}. There are cases in which pragma
13115 @code{Preelaborate} still permits code to be generated (e.g., code
13116 to initialize a large array to all zeroes), and there are cases of units
13117 which do not meet the requirements for pragma @code{Preelaborate},
13118 but for which no elaboration code is generated. Generally, it is
13119 the case that preelaborable units will meet the restrictions, with
13120 the exception of large aggregates initialized with an others_clause,
13121 and exception declarations (which generate calls to a run-time
13122 registry procedure). This restriction is enforced on
13123 a unit by unit basis, it need not be obeyed consistently
13124 throughout a partition.
13125
13126 In the case of aggregates with others, if the aggregate has a dynamic
13127 size, there is no way to eliminate the elaboration code (such dynamic
13128 bounds would be incompatible with @code{Preelaborate} in any case). If
13129 the bounds are static, then use of this restriction actually modifies
13130 the code choice of the compiler to avoid generating a loop, and instead
13131 generate the aggregate statically if possible, no matter how many times
13132 the data for the others clause must be repeatedly generated.
13133
13134 It is not possible to precisely document
13135 the constructs which are compatible with this restriction, since,
13136 unlike most other restrictions, this is not a restriction on the
13137 source code, but a restriction on the generated object code. For
13138 example, if the source contains a declaration:
13139
13140 @example
13141 Val : constant Integer := X;
13142 @end example
13143
13144 where X is not a static constant, it may be possible, depending
13145 on complex optimization circuitry, for the compiler to figure
13146 out the value of X at compile time, in which case this initialization
13147 can be done by the loader, and requires no initialization code. It
13148 is not possible to document the precise conditions under which the
13149 optimizer can figure this out.
13150
13151 Note that this the implementation of this restriction requires full
13152 code generation. If it is used in conjunction with "semantics only"
13153 checking, then some cases of violations may be missed.
13154
13155 When this restriction is active, we are not requesting control-flow
13156 preservation with -fpreserve-control-flow, and the static elaboration model is
13157 used, the compiler is allowed to suppress the elaboration counter normally
13158 associated with the unit. This counter is typically used to check for access
13159 before elaboration and to control multiple elaboration attempts.
13160
13161 @node No_Dynamic_Sized_Objects,No_Entry_Queue,No_Elaboration_Code,Program Unit Level Restrictions
13162 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-sized-objects}@anchor{205}
13163 @subsection No_Dynamic_Sized_Objects
13164
13165
13166 @geindex No_Dynamic_Sized_Objects
13167
13168 [GNAT] This restriction disallows certain constructs that might lead to the
13169 creation of dynamic-sized composite objects (or array or discriminated type).
13170 An array subtype indication is illegal if the bounds are not static
13171 or references to discriminants of an enclosing type.
13172 A discriminated subtype indication is illegal if the type has
13173 discriminant-dependent array components or a variant part, and the
13174 discriminants are not static. In addition, array and record aggregates are
13175 illegal in corresponding cases. Note that this restriction does not forbid
13176 access discriminants. It is often a good idea to combine this restriction
13177 with No_Secondary_Stack.
13178
13179 @node No_Entry_Queue,No_Implementation_Aspect_Specifications,No_Dynamic_Sized_Objects,Program Unit Level Restrictions
13180 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-queue}@anchor{206}
13181 @subsection No_Entry_Queue
13182
13183
13184 @geindex No_Entry_Queue
13185
13186 [GNAT] This restriction is a declaration that any protected entry compiled in
13187 the scope of the restriction has at most one task waiting on the entry
13188 at any one time, and so no queue is required. This restriction is not
13189 checked at compile time. A program execution is erroneous if an attempt
13190 is made to queue a second task on such an entry.
13191
13192 @node No_Implementation_Aspect_Specifications,No_Implementation_Attributes,No_Entry_Queue,Program Unit Level Restrictions
13193 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-aspect-specifications}@anchor{207}
13194 @subsection No_Implementation_Aspect_Specifications
13195
13196
13197 @geindex No_Implementation_Aspect_Specifications
13198
13199 [RM 13.12.1] This restriction checks at compile time that no
13200 GNAT-defined aspects are present. With this restriction, the only
13201 aspects that can be used are those defined in the Ada Reference Manual.
13202
13203 @node No_Implementation_Attributes,No_Implementation_Identifiers,No_Implementation_Aspect_Specifications,Program Unit Level Restrictions
13204 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-attributes}@anchor{208}
13205 @subsection No_Implementation_Attributes
13206
13207
13208 @geindex No_Implementation_Attributes
13209
13210 [RM 13.12.1] This restriction checks at compile time that no
13211 GNAT-defined attributes are present. With this restriction, the only
13212 attributes that can be used are those defined in the Ada Reference
13213 Manual.
13214
13215 @node No_Implementation_Identifiers,No_Implementation_Pragmas,No_Implementation_Attributes,Program Unit Level Restrictions
13216 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-identifiers}@anchor{209}
13217 @subsection No_Implementation_Identifiers
13218
13219
13220 @geindex No_Implementation_Identifiers
13221
13222 [RM 13.12.1] This restriction checks at compile time that no
13223 implementation-defined identifiers (marked with pragma Implementation_Defined)
13224 occur within language-defined packages.
13225
13226 @node No_Implementation_Pragmas,No_Implementation_Restrictions,No_Implementation_Identifiers,Program Unit Level Restrictions
13227 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-pragmas}@anchor{20a}
13228 @subsection No_Implementation_Pragmas
13229
13230
13231 @geindex No_Implementation_Pragmas
13232
13233 [RM 13.12.1] This restriction checks at compile time that no
13234 GNAT-defined pragmas are present. With this restriction, the only
13235 pragmas that can be used are those defined in the Ada Reference Manual.
13236
13237 @node No_Implementation_Restrictions,No_Implementation_Units,No_Implementation_Pragmas,Program Unit Level Restrictions
13238 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-restrictions}@anchor{20b}
13239 @subsection No_Implementation_Restrictions
13240
13241
13242 @geindex No_Implementation_Restrictions
13243
13244 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
13245 identifiers (other than @code{No_Implementation_Restrictions} itself)
13246 are present. With this restriction, the only other restriction identifiers
13247 that can be used are those defined in the Ada Reference Manual.
13248
13249 @node No_Implementation_Units,No_Implicit_Aliasing,No_Implementation_Restrictions,Program Unit Level Restrictions
13250 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-units}@anchor{20c}
13251 @subsection No_Implementation_Units
13252
13253
13254 @geindex No_Implementation_Units
13255
13256 [RM 13.12.1] This restriction checks at compile time that there is no
13257 mention in the context clause of any implementation-defined descendants
13258 of packages Ada, Interfaces, or System.
13259
13260 @node No_Implicit_Aliasing,No_Implicit_Loops,No_Implementation_Units,Program Unit Level Restrictions
13261 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-aliasing}@anchor{20d}
13262 @subsection No_Implicit_Aliasing
13263
13264
13265 @geindex No_Implicit_Aliasing
13266
13267 [GNAT] This restriction, which is not required to be partition-wide consistent,
13268 requires an explicit aliased keyword for an object to which 'Access,
13269 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
13270 the 'Unrestricted_Access attribute for objects. Note: the reason that
13271 Unrestricted_Access is forbidden is that it would require the prefix
13272 to be aliased, and in such cases, it can always be replaced by
13273 the standard attribute Unchecked_Access which is preferable.
13274
13275 @node No_Implicit_Loops,No_Obsolescent_Features,No_Implicit_Aliasing,Program Unit Level Restrictions
13276 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-loops}@anchor{20e}
13277 @subsection No_Implicit_Loops
13278
13279
13280 @geindex No_Implicit_Loops
13281
13282 [GNAT] This restriction ensures that the generated code of the unit marked
13283 with this restriction does not contain any implicit @code{for} loops, either by
13284 modifying the generated code where possible, or by rejecting any construct
13285 that would otherwise generate an implicit @code{for} loop. If this restriction is
13286 active, it is possible to build large array aggregates with all static
13287 components without generating an intermediate temporary, and without generating
13288 a loop to initialize individual components. Otherwise, a loop is created for
13289 arrays larger than about 5000 scalar components. Note that if this restriction
13290 is set in the spec of a package, it will not apply to its body.
13291
13292 @node No_Obsolescent_Features,No_Wide_Characters,No_Implicit_Loops,Program Unit Level Restrictions
13293 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-obsolescent-features}@anchor{20f}
13294 @subsection No_Obsolescent_Features
13295
13296
13297 @geindex No_Obsolescent_Features
13298
13299 [RM 13.12.1] This restriction checks at compile time that no obsolescent
13300 features are used, as defined in Annex J of the Ada Reference Manual.
13301
13302 @node No_Wide_Characters,Static_Dispatch_Tables,No_Obsolescent_Features,Program Unit Level Restrictions
13303 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-wide-characters}@anchor{210}
13304 @subsection No_Wide_Characters
13305
13306
13307 @geindex No_Wide_Characters
13308
13309 [GNAT] This restriction ensures at compile time that no uses of the types
13310 @code{Wide_Character} or @code{Wide_String} or corresponding wide
13311 wide types
13312 appear, and that no wide or wide wide string or character literals
13313 appear in the program (that is literals representing characters not in
13314 type @code{Character}).
13315
13316 @node Static_Dispatch_Tables,SPARK_05,No_Wide_Characters,Program Unit Level Restrictions
13317 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-dispatch-tables}@anchor{211}
13318 @subsection Static_Dispatch_Tables
13319
13320
13321 @geindex Static_Dispatch_Tables
13322
13323 [GNAT] This restriction checks at compile time that all the artifacts
13324 associated with dispatch tables can be placed in read-only memory.
13325
13326 @node SPARK_05,,Static_Dispatch_Tables,Program Unit Level Restrictions
13327 @anchor{gnat_rm/standard_and_implementation_defined_restrictions spark-05}@anchor{212}
13328 @subsection SPARK_05
13329
13330
13331 @geindex SPARK_05
13332
13333 [GNAT] This restriction no longer has any effect and is superseded by
13334 SPARK 2014, whose restrictions are checked by the tool GNATprove. To check that
13335 a codebase respects SPARK 2014 restrictions, mark the code with pragma or
13336 aspect @code{SPARK_Mode}, and run the tool GNATprove at Stone assurance level, as
13337 follows:
13338
13339 @example
13340 gnatprove -P project.gpr --mode=stone
13341 @end example
13342
13343 or equivalently:
13344
13345 @example
13346 gnatprove -P project.gpr --mode=check_all
13347 @end example
13348
13349 @node Implementation Advice,Implementation Defined Characteristics,Standard and Implementation Defined Restrictions,Top
13350 @anchor{gnat_rm/implementation_advice doc}@anchor{213}@anchor{gnat_rm/implementation_advice implementation-advice}@anchor{a}@anchor{gnat_rm/implementation_advice id1}@anchor{214}
13351 @chapter Implementation Advice
13352
13353
13354 The main text of the Ada Reference Manual describes the required
13355 behavior of all Ada compilers, and the GNAT compiler conforms to
13356 these requirements.
13357
13358 In addition, there are sections throughout the Ada Reference Manual headed
13359 by the phrase 'Implementation advice'. These sections are not normative,
13360 i.e., they do not specify requirements that all compilers must
13361 follow. Rather they provide advice on generally desirable behavior.
13362 They are not requirements, because they describe behavior that cannot
13363 be provided on all systems, or may be undesirable on some systems.
13364
13365 As far as practical, GNAT follows the implementation advice in
13366 the Ada Reference Manual. Each such RM section corresponds to a section
13367 in this chapter whose title specifies the
13368 RM section number and paragraph number and the subject of
13369 the advice. The contents of each section consists of the RM text within
13370 quotation marks,
13371 followed by the GNAT interpretation of the advice. Most often, this simply says
13372 'followed', which means that GNAT follows the advice. However, in a
13373 number of cases, GNAT deliberately deviates from this advice, in which
13374 case the text describes what GNAT does and why.
13375
13376 @geindex Error detection
13377
13378 @menu
13379 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection.
13380 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units.
13381 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors.
13382 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas.
13383 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas.
13384 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets.
13385 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types.
13386 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types.
13387 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values.
13388 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types.
13389 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays.
13390 * RM 9.6(30-31); Duration'Small: RM 9 6 30-31 Duration'Small.
13391 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation.
13392 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information.
13393 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks.
13394 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses.
13395 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types.
13396 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses.
13397 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses.
13398 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses.
13399 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses.
13400 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses.
13401 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses.
13402 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses.
13403 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes.
13404 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering.
13405 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private.
13406 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations.
13407 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion.
13408 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage.
13409 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation.
13410 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes.
13411 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types.
13412 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling.
13413 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling.
13414 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation.
13415 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate.
13416 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export.
13417 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces.
13418 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C.
13419 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL.
13420 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran.
13421 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations.
13422 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations.
13423 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support.
13424 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers.
13425 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts.
13426 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements.
13427 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names.
13428 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes.
13429 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies.
13430 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies.
13431 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort.
13432 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions.
13433 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time.
13434 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem.
13435 * RM F(7); COBOL Support: RM F 7 COBOL Support.
13436 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support.
13437 * RM G; Numerics: RM G Numerics.
13438 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types.
13439 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions.
13440 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements.
13441 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy.
13442 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy.
13443
13444 @end menu
13445
13446 @node RM 1 1 3 20 Error Detection,RM 1 1 3 31 Child Units,,Implementation Advice
13447 @anchor{gnat_rm/implementation_advice rm-1-1-3-20-error-detection}@anchor{215}
13448 @section RM 1.1.3(20): Error Detection
13449
13450
13451 @quotation
13452
13453 "If an implementation detects the use of an unsupported Specialized Needs
13454 Annex feature at run time, it should raise @code{Program_Error} if
13455 feasible."
13456 @end quotation
13457
13458 Not relevant. All specialized needs annex features are either supported,
13459 or diagnosed at compile time.
13460
13461 @geindex Child Units
13462
13463 @node RM 1 1 3 31 Child Units,RM 1 1 5 12 Bounded Errors,RM 1 1 3 20 Error Detection,Implementation Advice
13464 @anchor{gnat_rm/implementation_advice rm-1-1-3-31-child-units}@anchor{216}
13465 @section RM 1.1.3(31): Child Units
13466
13467
13468 @quotation
13469
13470 "If an implementation wishes to provide implementation-defined
13471 extensions to the functionality of a language-defined library unit, it
13472 should normally do so by adding children to the library unit."
13473 @end quotation
13474
13475 Followed.
13476
13477 @geindex Bounded errors
13478
13479 @node RM 1 1 5 12 Bounded Errors,RM 2 8 16 Pragmas,RM 1 1 3 31 Child Units,Implementation Advice
13480 @anchor{gnat_rm/implementation_advice rm-1-1-5-12-bounded-errors}@anchor{217}
13481 @section RM 1.1.5(12): Bounded Errors
13482
13483
13484 @quotation
13485
13486 "If an implementation detects a bounded error or erroneous
13487 execution, it should raise @code{Program_Error}."
13488 @end quotation
13489
13490 Followed in all cases in which the implementation detects a bounded
13491 error or erroneous execution. Not all such situations are detected at
13492 runtime.
13493
13494 @geindex Pragmas
13495
13496 @node RM 2 8 16 Pragmas,RM 2 8 17-19 Pragmas,RM 1 1 5 12 Bounded Errors,Implementation Advice
13497 @anchor{gnat_rm/implementation_advice id2}@anchor{218}@anchor{gnat_rm/implementation_advice rm-2-8-16-pragmas}@anchor{219}
13498 @section RM 2.8(16): Pragmas
13499
13500
13501 @quotation
13502
13503 "Normally, implementation-defined pragmas should have no semantic effect
13504 for error-free programs; that is, if the implementation-defined pragmas
13505 are removed from a working program, the program should still be legal,
13506 and should still have the same semantics."
13507 @end quotation
13508
13509 The following implementation defined pragmas are exceptions to this
13510 rule:
13511
13512
13513 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxx}
13514 @headitem
13515
13516 Pragma
13517
13518 @tab
13519
13520 Explanation
13521
13522 @item
13523
13524 @emph{Abort_Defer}
13525
13526 @tab
13527
13528 Affects semantics
13529
13530 @item
13531
13532 @emph{Ada_83}
13533
13534 @tab
13535
13536 Affects legality
13537
13538 @item
13539
13540 @emph{Assert}
13541
13542 @tab
13543
13544 Affects semantics
13545
13546 @item
13547
13548 @emph{CPP_Class}
13549
13550 @tab
13551
13552 Affects semantics
13553
13554 @item
13555
13556 @emph{CPP_Constructor}
13557
13558 @tab
13559
13560 Affects semantics
13561
13562 @item
13563
13564 @emph{Debug}
13565
13566 @tab
13567
13568 Affects semantics
13569
13570 @item
13571
13572 @emph{Interface_Name}
13573
13574 @tab
13575
13576 Affects semantics
13577
13578 @item
13579
13580 @emph{Machine_Attribute}
13581
13582 @tab
13583
13584 Affects semantics
13585
13586 @item
13587
13588 @emph{Unimplemented_Unit}
13589
13590 @tab
13591
13592 Affects legality
13593
13594 @item
13595
13596 @emph{Unchecked_Union}
13597
13598 @tab
13599
13600 Affects semantics
13601
13602 @end multitable
13603
13604
13605 In each of the above cases, it is essential to the purpose of the pragma
13606 that this advice not be followed. For details see
13607 @ref{7,,Implementation Defined Pragmas}.
13608
13609 @node RM 2 8 17-19 Pragmas,RM 3 5 2 5 Alternative Character Sets,RM 2 8 16 Pragmas,Implementation Advice
13610 @anchor{gnat_rm/implementation_advice rm-2-8-17-19-pragmas}@anchor{21a}
13611 @section RM 2.8(17-19): Pragmas
13612
13613
13614 @quotation
13615
13616 "Normally, an implementation should not define pragmas that can
13617 make an illegal program legal, except as follows:
13618
13619
13620 @itemize *
13621
13622 @item
13623 A pragma used to complete a declaration, such as a pragma @code{Import};
13624
13625 @item
13626 A pragma used to configure the environment by adding, removing, or
13627 replacing @code{library_items}."
13628 @end itemize
13629 @end quotation
13630
13631 See @ref{219,,RM 2.8(16); Pragmas}.
13632
13633 @geindex Character Sets
13634
13635 @geindex Alternative Character Sets
13636
13637 @node RM 3 5 2 5 Alternative Character Sets,RM 3 5 4 28 Integer Types,RM 2 8 17-19 Pragmas,Implementation Advice
13638 @anchor{gnat_rm/implementation_advice rm-3-5-2-5-alternative-character-sets}@anchor{21b}
13639 @section RM 3.5.2(5): Alternative Character Sets
13640
13641
13642 @quotation
13643
13644 "If an implementation supports a mode with alternative interpretations
13645 for @code{Character} and @code{Wide_Character}, the set of graphic
13646 characters of @code{Character} should nevertheless remain a proper
13647 subset of the set of graphic characters of @code{Wide_Character}. Any
13648 character set 'localizations' should be reflected in the results of
13649 the subprograms defined in the language-defined package
13650 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
13651 an alternative interpretation of @code{Character}, the implementation should
13652 also support a corresponding change in what is a legal
13653 @code{identifier_letter}."
13654 @end quotation
13655
13656 Not all wide character modes follow this advice, in particular the JIS
13657 and IEC modes reflect standard usage in Japan, and in these encoding,
13658 the upper half of the Latin-1 set is not part of the wide-character
13659 subset, since the most significant bit is used for wide character
13660 encoding. However, this only applies to the external forms. Internally
13661 there is no such restriction.
13662
13663 @geindex Integer types
13664
13665 @node RM 3 5 4 28 Integer Types,RM 3 5 4 29 Integer Types,RM 3 5 2 5 Alternative Character Sets,Implementation Advice
13666 @anchor{gnat_rm/implementation_advice rm-3-5-4-28-integer-types}@anchor{21c}
13667 @section RM 3.5.4(28): Integer Types
13668
13669
13670 @quotation
13671
13672 "An implementation should support @code{Long_Integer} in addition to
13673 @code{Integer} if the target machine supports 32-bit (or longer)
13674 arithmetic. No other named integer subtypes are recommended for package
13675 @code{Standard}. Instead, appropriate named integer subtypes should be
13676 provided in the library package @code{Interfaces} (see B.2)."
13677 @end quotation
13678
13679 @code{Long_Integer} is supported. Other standard integer types are supported
13680 so this advice is not fully followed. These types
13681 are supported for convenient interface to C, and so that all hardware
13682 types of the machine are easily available.
13683
13684 @node RM 3 5 4 29 Integer Types,RM 3 5 5 8 Enumeration Values,RM 3 5 4 28 Integer Types,Implementation Advice
13685 @anchor{gnat_rm/implementation_advice rm-3-5-4-29-integer-types}@anchor{21d}
13686 @section RM 3.5.4(29): Integer Types
13687
13688
13689 @quotation
13690
13691 "An implementation for a two's complement machine should support
13692 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
13693 implementation should support a non-binary modules up to @code{Integer'Last}."
13694 @end quotation
13695
13696 Followed.
13697
13698 @geindex Enumeration values
13699
13700 @node RM 3 5 5 8 Enumeration Values,RM 3 5 7 17 Float Types,RM 3 5 4 29 Integer Types,Implementation Advice
13701 @anchor{gnat_rm/implementation_advice rm-3-5-5-8-enumeration-values}@anchor{21e}
13702 @section RM 3.5.5(8): Enumeration Values
13703
13704
13705 @quotation
13706
13707 "For the evaluation of a call on @code{S'Pos} for an enumeration
13708 subtype, if the value of the operand does not correspond to the internal
13709 code for any enumeration literal of its type (perhaps due to an
13710 un-initialized variable), then the implementation should raise
13711 @code{Program_Error}. This is particularly important for enumeration
13712 types with noncontiguous internal codes specified by an
13713 enumeration_representation_clause."
13714 @end quotation
13715
13716 Followed.
13717
13718 @geindex Float types
13719
13720 @node RM 3 5 7 17 Float Types,RM 3 6 2 11 Multidimensional Arrays,RM 3 5 5 8 Enumeration Values,Implementation Advice
13721 @anchor{gnat_rm/implementation_advice rm-3-5-7-17-float-types}@anchor{21f}
13722 @section RM 3.5.7(17): Float Types
13723
13724
13725 @quotation
13726
13727 "An implementation should support @code{Long_Float} in addition to
13728 @code{Float} if the target machine supports 11 or more digits of
13729 precision. No other named floating point subtypes are recommended for
13730 package @code{Standard}. Instead, appropriate named floating point subtypes
13731 should be provided in the library package @code{Interfaces} (see B.2)."
13732 @end quotation
13733
13734 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
13735 former provides improved compatibility with other implementations
13736 supporting this type. The latter corresponds to the highest precision
13737 floating-point type supported by the hardware. On most machines, this
13738 will be the same as @code{Long_Float}, but on some machines, it will
13739 correspond to the IEEE extended form. The notable case is all ia32
13740 (x86) implementations, where @code{Long_Long_Float} corresponds to
13741 the 80-bit extended precision format supported in hardware on this
13742 processor. Note that the 128-bit format on SPARC is not supported,
13743 since this is a software rather than a hardware format.
13744
13745 @geindex Multidimensional arrays
13746
13747 @geindex Arrays
13748 @geindex multidimensional
13749
13750 @node RM 3 6 2 11 Multidimensional Arrays,RM 9 6 30-31 Duration'Small,RM 3 5 7 17 Float Types,Implementation Advice
13751 @anchor{gnat_rm/implementation_advice rm-3-6-2-11-multidimensional-arrays}@anchor{220}
13752 @section RM 3.6.2(11): Multidimensional Arrays
13753
13754
13755 @quotation
13756
13757 "An implementation should normally represent multidimensional arrays in
13758 row-major order, consistent with the notation used for multidimensional
13759 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
13760 (@code{Fortran}, ...) applies to a multidimensional array type, then
13761 column-major order should be used instead (see B.5, @emph{Interfacing with Fortran})."
13762 @end quotation
13763
13764 Followed.
13765
13766 @geindex Duration'Small
13767
13768 @node RM 9 6 30-31 Duration'Small,RM 10 2 1 12 Consistent Representation,RM 3 6 2 11 Multidimensional Arrays,Implementation Advice
13769 @anchor{gnat_rm/implementation_advice rm-9-6-30-31-duration-small}@anchor{221}
13770 @section RM 9.6(30-31): Duration'Small
13771
13772
13773 @quotation
13774
13775 "Whenever possible in an implementation, the value of @code{Duration'Small}
13776 should be no greater than 100 microseconds."
13777 @end quotation
13778
13779 Followed. (@code{Duration'Small} = 10**(-9)).
13780
13781 @quotation
13782
13783 "The time base for @code{delay_relative_statements} should be monotonic;
13784 it need not be the same time base as used for @code{Calendar.Clock}."
13785 @end quotation
13786
13787 Followed.
13788
13789 @node RM 10 2 1 12 Consistent Representation,RM 11 4 1 19 Exception Information,RM 9 6 30-31 Duration'Small,Implementation Advice
13790 @anchor{gnat_rm/implementation_advice rm-10-2-1-12-consistent-representation}@anchor{222}
13791 @section RM 10.2.1(12): Consistent Representation
13792
13793
13794 @quotation
13795
13796 "In an implementation, a type declared in a pre-elaborated package should
13797 have the same representation in every elaboration of a given version of
13798 the package, whether the elaborations occur in distinct executions of
13799 the same program, or in executions of distinct programs or partitions
13800 that include the given version."
13801 @end quotation
13802
13803 Followed, except in the case of tagged types. Tagged types involve
13804 implicit pointers to a local copy of a dispatch table, and these pointers
13805 have representations which thus depend on a particular elaboration of the
13806 package. It is not easy to see how it would be possible to follow this
13807 advice without severely impacting efficiency of execution.
13808
13809 @geindex Exception information
13810
13811 @node RM 11 4 1 19 Exception Information,RM 11 5 28 Suppression of Checks,RM 10 2 1 12 Consistent Representation,Implementation Advice
13812 @anchor{gnat_rm/implementation_advice rm-11-4-1-19-exception-information}@anchor{223}
13813 @section RM 11.4.1(19): Exception Information
13814
13815
13816 @quotation
13817
13818 "@code{Exception_Message} by default and @code{Exception_Information}
13819 should produce information useful for
13820 debugging. @code{Exception_Message} should be short, about one
13821 line. @code{Exception_Information} can be long. @code{Exception_Message}
13822 should not include the
13823 @code{Exception_Name}. @code{Exception_Information} should include both
13824 the @code{Exception_Name} and the @code{Exception_Message}."
13825 @end quotation
13826
13827 Followed. For each exception that doesn't have a specified
13828 @code{Exception_Message}, the compiler generates one containing the location
13829 of the raise statement. This location has the form 'file_name:line', where
13830 file_name is the short file name (without path information) and line is the line
13831 number in the file. Note that in the case of the Zero Cost Exception
13832 mechanism, these messages become redundant with the Exception_Information that
13833 contains a full backtrace of the calling sequence, so they are disabled.
13834 To disable explicitly the generation of the source location message, use the
13835 Pragma @code{Discard_Names}.
13836
13837 @geindex Suppression of checks
13838
13839 @geindex Checks
13840 @geindex suppression of
13841
13842 @node RM 11 5 28 Suppression of Checks,RM 13 1 21-24 Representation Clauses,RM 11 4 1 19 Exception Information,Implementation Advice
13843 @anchor{gnat_rm/implementation_advice rm-11-5-28-suppression-of-checks}@anchor{224}
13844 @section RM 11.5(28): Suppression of Checks
13845
13846
13847 @quotation
13848
13849 "The implementation should minimize the code executed for checks that
13850 have been suppressed."
13851 @end quotation
13852
13853 Followed.
13854
13855 @geindex Representation clauses
13856
13857 @node RM 13 1 21-24 Representation Clauses,RM 13 2 6-8 Packed Types,RM 11 5 28 Suppression of Checks,Implementation Advice
13858 @anchor{gnat_rm/implementation_advice rm-13-1-21-24-representation-clauses}@anchor{225}
13859 @section RM 13.1 (21-24): Representation Clauses
13860
13861
13862 @quotation
13863
13864 "The recommended level of support for all representation items is
13865 qualified as follows:
13866
13867 An implementation need not support representation items containing
13868 nonstatic expressions, except that an implementation should support a
13869 representation item for a given entity if each nonstatic expression in
13870 the representation item is a name that statically denotes a constant
13871 declared before the entity."
13872 @end quotation
13873
13874 Followed. In fact, GNAT goes beyond the recommended level of support
13875 by allowing nonstatic expressions in some representation clauses even
13876 without the need to declare constants initialized with the values of
13877 such expressions.
13878 For example:
13879
13880 @example
13881 X : Integer;
13882 Y : Float;
13883 for Y'Address use X'Address;>>
13884
13885
13886 "An implementation need not support a specification for the `@w{`}Size`@w{`}
13887 for a given composite subtype, nor the size or storage place for an
13888 object (including a component) of a given composite subtype, unless the
13889 constraints on the subtype and its composite subcomponents (if any) are
13890 all static constraints."
13891 @end example
13892
13893 Followed. Size Clauses are not permitted on nonstatic components, as
13894 described above.
13895
13896 @quotation
13897
13898 "An aliased component, or a component whose type is by-reference, should
13899 always be allocated at an addressable location."
13900 @end quotation
13901
13902 Followed.
13903
13904 @geindex Packed types
13905
13906 @node RM 13 2 6-8 Packed Types,RM 13 3 14-19 Address Clauses,RM 13 1 21-24 Representation Clauses,Implementation Advice
13907 @anchor{gnat_rm/implementation_advice rm-13-2-6-8-packed-types}@anchor{226}
13908 @section RM 13.2(6-8): Packed Types
13909
13910
13911 @quotation
13912
13913 "If a type is packed, then the implementation should try to minimize
13914 storage allocated to objects of the type, possibly at the expense of
13915 speed of accessing components, subject to reasonable complexity in
13916 addressing calculations.
13917
13918 The recommended level of support pragma @code{Pack} is:
13919
13920 For a packed record type, the components should be packed as tightly as
13921 possible subject to the Sizes of the component subtypes, and subject to
13922 any @emph{record_representation_clause} that applies to the type; the
13923 implementation may, but need not, reorder components or cross aligned
13924 word boundaries to improve the packing. A component whose @code{Size} is
13925 greater than the word size may be allocated an integral number of words."
13926 @end quotation
13927
13928 Followed. Tight packing of arrays is supported for all component sizes
13929 up to 64-bits. If the array component size is 1 (that is to say, if
13930 the component is a boolean type or an enumeration type with two values)
13931 then values of the type are implicitly initialized to zero. This
13932 happens both for objects of the packed type, and for objects that have a
13933 subcomponent of the packed type.
13934
13935 @quotation
13936
13937 "An implementation should support Address clauses for imported
13938 subprograms."
13939 @end quotation
13940
13941 Followed.
13942
13943 @geindex Address clauses
13944
13945 @node RM 13 3 14-19 Address Clauses,RM 13 3 29-35 Alignment Clauses,RM 13 2 6-8 Packed Types,Implementation Advice
13946 @anchor{gnat_rm/implementation_advice rm-13-3-14-19-address-clauses}@anchor{227}
13947 @section RM 13.3(14-19): Address Clauses
13948
13949
13950 @quotation
13951
13952 "For an array @code{X}, @code{X'Address} should point at the first
13953 component of the array, and not at the array bounds."
13954 @end quotation
13955
13956 Followed.
13957
13958 @quotation
13959
13960 "The recommended level of support for the @code{Address} attribute is:
13961
13962 @code{X'Address} should produce a useful result if @code{X} is an
13963 object that is aliased or of a by-reference type, or is an entity whose
13964 @code{Address} has been specified."
13965 @end quotation
13966
13967 Followed. A valid address will be produced even if none of those
13968 conditions have been met. If necessary, the object is forced into
13969 memory to ensure the address is valid.
13970
13971 @quotation
13972
13973 "An implementation should support @code{Address} clauses for imported
13974 subprograms."
13975 @end quotation
13976
13977 Followed.
13978
13979 @quotation
13980
13981 "Objects (including subcomponents) that are aliased or of a by-reference
13982 type should be allocated on storage element boundaries."
13983 @end quotation
13984
13985 Followed.
13986
13987 @quotation
13988
13989 "If the @code{Address} of an object is specified, or it is imported or exported,
13990 then the implementation should not perform optimizations based on
13991 assumptions of no aliases."
13992 @end quotation
13993
13994 Followed.
13995
13996 @geindex Alignment clauses
13997
13998 @node RM 13 3 29-35 Alignment Clauses,RM 13 3 42-43 Size Clauses,RM 13 3 14-19 Address Clauses,Implementation Advice
13999 @anchor{gnat_rm/implementation_advice rm-13-3-29-35-alignment-clauses}@anchor{228}
14000 @section RM 13.3(29-35): Alignment Clauses
14001
14002
14003 @quotation
14004
14005 "The recommended level of support for the @code{Alignment} attribute for
14006 subtypes is:
14007
14008 An implementation should support specified Alignments that are factors
14009 and multiples of the number of storage elements per word, subject to the
14010 following:"
14011 @end quotation
14012
14013 Followed.
14014
14015 @quotation
14016
14017 "An implementation need not support specified Alignments for
14018 combinations of Sizes and Alignments that cannot be easily
14019 loaded and stored by available machine instructions."
14020 @end quotation
14021
14022 Followed.
14023
14024 @quotation
14025
14026 "An implementation need not support specified Alignments that are
14027 greater than the maximum @code{Alignment} the implementation ever returns by
14028 default."
14029 @end quotation
14030
14031 Followed.
14032
14033 @quotation
14034
14035 "The recommended level of support for the @code{Alignment} attribute for
14036 objects is:
14037
14038 Same as above, for subtypes, but in addition:"
14039 @end quotation
14040
14041 Followed.
14042
14043 @quotation
14044
14045 "For stand-alone library-level objects of statically constrained
14046 subtypes, the implementation should support all alignments
14047 supported by the target linker. For example, page alignment is likely to
14048 be supported for such objects, but not for subtypes."
14049 @end quotation
14050
14051 Followed.
14052
14053 @geindex Size clauses
14054
14055 @node RM 13 3 42-43 Size Clauses,RM 13 3 50-56 Size Clauses,RM 13 3 29-35 Alignment Clauses,Implementation Advice
14056 @anchor{gnat_rm/implementation_advice rm-13-3-42-43-size-clauses}@anchor{229}
14057 @section RM 13.3(42-43): Size Clauses
14058
14059
14060 @quotation
14061
14062 "The recommended level of support for the @code{Size} attribute of
14063 objects is:
14064
14065 A @code{Size} clause should be supported for an object if the specified
14066 @code{Size} is at least as large as its subtype's @code{Size}, and
14067 corresponds to a size in storage elements that is a multiple of the
14068 object's @code{Alignment} (if the @code{Alignment} is nonzero)."
14069 @end quotation
14070
14071 Followed.
14072
14073 @node RM 13 3 50-56 Size Clauses,RM 13 3 71-73 Component Size Clauses,RM 13 3 42-43 Size Clauses,Implementation Advice
14074 @anchor{gnat_rm/implementation_advice rm-13-3-50-56-size-clauses}@anchor{22a}
14075 @section RM 13.3(50-56): Size Clauses
14076
14077
14078 @quotation
14079
14080 "If the @code{Size} of a subtype is specified, and allows for efficient
14081 independent addressability (see 9.10) on the target architecture, then
14082 the @code{Size} of the following objects of the subtype should equal the
14083 @code{Size} of the subtype:
14084
14085 Aliased objects (including components)."
14086 @end quotation
14087
14088 Followed.
14089
14090 @quotation
14091
14092 "@cite{Size} clause on a composite subtype should not affect the
14093 internal layout of components."
14094 @end quotation
14095
14096 Followed. But note that this can be overridden by use of the implementation
14097 pragma Implicit_Packing in the case of packed arrays.
14098
14099 @quotation
14100
14101 "The recommended level of support for the @code{Size} attribute of subtypes is:
14102
14103 The @code{Size} (if not specified) of a static discrete or fixed point
14104 subtype should be the number of bits needed to represent each value
14105 belonging to the subtype using an unbiased representation, leaving space
14106 for a sign bit only if the subtype contains negative values. If such a
14107 subtype is a first subtype, then an implementation should support a
14108 specified @code{Size} for it that reflects this representation."
14109 @end quotation
14110
14111 Followed.
14112
14113 @quotation
14114
14115 "For a subtype implemented with levels of indirection, the @code{Size}
14116 should include the size of the pointers, but not the size of what they
14117 point at."
14118 @end quotation
14119
14120 Followed.
14121
14122 @geindex Component_Size clauses
14123
14124 @node RM 13 3 71-73 Component Size Clauses,RM 13 4 9-10 Enumeration Representation Clauses,RM 13 3 50-56 Size Clauses,Implementation Advice
14125 @anchor{gnat_rm/implementation_advice rm-13-3-71-73-component-size-clauses}@anchor{22b}
14126 @section RM 13.3(71-73): Component Size Clauses
14127
14128
14129 @quotation
14130
14131 "The recommended level of support for the @code{Component_Size}
14132 attribute is:
14133
14134 An implementation need not support specified @code{Component_Sizes} that are
14135 less than the @code{Size} of the component subtype."
14136 @end quotation
14137
14138 Followed.
14139
14140 @quotation
14141
14142 "An implementation should support specified Component_Sizes that
14143 are factors and multiples of the word size. For such
14144 Component_Sizes, the array should contain no gaps between
14145 components. For other Component_Sizes (if supported), the array
14146 should contain no gaps between components when packing is also
14147 specified; the implementation should forbid this combination in cases
14148 where it cannot support a no-gaps representation."
14149 @end quotation
14150
14151 Followed.
14152
14153 @geindex Enumeration representation clauses
14154
14155 @geindex Representation clauses
14156 @geindex enumeration
14157
14158 @node RM 13 4 9-10 Enumeration Representation Clauses,RM 13 5 1 17-22 Record Representation Clauses,RM 13 3 71-73 Component Size Clauses,Implementation Advice
14159 @anchor{gnat_rm/implementation_advice rm-13-4-9-10-enumeration-representation-clauses}@anchor{22c}
14160 @section RM 13.4(9-10): Enumeration Representation Clauses
14161
14162
14163 @quotation
14164
14165 "The recommended level of support for enumeration representation clauses
14166 is:
14167
14168 An implementation need not support enumeration representation clauses
14169 for boolean types, but should at minimum support the internal codes in
14170 the range @code{System.Min_Int .. System.Max_Int}."
14171 @end quotation
14172
14173 Followed.
14174
14175 @geindex Record representation clauses
14176
14177 @geindex Representation clauses
14178 @geindex records
14179
14180 @node RM 13 5 1 17-22 Record Representation Clauses,RM 13 5 2 5 Storage Place Attributes,RM 13 4 9-10 Enumeration Representation Clauses,Implementation Advice
14181 @anchor{gnat_rm/implementation_advice rm-13-5-1-17-22-record-representation-clauses}@anchor{22d}
14182 @section RM 13.5.1(17-22): Record Representation Clauses
14183
14184
14185 @quotation
14186
14187 "The recommended level of support for
14188 @emph{record_representation_clause}s is:
14189
14190 An implementation should support storage places that can be extracted
14191 with a load, mask, shift sequence of machine code, and set with a load,
14192 shift, mask, store sequence, given the available machine instructions
14193 and run-time model."
14194 @end quotation
14195
14196 Followed.
14197
14198 @quotation
14199
14200 "A storage place should be supported if its size is equal to the
14201 @code{Size} of the component subtype, and it starts and ends on a
14202 boundary that obeys the @code{Alignment} of the component subtype."
14203 @end quotation
14204
14205 Followed.
14206
14207 @quotation
14208
14209 "If the default bit ordering applies to the declaration of a given type,
14210 then for a component whose subtype's @code{Size} is less than the word
14211 size, any storage place that does not cross an aligned word boundary
14212 should be supported."
14213 @end quotation
14214
14215 Followed.
14216
14217 @quotation
14218
14219 "An implementation may reserve a storage place for the tag field of a
14220 tagged type, and disallow other components from overlapping that place."
14221 @end quotation
14222
14223 Followed. The storage place for the tag field is the beginning of the tagged
14224 record, and its size is Address'Size. GNAT will reject an explicit component
14225 clause for the tag field.
14226
14227 @quotation
14228
14229 "An implementation need not support a @emph{component_clause} for a
14230 component of an extension part if the storage place is not after the
14231 storage places of all components of the parent type, whether or not
14232 those storage places had been specified."
14233 @end quotation
14234
14235 Followed. The above advice on record representation clauses is followed,
14236 and all mentioned features are implemented.
14237
14238 @geindex Storage place attributes
14239
14240 @node RM 13 5 2 5 Storage Place Attributes,RM 13 5 3 7-8 Bit Ordering,RM 13 5 1 17-22 Record Representation Clauses,Implementation Advice
14241 @anchor{gnat_rm/implementation_advice rm-13-5-2-5-storage-place-attributes}@anchor{22e}
14242 @section RM 13.5.2(5): Storage Place Attributes
14243
14244
14245 @quotation
14246
14247 "If a component is represented using some form of pointer (such as an
14248 offset) to the actual data of the component, and this data is contiguous
14249 with the rest of the object, then the storage place attributes should
14250 reflect the place of the actual data, not the pointer. If a component is
14251 allocated discontinuously from the rest of the object, then a warning
14252 should be generated upon reference to one of its storage place
14253 attributes."
14254 @end quotation
14255
14256 Followed. There are no such components in GNAT.
14257
14258 @geindex Bit ordering
14259
14260 @node RM 13 5 3 7-8 Bit Ordering,RM 13 7 37 Address as Private,RM 13 5 2 5 Storage Place Attributes,Implementation Advice
14261 @anchor{gnat_rm/implementation_advice rm-13-5-3-7-8-bit-ordering}@anchor{22f}
14262 @section RM 13.5.3(7-8): Bit Ordering
14263
14264
14265 @quotation
14266
14267 "The recommended level of support for the non-default bit ordering is:
14268
14269 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
14270 should support the non-default bit ordering in addition to the default
14271 bit ordering."
14272 @end quotation
14273
14274 Followed. Word size does not equal storage size in this implementation.
14275 Thus non-default bit ordering is not supported.
14276
14277 @geindex Address
14278 @geindex as private type
14279
14280 @node RM 13 7 37 Address as Private,RM 13 7 1 16 Address Operations,RM 13 5 3 7-8 Bit Ordering,Implementation Advice
14281 @anchor{gnat_rm/implementation_advice rm-13-7-37-address-as-private}@anchor{230}
14282 @section RM 13.7(37): Address as Private
14283
14284
14285 @quotation
14286
14287 "@cite{Address} should be of a private type."
14288 @end quotation
14289
14290 Followed.
14291
14292 @geindex Operations
14293 @geindex on `@w{`}Address`@w{`}
14294
14295 @geindex Address
14296 @geindex operations of
14297
14298 @node RM 13 7 1 16 Address Operations,RM 13 9 14-17 Unchecked Conversion,RM 13 7 37 Address as Private,Implementation Advice
14299 @anchor{gnat_rm/implementation_advice rm-13-7-1-16-address-operations}@anchor{231}
14300 @section RM 13.7.1(16): Address Operations
14301
14302
14303 @quotation
14304
14305 "Operations in @code{System} and its children should reflect the target
14306 environment semantics as closely as is reasonable. For example, on most
14307 machines, it makes sense for address arithmetic to 'wrap around'.
14308 Operations that do not make sense should raise @code{Program_Error}."
14309 @end quotation
14310
14311 Followed. Address arithmetic is modular arithmetic that wraps around. No
14312 operation raises @code{Program_Error}, since all operations make sense.
14313
14314 @geindex Unchecked conversion
14315
14316 @node RM 13 9 14-17 Unchecked Conversion,RM 13 11 23-25 Implicit Heap Usage,RM 13 7 1 16 Address Operations,Implementation Advice
14317 @anchor{gnat_rm/implementation_advice rm-13-9-14-17-unchecked-conversion}@anchor{232}
14318 @section RM 13.9(14-17): Unchecked Conversion
14319
14320
14321 @quotation
14322
14323 "The @code{Size} of an array object should not include its bounds; hence,
14324 the bounds should not be part of the converted data."
14325 @end quotation
14326
14327 Followed.
14328
14329 @quotation
14330
14331 "The implementation should not generate unnecessary run-time checks to
14332 ensure that the representation of @code{S} is a representation of the
14333 target type. It should take advantage of the permission to return by
14334 reference when possible. Restrictions on unchecked conversions should be
14335 avoided unless required by the target environment."
14336 @end quotation
14337
14338 Followed. There are no restrictions on unchecked conversion. A warning is
14339 generated if the source and target types do not have the same size since
14340 the semantics in this case may be target dependent.
14341
14342 @quotation
14343
14344 "The recommended level of support for unchecked conversions is:
14345
14346 Unchecked conversions should be supported and should be reversible in
14347 the cases where this clause defines the result. To enable meaningful use
14348 of unchecked conversion, a contiguous representation should be used for
14349 elementary subtypes, for statically constrained array subtypes whose
14350 component subtype is one of the subtypes described in this paragraph,
14351 and for record subtypes without discriminants whose component subtypes
14352 are described in this paragraph."
14353 @end quotation
14354
14355 Followed.
14356
14357 @geindex Heap usage
14358 @geindex implicit
14359
14360 @node RM 13 11 23-25 Implicit Heap Usage,RM 13 11 2 17 Unchecked Deallocation,RM 13 9 14-17 Unchecked Conversion,Implementation Advice
14361 @anchor{gnat_rm/implementation_advice rm-13-11-23-25-implicit-heap-usage}@anchor{233}
14362 @section RM 13.11(23-25): Implicit Heap Usage
14363
14364
14365 @quotation
14366
14367 "An implementation should document any cases in which it dynamically
14368 allocates heap storage for a purpose other than the evaluation of an
14369 allocator."
14370 @end quotation
14371
14372 Followed, the only other points at which heap storage is dynamically
14373 allocated are as follows:
14374
14375
14376 @itemize *
14377
14378 @item
14379 At initial elaboration time, to allocate dynamically sized global
14380 objects.
14381
14382 @item
14383 To allocate space for a task when a task is created.
14384
14385 @item
14386 To extend the secondary stack dynamically when needed. The secondary
14387 stack is used for returning variable length results.
14388 @end itemize
14389
14390
14391 @quotation
14392
14393 "A default (implementation-provided) storage pool for an
14394 access-to-constant type should not have overhead to support deallocation of
14395 individual objects."
14396 @end quotation
14397
14398 Followed.
14399
14400 @quotation
14401
14402 "A storage pool for an anonymous access type should be created at the
14403 point of an allocator for the type, and be reclaimed when the designated
14404 object becomes inaccessible."
14405 @end quotation
14406
14407 Followed.
14408
14409 @geindex Unchecked deallocation
14410
14411 @node RM 13 11 2 17 Unchecked Deallocation,RM 13 13 2 1 6 Stream Oriented Attributes,RM 13 11 23-25 Implicit Heap Usage,Implementation Advice
14412 @anchor{gnat_rm/implementation_advice rm-13-11-2-17-unchecked-deallocation}@anchor{234}
14413 @section RM 13.11.2(17): Unchecked Deallocation
14414
14415
14416 @quotation
14417
14418 "For a standard storage pool, @code{Free} should actually reclaim the
14419 storage."
14420 @end quotation
14421
14422 Followed.
14423
14424 @geindex Stream oriented attributes
14425
14426 @node RM 13 13 2 1 6 Stream Oriented Attributes,RM A 1 52 Names of Predefined Numeric Types,RM 13 11 2 17 Unchecked Deallocation,Implementation Advice
14427 @anchor{gnat_rm/implementation_advice rm-13-13-2-1-6-stream-oriented-attributes}@anchor{235}
14428 @section RM 13.13.2(1.6): Stream Oriented Attributes
14429
14430
14431 @quotation
14432
14433 "If not specified, the value of Stream_Size for an elementary type
14434 should be the number of bits that corresponds to the minimum number of
14435 stream elements required by the first subtype of the type, rounded up
14436 to the nearest factor or multiple of the word size that is also a
14437 multiple of the stream element size."
14438 @end quotation
14439
14440 Followed, except that the number of stream elements is 1, 2, 3, 4 or 8.
14441 The Stream_Size may be used to override the default choice.
14442
14443 The default implementation is based on direct binary representations and is
14444 therefore target- and endianness-dependent. To address this issue, GNAT also
14445 supplies an alternate implementation of the stream attributes @code{Read} and
14446 @code{Write}, which uses the target-independent XDR standard representation for
14447 scalar types. This XDR alternative can be enabled via the binder switch -xdr.
14448
14449 @geindex XDR representation
14450
14451 @geindex Read attribute
14452
14453 @geindex Write attribute
14454
14455 @geindex Stream oriented attributes
14456
14457 @node RM A 1 52 Names of Predefined Numeric Types,RM A 3 2 49 Ada Characters Handling,RM 13 13 2 1 6 Stream Oriented Attributes,Implementation Advice
14458 @anchor{gnat_rm/implementation_advice rm-a-1-52-names-of-predefined-numeric-types}@anchor{236}
14459 @section RM A.1(52): Names of Predefined Numeric Types
14460
14461
14462 @quotation
14463
14464 "If an implementation provides additional named predefined integer types,
14465 then the names should end with @code{Integer} as in
14466 @code{Long_Integer}. If an implementation provides additional named
14467 predefined floating point types, then the names should end with
14468 @code{Float} as in @code{Long_Float}."
14469 @end quotation
14470
14471 Followed.
14472
14473 @geindex Ada.Characters.Handling
14474
14475 @node RM A 3 2 49 Ada Characters Handling,RM A 4 4 106 Bounded-Length String Handling,RM A 1 52 Names of Predefined Numeric Types,Implementation Advice
14476 @anchor{gnat_rm/implementation_advice rm-a-3-2-49-ada-characters-handling}@anchor{237}
14477 @section RM A.3.2(49): @code{Ada.Characters.Handling}
14478
14479
14480 @quotation
14481
14482 "If an implementation provides a localized definition of @code{Character}
14483 or @code{Wide_Character}, then the effects of the subprograms in
14484 @code{Characters.Handling} should reflect the localizations.
14485 See also 3.5.2."
14486 @end quotation
14487
14488 Followed. GNAT provides no such localized definitions.
14489
14490 @geindex Bounded-length strings
14491
14492 @node RM A 4 4 106 Bounded-Length String Handling,RM A 5 2 46-47 Random Number Generation,RM A 3 2 49 Ada Characters Handling,Implementation Advice
14493 @anchor{gnat_rm/implementation_advice rm-a-4-4-106-bounded-length-string-handling}@anchor{238}
14494 @section RM A.4.4(106): Bounded-Length String Handling
14495
14496
14497 @quotation
14498
14499 "Bounded string objects should not be implemented by implicit pointers
14500 and dynamic allocation."
14501 @end quotation
14502
14503 Followed. No implicit pointers or dynamic allocation are used.
14504
14505 @geindex Random number generation
14506
14507 @node RM A 5 2 46-47 Random Number Generation,RM A 10 7 23 Get_Immediate,RM A 4 4 106 Bounded-Length String Handling,Implementation Advice
14508 @anchor{gnat_rm/implementation_advice rm-a-5-2-46-47-random-number-generation}@anchor{239}
14509 @section RM A.5.2(46-47): Random Number Generation
14510
14511
14512 @quotation
14513
14514 "Any storage associated with an object of type @code{Generator} should be
14515 reclaimed on exit from the scope of the object."
14516 @end quotation
14517
14518 Followed.
14519
14520 @quotation
14521
14522 "If the generator period is sufficiently long in relation to the number
14523 of distinct initiator values, then each possible value of
14524 @code{Initiator} passed to @code{Reset} should initiate a sequence of
14525 random numbers that does not, in a practical sense, overlap the sequence
14526 initiated by any other value. If this is not possible, then the mapping
14527 between initiator values and generator states should be a rapidly
14528 varying function of the initiator value."
14529 @end quotation
14530
14531 Followed. The generator period is sufficiently long for the first
14532 condition here to hold true.
14533
14534 @geindex Get_Immediate
14535
14536 @node RM A 10 7 23 Get_Immediate,RM B 1 39-41 Pragma Export,RM A 5 2 46-47 Random Number Generation,Implementation Advice
14537 @anchor{gnat_rm/implementation_advice rm-a-10-7-23-get-immediate}@anchor{23a}
14538 @section RM A.10.7(23): @code{Get_Immediate}
14539
14540
14541 @quotation
14542
14543 "The @code{Get_Immediate} procedures should be implemented with
14544 unbuffered input. For a device such as a keyboard, input should be
14545 available if a key has already been typed, whereas for a disk
14546 file, input should always be available except at end of file. For a file
14547 associated with a keyboard-like device, any line-editing features of the
14548 underlying operating system should be disabled during the execution of
14549 @code{Get_Immediate}."
14550 @end quotation
14551
14552 Followed on all targets except VxWorks. For VxWorks, there is no way to
14553 provide this functionality that does not result in the input buffer being
14554 flushed before the @code{Get_Immediate} call. A special unit
14555 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
14556 this functionality.
14557
14558 @geindex Export
14559
14560 @node RM B 1 39-41 Pragma Export,RM B 2 12-13 Package Interfaces,RM A 10 7 23 Get_Immediate,Implementation Advice
14561 @anchor{gnat_rm/implementation_advice rm-b-1-39-41-pragma-export}@anchor{23b}
14562 @section RM B.1(39-41): Pragma @code{Export}
14563
14564
14565 @quotation
14566
14567 "If an implementation supports pragma @code{Export} to a given language,
14568 then it should also allow the main subprogram to be written in that
14569 language. It should support some mechanism for invoking the elaboration
14570 of the Ada library units included in the system, and for invoking the
14571 finalization of the environment task. On typical systems, the
14572 recommended mechanism is to provide two subprograms whose link names are
14573 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
14574 elaboration code for library units. @code{adafinal} should contain the
14575 finalization code. These subprograms should have no effect the second
14576 and subsequent time they are called."
14577 @end quotation
14578
14579 Followed.
14580
14581 @quotation
14582
14583 "Automatic elaboration of pre-elaborated packages should be
14584 provided when pragma @code{Export} is supported."
14585 @end quotation
14586
14587 Followed when the main program is in Ada. If the main program is in a
14588 foreign language, then
14589 @code{adainit} must be called to elaborate pre-elaborated
14590 packages.
14591
14592 @quotation
14593
14594 "For each supported convention @emph{L} other than @code{Intrinsic}, an
14595 implementation should support @code{Import} and @code{Export} pragmas
14596 for objects of @emph{L}-compatible types and for subprograms, and pragma
14597 @cite{Convention} for @emph{L}-eligible types and for subprograms,
14598 presuming the other language has corresponding features. Pragma
14599 @code{Convention} need not be supported for scalar types."
14600 @end quotation
14601
14602 Followed.
14603
14604 @geindex Package Interfaces
14605
14606 @geindex Interfaces
14607
14608 @node RM B 2 12-13 Package Interfaces,RM B 3 63-71 Interfacing with C,RM B 1 39-41 Pragma Export,Implementation Advice
14609 @anchor{gnat_rm/implementation_advice rm-b-2-12-13-package-interfaces}@anchor{23c}
14610 @section RM B.2(12-13): Package @code{Interfaces}
14611
14612
14613 @quotation
14614
14615 "For each implementation-defined convention identifier, there should be a
14616 child package of package Interfaces with the corresponding name. This
14617 package should contain any declarations that would be useful for
14618 interfacing to the language (implementation) represented by the
14619 convention. Any declarations useful for interfacing to any language on
14620 the given hardware architecture should be provided directly in
14621 @code{Interfaces}."
14622 @end quotation
14623
14624 Followed.
14625
14626 @quotation
14627
14628 "An implementation supporting an interface to C, COBOL, or Fortran should
14629 provide the corresponding package or packages described in the following
14630 clauses."
14631 @end quotation
14632
14633 Followed. GNAT provides all the packages described in this section.
14634
14635 @geindex C
14636 @geindex interfacing with
14637
14638 @node RM B 3 63-71 Interfacing with C,RM B 4 95-98 Interfacing with COBOL,RM B 2 12-13 Package Interfaces,Implementation Advice
14639 @anchor{gnat_rm/implementation_advice rm-b-3-63-71-interfacing-with-c}@anchor{23d}
14640 @section RM B.3(63-71): Interfacing with C
14641
14642
14643 @quotation
14644
14645 "An implementation should support the following interface correspondences
14646 between Ada and C."
14647 @end quotation
14648
14649 Followed.
14650
14651 @quotation
14652
14653 "An Ada procedure corresponds to a void-returning C function."
14654 @end quotation
14655
14656 Followed.
14657
14658 @quotation
14659
14660 "An Ada function corresponds to a non-void C function."
14661 @end quotation
14662
14663 Followed.
14664
14665 @quotation
14666
14667 "An Ada @code{in} scalar parameter is passed as a scalar argument to a C
14668 function."
14669 @end quotation
14670
14671 Followed.
14672
14673 @quotation
14674
14675 "An Ada @code{in} parameter of an access-to-object type with designated
14676 type @code{T} is passed as a @code{t*} argument to a C function,
14677 where @code{t} is the C type corresponding to the Ada type @code{T}."
14678 @end quotation
14679
14680 Followed.
14681
14682 @quotation
14683
14684 "An Ada access @code{T} parameter, or an Ada @code{out} or @code{in out}
14685 parameter of an elementary type @code{T}, is passed as a @code{t*}
14686 argument to a C function, where @code{t} is the C type corresponding to
14687 the Ada type @code{T}. In the case of an elementary @code{out} or
14688 @code{in out} parameter, a pointer to a temporary copy is used to
14689 preserve by-copy semantics."
14690 @end quotation
14691
14692 Followed.
14693
14694 @quotation
14695
14696 "An Ada parameter of a record type @code{T}, of any mode, is passed as a
14697 @code{t*} argument to a C function, where @code{t} is the C
14698 structure corresponding to the Ada type @code{T}."
14699 @end quotation
14700
14701 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
14702 pragma, or Convention, or by explicitly specifying the mechanism for a given
14703 call using an extended import or export pragma.
14704
14705 @quotation
14706
14707 "An Ada parameter of an array type with component type @code{T}, of any
14708 mode, is passed as a @code{t*} argument to a C function, where
14709 @code{t} is the C type corresponding to the Ada type @code{T}."
14710 @end quotation
14711
14712 Followed.
14713
14714 @quotation
14715
14716 "An Ada parameter of an access-to-subprogram type is passed as a pointer
14717 to a C function whose prototype corresponds to the designated
14718 subprogram's specification."
14719 @end quotation
14720
14721 Followed.
14722
14723 @geindex COBOL
14724 @geindex interfacing with
14725
14726 @node RM B 4 95-98 Interfacing with COBOL,RM B 5 22-26 Interfacing with Fortran,RM B 3 63-71 Interfacing with C,Implementation Advice
14727 @anchor{gnat_rm/implementation_advice rm-b-4-95-98-interfacing-with-cobol}@anchor{23e}
14728 @section RM B.4(95-98): Interfacing with COBOL
14729
14730
14731 @quotation
14732
14733 "An Ada implementation should support the following interface
14734 correspondences between Ada and COBOL."
14735 @end quotation
14736
14737 Followed.
14738
14739 @quotation
14740
14741 "An Ada access @code{T} parameter is passed as a @code{BY REFERENCE} data item of
14742 the COBOL type corresponding to @code{T}."
14743 @end quotation
14744
14745 Followed.
14746
14747 @quotation
14748
14749 "An Ada in scalar parameter is passed as a @code{BY CONTENT} data item of
14750 the corresponding COBOL type."
14751 @end quotation
14752
14753 Followed.
14754
14755 @quotation
14756
14757 "Any other Ada parameter is passed as a @code{BY REFERENCE} data item of the
14758 COBOL type corresponding to the Ada parameter type; for scalars, a local
14759 copy is used if necessary to ensure by-copy semantics."
14760 @end quotation
14761
14762 Followed.
14763
14764 @geindex Fortran
14765 @geindex interfacing with
14766
14767 @node RM B 5 22-26 Interfacing with Fortran,RM C 1 3-5 Access to Machine Operations,RM B 4 95-98 Interfacing with COBOL,Implementation Advice
14768 @anchor{gnat_rm/implementation_advice rm-b-5-22-26-interfacing-with-fortran}@anchor{23f}
14769 @section RM B.5(22-26): Interfacing with Fortran
14770
14771
14772 @quotation
14773
14774 "An Ada implementation should support the following interface
14775 correspondences between Ada and Fortran:"
14776 @end quotation
14777
14778 Followed.
14779
14780 @quotation
14781
14782 "An Ada procedure corresponds to a Fortran subroutine."
14783 @end quotation
14784
14785 Followed.
14786
14787 @quotation
14788
14789 "An Ada function corresponds to a Fortran function."
14790 @end quotation
14791
14792 Followed.
14793
14794 @quotation
14795
14796 "An Ada parameter of an elementary, array, or record type @code{T} is
14797 passed as a @code{T} argument to a Fortran procedure, where @code{T} is
14798 the Fortran type corresponding to the Ada type @code{T}, and where the
14799 INTENT attribute of the corresponding dummy argument matches the Ada
14800 formal parameter mode; the Fortran implementation's parameter passing
14801 conventions are used. For elementary types, a local copy is used if
14802 necessary to ensure by-copy semantics."
14803 @end quotation
14804
14805 Followed.
14806
14807 @quotation
14808
14809 "An Ada parameter of an access-to-subprogram type is passed as a
14810 reference to a Fortran procedure whose interface corresponds to the
14811 designated subprogram's specification."
14812 @end quotation
14813
14814 Followed.
14815
14816 @geindex Machine operations
14817
14818 @node RM C 1 3-5 Access to Machine Operations,RM C 1 10-16 Access to Machine Operations,RM B 5 22-26 Interfacing with Fortran,Implementation Advice
14819 @anchor{gnat_rm/implementation_advice rm-c-1-3-5-access-to-machine-operations}@anchor{240}
14820 @section RM C.1(3-5): Access to Machine Operations
14821
14822
14823 @quotation
14824
14825 "The machine code or intrinsic support should allow access to all
14826 operations normally available to assembly language programmers for the
14827 target environment, including privileged instructions, if any."
14828 @end quotation
14829
14830 Followed.
14831
14832 @quotation
14833
14834 "The interfacing pragmas (see Annex B) should support interface to
14835 assembler; the default assembler should be associated with the
14836 convention identifier @code{Assembler}."
14837 @end quotation
14838
14839 Followed.
14840
14841 @quotation
14842
14843 "If an entity is exported to assembly language, then the implementation
14844 should allocate it at an addressable location, and should ensure that it
14845 is retained by the linking process, even if not otherwise referenced
14846 from the Ada code. The implementation should assume that any call to a
14847 machine code or assembler subprogram is allowed to read or update every
14848 object that is specified as exported."
14849 @end quotation
14850
14851 Followed.
14852
14853 @node RM C 1 10-16 Access to Machine Operations,RM C 3 28 Interrupt Support,RM C 1 3-5 Access to Machine Operations,Implementation Advice
14854 @anchor{gnat_rm/implementation_advice rm-c-1-10-16-access-to-machine-operations}@anchor{241}
14855 @section RM C.1(10-16): Access to Machine Operations
14856
14857
14858 @quotation
14859
14860 "The implementation should ensure that little or no overhead is
14861 associated with calling intrinsic and machine-code subprograms."
14862 @end quotation
14863
14864 Followed for both intrinsics and machine-code subprograms.
14865
14866 @quotation
14867
14868 "It is recommended that intrinsic subprograms be provided for convenient
14869 access to any machine operations that provide special capabilities or
14870 efficiency and that are not otherwise available through the language
14871 constructs."
14872 @end quotation
14873
14874 Followed. A full set of machine operation intrinsic subprograms is provided.
14875
14876 @quotation
14877
14878 "Atomic read-modify-write operations---e.g., test and set, compare and
14879 swap, decrement and test, enqueue/dequeue."
14880 @end quotation
14881
14882 Followed on any target supporting such operations.
14883
14884 @quotation
14885
14886 "Standard numeric functions---e.g.:, sin, log."
14887 @end quotation
14888
14889 Followed on any target supporting such operations.
14890
14891 @quotation
14892
14893 "String manipulation operations---e.g.:, translate and test."
14894 @end quotation
14895
14896 Followed on any target supporting such operations.
14897
14898 @quotation
14899
14900 "Vector operations---e.g.:, compare vector against thresholds."
14901 @end quotation
14902
14903 Followed on any target supporting such operations.
14904
14905 @quotation
14906
14907 "Direct operations on I/O ports."
14908 @end quotation
14909
14910 Followed on any target supporting such operations.
14911
14912 @geindex Interrupt support
14913
14914 @node RM C 3 28 Interrupt Support,RM C 3 1 20-21 Protected Procedure Handlers,RM C 1 10-16 Access to Machine Operations,Implementation Advice
14915 @anchor{gnat_rm/implementation_advice rm-c-3-28-interrupt-support}@anchor{242}
14916 @section RM C.3(28): Interrupt Support
14917
14918
14919 @quotation
14920
14921 "If the @code{Ceiling_Locking} policy is not in effect, the
14922 implementation should provide means for the application to specify which
14923 interrupts are to be blocked during protected actions, if the underlying
14924 system allows for a finer-grain control of interrupt blocking."
14925 @end quotation
14926
14927 Followed. The underlying system does not allow for finer-grain control
14928 of interrupt blocking.
14929
14930 @geindex Protected procedure handlers
14931
14932 @node RM C 3 1 20-21 Protected Procedure Handlers,RM C 3 2 25 Package Interrupts,RM C 3 28 Interrupt Support,Implementation Advice
14933 @anchor{gnat_rm/implementation_advice rm-c-3-1-20-21-protected-procedure-handlers}@anchor{243}
14934 @section RM C.3.1(20-21): Protected Procedure Handlers
14935
14936
14937 @quotation
14938
14939 "Whenever possible, the implementation should allow interrupt handlers to
14940 be called directly by the hardware."
14941 @end quotation
14942
14943 Followed on any target where the underlying operating system permits
14944 such direct calls.
14945
14946 @quotation
14947
14948 "Whenever practical, violations of any
14949 implementation-defined restrictions should be detected before run time."
14950 @end quotation
14951
14952 Followed. Compile time warnings are given when possible.
14953
14954 @geindex Package `@w{`}Interrupts`@w{`}
14955
14956 @geindex Interrupts
14957
14958 @node RM C 3 2 25 Package Interrupts,RM C 4 14 Pre-elaboration Requirements,RM C 3 1 20-21 Protected Procedure Handlers,Implementation Advice
14959 @anchor{gnat_rm/implementation_advice rm-c-3-2-25-package-interrupts}@anchor{244}
14960 @section RM C.3.2(25): Package @code{Interrupts}
14961
14962
14963 @quotation
14964
14965 "If implementation-defined forms of interrupt handler procedures are
14966 supported, such as protected procedures with parameters, then for each
14967 such form of a handler, a type analogous to @code{Parameterless_Handler}
14968 should be specified in a child package of @code{Interrupts}, with the
14969 same operations as in the predefined package Interrupts."
14970 @end quotation
14971
14972 Followed.
14973
14974 @geindex Pre-elaboration requirements
14975
14976 @node RM C 4 14 Pre-elaboration Requirements,RM C 5 8 Pragma Discard_Names,RM C 3 2 25 Package Interrupts,Implementation Advice
14977 @anchor{gnat_rm/implementation_advice rm-c-4-14-pre-elaboration-requirements}@anchor{245}
14978 @section RM C.4(14): Pre-elaboration Requirements
14979
14980
14981 @quotation
14982
14983 "It is recommended that pre-elaborated packages be implemented in such a
14984 way that there should be little or no code executed at run time for the
14985 elaboration of entities not already covered by the Implementation
14986 Requirements."
14987 @end quotation
14988
14989 Followed. Executable code is generated in some cases, e.g., loops
14990 to initialize large arrays.
14991
14992 @node RM C 5 8 Pragma Discard_Names,RM C 7 2 30 The Package Task_Attributes,RM C 4 14 Pre-elaboration Requirements,Implementation Advice
14993 @anchor{gnat_rm/implementation_advice rm-c-5-8-pragma-discard-names}@anchor{246}
14994 @section RM C.5(8): Pragma @code{Discard_Names}
14995
14996
14997 @quotation
14998
14999 "If the pragma applies to an entity, then the implementation should
15000 reduce the amount of storage used for storing names associated with that
15001 entity."
15002 @end quotation
15003
15004 Followed.
15005
15006 @geindex Package Task_Attributes
15007
15008 @geindex Task_Attributes
15009
15010 @node RM C 7 2 30 The Package Task_Attributes,RM D 3 17 Locking Policies,RM C 5 8 Pragma Discard_Names,Implementation Advice
15011 @anchor{gnat_rm/implementation_advice rm-c-7-2-30-the-package-task-attributes}@anchor{247}
15012 @section RM C.7.2(30): The Package Task_Attributes
15013
15014
15015 @quotation
15016
15017 "Some implementations are targeted to domains in which memory use at run
15018 time must be completely deterministic. For such implementations, it is
15019 recommended that the storage for task attributes will be pre-allocated
15020 statically and not from the heap. This can be accomplished by either
15021 placing restrictions on the number and the size of the task's
15022 attributes, or by using the pre-allocated storage for the first @code{N}
15023 attribute objects, and the heap for the others. In the latter case,
15024 @code{N} should be documented."
15025 @end quotation
15026
15027 Not followed. This implementation is not targeted to such a domain.
15028
15029 @geindex Locking Policies
15030
15031 @node RM D 3 17 Locking Policies,RM D 4 16 Entry Queuing Policies,RM C 7 2 30 The Package Task_Attributes,Implementation Advice
15032 @anchor{gnat_rm/implementation_advice rm-d-3-17-locking-policies}@anchor{248}
15033 @section RM D.3(17): Locking Policies
15034
15035
15036 @quotation
15037
15038 "The implementation should use names that end with @code{_Locking} for
15039 locking policies defined by the implementation."
15040 @end quotation
15041
15042 Followed. Two implementation-defined locking policies are defined,
15043 whose names (@code{Inheritance_Locking} and
15044 @code{Concurrent_Readers_Locking}) follow this suggestion.
15045
15046 @geindex Entry queuing policies
15047
15048 @node RM D 4 16 Entry Queuing Policies,RM D 6 9-10 Preemptive Abort,RM D 3 17 Locking Policies,Implementation Advice
15049 @anchor{gnat_rm/implementation_advice rm-d-4-16-entry-queuing-policies}@anchor{249}
15050 @section RM D.4(16): Entry Queuing Policies
15051
15052
15053 @quotation
15054
15055 "Names that end with @code{_Queuing} should be used
15056 for all implementation-defined queuing policies."
15057 @end quotation
15058
15059 Followed. No such implementation-defined queuing policies exist.
15060
15061 @geindex Preemptive abort
15062
15063 @node RM D 6 9-10 Preemptive Abort,RM D 7 21 Tasking Restrictions,RM D 4 16 Entry Queuing Policies,Implementation Advice
15064 @anchor{gnat_rm/implementation_advice rm-d-6-9-10-preemptive-abort}@anchor{24a}
15065 @section RM D.6(9-10): Preemptive Abort
15066
15067
15068 @quotation
15069
15070 "Even though the @emph{abort_statement} is included in the list of
15071 potentially blocking operations (see 9.5.1), it is recommended that this
15072 statement be implemented in a way that never requires the task executing
15073 the @emph{abort_statement} to block."
15074 @end quotation
15075
15076 Followed.
15077
15078 @quotation
15079
15080 "On a multi-processor, the delay associated with aborting a task on
15081 another processor should be bounded; the implementation should use
15082 periodic polling, if necessary, to achieve this."
15083 @end quotation
15084
15085 Followed.
15086
15087 @geindex Tasking restrictions
15088
15089 @node RM D 7 21 Tasking Restrictions,RM D 8 47-49 Monotonic Time,RM D 6 9-10 Preemptive Abort,Implementation Advice
15090 @anchor{gnat_rm/implementation_advice rm-d-7-21-tasking-restrictions}@anchor{24b}
15091 @section RM D.7(21): Tasking Restrictions
15092
15093
15094 @quotation
15095
15096 "When feasible, the implementation should take advantage of the specified
15097 restrictions to produce a more efficient implementation."
15098 @end quotation
15099
15100 GNAT currently takes advantage of these restrictions by providing an optimized
15101 run time when the Ravenscar profile and the GNAT restricted run time set
15102 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
15103 pragma @code{Profile (Restricted)} for more details.
15104
15105 @geindex Time
15106 @geindex monotonic
15107
15108 @node RM D 8 47-49 Monotonic Time,RM E 5 28-29 Partition Communication Subsystem,RM D 7 21 Tasking Restrictions,Implementation Advice
15109 @anchor{gnat_rm/implementation_advice rm-d-8-47-49-monotonic-time}@anchor{24c}
15110 @section RM D.8(47-49): Monotonic Time
15111
15112
15113 @quotation
15114
15115 "When appropriate, implementations should provide configuration
15116 mechanisms to change the value of @code{Tick}."
15117 @end quotation
15118
15119 Such configuration mechanisms are not appropriate to this implementation
15120 and are thus not supported.
15121
15122 @quotation
15123
15124 "It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
15125 be implemented as transformations of the same time base."
15126 @end quotation
15127
15128 Followed.
15129
15130 @quotation
15131
15132 "It is recommended that the best time base which exists in
15133 the underlying system be available to the application through
15134 @code{Clock}. @cite{Best} may mean highest accuracy or largest range."
15135 @end quotation
15136
15137 Followed.
15138
15139 @geindex Partition communication subsystem
15140
15141 @geindex PCS
15142
15143 @node RM E 5 28-29 Partition Communication Subsystem,RM F 7 COBOL Support,RM D 8 47-49 Monotonic Time,Implementation Advice
15144 @anchor{gnat_rm/implementation_advice rm-e-5-28-29-partition-communication-subsystem}@anchor{24d}
15145 @section RM E.5(28-29): Partition Communication Subsystem
15146
15147
15148 @quotation
15149
15150 "Whenever possible, the PCS on the called partition should allow for
15151 multiple tasks to call the RPC-receiver with different messages and
15152 should allow them to block until the corresponding subprogram body
15153 returns."
15154 @end quotation
15155
15156 Followed by GLADE, a separately supplied PCS that can be used with
15157 GNAT.
15158
15159 @quotation
15160
15161 "The @code{Write} operation on a stream of type @code{Params_Stream_Type}
15162 should raise @code{Storage_Error} if it runs out of space trying to
15163 write the @code{Item} into the stream."
15164 @end quotation
15165
15166 Followed by GLADE, a separately supplied PCS that can be used with
15167 GNAT.
15168
15169 @geindex COBOL support
15170
15171 @node RM F 7 COBOL Support,RM F 1 2 Decimal Radix Support,RM E 5 28-29 Partition Communication Subsystem,Implementation Advice
15172 @anchor{gnat_rm/implementation_advice rm-f-7-cobol-support}@anchor{24e}
15173 @section RM F(7): COBOL Support
15174
15175
15176 @quotation
15177
15178 "If COBOL (respectively, C) is widely supported in the target
15179 environment, implementations supporting the Information Systems Annex
15180 should provide the child package @code{Interfaces.COBOL} (respectively,
15181 @code{Interfaces.C}) specified in Annex B and should support a
15182 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
15183 pragmas (see Annex B), thus allowing Ada programs to interface with
15184 programs written in that language."
15185 @end quotation
15186
15187 Followed.
15188
15189 @geindex Decimal radix support
15190
15191 @node RM F 1 2 Decimal Radix Support,RM G Numerics,RM F 7 COBOL Support,Implementation Advice
15192 @anchor{gnat_rm/implementation_advice rm-f-1-2-decimal-radix-support}@anchor{24f}
15193 @section RM F.1(2): Decimal Radix Support
15194
15195
15196 @quotation
15197
15198 "Packed decimal should be used as the internal representation for objects
15199 of subtype @code{S} when @code{S}'Machine_Radix = 10."
15200 @end quotation
15201
15202 Not followed. GNAT ignores @code{S}'Machine_Radix and always uses binary
15203 representations.
15204
15205 @geindex Numerics
15206
15207 @node RM G Numerics,RM G 1 1 56-58 Complex Types,RM F 1 2 Decimal Radix Support,Implementation Advice
15208 @anchor{gnat_rm/implementation_advice rm-g-numerics}@anchor{250}
15209 @section RM G: Numerics
15210
15211
15212 @quotation
15213
15214 "If Fortran (respectively, C) is widely supported in the target
15215 environment, implementations supporting the Numerics Annex
15216 should provide the child package @code{Interfaces.Fortran} (respectively,
15217 @code{Interfaces.C}) specified in Annex B and should support a
15218 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
15219 pragmas (see Annex B), thus allowing Ada programs to interface with
15220 programs written in that language."
15221 @end quotation
15222
15223 Followed.
15224
15225 @geindex Complex types
15226
15227 @node RM G 1 1 56-58 Complex Types,RM G 1 2 49 Complex Elementary Functions,RM G Numerics,Implementation Advice
15228 @anchor{gnat_rm/implementation_advice rm-g-1-1-56-58-complex-types}@anchor{251}
15229 @section RM G.1.1(56-58): Complex Types
15230
15231
15232 @quotation
15233
15234 "Because the usual mathematical meaning of multiplication of a complex
15235 operand and a real operand is that of the scaling of both components of
15236 the former by the latter, an implementation should not perform this
15237 operation by first promoting the real operand to complex type and then
15238 performing a full complex multiplication. In systems that, in the
15239 future, support an Ada binding to IEC 559:1989, the latter technique
15240 will not generate the required result when one of the components of the
15241 complex operand is infinite. (Explicit multiplication of the infinite
15242 component by the zero component obtained during promotion yields a NaN
15243 that propagates into the final result.) Analogous advice applies in the
15244 case of multiplication of a complex operand and a pure-imaginary
15245 operand, and in the case of division of a complex operand by a real or
15246 pure-imaginary operand."
15247 @end quotation
15248
15249 Not followed.
15250
15251 @quotation
15252
15253 "Similarly, because the usual mathematical meaning of addition of a
15254 complex operand and a real operand is that the imaginary operand remains
15255 unchanged, an implementation should not perform this operation by first
15256 promoting the real operand to complex type and then performing a full
15257 complex addition. In implementations in which the @code{Signed_Zeros}
15258 attribute of the component type is @code{True} (and which therefore
15259 conform to IEC 559:1989 in regard to the handling of the sign of zero in
15260 predefined arithmetic operations), the latter technique will not
15261 generate the required result when the imaginary component of the complex
15262 operand is a negatively signed zero. (Explicit addition of the negative
15263 zero to the zero obtained during promotion yields a positive zero.)
15264 Analogous advice applies in the case of addition of a complex operand
15265 and a pure-imaginary operand, and in the case of subtraction of a
15266 complex operand and a real or pure-imaginary operand."
15267 @end quotation
15268
15269 Not followed.
15270
15271 @quotation
15272
15273 "Implementations in which @code{Real'Signed_Zeros} is @code{True} should
15274 attempt to provide a rational treatment of the signs of zero results and
15275 result components. As one example, the result of the @code{Argument}
15276 function should have the sign of the imaginary component of the
15277 parameter @code{X} when the point represented by that parameter lies on
15278 the positive real axis; as another, the sign of the imaginary component
15279 of the @code{Compose_From_Polar} function should be the same as
15280 (respectively, the opposite of) that of the @code{Argument} parameter when that
15281 parameter has a value of zero and the @code{Modulus} parameter has a
15282 nonnegative (respectively, negative) value."
15283 @end quotation
15284
15285 Followed.
15286
15287 @geindex Complex elementary functions
15288
15289 @node RM G 1 2 49 Complex Elementary Functions,RM G 2 4 19 Accuracy Requirements,RM G 1 1 56-58 Complex Types,Implementation Advice
15290 @anchor{gnat_rm/implementation_advice rm-g-1-2-49-complex-elementary-functions}@anchor{252}
15291 @section RM G.1.2(49): Complex Elementary Functions
15292
15293
15294 @quotation
15295
15296 "Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
15297 @code{True} should attempt to provide a rational treatment of the signs
15298 of zero results and result components. For example, many of the complex
15299 elementary functions have components that are odd functions of one of
15300 the parameter components; in these cases, the result component should
15301 have the sign of the parameter component at the origin. Other complex
15302 elementary functions have zero components whose sign is opposite that of
15303 a parameter component at the origin, or is always positive or always
15304 negative."
15305 @end quotation
15306
15307 Followed.
15308
15309 @geindex Accuracy requirements
15310
15311 @node RM G 2 4 19 Accuracy Requirements,RM G 2 6 15 Complex Arithmetic Accuracy,RM G 1 2 49 Complex Elementary Functions,Implementation Advice
15312 @anchor{gnat_rm/implementation_advice rm-g-2-4-19-accuracy-requirements}@anchor{253}
15313 @section RM G.2.4(19): Accuracy Requirements
15314
15315
15316 @quotation
15317
15318 "The versions of the forward trigonometric functions without a
15319 @code{Cycle} parameter should not be implemented by calling the
15320 corresponding version with a @code{Cycle} parameter of
15321 @code{2.0*Numerics.Pi}, since this will not provide the required
15322 accuracy in some portions of the domain. For the same reason, the
15323 version of @code{Log} without a @code{Base} parameter should not be
15324 implemented by calling the corresponding version with a @code{Base}
15325 parameter of @code{Numerics.e}."
15326 @end quotation
15327
15328 Followed.
15329
15330 @geindex Complex arithmetic accuracy
15331
15332 @geindex Accuracy
15333 @geindex complex arithmetic
15334
15335 @node RM G 2 6 15 Complex Arithmetic Accuracy,RM H 6 15/2 Pragma Partition_Elaboration_Policy,RM G 2 4 19 Accuracy Requirements,Implementation Advice
15336 @anchor{gnat_rm/implementation_advice rm-g-2-6-15-complex-arithmetic-accuracy}@anchor{254}
15337 @section RM G.2.6(15): Complex Arithmetic Accuracy
15338
15339
15340 @quotation
15341
15342 "The version of the @code{Compose_From_Polar} function without a
15343 @code{Cycle} parameter should not be implemented by calling the
15344 corresponding version with a @code{Cycle} parameter of
15345 @code{2.0*Numerics.Pi}, since this will not provide the required
15346 accuracy in some portions of the domain."
15347 @end quotation
15348
15349 Followed.
15350
15351 @geindex Sequential elaboration policy
15352
15353 @node RM H 6 15/2 Pragma Partition_Elaboration_Policy,,RM G 2 6 15 Complex Arithmetic Accuracy,Implementation Advice
15354 @anchor{gnat_rm/implementation_advice rm-h-6-15-2-pragma-partition-elaboration-policy}@anchor{255}
15355 @section RM H.6(15/2): Pragma Partition_Elaboration_Policy
15356
15357
15358 @quotation
15359
15360 "If the partition elaboration policy is @code{Sequential} and the
15361 Environment task becomes permanently blocked during elaboration then the
15362 partition is deadlocked and it is recommended that the partition be
15363 immediately terminated."
15364 @end quotation
15365
15366 Not followed.
15367
15368 @node Implementation Defined Characteristics,Intrinsic Subprograms,Implementation Advice,Top
15369 @anchor{gnat_rm/implementation_defined_characteristics implementation-defined-characteristics}@anchor{b}@anchor{gnat_rm/implementation_defined_characteristics doc}@anchor{256}@anchor{gnat_rm/implementation_defined_characteristics id1}@anchor{257}
15370 @chapter Implementation Defined Characteristics
15371
15372
15373 In addition to the implementation dependent pragmas and attributes, and the
15374 implementation advice, there are a number of other Ada features that are
15375 potentially implementation dependent and are designated as
15376 implementation-defined. These are mentioned throughout the Ada Reference
15377 Manual, and are summarized in Annex M.
15378
15379 A requirement for conforming Ada compilers is that they provide
15380 documentation describing how the implementation deals with each of these
15381 issues. In this chapter you will find each point in Annex M listed,
15382 followed by a description of how GNAT
15383 handles the implementation dependence.
15384
15385 You can use this chapter as a guide to minimizing implementation
15386 dependent features in your programs if portability to other compilers
15387 and other operating systems is an important consideration. The numbers
15388 in each entry below correspond to the paragraph numbers in the Ada
15389 Reference Manual.
15390
15391
15392 @itemize *
15393
15394 @item
15395 "Whether or not each recommendation given in Implementation
15396 Advice is followed. See 1.1.2(37)."
15397 @end itemize
15398
15399 See @ref{a,,Implementation Advice}.
15400
15401
15402 @itemize *
15403
15404 @item
15405 "Capacity limitations of the implementation. See 1.1.3(3)."
15406 @end itemize
15407
15408 The complexity of programs that can be processed is limited only by the
15409 total amount of available virtual memory, and disk space for the
15410 generated object files.
15411
15412
15413 @itemize *
15414
15415 @item
15416 "Variations from the standard that are impractical to avoid
15417 given the implementation's execution environment. See 1.1.3(6)."
15418 @end itemize
15419
15420 There are no variations from the standard.
15421
15422
15423 @itemize *
15424
15425 @item
15426 "Which code_statements cause external
15427 interactions. See 1.1.3(10)."
15428 @end itemize
15429
15430 Any @emph{code_statement} can potentially cause external interactions.
15431
15432
15433 @itemize *
15434
15435 @item
15436 "The coded representation for the text of an Ada
15437 program. See 2.1(4)."
15438 @end itemize
15439
15440 See separate section on source representation.
15441
15442
15443 @itemize *
15444
15445 @item
15446 "The control functions allowed in comments. See 2.1(14)."
15447 @end itemize
15448
15449 See separate section on source representation.
15450
15451
15452 @itemize *
15453
15454 @item
15455 "The representation for an end of line. See 2.2(2)."
15456 @end itemize
15457
15458 See separate section on source representation.
15459
15460
15461 @itemize *
15462
15463 @item
15464 "Maximum supported line length and lexical element
15465 length. See 2.2(15)."
15466 @end itemize
15467
15468 The maximum line length is 255 characters and the maximum length of
15469 a lexical element is also 255 characters. This is the default setting
15470 if not overridden by the use of compiler switch @emph{-gnaty} (which
15471 sets the maximum to 79) or @emph{-gnatyMnn} which allows the maximum
15472 line length to be specified to be any value up to 32767. The maximum
15473 length of a lexical element is the same as the maximum line length.
15474
15475
15476 @itemize *
15477
15478 @item
15479 "Implementation defined pragmas. See 2.8(14)."
15480 @end itemize
15481
15482 See @ref{7,,Implementation Defined Pragmas}.
15483
15484
15485 @itemize *
15486
15487 @item
15488 "Effect of pragma @code{Optimize}. See 2.8(27)."
15489 @end itemize
15490
15491 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
15492 parameter, checks that the optimization flag is set, and aborts if it is
15493 not.
15494
15495
15496 @itemize *
15497
15498 @item
15499 "The sequence of characters of the value returned by
15500 @code{S'Image} when some of the graphic characters of
15501 @code{S'Wide_Image} are not defined in @code{Character}. See
15502 3.5(37)."
15503 @end itemize
15504
15505 The sequence of characters is as defined by the wide character encoding
15506 method used for the source. See section on source representation for
15507 further details.
15508
15509
15510 @itemize *
15511
15512 @item
15513 "The predefined integer types declared in
15514 @code{Standard}. See 3.5.4(25)."
15515 @end itemize
15516
15517
15518 @multitable {xxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
15519 @headitem
15520
15521 Type
15522
15523 @tab
15524
15525 Representation
15526
15527 @item
15528
15529 @emph{Short_Short_Integer}
15530
15531 @tab
15532
15533 8 bit signed
15534
15535 @item
15536
15537 @emph{Short_Integer}
15538
15539 @tab
15540
15541 (Short) 16 bit signed
15542
15543 @item
15544
15545 @emph{Integer}
15546
15547 @tab
15548
15549 32 bit signed
15550
15551 @item
15552
15553 @emph{Long_Integer}
15554
15555 @tab
15556
15557 64 bit signed (on most 64 bit targets,
15558 depending on the C definition of long).
15559 32 bit signed (all other targets)
15560
15561 @item
15562
15563 @emph{Long_Long_Integer}
15564
15565 @tab
15566
15567 64 bit signed
15568
15569 @end multitable
15570
15571
15572
15573 @itemize *
15574
15575 @item
15576 "Any nonstandard integer types and the operators defined
15577 for them. See 3.5.4(26)."
15578 @end itemize
15579
15580 There are no nonstandard integer types.
15581
15582
15583 @itemize *
15584
15585 @item
15586 "Any nonstandard real types and the operators defined for
15587 them. See 3.5.6(8)."
15588 @end itemize
15589
15590 There are no nonstandard real types.
15591
15592
15593 @itemize *
15594
15595 @item
15596 "What combinations of requested decimal precision and range
15597 are supported for floating point types. See 3.5.7(7)."
15598 @end itemize
15599
15600 The precision and range is as defined by the IEEE standard.
15601
15602
15603 @itemize *
15604
15605 @item
15606 "The predefined floating point types declared in
15607 @code{Standard}. See 3.5.7(16)."
15608 @end itemize
15609
15610
15611 @multitable {xxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
15612 @headitem
15613
15614 Type
15615
15616 @tab
15617
15618 Representation
15619
15620 @item
15621
15622 @emph{Short_Float}
15623
15624 @tab
15625
15626 32 bit IEEE short
15627
15628 @item
15629
15630 @emph{Float}
15631
15632 @tab
15633
15634 (Short) 32 bit IEEE short
15635
15636 @item
15637
15638 @emph{Long_Float}
15639
15640 @tab
15641
15642 64 bit IEEE long
15643
15644 @item
15645
15646 @emph{Long_Long_Float}
15647
15648 @tab
15649
15650 64 bit IEEE long (80 bit IEEE long on x86 processors)
15651
15652 @end multitable
15653
15654
15655
15656 @itemize *
15657
15658 @item
15659 "The small of an ordinary fixed point type. See 3.5.9(8)."
15660 @end itemize
15661
15662 @code{Fine_Delta} is 2**(-63)
15663
15664
15665 @itemize *
15666
15667 @item
15668 "What combinations of small, range, and digits are
15669 supported for fixed point types. See 3.5.9(10)."
15670 @end itemize
15671
15672 Any combinations are permitted that do not result in a small less than
15673 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
15674 If the mantissa is larger than 53 bits on machines where Long_Long_Float
15675 is 64 bits (true of all architectures except ia32), then the output from
15676 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
15677 is because floating-point conversions are used to convert fixed point.
15678
15679
15680 @itemize *
15681
15682 @item
15683 "The result of @code{Tags.Expanded_Name} for types declared
15684 within an unnamed @emph{block_statement}. See 3.9(10)."
15685 @end itemize
15686
15687 Block numbers of the form @code{B@emph{nnn}}, where @emph{nnn} is a
15688 decimal integer are allocated.
15689
15690
15691 @itemize *
15692
15693 @item
15694 "Implementation-defined attributes. See 4.1.4(12)."
15695 @end itemize
15696
15697 See @ref{8,,Implementation Defined Attributes}.
15698
15699
15700 @itemize *
15701
15702 @item
15703 "Any implementation-defined time types. See 9.6(6)."
15704 @end itemize
15705
15706 There are no implementation-defined time types.
15707
15708
15709 @itemize *
15710
15711 @item
15712 "The time base associated with relative delays."
15713 @end itemize
15714
15715 See 9.6(20). The time base used is that provided by the C library
15716 function @code{gettimeofday}.
15717
15718
15719 @itemize *
15720
15721 @item
15722 "The time base of the type @code{Calendar.Time}. See
15723 9.6(23)."
15724 @end itemize
15725
15726 The time base used is that provided by the C library function
15727 @code{gettimeofday}.
15728
15729
15730 @itemize *
15731
15732 @item
15733 "The time zone used for package @code{Calendar}
15734 operations. See 9.6(24)."
15735 @end itemize
15736
15737 The time zone used by package @code{Calendar} is the current system time zone
15738 setting for local time, as accessed by the C library function
15739 @code{localtime}.
15740
15741
15742 @itemize *
15743
15744 @item
15745 "Any limit on @emph{delay_until_statements} of
15746 @emph{select_statements}. See 9.6(29)."
15747 @end itemize
15748
15749 There are no such limits.
15750
15751
15752 @itemize *
15753
15754 @item
15755 "Whether or not two non-overlapping parts of a composite
15756 object are independently addressable, in the case where packing, record
15757 layout, or @code{Component_Size} is specified for the object. See
15758 9.10(1)."
15759 @end itemize
15760
15761 Separate components are independently addressable if they do not share
15762 overlapping storage units.
15763
15764
15765 @itemize *
15766
15767 @item
15768 "The representation for a compilation. See 10.1(2)."
15769 @end itemize
15770
15771 A compilation is represented by a sequence of files presented to the
15772 compiler in a single invocation of the @emph{gcc} command.
15773
15774
15775 @itemize *
15776
15777 @item
15778 "Any restrictions on compilations that contain multiple
15779 compilation_units. See 10.1(4)."
15780 @end itemize
15781
15782 No single file can contain more than one compilation unit, but any
15783 sequence of files can be presented to the compiler as a single
15784 compilation.
15785
15786
15787 @itemize *
15788
15789 @item
15790 "The mechanisms for creating an environment and for adding
15791 and replacing compilation units. See 10.1.4(3)."
15792 @end itemize
15793
15794 See separate section on compilation model.
15795
15796
15797 @itemize *
15798
15799 @item
15800 "The manner of explicitly assigning library units to a
15801 partition. See 10.2(2)."
15802 @end itemize
15803
15804 If a unit contains an Ada main program, then the Ada units for the partition
15805 are determined by recursive application of the rules in the Ada Reference
15806 Manual section 10.2(2-6). In other words, the Ada units will be those that
15807 are needed by the main program, and then this definition of need is applied
15808 recursively to those units, and the partition contains the transitive
15809 closure determined by this relationship. In short, all the necessary units
15810 are included, with no need to explicitly specify the list. If additional
15811 units are required, e.g., by foreign language units, then all units must be
15812 mentioned in the context clause of one of the needed Ada units.
15813
15814 If the partition contains no main program, or if the main program is in
15815 a language other than Ada, then GNAT
15816 provides the binder options @emph{-z} and @emph{-n} respectively, and in
15817 this case a list of units can be explicitly supplied to the binder for
15818 inclusion in the partition (all units needed by these units will also
15819 be included automatically). For full details on the use of these
15820 options, refer to @emph{GNAT Make Program gnatmake} in the
15821 @cite{GNAT User's Guide}.
15822
15823
15824 @itemize *
15825
15826 @item
15827 "The implementation-defined means, if any, of specifying
15828 which compilation units are needed by a given compilation unit. See
15829 10.2(2)."
15830 @end itemize
15831
15832 The units needed by a given compilation unit are as defined in
15833 the Ada Reference Manual section 10.2(2-6). There are no
15834 implementation-defined pragmas or other implementation-defined
15835 means for specifying needed units.
15836
15837
15838 @itemize *
15839
15840 @item
15841 "The manner of designating the main subprogram of a
15842 partition. See 10.2(7)."
15843 @end itemize
15844
15845 The main program is designated by providing the name of the
15846 corresponding @code{ALI} file as the input parameter to the binder.
15847
15848
15849 @itemize *
15850
15851 @item
15852 "The order of elaboration of @emph{library_items}. See
15853 10.2(18)."
15854 @end itemize
15855
15856 The first constraint on ordering is that it meets the requirements of
15857 Chapter 10 of the Ada Reference Manual. This still leaves some
15858 implementation dependent choices, which are resolved by first
15859 elaborating bodies as early as possible (i.e., in preference to specs
15860 where there is a choice), and second by evaluating the immediate with
15861 clauses of a unit to determine the probably best choice, and
15862 third by elaborating in alphabetical order of unit names
15863 where a choice still remains.
15864
15865
15866 @itemize *
15867
15868 @item
15869 "Parameter passing and function return for the main
15870 subprogram. See 10.2(21)."
15871 @end itemize
15872
15873 The main program has no parameters. It may be a procedure, or a function
15874 returning an integer type. In the latter case, the returned integer
15875 value is the return code of the program (overriding any value that
15876 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
15877
15878
15879 @itemize *
15880
15881 @item
15882 "The mechanisms for building and running partitions. See
15883 10.2(24)."
15884 @end itemize
15885
15886 GNAT itself supports programs with only a single partition. The GNATDIST
15887 tool provided with the GLADE package (which also includes an implementation
15888 of the PCS) provides a completely flexible method for building and running
15889 programs consisting of multiple partitions. See the separate GLADE manual
15890 for details.
15891
15892
15893 @itemize *
15894
15895 @item
15896 "The details of program execution, including program
15897 termination. See 10.2(25)."
15898 @end itemize
15899
15900 See separate section on compilation model.
15901
15902
15903 @itemize *
15904
15905 @item
15906 "The semantics of any non-active partitions supported by the
15907 implementation. See 10.2(28)."
15908 @end itemize
15909
15910 Passive partitions are supported on targets where shared memory is
15911 provided by the operating system. See the GLADE reference manual for
15912 further details.
15913
15914
15915 @itemize *
15916
15917 @item
15918 "The information returned by @code{Exception_Message}. See
15919 11.4.1(10)."
15920 @end itemize
15921
15922 Exception message returns the null string unless a specific message has
15923 been passed by the program.
15924
15925
15926 @itemize *
15927
15928 @item
15929 "The result of @code{Exceptions.Exception_Name} for types
15930 declared within an unnamed @emph{block_statement}. See 11.4.1(12)."
15931 @end itemize
15932
15933 Blocks have implementation defined names of the form @code{B@emph{nnn}}
15934 where @emph{nnn} is an integer.
15935
15936
15937 @itemize *
15938
15939 @item
15940 "The information returned by
15941 @code{Exception_Information}. See 11.4.1(13)."
15942 @end itemize
15943
15944 @code{Exception_Information} returns a string in the following format:
15945
15946 @example
15947 *Exception_Name:* nnnnn
15948 *Message:* mmmmm
15949 *PID:* ppp
15950 *Load address:* 0xhhhh
15951 *Call stack traceback locations:*
15952 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
15953 @end example
15954
15955 where
15956
15957 @quotation
15958
15959
15960 @itemize *
15961
15962 @item
15963 @code{nnnn} is the fully qualified name of the exception in all upper
15964 case letters. This line is always present.
15965
15966 @item
15967 @code{mmmm} is the message (this line present only if message is non-null)
15968
15969 @item
15970 @code{ppp} is the Process Id value as a decimal integer (this line is
15971 present only if the Process Id is nonzero). Currently we are
15972 not making use of this field.
15973
15974 @item
15975 The Load address line, the Call stack traceback locations line and the
15976 following values are present only if at least one traceback location was
15977 recorded. The Load address indicates the address at which the main executable
15978 was loaded; this line may not be present if operating system hasn't relocated
15979 the main executable. The values are given in C style format, with lower case
15980 letters for a-f, and only as many digits present as are necessary.
15981 The line terminator sequence at the end of each line, including
15982 the last line is a single @code{LF} character (@code{16#0A#}).
15983 @end itemize
15984 @end quotation
15985
15986
15987 @itemize *
15988
15989 @item
15990 "Implementation-defined check names. See 11.5(27)."
15991 @end itemize
15992
15993 The implementation defined check names include Alignment_Check,
15994 Atomic_Synchronization, Duplicated_Tag_Check, Container_Checks,
15995 Tampering_Check, Predicate_Check, and Validity_Check. In addition, a user
15996 program can add implementation-defined check names by means of the pragma
15997 Check_Name. See the description of pragma @code{Suppress} for full details.
15998
15999
16000 @itemize *
16001
16002 @item
16003 "The interpretation of each aspect of representation. See
16004 13.1(20)."
16005 @end itemize
16006
16007 See separate section on data representations.
16008
16009
16010 @itemize *
16011
16012 @item
16013 "Any restrictions placed upon representation items. See
16014 13.1(20)."
16015 @end itemize
16016
16017 See separate section on data representations.
16018
16019
16020 @itemize *
16021
16022 @item
16023 "The meaning of @code{Size} for indefinite subtypes. See
16024 13.3(48)."
16025 @end itemize
16026
16027 Size for an indefinite subtype is the maximum possible size, except that
16028 for the case of a subprogram parameter, the size of the parameter object
16029 is the actual size.
16030
16031
16032 @itemize *
16033
16034 @item
16035 "The default external representation for a type tag. See
16036 13.3(75)."
16037 @end itemize
16038
16039 The default external representation for a type tag is the fully expanded
16040 name of the type in upper case letters.
16041
16042
16043 @itemize *
16044
16045 @item
16046 "What determines whether a compilation unit is the same in
16047 two different partitions. See 13.3(76)."
16048 @end itemize
16049
16050 A compilation unit is the same in two different partitions if and only
16051 if it derives from the same source file.
16052
16053
16054 @itemize *
16055
16056 @item
16057 "Implementation-defined components. See 13.5.1(15)."
16058 @end itemize
16059
16060 The only implementation defined component is the tag for a tagged type,
16061 which contains a pointer to the dispatching table.
16062
16063
16064 @itemize *
16065
16066 @item
16067 "If @code{Word_Size} = @code{Storage_Unit}, the default bit
16068 ordering. See 13.5.3(5)."
16069 @end itemize
16070
16071 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
16072 implementation, so no non-default bit ordering is supported. The default
16073 bit ordering corresponds to the natural endianness of the target architecture.
16074
16075
16076 @itemize *
16077
16078 @item
16079 "The contents of the visible part of package @code{System}
16080 and its language-defined children. See 13.7(2)."
16081 @end itemize
16082
16083 See the definition of these packages in files @code{system.ads} and
16084 @code{s-stoele.ads}. Note that two declarations are added to package
16085 System.
16086
16087 @example
16088 Max_Priority : constant Positive := Priority'Last;
16089 Max_Interrupt_Priority : constant Positive := Interrupt_Priority'Last;
16090 @end example
16091
16092
16093 @itemize *
16094
16095 @item
16096 "The contents of the visible part of package
16097 @code{System.Machine_Code}, and the meaning of
16098 @emph{code_statements}. See 13.8(7)."
16099 @end itemize
16100
16101 See the definition and documentation in file @code{s-maccod.ads}.
16102
16103
16104 @itemize *
16105
16106 @item
16107 "The effect of unchecked conversion. See 13.9(11)."
16108 @end itemize
16109
16110 Unchecked conversion between types of the same size
16111 results in an uninterpreted transmission of the bits from one type
16112 to the other. If the types are of unequal sizes, then in the case of
16113 discrete types, a shorter source is first zero or sign extended as
16114 necessary, and a shorter target is simply truncated on the left.
16115 For all non-discrete types, the source is first copied if necessary
16116 to ensure that the alignment requirements of the target are met, then
16117 a pointer is constructed to the source value, and the result is obtained
16118 by dereferencing this pointer after converting it to be a pointer to the
16119 target type. Unchecked conversions where the target subtype is an
16120 unconstrained array are not permitted. If the target alignment is
16121 greater than the source alignment, then a copy of the result is
16122 made with appropriate alignment
16123
16124
16125 @itemize *
16126
16127 @item
16128 "The semantics of operations on invalid representations.
16129 See 13.9.2(10-11)."
16130 @end itemize
16131
16132 For assignments and other operations where the use of invalid values cannot
16133 result in erroneous behavior, the compiler ignores the possibility of invalid
16134 values. An exception is raised at the point where an invalid value would
16135 result in erroneous behavior. For example executing:
16136
16137 @example
16138 procedure invalidvals is
16139 X : Integer := -1;
16140 Y : Natural range 1 .. 10;
16141 for Y'Address use X'Address;
16142 Z : Natural range 1 .. 10;
16143 A : array (Natural range 1 .. 10) of Integer;
16144 begin
16145 Z := Y; -- no exception
16146 A (Z) := 3; -- exception raised;
16147 end;
16148 @end example
16149
16150 As indicated, an exception is raised on the array assignment, but not
16151 on the simple assignment of the invalid negative value from Y to Z.
16152
16153
16154 @itemize *
16155
16156 @item
16157 "The manner of choosing a storage pool for an access type
16158 when @code{Storage_Pool} is not specified for the type. See 13.11(17)."
16159 @end itemize
16160
16161 There are 3 different standard pools used by the compiler when
16162 @code{Storage_Pool} is not specified depending whether the type is local
16163 to a subprogram or defined at the library level and whether
16164 @code{Storage_Size`@w{`}is specified or not. See documentation in the runtime
16165 library units `@w{`}System.Pool_Global}, @code{System.Pool_Size} and
16166 @code{System.Pool_Local} in files @code{s-poosiz.ads},
16167 @code{s-pooglo.ads} and @code{s-pooloc.ads} for full details on the
16168 default pools used.
16169
16170
16171 @itemize *
16172
16173 @item
16174 "Whether or not the implementation provides user-accessible
16175 names for the standard pool type(s). See 13.11(17)."
16176 @end itemize
16177
16178 See documentation in the sources of the run time mentioned in the previous
16179 paragraph. All these pools are accessible by means of @cite{with}ing
16180 these units.
16181
16182
16183 @itemize *
16184
16185 @item
16186 "The meaning of @code{Storage_Size}. See 13.11(18)."
16187 @end itemize
16188
16189 @code{Storage_Size} is measured in storage units, and refers to the
16190 total space available for an access type collection, or to the primary
16191 stack space for a task.
16192
16193
16194 @itemize *
16195
16196 @item
16197 "Implementation-defined aspects of storage pools. See
16198 13.11(22)."
16199 @end itemize
16200
16201 See documentation in the sources of the run time mentioned in the
16202 paragraph about standard storage pools above
16203 for details on GNAT-defined aspects of storage pools.
16204
16205
16206 @itemize *
16207
16208 @item
16209 "The set of restrictions allowed in a pragma
16210 @code{Restrictions}. See 13.12(7)."
16211 @end itemize
16212
16213 See @ref{9,,Standard and Implementation Defined Restrictions}.
16214
16215
16216 @itemize *
16217
16218 @item
16219 "The consequences of violating limitations on
16220 @code{Restrictions} pragmas. See 13.12(9)."
16221 @end itemize
16222
16223 Restrictions that can be checked at compile time result in illegalities
16224 if violated. Currently there are no other consequences of violating
16225 restrictions.
16226
16227
16228 @itemize *
16229
16230 @item
16231 "The representation used by the @code{Read} and
16232 @code{Write} attributes of elementary types in terms of stream
16233 elements. See 13.13.2(9)."
16234 @end itemize
16235
16236 The representation is the in-memory representation of the base type of
16237 the type, using the number of bits corresponding to the
16238 @code{type'Size} value, and the natural ordering of the machine.
16239
16240
16241 @itemize *
16242
16243 @item
16244 "The names and characteristics of the numeric subtypes
16245 declared in the visible part of package @code{Standard}. See A.1(3)."
16246 @end itemize
16247
16248 See items describing the integer and floating-point types supported.
16249
16250
16251 @itemize *
16252
16253 @item
16254 "The string returned by @code{Character_Set_Version}.
16255 See A.3.5(3)."
16256 @end itemize
16257
16258 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
16259 the string "Unicode 4.0", referring to version 4.0 of the
16260 Unicode specification.
16261
16262
16263 @itemize *
16264
16265 @item
16266 "The accuracy actually achieved by the elementary
16267 functions. See A.5.1(1)."
16268 @end itemize
16269
16270 The elementary functions correspond to the functions available in the C
16271 library. Only fast math mode is implemented.
16272
16273
16274 @itemize *
16275
16276 @item
16277 "The sign of a zero result from some of the operators or
16278 functions in @code{Numerics.Generic_Elementary_Functions}, when
16279 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46)."
16280 @end itemize
16281
16282 The sign of zeroes follows the requirements of the IEEE 754 standard on
16283 floating-point.
16284
16285
16286 @itemize *
16287
16288 @item
16289 "The value of
16290 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27)."
16291 @end itemize
16292
16293 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16294
16295
16296 @itemize *
16297
16298 @item
16299 "The value of
16300 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27)."
16301 @end itemize
16302
16303 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16304
16305
16306 @itemize *
16307
16308 @item
16309 "The algorithms for random number generation. See
16310 A.5.2(32)."
16311 @end itemize
16312
16313 The algorithm is the Mersenne Twister, as documented in the source file
16314 @code{s-rannum.adb}. This version of the algorithm has a period of
16315 2**19937-1.
16316
16317
16318 @itemize *
16319
16320 @item
16321 "The string representation of a random number generator's
16322 state. See A.5.2(38)."
16323 @end itemize
16324
16325 The value returned by the Image function is the concatenation of
16326 the fixed-width decimal representations of the 624 32-bit integers
16327 of the state vector.
16328
16329
16330 @itemize *
16331
16332 @item
16333 "The minimum time interval between calls to the
16334 time-dependent Reset procedure that are guaranteed to initiate different
16335 random number sequences. See A.5.2(45)."
16336 @end itemize
16337
16338 The minimum period between reset calls to guarantee distinct series of
16339 random numbers is one microsecond.
16340
16341
16342 @itemize *
16343
16344 @item
16345 "The values of the @code{Model_Mantissa},
16346 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
16347 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
16348 Annex is not supported. See A.5.3(72)."
16349 @end itemize
16350
16351 Run the compiler with @emph{-gnatS} to produce a listing of package
16352 @code{Standard}, has the values of all numeric attributes.
16353
16354
16355 @itemize *
16356
16357 @item
16358 "Any implementation-defined characteristics of the
16359 input-output packages. See A.7(14)."
16360 @end itemize
16361
16362 There are no special implementation defined characteristics for these
16363 packages.
16364
16365
16366 @itemize *
16367
16368 @item
16369 "The value of @code{Buffer_Size} in @code{Storage_IO}. See
16370 A.9(10)."
16371 @end itemize
16372
16373 All type representations are contiguous, and the @code{Buffer_Size} is
16374 the value of @code{type'Size} rounded up to the next storage unit
16375 boundary.
16376
16377
16378 @itemize *
16379
16380 @item
16381 "External files for standard input, standard output, and
16382 standard error See A.10(5)."
16383 @end itemize
16384
16385 These files are mapped onto the files provided by the C streams
16386 libraries. See source file @code{i-cstrea.ads} for further details.
16387
16388
16389 @itemize *
16390
16391 @item
16392 "The accuracy of the value produced by @code{Put}. See
16393 A.10.9(36)."
16394 @end itemize
16395
16396 If more digits are requested in the output than are represented by the
16397 precision of the value, zeroes are output in the corresponding least
16398 significant digit positions.
16399
16400
16401 @itemize *
16402
16403 @item
16404 "The meaning of @code{Argument_Count}, @code{Argument}, and
16405 @code{Command_Name}. See A.15(1)."
16406 @end itemize
16407
16408 These are mapped onto the @code{argv} and @code{argc} parameters of the
16409 main program in the natural manner.
16410
16411
16412 @itemize *
16413
16414 @item
16415 "The interpretation of the @code{Form} parameter in procedure
16416 @code{Create_Directory}. See A.16(56)."
16417 @end itemize
16418
16419 The @code{Form} parameter is not used.
16420
16421
16422 @itemize *
16423
16424 @item
16425 "The interpretation of the @code{Form} parameter in procedure
16426 @code{Create_Path}. See A.16(60)."
16427 @end itemize
16428
16429 The @code{Form} parameter is not used.
16430
16431
16432 @itemize *
16433
16434 @item
16435 "The interpretation of the @code{Form} parameter in procedure
16436 @code{Copy_File}. See A.16(68)."
16437 @end itemize
16438
16439 The @code{Form} parameter is case-insensitive.
16440 Two fields are recognized in the @code{Form} parameter:
16441
16442 @example
16443 *preserve=<value>*
16444 *mode=<value>*
16445 @end example
16446
16447 <value> starts immediately after the character '=' and ends with the
16448 character immediately preceding the next comma (',') or with the last
16449 character of the parameter.
16450
16451 The only possible values for preserve= are:
16452
16453
16454 @multitable {xxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16455 @headitem
16456
16457 Value
16458
16459 @tab
16460
16461 Meaning
16462
16463 @item
16464
16465 @emph{no_attributes}
16466
16467 @tab
16468
16469 Do not try to preserve any file attributes. This is the
16470 default if no preserve= is found in Form.
16471
16472 @item
16473
16474 @emph{all_attributes}
16475
16476 @tab
16477
16478 Try to preserve all file attributes (timestamps, access rights).
16479
16480 @item
16481
16482 @emph{timestamps}
16483
16484 @tab
16485
16486 Preserve the timestamp of the copied file, but not the other
16487 file attributes.
16488
16489 @end multitable
16490
16491
16492 The only possible values for mode= are:
16493
16494
16495 @multitable {xxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16496 @headitem
16497
16498 Value
16499
16500 @tab
16501
16502 Meaning
16503
16504 @item
16505
16506 @emph{copy}
16507
16508 @tab
16509
16510 Only do the copy if the destination file does not already exist.
16511 If it already exists, Copy_File fails.
16512
16513 @item
16514
16515 @emph{overwrite}
16516
16517 @tab
16518
16519 Copy the file in all cases. Overwrite an already existing destination file.
16520
16521 @item
16522
16523 @emph{append}
16524
16525 @tab
16526
16527 Append the original file to the destination file. If the destination file
16528 does not exist, the destination file is a copy of the source file.
16529 When mode=append, the field preserve=, if it exists, is not taken into account.
16530
16531 @end multitable
16532
16533
16534 If the Form parameter includes one or both of the fields and the value or
16535 values are incorrect, Copy_file fails with Use_Error.
16536
16537 Examples of correct Forms:
16538
16539 @example
16540 Form => "preserve=no_attributes,mode=overwrite" (the default)
16541 Form => "mode=append"
16542 Form => "mode=copy, preserve=all_attributes"
16543 @end example
16544
16545 Examples of incorrect Forms:
16546
16547 @example
16548 Form => "preserve=junk"
16549 Form => "mode=internal, preserve=timestamps"
16550 @end example
16551
16552
16553 @itemize *
16554
16555 @item
16556 "The interpretation of the @code{Pattern} parameter, when not the null string,
16557 in the @code{Start_Search} and @code{Search} procedures.
16558 See A.16(104) and A.16(112)."
16559 @end itemize
16560
16561 When the @code{Pattern} parameter is not the null string, it is interpreted
16562 according to the syntax of regular expressions as defined in the
16563 @code{GNAT.Regexp} package.
16564
16565 See @ref{258,,GNAT.Regexp (g-regexp.ads)}.
16566
16567
16568 @itemize *
16569
16570 @item
16571 "Implementation-defined convention names. See B.1(11)."
16572 @end itemize
16573
16574 The following convention names are supported
16575
16576
16577 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16578 @headitem
16579
16580 Convention Name
16581
16582 @tab
16583
16584 Interpretation
16585
16586 @item
16587
16588 @emph{Ada}
16589
16590 @tab
16591
16592 Ada
16593
16594 @item
16595
16596 @emph{Ada_Pass_By_Copy}
16597
16598 @tab
16599
16600 Allowed for any types except by-reference types such as limited
16601 records. Compatible with convention Ada, but causes any parameters
16602 with this convention to be passed by copy.
16603
16604 @item
16605
16606 @emph{Ada_Pass_By_Reference}
16607
16608 @tab
16609
16610 Allowed for any types except by-copy types such as scalars.
16611 Compatible with convention Ada, but causes any parameters
16612 with this convention to be passed by reference.
16613
16614 @item
16615
16616 @emph{Assembler}
16617
16618 @tab
16619
16620 Assembly language
16621
16622 @item
16623
16624 @emph{Asm}
16625
16626 @tab
16627
16628 Synonym for Assembler
16629
16630 @item
16631
16632 @emph{Assembly}
16633
16634 @tab
16635
16636 Synonym for Assembler
16637
16638 @item
16639
16640 @emph{C}
16641
16642 @tab
16643
16644 C
16645
16646 @item
16647
16648 @emph{C_Pass_By_Copy}
16649
16650 @tab
16651
16652 Allowed only for record types, like C, but also notes that record
16653 is to be passed by copy rather than reference.
16654
16655 @item
16656
16657 @emph{COBOL}
16658
16659 @tab
16660
16661 COBOL
16662
16663 @item
16664
16665 @emph{C_Plus_Plus (or CPP)}
16666
16667 @tab
16668
16669 C++
16670
16671 @item
16672
16673 @emph{Default}
16674
16675 @tab
16676
16677 Treated the same as C
16678
16679 @item
16680
16681 @emph{External}
16682
16683 @tab
16684
16685 Treated the same as C
16686
16687 @item
16688
16689 @emph{Fortran}
16690
16691 @tab
16692
16693 Fortran
16694
16695 @item
16696
16697 @emph{Intrinsic}
16698
16699 @tab
16700
16701 For support of pragma @code{Import} with convention Intrinsic, see
16702 separate section on Intrinsic Subprograms.
16703
16704 @item
16705
16706 @emph{Stdcall}
16707
16708 @tab
16709
16710 Stdcall (used for Windows implementations only). This convention correspond
16711 to the WINAPI (previously called Pascal convention) C/C++ convention under
16712 Windows. A routine with this convention cleans the stack before
16713 exit. This pragma cannot be applied to a dispatching call.
16714
16715 @item
16716
16717 @emph{DLL}
16718
16719 @tab
16720
16721 Synonym for Stdcall
16722
16723 @item
16724
16725 @emph{Win32}
16726
16727 @tab
16728
16729 Synonym for Stdcall
16730
16731 @item
16732
16733 @emph{Stubbed}
16734
16735 @tab
16736
16737 Stubbed is a special convention used to indicate that the body of the
16738 subprogram will be entirely ignored. Any call to the subprogram
16739 is converted into a raise of the @code{Program_Error} exception. If a
16740 pragma @code{Import} specifies convention @code{stubbed} then no body need
16741 be present at all. This convention is useful during development for the
16742 inclusion of subprograms whose body has not yet been written.
16743 In addition, all otherwise unrecognized convention names are also
16744 treated as being synonymous with convention C. In all implementations,
16745 use of such other names results in a warning.
16746
16747 @end multitable
16748
16749
16750
16751 @itemize *
16752
16753 @item
16754 "The meaning of link names. See B.1(36)."
16755 @end itemize
16756
16757 Link names are the actual names used by the linker.
16758
16759
16760 @itemize *
16761
16762 @item
16763 "The manner of choosing link names when neither the link
16764 name nor the address of an imported or exported entity is specified. See
16765 B.1(36)."
16766 @end itemize
16767
16768 The default linker name is that which would be assigned by the relevant
16769 external language, interpreting the Ada name as being in all lower case
16770 letters.
16771
16772
16773 @itemize *
16774
16775 @item
16776 "The effect of pragma @code{Linker_Options}. See B.1(37)."
16777 @end itemize
16778
16779 The string passed to @code{Linker_Options} is presented uninterpreted as
16780 an argument to the link command, unless it contains ASCII.NUL characters.
16781 NUL characters if they appear act as argument separators, so for example
16782
16783 @example
16784 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
16785 @end example
16786
16787 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
16788 linker. The order of linker options is preserved for a given unit. The final
16789 list of options passed to the linker is in reverse order of the elaboration
16790 order. For example, linker options for a body always appear before the options
16791 from the corresponding package spec.
16792
16793
16794 @itemize *
16795
16796 @item
16797 "The contents of the visible part of package
16798 @code{Interfaces} and its language-defined descendants. See B.2(1)."
16799 @end itemize
16800
16801 See files with prefix @code{i-} in the distributed library.
16802
16803
16804 @itemize *
16805
16806 @item
16807 "Implementation-defined children of package
16808 @code{Interfaces}. The contents of the visible part of package
16809 @code{Interfaces}. See B.2(11)."
16810 @end itemize
16811
16812 See files with prefix @code{i-} in the distributed library.
16813
16814
16815 @itemize *
16816
16817 @item
16818 "The types @code{Floating}, @code{Long_Floating},
16819 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
16820 @code{COBOL_Character}; and the initialization of the variables
16821 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
16822 @code{Interfaces.COBOL}. See B.4(50)."
16823 @end itemize
16824
16825
16826 @multitable {xxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16827 @headitem
16828
16829 COBOL
16830
16831 @tab
16832
16833 Ada
16834
16835 @item
16836
16837 @emph{Floating}
16838
16839 @tab
16840
16841 Float
16842
16843 @item
16844
16845 @emph{Long_Floating}
16846
16847 @tab
16848
16849 (Floating) Long_Float
16850
16851 @item
16852
16853 @emph{Binary}
16854
16855 @tab
16856
16857 Integer
16858
16859 @item
16860
16861 @emph{Long_Binary}
16862
16863 @tab
16864
16865 Long_Long_Integer
16866
16867 @item
16868
16869 @emph{Decimal_Element}
16870
16871 @tab
16872
16873 Character
16874
16875 @item
16876
16877 @emph{COBOL_Character}
16878
16879 @tab
16880
16881 Character
16882
16883 @end multitable
16884
16885
16886 For initialization, see the file @code{i-cobol.ads} in the distributed library.
16887
16888
16889 @itemize *
16890
16891 @item
16892 "Support for access to machine instructions. See C.1(1)."
16893 @end itemize
16894
16895 See documentation in file @code{s-maccod.ads} in the distributed library.
16896
16897
16898 @itemize *
16899
16900 @item
16901 "Implementation-defined aspects of access to machine
16902 operations. See C.1(9)."
16903 @end itemize
16904
16905 See documentation in file @code{s-maccod.ads} in the distributed library.
16906
16907
16908 @itemize *
16909
16910 @item
16911 "Implementation-defined aspects of interrupts. See C.3(2)."
16912 @end itemize
16913
16914 Interrupts are mapped to signals or conditions as appropriate. See
16915 definition of unit
16916 @code{Ada.Interrupt_Names} in source file @code{a-intnam.ads} for details
16917 on the interrupts supported on a particular target.
16918
16919
16920 @itemize *
16921
16922 @item
16923 "Implementation-defined aspects of pre-elaboration. See
16924 C.4(13)."
16925 @end itemize
16926
16927 GNAT does not permit a partition to be restarted without reloading,
16928 except under control of the debugger.
16929
16930
16931 @itemize *
16932
16933 @item
16934 "The semantics of pragma @code{Discard_Names}. See C.5(7)."
16935 @end itemize
16936
16937 Pragma @code{Discard_Names} causes names of enumeration literals to
16938 be suppressed. In the presence of this pragma, the Image attribute
16939 provides the image of the Pos of the literal, and Value accepts
16940 Pos values.
16941
16942 For tagged types, when pragmas @code{Discard_Names} and @code{No_Tagged_Streams}
16943 simultaneously apply, their Expanded_Name and External_Tag are initialized
16944 with empty strings. This is useful to avoid exposing entity names at binary
16945 level.
16946
16947
16948 @itemize *
16949
16950 @item
16951 "The result of the @code{Task_Identification.Image}
16952 attribute. See C.7.1(7)."
16953 @end itemize
16954
16955 The result of this attribute is a string that identifies
16956 the object or component that denotes a given task. If a variable @code{Var}
16957 has a task type, the image for this task will have the form @code{Var_@emph{XXXXXXXX}},
16958 where the suffix @emph{XXXXXXXX}
16959 is the hexadecimal representation of the virtual address of the corresponding
16960 task control block. If the variable is an array of tasks, the image of each
16961 task will have the form of an indexed component indicating the position of a
16962 given task in the array, e.g., @code{Group(5)_@emph{XXXXXXX}}. If the task is a
16963 component of a record, the image of the task will have the form of a selected
16964 component. These rules are fully recursive, so that the image of a task that
16965 is a subcomponent of a composite object corresponds to the expression that
16966 designates this task.
16967
16968 If a task is created by an allocator, its image depends on the context. If the
16969 allocator is part of an object declaration, the rules described above are used
16970 to construct its image, and this image is not affected by subsequent
16971 assignments. If the allocator appears within an expression, the image
16972 includes only the name of the task type.
16973
16974 If the configuration pragma Discard_Names is present, or if the restriction
16975 No_Implicit_Heap_Allocation is in effect, the image reduces to
16976 the numeric suffix, that is to say the hexadecimal representation of the
16977 virtual address of the control block of the task.
16978
16979
16980 @itemize *
16981
16982 @item
16983 "The value of @code{Current_Task} when in a protected entry
16984 or interrupt handler. See C.7.1(17)."
16985 @end itemize
16986
16987 Protected entries or interrupt handlers can be executed by any
16988 convenient thread, so the value of @code{Current_Task} is undefined.
16989
16990
16991 @itemize *
16992
16993 @item
16994 "The effect of calling @code{Current_Task} from an entry
16995 body or interrupt handler. See C.7.1(19)."
16996 @end itemize
16997
16998 When GNAT can determine statically that @code{Current_Task} is called directly in
16999 the body of an entry (or barrier) then a warning is emitted and @code{Program_Error}
17000 is raised at run time. Otherwise, the effect of calling @code{Current_Task} from an
17001 entry body or interrupt handler is to return the identification of the task
17002 currently executing the code.
17003
17004
17005 @itemize *
17006
17007 @item
17008 "Implementation-defined aspects of
17009 @code{Task_Attributes}. See C.7.2(19)."
17010 @end itemize
17011
17012 There are no implementation-defined aspects of @code{Task_Attributes}.
17013
17014
17015 @itemize *
17016
17017 @item
17018 "Values of all @code{Metrics}. See D(2)."
17019 @end itemize
17020
17021 The metrics information for GNAT depends on the performance of the
17022 underlying operating system. The sources of the run-time for tasking
17023 implementation, together with the output from @emph{-gnatG} can be
17024 used to determine the exact sequence of operating systems calls made
17025 to implement various tasking constructs. Together with appropriate
17026 information on the performance of the underlying operating system,
17027 on the exact target in use, this information can be used to determine
17028 the required metrics.
17029
17030
17031 @itemize *
17032
17033 @item
17034 "The declarations of @code{Any_Priority} and
17035 @code{Priority}. See D.1(11)."
17036 @end itemize
17037
17038 See declarations in file @code{system.ads}.
17039
17040
17041 @itemize *
17042
17043 @item
17044 "Implementation-defined execution resources. See D.1(15)."
17045 @end itemize
17046
17047 There are no implementation-defined execution resources.
17048
17049
17050 @itemize *
17051
17052 @item
17053 "Whether, on a multiprocessor, a task that is waiting for
17054 access to a protected object keeps its processor busy. See D.2.1(3)."
17055 @end itemize
17056
17057 On a multi-processor, a task that is waiting for access to a protected
17058 object does not keep its processor busy.
17059
17060
17061 @itemize *
17062
17063 @item
17064 "The affect of implementation defined execution resources
17065 on task dispatching. See D.2.1(9)."
17066 @end itemize
17067
17068 Tasks map to threads in the threads package used by GNAT. Where possible
17069 and appropriate, these threads correspond to native threads of the
17070 underlying operating system.
17071
17072
17073 @itemize *
17074
17075 @item
17076 "Implementation-defined @emph{policy_identifiers} allowed
17077 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3)."
17078 @end itemize
17079
17080 There are no implementation-defined policy-identifiers allowed in this
17081 pragma.
17082
17083
17084 @itemize *
17085
17086 @item
17087 "Implementation-defined aspects of priority inversion. See
17088 D.2.2(16)."
17089 @end itemize
17090
17091 Execution of a task cannot be preempted by the implementation processing
17092 of delay expirations for lower priority tasks.
17093
17094
17095 @itemize *
17096
17097 @item
17098 "Implementation-defined task dispatching. See D.2.2(18)."
17099 @end itemize
17100
17101 The policy is the same as that of the underlying threads implementation.
17102
17103
17104 @itemize *
17105
17106 @item
17107 "Implementation-defined @emph{policy_identifiers} allowed
17108 in a pragma @code{Locking_Policy}. See D.3(4)."
17109 @end itemize
17110
17111 The two implementation defined policies permitted in GNAT are
17112 @code{Inheritance_Locking} and @code{Concurrent_Readers_Locking}. On
17113 targets that support the @code{Inheritance_Locking} policy, locking is
17114 implemented by inheritance, i.e., the task owning the lock operates
17115 at a priority equal to the highest priority of any task currently
17116 requesting the lock. On targets that support the
17117 @code{Concurrent_Readers_Locking} policy, locking is implemented with a
17118 read/write lock allowing multiple protected object functions to enter
17119 concurrently.
17120
17121
17122 @itemize *
17123
17124 @item
17125 "Default ceiling priorities. See D.3(10)."
17126 @end itemize
17127
17128 The ceiling priority of protected objects of the type
17129 @code{System.Interrupt_Priority'Last} as described in the Ada
17130 Reference Manual D.3(10),
17131
17132
17133 @itemize *
17134
17135 @item
17136 "The ceiling of any protected object used internally by
17137 the implementation. See D.3(16)."
17138 @end itemize
17139
17140 The ceiling priority of internal protected objects is
17141 @code{System.Priority'Last}.
17142
17143
17144 @itemize *
17145
17146 @item
17147 "Implementation-defined queuing policies. See D.4(1)."
17148 @end itemize
17149
17150 There are no implementation-defined queuing policies.
17151
17152
17153 @itemize *
17154
17155 @item
17156 "On a multiprocessor, any conditions that cause the
17157 completion of an aborted construct to be delayed later than what is
17158 specified for a single processor. See D.6(3)."
17159 @end itemize
17160
17161 The semantics for abort on a multi-processor is the same as on a single
17162 processor, there are no further delays.
17163
17164
17165 @itemize *
17166
17167 @item
17168 "Any operations that implicitly require heap storage
17169 allocation. See D.7(8)."
17170 @end itemize
17171
17172 The only operation that implicitly requires heap storage allocation is
17173 task creation.
17174
17175
17176 @itemize *
17177
17178 @item
17179 "What happens when a task terminates in the presence of
17180 pragma @code{No_Task_Termination}. See D.7(15)."
17181 @end itemize
17182
17183 Execution is erroneous in that case.
17184
17185
17186 @itemize *
17187
17188 @item
17189 "Implementation-defined aspects of pragma
17190 @code{Restrictions}. See D.7(20)."
17191 @end itemize
17192
17193 There are no such implementation-defined aspects.
17194
17195
17196 @itemize *
17197
17198 @item
17199 "Implementation-defined aspects of package
17200 @code{Real_Time}. See D.8(17)."
17201 @end itemize
17202
17203 There are no implementation defined aspects of package @code{Real_Time}.
17204
17205
17206 @itemize *
17207
17208 @item
17209 "Implementation-defined aspects of
17210 @emph{delay_statements}. See D.9(8)."
17211 @end itemize
17212
17213 Any difference greater than one microsecond will cause the task to be
17214 delayed (see D.9(7)).
17215
17216
17217 @itemize *
17218
17219 @item
17220 "The upper bound on the duration of interrupt blocking
17221 caused by the implementation. See D.12(5)."
17222 @end itemize
17223
17224 The upper bound is determined by the underlying operating system. In
17225 no cases is it more than 10 milliseconds.
17226
17227
17228 @itemize *
17229
17230 @item
17231 "The means for creating and executing distributed
17232 programs. See E(5)."
17233 @end itemize
17234
17235 The GLADE package provides a utility GNATDIST for creating and executing
17236 distributed programs. See the GLADE reference manual for further details.
17237
17238
17239 @itemize *
17240
17241 @item
17242 "Any events that can result in a partition becoming
17243 inaccessible. See E.1(7)."
17244 @end itemize
17245
17246 See the GLADE reference manual for full details on such events.
17247
17248
17249 @itemize *
17250
17251 @item
17252 "The scheduling policies, treatment of priorities, and
17253 management of shared resources between partitions in certain cases. See
17254 E.1(11)."
17255 @end itemize
17256
17257 See the GLADE reference manual for full details on these aspects of
17258 multi-partition execution.
17259
17260
17261 @itemize *
17262
17263 @item
17264 "Events that cause the version of a compilation unit to
17265 change. See E.3(5)."
17266 @end itemize
17267
17268 Editing the source file of a compilation unit, or the source files of
17269 any units on which it is dependent in a significant way cause the version
17270 to change. No other actions cause the version number to change. All changes
17271 are significant except those which affect only layout, capitalization or
17272 comments.
17273
17274
17275 @itemize *
17276
17277 @item
17278 "Whether the execution of the remote subprogram is
17279 immediately aborted as a result of cancellation. See E.4(13)."
17280 @end itemize
17281
17282 See the GLADE reference manual for details on the effect of abort in
17283 a distributed application.
17284
17285
17286 @itemize *
17287
17288 @item
17289 "Implementation-defined aspects of the PCS. See E.5(25)."
17290 @end itemize
17291
17292 See the GLADE reference manual for a full description of all implementation
17293 defined aspects of the PCS.
17294
17295
17296 @itemize *
17297
17298 @item
17299 "Implementation-defined interfaces in the PCS. See
17300 E.5(26)."
17301 @end itemize
17302
17303 See the GLADE reference manual for a full description of all
17304 implementation defined interfaces.
17305
17306
17307 @itemize *
17308
17309 @item
17310 "The values of named numbers in the package
17311 @code{Decimal}. See F.2(7)."
17312 @end itemize
17313
17314
17315 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxx}
17316 @headitem
17317
17318 Named Number
17319
17320 @tab
17321
17322 Value
17323
17324 @item
17325
17326 @emph{Max_Scale}
17327
17328 @tab
17329
17330 +18
17331
17332 @item
17333
17334 @emph{Min_Scale}
17335
17336 @tab
17337
17338 -18
17339
17340 @item
17341
17342 @emph{Min_Delta}
17343
17344 @tab
17345
17346 1.0E-18
17347
17348 @item
17349
17350 @emph{Max_Delta}
17351
17352 @tab
17353
17354 1.0E+18
17355
17356 @item
17357
17358 @emph{Max_Decimal_Digits}
17359
17360 @tab
17361
17362 18
17363
17364 @end multitable
17365
17366
17367
17368 @itemize *
17369
17370 @item
17371 "The value of @code{Max_Picture_Length} in the package
17372 @code{Text_IO.Editing}. See F.3.3(16)."
17373 @end itemize
17374
17375 64
17376
17377
17378 @itemize *
17379
17380 @item
17381 "The value of @code{Max_Picture_Length} in the package
17382 @code{Wide_Text_IO.Editing}. See F.3.4(5)."
17383 @end itemize
17384
17385 64
17386
17387
17388 @itemize *
17389
17390 @item
17391 "The accuracy actually achieved by the complex elementary
17392 functions and by other complex arithmetic operations. See G.1(1)."
17393 @end itemize
17394
17395 Standard library functions are used for the complex arithmetic
17396 operations. Only fast math mode is currently supported.
17397
17398
17399 @itemize *
17400
17401 @item
17402 "The sign of a zero result (or a component thereof) from
17403 any operator or function in @code{Numerics.Generic_Complex_Types}, when
17404 @code{Real'Signed_Zeros} is True. See G.1.1(53)."
17405 @end itemize
17406
17407 The signs of zero values are as recommended by the relevant
17408 implementation advice.
17409
17410
17411 @itemize *
17412
17413 @item
17414 "The sign of a zero result (or a component thereof) from
17415 any operator or function in
17416 @code{Numerics.Generic_Complex_Elementary_Functions}, when
17417 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45)."
17418 @end itemize
17419
17420 The signs of zero values are as recommended by the relevant
17421 implementation advice.
17422
17423
17424 @itemize *
17425
17426 @item
17427 "Whether the strict mode or the relaxed mode is the
17428 default. See G.2(2)."
17429 @end itemize
17430
17431 The strict mode is the default. There is no separate relaxed mode. GNAT
17432 provides a highly efficient implementation of strict mode.
17433
17434
17435 @itemize *
17436
17437 @item
17438 "The result interval in certain cases of fixed-to-float
17439 conversion. See G.2.1(10)."
17440 @end itemize
17441
17442 For cases where the result interval is implementation dependent, the
17443 accuracy is that provided by performing all operations in 64-bit IEEE
17444 floating-point format.
17445
17446
17447 @itemize *
17448
17449 @item
17450 "The result of a floating point arithmetic operation in
17451 overflow situations, when the @code{Machine_Overflows} attribute of the
17452 result type is @code{False}. See G.2.1(13)."
17453 @end itemize
17454
17455 Infinite and NaN values are produced as dictated by the IEEE
17456 floating-point standard.
17457 Note that on machines that are not fully compliant with the IEEE
17458 floating-point standard, such as Alpha, the @emph{-mieee} compiler flag
17459 must be used for achieving IEEE conforming behavior (although at the cost
17460 of a significant performance penalty), so infinite and NaN values are
17461 properly generated.
17462
17463
17464 @itemize *
17465
17466 @item
17467 "The result interval for division (or exponentiation by a
17468 negative exponent), when the floating point hardware implements division
17469 as multiplication by a reciprocal. See G.2.1(16)."
17470 @end itemize
17471
17472 Not relevant, division is IEEE exact.
17473
17474
17475 @itemize *
17476
17477 @item
17478 "The definition of close result set, which determines the
17479 accuracy of certain fixed point multiplications and divisions. See
17480 G.2.3(5)."
17481 @end itemize
17482
17483 Operations in the close result set are performed using IEEE long format
17484 floating-point arithmetic. The input operands are converted to
17485 floating-point, the operation is done in floating-point, and the result
17486 is converted to the target type.
17487
17488
17489 @itemize *
17490
17491 @item
17492 "Conditions on a @emph{universal_real} operand of a fixed
17493 point multiplication or division for which the result shall be in the
17494 perfect result set. See G.2.3(22)."
17495 @end itemize
17496
17497 The result is only defined to be in the perfect result set if the result
17498 can be computed by a single scaling operation involving a scale factor
17499 representable in 64-bits.
17500
17501
17502 @itemize *
17503
17504 @item
17505 "The result of a fixed point arithmetic operation in
17506 overflow situations, when the @code{Machine_Overflows} attribute of the
17507 result type is @code{False}. See G.2.3(27)."
17508 @end itemize
17509
17510 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
17511 types.
17512
17513
17514 @itemize *
17515
17516 @item
17517 "The result of an elementary function reference in
17518 overflow situations, when the @code{Machine_Overflows} attribute of the
17519 result type is @code{False}. See G.2.4(4)."
17520 @end itemize
17521
17522 IEEE infinite and Nan values are produced as appropriate.
17523
17524
17525 @itemize *
17526
17527 @item
17528 "The value of the angle threshold, within which certain
17529 elementary functions, complex arithmetic operations, and complex
17530 elementary functions yield results conforming to a maximum relative
17531 error bound. See G.2.4(10)."
17532 @end itemize
17533
17534 Information on this subject is not yet available.
17535
17536
17537 @itemize *
17538
17539 @item
17540 "The accuracy of certain elementary functions for
17541 parameters beyond the angle threshold. See G.2.4(10)."
17542 @end itemize
17543
17544 Information on this subject is not yet available.
17545
17546
17547 @itemize *
17548
17549 @item
17550 "The result of a complex arithmetic operation or complex
17551 elementary function reference in overflow situations, when the
17552 @code{Machine_Overflows} attribute of the corresponding real type is
17553 @code{False}. See G.2.6(5)."
17554 @end itemize
17555
17556 IEEE infinite and Nan values are produced as appropriate.
17557
17558
17559 @itemize *
17560
17561 @item
17562 "The accuracy of certain complex arithmetic operations and
17563 certain complex elementary functions for parameters (or components
17564 thereof) beyond the angle threshold. See G.2.6(8)."
17565 @end itemize
17566
17567 Information on those subjects is not yet available.
17568
17569
17570 @itemize *
17571
17572 @item
17573 "Information regarding bounded errors and erroneous
17574 execution. See H.2(1)."
17575 @end itemize
17576
17577 Information on this subject is not yet available.
17578
17579
17580 @itemize *
17581
17582 @item
17583 "Implementation-defined aspects of pragma
17584 @code{Inspection_Point}. See H.3.2(8)."
17585 @end itemize
17586
17587 Pragma @code{Inspection_Point} ensures that the variable is live and can
17588 be examined by the debugger at the inspection point.
17589
17590
17591 @itemize *
17592
17593 @item
17594 "Implementation-defined aspects of pragma
17595 @code{Restrictions}. See H.4(25)."
17596 @end itemize
17597
17598 There are no implementation-defined aspects of pragma @code{Restrictions}. The
17599 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
17600 generated code. Checks must suppressed by use of pragma @code{Suppress}.
17601
17602
17603 @itemize *
17604
17605 @item
17606 "Any restrictions on pragma @code{Restrictions}. See
17607 H.4(27)."
17608 @end itemize
17609
17610 There are no restrictions on pragma @code{Restrictions}.
17611
17612 @node Intrinsic Subprograms,Representation Clauses and Pragmas,Implementation Defined Characteristics,Top
17613 @anchor{gnat_rm/intrinsic_subprograms doc}@anchor{259}@anchor{gnat_rm/intrinsic_subprograms intrinsic-subprograms}@anchor{c}@anchor{gnat_rm/intrinsic_subprograms id1}@anchor{25a}
17614 @chapter Intrinsic Subprograms
17615
17616
17617 @geindex Intrinsic Subprograms
17618
17619 GNAT allows a user application program to write the declaration:
17620
17621 @example
17622 pragma Import (Intrinsic, name);
17623 @end example
17624
17625 providing that the name corresponds to one of the implemented intrinsic
17626 subprograms in GNAT, and that the parameter profile of the referenced
17627 subprogram meets the requirements. This chapter describes the set of
17628 implemented intrinsic subprograms, and the requirements on parameter profiles.
17629 Note that no body is supplied; as with other uses of pragma Import, the
17630 body is supplied elsewhere (in this case by the compiler itself). Note
17631 that any use of this feature is potentially non-portable, since the
17632 Ada standard does not require Ada compilers to implement this feature.
17633
17634 @menu
17635 * Intrinsic Operators::
17636 * Compilation_ISO_Date::
17637 * Compilation_Date::
17638 * Compilation_Time::
17639 * Enclosing_Entity::
17640 * Exception_Information::
17641 * Exception_Message::
17642 * Exception_Name::
17643 * File::
17644 * Line::
17645 * Shifts and Rotates::
17646 * Source_Location::
17647
17648 @end menu
17649
17650 @node Intrinsic Operators,Compilation_ISO_Date,,Intrinsic Subprograms
17651 @anchor{gnat_rm/intrinsic_subprograms id2}@anchor{25b}@anchor{gnat_rm/intrinsic_subprograms intrinsic-operators}@anchor{25c}
17652 @section Intrinsic Operators
17653
17654
17655 @geindex Intrinsic operator
17656
17657 All the predefined numeric operators in package Standard
17658 in @code{pragma Import (Intrinsic,..)}
17659 declarations. In the binary operator case, the operands must have the same
17660 size. The operand or operands must also be appropriate for
17661 the operator. For example, for addition, the operands must
17662 both be floating-point or both be fixed-point, and the
17663 right operand for @code{"**"} must have a root type of
17664 @code{Standard.Integer'Base}.
17665 You can use an intrinsic operator declaration as in the following example:
17666
17667 @example
17668 type Int1 is new Integer;
17669 type Int2 is new Integer;
17670
17671 function "+" (X1 : Int1; X2 : Int2) return Int1;
17672 function "+" (X1 : Int1; X2 : Int2) return Int2;
17673 pragma Import (Intrinsic, "+");
17674 @end example
17675
17676 This declaration would permit 'mixed mode' arithmetic on items
17677 of the differing types @code{Int1} and @code{Int2}.
17678 It is also possible to specify such operators for private types, if the
17679 full views are appropriate arithmetic types.
17680
17681 @node Compilation_ISO_Date,Compilation_Date,Intrinsic Operators,Intrinsic Subprograms
17682 @anchor{gnat_rm/intrinsic_subprograms id3}@anchor{25d}@anchor{gnat_rm/intrinsic_subprograms compilation-iso-date}@anchor{25e}
17683 @section Compilation_ISO_Date
17684
17685
17686 @geindex Compilation_ISO_Date
17687
17688 This intrinsic subprogram is used in the implementation of the
17689 library package @code{GNAT.Source_Info}. The only useful use of the
17690 intrinsic import in this case is the one in this unit, so an
17691 application program should simply call the function
17692 @code{GNAT.Source_Info.Compilation_ISO_Date} to obtain the date of
17693 the current compilation (in local time format YYYY-MM-DD).
17694
17695 @node Compilation_Date,Compilation_Time,Compilation_ISO_Date,Intrinsic Subprograms
17696 @anchor{gnat_rm/intrinsic_subprograms compilation-date}@anchor{25f}@anchor{gnat_rm/intrinsic_subprograms id4}@anchor{260}
17697 @section Compilation_Date
17698
17699
17700 @geindex Compilation_Date
17701
17702 Same as Compilation_ISO_Date, except the string is in the form
17703 MMM DD YYYY.
17704
17705 @node Compilation_Time,Enclosing_Entity,Compilation_Date,Intrinsic Subprograms
17706 @anchor{gnat_rm/intrinsic_subprograms compilation-time}@anchor{261}@anchor{gnat_rm/intrinsic_subprograms id5}@anchor{262}
17707 @section Compilation_Time
17708
17709
17710 @geindex Compilation_Time
17711
17712 This intrinsic subprogram is used in the implementation of the
17713 library package @code{GNAT.Source_Info}. The only useful use of the
17714 intrinsic import in this case is the one in this unit, so an
17715 application program should simply call the function
17716 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
17717 the current compilation (in local time format HH:MM:SS).
17718
17719 @node Enclosing_Entity,Exception_Information,Compilation_Time,Intrinsic Subprograms
17720 @anchor{gnat_rm/intrinsic_subprograms id6}@anchor{263}@anchor{gnat_rm/intrinsic_subprograms enclosing-entity}@anchor{264}
17721 @section Enclosing_Entity
17722
17723
17724 @geindex Enclosing_Entity
17725
17726 This intrinsic subprogram is used in the implementation of the
17727 library package @code{GNAT.Source_Info}. The only useful use of the
17728 intrinsic import in this case is the one in this unit, so an
17729 application program should simply call the function
17730 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
17731 the current subprogram, package, task, entry, or protected subprogram.
17732
17733 @node Exception_Information,Exception_Message,Enclosing_Entity,Intrinsic Subprograms
17734 @anchor{gnat_rm/intrinsic_subprograms id7}@anchor{265}@anchor{gnat_rm/intrinsic_subprograms exception-information}@anchor{266}
17735 @section Exception_Information
17736
17737
17738 @geindex Exception_Information'
17739
17740 This intrinsic subprogram is used in the implementation of the
17741 library package @code{GNAT.Current_Exception}. The only useful
17742 use of the intrinsic import in this case is the one in this unit,
17743 so an application program should simply call the function
17744 @code{GNAT.Current_Exception.Exception_Information} to obtain
17745 the exception information associated with the current exception.
17746
17747 @node Exception_Message,Exception_Name,Exception_Information,Intrinsic Subprograms
17748 @anchor{gnat_rm/intrinsic_subprograms exception-message}@anchor{267}@anchor{gnat_rm/intrinsic_subprograms id8}@anchor{268}
17749 @section Exception_Message
17750
17751
17752 @geindex Exception_Message
17753
17754 This intrinsic subprogram is used in the implementation of the
17755 library package @code{GNAT.Current_Exception}. The only useful
17756 use of the intrinsic import in this case is the one in this unit,
17757 so an application program should simply call the function
17758 @code{GNAT.Current_Exception.Exception_Message} to obtain
17759 the message associated with the current exception.
17760
17761 @node Exception_Name,File,Exception_Message,Intrinsic Subprograms
17762 @anchor{gnat_rm/intrinsic_subprograms exception-name}@anchor{269}@anchor{gnat_rm/intrinsic_subprograms id9}@anchor{26a}
17763 @section Exception_Name
17764
17765
17766 @geindex Exception_Name
17767
17768 This intrinsic subprogram is used in the implementation of the
17769 library package @code{GNAT.Current_Exception}. The only useful
17770 use of the intrinsic import in this case is the one in this unit,
17771 so an application program should simply call the function
17772 @code{GNAT.Current_Exception.Exception_Name} to obtain
17773 the name of the current exception.
17774
17775 @node File,Line,Exception_Name,Intrinsic Subprograms
17776 @anchor{gnat_rm/intrinsic_subprograms id10}@anchor{26b}@anchor{gnat_rm/intrinsic_subprograms file}@anchor{26c}
17777 @section File
17778
17779
17780 @geindex File
17781
17782 This intrinsic subprogram is used in the implementation of the
17783 library package @code{GNAT.Source_Info}. The only useful use of the
17784 intrinsic import in this case is the one in this unit, so an
17785 application program should simply call the function
17786 @code{GNAT.Source_Info.File} to obtain the name of the current
17787 file.
17788
17789 @node Line,Shifts and Rotates,File,Intrinsic Subprograms
17790 @anchor{gnat_rm/intrinsic_subprograms id11}@anchor{26d}@anchor{gnat_rm/intrinsic_subprograms line}@anchor{26e}
17791 @section Line
17792
17793
17794 @geindex Line
17795
17796 This intrinsic subprogram is used in the implementation of the
17797 library package @code{GNAT.Source_Info}. The only useful use of the
17798 intrinsic import in this case is the one in this unit, so an
17799 application program should simply call the function
17800 @code{GNAT.Source_Info.Line} to obtain the number of the current
17801 source line.
17802
17803 @node Shifts and Rotates,Source_Location,Line,Intrinsic Subprograms
17804 @anchor{gnat_rm/intrinsic_subprograms shifts-and-rotates}@anchor{26f}@anchor{gnat_rm/intrinsic_subprograms id12}@anchor{270}
17805 @section Shifts and Rotates
17806
17807
17808 @geindex Shift_Left
17809
17810 @geindex Shift_Right
17811
17812 @geindex Shift_Right_Arithmetic
17813
17814 @geindex Rotate_Left
17815
17816 @geindex Rotate_Right
17817
17818 In standard Ada, the shift and rotate functions are available only
17819 for the predefined modular types in package @code{Interfaces}. However, in
17820 GNAT it is possible to define these functions for any integer
17821 type (signed or modular), as in this example:
17822
17823 @example
17824 function Shift_Left
17825 (Value : T;
17826 Amount : Natural) return T;
17827 @end example
17828
17829 The function name must be one of
17830 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
17831 Rotate_Right. T must be an integer type. T'Size must be
17832 8, 16, 32 or 64 bits; if T is modular, the modulus
17833 must be 2**8, 2**16, 2**32 or 2**64.
17834 The result type must be the same as the type of @code{Value}.
17835 The shift amount must be Natural.
17836 The formal parameter names can be anything.
17837
17838 A more convenient way of providing these shift operators is to use
17839 the Provide_Shift_Operators pragma, which provides the function declarations
17840 and corresponding pragma Import's for all five shift functions.
17841
17842 @node Source_Location,,Shifts and Rotates,Intrinsic Subprograms
17843 @anchor{gnat_rm/intrinsic_subprograms source-location}@anchor{271}@anchor{gnat_rm/intrinsic_subprograms id13}@anchor{272}
17844 @section Source_Location
17845
17846
17847 @geindex Source_Location
17848
17849 This intrinsic subprogram is used in the implementation of the
17850 library routine @code{GNAT.Source_Info}. The only useful use of the
17851 intrinsic import in this case is the one in this unit, so an
17852 application program should simply call the function
17853 @code{GNAT.Source_Info.Source_Location} to obtain the current
17854 source file location.
17855
17856 @node Representation Clauses and Pragmas,Standard Library Routines,Intrinsic Subprograms,Top
17857 @anchor{gnat_rm/representation_clauses_and_pragmas representation-clauses-and-pragmas}@anchor{d}@anchor{gnat_rm/representation_clauses_and_pragmas doc}@anchor{273}@anchor{gnat_rm/representation_clauses_and_pragmas id1}@anchor{274}
17858 @chapter Representation Clauses and Pragmas
17859
17860
17861 @geindex Representation Clauses
17862
17863 @geindex Representation Clause
17864
17865 @geindex Representation Pragma
17866
17867 @geindex Pragma
17868 @geindex representation
17869
17870 This section describes the representation clauses accepted by GNAT, and
17871 their effect on the representation of corresponding data objects.
17872
17873 GNAT fully implements Annex C (Systems Programming). This means that all
17874 the implementation advice sections in chapter 13 are fully implemented.
17875 However, these sections only require a minimal level of support for
17876 representation clauses. GNAT provides much more extensive capabilities,
17877 and this section describes the additional capabilities provided.
17878
17879 @menu
17880 * Alignment Clauses::
17881 * Size Clauses::
17882 * Storage_Size Clauses::
17883 * Size of Variant Record Objects::
17884 * Biased Representation::
17885 * Value_Size and Object_Size Clauses::
17886 * Component_Size Clauses::
17887 * Bit_Order Clauses::
17888 * Effect of Bit_Order on Byte Ordering::
17889 * Pragma Pack for Arrays::
17890 * Pragma Pack for Records::
17891 * Record Representation Clauses::
17892 * Handling of Records with Holes::
17893 * Enumeration Clauses::
17894 * Address Clauses::
17895 * Use of Address Clauses for Memory-Mapped I/O::
17896 * Effect of Convention on Representation::
17897 * Conventions and Anonymous Access Types::
17898 * Determining the Representations chosen by GNAT::
17899
17900 @end menu
17901
17902 @node Alignment Clauses,Size Clauses,,Representation Clauses and Pragmas
17903 @anchor{gnat_rm/representation_clauses_and_pragmas id2}@anchor{275}@anchor{gnat_rm/representation_clauses_and_pragmas alignment-clauses}@anchor{276}
17904 @section Alignment Clauses
17905
17906
17907 @geindex Alignment Clause
17908
17909 GNAT requires that all alignment clauses specify 0 or a power of 2, and
17910 all default alignments are always a power of 2. Specifying 0 is the
17911 same as specifying 1.
17912
17913 The default alignment values are as follows:
17914
17915
17916 @itemize *
17917
17918 @item
17919 @emph{Elementary Types}.
17920
17921 For elementary types, the alignment is the minimum of the actual size of
17922 objects of the type divided by @code{Storage_Unit},
17923 and the maximum alignment supported by the target.
17924 (This maximum alignment is given by the GNAT-specific attribute
17925 @code{Standard'Maximum_Alignment}; see @ref{18f,,Attribute Maximum_Alignment}.)
17926
17927 @geindex Maximum_Alignment attribute
17928
17929 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
17930 default alignment will be 8 on any target that supports alignments
17931 this large, but on some targets, the maximum alignment may be smaller
17932 than 8, in which case objects of type @code{Long_Float} will be maximally
17933 aligned.
17934
17935 @item
17936 @emph{Arrays}.
17937
17938 For arrays, the alignment is equal to the alignment of the component type
17939 for the normal case where no packing or component size is given. If the
17940 array is packed, and the packing is effective (see separate section on
17941 packed arrays), then the alignment will be either 4, 2, or 1 for long packed
17942 arrays or arrays whose length is not known at compile time, depending on
17943 whether the component size is divisible by 4, 2, or is odd. For short packed
17944 arrays, which are handled internally as modular types, the alignment
17945 will be as described for elementary types, e.g. a packed array of length
17946 31 bits will have an object size of four bytes, and an alignment of 4.
17947
17948 @item
17949 @emph{Records}.
17950
17951 For the normal unpacked case, the alignment of a record is equal to
17952 the maximum alignment of any of its components. For tagged records, this
17953 includes the implicit access type used for the tag. If a pragma @code{Pack}
17954 is used and all components are packable (see separate section on pragma
17955 @code{Pack}), then the resulting alignment is 1, unless the layout of the
17956 record makes it profitable to increase it.
17957
17958 A special case is when:
17959
17960
17961 @itemize *
17962
17963 @item
17964 the size of the record is given explicitly, or a
17965 full record representation clause is given, and
17966
17967 @item
17968 the size of the record is 2, 4, or 8 bytes.
17969 @end itemize
17970
17971 In this case, an alignment is chosen to match the
17972 size of the record. For example, if we have:
17973
17974 @example
17975 type Small is record
17976 A, B : Character;
17977 end record;
17978 for Small'Size use 16;
17979 @end example
17980
17981 then the default alignment of the record type @code{Small} is 2, not 1. This
17982 leads to more efficient code when the record is treated as a unit, and also
17983 allows the type to specified as @code{Atomic} on architectures requiring
17984 strict alignment.
17985 @end itemize
17986
17987 An alignment clause may specify a larger alignment than the default value
17988 up to some maximum value dependent on the target (obtainable by using the
17989 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
17990 a smaller alignment than the default value for enumeration, integer and
17991 fixed point types, as well as for record types, for example
17992
17993 @example
17994 type V is record
17995 A : Integer;
17996 end record;
17997
17998 for V'alignment use 1;
17999 @end example
18000
18001 @geindex Alignment
18002 @geindex default
18003
18004 The default alignment for the type @code{V} is 4, as a result of the
18005 Integer field in the record, but it is permissible, as shown, to
18006 override the default alignment of the record with a smaller value.
18007
18008 @geindex Alignment
18009 @geindex subtypes
18010
18011 Note that according to the Ada standard, an alignment clause applies only
18012 to the first named subtype. If additional subtypes are declared, then the
18013 compiler is allowed to choose any alignment it likes, and there is no way
18014 to control this choice. Consider:
18015
18016 @example
18017 type R is range 1 .. 10_000;
18018 for R'Alignment use 1;
18019 subtype RS is R range 1 .. 1000;
18020 @end example
18021
18022 The alignment clause specifies an alignment of 1 for the first named subtype
18023 @code{R} but this does not necessarily apply to @code{RS}. When writing
18024 portable Ada code, you should avoid writing code that explicitly or
18025 implicitly relies on the alignment of such subtypes.
18026
18027 For the GNAT compiler, if an explicit alignment clause is given, this
18028 value is also used for any subsequent subtypes. So for GNAT, in the
18029 above example, you can count on the alignment of @code{RS} being 1. But this
18030 assumption is non-portable, and other compilers may choose different
18031 alignments for the subtype @code{RS}.
18032
18033 @node Size Clauses,Storage_Size Clauses,Alignment Clauses,Representation Clauses and Pragmas
18034 @anchor{gnat_rm/representation_clauses_and_pragmas id3}@anchor{277}@anchor{gnat_rm/representation_clauses_and_pragmas size-clauses}@anchor{278}
18035 @section Size Clauses
18036
18037
18038 @geindex Size Clause
18039
18040 The default size for a type @code{T} is obtainable through the
18041 language-defined attribute @code{T'Size} and also through the
18042 equivalent GNAT-defined attribute @code{T'Value_Size}.
18043 For objects of type @code{T}, GNAT will generally increase the type size
18044 so that the object size (obtainable through the GNAT-defined attribute
18045 @code{T'Object_Size})
18046 is a multiple of @code{T'Alignment * Storage_Unit}.
18047
18048 For example:
18049
18050 @example
18051 type Smallint is range 1 .. 6;
18052
18053 type Rec is record
18054 Y1 : integer;
18055 Y2 : boolean;
18056 end record;
18057 @end example
18058
18059 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
18060 as specified by the RM rules,
18061 but objects of this type will have a size of 8
18062 (@code{Smallint'Object_Size} = 8),
18063 since objects by default occupy an integral number
18064 of storage units. On some targets, notably older
18065 versions of the Digital Alpha, the size of stand
18066 alone objects of this type may be 32, reflecting
18067 the inability of the hardware to do byte load/stores.
18068
18069 Similarly, the size of type @code{Rec} is 40 bits
18070 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
18071 the alignment is 4, so objects of this type will have
18072 their size increased to 64 bits so that it is a multiple
18073 of the alignment (in bits). This decision is
18074 in accordance with the specific Implementation Advice in RM 13.3(43):
18075
18076 @quotation
18077
18078 "A @code{Size} clause should be supported for an object if the specified
18079 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
18080 to a size in storage elements that is a multiple of the object's
18081 @code{Alignment} (if the @code{Alignment} is nonzero)."
18082 @end quotation
18083
18084 An explicit size clause may be used to override the default size by
18085 increasing it. For example, if we have:
18086
18087 @example
18088 type My_Boolean is new Boolean;
18089 for My_Boolean'Size use 32;
18090 @end example
18091
18092 then values of this type will always be 32 bits long. In the case of
18093 discrete types, the size can be increased up to 64 bits, with the effect
18094 that the entire specified field is used to hold the value, sign- or
18095 zero-extended as appropriate. If more than 64 bits is specified, then
18096 padding space is allocated after the value, and a warning is issued that
18097 there are unused bits.
18098
18099 Similarly the size of records and arrays may be increased, and the effect
18100 is to add padding bits after the value. This also causes a warning message
18101 to be generated.
18102
18103 The largest Size value permitted in GNAT is 2**31-1. Since this is a
18104 Size in bits, this corresponds to an object of size 256 megabytes (minus
18105 one). This limitation is true on all targets. The reason for this
18106 limitation is that it improves the quality of the code in many cases
18107 if it is known that a Size value can be accommodated in an object of
18108 type Integer.
18109
18110 @node Storage_Size Clauses,Size of Variant Record Objects,Size Clauses,Representation Clauses and Pragmas
18111 @anchor{gnat_rm/representation_clauses_and_pragmas storage-size-clauses}@anchor{279}@anchor{gnat_rm/representation_clauses_and_pragmas id4}@anchor{27a}
18112 @section Storage_Size Clauses
18113
18114
18115 @geindex Storage_Size Clause
18116
18117 For tasks, the @code{Storage_Size} clause specifies the amount of space
18118 to be allocated for the task stack. This cannot be extended, and if the
18119 stack is exhausted, then @code{Storage_Error} will be raised (if stack
18120 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
18121 or a @code{Storage_Size} pragma in the task definition to set the
18122 appropriate required size. A useful technique is to include in every
18123 task definition a pragma of the form:
18124
18125 @example
18126 pragma Storage_Size (Default_Stack_Size);
18127 @end example
18128
18129 Then @code{Default_Stack_Size} can be defined in a global package, and
18130 modified as required. Any tasks requiring stack sizes different from the
18131 default can have an appropriate alternative reference in the pragma.
18132
18133 You can also use the @emph{-d} binder switch to modify the default stack
18134 size.
18135
18136 For access types, the @code{Storage_Size} clause specifies the maximum
18137 space available for allocation of objects of the type. If this space is
18138 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
18139 In the case where the access type is declared local to a subprogram, the
18140 use of a @code{Storage_Size} clause triggers automatic use of a special
18141 predefined storage pool (@code{System.Pool_Size}) that ensures that all
18142 space for the pool is automatically reclaimed on exit from the scope in
18143 which the type is declared.
18144
18145 A special case recognized by the compiler is the specification of a
18146 @code{Storage_Size} of zero for an access type. This means that no
18147 items can be allocated from the pool, and this is recognized at compile
18148 time, and all the overhead normally associated with maintaining a fixed
18149 size storage pool is eliminated. Consider the following example:
18150
18151 @example
18152 procedure p is
18153 type R is array (Natural) of Character;
18154 type P is access all R;
18155 for P'Storage_Size use 0;
18156 -- Above access type intended only for interfacing purposes
18157
18158 y : P;
18159
18160 procedure g (m : P);
18161 pragma Import (C, g);
18162
18163 -- ...
18164
18165 begin
18166 -- ...
18167 y := new R;
18168 end;
18169 @end example
18170
18171 As indicated in this example, these dummy storage pools are often useful in
18172 connection with interfacing where no object will ever be allocated. If you
18173 compile the above example, you get the warning:
18174
18175 @example
18176 p.adb:16:09: warning: allocation from empty storage pool
18177 p.adb:16:09: warning: Storage_Error will be raised at run time
18178 @end example
18179
18180 Of course in practice, there will not be any explicit allocators in the
18181 case of such an access declaration.
18182
18183 @node Size of Variant Record Objects,Biased Representation,Storage_Size Clauses,Representation Clauses and Pragmas
18184 @anchor{gnat_rm/representation_clauses_and_pragmas id5}@anchor{27b}@anchor{gnat_rm/representation_clauses_and_pragmas size-of-variant-record-objects}@anchor{27c}
18185 @section Size of Variant Record Objects
18186
18187
18188 @geindex Size
18189 @geindex variant record objects
18190
18191 @geindex Variant record objects
18192 @geindex size
18193
18194 In the case of variant record objects, there is a question whether Size gives
18195 information about a particular variant, or the maximum size required
18196 for any variant. Consider the following program
18197
18198 @example
18199 with Text_IO; use Text_IO;
18200 procedure q is
18201 type R1 (A : Boolean := False) is record
18202 case A is
18203 when True => X : Character;
18204 when False => null;
18205 end case;
18206 end record;
18207
18208 V1 : R1 (False);
18209 V2 : R1;
18210
18211 begin
18212 Put_Line (Integer'Image (V1'Size));
18213 Put_Line (Integer'Image (V2'Size));
18214 end q;
18215 @end example
18216
18217 Here we are dealing with a variant record, where the True variant
18218 requires 16 bits, and the False variant requires 8 bits.
18219 In the above example, both V1 and V2 contain the False variant,
18220 which is only 8 bits long. However, the result of running the
18221 program is:
18222
18223 @example
18224 8
18225 16
18226 @end example
18227
18228 The reason for the difference here is that the discriminant value of
18229 V1 is fixed, and will always be False. It is not possible to assign
18230 a True variant value to V1, therefore 8 bits is sufficient. On the
18231 other hand, in the case of V2, the initial discriminant value is
18232 False (from the default), but it is possible to assign a True
18233 variant value to V2, therefore 16 bits must be allocated for V2
18234 in the general case, even fewer bits may be needed at any particular
18235 point during the program execution.
18236
18237 As can be seen from the output of this program, the @code{'Size}
18238 attribute applied to such an object in GNAT gives the actual allocated
18239 size of the variable, which is the largest size of any of the variants.
18240 The Ada Reference Manual is not completely clear on what choice should
18241 be made here, but the GNAT behavior seems most consistent with the
18242 language in the RM.
18243
18244 In some cases, it may be desirable to obtain the size of the current
18245 variant, rather than the size of the largest variant. This can be
18246 achieved in GNAT by making use of the fact that in the case of a
18247 subprogram parameter, GNAT does indeed return the size of the current
18248 variant (because a subprogram has no way of knowing how much space
18249 is actually allocated for the actual).
18250
18251 Consider the following modified version of the above program:
18252
18253 @example
18254 with Text_IO; use Text_IO;
18255 procedure q is
18256 type R1 (A : Boolean := False) is record
18257 case A is
18258 when True => X : Character;
18259 when False => null;
18260 end case;
18261 end record;
18262
18263 V2 : R1;
18264
18265 function Size (V : R1) return Integer is
18266 begin
18267 return V'Size;
18268 end Size;
18269
18270 begin
18271 Put_Line (Integer'Image (V2'Size));
18272 Put_Line (Integer'Image (Size (V2)));
18273 V2 := (True, 'x');
18274 Put_Line (Integer'Image (V2'Size));
18275 Put_Line (Integer'Image (Size (V2)));
18276 end q;
18277 @end example
18278
18279 The output from this program is
18280
18281 @example
18282 16
18283 8
18284 16
18285 16
18286 @end example
18287
18288 Here we see that while the @code{'Size} attribute always returns
18289 the maximum size, regardless of the current variant value, the
18290 @code{Size} function does indeed return the size of the current
18291 variant value.
18292
18293 @node Biased Representation,Value_Size and Object_Size Clauses,Size of Variant Record Objects,Representation Clauses and Pragmas
18294 @anchor{gnat_rm/representation_clauses_and_pragmas id6}@anchor{27d}@anchor{gnat_rm/representation_clauses_and_pragmas biased-representation}@anchor{27e}
18295 @section Biased Representation
18296
18297
18298 @geindex Size for biased representation
18299
18300 @geindex Biased representation
18301
18302 In the case of scalars with a range starting at other than zero, it is
18303 possible in some cases to specify a size smaller than the default minimum
18304 value, and in such cases, GNAT uses an unsigned biased representation,
18305 in which zero is used to represent the lower bound, and successive values
18306 represent successive values of the type.
18307
18308 For example, suppose we have the declaration:
18309
18310 @example
18311 type Small is range -7 .. -4;
18312 for Small'Size use 2;
18313 @end example
18314
18315 Although the default size of type @code{Small} is 4, the @code{Size}
18316 clause is accepted by GNAT and results in the following representation
18317 scheme:
18318
18319 @example
18320 -7 is represented as 2#00#
18321 -6 is represented as 2#01#
18322 -5 is represented as 2#10#
18323 -4 is represented as 2#11#
18324 @end example
18325
18326 Biased representation is only used if the specified @code{Size} clause
18327 cannot be accepted in any other manner. These reduced sizes that force
18328 biased representation can be used for all discrete types except for
18329 enumeration types for which a representation clause is given.
18330
18331 @node Value_Size and Object_Size Clauses,Component_Size Clauses,Biased Representation,Representation Clauses and Pragmas
18332 @anchor{gnat_rm/representation_clauses_and_pragmas id7}@anchor{27f}@anchor{gnat_rm/representation_clauses_and_pragmas value-size-and-object-size-clauses}@anchor{280}
18333 @section Value_Size and Object_Size Clauses
18334
18335
18336 @geindex Value_Size
18337
18338 @geindex Object_Size
18339
18340 @geindex Size
18341 @geindex of objects
18342
18343 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
18344 number of bits required to hold values of type @code{T}.
18345 Although this interpretation was allowed in Ada 83, it was not required,
18346 and this requirement in practice can cause some significant difficulties.
18347 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
18348 However, in Ada 95 and Ada 2005,
18349 @code{Natural'Size} is
18350 typically 31. This means that code may change in behavior when moving
18351 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
18352
18353 @example
18354 type Rec is record;
18355 A : Natural;
18356 B : Natural;
18357 end record;
18358
18359 for Rec use record
18360 at 0 range 0 .. Natural'Size - 1;
18361 at 0 range Natural'Size .. 2 * Natural'Size - 1;
18362 end record;
18363 @end example
18364
18365 In the above code, since the typical size of @code{Natural} objects
18366 is 32 bits and @code{Natural'Size} is 31, the above code can cause
18367 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
18368 there are cases where the fact that the object size can exceed the
18369 size of the type causes surprises.
18370
18371 To help get around this problem GNAT provides two implementation
18372 defined attributes, @code{Value_Size} and @code{Object_Size}. When
18373 applied to a type, these attributes yield the size of the type
18374 (corresponding to the RM defined size attribute), and the size of
18375 objects of the type respectively.
18376
18377 The @code{Object_Size} is used for determining the default size of
18378 objects and components. This size value can be referred to using the
18379 @code{Object_Size} attribute. The phrase 'is used' here means that it is
18380 the basis of the determination of the size. The backend is free to
18381 pad this up if necessary for efficiency, e.g., an 8-bit stand-alone
18382 character might be stored in 32 bits on a machine with no efficient
18383 byte access instructions such as the Alpha.
18384
18385 The default rules for the value of @code{Object_Size} for
18386 discrete types are as follows:
18387
18388
18389 @itemize *
18390
18391 @item
18392 The @code{Object_Size} for base subtypes reflect the natural hardware
18393 size in bits (run the compiler with @emph{-gnatS} to find those values
18394 for numeric types). Enumeration types and fixed-point base subtypes have
18395 8, 16, 32, or 64 bits for this size, depending on the range of values
18396 to be stored.
18397
18398 @item
18399 The @code{Object_Size} of a subtype is the same as the
18400 @code{Object_Size} of
18401 the type from which it is obtained.
18402
18403 @item
18404 The @code{Object_Size} of a derived base type is copied from the parent
18405 base type, and the @code{Object_Size} of a derived first subtype is copied
18406 from the parent first subtype.
18407 @end itemize
18408
18409 The @code{Value_Size} attribute
18410 is the (minimum) number of bits required to store a value
18411 of the type.
18412 This value is used to determine how tightly to pack
18413 records or arrays with components of this type, and also affects
18414 the semantics of unchecked conversion (unchecked conversions where
18415 the @code{Value_Size} values differ generate a warning, and are potentially
18416 target dependent).
18417
18418 The default rules for the value of @code{Value_Size} are as follows:
18419
18420
18421 @itemize *
18422
18423 @item
18424 The @code{Value_Size} for a base subtype is the minimum number of bits
18425 required to store all values of the type (including the sign bit
18426 only if negative values are possible).
18427
18428 @item
18429 If a subtype statically matches the first subtype of a given type, then it has
18430 by default the same @code{Value_Size} as the first subtype. This is a
18431 consequence of RM 13.1(14): "if two subtypes statically match,
18432 then their subtype-specific aspects are the same".)
18433
18434 @item
18435 All other subtypes have a @code{Value_Size} corresponding to the minimum
18436 number of bits required to store all values of the subtype. For
18437 dynamic bounds, it is assumed that the value can range down or up
18438 to the corresponding bound of the ancestor
18439 @end itemize
18440
18441 The RM defined attribute @code{Size} corresponds to the
18442 @code{Value_Size} attribute.
18443
18444 The @code{Size} attribute may be defined for a first-named subtype. This sets
18445 the @code{Value_Size} of
18446 the first-named subtype to the given value, and the
18447 @code{Object_Size} of this first-named subtype to the given value padded up
18448 to an appropriate boundary. It is a consequence of the default rules
18449 above that this @code{Object_Size} will apply to all further subtypes. On the
18450 other hand, @code{Value_Size} is affected only for the first subtype, any
18451 dynamic subtypes obtained from it directly, and any statically matching
18452 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
18453
18454 @code{Value_Size} and
18455 @code{Object_Size} may be explicitly set for any subtype using
18456 an attribute definition clause. Note that the use of these attributes
18457 can cause the RM 13.1(14) rule to be violated. If two access types
18458 reference aliased objects whose subtypes have differing @code{Object_Size}
18459 values as a result of explicit attribute definition clauses, then it
18460 is illegal to convert from one access subtype to the other. For a more
18461 complete description of this additional legality rule, see the
18462 description of the @code{Object_Size} attribute.
18463
18464 To get a feel for the difference, consider the following examples (note
18465 that in each case the base is @code{Short_Short_Integer} with a size of 8):
18466
18467
18468 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx}
18469 @headitem
18470
18471 Type or subtype declaration
18472
18473 @tab
18474
18475 Object_Size
18476
18477 @tab
18478
18479 Value_Size
18480
18481 @item
18482
18483 @code{type x1 is range 0 .. 5;}
18484
18485 @tab
18486
18487 8
18488
18489 @tab
18490
18491 3
18492
18493 @item
18494
18495 @code{type x2 is range 0 .. 5;}
18496 @code{for x2'size use 12;}
18497
18498 @tab
18499
18500 16
18501
18502 @tab
18503
18504 12
18505
18506 @item
18507
18508 @code{subtype x3 is x2 range 0 .. 3;}
18509
18510 @tab
18511
18512 16
18513
18514 @tab
18515
18516 2
18517
18518 @item
18519
18520 @code{subtype x4 is x2'base range 0 .. 10;}
18521
18522 @tab
18523
18524 8
18525
18526 @tab
18527
18528 4
18529
18530 @item
18531
18532 @code{dynamic : x2'Base range -64 .. +63;}
18533
18534 @tab
18535
18536 @tab
18537
18538 @item
18539
18540 @code{subtype x5 is x2 range 0 .. dynamic;}
18541
18542 @tab
18543
18544 16
18545
18546 @tab
18547
18548 3*
18549
18550 @item
18551
18552 @code{subtype x6 is x2'base range 0 .. dynamic;}
18553
18554 @tab
18555
18556 8
18557
18558 @tab
18559
18560 7*
18561
18562 @end multitable
18563
18564
18565 Note: the entries marked '*' are not actually specified by the Ada
18566 Reference Manual, which has nothing to say about size in the dynamic
18567 case. What GNAT does is to allocate sufficient bits to accommodate any
18568 possible dynamic values for the bounds at run-time.
18569
18570 So far, so good, but GNAT has to obey the RM rules, so the question is
18571 under what conditions must the RM @code{Size} be used.
18572 The following is a list
18573 of the occasions on which the RM @code{Size} must be used:
18574
18575
18576 @itemize *
18577
18578 @item
18579 Component size for packed arrays or records
18580
18581 @item
18582 Value of the attribute @code{Size} for a type
18583
18584 @item
18585 Warning about sizes not matching for unchecked conversion
18586 @end itemize
18587
18588 For record types, the @code{Object_Size} is always a multiple of the
18589 alignment of the type (this is true for all types). In some cases the
18590 @code{Value_Size} can be smaller. Consider:
18591
18592 @example
18593 type R is record
18594 X : Integer;
18595 Y : Character;
18596 end record;
18597 @end example
18598
18599 On a typical 32-bit architecture, the X component will occupy four bytes
18600 and the Y component will occupy one byte, for a total of 5 bytes. As a
18601 result @code{R'Value_Size} will be 40 (bits) since this is the minimum size
18602 required to store a value of this type. For example, it is permissible
18603 to have a component of type R in an array whose component size is
18604 specified to be 40 bits.
18605
18606 However, @code{R'Object_Size} will be 64 (bits). The difference is due to
18607 the alignment requirement for objects of the record type. The X
18608 component will require four-byte alignment because that is what type
18609 Integer requires, whereas the Y component, a Character, will only
18610 require 1-byte alignment. Since the alignment required for X is the
18611 greatest of all the components' alignments, that is the alignment
18612 required for the enclosing record type, i.e., 4 bytes or 32 bits. As
18613 indicated above, the actual object size must be rounded up so that it is
18614 a multiple of the alignment value. Therefore, 40 bits rounded up to the
18615 next multiple of 32 yields 64 bits.
18616
18617 For all other types, the @code{Object_Size}
18618 and @code{Value_Size} are the same (and equivalent to the RM attribute @code{Size}).
18619 Only @code{Size} may be specified for such types.
18620
18621 Note that @code{Value_Size} can be used to force biased representation
18622 for a particular subtype. Consider this example:
18623
18624 @example
18625 type R is (A, B, C, D, E, F);
18626 subtype RAB is R range A .. B;
18627 subtype REF is R range E .. F;
18628 @end example
18629
18630 By default, @code{RAB}
18631 has a size of 1 (sufficient to accommodate the representation
18632 of @code{A} and @code{B}, 0 and 1), and @code{REF}
18633 has a size of 3 (sufficient to accommodate the representation
18634 of @code{E} and @code{F}, 4 and 5). But if we add the
18635 following @code{Value_Size} attribute definition clause:
18636
18637 @example
18638 for REF'Value_Size use 1;
18639 @end example
18640
18641 then biased representation is forced for @code{REF},
18642 and 0 will represent @code{E} and 1 will represent @code{F}.
18643 A warning is issued when a @code{Value_Size} attribute
18644 definition clause forces biased representation. This
18645 warning can be turned off using @code{-gnatw.B}.
18646
18647 @node Component_Size Clauses,Bit_Order Clauses,Value_Size and Object_Size Clauses,Representation Clauses and Pragmas
18648 @anchor{gnat_rm/representation_clauses_and_pragmas id8}@anchor{281}@anchor{gnat_rm/representation_clauses_and_pragmas component-size-clauses}@anchor{282}
18649 @section Component_Size Clauses
18650
18651
18652 @geindex Component_Size Clause
18653
18654 Normally, the value specified in a component size clause must be consistent
18655 with the subtype of the array component with regard to size and alignment.
18656 In other words, the value specified must be at least equal to the size
18657 of this subtype, and must be a multiple of the alignment value.
18658
18659 In addition, component size clauses are allowed which cause the array
18660 to be packed, by specifying a smaller value. A first case is for
18661 component size values in the range 1 through 63. The value specified
18662 must not be smaller than the Size of the subtype. GNAT will accurately
18663 honor all packing requests in this range. For example, if we have:
18664
18665 @example
18666 type r is array (1 .. 8) of Natural;
18667 for r'Component_Size use 31;
18668 @end example
18669
18670 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
18671 Of course access to the components of such an array is considerably
18672 less efficient than if the natural component size of 32 is used.
18673 A second case is when the subtype of the component is a record type
18674 padded because of its default alignment. For example, if we have:
18675
18676 @example
18677 type r is record
18678 i : Integer;
18679 j : Integer;
18680 b : Boolean;
18681 end record;
18682
18683 type a is array (1 .. 8) of r;
18684 for a'Component_Size use 72;
18685 @end example
18686
18687 then the resulting array has a length of 72 bytes, instead of 96 bytes
18688 if the alignment of the record (4) was obeyed.
18689
18690 Note that there is no point in giving both a component size clause
18691 and a pragma Pack for the same array type. if such duplicate
18692 clauses are given, the pragma Pack will be ignored.
18693
18694 @node Bit_Order Clauses,Effect of Bit_Order on Byte Ordering,Component_Size Clauses,Representation Clauses and Pragmas
18695 @anchor{gnat_rm/representation_clauses_and_pragmas bit-order-clauses}@anchor{283}@anchor{gnat_rm/representation_clauses_and_pragmas id9}@anchor{284}
18696 @section Bit_Order Clauses
18697
18698
18699 @geindex Bit_Order Clause
18700
18701 @geindex bit ordering
18702
18703 @geindex ordering
18704 @geindex of bits
18705
18706 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
18707 attribute. The specification may either correspond to the default bit
18708 order for the target, in which case the specification has no effect and
18709 places no additional restrictions, or it may be for the non-standard
18710 setting (that is the opposite of the default).
18711
18712 In the case where the non-standard value is specified, the effect is
18713 to renumber bits within each byte, but the ordering of bytes is not
18714 affected. There are certain
18715 restrictions placed on component clauses as follows:
18716
18717
18718 @itemize *
18719
18720 @item
18721 Components fitting within a single storage unit.
18722
18723 These are unrestricted, and the effect is merely to renumber bits. For
18724 example if we are on a little-endian machine with @code{Low_Order_First}
18725 being the default, then the following two declarations have exactly
18726 the same effect:
18727
18728 @example
18729 type R1 is record
18730 A : Boolean;
18731 B : Integer range 1 .. 120;
18732 end record;
18733
18734 for R1 use record
18735 A at 0 range 0 .. 0;
18736 B at 0 range 1 .. 7;
18737 end record;
18738
18739 type R2 is record
18740 A : Boolean;
18741 B : Integer range 1 .. 120;
18742 end record;
18743
18744 for R2'Bit_Order use High_Order_First;
18745
18746 for R2 use record
18747 A at 0 range 7 .. 7;
18748 B at 0 range 0 .. 6;
18749 end record;
18750 @end example
18751
18752 The useful application here is to write the second declaration with the
18753 @code{Bit_Order} attribute definition clause, and know that it will be treated
18754 the same, regardless of whether the target is little-endian or big-endian.
18755
18756 @item
18757 Components occupying an integral number of bytes.
18758
18759 These are components that exactly fit in two or more bytes. Such component
18760 declarations are allowed, but have no effect, since it is important to realize
18761 that the @code{Bit_Order} specification does not affect the ordering of bytes.
18762 In particular, the following attempt at getting an endian-independent integer
18763 does not work:
18764
18765 @example
18766 type R2 is record
18767 A : Integer;
18768 end record;
18769
18770 for R2'Bit_Order use High_Order_First;
18771
18772 for R2 use record
18773 A at 0 range 0 .. 31;
18774 end record;
18775 @end example
18776
18777 This declaration will result in a little-endian integer on a
18778 little-endian machine, and a big-endian integer on a big-endian machine.
18779 If byte flipping is required for interoperability between big- and
18780 little-endian machines, this must be explicitly programmed. This capability
18781 is not provided by @code{Bit_Order}.
18782
18783 @item
18784 Components that are positioned across byte boundaries.
18785
18786 but do not occupy an integral number of bytes. Given that bytes are not
18787 reordered, such fields would occupy a non-contiguous sequence of bits
18788 in memory, requiring non-trivial code to reassemble. They are for this
18789 reason not permitted, and any component clause specifying such a layout
18790 will be flagged as illegal by GNAT.
18791 @end itemize
18792
18793 Since the misconception that Bit_Order automatically deals with all
18794 endian-related incompatibilities is a common one, the specification of
18795 a component field that is an integral number of bytes will always
18796 generate a warning. This warning may be suppressed using @code{pragma Warnings (Off)}
18797 if desired. The following section contains additional
18798 details regarding the issue of byte ordering.
18799
18800 @node Effect of Bit_Order on Byte Ordering,Pragma Pack for Arrays,Bit_Order Clauses,Representation Clauses and Pragmas
18801 @anchor{gnat_rm/representation_clauses_and_pragmas id10}@anchor{285}@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-bit-order-on-byte-ordering}@anchor{286}
18802 @section Effect of Bit_Order on Byte Ordering
18803
18804
18805 @geindex byte ordering
18806
18807 @geindex ordering
18808 @geindex of bytes
18809
18810 In this section we will review the effect of the @code{Bit_Order} attribute
18811 definition clause on byte ordering. Briefly, it has no effect at all, but
18812 a detailed example will be helpful. Before giving this
18813 example, let us review the precise
18814 definition of the effect of defining @code{Bit_Order}. The effect of a
18815 non-standard bit order is described in section 13.5.3 of the Ada
18816 Reference Manual:
18817
18818 @quotation
18819
18820 "2 A bit ordering is a method of interpreting the meaning of
18821 the storage place attributes."
18822 @end quotation
18823
18824 To understand the precise definition of storage place attributes in
18825 this context, we visit section 13.5.1 of the manual:
18826
18827 @quotation
18828
18829 "13 A record_representation_clause (without the mod_clause)
18830 specifies the layout. The storage place attributes (see 13.5.2)
18831 are taken from the values of the position, first_bit, and last_bit
18832 expressions after normalizing those values so that first_bit is
18833 less than Storage_Unit."
18834 @end quotation
18835
18836 The critical point here is that storage places are taken from
18837 the values after normalization, not before. So the @code{Bit_Order}
18838 interpretation applies to normalized values. The interpretation
18839 is described in the later part of the 13.5.3 paragraph:
18840
18841 @quotation
18842
18843 "2 A bit ordering is a method of interpreting the meaning of
18844 the storage place attributes. High_Order_First (known in the
18845 vernacular as 'big endian') means that the first bit of a
18846 storage element (bit 0) is the most significant bit (interpreting
18847 the sequence of bits that represent a component as an unsigned
18848 integer value). Low_Order_First (known in the vernacular as
18849 'little endian') means the opposite: the first bit is the
18850 least significant."
18851 @end quotation
18852
18853 Note that the numbering is with respect to the bits of a storage
18854 unit. In other words, the specification affects only the numbering
18855 of bits within a single storage unit.
18856
18857 We can make the effect clearer by giving an example.
18858
18859 Suppose that we have an external device which presents two bytes, the first
18860 byte presented, which is the first (low addressed byte) of the two byte
18861 record is called Master, and the second byte is called Slave.
18862
18863 The left most (most significant bit is called Control for each byte, and
18864 the remaining 7 bits are called V1, V2, ... V7, where V7 is the rightmost
18865 (least significant) bit.
18866
18867 On a big-endian machine, we can write the following representation clause
18868
18869 @example
18870 type Data is record
18871 Master_Control : Bit;
18872 Master_V1 : Bit;
18873 Master_V2 : Bit;
18874 Master_V3 : Bit;
18875 Master_V4 : Bit;
18876 Master_V5 : Bit;
18877 Master_V6 : Bit;
18878 Master_V7 : Bit;
18879 Slave_Control : Bit;
18880 Slave_V1 : Bit;
18881 Slave_V2 : Bit;
18882 Slave_V3 : Bit;
18883 Slave_V4 : Bit;
18884 Slave_V5 : Bit;
18885 Slave_V6 : Bit;
18886 Slave_V7 : Bit;
18887 end record;
18888
18889 for Data use record
18890 Master_Control at 0 range 0 .. 0;
18891 Master_V1 at 0 range 1 .. 1;
18892 Master_V2 at 0 range 2 .. 2;
18893 Master_V3 at 0 range 3 .. 3;
18894 Master_V4 at 0 range 4 .. 4;
18895 Master_V5 at 0 range 5 .. 5;
18896 Master_V6 at 0 range 6 .. 6;
18897 Master_V7 at 0 range 7 .. 7;
18898 Slave_Control at 1 range 0 .. 0;
18899 Slave_V1 at 1 range 1 .. 1;
18900 Slave_V2 at 1 range 2 .. 2;
18901 Slave_V3 at 1 range 3 .. 3;
18902 Slave_V4 at 1 range 4 .. 4;
18903 Slave_V5 at 1 range 5 .. 5;
18904 Slave_V6 at 1 range 6 .. 6;
18905 Slave_V7 at 1 range 7 .. 7;
18906 end record;
18907 @end example
18908
18909 Now if we move this to a little endian machine, then the bit ordering within
18910 the byte is backwards, so we have to rewrite the record rep clause as:
18911
18912 @example
18913 for Data use record
18914 Master_Control at 0 range 7 .. 7;
18915 Master_V1 at 0 range 6 .. 6;
18916 Master_V2 at 0 range 5 .. 5;
18917 Master_V3 at 0 range 4 .. 4;
18918 Master_V4 at 0 range 3 .. 3;
18919 Master_V5 at 0 range 2 .. 2;
18920 Master_V6 at 0 range 1 .. 1;
18921 Master_V7 at 0 range 0 .. 0;
18922 Slave_Control at 1 range 7 .. 7;
18923 Slave_V1 at 1 range 6 .. 6;
18924 Slave_V2 at 1 range 5 .. 5;
18925 Slave_V3 at 1 range 4 .. 4;
18926 Slave_V4 at 1 range 3 .. 3;
18927 Slave_V5 at 1 range 2 .. 2;
18928 Slave_V6 at 1 range 1 .. 1;
18929 Slave_V7 at 1 range 0 .. 0;
18930 end record;
18931 @end example
18932
18933 It is a nuisance to have to rewrite the clause, especially if
18934 the code has to be maintained on both machines. However,
18935 this is a case that we can handle with the
18936 @code{Bit_Order} attribute if it is implemented.
18937 Note that the implementation is not required on byte addressed
18938 machines, but it is indeed implemented in GNAT.
18939 This means that we can simply use the
18940 first record clause, together with the declaration
18941
18942 @example
18943 for Data'Bit_Order use High_Order_First;
18944 @end example
18945
18946 and the effect is what is desired, namely the layout is exactly the same,
18947 independent of whether the code is compiled on a big-endian or little-endian
18948 machine.
18949
18950 The important point to understand is that byte ordering is not affected.
18951 A @code{Bit_Order} attribute definition never affects which byte a field
18952 ends up in, only where it ends up in that byte.
18953 To make this clear, let us rewrite the record rep clause of the previous
18954 example as:
18955
18956 @example
18957 for Data'Bit_Order use High_Order_First;
18958 for Data use record
18959 Master_Control at 0 range 0 .. 0;
18960 Master_V1 at 0 range 1 .. 1;
18961 Master_V2 at 0 range 2 .. 2;
18962 Master_V3 at 0 range 3 .. 3;
18963 Master_V4 at 0 range 4 .. 4;
18964 Master_V5 at 0 range 5 .. 5;
18965 Master_V6 at 0 range 6 .. 6;
18966 Master_V7 at 0 range 7 .. 7;
18967 Slave_Control at 0 range 8 .. 8;
18968 Slave_V1 at 0 range 9 .. 9;
18969 Slave_V2 at 0 range 10 .. 10;
18970 Slave_V3 at 0 range 11 .. 11;
18971 Slave_V4 at 0 range 12 .. 12;
18972 Slave_V5 at 0 range 13 .. 13;
18973 Slave_V6 at 0 range 14 .. 14;
18974 Slave_V7 at 0 range 15 .. 15;
18975 end record;
18976 @end example
18977
18978 This is exactly equivalent to saying (a repeat of the first example):
18979
18980 @example
18981 for Data'Bit_Order use High_Order_First;
18982 for Data use record
18983 Master_Control at 0 range 0 .. 0;
18984 Master_V1 at 0 range 1 .. 1;
18985 Master_V2 at 0 range 2 .. 2;
18986 Master_V3 at 0 range 3 .. 3;
18987 Master_V4 at 0 range 4 .. 4;
18988 Master_V5 at 0 range 5 .. 5;
18989 Master_V6 at 0 range 6 .. 6;
18990 Master_V7 at 0 range 7 .. 7;
18991 Slave_Control at 1 range 0 .. 0;
18992 Slave_V1 at 1 range 1 .. 1;
18993 Slave_V2 at 1 range 2 .. 2;
18994 Slave_V3 at 1 range 3 .. 3;
18995 Slave_V4 at 1 range 4 .. 4;
18996 Slave_V5 at 1 range 5 .. 5;
18997 Slave_V6 at 1 range 6 .. 6;
18998 Slave_V7 at 1 range 7 .. 7;
18999 end record;
19000 @end example
19001
19002 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
19003 field. The storage place attributes are obtained by normalizing the
19004 values given so that the @code{First_Bit} value is less than 8. After
19005 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
19006 we specified in the other case.
19007
19008 Now one might expect that the @code{Bit_Order} attribute might affect
19009 bit numbering within the entire record component (two bytes in this
19010 case, thus affecting which byte fields end up in), but that is not
19011 the way this feature is defined, it only affects numbering of bits,
19012 not which byte they end up in.
19013
19014 Consequently it never makes sense to specify a starting bit number
19015 greater than 7 (for a byte addressable field) if an attribute
19016 definition for @code{Bit_Order} has been given, and indeed it
19017 may be actively confusing to specify such a value, so the compiler
19018 generates a warning for such usage.
19019
19020 If you do need to control byte ordering then appropriate conditional
19021 values must be used. If in our example, the slave byte came first on
19022 some machines we might write:
19023
19024 @example
19025 Master_Byte_First constant Boolean := ...;
19026
19027 Master_Byte : constant Natural :=
19028 1 - Boolean'Pos (Master_Byte_First);
19029 Slave_Byte : constant Natural :=
19030 Boolean'Pos (Master_Byte_First);
19031
19032 for Data'Bit_Order use High_Order_First;
19033 for Data use record
19034 Master_Control at Master_Byte range 0 .. 0;
19035 Master_V1 at Master_Byte range 1 .. 1;
19036 Master_V2 at Master_Byte range 2 .. 2;
19037 Master_V3 at Master_Byte range 3 .. 3;
19038 Master_V4 at Master_Byte range 4 .. 4;
19039 Master_V5 at Master_Byte range 5 .. 5;
19040 Master_V6 at Master_Byte range 6 .. 6;
19041 Master_V7 at Master_Byte range 7 .. 7;
19042 Slave_Control at Slave_Byte range 0 .. 0;
19043 Slave_V1 at Slave_Byte range 1 .. 1;
19044 Slave_V2 at Slave_Byte range 2 .. 2;
19045 Slave_V3 at Slave_Byte range 3 .. 3;
19046 Slave_V4 at Slave_Byte range 4 .. 4;
19047 Slave_V5 at Slave_Byte range 5 .. 5;
19048 Slave_V6 at Slave_Byte range 6 .. 6;
19049 Slave_V7 at Slave_Byte range 7 .. 7;
19050 end record;
19051 @end example
19052
19053 Now to switch between machines, all that is necessary is
19054 to set the boolean constant @code{Master_Byte_First} in
19055 an appropriate manner.
19056
19057 @node Pragma Pack for Arrays,Pragma Pack for Records,Effect of Bit_Order on Byte Ordering,Representation Clauses and Pragmas
19058 @anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-arrays}@anchor{287}@anchor{gnat_rm/representation_clauses_and_pragmas id11}@anchor{288}
19059 @section Pragma Pack for Arrays
19060
19061
19062 @geindex Pragma Pack (for arrays)
19063
19064 Pragma @code{Pack} applied to an array has an effect that depends upon whether the
19065 component type is @emph{packable}. For a component type to be @emph{packable}, it must
19066 be one of the following cases:
19067
19068
19069 @itemize *
19070
19071 @item
19072 Any elementary type.
19073
19074 @item
19075 Any small packed array type with a static size.
19076
19077 @item
19078 Any small simple record type with a static size.
19079 @end itemize
19080
19081 For all these cases, if the component subtype size is in the range
19082 1 through 64, then the effect of the pragma @code{Pack} is exactly as though a
19083 component size were specified giving the component subtype size.
19084
19085 All other types are non-packable, they occupy an integral number of storage
19086 units and the only effect of pragma Pack is to remove alignment gaps.
19087
19088 For example if we have:
19089
19090 @example
19091 type r is range 0 .. 17;
19092
19093 type ar is array (1 .. 8) of r;
19094 pragma Pack (ar);
19095 @end example
19096
19097 Then the component size of @code{ar} will be set to 5 (i.e., to @code{r'size},
19098 and the size of the array @code{ar} will be exactly 40 bits).
19099
19100 Note that in some cases this rather fierce approach to packing can produce
19101 unexpected effects. For example, in Ada 95 and Ada 2005,
19102 subtype @code{Natural} typically has a size of 31, meaning that if you
19103 pack an array of @code{Natural}, you get 31-bit
19104 close packing, which saves a few bits, but results in far less efficient
19105 access. Since many other Ada compilers will ignore such a packing request,
19106 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
19107 might not be what is intended. You can easily remove this warning by
19108 using an explicit @code{Component_Size} setting instead, which never generates
19109 a warning, since the intention of the programmer is clear in this case.
19110
19111 GNAT treats packed arrays in one of two ways. If the size of the array is
19112 known at compile time and is less than 64 bits, then internally the array
19113 is represented as a single modular type, of exactly the appropriate number
19114 of bits. If the length is greater than 63 bits, or is not known at compile
19115 time, then the packed array is represented as an array of bytes, and the
19116 length is always a multiple of 8 bits.
19117
19118 Note that to represent a packed array as a modular type, the alignment must
19119 be suitable for the modular type involved. For example, on typical machines
19120 a 32-bit packed array will be represented by a 32-bit modular integer with
19121 an alignment of four bytes. If you explicitly override the default alignment
19122 with an alignment clause that is too small, the modular representation
19123 cannot be used. For example, consider the following set of declarations:
19124
19125 @example
19126 type R is range 1 .. 3;
19127 type S is array (1 .. 31) of R;
19128 for S'Component_Size use 2;
19129 for S'Size use 62;
19130 for S'Alignment use 1;
19131 @end example
19132
19133 If the alignment clause were not present, then a 62-bit modular
19134 representation would be chosen (typically with an alignment of 4 or 8
19135 bytes depending on the target). But the default alignment is overridden
19136 with the explicit alignment clause. This means that the modular
19137 representation cannot be used, and instead the array of bytes
19138 representation must be used, meaning that the length must be a multiple
19139 of 8. Thus the above set of declarations will result in a diagnostic
19140 rejecting the size clause and noting that the minimum size allowed is 64.
19141
19142 @geindex Pragma Pack (for type Natural)
19143
19144 @geindex Pragma Pack warning
19145
19146 One special case that is worth noting occurs when the base type of the
19147 component size is 8/16/32 and the subtype is one bit less. Notably this
19148 occurs with subtype @code{Natural}. Consider:
19149
19150 @example
19151 type Arr is array (1 .. 32) of Natural;
19152 pragma Pack (Arr);
19153 @end example
19154
19155 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
19156 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
19157 Ada 83 compilers did not attempt 31 bit packing.
19158
19159 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
19160 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
19161 substantial unintended performance penalty when porting legacy Ada 83 code.
19162 To help prevent this, GNAT generates a warning in such cases. If you really
19163 want 31 bit packing in a case like this, you can set the component size
19164 explicitly:
19165
19166 @example
19167 type Arr is array (1 .. 32) of Natural;
19168 for Arr'Component_Size use 31;
19169 @end example
19170
19171 Here 31-bit packing is achieved as required, and no warning is generated,
19172 since in this case the programmer intention is clear.
19173
19174 @node Pragma Pack for Records,Record Representation Clauses,Pragma Pack for Arrays,Representation Clauses and Pragmas
19175 @anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-records}@anchor{289}@anchor{gnat_rm/representation_clauses_and_pragmas id12}@anchor{28a}
19176 @section Pragma Pack for Records
19177
19178
19179 @geindex Pragma Pack (for records)
19180
19181 Pragma @code{Pack} applied to a record will pack the components to reduce
19182 wasted space from alignment gaps and by reducing the amount of space
19183 taken by components. We distinguish between @emph{packable} components and
19184 @emph{non-packable} components.
19185 Components of the following types are considered packable:
19186
19187
19188 @itemize *
19189
19190 @item
19191 Components of an elementary type are packable unless they are aliased,
19192 independent, or of an atomic type.
19193
19194 @item
19195 Small packed arrays, where the size is statically known, are represented
19196 internally as modular integers, and so they are also packable.
19197
19198 @item
19199 Small simple records, where the size is statically known, are also packable.
19200 @end itemize
19201
19202 For all these cases, if the @code{'Size} value is in the range 1 through 64, the
19203 components occupy the exact number of bits corresponding to this value
19204 and are packed with no padding bits, i.e. they can start on an arbitrary
19205 bit boundary.
19206
19207 All other types are non-packable, they occupy an integral number of storage
19208 units and the only effect of pragma @code{Pack} is to remove alignment gaps.
19209
19210 For example, consider the record
19211
19212 @example
19213 type Rb1 is array (1 .. 13) of Boolean;
19214 pragma Pack (Rb1);
19215
19216 type Rb2 is array (1 .. 65) of Boolean;
19217 pragma Pack (Rb2);
19218
19219 type AF is new Float with Atomic;
19220
19221 type X2 is record
19222 L1 : Boolean;
19223 L2 : Duration;
19224 L3 : AF;
19225 L4 : Boolean;
19226 L5 : Rb1;
19227 L6 : Rb2;
19228 end record;
19229 pragma Pack (X2);
19230 @end example
19231
19232 The representation for the record @code{X2} is as follows:
19233
19234 @example
19235 for X2'Size use 224;
19236 for X2 use record
19237 L1 at 0 range 0 .. 0;
19238 L2 at 0 range 1 .. 64;
19239 L3 at 12 range 0 .. 31;
19240 L4 at 16 range 0 .. 0;
19241 L5 at 16 range 1 .. 13;
19242 L6 at 18 range 0 .. 71;
19243 end record;
19244 @end example
19245
19246 Studying this example, we see that the packable fields @code{L1}
19247 and @code{L2} are
19248 of length equal to their sizes, and placed at specific bit boundaries (and
19249 not byte boundaries) to
19250 eliminate padding. But @code{L3} is of a non-packable float type (because
19251 it is aliased), so it is on the next appropriate alignment boundary.
19252
19253 The next two fields are fully packable, so @code{L4} and @code{L5} are
19254 minimally packed with no gaps. However, type @code{Rb2} is a packed
19255 array that is longer than 64 bits, so it is itself non-packable. Thus
19256 the @code{L6} field is aligned to the next byte boundary, and takes an
19257 integral number of bytes, i.e., 72 bits.
19258
19259 @node Record Representation Clauses,Handling of Records with Holes,Pragma Pack for Records,Representation Clauses and Pragmas
19260 @anchor{gnat_rm/representation_clauses_and_pragmas id13}@anchor{28b}@anchor{gnat_rm/representation_clauses_and_pragmas record-representation-clauses}@anchor{28c}
19261 @section Record Representation Clauses
19262
19263
19264 @geindex Record Representation Clause
19265
19266 Record representation clauses may be given for all record types, including
19267 types obtained by record extension. Component clauses are allowed for any
19268 static component. The restrictions on component clauses depend on the type
19269 of the component.
19270
19271 @geindex Component Clause
19272
19273 For all components of an elementary type, the only restriction on component
19274 clauses is that the size must be at least the @code{'Size} value of the type
19275 (actually the Value_Size). There are no restrictions due to alignment,
19276 and such components may freely cross storage boundaries.
19277
19278 Packed arrays with a size up to and including 64 bits are represented
19279 internally using a modular type with the appropriate number of bits, and
19280 thus the same lack of restriction applies. For example, if you declare:
19281
19282 @example
19283 type R is array (1 .. 49) of Boolean;
19284 pragma Pack (R);
19285 for R'Size use 49;
19286 @end example
19287
19288 then a component clause for a component of type @code{R} may start on any
19289 specified bit boundary, and may specify a value of 49 bits or greater.
19290
19291 For packed bit arrays that are longer than 64 bits, there are two
19292 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
19293 including the important case of single bits or boolean values, then
19294 there are no limitations on placement of such components, and they
19295 may start and end at arbitrary bit boundaries.
19296
19297 If the component size is not a power of 2 (e.g., 3 or 5), then
19298 an array of this type longer than 64 bits must always be placed on
19299 on a storage unit (byte) boundary and occupy an integral number
19300 of storage units (bytes). Any component clause that does not
19301 meet this requirement will be rejected.
19302
19303 Any aliased component, or component of an aliased type, must
19304 have its normal alignment and size. A component clause that
19305 does not meet this requirement will be rejected.
19306
19307 The tag field of a tagged type always occupies an address sized field at
19308 the start of the record. No component clause may attempt to overlay this
19309 tag. When a tagged type appears as a component, the tag field must have
19310 proper alignment
19311
19312 In the case of a record extension @code{T1}, of a type @code{T}, no component clause applied
19313 to the type @code{T1} can specify a storage location that would overlap the first
19314 @code{T'Size} bytes of the record.
19315
19316 For all other component types, including non-bit-packed arrays,
19317 the component can be placed at an arbitrary bit boundary,
19318 so for example, the following is permitted:
19319
19320 @example
19321 type R is array (1 .. 10) of Boolean;
19322 for R'Size use 80;
19323
19324 type Q is record
19325 G, H : Boolean;
19326 L, M : R;
19327 end record;
19328
19329 for Q use record
19330 G at 0 range 0 .. 0;
19331 H at 0 range 1 .. 1;
19332 L at 0 range 2 .. 81;
19333 R at 0 range 82 .. 161;
19334 end record;
19335 @end example
19336
19337 @node Handling of Records with Holes,Enumeration Clauses,Record Representation Clauses,Representation Clauses and Pragmas
19338 @anchor{gnat_rm/representation_clauses_and_pragmas handling-of-records-with-holes}@anchor{28d}@anchor{gnat_rm/representation_clauses_and_pragmas id14}@anchor{28e}
19339 @section Handling of Records with Holes
19340
19341
19342 @geindex Handling of Records with Holes
19343
19344 As a result of alignment considerations, records may contain "holes"
19345 or gaps
19346 which do not correspond to the data bits of any of the components.
19347 Record representation clauses can also result in holes in records.
19348
19349 GNAT does not attempt to clear these holes, so in record objects,
19350 they should be considered to hold undefined rubbish. The generated
19351 equality routine just tests components so does not access these
19352 undefined bits, and assignment and copy operations may or may not
19353 preserve the contents of these holes (for assignments, the holes
19354 in the target will in practice contain either the bits that are
19355 present in the holes in the source, or the bits that were present
19356 in the target before the assignment).
19357
19358 If it is necessary to ensure that holes in records have all zero
19359 bits, then record objects for which this initialization is desired
19360 should be explicitly set to all zero values using Unchecked_Conversion
19361 or address overlays. For example
19362
19363 @example
19364 type HRec is record
19365 C : Character;
19366 I : Integer;
19367 end record;
19368 @end example
19369
19370 On typical machines, integers need to be aligned on a four-byte
19371 boundary, resulting in three bytes of undefined rubbish following
19372 the 8-bit field for C. To ensure that the hole in a variable of
19373 type HRec is set to all zero bits,
19374 you could for example do:
19375
19376 @example
19377 type Base is record
19378 Dummy1, Dummy2 : Integer := 0;
19379 end record;
19380
19381 BaseVar : Base;
19382 RealVar : Hrec;
19383 for RealVar'Address use BaseVar'Address;
19384 @end example
19385
19386 Now the 8-bytes of the value of RealVar start out containing all zero
19387 bits. A safer approach is to just define dummy fields, avoiding the
19388 holes, as in:
19389
19390 @example
19391 type HRec is record
19392 C : Character;
19393 Dummy1 : Short_Short_Integer := 0;
19394 Dummy2 : Short_Short_Integer := 0;
19395 Dummy3 : Short_Short_Integer := 0;
19396 I : Integer;
19397 end record;
19398 @end example
19399
19400 And to make absolutely sure that the intent of this is followed, you
19401 can use representation clauses:
19402
19403 @example
19404 for Hrec use record
19405 C at 0 range 0 .. 7;
19406 Dummy1 at 1 range 0 .. 7;
19407 Dummy2 at 2 range 0 .. 7;
19408 Dummy3 at 3 range 0 .. 7;
19409 I at 4 range 0 .. 31;
19410 end record;
19411 for Hrec'Size use 64;
19412 @end example
19413
19414 @node Enumeration Clauses,Address Clauses,Handling of Records with Holes,Representation Clauses and Pragmas
19415 @anchor{gnat_rm/representation_clauses_and_pragmas enumeration-clauses}@anchor{28f}@anchor{gnat_rm/representation_clauses_and_pragmas id15}@anchor{290}
19416 @section Enumeration Clauses
19417
19418
19419 The only restriction on enumeration clauses is that the range of values
19420 must be representable. For the signed case, if one or more of the
19421 representation values are negative, all values must be in the range:
19422
19423 @example
19424 System.Min_Int .. System.Max_Int
19425 @end example
19426
19427 For the unsigned case, where all values are nonnegative, the values must
19428 be in the range:
19429
19430 @example
19431 0 .. System.Max_Binary_Modulus;
19432 @end example
19433
19434 A @emph{confirming} representation clause is one in which the values range
19435 from 0 in sequence, i.e., a clause that confirms the default representation
19436 for an enumeration type.
19437 Such a confirming representation
19438 is permitted by these rules, and is specially recognized by the compiler so
19439 that no extra overhead results from the use of such a clause.
19440
19441 If an array has an index type which is an enumeration type to which an
19442 enumeration clause has been applied, then the array is stored in a compact
19443 manner. Consider the declarations:
19444
19445 @example
19446 type r is (A, B, C);
19447 for r use (A => 1, B => 5, C => 10);
19448 type t is array (r) of Character;
19449 @end example
19450
19451 The array type t corresponds to a vector with exactly three elements and
19452 has a default size equal to @code{3*Character'Size}. This ensures efficient
19453 use of space, but means that accesses to elements of the array will incur
19454 the overhead of converting representation values to the corresponding
19455 positional values, (i.e., the value delivered by the @code{Pos} attribute).
19456
19457 @node Address Clauses,Use of Address Clauses for Memory-Mapped I/O,Enumeration Clauses,Representation Clauses and Pragmas
19458 @anchor{gnat_rm/representation_clauses_and_pragmas id16}@anchor{291}@anchor{gnat_rm/representation_clauses_and_pragmas address-clauses}@anchor{292}
19459 @section Address Clauses
19460
19461
19462 @geindex Address Clause
19463
19464 The reference manual allows a general restriction on representation clauses,
19465 as found in RM 13.1(22):
19466
19467 @quotation
19468
19469 "An implementation need not support representation
19470 items containing nonstatic expressions, except that
19471 an implementation should support a representation item
19472 for a given entity if each nonstatic expression in the
19473 representation item is a name that statically denotes
19474 a constant declared before the entity."
19475 @end quotation
19476
19477 In practice this is applicable only to address clauses, since this is the
19478 only case in which a nonstatic expression is permitted by the syntax. As
19479 the AARM notes in sections 13.1 (22.a-22.h):
19480
19481 @quotation
19482
19483 22.a Reason: This is to avoid the following sort of thing:
19484
19485 22.b X : Integer := F(...);
19486 Y : Address := G(...);
19487 for X'Address use Y;
19488
19489 22.c In the above, we have to evaluate the
19490 initialization expression for X before we
19491 know where to put the result. This seems
19492 like an unreasonable implementation burden.
19493
19494 22.d The above code should instead be written
19495 like this:
19496
19497 22.e Y : constant Address := G(...);
19498 X : Integer := F(...);
19499 for X'Address use Y;
19500
19501 22.f This allows the expression 'Y' to be safely
19502 evaluated before X is created.
19503
19504 22.g The constant could be a formal parameter of mode in.
19505
19506 22.h An implementation can support other nonstatic
19507 expressions if it wants to. Expressions of type
19508 Address are hardly ever static, but their value
19509 might be known at compile time anyway in many
19510 cases.
19511 @end quotation
19512
19513 GNAT does indeed permit many additional cases of nonstatic expressions. In
19514 particular, if the type involved is elementary there are no restrictions
19515 (since in this case, holding a temporary copy of the initialization value,
19516 if one is present, is inexpensive). In addition, if there is no implicit or
19517 explicit initialization, then there are no restrictions. GNAT will reject
19518 only the case where all three of these conditions hold:
19519
19520
19521 @itemize *
19522
19523 @item
19524 The type of the item is non-elementary (e.g., a record or array).
19525
19526 @item
19527 There is explicit or implicit initialization required for the object.
19528 Note that access values are always implicitly initialized.
19529
19530 @item
19531 The address value is nonstatic. Here GNAT is more permissive than the
19532 RM, and allows the address value to be the address of a previously declared
19533 stand-alone variable, as long as it does not itself have an address clause.
19534
19535 @example
19536 Anchor : Some_Initialized_Type;
19537 Overlay : Some_Initialized_Type;
19538 for Overlay'Address use Anchor'Address;
19539 @end example
19540
19541 However, the prefix of the address clause cannot be an array component, or
19542 a component of a discriminated record.
19543 @end itemize
19544
19545 As noted above in section 22.h, address values are typically nonstatic. In
19546 particular the To_Address function, even if applied to a literal value, is
19547 a nonstatic function call. To avoid this minor annoyance, GNAT provides
19548 the implementation defined attribute 'To_Address. The following two
19549 expressions have identical values:
19550
19551 @geindex Attribute
19552
19553 @geindex To_Address
19554
19555 @example
19556 To_Address (16#1234_0000#)
19557 System'To_Address (16#1234_0000#);
19558 @end example
19559
19560 except that the second form is considered to be a static expression, and
19561 thus when used as an address clause value is always permitted.
19562
19563 Additionally, GNAT treats as static an address clause that is an
19564 unchecked_conversion of a static integer value. This simplifies the porting
19565 of legacy code, and provides a portable equivalent to the GNAT attribute
19566 @code{To_Address}.
19567
19568 Another issue with address clauses is the interaction with alignment
19569 requirements. When an address clause is given for an object, the address
19570 value must be consistent with the alignment of the object (which is usually
19571 the same as the alignment of the type of the object). If an address clause
19572 is given that specifies an inappropriately aligned address value, then the
19573 program execution is erroneous.
19574
19575 Since this source of erroneous behavior can have unfortunate effects on
19576 machines with strict alignment requirements, GNAT
19577 checks (at compile time if possible, generating a warning, or at execution
19578 time with a run-time check) that the alignment is appropriate. If the
19579 run-time check fails, then @code{Program_Error} is raised. This run-time
19580 check is suppressed if range checks are suppressed, or if the special GNAT
19581 check Alignment_Check is suppressed, or if
19582 @code{pragma Restrictions (No_Elaboration_Code)} is in effect. It is also
19583 suppressed by default on non-strict alignment machines (such as the x86).
19584
19585 Finally, GNAT does not permit overlaying of objects of class-wide types. In
19586 most cases, the compiler can detect an attempt at such overlays and will
19587 generate a warning at compile time and a Program_Error exception at run time.
19588
19589 @geindex Export
19590
19591 An address clause cannot be given for an exported object. More
19592 understandably the real restriction is that objects with an address
19593 clause cannot be exported. This is because such variables are not
19594 defined by the Ada program, so there is no external object to export.
19595
19596 @geindex Import
19597
19598 It is permissible to give an address clause and a pragma Import for the
19599 same object. In this case, the variable is not really defined by the
19600 Ada program, so there is no external symbol to be linked. The link name
19601 and the external name are ignored in this case. The reason that we allow this
19602 combination is that it provides a useful idiom to avoid unwanted
19603 initializations on objects with address clauses.
19604
19605 When an address clause is given for an object that has implicit or
19606 explicit initialization, then by default initialization takes place. This
19607 means that the effect of the object declaration is to overwrite the
19608 memory at the specified address. This is almost always not what the
19609 programmer wants, so GNAT will output a warning:
19610
19611 @example
19612 with System;
19613 package G is
19614 type R is record
19615 M : Integer := 0;
19616 end record;
19617
19618 Ext : R;
19619 for Ext'Address use System'To_Address (16#1234_1234#);
19620 |
19621 >>> warning: implicit initialization of "Ext" may
19622 modify overlaid storage
19623 >>> warning: use pragma Import for "Ext" to suppress
19624 initialization (RM B(24))
19625
19626 end G;
19627 @end example
19628
19629 As indicated by the warning message, the solution is to use a (dummy) pragma
19630 Import to suppress this initialization. The pragma tell the compiler that the
19631 object is declared and initialized elsewhere. The following package compiles
19632 without warnings (and the initialization is suppressed):
19633
19634 @example
19635 with System;
19636 package G is
19637 type R is record
19638 M : Integer := 0;
19639 end record;
19640
19641 Ext : R;
19642 for Ext'Address use System'To_Address (16#1234_1234#);
19643 pragma Import (Ada, Ext);
19644 end G;
19645 @end example
19646
19647 A final issue with address clauses involves their use for overlaying
19648 variables, as in the following example:
19649
19650 @geindex Overlaying of objects
19651
19652 @example
19653 A : Integer;
19654 B : Integer;
19655 for B'Address use A'Address;
19656 @end example
19657
19658 or alternatively, using the form recommended by the RM:
19659
19660 @example
19661 A : Integer;
19662 Addr : constant Address := A'Address;
19663 B : Integer;
19664 for B'Address use Addr;
19665 @end example
19666
19667 In both of these cases, @code{A} and @code{B} become aliased to one another
19668 via the address clause. This use of address clauses to overlay
19669 variables, achieving an effect similar to unchecked conversion
19670 was erroneous in Ada 83, but in Ada 95 and Ada 2005
19671 the effect is implementation defined. Furthermore, the
19672 Ada RM specifically recommends that in a situation
19673 like this, @code{B} should be subject to the following
19674 implementation advice (RM 13.3(19)):
19675
19676 @quotation
19677
19678 "19 If the Address of an object is specified, or it is imported
19679 or exported, then the implementation should not perform
19680 optimizations based on assumptions of no aliases."
19681 @end quotation
19682
19683 GNAT follows this recommendation, and goes further by also applying
19684 this recommendation to the overlaid variable (@code{A} in the above example)
19685 in this case. This means that the overlay works "as expected", in that
19686 a modification to one of the variables will affect the value of the other.
19687
19688 More generally, GNAT interprets this recommendation conservatively for
19689 address clauses: in the cases other than overlays, it considers that the
19690 object is effectively subject to pragma @code{Volatile} and implements the
19691 associated semantics.
19692
19693 Note that when address clause overlays are used in this way, there is an
19694 issue of unintentional initialization, as shown by this example:
19695
19696 @example
19697 package Overwrite_Record is
19698 type R is record
19699 A : Character := 'C';
19700 B : Character := 'A';
19701 end record;
19702 X : Short_Integer := 3;
19703 Y : R;
19704 for Y'Address use X'Address;
19705 |
19706 >>> warning: default initialization of "Y" may
19707 modify "X", use pragma Import for "Y" to
19708 suppress initialization (RM B.1(24))
19709
19710 end Overwrite_Record;
19711 @end example
19712
19713 Here the default initialization of @code{Y} will clobber the value
19714 of @code{X}, which justifies the warning. The warning notes that
19715 this effect can be eliminated by adding a @code{pragma Import}
19716 which suppresses the initialization:
19717
19718 @example
19719 package Overwrite_Record is
19720 type R is record
19721 A : Character := 'C';
19722 B : Character := 'A';
19723 end record;
19724 X : Short_Integer := 3;
19725 Y : R;
19726 for Y'Address use X'Address;
19727 pragma Import (Ada, Y);
19728 end Overwrite_Record;
19729 @end example
19730
19731 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
19732 be initialized when they would not otherwise have been in the absence
19733 of the use of this pragma. This may cause an overlay to have this
19734 unintended clobbering effect. The compiler avoids this for scalar
19735 types, but not for composite objects (where in general the effect
19736 of @code{Initialize_Scalars} is part of the initialization routine
19737 for the composite object:
19738
19739 @example
19740 pragma Initialize_Scalars;
19741 with Ada.Text_IO; use Ada.Text_IO;
19742 procedure Overwrite_Array is
19743 type Arr is array (1 .. 5) of Integer;
19744 X : Arr := (others => 1);
19745 A : Arr;
19746 for A'Address use X'Address;
19747 |
19748 >>> warning: default initialization of "A" may
19749 modify "X", use pragma Import for "A" to
19750 suppress initialization (RM B.1(24))
19751
19752 begin
19753 if X /= Arr'(others => 1) then
19754 Put_Line ("X was clobbered");
19755 else
19756 Put_Line ("X was not clobbered");
19757 end if;
19758 end Overwrite_Array;
19759 @end example
19760
19761 The above program generates the warning as shown, and at execution
19762 time, prints @code{X was clobbered}. If the @code{pragma Import} is
19763 added as suggested:
19764
19765 @example
19766 pragma Initialize_Scalars;
19767 with Ada.Text_IO; use Ada.Text_IO;
19768 procedure Overwrite_Array is
19769 type Arr is array (1 .. 5) of Integer;
19770 X : Arr := (others => 1);
19771 A : Arr;
19772 for A'Address use X'Address;
19773 pragma Import (Ada, A);
19774 begin
19775 if X /= Arr'(others => 1) then
19776 Put_Line ("X was clobbered");
19777 else
19778 Put_Line ("X was not clobbered");
19779 end if;
19780 end Overwrite_Array;
19781 @end example
19782
19783 then the program compiles without the warning and when run will generate
19784 the output @code{X was not clobbered}.
19785
19786 @node Use of Address Clauses for Memory-Mapped I/O,Effect of Convention on Representation,Address Clauses,Representation Clauses and Pragmas
19787 @anchor{gnat_rm/representation_clauses_and_pragmas id17}@anchor{293}@anchor{gnat_rm/representation_clauses_and_pragmas use-of-address-clauses-for-memory-mapped-i-o}@anchor{294}
19788 @section Use of Address Clauses for Memory-Mapped I/O
19789
19790
19791 @geindex Memory-mapped I/O
19792
19793 A common pattern is to use an address clause to map an atomic variable to
19794 a location in memory that corresponds to a memory-mapped I/O operation or
19795 operations, for example:
19796
19797 @example
19798 type Mem_Word is record
19799 A,B,C,D : Byte;
19800 end record;
19801 pragma Atomic (Mem_Word);
19802 for Mem_Word_Size use 32;
19803
19804 Mem : Mem_Word;
19805 for Mem'Address use some-address;
19806 ...
19807 Temp := Mem;
19808 Temp.A := 32;
19809 Mem := Temp;
19810 @end example
19811
19812 For a full access (reference or modification) of the variable (Mem) in this
19813 case, as in the above examples, GNAT guarantees that the entire atomic word
19814 will be accessed, in accordance with the RM C.6(15) clause.
19815
19816 A problem arises with a component access such as:
19817
19818 @example
19819 Mem.A := 32;
19820 @end example
19821
19822 Note that the component A is not declared as atomic. This means that it is
19823 not clear what this assignment means. It could correspond to full word read
19824 and write as given in the first example, or on architectures that supported
19825 such an operation it might be a single byte store instruction. The RM does
19826 not have anything to say in this situation, and GNAT does not make any
19827 guarantee. The code generated may vary from target to target. GNAT will issue
19828 a warning in such a case:
19829
19830 @example
19831 Mem.A := 32;
19832 |
19833 >>> warning: access to non-atomic component of atomic array,
19834 may cause unexpected accesses to atomic object
19835 @end example
19836
19837 It is best to be explicit in this situation, by either declaring the
19838 components to be atomic if you want the byte store, or explicitly writing
19839 the full word access sequence if that is what the hardware requires.
19840 Alternatively, if the full word access sequence is required, GNAT also
19841 provides the pragma @code{Volatile_Full_Access} which can be used in lieu of
19842 pragma @code{Atomic} and will give the additional guarantee.
19843
19844 @node Effect of Convention on Representation,Conventions and Anonymous Access Types,Use of Address Clauses for Memory-Mapped I/O,Representation Clauses and Pragmas
19845 @anchor{gnat_rm/representation_clauses_and_pragmas id18}@anchor{295}@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-convention-on-representation}@anchor{296}
19846 @section Effect of Convention on Representation
19847
19848
19849 @geindex Convention
19850 @geindex effect on representation
19851
19852 Normally the specification of a foreign language convention for a type or
19853 an object has no effect on the chosen representation. In particular, the
19854 representation chosen for data in GNAT generally meets the standard system
19855 conventions, and for example records are laid out in a manner that is
19856 consistent with C. This means that specifying convention C (for example)
19857 has no effect.
19858
19859 There are four exceptions to this general rule:
19860
19861
19862 @itemize *
19863
19864 @item
19865 @emph{Convention Fortran and array subtypes}.
19866
19867 If pragma Convention Fortran is specified for an array subtype, then in
19868 accordance with the implementation advice in section 3.6.2(11) of the
19869 Ada Reference Manual, the array will be stored in a Fortran-compatible
19870 column-major manner, instead of the normal default row-major order.
19871
19872 @item
19873 @emph{Convention C and enumeration types}
19874
19875 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
19876 to accommodate all values of the type. For example, for the enumeration
19877 type declared by:
19878
19879 @example
19880 type Color is (Red, Green, Blue);
19881 @end example
19882
19883 8 bits is sufficient to store all values of the type, so by default, objects
19884 of type @code{Color} will be represented using 8 bits. However, normal C
19885 convention is to use 32 bits for all enum values in C, since enum values
19886 are essentially of type int. If pragma @code{Convention C} is specified for an
19887 Ada enumeration type, then the size is modified as necessary (usually to
19888 32 bits) to be consistent with the C convention for enum values.
19889
19890 Note that this treatment applies only to types. If Convention C is given for
19891 an enumeration object, where the enumeration type is not Convention C, then
19892 Object_Size bits are allocated. For example, for a normal enumeration type,
19893 with less than 256 elements, only 8 bits will be allocated for the object.
19894 Since this may be a surprise in terms of what C expects, GNAT will issue a
19895 warning in this situation. The warning can be suppressed by giving an explicit
19896 size clause specifying the desired size.
19897
19898 @item
19899 @emph{Convention C/Fortran and Boolean types}
19900
19901 In C, the usual convention for boolean values, that is values used for
19902 conditions, is that zero represents false, and nonzero values represent
19903 true. In Ada, the normal convention is that two specific values, typically
19904 0/1, are used to represent false/true respectively.
19905
19906 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
19907 value represents true).
19908
19909 To accommodate the Fortran and C conventions, if a pragma Convention specifies
19910 C or Fortran convention for a derived Boolean, as in the following example:
19911
19912 @example
19913 type C_Switch is new Boolean;
19914 pragma Convention (C, C_Switch);
19915 @end example
19916
19917 then the GNAT generated code will treat any nonzero value as true. For truth
19918 values generated by GNAT, the conventional value 1 will be used for True, but
19919 when one of these values is read, any nonzero value is treated as True.
19920 @end itemize
19921
19922 @node Conventions and Anonymous Access Types,Determining the Representations chosen by GNAT,Effect of Convention on Representation,Representation Clauses and Pragmas
19923 @anchor{gnat_rm/representation_clauses_and_pragmas conventions-and-anonymous-access-types}@anchor{297}@anchor{gnat_rm/representation_clauses_and_pragmas id19}@anchor{298}
19924 @section Conventions and Anonymous Access Types
19925
19926
19927 @geindex Anonymous access types
19928
19929 @geindex Convention for anonymous access types
19930
19931 The RM is not entirely clear on convention handling in a number of cases,
19932 and in particular, it is not clear on the convention to be given to
19933 anonymous access types in general, and in particular what is to be
19934 done for the case of anonymous access-to-subprogram.
19935
19936 In GNAT, we decide that if an explicit Convention is applied
19937 to an object or component, and its type is such an anonymous type,
19938 then the convention will apply to this anonymous type as well. This
19939 seems to make sense since it is anomolous in any case to have a
19940 different convention for an object and its type, and there is clearly
19941 no way to explicitly specify a convention for an anonymous type, since
19942 it doesn't have a name to specify!
19943
19944 Furthermore, we decide that if a convention is applied to a record type,
19945 then this convention is inherited by any of its components that are of an
19946 anonymous access type which do not have an explicitly specified convention.
19947
19948 The following program shows these conventions in action:
19949
19950 @example
19951 package ConvComp is
19952 type Foo is range 1 .. 10;
19953 type T1 is record
19954 A : access function (X : Foo) return Integer;
19955 B : Integer;
19956 end record;
19957 pragma Convention (C, T1);
19958
19959 type T2 is record
19960 A : access function (X : Foo) return Integer;
19961 pragma Convention (C, A);
19962 B : Integer;
19963 end record;
19964 pragma Convention (COBOL, T2);
19965
19966 type T3 is record
19967 A : access function (X : Foo) return Integer;
19968 pragma Convention (COBOL, A);
19969 B : Integer;
19970 end record;
19971 pragma Convention (C, T3);
19972
19973 type T4 is record
19974 A : access function (X : Foo) return Integer;
19975 B : Integer;
19976 end record;
19977 pragma Convention (COBOL, T4);
19978
19979 function F (X : Foo) return Integer;
19980 pragma Convention (C, F);
19981
19982 function F (X : Foo) return Integer is (13);
19983
19984 TV1 : T1 := (F'Access, 12); -- OK
19985 TV2 : T2 := (F'Access, 13); -- OK
19986
19987 TV3 : T3 := (F'Access, 13); -- ERROR
19988 |
19989 >>> subprogram "F" has wrong convention
19990 >>> does not match access to subprogram declared at line 17
19991 38. TV4 : T4 := (F'Access, 13); -- ERROR
19992 |
19993 >>> subprogram "F" has wrong convention
19994 >>> does not match access to subprogram declared at line 24
19995 39. end ConvComp;
19996 @end example
19997
19998 @node Determining the Representations chosen by GNAT,,Conventions and Anonymous Access Types,Representation Clauses and Pragmas
19999 @anchor{gnat_rm/representation_clauses_and_pragmas id20}@anchor{299}@anchor{gnat_rm/representation_clauses_and_pragmas determining-the-representations-chosen-by-gnat}@anchor{29a}
20000 @section Determining the Representations chosen by GNAT
20001
20002
20003 @geindex Representation
20004 @geindex determination of
20005
20006 @geindex -gnatR (gcc)
20007
20008 Although the descriptions in this section are intended to be complete, it is
20009 often easier to simply experiment to see what GNAT accepts and what the
20010 effect is on the layout of types and objects.
20011
20012 As required by the Ada RM, if a representation clause is not accepted, then
20013 it must be rejected as illegal by the compiler. However, when a
20014 representation clause or pragma is accepted, there can still be questions
20015 of what the compiler actually does. For example, if a partial record
20016 representation clause specifies the location of some components and not
20017 others, then where are the non-specified components placed? Or if pragma
20018 @code{Pack} is used on a record, then exactly where are the resulting
20019 fields placed? The section on pragma @code{Pack} in this chapter can be
20020 used to answer the second question, but it is often easier to just see
20021 what the compiler does.
20022
20023 For this purpose, GNAT provides the option @emph{-gnatR}. If you compile
20024 with this option, then the compiler will output information on the actual
20025 representations chosen, in a format similar to source representation
20026 clauses. For example, if we compile the package:
20027
20028 @example
20029 package q is
20030 type r (x : boolean) is tagged record
20031 case x is
20032 when True => S : String (1 .. 100);
20033 when False => null;
20034 end case;
20035 end record;
20036
20037 type r2 is new r (false) with record
20038 y2 : integer;
20039 end record;
20040
20041 for r2 use record
20042 y2 at 16 range 0 .. 31;
20043 end record;
20044
20045 type x is record
20046 y : character;
20047 end record;
20048
20049 type x1 is array (1 .. 10) of x;
20050 for x1'component_size use 11;
20051
20052 type ia is access integer;
20053
20054 type Rb1 is array (1 .. 13) of Boolean;
20055 pragma Pack (rb1);
20056
20057 type Rb2 is array (1 .. 65) of Boolean;
20058 pragma Pack (rb2);
20059
20060 type x2 is record
20061 l1 : Boolean;
20062 l2 : Duration;
20063 l3 : Float;
20064 l4 : Boolean;
20065 l5 : Rb1;
20066 l6 : Rb2;
20067 end record;
20068 pragma Pack (x2);
20069 end q;
20070 @end example
20071
20072 using the switch @emph{-gnatR} we obtain the following output:
20073
20074 @example
20075 Representation information for unit q
20076 -------------------------------------
20077
20078 for r'Size use ??;
20079 for r'Alignment use 4;
20080 for r use record
20081 x at 4 range 0 .. 7;
20082 _tag at 0 range 0 .. 31;
20083 s at 5 range 0 .. 799;
20084 end record;
20085
20086 for r2'Size use 160;
20087 for r2'Alignment use 4;
20088 for r2 use record
20089 x at 4 range 0 .. 7;
20090 _tag at 0 range 0 .. 31;
20091 _parent at 0 range 0 .. 63;
20092 y2 at 16 range 0 .. 31;
20093 end record;
20094
20095 for x'Size use 8;
20096 for x'Alignment use 1;
20097 for x use record
20098 y at 0 range 0 .. 7;
20099 end record;
20100
20101 for x1'Size use 112;
20102 for x1'Alignment use 1;
20103 for x1'Component_Size use 11;
20104
20105 for rb1'Size use 13;
20106 for rb1'Alignment use 2;
20107 for rb1'Component_Size use 1;
20108
20109 for rb2'Size use 72;
20110 for rb2'Alignment use 1;
20111 for rb2'Component_Size use 1;
20112
20113 for x2'Size use 224;
20114 for x2'Alignment use 4;
20115 for x2 use record
20116 l1 at 0 range 0 .. 0;
20117 l2 at 0 range 1 .. 64;
20118 l3 at 12 range 0 .. 31;
20119 l4 at 16 range 0 .. 0;
20120 l5 at 16 range 1 .. 13;
20121 l6 at 18 range 0 .. 71;
20122 end record;
20123 @end example
20124
20125 The Size values are actually the Object_Size, i.e., the default size that
20126 will be allocated for objects of the type.
20127 The @code{??} size for type r indicates that we have a variant record, and the
20128 actual size of objects will depend on the discriminant value.
20129
20130 The Alignment values show the actual alignment chosen by the compiler
20131 for each record or array type.
20132
20133 The record representation clause for type r shows where all fields
20134 are placed, including the compiler generated tag field (whose location
20135 cannot be controlled by the programmer).
20136
20137 The record representation clause for the type extension r2 shows all the
20138 fields present, including the parent field, which is a copy of the fields
20139 of the parent type of r2, i.e., r1.
20140
20141 The component size and size clauses for types rb1 and rb2 show
20142 the exact effect of pragma @code{Pack} on these arrays, and the record
20143 representation clause for type x2 shows how pragma @cite{Pack} affects
20144 this record type.
20145
20146 In some cases, it may be useful to cut and paste the representation clauses
20147 generated by the compiler into the original source to fix and guarantee
20148 the actual representation to be used.
20149
20150 @node Standard Library Routines,The Implementation of Standard I/O,Representation Clauses and Pragmas,Top
20151 @anchor{gnat_rm/standard_library_routines standard-library-routines}@anchor{e}@anchor{gnat_rm/standard_library_routines doc}@anchor{29b}@anchor{gnat_rm/standard_library_routines id1}@anchor{29c}
20152 @chapter Standard Library Routines
20153
20154
20155 The Ada Reference Manual contains in Annex A a full description of an
20156 extensive set of standard library routines that can be used in any Ada
20157 program, and which must be provided by all Ada compilers. They are
20158 analogous to the standard C library used by C programs.
20159
20160 GNAT implements all of the facilities described in annex A, and for most
20161 purposes the description in the Ada Reference Manual, or appropriate Ada
20162 text book, will be sufficient for making use of these facilities.
20163
20164 In the case of the input-output facilities,
20165 @ref{f,,The Implementation of Standard I/O},
20166 gives details on exactly how GNAT interfaces to the
20167 file system. For the remaining packages, the Ada Reference Manual
20168 should be sufficient. The following is a list of the packages included,
20169 together with a brief description of the functionality that is provided.
20170
20171 For completeness, references are included to other predefined library
20172 routines defined in other sections of the Ada Reference Manual (these are
20173 cross-indexed from Annex A). For further details see the relevant
20174 package declarations in the run-time library. In particular, a few units
20175 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
20176 and in this case the package declaration contains comments explaining why
20177 the unit is not implemented.
20178
20179
20180 @table @asis
20181
20182 @item @code{Ada} @emph{(A.2)}
20183
20184 This is a parent package for all the standard library packages. It is
20185 usually included implicitly in your program, and itself contains no
20186 useful data or routines.
20187
20188 @item @code{Ada.Assertions} @emph{(11.4.2)}
20189
20190 @code{Assertions} provides the @code{Assert} subprograms, and also
20191 the declaration of the @code{Assertion_Error} exception.
20192
20193 @item @code{Ada.Asynchronous_Task_Control} @emph{(D.11)}
20194
20195 @code{Asynchronous_Task_Control} provides low level facilities for task
20196 synchronization. It is typically not implemented. See package spec for details.
20197
20198 @item @code{Ada.Calendar} @emph{(9.6)}
20199
20200 @code{Calendar} provides time of day access, and routines for
20201 manipulating times and durations.
20202
20203 @item @code{Ada.Calendar.Arithmetic} @emph{(9.6.1)}
20204
20205 This package provides additional arithmetic
20206 operations for @code{Calendar}.
20207
20208 @item @code{Ada.Calendar.Formatting} @emph{(9.6.1)}
20209
20210 This package provides formatting operations for @code{Calendar}.
20211
20212 @item @code{Ada.Calendar.Time_Zones} @emph{(9.6.1)}
20213
20214 This package provides additional @code{Calendar} facilities
20215 for handling time zones.
20216
20217 @item @code{Ada.Characters} @emph{(A.3.1)}
20218
20219 This is a dummy parent package that contains no useful entities
20220
20221 @item @code{Ada.Characters.Conversions} @emph{(A.3.2)}
20222
20223 This package provides character conversion functions.
20224
20225 @item @code{Ada.Characters.Handling} @emph{(A.3.2)}
20226
20227 This package provides some basic character handling capabilities,
20228 including classification functions for classes of characters (e.g., test
20229 for letters, or digits).
20230
20231 @item @code{Ada.Characters.Latin_1} @emph{(A.3.3)}
20232
20233 This package includes a complete set of definitions of the characters
20234 that appear in type CHARACTER. It is useful for writing programs that
20235 will run in international environments. For example, if you want an
20236 upper case E with an acute accent in a string, it is often better to use
20237 the definition of @code{UC_E_Acute} in this package. Then your program
20238 will print in an understandable manner even if your environment does not
20239 support these extended characters.
20240
20241 @item @code{Ada.Command_Line} @emph{(A.15)}
20242
20243 This package provides access to the command line parameters and the name
20244 of the current program (analogous to the use of @code{argc} and @code{argv}
20245 in C), and also allows the exit status for the program to be set in a
20246 system-independent manner.
20247
20248 @item @code{Ada.Complex_Text_IO} @emph{(G.1.3)}
20249
20250 This package provides text input and output of complex numbers.
20251
20252 @item @code{Ada.Containers} @emph{(A.18.1)}
20253
20254 A top level package providing a few basic definitions used by all the
20255 following specific child packages that provide specific kinds of
20256 containers.
20257 @end table
20258
20259 @code{Ada.Containers.Bounded_Priority_Queues} @emph{(A.18.31)}
20260
20261 @code{Ada.Containers.Bounded_Synchronized_Queues} @emph{(A.18.29)}
20262
20263 @code{Ada.Containers.Doubly_Linked_Lists} @emph{(A.18.3)}
20264
20265 @code{Ada.Containers.Generic_Array_Sort} @emph{(A.18.26)}
20266
20267 @code{Ada.Containers.Generic_Constrained_Array_Sort} @emph{(A.18.26)}
20268
20269 @code{Ada.Containers.Generic_Sort} @emph{(A.18.26)}
20270
20271 @code{Ada.Containers.Hashed_Maps} @emph{(A.18.5)}
20272
20273 @code{Ada.Containers.Hashed_Sets} @emph{(A.18.8)}
20274
20275 @code{Ada.Containers.Indefinite_Doubly_Linked_Lists} @emph{(A.18.12)}
20276
20277 @code{Ada.Containers.Indefinite_Hashed_Maps} @emph{(A.18.13)}
20278
20279 @code{Ada.Containers.Indefinite_Hashed_Sets} @emph{(A.18.15)}
20280
20281 @code{Ada.Containers.Indefinite_Holders} @emph{(A.18.18)}
20282
20283 @code{Ada.Containers.Indefinite_Multiway_Trees} @emph{(A.18.17)}
20284
20285 @code{Ada.Containers.Indefinite_Ordered_Maps} @emph{(A.18.14)}
20286
20287 @code{Ada.Containers.Indefinite_Ordered_Sets} @emph{(A.18.16)}
20288
20289 @code{Ada.Containers.Indefinite_Vectors} @emph{(A.18.11)}
20290
20291 @code{Ada.Containers.Multiway_Trees} @emph{(A.18.10)}
20292
20293 @code{Ada.Containers.Ordered_Maps} @emph{(A.18.6)}
20294
20295 @code{Ada.Containers.Ordered_Sets} @emph{(A.18.9)}
20296
20297 @code{Ada.Containers.Synchronized_Queue_Interfaces} @emph{(A.18.27)}
20298
20299 @code{Ada.Containers.Unbounded_Priority_Queues} @emph{(A.18.30)}
20300
20301 @code{Ada.Containers.Unbounded_Synchronized_Queues} @emph{(A.18.28)}
20302
20303 @code{Ada.Containers.Vectors} @emph{(A.18.2)}
20304
20305
20306 @table @asis
20307
20308 @item @code{Ada.Directories} @emph{(A.16)}
20309
20310 This package provides operations on directories.
20311
20312 @item @code{Ada.Directories.Hierarchical_File_Names} @emph{(A.16.1)}
20313
20314 This package provides additional directory operations handling
20315 hiearchical file names.
20316
20317 @item @code{Ada.Directories.Information} @emph{(A.16)}
20318
20319 This is an implementation defined package for additional directory
20320 operations, which is not implemented in GNAT.
20321
20322 @item @code{Ada.Decimal} @emph{(F.2)}
20323
20324 This package provides constants describing the range of decimal numbers
20325 implemented, and also a decimal divide routine (analogous to the COBOL
20326 verb DIVIDE ... GIVING ... REMAINDER ...)
20327
20328 @item @code{Ada.Direct_IO} @emph{(A.8.4)}
20329
20330 This package provides input-output using a model of a set of records of
20331 fixed-length, containing an arbitrary definite Ada type, indexed by an
20332 integer record number.
20333
20334 @item @code{Ada.Dispatching} @emph{(D.2.1)}
20335
20336 A parent package containing definitions for task dispatching operations.
20337
20338 @item @code{Ada.Dispatching.EDF} @emph{(D.2.6)}
20339
20340 Not implemented in GNAT.
20341
20342 @item @code{Ada.Dispatching.Non_Preemptive} @emph{(D.2.4)}
20343
20344 Not implemented in GNAT.
20345
20346 @item @code{Ada.Dispatching.Round_Robin} @emph{(D.2.5)}
20347
20348 Not implemented in GNAT.
20349
20350 @item @code{Ada.Dynamic_Priorities} @emph{(D.5)}
20351
20352 This package allows the priorities of a task to be adjusted dynamically
20353 as the task is running.
20354
20355 @item @code{Ada.Environment_Variables} @emph{(A.17)}
20356
20357 This package provides facilities for accessing environment variables.
20358
20359 @item @code{Ada.Exceptions} @emph{(11.4.1)}
20360
20361 This package provides additional information on exceptions, and also
20362 contains facilities for treating exceptions as data objects, and raising
20363 exceptions with associated messages.
20364
20365 @item @code{Ada.Execution_Time} @emph{(D.14)}
20366
20367 This package provides CPU clock functionalities. It is not implemented on
20368 all targets (see package spec for details).
20369
20370 @item @code{Ada.Execution_Time.Group_Budgets} @emph{(D.14.2)}
20371
20372 Not implemented in GNAT.
20373
20374 @item @code{Ada.Execution_Time.Timers} @emph{(D.14.1)'}
20375
20376 Not implemented in GNAT.
20377
20378 @item @code{Ada.Finalization} @emph{(7.6)}
20379
20380 This package contains the declarations and subprograms to support the
20381 use of controlled types, providing for automatic initialization and
20382 finalization (analogous to the constructors and destructors of C++).
20383
20384 @item @code{Ada.Float_Text_IO} @emph{(A.10.9)}
20385
20386 A library level instantiation of Text_IO.Float_IO for type Float.
20387
20388 @item @code{Ada.Float_Wide_Text_IO} @emph{(A.10.9)}
20389
20390 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
20391
20392 @item @code{Ada.Float_Wide_Wide_Text_IO} @emph{(A.10.9)}
20393
20394 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
20395
20396 @item @code{Ada.Integer_Text_IO} @emph{(A.10.9)}
20397
20398 A library level instantiation of Text_IO.Integer_IO for type Integer.
20399
20400 @item @code{Ada.Integer_Wide_Text_IO} @emph{(A.10.9)}
20401
20402 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
20403
20404 @item @code{Ada.Integer_Wide_Wide_Text_IO} @emph{(A.10.9)}
20405
20406 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
20407
20408 @item @code{Ada.Interrupts} @emph{(C.3.2)}
20409
20410 This package provides facilities for interfacing to interrupts, which
20411 includes the set of signals or conditions that can be raised and
20412 recognized as interrupts.
20413
20414 @item @code{Ada.Interrupts.Names} @emph{(C.3.2)}
20415
20416 This package provides the set of interrupt names (actually signal
20417 or condition names) that can be handled by GNAT.
20418
20419 @item @code{Ada.IO_Exceptions} @emph{(A.13)}
20420
20421 This package defines the set of exceptions that can be raised by use of
20422 the standard IO packages.
20423
20424 @item @code{Ada.Iterator_Interfaces} @emph{(5.5.1)}
20425
20426 This package provides a generic interface to generalized iterators.
20427
20428 @item @code{Ada.Locales} @emph{(A.19)}
20429
20430 This package provides declarations providing information (Language
20431 and Country) about the current locale.
20432
20433 @item @code{Ada.Numerics}
20434
20435 This package contains some standard constants and exceptions used
20436 throughout the numerics packages. Note that the constants pi and e are
20437 defined here, and it is better to use these definitions than rolling
20438 your own.
20439
20440 @item @code{Ada.Numerics.Complex_Arrays} @emph{(G.3.2)}
20441
20442 Provides operations on arrays of complex numbers.
20443
20444 @item @code{Ada.Numerics.Complex_Elementary_Functions}
20445
20446 Provides the implementation of standard elementary functions (such as
20447 log and trigonometric functions) operating on complex numbers using the
20448 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
20449 created by the package @code{Numerics.Complex_Types}.
20450
20451 @item @code{Ada.Numerics.Complex_Types}
20452
20453 This is a predefined instantiation of
20454 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
20455 build the type @code{Complex} and @code{Imaginary}.
20456
20457 @item @code{Ada.Numerics.Discrete_Random}
20458
20459 This generic package provides a random number generator suitable for generating
20460 uniformly distributed values of a specified discrete subtype.
20461
20462 @item @code{Ada.Numerics.Float_Random}
20463
20464 This package provides a random number generator suitable for generating
20465 uniformly distributed floating point values in the unit interval.
20466
20467 @item @code{Ada.Numerics.Generic_Complex_Elementary_Functions}
20468
20469 This is a generic version of the package that provides the
20470 implementation of standard elementary functions (such as log and
20471 trigonometric functions) for an arbitrary complex type.
20472
20473 The following predefined instantiations of this package are provided:
20474
20475
20476 @itemize *
20477
20478 @item
20479 @code{Short_Float}
20480
20481 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
20482
20483 @item
20484 @code{Float}
20485
20486 @code{Ada.Numerics.Complex_Elementary_Functions}
20487
20488 @item
20489 @code{Long_Float}
20490
20491 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
20492 @end itemize
20493
20494 @item @code{Ada.Numerics.Generic_Complex_Types}
20495
20496 This is a generic package that allows the creation of complex types,
20497 with associated complex arithmetic operations.
20498
20499 The following predefined instantiations of this package exist
20500
20501
20502 @itemize *
20503
20504 @item
20505 @code{Short_Float}
20506
20507 @code{Ada.Numerics.Short_Complex_Complex_Types}
20508
20509 @item
20510 @code{Float}
20511
20512 @code{Ada.Numerics.Complex_Complex_Types}
20513
20514 @item
20515 @code{Long_Float}
20516
20517 @code{Ada.Numerics.Long_Complex_Complex_Types}
20518 @end itemize
20519
20520 @item @code{Ada.Numerics.Generic_Elementary_Functions}
20521
20522 This is a generic package that provides the implementation of standard
20523 elementary functions (such as log an trigonometric functions) for an
20524 arbitrary float type.
20525
20526 The following predefined instantiations of this package exist
20527
20528
20529 @itemize *
20530
20531 @item
20532 @code{Short_Float}
20533
20534 @code{Ada.Numerics.Short_Elementary_Functions}
20535
20536 @item
20537 @code{Float}
20538
20539 @code{Ada.Numerics.Elementary_Functions}
20540
20541 @item
20542 @code{Long_Float}
20543
20544 @code{Ada.Numerics.Long_Elementary_Functions}
20545 @end itemize
20546
20547 @item @code{Ada.Numerics.Generic_Real_Arrays} @emph{(G.3.1)}
20548
20549 Generic operations on arrays of reals
20550
20551 @item @code{Ada.Numerics.Real_Arrays} @emph{(G.3.1)}
20552
20553 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
20554
20555 @item @code{Ada.Real_Time} @emph{(D.8)}
20556
20557 This package provides facilities similar to those of @code{Calendar}, but
20558 operating with a finer clock suitable for real time control. Note that
20559 annex D requires that there be no backward clock jumps, and GNAT generally
20560 guarantees this behavior, but of course if the external clock on which
20561 the GNAT runtime depends is deliberately reset by some external event,
20562 then such a backward jump may occur.
20563
20564 @item @code{Ada.Real_Time.Timing_Events} @emph{(D.15)}
20565
20566 Not implemented in GNAT.
20567
20568 @item @code{Ada.Sequential_IO} @emph{(A.8.1)}
20569
20570 This package provides input-output facilities for sequential files,
20571 which can contain a sequence of values of a single type, which can be
20572 any Ada type, including indefinite (unconstrained) types.
20573
20574 @item @code{Ada.Storage_IO} @emph{(A.9)}
20575
20576 This package provides a facility for mapping arbitrary Ada types to and
20577 from a storage buffer. It is primarily intended for the creation of new
20578 IO packages.
20579
20580 @item @code{Ada.Streams} @emph{(13.13.1)}
20581
20582 This is a generic package that provides the basic support for the
20583 concept of streams as used by the stream attributes (@code{Input},
20584 @code{Output}, @code{Read} and @code{Write}).
20585
20586 @item @code{Ada.Streams.Stream_IO} @emph{(A.12.1)}
20587
20588 This package is a specialization of the type @code{Streams} defined in
20589 package @code{Streams} together with a set of operations providing
20590 Stream_IO capability. The Stream_IO model permits both random and
20591 sequential access to a file which can contain an arbitrary set of values
20592 of one or more Ada types.
20593
20594 @item @code{Ada.Strings} @emph{(A.4.1)}
20595
20596 This package provides some basic constants used by the string handling
20597 packages.
20598
20599 @item @code{Ada.Strings.Bounded} @emph{(A.4.4)}
20600
20601 This package provides facilities for handling variable length
20602 strings. The bounded model requires a maximum length. It is thus
20603 somewhat more limited than the unbounded model, but avoids the use of
20604 dynamic allocation or finalization.
20605
20606 @item @code{Ada.Strings.Bounded.Equal_Case_Insensitive} @emph{(A.4.10)}
20607
20608 Provides case-insensitive comparisons of bounded strings
20609
20610 @item @code{Ada.Strings.Bounded.Hash} @emph{(A.4.9)}
20611
20612 This package provides a generic hash function for bounded strings
20613
20614 @item @code{Ada.Strings.Bounded.Hash_Case_Insensitive} @emph{(A.4.9)}
20615
20616 This package provides a generic hash function for bounded strings that
20617 converts the string to be hashed to lower case.
20618
20619 @item @code{Ada.Strings.Bounded.Less_Case_Insensitive} @emph{(A.4.10)}
20620
20621 This package provides a comparison function for bounded strings that works
20622 in a case insensitive manner by converting to lower case before the comparison.
20623
20624 @item @code{Ada.Strings.Fixed} @emph{(A.4.3)}
20625
20626 This package provides facilities for handling fixed length strings.
20627
20628 @item @code{Ada.Strings.Fixed.Equal_Case_Insensitive} @emph{(A.4.10)}
20629
20630 This package provides an equality function for fixed strings that compares
20631 the strings after converting both to lower case.
20632
20633 @item @code{Ada.Strings.Fixed.Hash_Case_Insensitive} @emph{(A.4.9)}
20634
20635 This package provides a case insensitive hash function for fixed strings that
20636 converts the string to lower case before computing the hash.
20637
20638 @item @code{Ada.Strings.Fixed.Less_Case_Insensitive} @emph{(A.4.10)}
20639
20640 This package provides a comparison function for fixed strings that works
20641 in a case insensitive manner by converting to lower case before the comparison.
20642
20643 @item @code{Ada.Strings.Hash} @emph{(A.4.9)}
20644
20645 This package provides a hash function for strings.
20646
20647 @item @code{Ada.Strings.Hash_Case_Insensitive} @emph{(A.4.9)}
20648
20649 This package provides a hash function for strings that is case insensitive.
20650 The string is converted to lower case before computing the hash.
20651
20652 @item @code{Ada.Strings.Less_Case_Insensitive} @emph{(A.4.10)}
20653
20654 This package provides a comparison function for\strings that works
20655 in a case insensitive manner by converting to lower case before the comparison.
20656
20657 @item @code{Ada.Strings.Maps} @emph{(A.4.2)}
20658
20659 This package provides facilities for handling character mappings and
20660 arbitrarily defined subsets of characters. For instance it is useful in
20661 defining specialized translation tables.
20662
20663 @item @code{Ada.Strings.Maps.Constants} @emph{(A.4.6)}
20664
20665 This package provides a standard set of predefined mappings and
20666 predefined character sets. For example, the standard upper to lower case
20667 conversion table is found in this package. Note that upper to lower case
20668 conversion is non-trivial if you want to take the entire set of
20669 characters, including extended characters like E with an acute accent,
20670 into account. You should use the mappings in this package (rather than
20671 adding 32 yourself) to do case mappings.
20672
20673 @item @code{Ada.Strings.Unbounded} @emph{(A.4.5)}
20674
20675 This package provides facilities for handling variable length
20676 strings. The unbounded model allows arbitrary length strings, but
20677 requires the use of dynamic allocation and finalization.
20678
20679 @item @code{Ada.Strings.Unbounded.Equal_Case_Insensitive} @emph{(A.4.10)}
20680
20681 Provides case-insensitive comparisons of unbounded strings
20682
20683 @item @code{Ada.Strings.Unbounded.Hash} @emph{(A.4.9)}
20684
20685 This package provides a generic hash function for unbounded strings
20686
20687 @item @code{Ada.Strings.Unbounded.Hash_Case_Insensitive} @emph{(A.4.9)}
20688
20689 This package provides a generic hash function for unbounded strings that
20690 converts the string to be hashed to lower case.
20691
20692 @item @code{Ada.Strings.Unbounded.Less_Case_Insensitive} @emph{(A.4.10)}
20693
20694 This package provides a comparison function for unbounded strings that works
20695 in a case insensitive manner by converting to lower case before the comparison.
20696
20697 @item @code{Ada.Strings.UTF_Encoding} @emph{(A.4.11)}
20698
20699 This package provides basic definitions for dealing with UTF-encoded strings.
20700
20701 @item @code{Ada.Strings.UTF_Encoding.Conversions} @emph{(A.4.11)}
20702
20703 This package provides conversion functions for UTF-encoded strings.
20704 @end table
20705
20706 @code{Ada.Strings.UTF_Encoding.Strings} @emph{(A.4.11)}
20707
20708 @code{Ada.Strings.UTF_Encoding.Wide_Strings} @emph{(A.4.11)}
20709
20710
20711 @table @asis
20712
20713 @item @code{Ada.Strings.UTF_Encoding.Wide_Wide_Strings} @emph{(A.4.11)}
20714
20715 These packages provide facilities for handling UTF encodings for
20716 Strings, Wide_Strings and Wide_Wide_Strings.
20717 @end table
20718
20719 @code{Ada.Strings.Wide_Bounded} @emph{(A.4.7)}
20720
20721 @code{Ada.Strings.Wide_Fixed} @emph{(A.4.7)}
20722
20723 @code{Ada.Strings.Wide_Maps} @emph{(A.4.7)}
20724
20725
20726 @table @asis
20727
20728 @item @code{Ada.Strings.Wide_Unbounded} @emph{(A.4.7)}
20729
20730 These packages provide analogous capabilities to the corresponding
20731 packages without @code{Wide_} in the name, but operate with the types
20732 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
20733 and @code{Character}. Versions of all the child packages are available.
20734 @end table
20735
20736 @code{Ada.Strings.Wide_Wide_Bounded} @emph{(A.4.7)}
20737
20738 @code{Ada.Strings.Wide_Wide_Fixed} @emph{(A.4.7)}
20739
20740 @code{Ada.Strings.Wide_Wide_Maps} @emph{(A.4.7)}
20741
20742
20743 @table @asis
20744
20745 @item @code{Ada.Strings.Wide_Wide_Unbounded} @emph{(A.4.7)}
20746
20747 These packages provide analogous capabilities to the corresponding
20748 packages without @code{Wide_} in the name, but operate with the types
20749 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
20750 of @code{String} and @code{Character}.
20751
20752 @item @code{Ada.Synchronous_Barriers} @emph{(D.10.1)}
20753
20754 This package provides facilities for synchronizing tasks at a low level
20755 with barriers.
20756
20757 @item @code{Ada.Synchronous_Task_Control} @emph{(D.10)}
20758
20759 This package provides some standard facilities for controlling task
20760 communication in a synchronous manner.
20761
20762 @item @code{Ada.Synchronous_Task_Control.EDF} @emph{(D.10)}
20763
20764 Not implemented in GNAT.
20765
20766 @item @code{Ada.Tags}
20767
20768 This package contains definitions for manipulation of the tags of tagged
20769 values.
20770
20771 @item @code{Ada.Tags.Generic_Dispatching_Constructor} @emph{(3.9)}
20772
20773 This package provides a way of constructing tagged class-wide values given
20774 only the tag value.
20775
20776 @item @code{Ada.Task_Attributes} @emph{(C.7.2)}
20777
20778 This package provides the capability of associating arbitrary
20779 task-specific data with separate tasks.
20780
20781 @item @code{Ada.Task_Identifification} @emph{(C.7.1)}
20782
20783 This package provides capabilities for task identification.
20784
20785 @item @code{Ada.Task_Termination} @emph{(C.7.3)}
20786
20787 This package provides control over task termination.
20788
20789 @item @code{Ada.Text_IO}
20790
20791 This package provides basic text input-output capabilities for
20792 character, string and numeric data. The subpackages of this
20793 package are listed next. Note that although these are defined
20794 as subpackages in the RM, they are actually transparently
20795 implemented as child packages in GNAT, meaning that they
20796 are only loaded if needed.
20797
20798 @item @code{Ada.Text_IO.Decimal_IO}
20799
20800 Provides input-output facilities for decimal fixed-point types
20801
20802 @item @code{Ada.Text_IO.Enumeration_IO}
20803
20804 Provides input-output facilities for enumeration types.
20805
20806 @item @code{Ada.Text_IO.Fixed_IO}
20807
20808 Provides input-output facilities for ordinary fixed-point types.
20809
20810 @item @code{Ada.Text_IO.Float_IO}
20811
20812 Provides input-output facilities for float types. The following
20813 predefined instantiations of this generic package are available:
20814
20815
20816 @itemize *
20817
20818 @item
20819 @code{Short_Float}
20820
20821 @code{Short_Float_Text_IO}
20822
20823 @item
20824 @code{Float}
20825
20826 @code{Float_Text_IO}
20827
20828 @item
20829 @code{Long_Float}
20830
20831 @code{Long_Float_Text_IO}
20832 @end itemize
20833
20834 @item @code{Ada.Text_IO.Integer_IO}
20835
20836 Provides input-output facilities for integer types. The following
20837 predefined instantiations of this generic package are available:
20838
20839
20840 @itemize *
20841
20842 @item
20843 @code{Short_Short_Integer}
20844
20845 @code{Ada.Short_Short_Integer_Text_IO}
20846
20847 @item
20848 @code{Short_Integer}
20849
20850 @code{Ada.Short_Integer_Text_IO}
20851
20852 @item
20853 @code{Integer}
20854
20855 @code{Ada.Integer_Text_IO}
20856
20857 @item
20858 @code{Long_Integer}
20859
20860 @code{Ada.Long_Integer_Text_IO}
20861
20862 @item
20863 @code{Long_Long_Integer}
20864
20865 @code{Ada.Long_Long_Integer_Text_IO}
20866 @end itemize
20867
20868 @item @code{Ada.Text_IO.Modular_IO}
20869
20870 Provides input-output facilities for modular (unsigned) types.
20871
20872 @item @code{Ada.Text_IO.Bounded_IO (A.10.11)}
20873
20874 Provides input-output facilities for bounded strings.
20875
20876 @item @code{Ada.Text_IO.Complex_IO (G.1.3)}
20877
20878 This package provides basic text input-output capabilities for complex
20879 data.
20880
20881 @item @code{Ada.Text_IO.Editing (F.3.3)}
20882
20883 This package contains routines for edited output, analogous to the use
20884 of pictures in COBOL. The picture formats used by this package are a
20885 close copy of the facility in COBOL.
20886
20887 @item @code{Ada.Text_IO.Text_Streams (A.12.2)}
20888
20889 This package provides a facility that allows Text_IO files to be treated
20890 as streams, so that the stream attributes can be used for writing
20891 arbitrary data, including binary data, to Text_IO files.
20892
20893 @item @code{Ada.Text_IO.Unbounded_IO (A.10.12)}
20894
20895 This package provides input-output facilities for unbounded strings.
20896
20897 @item @code{Ada.Unchecked_Conversion (13.9)}
20898
20899 This generic package allows arbitrary conversion from one type to
20900 another of the same size, providing for breaking the type safety in
20901 special circumstances.
20902
20903 If the types have the same Size (more accurately the same Value_Size),
20904 then the effect is simply to transfer the bits from the source to the
20905 target type without any modification. This usage is well defined, and
20906 for simple types whose representation is typically the same across
20907 all implementations, gives a portable method of performing such
20908 conversions.
20909
20910 If the types do not have the same size, then the result is implementation
20911 defined, and thus may be non-portable. The following describes how GNAT
20912 handles such unchecked conversion cases.
20913
20914 If the types are of different sizes, and are both discrete types, then
20915 the effect is of a normal type conversion without any constraint checking.
20916 In particular if the result type has a larger size, the result will be
20917 zero or sign extended. If the result type has a smaller size, the result
20918 will be truncated by ignoring high order bits.
20919
20920 If the types are of different sizes, and are not both discrete types,
20921 then the conversion works as though pointers were created to the source
20922 and target, and the pointer value is converted. The effect is that bits
20923 are copied from successive low order storage units and bits of the source
20924 up to the length of the target type.
20925
20926 A warning is issued if the lengths differ, since the effect in this
20927 case is implementation dependent, and the above behavior may not match
20928 that of some other compiler.
20929
20930 A pointer to one type may be converted to a pointer to another type using
20931 unchecked conversion. The only case in which the effect is undefined is
20932 when one or both pointers are pointers to unconstrained array types. In
20933 this case, the bounds information may get incorrectly transferred, and in
20934 particular, GNAT uses double size pointers for such types, and it is
20935 meaningless to convert between such pointer types. GNAT will issue a
20936 warning if the alignment of the target designated type is more strict
20937 than the alignment of the source designated type (since the result may
20938 be unaligned in this case).
20939
20940 A pointer other than a pointer to an unconstrained array type may be
20941 converted to and from System.Address. Such usage is common in Ada 83
20942 programs, but note that Ada.Address_To_Access_Conversions is the
20943 preferred method of performing such conversions in Ada 95 and Ada 2005.
20944 Neither
20945 unchecked conversion nor Ada.Address_To_Access_Conversions should be
20946 used in conjunction with pointers to unconstrained objects, since
20947 the bounds information cannot be handled correctly in this case.
20948
20949 @item @code{Ada.Unchecked_Deallocation} @emph{(13.11.2)}
20950
20951 This generic package allows explicit freeing of storage previously
20952 allocated by use of an allocator.
20953
20954 @item @code{Ada.Wide_Text_IO} @emph{(A.11)}
20955
20956 This package is similar to @code{Ada.Text_IO}, except that the external
20957 file supports wide character representations, and the internal types are
20958 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
20959 and @code{String}. The corresponding set of nested packages and child
20960 packages are defined.
20961
20962 @item @code{Ada.Wide_Wide_Text_IO} @emph{(A.11)}
20963
20964 This package is similar to @code{Ada.Text_IO}, except that the external
20965 file supports wide character representations, and the internal types are
20966 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
20967 and @code{String}. The corresponding set of nested packages and child
20968 packages are defined.
20969 @end table
20970
20971 For packages in Interfaces and System, all the RM defined packages are
20972 available in GNAT, see the Ada 2012 RM for full details.
20973
20974 @node The Implementation of Standard I/O,The GNAT Library,Standard Library Routines,Top
20975 @anchor{gnat_rm/the_implementation_of_standard_i_o the-implementation-of-standard-i-o}@anchor{f}@anchor{gnat_rm/the_implementation_of_standard_i_o doc}@anchor{29d}@anchor{gnat_rm/the_implementation_of_standard_i_o id1}@anchor{29e}
20976 @chapter The Implementation of Standard I/O
20977
20978
20979 GNAT implements all the required input-output facilities described in
20980 A.6 through A.14. These sections of the Ada Reference Manual describe the
20981 required behavior of these packages from the Ada point of view, and if
20982 you are writing a portable Ada program that does not need to know the
20983 exact manner in which Ada maps to the outside world when it comes to
20984 reading or writing external files, then you do not need to read this
20985 chapter. As long as your files are all regular files (not pipes or
20986 devices), and as long as you write and read the files only from Ada, the
20987 description in the Ada Reference Manual is sufficient.
20988
20989 However, if you want to do input-output to pipes or other devices, such
20990 as the keyboard or screen, or if the files you are dealing with are
20991 either generated by some other language, or to be read by some other
20992 language, then you need to know more about the details of how the GNAT
20993 implementation of these input-output facilities behaves.
20994
20995 In this chapter we give a detailed description of exactly how GNAT
20996 interfaces to the file system. As always, the sources of the system are
20997 available to you for answering questions at an even more detailed level,
20998 but for most purposes the information in this chapter will suffice.
20999
21000 Another reason that you may need to know more about how input-output is
21001 implemented arises when you have a program written in mixed languages
21002 where, for example, files are shared between the C and Ada sections of
21003 the same program. GNAT provides some additional facilities, in the form
21004 of additional child library packages, that facilitate this sharing, and
21005 these additional facilities are also described in this chapter.
21006
21007 @menu
21008 * Standard I/O Packages::
21009 * FORM Strings::
21010 * Direct_IO::
21011 * Sequential_IO::
21012 * Text_IO::
21013 * Wide_Text_IO::
21014 * Wide_Wide_Text_IO::
21015 * Stream_IO::
21016 * Text Translation::
21017 * Shared Files::
21018 * Filenames encoding::
21019 * File content encoding::
21020 * Open Modes::
21021 * Operations on C Streams::
21022 * Interfacing to C Streams::
21023
21024 @end menu
21025
21026 @node Standard I/O Packages,FORM Strings,,The Implementation of Standard I/O
21027 @anchor{gnat_rm/the_implementation_of_standard_i_o standard-i-o-packages}@anchor{29f}@anchor{gnat_rm/the_implementation_of_standard_i_o id2}@anchor{2a0}
21028 @section Standard I/O Packages
21029
21030
21031 The Standard I/O packages described in Annex A for
21032
21033
21034 @itemize *
21035
21036 @item
21037 Ada.Text_IO
21038
21039 @item
21040 Ada.Text_IO.Complex_IO
21041
21042 @item
21043 Ada.Text_IO.Text_Streams
21044
21045 @item
21046 Ada.Wide_Text_IO
21047
21048 @item
21049 Ada.Wide_Text_IO.Complex_IO
21050
21051 @item
21052 Ada.Wide_Text_IO.Text_Streams
21053
21054 @item
21055 Ada.Wide_Wide_Text_IO
21056
21057 @item
21058 Ada.Wide_Wide_Text_IO.Complex_IO
21059
21060 @item
21061 Ada.Wide_Wide_Text_IO.Text_Streams
21062
21063 @item
21064 Ada.Stream_IO
21065
21066 @item
21067 Ada.Sequential_IO
21068
21069 @item
21070 Ada.Direct_IO
21071 @end itemize
21072
21073 are implemented using the C
21074 library streams facility; where
21075
21076
21077 @itemize *
21078
21079 @item
21080 All files are opened using @code{fopen}.
21081
21082 @item
21083 All input/output operations use @code{fread}/@cite{fwrite}.
21084 @end itemize
21085
21086 There is no internal buffering of any kind at the Ada library level. The only
21087 buffering is that provided at the system level in the implementation of the
21088 library routines that support streams. This facilitates shared use of these
21089 streams by mixed language programs. Note though that system level buffering is
21090 explicitly enabled at elaboration of the standard I/O packages and that can
21091 have an impact on mixed language programs, in particular those using I/O before
21092 calling the Ada elaboration routine (e.g., adainit). It is recommended to call
21093 the Ada elaboration routine before performing any I/O or when impractical,
21094 flush the common I/O streams and in particular Standard_Output before
21095 elaborating the Ada code.
21096
21097 @node FORM Strings,Direct_IO,Standard I/O Packages,The Implementation of Standard I/O
21098 @anchor{gnat_rm/the_implementation_of_standard_i_o form-strings}@anchor{2a1}@anchor{gnat_rm/the_implementation_of_standard_i_o id3}@anchor{2a2}
21099 @section FORM Strings
21100
21101
21102 The format of a FORM string in GNAT is:
21103
21104 @example
21105 "keyword=value,keyword=value,...,keyword=value"
21106 @end example
21107
21108 where letters may be in upper or lower case, and there are no spaces
21109 between values. The order of the entries is not important. Currently
21110 the following keywords defined.
21111
21112 @example
21113 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
21114 SHARED=[YES|NO]
21115 WCEM=[n|h|u|s|e|8|b]
21116 ENCODING=[UTF8|8BITS]
21117 @end example
21118
21119 The use of these parameters is described later in this section. If an
21120 unrecognized keyword appears in a form string, it is silently ignored
21121 and not considered invalid.
21122
21123 @node Direct_IO,Sequential_IO,FORM Strings,The Implementation of Standard I/O
21124 @anchor{gnat_rm/the_implementation_of_standard_i_o direct-io}@anchor{2a3}@anchor{gnat_rm/the_implementation_of_standard_i_o id4}@anchor{2a4}
21125 @section Direct_IO
21126
21127
21128 Direct_IO can only be instantiated for definite types. This is a
21129 restriction of the Ada language, which means that the records are fixed
21130 length (the length being determined by @code{type'Size}, rounded
21131 up to the next storage unit boundary if necessary).
21132
21133 The records of a Direct_IO file are simply written to the file in index
21134 sequence, with the first record starting at offset zero, and subsequent
21135 records following. There is no control information of any kind. For
21136 example, if 32-bit integers are being written, each record takes
21137 4-bytes, so the record at index @code{K} starts at offset
21138 (@code{K}-1)*4.
21139
21140 There is no limit on the size of Direct_IO files, they are expanded as
21141 necessary to accommodate whatever records are written to the file.
21142
21143 @node Sequential_IO,Text_IO,Direct_IO,The Implementation of Standard I/O
21144 @anchor{gnat_rm/the_implementation_of_standard_i_o sequential-io}@anchor{2a5}@anchor{gnat_rm/the_implementation_of_standard_i_o id5}@anchor{2a6}
21145 @section Sequential_IO
21146
21147
21148 Sequential_IO may be instantiated with either a definite (constrained)
21149 or indefinite (unconstrained) type.
21150
21151 For the definite type case, the elements written to the file are simply
21152 the memory images of the data values with no control information of any
21153 kind. The resulting file should be read using the same type, no validity
21154 checking is performed on input.
21155
21156 For the indefinite type case, the elements written consist of two
21157 parts. First is the size of the data item, written as the memory image
21158 of a @code{Interfaces.C.size_t} value, followed by the memory image of
21159 the data value. The resulting file can only be read using the same
21160 (unconstrained) type. Normal assignment checks are performed on these
21161 read operations, and if these checks fail, @code{Data_Error} is
21162 raised. In particular, in the array case, the lengths must match, and in
21163 the variant record case, if the variable for a particular read operation
21164 is constrained, the discriminants must match.
21165
21166 Note that it is not possible to use Sequential_IO to write variable
21167 length array items, and then read the data back into different length
21168 arrays. For example, the following will raise @code{Data_Error}:
21169
21170 @example
21171 package IO is new Sequential_IO (String);
21172 F : IO.File_Type;
21173 S : String (1..4);
21174 ...
21175 IO.Create (F)
21176 IO.Write (F, "hello!")
21177 IO.Reset (F, Mode=>In_File);
21178 IO.Read (F, S);
21179 Put_Line (S);
21180 @end example
21181
21182 On some Ada implementations, this will print @code{hell}, but the program is
21183 clearly incorrect, since there is only one element in the file, and that
21184 element is the string @code{hello!}.
21185
21186 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
21187 using Stream_IO, and this is the preferred mechanism. In particular, the
21188 above program fragment rewritten to use Stream_IO will work correctly.
21189
21190 @node Text_IO,Wide_Text_IO,Sequential_IO,The Implementation of Standard I/O
21191 @anchor{gnat_rm/the_implementation_of_standard_i_o id6}@anchor{2a7}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io}@anchor{2a8}
21192 @section Text_IO
21193
21194
21195 Text_IO files consist of a stream of characters containing the following
21196 special control characters:
21197
21198 @example
21199 LF (line feed, 16#0A#) Line Mark
21200 FF (form feed, 16#0C#) Page Mark
21201 @end example
21202
21203 A canonical Text_IO file is defined as one in which the following
21204 conditions are met:
21205
21206
21207 @itemize *
21208
21209 @item
21210 The character @code{LF} is used only as a line mark, i.e., to mark the end
21211 of the line.
21212
21213 @item
21214 The character @code{FF} is used only as a page mark, i.e., to mark the
21215 end of a page and consequently can appear only immediately following a
21216 @code{LF} (line mark) character.
21217
21218 @item
21219 The file ends with either @code{LF} (line mark) or @code{LF}-@cite{FF}
21220 (line mark, page mark). In the former case, the page mark is implicitly
21221 assumed to be present.
21222 @end itemize
21223
21224 A file written using Text_IO will be in canonical form provided that no
21225 explicit @code{LF} or @code{FF} characters are written using @code{Put}
21226 or @code{Put_Line}. There will be no @code{FF} character at the end of
21227 the file unless an explicit @code{New_Page} operation was performed
21228 before closing the file.
21229
21230 A canonical Text_IO file that is a regular file (i.e., not a device or a
21231 pipe) can be read using any of the routines in Text_IO. The
21232 semantics in this case will be exactly as defined in the Ada Reference
21233 Manual, and all the routines in Text_IO are fully implemented.
21234
21235 A text file that does not meet the requirements for a canonical Text_IO
21236 file has one of the following:
21237
21238
21239 @itemize *
21240
21241 @item
21242 The file contains @code{FF} characters not immediately following a
21243 @code{LF} character.
21244
21245 @item
21246 The file contains @code{LF} or @code{FF} characters written by
21247 @code{Put} or @code{Put_Line}, which are not logically considered to be
21248 line marks or page marks.
21249
21250 @item
21251 The file ends in a character other than @code{LF} or @code{FF},
21252 i.e., there is no explicit line mark or page mark at the end of the file.
21253 @end itemize
21254
21255 Text_IO can be used to read such non-standard text files but subprograms
21256 to do with line or page numbers do not have defined meanings. In
21257 particular, a @code{FF} character that does not follow a @code{LF}
21258 character may or may not be treated as a page mark from the point of
21259 view of page and line numbering. Every @code{LF} character is considered
21260 to end a line, and there is an implied @code{LF} character at the end of
21261 the file.
21262
21263 @menu
21264 * Stream Pointer Positioning::
21265 * Reading and Writing Non-Regular Files::
21266 * Get_Immediate::
21267 * Treating Text_IO Files as Streams::
21268 * Text_IO Extensions::
21269 * Text_IO Facilities for Unbounded Strings::
21270
21271 @end menu
21272
21273 @node Stream Pointer Positioning,Reading and Writing Non-Regular Files,,Text_IO
21274 @anchor{gnat_rm/the_implementation_of_standard_i_o id7}@anchor{2a9}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning}@anchor{2aa}
21275 @subsection Stream Pointer Positioning
21276
21277
21278 @code{Ada.Text_IO} has a definition of current position for a file that
21279 is being read. No internal buffering occurs in Text_IO, and usually the
21280 physical position in the stream used to implement the file corresponds
21281 to this logical position defined by Text_IO. There are two exceptions:
21282
21283
21284 @itemize *
21285
21286 @item
21287 After a call to @code{End_Of_Page} that returns @code{True}, the stream
21288 is positioned past the @code{LF} (line mark) that precedes the page
21289 mark. Text_IO maintains an internal flag so that subsequent read
21290 operations properly handle the logical position which is unchanged by
21291 the @code{End_Of_Page} call.
21292
21293 @item
21294 After a call to @code{End_Of_File} that returns @code{True}, if the
21295 Text_IO file was positioned before the line mark at the end of file
21296 before the call, then the logical position is unchanged, but the stream
21297 is physically positioned right at the end of file (past the line mark,
21298 and past a possible page mark following the line mark. Again Text_IO
21299 maintains internal flags so that subsequent read operations properly
21300 handle the logical position.
21301 @end itemize
21302
21303 These discrepancies have no effect on the observable behavior of
21304 Text_IO, but if a single Ada stream is shared between a C program and
21305 Ada program, or shared (using @code{shared=yes} in the form string)
21306 between two Ada files, then the difference may be observable in some
21307 situations.
21308
21309 @node Reading and Writing Non-Regular Files,Get_Immediate,Stream Pointer Positioning,Text_IO
21310 @anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files}@anchor{2ab}@anchor{gnat_rm/the_implementation_of_standard_i_o id8}@anchor{2ac}
21311 @subsection Reading and Writing Non-Regular Files
21312
21313
21314 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
21315 can be used for reading and writing. Writing is not affected and the
21316 sequence of characters output is identical to the normal file case, but
21317 for reading, the behavior of Text_IO is modified to avoid undesirable
21318 look-ahead as follows:
21319
21320 An input file that is not a regular file is considered to have no page
21321 marks. Any @code{Ascii.FF} characters (the character normally used for a
21322 page mark) appearing in the file are considered to be data
21323 characters. In particular:
21324
21325
21326 @itemize *
21327
21328 @item
21329 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
21330 following a line mark. If a page mark appears, it will be treated as a
21331 data character.
21332
21333 @item
21334 This avoids the need to wait for an extra character to be typed or
21335 entered from the pipe to complete one of these operations.
21336
21337 @item
21338 @code{End_Of_Page} always returns @code{False}
21339
21340 @item
21341 @code{End_Of_File} will return @code{False} if there is a page mark at
21342 the end of the file.
21343 @end itemize
21344
21345 Output to non-regular files is the same as for regular files. Page marks
21346 may be written to non-regular files using @code{New_Page}, but as noted
21347 above they will not be treated as page marks on input if the output is
21348 piped to another Ada program.
21349
21350 Another important discrepancy when reading non-regular files is that the end
21351 of file indication is not 'sticky'. If an end of file is entered, e.g., by
21352 pressing the @code{EOT} key,
21353 then end of file
21354 is signaled once (i.e., the test @code{End_Of_File}
21355 will yield @code{True}, or a read will
21356 raise @code{End_Error}), but then reading can resume
21357 to read data past that end of
21358 file indication, until another end of file indication is entered.
21359
21360 @node Get_Immediate,Treating Text_IO Files as Streams,Reading and Writing Non-Regular Files,Text_IO
21361 @anchor{gnat_rm/the_implementation_of_standard_i_o get-immediate}@anchor{2ad}@anchor{gnat_rm/the_implementation_of_standard_i_o id9}@anchor{2ae}
21362 @subsection Get_Immediate
21363
21364
21365 @geindex Get_Immediate
21366
21367 Get_Immediate returns the next character (including control characters)
21368 from the input file. In particular, Get_Immediate will return LF or FF
21369 characters used as line marks or page marks. Such operations leave the
21370 file positioned past the control character, and it is thus not treated
21371 as having its normal function. This means that page, line and column
21372 counts after this kind of Get_Immediate call are set as though the mark
21373 did not occur. In the case where a Get_Immediate leaves the file
21374 positioned between the line mark and page mark (which is not normally
21375 possible), it is undefined whether the FF character will be treated as a
21376 page mark.
21377
21378 @node Treating Text_IO Files as Streams,Text_IO Extensions,Get_Immediate,Text_IO
21379 @anchor{gnat_rm/the_implementation_of_standard_i_o id10}@anchor{2af}@anchor{gnat_rm/the_implementation_of_standard_i_o treating-text-io-files-as-streams}@anchor{2b0}
21380 @subsection Treating Text_IO Files as Streams
21381
21382
21383 @geindex Stream files
21384
21385 The package @code{Text_IO.Streams} allows a @code{Text_IO} file to be treated
21386 as a stream. Data written to a @code{Text_IO} file in this stream mode is
21387 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
21388 16#0C# (@code{FF}), the resulting file may have non-standard
21389 format. Similarly if read operations are used to read from a Text_IO
21390 file treated as a stream, then @code{LF} and @code{FF} characters may be
21391 skipped and the effect is similar to that described above for
21392 @code{Get_Immediate}.
21393
21394 @node Text_IO Extensions,Text_IO Facilities for Unbounded Strings,Treating Text_IO Files as Streams,Text_IO
21395 @anchor{gnat_rm/the_implementation_of_standard_i_o id11}@anchor{2b1}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-extensions}@anchor{2b2}
21396 @subsection Text_IO Extensions
21397
21398
21399 @geindex Text_IO extensions
21400
21401 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
21402 to the standard @code{Text_IO} package:
21403
21404
21405 @itemize *
21406
21407 @item
21408 function File_Exists (Name : String) return Boolean;
21409 Determines if a file of the given name exists.
21410
21411 @item
21412 function Get_Line return String;
21413 Reads a string from the standard input file. The value returned is exactly
21414 the length of the line that was read.
21415
21416 @item
21417 function Get_Line (File : Ada.Text_IO.File_Type) return String;
21418 Similar, except that the parameter File specifies the file from which
21419 the string is to be read.
21420 @end itemize
21421
21422 @node Text_IO Facilities for Unbounded Strings,,Text_IO Extensions,Text_IO
21423 @anchor{gnat_rm/the_implementation_of_standard_i_o text-io-facilities-for-unbounded-strings}@anchor{2b3}@anchor{gnat_rm/the_implementation_of_standard_i_o id12}@anchor{2b4}
21424 @subsection Text_IO Facilities for Unbounded Strings
21425
21426
21427 @geindex Text_IO for unbounded strings
21428
21429 @geindex Unbounded_String
21430 @geindex Text_IO operations
21431
21432 The package @code{Ada.Strings.Unbounded.Text_IO}
21433 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
21434 subprograms useful for Text_IO operations on unbounded strings:
21435
21436
21437 @itemize *
21438
21439 @item
21440 function Get_Line (File : File_Type) return Unbounded_String;
21441 Reads a line from the specified file
21442 and returns the result as an unbounded string.
21443
21444 @item
21445 procedure Put (File : File_Type; U : Unbounded_String);
21446 Writes the value of the given unbounded string to the specified file
21447 Similar to the effect of
21448 @code{Put (To_String (U))} except that an extra copy is avoided.
21449
21450 @item
21451 procedure Put_Line (File : File_Type; U : Unbounded_String);
21452 Writes the value of the given unbounded string to the specified file,
21453 followed by a @code{New_Line}.
21454 Similar to the effect of @code{Put_Line (To_String (U))} except
21455 that an extra copy is avoided.
21456 @end itemize
21457
21458 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
21459 and is optional. If the parameter is omitted, then the standard input or
21460 output file is referenced as appropriate.
21461
21462 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
21463 files @code{a-swuwti.ads} and @code{a-swuwti.adb} provides similar extended
21464 @code{Wide_Text_IO} functionality for unbounded wide strings.
21465
21466 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
21467 files @code{a-szuzti.ads} and @code{a-szuzti.adb} provides similar extended
21468 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
21469
21470 @node Wide_Text_IO,Wide_Wide_Text_IO,Text_IO,The Implementation of Standard I/O
21471 @anchor{gnat_rm/the_implementation_of_standard_i_o wide-text-io}@anchor{2b5}@anchor{gnat_rm/the_implementation_of_standard_i_o id13}@anchor{2b6}
21472 @section Wide_Text_IO
21473
21474
21475 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
21476 both input and output files may contain special sequences that represent
21477 wide character values. The encoding scheme for a given file may be
21478 specified using a FORM parameter:
21479
21480 @example
21481 WCEM=`x`
21482 @end example
21483
21484 as part of the FORM string (WCEM = wide character encoding method),
21485 where @code{x} is one of the following characters
21486
21487
21488 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
21489 @headitem
21490
21491 Character
21492
21493 @tab
21494
21495 Encoding
21496
21497 @item
21498
21499 @emph{h}
21500
21501 @tab
21502
21503 Hex ESC encoding
21504
21505 @item
21506
21507 @emph{u}
21508
21509 @tab
21510
21511 Upper half encoding
21512
21513 @item
21514
21515 @emph{s}
21516
21517 @tab
21518
21519 Shift-JIS encoding
21520
21521 @item
21522
21523 @emph{e}
21524
21525 @tab
21526
21527 EUC Encoding
21528
21529 @item
21530
21531 @emph{8}
21532
21533 @tab
21534
21535 UTF-8 encoding
21536
21537 @item
21538
21539 @emph{b}
21540
21541 @tab
21542
21543 Brackets encoding
21544
21545 @end multitable
21546
21547
21548 The encoding methods match those that
21549 can be used in a source
21550 program, but there is no requirement that the encoding method used for
21551 the source program be the same as the encoding method used for files,
21552 and different files may use different encoding methods.
21553
21554 The default encoding method for the standard files, and for opened files
21555 for which no WCEM parameter is given in the FORM string matches the
21556 wide character encoding specified for the main program (the default
21557 being brackets encoding if no coding method was specified with -gnatW).
21558
21559
21560 @table @asis
21561
21562 @item @emph{Hex Coding}
21563
21564 In this encoding, a wide character is represented by a five character
21565 sequence:
21566 @end table
21567
21568 @example
21569 ESC a b c d
21570 @end example
21571
21572
21573 @quotation
21574
21575 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
21576 characters (using upper case letters) of the wide character code. For
21577 example, ESC A345 is used to represent the wide character with code
21578 16#A345#. This scheme is compatible with use of the full
21579 @code{Wide_Character} set.
21580 @end quotation
21581
21582
21583 @table @asis
21584
21585 @item @emph{Upper Half Coding}
21586
21587 The wide character with encoding 16#abcd#, where the upper bit is on
21588 (i.e., a is in the range 8-F) is represented as two bytes 16#ab# and
21589 16#cd#. The second byte may never be a format control character, but is
21590 not required to be in the upper half. This method can be also used for
21591 shift-JIS or EUC where the internal coding matches the external coding.
21592
21593 @item @emph{Shift JIS Coding}
21594
21595 A wide character is represented by a two character sequence 16#ab# and
21596 16#cd#, with the restrictions described for upper half encoding as
21597 described above. The internal character code is the corresponding JIS
21598 character according to the standard algorithm for Shift-JIS
21599 conversion. Only characters defined in the JIS code set table can be
21600 used with this encoding method.
21601
21602 @item @emph{EUC Coding}
21603
21604 A wide character is represented by a two character sequence 16#ab# and
21605 16#cd#, with both characters being in the upper half. The internal
21606 character code is the corresponding JIS character according to the EUC
21607 encoding algorithm. Only characters defined in the JIS code set table
21608 can be used with this encoding method.
21609
21610 @item @emph{UTF-8 Coding}
21611
21612 A wide character is represented using
21613 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
21614 10646-1/Am.2. Depending on the character value, the representation
21615 is a one, two, or three byte sequence:
21616 @end table
21617
21618 @example
21619 16#0000#-16#007f#: 2#0xxxxxxx#
21620 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
21621 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
21622 @end example
21623
21624
21625 @quotation
21626
21627 where the @code{xxx} bits correspond to the left-padded bits of the
21628 16-bit character value. Note that all lower half ASCII characters
21629 are represented as ASCII bytes and all upper half characters and
21630 other wide characters are represented as sequences of upper-half
21631 (The full UTF-8 scheme allows for encoding 31-bit characters as
21632 6-byte sequences, but in this implementation, all UTF-8 sequences
21633 of four or more bytes length will raise a Constraint_Error, as
21634 will all invalid UTF-8 sequences.)
21635 @end quotation
21636
21637
21638 @table @asis
21639
21640 @item @emph{Brackets Coding}
21641
21642 In this encoding, a wide character is represented by the following eight
21643 character sequence:
21644 @end table
21645
21646 @example
21647 [ " a b c d " ]
21648 @end example
21649
21650
21651 @quotation
21652
21653 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
21654 characters (using uppercase letters) of the wide character code. For
21655 example, @code{["A345"]} is used to represent the wide character with code
21656 @code{16#A345#}.
21657 This scheme is compatible with use of the full Wide_Character set.
21658 On input, brackets coding can also be used for upper half characters,
21659 e.g., @code{["C1"]} for lower case a. However, on output, brackets notation
21660 is only used for wide characters with a code greater than @code{16#FF#}.
21661
21662 Note that brackets coding is not normally used in the context of
21663 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
21664 a portable way of encoding source files. In the context of Wide_Text_IO
21665 or Wide_Wide_Text_IO, it can only be used if the file does not contain
21666 any instance of the left bracket character other than to encode wide
21667 character values using the brackets encoding method. In practice it is
21668 expected that some standard wide character encoding method such
21669 as UTF-8 will be used for text input output.
21670
21671 If brackets notation is used, then any occurrence of a left bracket
21672 in the input file which is not the start of a valid wide character
21673 sequence will cause Constraint_Error to be raised. It is possible to
21674 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
21675 input will interpret this as a left bracket.
21676
21677 However, when a left bracket is output, it will be output as a left bracket
21678 and not as ["5B"]. We make this decision because for normal use of
21679 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
21680 brackets. For example, if we write:
21681
21682 @example
21683 Put_Line ("Start of output [first run]");
21684 @end example
21685
21686 we really do not want to have the left bracket in this message clobbered so
21687 that the output reads:
21688 @end quotation
21689
21690 @example
21691 Start of output ["5B"]first run]
21692 @end example
21693
21694
21695 @quotation
21696
21697 In practice brackets encoding is reasonably useful for normal Put_Line use
21698 since we won't get confused between left brackets and wide character
21699 sequences in the output. But for input, or when files are written out
21700 and read back in, it really makes better sense to use one of the standard
21701 encoding methods such as UTF-8.
21702 @end quotation
21703
21704 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
21705 not all wide character
21706 values can be represented. An attempt to output a character that cannot
21707 be represented using the encoding scheme for the file causes
21708 Constraint_Error to be raised. An invalid wide character sequence on
21709 input also causes Constraint_Error to be raised.
21710
21711 @menu
21712 * Stream Pointer Positioning: Stream Pointer Positioning<2>.
21713 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>.
21714
21715 @end menu
21716
21717 @node Stream Pointer Positioning<2>,Reading and Writing Non-Regular Files<2>,,Wide_Text_IO
21718 @anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-1}@anchor{2b7}@anchor{gnat_rm/the_implementation_of_standard_i_o id14}@anchor{2b8}
21719 @subsection Stream Pointer Positioning
21720
21721
21722 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
21723 of stream pointer positioning (@ref{2a8,,Text_IO}). There is one additional
21724 case:
21725
21726 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
21727 normal lower ASCII set (i.e., a character in the range:
21728
21729 @example
21730 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
21731 @end example
21732
21733 then although the logical position of the file pointer is unchanged by
21734 the @code{Look_Ahead} call, the stream is physically positioned past the
21735 wide character sequence. Again this is to avoid the need for buffering
21736 or backup, and all @code{Wide_Text_IO} routines check the internal
21737 indication that this situation has occurred so that this is not visible
21738 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
21739 can be observed if the wide text file shares a stream with another file.
21740
21741 @node Reading and Writing Non-Regular Files<2>,,Stream Pointer Positioning<2>,Wide_Text_IO
21742 @anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-1}@anchor{2b9}@anchor{gnat_rm/the_implementation_of_standard_i_o id15}@anchor{2ba}
21743 @subsection Reading and Writing Non-Regular Files
21744
21745
21746 As in the case of Text_IO, when a non-regular file is read, it is
21747 assumed that the file contains no page marks (any form characters are
21748 treated as data characters), and @code{End_Of_Page} always returns
21749 @code{False}. Similarly, the end of file indication is not sticky, so
21750 it is possible to read beyond an end of file.
21751
21752 @node Wide_Wide_Text_IO,Stream_IO,Wide_Text_IO,The Implementation of Standard I/O
21753 @anchor{gnat_rm/the_implementation_of_standard_i_o id16}@anchor{2bb}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-wide-text-io}@anchor{2bc}
21754 @section Wide_Wide_Text_IO
21755
21756
21757 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
21758 both input and output files may contain special sequences that represent
21759 wide wide character values. The encoding scheme for a given file may be
21760 specified using a FORM parameter:
21761
21762 @example
21763 WCEM=`x`
21764 @end example
21765
21766 as part of the FORM string (WCEM = wide character encoding method),
21767 where @code{x} is one of the following characters
21768
21769
21770 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
21771 @headitem
21772
21773 Character
21774
21775 @tab
21776
21777 Encoding
21778
21779 @item
21780
21781 @emph{h}
21782
21783 @tab
21784
21785 Hex ESC encoding
21786
21787 @item
21788
21789 @emph{u}
21790
21791 @tab
21792
21793 Upper half encoding
21794
21795 @item
21796
21797 @emph{s}
21798
21799 @tab
21800
21801 Shift-JIS encoding
21802
21803 @item
21804
21805 @emph{e}
21806
21807 @tab
21808
21809 EUC Encoding
21810
21811 @item
21812
21813 @emph{8}
21814
21815 @tab
21816
21817 UTF-8 encoding
21818
21819 @item
21820
21821 @emph{b}
21822
21823 @tab
21824
21825 Brackets encoding
21826
21827 @end multitable
21828
21829
21830 The encoding methods match those that
21831 can be used in a source
21832 program, but there is no requirement that the encoding method used for
21833 the source program be the same as the encoding method used for files,
21834 and different files may use different encoding methods.
21835
21836 The default encoding method for the standard files, and for opened files
21837 for which no WCEM parameter is given in the FORM string matches the
21838 wide character encoding specified for the main program (the default
21839 being brackets encoding if no coding method was specified with -gnatW).
21840
21841
21842 @table @asis
21843
21844 @item @emph{UTF-8 Coding}
21845
21846 A wide character is represented using
21847 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
21848 10646-1/Am.2. Depending on the character value, the representation
21849 is a one, two, three, or four byte sequence:
21850 @end table
21851
21852 @example
21853 16#000000#-16#00007f#: 2#0xxxxxxx#
21854 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
21855 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
21856 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
21857 @end example
21858
21859
21860 @quotation
21861
21862 where the @code{xxx} bits correspond to the left-padded bits of the
21863 21-bit character value. Note that all lower half ASCII characters
21864 are represented as ASCII bytes and all upper half characters and
21865 other wide characters are represented as sequences of upper-half
21866 characters.
21867 @end quotation
21868
21869
21870 @table @asis
21871
21872 @item @emph{Brackets Coding}
21873
21874 In this encoding, a wide wide character is represented by the following eight
21875 character sequence if is in wide character range
21876 @end table
21877
21878 @example
21879 [ " a b c d " ]
21880 @end example
21881
21882
21883 @quotation
21884
21885 and by the following ten character sequence if not
21886 @end quotation
21887
21888 @example
21889 [ " a b c d e f " ]
21890 @end example
21891
21892
21893 @quotation
21894
21895 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
21896 are the four or six hexadecimal
21897 characters (using uppercase letters) of the wide wide character code. For
21898 example, @code{["01A345"]} is used to represent the wide wide character
21899 with code @code{16#01A345#}.
21900
21901 This scheme is compatible with use of the full Wide_Wide_Character set.
21902 On input, brackets coding can also be used for upper half characters,
21903 e.g., @code{["C1"]} for lower case a. However, on output, brackets notation
21904 is only used for wide characters with a code greater than @code{16#FF#}.
21905 @end quotation
21906
21907 If is also possible to use the other Wide_Character encoding methods,
21908 such as Shift-JIS, but the other schemes cannot support the full range
21909 of wide wide characters.
21910 An attempt to output a character that cannot
21911 be represented using the encoding scheme for the file causes
21912 Constraint_Error to be raised. An invalid wide character sequence on
21913 input also causes Constraint_Error to be raised.
21914
21915 @menu
21916 * Stream Pointer Positioning: Stream Pointer Positioning<3>.
21917 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>.
21918
21919 @end menu
21920
21921 @node Stream Pointer Positioning<3>,Reading and Writing Non-Regular Files<3>,,Wide_Wide_Text_IO
21922 @anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-2}@anchor{2bd}@anchor{gnat_rm/the_implementation_of_standard_i_o id17}@anchor{2be}
21923 @subsection Stream Pointer Positioning
21924
21925
21926 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
21927 of stream pointer positioning (@ref{2a8,,Text_IO}). There is one additional
21928 case:
21929
21930 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
21931 normal lower ASCII set (i.e., a character in the range:
21932
21933 @example
21934 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
21935 @end example
21936
21937 then although the logical position of the file pointer is unchanged by
21938 the @code{Look_Ahead} call, the stream is physically positioned past the
21939 wide character sequence. Again this is to avoid the need for buffering
21940 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
21941 indication that this situation has occurred so that this is not visible
21942 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
21943 can be observed if the wide text file shares a stream with another file.
21944
21945 @node Reading and Writing Non-Regular Files<3>,,Stream Pointer Positioning<3>,Wide_Wide_Text_IO
21946 @anchor{gnat_rm/the_implementation_of_standard_i_o id18}@anchor{2bf}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-2}@anchor{2c0}
21947 @subsection Reading and Writing Non-Regular Files
21948
21949
21950 As in the case of Text_IO, when a non-regular file is read, it is
21951 assumed that the file contains no page marks (any form characters are
21952 treated as data characters), and @code{End_Of_Page} always returns
21953 @code{False}. Similarly, the end of file indication is not sticky, so
21954 it is possible to read beyond an end of file.
21955
21956 @node Stream_IO,Text Translation,Wide_Wide_Text_IO,The Implementation of Standard I/O
21957 @anchor{gnat_rm/the_implementation_of_standard_i_o id19}@anchor{2c1}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-io}@anchor{2c2}
21958 @section Stream_IO
21959
21960
21961 A stream file is a sequence of bytes, where individual elements are
21962 written to the file as described in the Ada Reference Manual. The type
21963 @code{Stream_Element} is simply a byte. There are two ways to read or
21964 write a stream file.
21965
21966
21967 @itemize *
21968
21969 @item
21970 The operations @code{Read} and @code{Write} directly read or write a
21971 sequence of stream elements with no control information.
21972
21973 @item
21974 The stream attributes applied to a stream file transfer data in the
21975 manner described for stream attributes.
21976 @end itemize
21977
21978 @node Text Translation,Shared Files,Stream_IO,The Implementation of Standard I/O
21979 @anchor{gnat_rm/the_implementation_of_standard_i_o id20}@anchor{2c3}@anchor{gnat_rm/the_implementation_of_standard_i_o text-translation}@anchor{2c4}
21980 @section Text Translation
21981
21982
21983 @code{Text_Translation=xxx} may be used as the Form parameter
21984 passed to Text_IO.Create and Text_IO.Open. @code{Text_Translation=xxx}
21985 has no effect on Unix systems. Possible values are:
21986
21987
21988 @itemize *
21989
21990 @item
21991 @code{Yes} or @code{Text} is the default, which means to
21992 translate LF to/from CR/LF on Windows systems.
21993
21994 @code{No} disables this translation; i.e. it
21995 uses binary mode. For output files, @code{Text_Translation=No}
21996 may be used to create Unix-style files on
21997 Windows.
21998
21999 @item
22000 @code{wtext} translation enabled in Unicode mode.
22001 (corresponds to _O_WTEXT).
22002
22003 @item
22004 @code{u8text} translation enabled in Unicode UTF-8 mode.
22005 (corresponds to O_U8TEXT).
22006
22007 @item
22008 @code{u16text} translation enabled in Unicode UTF-16
22009 mode. (corresponds to_O_U16TEXT).
22010 @end itemize
22011
22012 @node Shared Files,Filenames encoding,Text Translation,The Implementation of Standard I/O
22013 @anchor{gnat_rm/the_implementation_of_standard_i_o id21}@anchor{2c5}@anchor{gnat_rm/the_implementation_of_standard_i_o shared-files}@anchor{2c6}
22014 @section Shared Files
22015
22016
22017 Section A.14 of the Ada Reference Manual allows implementations to
22018 provide a wide variety of behavior if an attempt is made to access the
22019 same external file with two or more internal files.
22020
22021 To provide a full range of functionality, while at the same time
22022 minimizing the problems of portability caused by this implementation
22023 dependence, GNAT handles file sharing as follows:
22024
22025
22026 @itemize *
22027
22028 @item
22029 In the absence of a @code{shared=xxx} form parameter, an attempt
22030 to open two or more files with the same full name is considered an error
22031 and is not supported. The exception @code{Use_Error} will be
22032 raised. Note that a file that is not explicitly closed by the program
22033 remains open until the program terminates.
22034
22035 @item
22036 If the form parameter @code{shared=no} appears in the form string, the
22037 file can be opened or created with its own separate stream identifier,
22038 regardless of whether other files sharing the same external file are
22039 opened. The exact effect depends on how the C stream routines handle
22040 multiple accesses to the same external files using separate streams.
22041
22042 @item
22043 If the form parameter @code{shared=yes} appears in the form string for
22044 each of two or more files opened using the same full name, the same
22045 stream is shared between these files, and the semantics are as described
22046 in Ada Reference Manual, Section A.14.
22047 @end itemize
22048
22049 When a program that opens multiple files with the same name is ported
22050 from another Ada compiler to GNAT, the effect will be that
22051 @code{Use_Error} is raised.
22052
22053 The documentation of the original compiler and the documentation of the
22054 program should then be examined to determine if file sharing was
22055 expected, and @code{shared=xxx} parameters added to @code{Open}
22056 and @code{Create} calls as required.
22057
22058 When a program is ported from GNAT to some other Ada compiler, no
22059 special attention is required unless the @code{shared=xxx} form
22060 parameter is used in the program. In this case, you must examine the
22061 documentation of the new compiler to see if it supports the required
22062 file sharing semantics, and form strings modified appropriately. Of
22063 course it may be the case that the program cannot be ported if the
22064 target compiler does not support the required functionality. The best
22065 approach in writing portable code is to avoid file sharing (and hence
22066 the use of the @code{shared=xxx} parameter in the form string)
22067 completely.
22068
22069 One common use of file sharing in Ada 83 is the use of instantiations of
22070 Sequential_IO on the same file with different types, to achieve
22071 heterogeneous input-output. Although this approach will work in GNAT if
22072 @code{shared=yes} is specified, it is preferable in Ada to use Stream_IO
22073 for this purpose (using the stream attributes)
22074
22075 @node Filenames encoding,File content encoding,Shared Files,The Implementation of Standard I/O
22076 @anchor{gnat_rm/the_implementation_of_standard_i_o filenames-encoding}@anchor{2c7}@anchor{gnat_rm/the_implementation_of_standard_i_o id22}@anchor{2c8}
22077 @section Filenames encoding
22078
22079
22080 An encoding form parameter can be used to specify the filename
22081 encoding @code{encoding=xxx}.
22082
22083
22084 @itemize *
22085
22086 @item
22087 If the form parameter @code{encoding=utf8} appears in the form string, the
22088 filename must be encoded in UTF-8.
22089
22090 @item
22091 If the form parameter @code{encoding=8bits} appears in the form
22092 string, the filename must be a standard 8bits string.
22093 @end itemize
22094
22095 In the absence of a @code{encoding=xxx} form parameter, the
22096 encoding is controlled by the @code{GNAT_CODE_PAGE} environment
22097 variable. And if not set @code{utf8} is assumed.
22098
22099
22100 @table @asis
22101
22102 @item @emph{CP_ACP}
22103
22104 The current system Windows ANSI code page.
22105
22106 @item @emph{CP_UTF8}
22107
22108 UTF-8 encoding
22109 @end table
22110
22111 This encoding form parameter is only supported on the Windows
22112 platform. On the other Operating Systems the run-time is supporting
22113 UTF-8 natively.
22114
22115 @node File content encoding,Open Modes,Filenames encoding,The Implementation of Standard I/O
22116 @anchor{gnat_rm/the_implementation_of_standard_i_o file-content-encoding}@anchor{2c9}@anchor{gnat_rm/the_implementation_of_standard_i_o id23}@anchor{2ca}
22117 @section File content encoding
22118
22119
22120 For text files it is possible to specify the encoding to use. This is
22121 controlled by the by the @code{GNAT_CCS_ENCODING} environment
22122 variable. And if not set @code{TEXT} is assumed.
22123
22124 The possible values are those supported on Windows:
22125
22126
22127 @table @asis
22128
22129 @item @emph{TEXT}
22130
22131 Translated text mode
22132
22133 @item @emph{WTEXT}
22134
22135 Translated unicode encoding
22136
22137 @item @emph{U16TEXT}
22138
22139 Unicode 16-bit encoding
22140
22141 @item @emph{U8TEXT}
22142
22143 Unicode 8-bit encoding
22144 @end table
22145
22146 This encoding is only supported on the Windows platform.
22147
22148 @node Open Modes,Operations on C Streams,File content encoding,The Implementation of Standard I/O
22149 @anchor{gnat_rm/the_implementation_of_standard_i_o open-modes}@anchor{2cb}@anchor{gnat_rm/the_implementation_of_standard_i_o id24}@anchor{2cc}
22150 @section Open Modes
22151
22152
22153 @code{Open} and @code{Create} calls result in a call to @code{fopen}
22154 using the mode shown in the following table:
22155
22156
22157 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxx}
22158 @headitem
22159
22160 @code{Open} and @code{Create} Call Modes
22161
22162 @tab
22163
22164 @tab
22165
22166 @item
22167
22168 @tab
22169
22170 @strong{OPEN}
22171
22172 @tab
22173
22174 @strong{CREATE}
22175
22176 @item
22177
22178 Append_File
22179
22180 @tab
22181
22182 "r+"
22183
22184 @tab
22185
22186 "w+"
22187
22188 @item
22189
22190 In_File
22191
22192 @tab
22193
22194 "r"
22195
22196 @tab
22197
22198 "w+"
22199
22200 @item
22201
22202 Out_File (Direct_IO)
22203
22204 @tab
22205
22206 "r+"
22207
22208 @tab
22209
22210 "w"
22211
22212 @item
22213
22214 Out_File (all other cases)
22215
22216 @tab
22217
22218 "w"
22219
22220 @tab
22221
22222 "w"
22223
22224 @item
22225
22226 Inout_File
22227
22228 @tab
22229
22230 "r+"
22231
22232 @tab
22233
22234 "w+"
22235
22236 @end multitable
22237
22238
22239 If text file translation is required, then either @code{b} or @code{t}
22240 is added to the mode, depending on the setting of Text. Text file
22241 translation refers to the mapping of CR/LF sequences in an external file
22242 to LF characters internally. This mapping only occurs in DOS and
22243 DOS-like systems, and is not relevant to other systems.
22244
22245 A special case occurs with Stream_IO. As shown in the above table, the
22246 file is initially opened in @code{r} or @code{w} mode for the
22247 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
22248 subsequently requires switching from reading to writing or vice-versa,
22249 then the file is reopened in @code{r+} mode to permit the required operation.
22250
22251 @node Operations on C Streams,Interfacing to C Streams,Open Modes,The Implementation of Standard I/O
22252 @anchor{gnat_rm/the_implementation_of_standard_i_o operations-on-c-streams}@anchor{2cd}@anchor{gnat_rm/the_implementation_of_standard_i_o id25}@anchor{2ce}
22253 @section Operations on C Streams
22254
22255
22256 The package @code{Interfaces.C_Streams} provides an Ada program with direct
22257 access to the C library functions for operations on C streams:
22258
22259 @example
22260 package Interfaces.C_Streams is
22261 -- Note: the reason we do not use the types that are in
22262 -- Interfaces.C is that we want to avoid dragging in the
22263 -- code in this unit if possible.
22264 subtype chars is System.Address;
22265 -- Pointer to null-terminated array of characters
22266 subtype FILEs is System.Address;
22267 -- Corresponds to the C type FILE*
22268 subtype voids is System.Address;
22269 -- Corresponds to the C type void*
22270 subtype int is Integer;
22271 subtype long is Long_Integer;
22272 -- Note: the above types are subtypes deliberately, and it
22273 -- is part of this spec that the above correspondences are
22274 -- guaranteed. This means that it is legitimate to, for
22275 -- example, use Integer instead of int. We provide these
22276 -- synonyms for clarity, but in some cases it may be
22277 -- convenient to use the underlying types (for example to
22278 -- avoid an unnecessary dependency of a spec on the spec
22279 -- of this unit).
22280 type size_t is mod 2 ** Standard'Address_Size;
22281 NULL_Stream : constant FILEs;
22282 -- Value returned (NULL in C) to indicate an
22283 -- fdopen/fopen/tmpfile error
22284 ----------------------------------
22285 -- Constants Defined in stdio.h --
22286 ----------------------------------
22287 EOF : constant int;
22288 -- Used by a number of routines to indicate error or
22289 -- end of file
22290 IOFBF : constant int;
22291 IOLBF : constant int;
22292 IONBF : constant int;
22293 -- Used to indicate buffering mode for setvbuf call
22294 SEEK_CUR : constant int;
22295 SEEK_END : constant int;
22296 SEEK_SET : constant int;
22297 -- Used to indicate origin for fseek call
22298 function stdin return FILEs;
22299 function stdout return FILEs;
22300 function stderr return FILEs;
22301 -- Streams associated with standard files
22302 --------------------------
22303 -- Standard C functions --
22304 --------------------------
22305 -- The functions selected below are ones that are
22306 -- available in UNIX (but not necessarily in ANSI C).
22307 -- These are very thin interfaces
22308 -- which copy exactly the C headers. For more
22309 -- documentation on these functions, see the Microsoft C
22310 -- "Run-Time Library Reference" (Microsoft Press, 1990,
22311 -- ISBN 1-55615-225-6), which includes useful information
22312 -- on system compatibility.
22313 procedure clearerr (stream : FILEs);
22314 function fclose (stream : FILEs) return int;
22315 function fdopen (handle : int; mode : chars) return FILEs;
22316 function feof (stream : FILEs) return int;
22317 function ferror (stream : FILEs) return int;
22318 function fflush (stream : FILEs) return int;
22319 function fgetc (stream : FILEs) return int;
22320 function fgets (strng : chars; n : int; stream : FILEs)
22321 return chars;
22322 function fileno (stream : FILEs) return int;
22323 function fopen (filename : chars; Mode : chars)
22324 return FILEs;
22325 -- Note: to maintain target independence, use
22326 -- text_translation_required, a boolean variable defined in
22327 -- a-sysdep.c to deal with the target dependent text
22328 -- translation requirement. If this variable is set,
22329 -- then b/t should be appended to the standard mode
22330 -- argument to set the text translation mode off or on
22331 -- as required.
22332 function fputc (C : int; stream : FILEs) return int;
22333 function fputs (Strng : chars; Stream : FILEs) return int;
22334 function fread
22335 (buffer : voids;
22336 size : size_t;
22337 count : size_t;
22338 stream : FILEs)
22339 return size_t;
22340 function freopen
22341 (filename : chars;
22342 mode : chars;
22343 stream : FILEs)
22344 return FILEs;
22345 function fseek
22346 (stream : FILEs;
22347 offset : long;
22348 origin : int)
22349 return int;
22350 function ftell (stream : FILEs) return long;
22351 function fwrite
22352 (buffer : voids;
22353 size : size_t;
22354 count : size_t;
22355 stream : FILEs)
22356 return size_t;
22357 function isatty (handle : int) return int;
22358 procedure mktemp (template : chars);
22359 -- The return value (which is just a pointer to template)
22360 -- is discarded
22361 procedure rewind (stream : FILEs);
22362 function rmtmp return int;
22363 function setvbuf
22364 (stream : FILEs;
22365 buffer : chars;
22366 mode : int;
22367 size : size_t)
22368 return int;
22369
22370 function tmpfile return FILEs;
22371 function ungetc (c : int; stream : FILEs) return int;
22372 function unlink (filename : chars) return int;
22373 ---------------------
22374 -- Extra functions --
22375 ---------------------
22376 -- These functions supply slightly thicker bindings than
22377 -- those above. They are derived from functions in the
22378 -- C Run-Time Library, but may do a bit more work than
22379 -- just directly calling one of the Library functions.
22380 function is_regular_file (handle : int) return int;
22381 -- Tests if given handle is for a regular file (result 1)
22382 -- or for a non-regular file (pipe or device, result 0).
22383 ---------------------------------
22384 -- Control of Text/Binary Mode --
22385 ---------------------------------
22386 -- If text_translation_required is true, then the following
22387 -- functions may be used to dynamically switch a file from
22388 -- binary to text mode or vice versa. These functions have
22389 -- no effect if text_translation_required is false (i.e., in
22390 -- normal UNIX mode). Use fileno to get a stream handle.
22391 procedure set_binary_mode (handle : int);
22392 procedure set_text_mode (handle : int);
22393 ----------------------------
22394 -- Full Path Name support --
22395 ----------------------------
22396 procedure full_name (nam : chars; buffer : chars);
22397 -- Given a NUL terminated string representing a file
22398 -- name, returns in buffer a NUL terminated string
22399 -- representing the full path name for the file name.
22400 -- On systems where it is relevant the drive is also
22401 -- part of the full path name. It is the responsibility
22402 -- of the caller to pass an actual parameter for buffer
22403 -- that is big enough for any full path name. Use
22404 -- max_path_len given below as the size of buffer.
22405 max_path_len : integer;
22406 -- Maximum length of an allowable full path name on the
22407 -- system, including a terminating NUL character.
22408 end Interfaces.C_Streams;
22409 @end example
22410
22411 @node Interfacing to C Streams,,Operations on C Streams,The Implementation of Standard I/O
22412 @anchor{gnat_rm/the_implementation_of_standard_i_o interfacing-to-c-streams}@anchor{2cf}@anchor{gnat_rm/the_implementation_of_standard_i_o id26}@anchor{2d0}
22413 @section Interfacing to C Streams
22414
22415
22416 The packages in this section permit interfacing Ada files to C Stream
22417 operations.
22418
22419 @example
22420 with Interfaces.C_Streams;
22421 package Ada.Sequential_IO.C_Streams is
22422 function C_Stream (F : File_Type)
22423 return Interfaces.C_Streams.FILEs;
22424 procedure Open
22425 (File : in out File_Type;
22426 Mode : in File_Mode;
22427 C_Stream : in Interfaces.C_Streams.FILEs;
22428 Form : in String := "");
22429 end Ada.Sequential_IO.C_Streams;
22430
22431 with Interfaces.C_Streams;
22432 package Ada.Direct_IO.C_Streams is
22433 function C_Stream (F : File_Type)
22434 return Interfaces.C_Streams.FILEs;
22435 procedure Open
22436 (File : in out File_Type;
22437 Mode : in File_Mode;
22438 C_Stream : in Interfaces.C_Streams.FILEs;
22439 Form : in String := "");
22440 end Ada.Direct_IO.C_Streams;
22441
22442 with Interfaces.C_Streams;
22443 package Ada.Text_IO.C_Streams is
22444 function C_Stream (F : File_Type)
22445 return Interfaces.C_Streams.FILEs;
22446 procedure Open
22447 (File : in out File_Type;
22448 Mode : in File_Mode;
22449 C_Stream : in Interfaces.C_Streams.FILEs;
22450 Form : in String := "");
22451 end Ada.Text_IO.C_Streams;
22452
22453 with Interfaces.C_Streams;
22454 package Ada.Wide_Text_IO.C_Streams is
22455 function C_Stream (F : File_Type)
22456 return Interfaces.C_Streams.FILEs;
22457 procedure Open
22458 (File : in out File_Type;
22459 Mode : in File_Mode;
22460 C_Stream : in Interfaces.C_Streams.FILEs;
22461 Form : in String := "");
22462 end Ada.Wide_Text_IO.C_Streams;
22463
22464 with Interfaces.C_Streams;
22465 package Ada.Wide_Wide_Text_IO.C_Streams is
22466 function C_Stream (F : File_Type)
22467 return Interfaces.C_Streams.FILEs;
22468 procedure Open
22469 (File : in out File_Type;
22470 Mode : in File_Mode;
22471 C_Stream : in Interfaces.C_Streams.FILEs;
22472 Form : in String := "");
22473 end Ada.Wide_Wide_Text_IO.C_Streams;
22474
22475 with Interfaces.C_Streams;
22476 package Ada.Stream_IO.C_Streams is
22477 function C_Stream (F : File_Type)
22478 return Interfaces.C_Streams.FILEs;
22479 procedure Open
22480 (File : in out File_Type;
22481 Mode : in File_Mode;
22482 C_Stream : in Interfaces.C_Streams.FILEs;
22483 Form : in String := "");
22484 end Ada.Stream_IO.C_Streams;
22485 @end example
22486
22487 In each of these six packages, the @code{C_Stream} function obtains the
22488 @code{FILE} pointer from a currently opened Ada file. It is then
22489 possible to use the @code{Interfaces.C_Streams} package to operate on
22490 this stream, or the stream can be passed to a C program which can
22491 operate on it directly. Of course the program is responsible for
22492 ensuring that only appropriate sequences of operations are executed.
22493
22494 One particular use of relevance to an Ada program is that the
22495 @code{setvbuf} function can be used to control the buffering of the
22496 stream used by an Ada file. In the absence of such a call the standard
22497 default buffering is used.
22498
22499 The @code{Open} procedures in these packages open a file giving an
22500 existing C Stream instead of a file name. Typically this stream is
22501 imported from a C program, allowing an Ada file to operate on an
22502 existing C file.
22503
22504 @node The GNAT Library,Interfacing to Other Languages,The Implementation of Standard I/O,Top
22505 @anchor{gnat_rm/the_gnat_library the-gnat-library}@anchor{10}@anchor{gnat_rm/the_gnat_library doc}@anchor{2d1}@anchor{gnat_rm/the_gnat_library id1}@anchor{2d2}
22506 @chapter The GNAT Library
22507
22508
22509 The GNAT library contains a number of general and special purpose packages.
22510 It represents functionality that the GNAT developers have found useful, and
22511 which is made available to GNAT users. The packages described here are fully
22512 supported, and upwards compatibility will be maintained in future releases,
22513 so you can use these facilities with the confidence that the same functionality
22514 will be available in future releases.
22515
22516 The chapter here simply gives a brief summary of the facilities available.
22517 The full documentation is found in the spec file for the package. The full
22518 sources of these library packages, including both spec and body, are provided
22519 with all GNAT releases. For example, to find out the full specifications of
22520 the SPITBOL pattern matching capability, including a full tutorial and
22521 extensive examples, look in the @code{g-spipat.ads} file in the library.
22522
22523 For each entry here, the package name (as it would appear in a @code{with}
22524 clause) is given, followed by the name of the corresponding spec file in
22525 parentheses. The packages are children in four hierarchies, @code{Ada},
22526 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
22527 GNAT-specific hierarchy.
22528
22529 Note that an application program should only use packages in one of these
22530 four hierarchies if the package is defined in the Ada Reference Manual,
22531 or is listed in this section of the GNAT Programmers Reference Manual.
22532 All other units should be considered internal implementation units and
22533 should not be directly @code{with}ed by application code. The use of
22534 a @code{with} clause that references one of these internal implementation
22535 units makes an application potentially dependent on changes in versions
22536 of GNAT, and will generate a warning message.
22537
22538 @menu
22539 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads.
22540 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads.
22541 * Ada.Characters.Wide_Latin_9 (a-cwila1.ads): Ada Characters Wide_Latin_9 a-cwila1 ads.
22542 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads.
22543 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads.
22544 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads): Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads.
22545 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads): Ada Containers Formal_Hashed_Maps a-cfhama ads.
22546 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads): Ada Containers Formal_Hashed_Sets a-cfhase ads.
22547 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads): Ada Containers Formal_Ordered_Maps a-cforma ads.
22548 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads): Ada Containers Formal_Ordered_Sets a-cforse ads.
22549 * Ada.Containers.Formal_Vectors (a-cofove.ads): Ada Containers Formal_Vectors a-cofove ads.
22550 * Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads): Ada Containers Formal_Indefinite_Vectors a-cfinve ads.
22551 * Ada.Containers.Functional_Vectors (a-cofuve.ads): Ada Containers Functional_Vectors a-cofuve ads.
22552 * Ada.Containers.Functional_Sets (a-cofuse.ads): Ada Containers Functional_Sets a-cofuse ads.
22553 * Ada.Containers.Functional_Maps (a-cofuma.ads): Ada Containers Functional_Maps a-cofuma ads.
22554 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads.
22555 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads.
22556 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads.
22557 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads.
22558 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads.
22559 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads.
22560 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads.
22561 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads.
22562 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads.
22563 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads.
22564 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads.
22565 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads.
22566 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads.
22567 * Ada.Task_Initialization (a-tasini.ads): Ada Task_Initialization a-tasini ads.
22568 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads.
22569 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads.
22570 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads.
22571 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads.
22572 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads.
22573 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads.
22574 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads.
22575 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads.
22576 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads.
22577 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads.
22578 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads.
22579 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads.
22580 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads.
22581 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads.
22582 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads.
22583 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads.
22584 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads.
22585 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads.
22586 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads.
22587 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads.
22588 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads.
22589 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads.
22590 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads.
22591 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads.
22592 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads.
22593 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads.
22594 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads.
22595 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads.
22596 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads.
22597 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads.
22598 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads.
22599 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads.
22600 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads.
22601 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads.
22602 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads.
22603 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads.
22604 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads.
22605 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads.
22606 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads.
22607 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads.
22608 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads.
22609 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads.
22610 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads.
22611 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads.
22612 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads.
22613 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads.
22614 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads.
22615 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads.
22616 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads.
22617 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads.
22618 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads.
22619 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads.
22620 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads.
22621 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads.
22622 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads.
22623 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads.
22624 * GNAT.IO (g-io.ads): GNAT IO g-io ads.
22625 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads.
22626 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads.
22627 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads.
22628 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads.
22629 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads.
22630 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads.
22631 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads.
22632 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads.
22633 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads.
22634 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads.
22635 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads.
22636 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads.
22637 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads.
22638 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads.
22639 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads.
22640 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads.
22641 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads.
22642 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads.
22643 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads.
22644 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads.
22645 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads.
22646 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads.
22647 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads.
22648 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads.
22649 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads.
22650 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads.
22651 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads.
22652 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads.
22653 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads.
22654 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads.
22655 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads.
22656 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads.
22657 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads.
22658 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads.
22659 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads.
22660 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads.
22661 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads.
22662 * GNAT.Table (g-table.ads): GNAT Table g-table ads.
22663 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads.
22664 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads.
22665 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads.
22666 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads.
22667 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads.
22668 * GNAT.UTF_32 (g-table.ads): GNAT UTF_32 g-table ads.
22669 * GNAT.Wide_Spelling_Checker (g-u3spch.ads): GNAT Wide_Spelling_Checker g-u3spch ads.
22670 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads.
22671 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads.
22672 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads.
22673 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads.
22674 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads.
22675 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads.
22676 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads.
22677 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads.
22678 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads.
22679 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads.
22680 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads.
22681 * System.Assertions (s-assert.ads): System Assertions s-assert ads.
22682 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads.
22683 * System.Memory (s-memory.ads): System Memory s-memory ads.
22684 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads.
22685 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads.
22686 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads.
22687 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads.
22688 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads.
22689 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads.
22690 * System.Rident (s-rident.ads): System Rident s-rident ads.
22691 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads.
22692 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads.
22693 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads.
22694 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads.
22695
22696 @end menu
22697
22698 @node Ada Characters Latin_9 a-chlat9 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,,The GNAT Library
22699 @anchor{gnat_rm/the_gnat_library id2}@anchor{2d3}@anchor{gnat_rm/the_gnat_library ada-characters-latin-9-a-chlat9-ads}@anchor{2d4}
22700 @section @code{Ada.Characters.Latin_9} (@code{a-chlat9.ads})
22701
22702
22703 @geindex Ada.Characters.Latin_9 (a-chlat9.ads)
22704
22705 @geindex Latin_9 constants for Character
22706
22707 This child of @code{Ada.Characters}
22708 provides a set of definitions corresponding to those in the
22709 RM-defined package @code{Ada.Characters.Latin_1} but with the
22710 few modifications required for @code{Latin-9}
22711 The provision of such a package
22712 is specifically authorized by the Ada Reference Manual
22713 (RM A.3.3(27)).
22714
22715 @node Ada Characters Wide_Latin_1 a-cwila1 ads,Ada Characters Wide_Latin_9 a-cwila1 ads,Ada Characters Latin_9 a-chlat9 ads,The GNAT Library
22716 @anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-1-a-cwila1-ads}@anchor{2d5}@anchor{gnat_rm/the_gnat_library id3}@anchor{2d6}
22717 @section @code{Ada.Characters.Wide_Latin_1} (@code{a-cwila1.ads})
22718
22719
22720 @geindex Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
22721
22722 @geindex Latin_1 constants for Wide_Character
22723
22724 This child of @code{Ada.Characters}
22725 provides a set of definitions corresponding to those in the
22726 RM-defined package @code{Ada.Characters.Latin_1} but with the
22727 types of the constants being @code{Wide_Character}
22728 instead of @code{Character}. The provision of such a package
22729 is specifically authorized by the Ada Reference Manual
22730 (RM A.3.3(27)).
22731
22732 @node Ada Characters Wide_Latin_9 a-cwila1 ads,Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,The GNAT Library
22733 @anchor{gnat_rm/the_gnat_library id4}@anchor{2d7}@anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-9-a-cwila1-ads}@anchor{2d8}
22734 @section @code{Ada.Characters.Wide_Latin_9} (@code{a-cwila1.ads})
22735
22736
22737 @geindex Ada.Characters.Wide_Latin_9 (a-cwila1.ads)
22738
22739 @geindex Latin_9 constants for Wide_Character
22740
22741 This child of @code{Ada.Characters}
22742 provides a set of definitions corresponding to those in the
22743 GNAT defined package @code{Ada.Characters.Latin_9} but with the
22744 types of the constants being @code{Wide_Character}
22745 instead of @code{Character}. The provision of such a package
22746 is specifically authorized by the Ada Reference Manual
22747 (RM A.3.3(27)).
22748
22749 @node Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,Ada Characters Wide_Latin_9 a-cwila1 ads,The GNAT Library
22750 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-1-a-chzla1-ads}@anchor{2d9}@anchor{gnat_rm/the_gnat_library id5}@anchor{2da}
22751 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@code{a-chzla1.ads})
22752
22753
22754 @geindex Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
22755
22756 @geindex Latin_1 constants for Wide_Wide_Character
22757
22758 This child of @code{Ada.Characters}
22759 provides a set of definitions corresponding to those in the
22760 RM-defined package @code{Ada.Characters.Latin_1} but with the
22761 types of the constants being @code{Wide_Wide_Character}
22762 instead of @code{Character}. The provision of such a package
22763 is specifically authorized by the Ada Reference Manual
22764 (RM A.3.3(27)).
22765
22766 @node Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads,Ada Characters Wide_Wide_Latin_1 a-chzla1 ads,The GNAT Library
22767 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-9-a-chzla9-ads}@anchor{2db}@anchor{gnat_rm/the_gnat_library id6}@anchor{2dc}
22768 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@code{a-chzla9.ads})
22769
22770
22771 @geindex Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
22772
22773 @geindex Latin_9 constants for Wide_Wide_Character
22774
22775 This child of @code{Ada.Characters}
22776 provides a set of definitions corresponding to those in the
22777 GNAT defined package @code{Ada.Characters.Latin_9} but with the
22778 types of the constants being @code{Wide_Wide_Character}
22779 instead of @code{Character}. The provision of such a package
22780 is specifically authorized by the Ada Reference Manual
22781 (RM A.3.3(27)).
22782
22783 @node Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads,Ada Containers Formal_Hashed_Maps a-cfhama ads,Ada Characters Wide_Wide_Latin_9 a-chzla9 ads,The GNAT Library
22784 @anchor{gnat_rm/the_gnat_library id7}@anchor{2dd}@anchor{gnat_rm/the_gnat_library ada-containers-formal-doubly-linked-lists-a-cfdlli-ads}@anchor{2de}
22785 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@code{a-cfdlli.ads})
22786
22787
22788 @geindex Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
22789
22790 @geindex Formal container for doubly linked lists
22791
22792 This child of @code{Ada.Containers} defines a modified version of the
22793 Ada 2005 container for doubly linked lists, meant to facilitate formal
22794 verification of code using such containers. The specification of this
22795 unit is compatible with SPARK 2014.
22796
22797 Note that although this container was designed with formal verification
22798 in mind, it may well be generally useful in that it is a simplified more
22799 efficient version than the one defined in the standard. In particular it
22800 does not have the complex overhead required to detect cursor tampering.
22801
22802 @node Ada Containers Formal_Hashed_Maps a-cfhama ads,Ada Containers Formal_Hashed_Sets a-cfhase ads,Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads,The GNAT Library
22803 @anchor{gnat_rm/the_gnat_library id8}@anchor{2df}@anchor{gnat_rm/the_gnat_library ada-containers-formal-hashed-maps-a-cfhama-ads}@anchor{2e0}
22804 @section @code{Ada.Containers.Formal_Hashed_Maps} (@code{a-cfhama.ads})
22805
22806
22807 @geindex Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
22808
22809 @geindex Formal container for hashed maps
22810
22811 This child of @code{Ada.Containers} defines a modified version of the
22812 Ada 2005 container for hashed maps, meant to facilitate formal
22813 verification of code using such containers. The specification of this
22814 unit is compatible with SPARK 2014.
22815
22816 Note that although this container was designed with formal verification
22817 in mind, it may well be generally useful in that it is a simplified more
22818 efficient version than the one defined in the standard. In particular it
22819 does not have the complex overhead required to detect cursor tampering.
22820
22821 @node Ada Containers Formal_Hashed_Sets a-cfhase ads,Ada Containers Formal_Ordered_Maps a-cforma ads,Ada Containers Formal_Hashed_Maps a-cfhama ads,The GNAT Library
22822 @anchor{gnat_rm/the_gnat_library id9}@anchor{2e1}@anchor{gnat_rm/the_gnat_library ada-containers-formal-hashed-sets-a-cfhase-ads}@anchor{2e2}
22823 @section @code{Ada.Containers.Formal_Hashed_Sets} (@code{a-cfhase.ads})
22824
22825
22826 @geindex Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
22827
22828 @geindex Formal container for hashed sets
22829
22830 This child of @code{Ada.Containers} defines a modified version of the
22831 Ada 2005 container for hashed sets, meant to facilitate formal
22832 verification of code using such containers. The specification of this
22833 unit is compatible with SPARK 2014.
22834
22835 Note that although this container was designed with formal verification
22836 in mind, it may well be generally useful in that it is a simplified more
22837 efficient version than the one defined in the standard. In particular it
22838 does not have the complex overhead required to detect cursor tampering.
22839
22840 @node Ada Containers Formal_Ordered_Maps a-cforma ads,Ada Containers Formal_Ordered_Sets a-cforse ads,Ada Containers Formal_Hashed_Sets a-cfhase ads,The GNAT Library
22841 @anchor{gnat_rm/the_gnat_library id10}@anchor{2e3}@anchor{gnat_rm/the_gnat_library ada-containers-formal-ordered-maps-a-cforma-ads}@anchor{2e4}
22842 @section @code{Ada.Containers.Formal_Ordered_Maps} (@code{a-cforma.ads})
22843
22844
22845 @geindex Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
22846
22847 @geindex Formal container for ordered maps
22848
22849 This child of @code{Ada.Containers} defines a modified version of the
22850 Ada 2005 container for ordered maps, meant to facilitate formal
22851 verification of code using such containers. The specification of this
22852 unit is compatible with SPARK 2014.
22853
22854 Note that although this container was designed with formal verification
22855 in mind, it may well be generally useful in that it is a simplified more
22856 efficient version than the one defined in the standard. In particular it
22857 does not have the complex overhead required to detect cursor tampering.
22858
22859 @node Ada Containers Formal_Ordered_Sets a-cforse ads,Ada Containers Formal_Vectors a-cofove ads,Ada Containers Formal_Ordered_Maps a-cforma ads,The GNAT Library
22860 @anchor{gnat_rm/the_gnat_library ada-containers-formal-ordered-sets-a-cforse-ads}@anchor{2e5}@anchor{gnat_rm/the_gnat_library id11}@anchor{2e6}
22861 @section @code{Ada.Containers.Formal_Ordered_Sets} (@code{a-cforse.ads})
22862
22863
22864 @geindex Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
22865
22866 @geindex Formal container for ordered sets
22867
22868 This child of @code{Ada.Containers} defines a modified version of the
22869 Ada 2005 container for ordered sets, meant to facilitate formal
22870 verification of code using such containers. The specification of this
22871 unit is compatible with SPARK 2014.
22872
22873 Note that although this container was designed with formal verification
22874 in mind, it may well be generally useful in that it is a simplified more
22875 efficient version than the one defined in the standard. In particular it
22876 does not have the complex overhead required to detect cursor tampering.
22877
22878 @node Ada Containers Formal_Vectors a-cofove ads,Ada Containers Formal_Indefinite_Vectors a-cfinve ads,Ada Containers Formal_Ordered_Sets a-cforse ads,The GNAT Library
22879 @anchor{gnat_rm/the_gnat_library id12}@anchor{2e7}@anchor{gnat_rm/the_gnat_library ada-containers-formal-vectors-a-cofove-ads}@anchor{2e8}
22880 @section @code{Ada.Containers.Formal_Vectors} (@code{a-cofove.ads})
22881
22882
22883 @geindex Ada.Containers.Formal_Vectors (a-cofove.ads)
22884
22885 @geindex Formal container for vectors
22886
22887 This child of @code{Ada.Containers} defines a modified version of the
22888 Ada 2005 container for vectors, meant to facilitate formal
22889 verification of code using such containers. The specification of this
22890 unit is compatible with SPARK 2014.
22891
22892 Note that although this container was designed with formal verification
22893 in mind, it may well be generally useful in that it is a simplified more
22894 efficient version than the one defined in the standard. In particular it
22895 does not have the complex overhead required to detect cursor tampering.
22896
22897 @node Ada Containers Formal_Indefinite_Vectors a-cfinve ads,Ada Containers Functional_Vectors a-cofuve ads,Ada Containers Formal_Vectors a-cofove ads,The GNAT Library
22898 @anchor{gnat_rm/the_gnat_library id13}@anchor{2e9}@anchor{gnat_rm/the_gnat_library ada-containers-formal-indefinite-vectors-a-cfinve-ads}@anchor{2ea}
22899 @section @code{Ada.Containers.Formal_Indefinite_Vectors} (@code{a-cfinve.ads})
22900
22901
22902 @geindex Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads)
22903
22904 @geindex Formal container for vectors
22905
22906 This child of @code{Ada.Containers} defines a modified version of the
22907 Ada 2005 container for vectors of indefinite elements, meant to
22908 facilitate formal verification of code using such containers. The
22909 specification of this unit is compatible with SPARK 2014.
22910
22911 Note that although this container was designed with formal verification
22912 in mind, it may well be generally useful in that it is a simplified more
22913 efficient version than the one defined in the standard. In particular it
22914 does not have the complex overhead required to detect cursor tampering.
22915
22916 @node Ada Containers Functional_Vectors a-cofuve ads,Ada Containers Functional_Sets a-cofuse ads,Ada Containers Formal_Indefinite_Vectors a-cfinve ads,The GNAT Library
22917 @anchor{gnat_rm/the_gnat_library id14}@anchor{2eb}@anchor{gnat_rm/the_gnat_library ada-containers-functional-vectors-a-cofuve-ads}@anchor{2ec}
22918 @section @code{Ada.Containers.Functional_Vectors} (@code{a-cofuve.ads})
22919
22920
22921 @geindex Ada.Containers.Functional_Vectors (a-cofuve.ads)
22922
22923 @geindex Functional vectors
22924
22925 This child of @code{Ada.Containers} defines immutable vectors. These
22926 containers are unbounded and may contain indefinite elements. Furthermore, to
22927 be usable in every context, they are neither controlled nor limited. As they
22928 are functional, that is, no primitives are provided which would allow modifying
22929 an existing container, these containers can still be used safely.
22930
22931 Their API features functions creating new containers from existing ones.
22932 As a consequence, these containers are highly inefficient. They are also
22933 memory consuming, as the allocated memory is not reclaimed when the container
22934 is no longer referenced. Thus, they should in general be used in ghost code
22935 and annotations, so that they can be removed from the final executable. The
22936 specification of this unit is compatible with SPARK 2014.
22937
22938 @node Ada Containers Functional_Sets a-cofuse ads,Ada Containers Functional_Maps a-cofuma ads,Ada Containers Functional_Vectors a-cofuve ads,The GNAT Library
22939 @anchor{gnat_rm/the_gnat_library ada-containers-functional-sets-a-cofuse-ads}@anchor{2ed}@anchor{gnat_rm/the_gnat_library id15}@anchor{2ee}
22940 @section @code{Ada.Containers.Functional_Sets} (@code{a-cofuse.ads})
22941
22942
22943 @geindex Ada.Containers.Functional_Sets (a-cofuse.ads)
22944
22945 @geindex Functional sets
22946
22947 This child of @code{Ada.Containers} defines immutable sets. These containers are
22948 unbounded and may contain indefinite elements. Furthermore, to be usable in
22949 every context, they are neither controlled nor limited. As they are functional,
22950 that is, no primitives are provided which would allow modifying an existing
22951 container, these containers can still be used safely.
22952
22953 Their API features functions creating new containers from existing ones.
22954 As a consequence, these containers are highly inefficient. They are also
22955 memory consuming, as the allocated memory is not reclaimed when the container
22956 is no longer referenced. Thus, they should in general be used in ghost code
22957 and annotations, so that they can be removed from the final executable. The
22958 specification of this unit is compatible with SPARK 2014.
22959
22960 @node Ada Containers Functional_Maps a-cofuma ads,Ada Containers Bounded_Holders a-coboho ads,Ada Containers Functional_Sets a-cofuse ads,The GNAT Library
22961 @anchor{gnat_rm/the_gnat_library id16}@anchor{2ef}@anchor{gnat_rm/the_gnat_library ada-containers-functional-maps-a-cofuma-ads}@anchor{2f0}
22962 @section @code{Ada.Containers.Functional_Maps} (@code{a-cofuma.ads})
22963
22964
22965 @geindex Ada.Containers.Functional_Maps (a-cofuma.ads)
22966
22967 @geindex Functional maps
22968
22969 This child of @code{Ada.Containers} defines immutable maps. These containers are
22970 unbounded and may contain indefinite elements. Furthermore, to be usable in
22971 every context, they are neither controlled nor limited. As they are functional,
22972 that is, no primitives are provided which would allow modifying an existing
22973 container, these containers can still be used safely.
22974
22975 Their API features functions creating new containers from existing ones.
22976 As a consequence, these containers are highly inefficient. They are also
22977 memory consuming, as the allocated memory is not reclaimed when the container
22978 is no longer referenced. Thus, they should in general be used in ghost code
22979 and annotations, so that they can be removed from the final executable. The
22980 specification of this unit is compatible with SPARK 2014.
22981
22982 @node Ada Containers Bounded_Holders a-coboho ads,Ada Command_Line Environment a-colien ads,Ada Containers Functional_Maps a-cofuma ads,The GNAT Library
22983 @anchor{gnat_rm/the_gnat_library ada-containers-bounded-holders-a-coboho-ads}@anchor{2f1}@anchor{gnat_rm/the_gnat_library id17}@anchor{2f2}
22984 @section @code{Ada.Containers.Bounded_Holders} (@code{a-coboho.ads})
22985
22986
22987 @geindex Ada.Containers.Bounded_Holders (a-coboho.ads)
22988
22989 @geindex Formal container for vectors
22990
22991 This child of @code{Ada.Containers} defines a modified version of
22992 Indefinite_Holders that avoids heap allocation.
22993
22994 @node Ada Command_Line Environment a-colien ads,Ada Command_Line Remove a-colire ads,Ada Containers Bounded_Holders a-coboho ads,The GNAT Library
22995 @anchor{gnat_rm/the_gnat_library ada-command-line-environment-a-colien-ads}@anchor{2f3}@anchor{gnat_rm/the_gnat_library id18}@anchor{2f4}
22996 @section @code{Ada.Command_Line.Environment} (@code{a-colien.ads})
22997
22998
22999 @geindex Ada.Command_Line.Environment (a-colien.ads)
23000
23001 @geindex Environment entries
23002
23003 This child of @code{Ada.Command_Line}
23004 provides a mechanism for obtaining environment values on systems
23005 where this concept makes sense.
23006
23007 @node Ada Command_Line Remove a-colire ads,Ada Command_Line Response_File a-clrefi ads,Ada Command_Line Environment a-colien ads,The GNAT Library
23008 @anchor{gnat_rm/the_gnat_library id19}@anchor{2f5}@anchor{gnat_rm/the_gnat_library ada-command-line-remove-a-colire-ads}@anchor{2f6}
23009 @section @code{Ada.Command_Line.Remove} (@code{a-colire.ads})
23010
23011
23012 @geindex Ada.Command_Line.Remove (a-colire.ads)
23013
23014 @geindex Removing command line arguments
23015
23016 @geindex Command line
23017 @geindex argument removal
23018
23019 This child of @code{Ada.Command_Line}
23020 provides a mechanism for logically removing
23021 arguments from the argument list. Once removed, an argument is not visible
23022 to further calls on the subprograms in @code{Ada.Command_Line} will not
23023 see the removed argument.
23024
23025 @node Ada Command_Line Response_File a-clrefi ads,Ada Direct_IO C_Streams a-diocst ads,Ada Command_Line Remove a-colire ads,The GNAT Library
23026 @anchor{gnat_rm/the_gnat_library id20}@anchor{2f7}@anchor{gnat_rm/the_gnat_library ada-command-line-response-file-a-clrefi-ads}@anchor{2f8}
23027 @section @code{Ada.Command_Line.Response_File} (@code{a-clrefi.ads})
23028
23029
23030 @geindex Ada.Command_Line.Response_File (a-clrefi.ads)
23031
23032 @geindex Response file for command line
23033
23034 @geindex Command line
23035 @geindex response file
23036
23037 @geindex Command line
23038 @geindex handling long command lines
23039
23040 This child of @code{Ada.Command_Line} provides a mechanism facilities for
23041 getting command line arguments from a text file, called a "response file".
23042 Using a response file allow passing a set of arguments to an executable longer
23043 than the maximum allowed by the system on the command line.
23044
23045 @node Ada Direct_IO C_Streams a-diocst ads,Ada Exceptions Is_Null_Occurrence a-einuoc ads,Ada Command_Line Response_File a-clrefi ads,The GNAT Library
23046 @anchor{gnat_rm/the_gnat_library id21}@anchor{2f9}@anchor{gnat_rm/the_gnat_library ada-direct-io-c-streams-a-diocst-ads}@anchor{2fa}
23047 @section @code{Ada.Direct_IO.C_Streams} (@code{a-diocst.ads})
23048
23049
23050 @geindex Ada.Direct_IO.C_Streams (a-diocst.ads)
23051
23052 @geindex C Streams
23053 @geindex Interfacing with Direct_IO
23054
23055 This package provides subprograms that allow interfacing between
23056 C streams and @code{Direct_IO}. The stream identifier can be
23057 extracted from a file opened on the Ada side, and an Ada file
23058 can be constructed from a stream opened on the C side.
23059
23060 @node Ada Exceptions Is_Null_Occurrence a-einuoc ads,Ada Exceptions Last_Chance_Handler a-elchha ads,Ada Direct_IO C_Streams a-diocst ads,The GNAT Library
23061 @anchor{gnat_rm/the_gnat_library id22}@anchor{2fb}@anchor{gnat_rm/the_gnat_library ada-exceptions-is-null-occurrence-a-einuoc-ads}@anchor{2fc}
23062 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@code{a-einuoc.ads})
23063
23064
23065 @geindex Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
23066
23067 @geindex Null_Occurrence
23068 @geindex testing for
23069
23070 This child subprogram provides a way of testing for the null
23071 exception occurrence (@code{Null_Occurrence}) without raising
23072 an exception.
23073
23074 @node Ada Exceptions Last_Chance_Handler a-elchha ads,Ada Exceptions Traceback a-exctra ads,Ada Exceptions Is_Null_Occurrence a-einuoc ads,The GNAT Library
23075 @anchor{gnat_rm/the_gnat_library id23}@anchor{2fd}@anchor{gnat_rm/the_gnat_library ada-exceptions-last-chance-handler-a-elchha-ads}@anchor{2fe}
23076 @section @code{Ada.Exceptions.Last_Chance_Handler} (@code{a-elchha.ads})
23077
23078
23079 @geindex Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
23080
23081 @geindex Null_Occurrence
23082 @geindex testing for
23083
23084 This child subprogram is used for handling otherwise unhandled
23085 exceptions (hence the name last chance), and perform clean ups before
23086 terminating the program. Note that this subprogram never returns.
23087
23088 @node Ada Exceptions Traceback a-exctra ads,Ada Sequential_IO C_Streams a-siocst ads,Ada Exceptions Last_Chance_Handler a-elchha ads,The GNAT Library
23089 @anchor{gnat_rm/the_gnat_library ada-exceptions-traceback-a-exctra-ads}@anchor{2ff}@anchor{gnat_rm/the_gnat_library id24}@anchor{300}
23090 @section @code{Ada.Exceptions.Traceback} (@code{a-exctra.ads})
23091
23092
23093 @geindex Ada.Exceptions.Traceback (a-exctra.ads)
23094
23095 @geindex Traceback for Exception Occurrence
23096
23097 This child package provides the subprogram (@code{Tracebacks}) to
23098 give a traceback array of addresses based on an exception
23099 occurrence.
23100
23101 @node Ada Sequential_IO C_Streams a-siocst ads,Ada Streams Stream_IO C_Streams a-ssicst ads,Ada Exceptions Traceback a-exctra ads,The GNAT Library
23102 @anchor{gnat_rm/the_gnat_library ada-sequential-io-c-streams-a-siocst-ads}@anchor{301}@anchor{gnat_rm/the_gnat_library id25}@anchor{302}
23103 @section @code{Ada.Sequential_IO.C_Streams} (@code{a-siocst.ads})
23104
23105
23106 @geindex Ada.Sequential_IO.C_Streams (a-siocst.ads)
23107
23108 @geindex C Streams
23109 @geindex Interfacing with Sequential_IO
23110
23111 This package provides subprograms that allow interfacing between
23112 C streams and @code{Sequential_IO}. The stream identifier can be
23113 extracted from a file opened on the Ada side, and an Ada file
23114 can be constructed from a stream opened on the C side.
23115
23116 @node Ada Streams Stream_IO C_Streams a-ssicst ads,Ada Strings Unbounded Text_IO a-suteio ads,Ada Sequential_IO C_Streams a-siocst ads,The GNAT Library
23117 @anchor{gnat_rm/the_gnat_library id26}@anchor{303}@anchor{gnat_rm/the_gnat_library ada-streams-stream-io-c-streams-a-ssicst-ads}@anchor{304}
23118 @section @code{Ada.Streams.Stream_IO.C_Streams} (@code{a-ssicst.ads})
23119
23120
23121 @geindex Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
23122
23123 @geindex C Streams
23124 @geindex Interfacing with Stream_IO
23125
23126 This package provides subprograms that allow interfacing between
23127 C streams and @code{Stream_IO}. The stream identifier can be
23128 extracted from a file opened on the Ada side, and an Ada file
23129 can be constructed from a stream opened on the C side.
23130
23131 @node Ada Strings Unbounded Text_IO a-suteio ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,Ada Streams Stream_IO C_Streams a-ssicst ads,The GNAT Library
23132 @anchor{gnat_rm/the_gnat_library ada-strings-unbounded-text-io-a-suteio-ads}@anchor{305}@anchor{gnat_rm/the_gnat_library id27}@anchor{306}
23133 @section @code{Ada.Strings.Unbounded.Text_IO} (@code{a-suteio.ads})
23134
23135
23136 @geindex Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
23137
23138 @geindex Unbounded_String
23139 @geindex IO support
23140
23141 @geindex Text_IO
23142 @geindex extensions for unbounded strings
23143
23144 This package provides subprograms for Text_IO for unbounded
23145 strings, avoiding the necessity for an intermediate operation
23146 with ordinary strings.
23147
23148 @node Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Strings Unbounded Text_IO a-suteio ads,The GNAT Library
23149 @anchor{gnat_rm/the_gnat_library id28}@anchor{307}@anchor{gnat_rm/the_gnat_library ada-strings-wide-unbounded-wide-text-io-a-swuwti-ads}@anchor{308}
23150 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@code{a-swuwti.ads})
23151
23152
23153 @geindex Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
23154
23155 @geindex Unbounded_Wide_String
23156 @geindex IO support
23157
23158 @geindex Text_IO
23159 @geindex extensions for unbounded wide strings
23160
23161 This package provides subprograms for Text_IO for unbounded
23162 wide strings, avoiding the necessity for an intermediate operation
23163 with ordinary wide strings.
23164
23165 @node Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Task_Initialization a-tasini ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,The GNAT Library
23166 @anchor{gnat_rm/the_gnat_library id29}@anchor{309}@anchor{gnat_rm/the_gnat_library ada-strings-wide-wide-unbounded-wide-wide-text-io-a-szuzti-ads}@anchor{30a}
23167 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@code{a-szuzti.ads})
23168
23169
23170 @geindex Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
23171
23172 @geindex Unbounded_Wide_Wide_String
23173 @geindex IO support
23174
23175 @geindex Text_IO
23176 @geindex extensions for unbounded wide wide strings
23177
23178 This package provides subprograms for Text_IO for unbounded
23179 wide wide strings, avoiding the necessity for an intermediate operation
23180 with ordinary wide wide strings.
23181
23182 @node Ada Task_Initialization a-tasini ads,Ada Text_IO C_Streams a-tiocst ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,The GNAT Library
23183 @anchor{gnat_rm/the_gnat_library ada-task-initialization-a-tasini-ads}@anchor{30b}@anchor{gnat_rm/the_gnat_library id30}@anchor{30c}
23184 @section @code{Ada.Task_Initialization} (@code{a-tasini.ads})
23185
23186
23187 @geindex Ada.Task_Initialization (a-tasini.ads)
23188
23189 This package provides a way to set a global initialization handler that
23190 is automatically invoked whenever a task is activated. Handlers are
23191 parameterless procedures. Note that such a handler is only invoked for
23192 those tasks activated after the handler is set.
23193
23194 @node Ada Text_IO C_Streams a-tiocst ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Task_Initialization a-tasini ads,The GNAT Library
23195 @anchor{gnat_rm/the_gnat_library ada-text-io-c-streams-a-tiocst-ads}@anchor{30d}@anchor{gnat_rm/the_gnat_library id31}@anchor{30e}
23196 @section @code{Ada.Text_IO.C_Streams} (@code{a-tiocst.ads})
23197
23198
23199 @geindex Ada.Text_IO.C_Streams (a-tiocst.ads)
23200
23201 @geindex C Streams
23202 @geindex Interfacing with `@w{`}Text_IO`@w{`}
23203
23204 This package provides subprograms that allow interfacing between
23205 C streams and @code{Text_IO}. The stream identifier can be
23206 extracted from a file opened on the Ada side, and an Ada file
23207 can be constructed from a stream opened on the C side.
23208
23209 @node Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Wide_Characters Unicode a-wichun ads,Ada Text_IO C_Streams a-tiocst ads,The GNAT Library
23210 @anchor{gnat_rm/the_gnat_library ada-text-io-reset-standard-files-a-tirsfi-ads}@anchor{30f}@anchor{gnat_rm/the_gnat_library id32}@anchor{310}
23211 @section @code{Ada.Text_IO.Reset_Standard_Files} (@code{a-tirsfi.ads})
23212
23213
23214 @geindex Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
23215
23216 @geindex Text_IO resetting standard files
23217
23218 This procedure is used to reset the status of the standard files used
23219 by Ada.Text_IO. This is useful in a situation (such as a restart in an
23220 embedded application) where the status of the files may change during
23221 execution (for example a standard input file may be redefined to be
23222 interactive).
23223
23224 @node Ada Wide_Characters Unicode a-wichun ads,Ada Wide_Text_IO C_Streams a-wtcstr ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,The GNAT Library
23225 @anchor{gnat_rm/the_gnat_library id33}@anchor{311}@anchor{gnat_rm/the_gnat_library ada-wide-characters-unicode-a-wichun-ads}@anchor{312}
23226 @section @code{Ada.Wide_Characters.Unicode} (@code{a-wichun.ads})
23227
23228
23229 @geindex Ada.Wide_Characters.Unicode (a-wichun.ads)
23230
23231 @geindex Unicode categorization
23232 @geindex Wide_Character
23233
23234 This package provides subprograms that allow categorization of
23235 Wide_Character values according to Unicode categories.
23236
23237 @node Ada Wide_Text_IO C_Streams a-wtcstr ads,Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,Ada Wide_Characters Unicode a-wichun ads,The GNAT Library
23238 @anchor{gnat_rm/the_gnat_library id34}@anchor{313}@anchor{gnat_rm/the_gnat_library ada-wide-text-io-c-streams-a-wtcstr-ads}@anchor{314}
23239 @section @code{Ada.Wide_Text_IO.C_Streams} (@code{a-wtcstr.ads})
23240
23241
23242 @geindex Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
23243
23244 @geindex C Streams
23245 @geindex Interfacing with `@w{`}Wide_Text_IO`@w{`}
23246
23247 This package provides subprograms that allow interfacing between
23248 C streams and @code{Wide_Text_IO}. The stream identifier can be
23249 extracted from a file opened on the Ada side, and an Ada file
23250 can be constructed from a stream opened on the C side.
23251
23252 @node Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,Ada Wide_Wide_Characters Unicode a-zchuni ads,Ada Wide_Text_IO C_Streams a-wtcstr ads,The GNAT Library
23253 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-reset-standard-files-a-wrstfi-ads}@anchor{315}@anchor{gnat_rm/the_gnat_library id35}@anchor{316}
23254 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@code{a-wrstfi.ads})
23255
23256
23257 @geindex Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
23258
23259 @geindex Wide_Text_IO resetting standard files
23260
23261 This procedure is used to reset the status of the standard files used
23262 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
23263 embedded application) where the status of the files may change during
23264 execution (for example a standard input file may be redefined to be
23265 interactive).
23266
23267 @node Ada Wide_Wide_Characters Unicode a-zchuni ads,Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads,The GNAT Library
23268 @anchor{gnat_rm/the_gnat_library id36}@anchor{317}@anchor{gnat_rm/the_gnat_library ada-wide-wide-characters-unicode-a-zchuni-ads}@anchor{318}
23269 @section @code{Ada.Wide_Wide_Characters.Unicode} (@code{a-zchuni.ads})
23270
23271
23272 @geindex Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
23273
23274 @geindex Unicode categorization
23275 @geindex Wide_Wide_Character
23276
23277 This package provides subprograms that allow categorization of
23278 Wide_Wide_Character values according to Unicode categories.
23279
23280 @node Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,Ada Wide_Wide_Characters Unicode a-zchuni ads,The GNAT Library
23281 @anchor{gnat_rm/the_gnat_library id37}@anchor{319}@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-c-streams-a-ztcstr-ads}@anchor{31a}
23282 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@code{a-ztcstr.ads})
23283
23284
23285 @geindex Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
23286
23287 @geindex C Streams
23288 @geindex Interfacing with `@w{`}Wide_Wide_Text_IO`@w{`}
23289
23290 This package provides subprograms that allow interfacing between
23291 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
23292 extracted from a file opened on the Ada side, and an Ada file
23293 can be constructed from a stream opened on the C side.
23294
23295 @node Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,GNAT Altivec g-altive ads,Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads,The GNAT Library
23296 @anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-reset-standard-files-a-zrstfi-ads}@anchor{31b}@anchor{gnat_rm/the_gnat_library id38}@anchor{31c}
23297 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@code{a-zrstfi.ads})
23298
23299
23300 @geindex Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
23301
23302 @geindex Wide_Wide_Text_IO resetting standard files
23303
23304 This procedure is used to reset the status of the standard files used
23305 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
23306 restart in an embedded application) where the status of the files may
23307 change during execution (for example a standard input file may be
23308 redefined to be interactive).
23309
23310 @node GNAT Altivec g-altive ads,GNAT Altivec Conversions g-altcon ads,Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads,The GNAT Library
23311 @anchor{gnat_rm/the_gnat_library gnat-altivec-g-altive-ads}@anchor{31d}@anchor{gnat_rm/the_gnat_library id39}@anchor{31e}
23312 @section @code{GNAT.Altivec} (@code{g-altive.ads})
23313
23314
23315 @geindex GNAT.Altivec (g-altive.ads)
23316
23317 @geindex AltiVec
23318
23319 This is the root package of the GNAT AltiVec binding. It provides
23320 definitions of constants and types common to all the versions of the
23321 binding.
23322
23323 @node GNAT Altivec Conversions g-altcon ads,GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec g-altive ads,The GNAT Library
23324 @anchor{gnat_rm/the_gnat_library gnat-altivec-conversions-g-altcon-ads}@anchor{31f}@anchor{gnat_rm/the_gnat_library id40}@anchor{320}
23325 @section @code{GNAT.Altivec.Conversions} (@code{g-altcon.ads})
23326
23327
23328 @geindex GNAT.Altivec.Conversions (g-altcon.ads)
23329
23330 @geindex AltiVec
23331
23332 This package provides the Vector/View conversion routines.
23333
23334 @node GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Conversions g-altcon ads,The GNAT Library
23335 @anchor{gnat_rm/the_gnat_library id41}@anchor{321}@anchor{gnat_rm/the_gnat_library gnat-altivec-vector-operations-g-alveop-ads}@anchor{322}
23336 @section @code{GNAT.Altivec.Vector_Operations} (@code{g-alveop.ads})
23337
23338
23339 @geindex GNAT.Altivec.Vector_Operations (g-alveop.ads)
23340
23341 @geindex AltiVec
23342
23343 This package exposes the Ada interface to the AltiVec operations on
23344 vector objects. A soft emulation is included by default in the GNAT
23345 library. The hard binding is provided as a separate package. This unit
23346 is common to both bindings.
23347
23348 @node GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Vector_Views g-alvevi ads,GNAT Altivec Vector_Operations g-alveop ads,The GNAT Library
23349 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-types-g-alvety-ads}@anchor{323}@anchor{gnat_rm/the_gnat_library id42}@anchor{324}
23350 @section @code{GNAT.Altivec.Vector_Types} (@code{g-alvety.ads})
23351
23352
23353 @geindex GNAT.Altivec.Vector_Types (g-alvety.ads)
23354
23355 @geindex AltiVec
23356
23357 This package exposes the various vector types part of the Ada binding
23358 to AltiVec facilities.
23359
23360 @node GNAT Altivec Vector_Views g-alvevi ads,GNAT Array_Split g-arrspl ads,GNAT Altivec Vector_Types g-alvety ads,The GNAT Library
23361 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-views-g-alvevi-ads}@anchor{325}@anchor{gnat_rm/the_gnat_library id43}@anchor{326}
23362 @section @code{GNAT.Altivec.Vector_Views} (@code{g-alvevi.ads})
23363
23364
23365 @geindex GNAT.Altivec.Vector_Views (g-alvevi.ads)
23366
23367 @geindex AltiVec
23368
23369 This package provides public 'View' data types from/to which private
23370 vector representations can be converted via
23371 GNAT.Altivec.Conversions. This allows convenient access to individual
23372 vector elements and provides a simple way to initialize vector
23373 objects.
23374
23375 @node GNAT Array_Split g-arrspl ads,GNAT AWK g-awk ads,GNAT Altivec Vector_Views g-alvevi ads,The GNAT Library
23376 @anchor{gnat_rm/the_gnat_library gnat-array-split-g-arrspl-ads}@anchor{327}@anchor{gnat_rm/the_gnat_library id44}@anchor{328}
23377 @section @code{GNAT.Array_Split} (@code{g-arrspl.ads})
23378
23379
23380 @geindex GNAT.Array_Split (g-arrspl.ads)
23381
23382 @geindex Array splitter
23383
23384 Useful array-manipulation routines: given a set of separators, split
23385 an array wherever the separators appear, and provide direct access
23386 to the resulting slices.
23387
23388 @node GNAT AWK g-awk ads,GNAT Bind_Environment g-binenv ads,GNAT Array_Split g-arrspl ads,The GNAT Library
23389 @anchor{gnat_rm/the_gnat_library id45}@anchor{329}@anchor{gnat_rm/the_gnat_library gnat-awk-g-awk-ads}@anchor{32a}
23390 @section @code{GNAT.AWK} (@code{g-awk.ads})
23391
23392
23393 @geindex GNAT.AWK (g-awk.ads)
23394
23395 @geindex Parsing
23396
23397 @geindex AWK
23398
23399 Provides AWK-like parsing functions, with an easy interface for parsing one
23400 or more files containing formatted data. The file is viewed as a database
23401 where each record is a line and a field is a data element in this line.
23402
23403 @node GNAT Bind_Environment g-binenv ads,GNAT Branch_Prediction g-brapre ads,GNAT AWK g-awk ads,The GNAT Library
23404 @anchor{gnat_rm/the_gnat_library id46}@anchor{32b}@anchor{gnat_rm/the_gnat_library gnat-bind-environment-g-binenv-ads}@anchor{32c}
23405 @section @code{GNAT.Bind_Environment} (@code{g-binenv.ads})
23406
23407
23408 @geindex GNAT.Bind_Environment (g-binenv.ads)
23409
23410 @geindex Bind environment
23411
23412 Provides access to key=value associations captured at bind time.
23413 These associations can be specified using the @code{-V} binder command
23414 line switch.
23415
23416 @node GNAT Branch_Prediction g-brapre ads,GNAT Bounded_Buffers g-boubuf ads,GNAT Bind_Environment g-binenv ads,The GNAT Library
23417 @anchor{gnat_rm/the_gnat_library id47}@anchor{32d}@anchor{gnat_rm/the_gnat_library gnat-branch-prediction-g-brapre-ads}@anchor{32e}
23418 @section @code{GNAT.Branch_Prediction} (@code{g-brapre.ads})
23419
23420
23421 @geindex GNAT.Branch_Prediction (g-brapre.ads)
23422
23423 @geindex Branch Prediction
23424
23425 Provides routines giving hints to the branch predictor of the code generator.
23426
23427 @node GNAT Bounded_Buffers g-boubuf ads,GNAT Bounded_Mailboxes g-boumai ads,GNAT Branch_Prediction g-brapre ads,The GNAT Library
23428 @anchor{gnat_rm/the_gnat_library gnat-bounded-buffers-g-boubuf-ads}@anchor{32f}@anchor{gnat_rm/the_gnat_library id48}@anchor{330}
23429 @section @code{GNAT.Bounded_Buffers} (@code{g-boubuf.ads})
23430
23431
23432 @geindex GNAT.Bounded_Buffers (g-boubuf.ads)
23433
23434 @geindex Parsing
23435
23436 @geindex Bounded Buffers
23437
23438 Provides a concurrent generic bounded buffer abstraction. Instances are
23439 useful directly or as parts of the implementations of other abstractions,
23440 such as mailboxes.
23441
23442 @node GNAT Bounded_Mailboxes g-boumai ads,GNAT Bubble_Sort g-bubsor ads,GNAT Bounded_Buffers g-boubuf ads,The GNAT Library
23443 @anchor{gnat_rm/the_gnat_library gnat-bounded-mailboxes-g-boumai-ads}@anchor{331}@anchor{gnat_rm/the_gnat_library id49}@anchor{332}
23444 @section @code{GNAT.Bounded_Mailboxes} (@code{g-boumai.ads})
23445
23446
23447 @geindex GNAT.Bounded_Mailboxes (g-boumai.ads)
23448
23449 @geindex Parsing
23450
23451 @geindex Mailboxes
23452
23453 Provides a thread-safe asynchronous intertask mailbox communication facility.
23454
23455 @node GNAT Bubble_Sort g-bubsor ads,GNAT Bubble_Sort_A g-busora ads,GNAT Bounded_Mailboxes g-boumai ads,The GNAT Library
23456 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-bubsor-ads}@anchor{333}@anchor{gnat_rm/the_gnat_library id50}@anchor{334}
23457 @section @code{GNAT.Bubble_Sort} (@code{g-bubsor.ads})
23458
23459
23460 @geindex GNAT.Bubble_Sort (g-bubsor.ads)
23461
23462 @geindex Sorting
23463
23464 @geindex Bubble sort
23465
23466 Provides a general implementation of bubble sort usable for sorting arbitrary
23467 data items. Exchange and comparison procedures are provided by passing
23468 access-to-procedure values.
23469
23470 @node GNAT Bubble_Sort_A g-busora ads,GNAT Bubble_Sort_G g-busorg ads,GNAT Bubble_Sort g-bubsor ads,The GNAT Library
23471 @anchor{gnat_rm/the_gnat_library id51}@anchor{335}@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-a-g-busora-ads}@anchor{336}
23472 @section @code{GNAT.Bubble_Sort_A} (@code{g-busora.ads})
23473
23474
23475 @geindex GNAT.Bubble_Sort_A (g-busora.ads)
23476
23477 @geindex Sorting
23478
23479 @geindex Bubble sort
23480
23481 Provides a general implementation of bubble sort usable for sorting arbitrary
23482 data items. Move and comparison procedures are provided by passing
23483 access-to-procedure values. This is an older version, retained for
23484 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
23485
23486 @node GNAT Bubble_Sort_G g-busorg ads,GNAT Byte_Order_Mark g-byorma ads,GNAT Bubble_Sort_A g-busora ads,The GNAT Library
23487 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-g-busorg-ads}@anchor{337}@anchor{gnat_rm/the_gnat_library id52}@anchor{338}
23488 @section @code{GNAT.Bubble_Sort_G} (@code{g-busorg.ads})
23489
23490
23491 @geindex GNAT.Bubble_Sort_G (g-busorg.ads)
23492
23493 @geindex Sorting
23494
23495 @geindex Bubble sort
23496
23497 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
23498 are provided as generic parameters, this improves efficiency, especially
23499 if the procedures can be inlined, at the expense of duplicating code for
23500 multiple instantiations.
23501
23502 @node GNAT Byte_Order_Mark g-byorma ads,GNAT Byte_Swapping g-bytswa ads,GNAT Bubble_Sort_G g-busorg ads,The GNAT Library
23503 @anchor{gnat_rm/the_gnat_library gnat-byte-order-mark-g-byorma-ads}@anchor{339}@anchor{gnat_rm/the_gnat_library id53}@anchor{33a}
23504 @section @code{GNAT.Byte_Order_Mark} (@code{g-byorma.ads})
23505
23506
23507 @geindex GNAT.Byte_Order_Mark (g-byorma.ads)
23508
23509 @geindex UTF-8 representation
23510
23511 @geindex Wide characte representations
23512
23513 Provides a routine which given a string, reads the start of the string to
23514 see whether it is one of the standard byte order marks (BOM's) which signal
23515 the encoding of the string. The routine includes detection of special XML
23516 sequences for various UCS input formats.
23517
23518 @node GNAT Byte_Swapping g-bytswa ads,GNAT Calendar g-calend ads,GNAT Byte_Order_Mark g-byorma ads,The GNAT Library
23519 @anchor{gnat_rm/the_gnat_library gnat-byte-swapping-g-bytswa-ads}@anchor{33b}@anchor{gnat_rm/the_gnat_library id54}@anchor{33c}
23520 @section @code{GNAT.Byte_Swapping} (@code{g-bytswa.ads})
23521
23522
23523 @geindex GNAT.Byte_Swapping (g-bytswa.ads)
23524
23525 @geindex Byte swapping
23526
23527 @geindex Endianness
23528
23529 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
23530 Machine-specific implementations are available in some cases.
23531
23532 @node GNAT Calendar g-calend ads,GNAT Calendar Time_IO g-catiio ads,GNAT Byte_Swapping g-bytswa ads,The GNAT Library
23533 @anchor{gnat_rm/the_gnat_library id55}@anchor{33d}@anchor{gnat_rm/the_gnat_library gnat-calendar-g-calend-ads}@anchor{33e}
23534 @section @code{GNAT.Calendar} (@code{g-calend.ads})
23535
23536
23537 @geindex GNAT.Calendar (g-calend.ads)
23538
23539 @geindex Calendar
23540
23541 Extends the facilities provided by @code{Ada.Calendar} to include handling
23542 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
23543 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
23544 C @code{timeval} format.
23545
23546 @node GNAT Calendar Time_IO g-catiio ads,GNAT CRC32 g-crc32 ads,GNAT Calendar g-calend ads,The GNAT Library
23547 @anchor{gnat_rm/the_gnat_library id56}@anchor{33f}@anchor{gnat_rm/the_gnat_library gnat-calendar-time-io-g-catiio-ads}@anchor{340}
23548 @section @code{GNAT.Calendar.Time_IO} (@code{g-catiio.ads})
23549
23550
23551 @geindex Calendar
23552
23553 @geindex Time
23554
23555 @geindex GNAT.Calendar.Time_IO (g-catiio.ads)
23556
23557 @node GNAT CRC32 g-crc32 ads,GNAT Case_Util g-casuti ads,GNAT Calendar Time_IO g-catiio ads,The GNAT Library
23558 @anchor{gnat_rm/the_gnat_library id57}@anchor{341}@anchor{gnat_rm/the_gnat_library gnat-crc32-g-crc32-ads}@anchor{342}
23559 @section @code{GNAT.CRC32} (@code{g-crc32.ads})
23560
23561
23562 @geindex GNAT.CRC32 (g-crc32.ads)
23563
23564 @geindex CRC32
23565
23566 @geindex Cyclic Redundancy Check
23567
23568 This package implements the CRC-32 algorithm. For a full description
23569 of this algorithm see
23570 @emph{Computation of Cyclic Redundancy Checks via Table Look-Up},
23571 @cite{Communications of the ACM}, Vol. 31 No. 8, pp. 1008-1013,
23572 Aug. 1988. Sarwate, D.V.
23573
23574 @node GNAT Case_Util g-casuti ads,GNAT CGI g-cgi ads,GNAT CRC32 g-crc32 ads,The GNAT Library
23575 @anchor{gnat_rm/the_gnat_library id58}@anchor{343}@anchor{gnat_rm/the_gnat_library gnat-case-util-g-casuti-ads}@anchor{344}
23576 @section @code{GNAT.Case_Util} (@code{g-casuti.ads})
23577
23578
23579 @geindex GNAT.Case_Util (g-casuti.ads)
23580
23581 @geindex Casing utilities
23582
23583 @geindex Character handling (`@w{`}GNAT.Case_Util`@w{`})
23584
23585 A set of simple routines for handling upper and lower casing of strings
23586 without the overhead of the full casing tables
23587 in @code{Ada.Characters.Handling}.
23588
23589 @node GNAT CGI g-cgi ads,GNAT CGI Cookie g-cgicoo ads,GNAT Case_Util g-casuti ads,The GNAT Library
23590 @anchor{gnat_rm/the_gnat_library id59}@anchor{345}@anchor{gnat_rm/the_gnat_library gnat-cgi-g-cgi-ads}@anchor{346}
23591 @section @code{GNAT.CGI} (@code{g-cgi.ads})
23592
23593
23594 @geindex GNAT.CGI (g-cgi.ads)
23595
23596 @geindex CGI (Common Gateway Interface)
23597
23598 This is a package for interfacing a GNAT program with a Web server via the
23599 Common Gateway Interface (CGI). Basically this package parses the CGI
23600 parameters, which are a set of key/value pairs sent by the Web server. It
23601 builds a table whose index is the key and provides some services to deal
23602 with this table.
23603
23604 @node GNAT CGI Cookie g-cgicoo ads,GNAT CGI Debug g-cgideb ads,GNAT CGI g-cgi ads,The GNAT Library
23605 @anchor{gnat_rm/the_gnat_library gnat-cgi-cookie-g-cgicoo-ads}@anchor{347}@anchor{gnat_rm/the_gnat_library id60}@anchor{348}
23606 @section @code{GNAT.CGI.Cookie} (@code{g-cgicoo.ads})
23607
23608
23609 @geindex GNAT.CGI.Cookie (g-cgicoo.ads)
23610
23611 @geindex CGI (Common Gateway Interface) cookie support
23612
23613 @geindex Cookie support in CGI
23614
23615 This is a package to interface a GNAT program with a Web server via the
23616 Common Gateway Interface (CGI). It exports services to deal with Web
23617 cookies (piece of information kept in the Web client software).
23618
23619 @node GNAT CGI Debug g-cgideb ads,GNAT Command_Line g-comlin ads,GNAT CGI Cookie g-cgicoo ads,The GNAT Library
23620 @anchor{gnat_rm/the_gnat_library gnat-cgi-debug-g-cgideb-ads}@anchor{349}@anchor{gnat_rm/the_gnat_library id61}@anchor{34a}
23621 @section @code{GNAT.CGI.Debug} (@code{g-cgideb.ads})
23622
23623
23624 @geindex GNAT.CGI.Debug (g-cgideb.ads)
23625
23626 @geindex CGI (Common Gateway Interface) debugging
23627
23628 This is a package to help debugging CGI (Common Gateway Interface)
23629 programs written in Ada.
23630
23631 @node GNAT Command_Line g-comlin ads,GNAT Compiler_Version g-comver ads,GNAT CGI Debug g-cgideb ads,The GNAT Library
23632 @anchor{gnat_rm/the_gnat_library id62}@anchor{34b}@anchor{gnat_rm/the_gnat_library gnat-command-line-g-comlin-ads}@anchor{34c}
23633 @section @code{GNAT.Command_Line} (@code{g-comlin.ads})
23634
23635
23636 @geindex GNAT.Command_Line (g-comlin.ads)
23637
23638 @geindex Command line
23639
23640 Provides a high level interface to @code{Ada.Command_Line} facilities,
23641 including the ability to scan for named switches with optional parameters
23642 and expand file names using wildcard notations.
23643
23644 @node GNAT Compiler_Version g-comver ads,GNAT Ctrl_C g-ctrl_c ads,GNAT Command_Line g-comlin ads,The GNAT Library
23645 @anchor{gnat_rm/the_gnat_library gnat-compiler-version-g-comver-ads}@anchor{34d}@anchor{gnat_rm/the_gnat_library id63}@anchor{34e}
23646 @section @code{GNAT.Compiler_Version} (@code{g-comver.ads})
23647
23648
23649 @geindex GNAT.Compiler_Version (g-comver.ads)
23650
23651 @geindex Compiler Version
23652
23653 @geindex Version
23654 @geindex of compiler
23655
23656 Provides a routine for obtaining the version of the compiler used to
23657 compile the program. More accurately this is the version of the binder
23658 used to bind the program (this will normally be the same as the version
23659 of the compiler if a consistent tool set is used to compile all units
23660 of a partition).
23661
23662 @node GNAT Ctrl_C g-ctrl_c ads,GNAT Current_Exception g-curexc ads,GNAT Compiler_Version g-comver ads,The GNAT Library
23663 @anchor{gnat_rm/the_gnat_library id64}@anchor{34f}@anchor{gnat_rm/the_gnat_library gnat-ctrl-c-g-ctrl-c-ads}@anchor{350}
23664 @section @code{GNAT.Ctrl_C} (@code{g-ctrl_c.ads})
23665
23666
23667 @geindex GNAT.Ctrl_C (g-ctrl_c.ads)
23668
23669 @geindex Interrupt
23670
23671 Provides a simple interface to handle Ctrl-C keyboard events.
23672
23673 @node GNAT Current_Exception g-curexc ads,GNAT Debug_Pools g-debpoo ads,GNAT Ctrl_C g-ctrl_c ads,The GNAT Library
23674 @anchor{gnat_rm/the_gnat_library id65}@anchor{351}@anchor{gnat_rm/the_gnat_library gnat-current-exception-g-curexc-ads}@anchor{352}
23675 @section @code{GNAT.Current_Exception} (@code{g-curexc.ads})
23676
23677
23678 @geindex GNAT.Current_Exception (g-curexc.ads)
23679
23680 @geindex Current exception
23681
23682 @geindex Exception retrieval
23683
23684 Provides access to information on the current exception that has been raised
23685 without the need for using the Ada 95 / Ada 2005 exception choice parameter
23686 specification syntax.
23687 This is particularly useful in simulating typical facilities for
23688 obtaining information about exceptions provided by Ada 83 compilers.
23689
23690 @node GNAT Debug_Pools g-debpoo ads,GNAT Debug_Utilities g-debuti ads,GNAT Current_Exception g-curexc ads,The GNAT Library
23691 @anchor{gnat_rm/the_gnat_library gnat-debug-pools-g-debpoo-ads}@anchor{353}@anchor{gnat_rm/the_gnat_library id66}@anchor{354}
23692 @section @code{GNAT.Debug_Pools} (@code{g-debpoo.ads})
23693
23694
23695 @geindex GNAT.Debug_Pools (g-debpoo.ads)
23696
23697 @geindex Debugging
23698
23699 @geindex Debug pools
23700
23701 @geindex Memory corruption debugging
23702
23703 Provide a debugging storage pools that helps tracking memory corruption
23704 problems.
23705 See @code{The GNAT Debug_Pool Facility} section in the @cite{GNAT User's Guide}.
23706
23707 @node GNAT Debug_Utilities g-debuti ads,GNAT Decode_String g-decstr ads,GNAT Debug_Pools g-debpoo ads,The GNAT Library
23708 @anchor{gnat_rm/the_gnat_library gnat-debug-utilities-g-debuti-ads}@anchor{355}@anchor{gnat_rm/the_gnat_library id67}@anchor{356}
23709 @section @code{GNAT.Debug_Utilities} (@code{g-debuti.ads})
23710
23711
23712 @geindex GNAT.Debug_Utilities (g-debuti.ads)
23713
23714 @geindex Debugging
23715
23716 Provides a few useful utilities for debugging purposes, including conversion
23717 to and from string images of address values. Supports both C and Ada formats
23718 for hexadecimal literals.
23719
23720 @node GNAT Decode_String g-decstr ads,GNAT Decode_UTF8_String g-deutst ads,GNAT Debug_Utilities g-debuti ads,The GNAT Library
23721 @anchor{gnat_rm/the_gnat_library gnat-decode-string-g-decstr-ads}@anchor{357}@anchor{gnat_rm/the_gnat_library id68}@anchor{358}
23722 @section @code{GNAT.Decode_String} (@code{g-decstr.ads})
23723
23724
23725 @geindex GNAT.Decode_String (g-decstr.ads)
23726
23727 @geindex Decoding strings
23728
23729 @geindex String decoding
23730
23731 @geindex Wide character encoding
23732
23733 @geindex UTF-8
23734
23735 @geindex Unicode
23736
23737 A generic package providing routines for decoding wide character and wide wide
23738 character strings encoded as sequences of 8-bit characters using a specified
23739 encoding method. Includes validation routines, and also routines for stepping
23740 to next or previous encoded character in an encoded string.
23741 Useful in conjunction with Unicode character coding. Note there is a
23742 preinstantiation for UTF-8. See next entry.
23743
23744 @node GNAT Decode_UTF8_String g-deutst ads,GNAT Directory_Operations g-dirope ads,GNAT Decode_String g-decstr ads,The GNAT Library
23745 @anchor{gnat_rm/the_gnat_library gnat-decode-utf8-string-g-deutst-ads}@anchor{359}@anchor{gnat_rm/the_gnat_library id69}@anchor{35a}
23746 @section @code{GNAT.Decode_UTF8_String} (@code{g-deutst.ads})
23747
23748
23749 @geindex GNAT.Decode_UTF8_String (g-deutst.ads)
23750
23751 @geindex Decoding strings
23752
23753 @geindex Decoding UTF-8 strings
23754
23755 @geindex UTF-8 string decoding
23756
23757 @geindex Wide character decoding
23758
23759 @geindex UTF-8
23760
23761 @geindex Unicode
23762
23763 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
23764
23765 @node GNAT Directory_Operations g-dirope ads,GNAT Directory_Operations Iteration g-diopit ads,GNAT Decode_UTF8_String g-deutst ads,The GNAT Library
23766 @anchor{gnat_rm/the_gnat_library id70}@anchor{35b}@anchor{gnat_rm/the_gnat_library gnat-directory-operations-g-dirope-ads}@anchor{35c}
23767 @section @code{GNAT.Directory_Operations} (@code{g-dirope.ads})
23768
23769
23770 @geindex GNAT.Directory_Operations (g-dirope.ads)
23771
23772 @geindex Directory operations
23773
23774 Provides a set of routines for manipulating directories, including changing
23775 the current directory, making new directories, and scanning the files in a
23776 directory.
23777
23778 @node GNAT Directory_Operations Iteration g-diopit ads,GNAT Dynamic_HTables g-dynhta ads,GNAT Directory_Operations g-dirope ads,The GNAT Library
23779 @anchor{gnat_rm/the_gnat_library id71}@anchor{35d}@anchor{gnat_rm/the_gnat_library gnat-directory-operations-iteration-g-diopit-ads}@anchor{35e}
23780 @section @code{GNAT.Directory_Operations.Iteration} (@code{g-diopit.ads})
23781
23782
23783 @geindex GNAT.Directory_Operations.Iteration (g-diopit.ads)
23784
23785 @geindex Directory operations iteration
23786
23787 A child unit of GNAT.Directory_Operations providing additional operations
23788 for iterating through directories.
23789
23790 @node GNAT Dynamic_HTables g-dynhta ads,GNAT Dynamic_Tables g-dyntab ads,GNAT Directory_Operations Iteration g-diopit ads,The GNAT Library
23791 @anchor{gnat_rm/the_gnat_library id72}@anchor{35f}@anchor{gnat_rm/the_gnat_library gnat-dynamic-htables-g-dynhta-ads}@anchor{360}
23792 @section @code{GNAT.Dynamic_HTables} (@code{g-dynhta.ads})
23793
23794
23795 @geindex GNAT.Dynamic_HTables (g-dynhta.ads)
23796
23797 @geindex Hash tables
23798
23799 A generic implementation of hash tables that can be used to hash arbitrary
23800 data. Provided in two forms, a simple form with built in hash functions,
23801 and a more complex form in which the hash function is supplied.
23802
23803 This package provides a facility similar to that of @code{GNAT.HTable},
23804 except that this package declares a type that can be used to define
23805 dynamic instances of the hash table, while an instantiation of
23806 @code{GNAT.HTable} creates a single instance of the hash table.
23807
23808 @node GNAT Dynamic_Tables g-dyntab ads,GNAT Encode_String g-encstr ads,GNAT Dynamic_HTables g-dynhta ads,The GNAT Library
23809 @anchor{gnat_rm/the_gnat_library gnat-dynamic-tables-g-dyntab-ads}@anchor{361}@anchor{gnat_rm/the_gnat_library id73}@anchor{362}
23810 @section @code{GNAT.Dynamic_Tables} (@code{g-dyntab.ads})
23811
23812
23813 @geindex GNAT.Dynamic_Tables (g-dyntab.ads)
23814
23815 @geindex Table implementation
23816
23817 @geindex Arrays
23818 @geindex extendable
23819
23820 A generic package providing a single dimension array abstraction where the
23821 length of the array can be dynamically modified.
23822
23823 This package provides a facility similar to that of @code{GNAT.Table},
23824 except that this package declares a type that can be used to define
23825 dynamic instances of the table, while an instantiation of
23826 @code{GNAT.Table} creates a single instance of the table type.
23827
23828 @node GNAT Encode_String g-encstr ads,GNAT Encode_UTF8_String g-enutst ads,GNAT Dynamic_Tables g-dyntab ads,The GNAT Library
23829 @anchor{gnat_rm/the_gnat_library id74}@anchor{363}@anchor{gnat_rm/the_gnat_library gnat-encode-string-g-encstr-ads}@anchor{364}
23830 @section @code{GNAT.Encode_String} (@code{g-encstr.ads})
23831
23832
23833 @geindex GNAT.Encode_String (g-encstr.ads)
23834
23835 @geindex Encoding strings
23836
23837 @geindex String encoding
23838
23839 @geindex Wide character encoding
23840
23841 @geindex UTF-8
23842
23843 @geindex Unicode
23844
23845 A generic package providing routines for encoding wide character and wide
23846 wide character strings as sequences of 8-bit characters using a specified
23847 encoding method. Useful in conjunction with Unicode character coding.
23848 Note there is a preinstantiation for UTF-8. See next entry.
23849
23850 @node GNAT Encode_UTF8_String g-enutst ads,GNAT Exception_Actions g-excact ads,GNAT Encode_String g-encstr ads,The GNAT Library
23851 @anchor{gnat_rm/the_gnat_library gnat-encode-utf8-string-g-enutst-ads}@anchor{365}@anchor{gnat_rm/the_gnat_library id75}@anchor{366}
23852 @section @code{GNAT.Encode_UTF8_String} (@code{g-enutst.ads})
23853
23854
23855 @geindex GNAT.Encode_UTF8_String (g-enutst.ads)
23856
23857 @geindex Encoding strings
23858
23859 @geindex Encoding UTF-8 strings
23860
23861 @geindex UTF-8 string encoding
23862
23863 @geindex Wide character encoding
23864
23865 @geindex UTF-8
23866
23867 @geindex Unicode
23868
23869 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
23870
23871 @node GNAT Exception_Actions g-excact ads,GNAT Exception_Traces g-exctra ads,GNAT Encode_UTF8_String g-enutst ads,The GNAT Library
23872 @anchor{gnat_rm/the_gnat_library gnat-exception-actions-g-excact-ads}@anchor{367}@anchor{gnat_rm/the_gnat_library id76}@anchor{368}
23873 @section @code{GNAT.Exception_Actions} (@code{g-excact.ads})
23874
23875
23876 @geindex GNAT.Exception_Actions (g-excact.ads)
23877
23878 @geindex Exception actions
23879
23880 Provides callbacks when an exception is raised. Callbacks can be registered
23881 for specific exceptions, or when any exception is raised. This
23882 can be used for instance to force a core dump to ease debugging.
23883
23884 @node GNAT Exception_Traces g-exctra ads,GNAT Exceptions g-except ads,GNAT Exception_Actions g-excact ads,The GNAT Library
23885 @anchor{gnat_rm/the_gnat_library gnat-exception-traces-g-exctra-ads}@anchor{369}@anchor{gnat_rm/the_gnat_library id77}@anchor{36a}
23886 @section @code{GNAT.Exception_Traces} (@code{g-exctra.ads})
23887
23888
23889 @geindex GNAT.Exception_Traces (g-exctra.ads)
23890
23891 @geindex Exception traces
23892
23893 @geindex Debugging
23894
23895 Provides an interface allowing to control automatic output upon exception
23896 occurrences.
23897
23898 @node GNAT Exceptions g-except ads,GNAT Expect g-expect ads,GNAT Exception_Traces g-exctra ads,The GNAT Library
23899 @anchor{gnat_rm/the_gnat_library id78}@anchor{36b}@anchor{gnat_rm/the_gnat_library gnat-exceptions-g-except-ads}@anchor{36c}
23900 @section @code{GNAT.Exceptions} (@code{g-except.ads})
23901
23902
23903 @geindex GNAT.Exceptions (g-except.ads)
23904
23905 @geindex Exceptions
23906 @geindex Pure
23907
23908 @geindex Pure packages
23909 @geindex exceptions
23910
23911 Normally it is not possible to raise an exception with
23912 a message from a subprogram in a pure package, since the
23913 necessary types and subprograms are in @code{Ada.Exceptions}
23914 which is not a pure unit. @code{GNAT.Exceptions} provides a
23915 facility for getting around this limitation for a few
23916 predefined exceptions, and for example allow raising
23917 @code{Constraint_Error} with a message from a pure subprogram.
23918
23919 @node GNAT Expect g-expect ads,GNAT Expect TTY g-exptty ads,GNAT Exceptions g-except ads,The GNAT Library
23920 @anchor{gnat_rm/the_gnat_library id79}@anchor{36d}@anchor{gnat_rm/the_gnat_library gnat-expect-g-expect-ads}@anchor{36e}
23921 @section @code{GNAT.Expect} (@code{g-expect.ads})
23922
23923
23924 @geindex GNAT.Expect (g-expect.ads)
23925
23926 Provides a set of subprograms similar to what is available
23927 with the standard Tcl Expect tool.
23928 It allows you to easily spawn and communicate with an external process.
23929 You can send commands or inputs to the process, and compare the output
23930 with some expected regular expression. Currently @code{GNAT.Expect}
23931 is implemented on all native GNAT ports.
23932 It is not implemented for cross ports, and in particular is not
23933 implemented for VxWorks or LynxOS.
23934
23935 @node GNAT Expect TTY g-exptty ads,GNAT Float_Control g-flocon ads,GNAT Expect g-expect ads,The GNAT Library
23936 @anchor{gnat_rm/the_gnat_library id80}@anchor{36f}@anchor{gnat_rm/the_gnat_library gnat-expect-tty-g-exptty-ads}@anchor{370}
23937 @section @code{GNAT.Expect.TTY} (@code{g-exptty.ads})
23938
23939
23940 @geindex GNAT.Expect.TTY (g-exptty.ads)
23941
23942 As GNAT.Expect but using pseudo-terminal.
23943 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
23944 ports. It is not implemented for cross ports, and
23945 in particular is not implemented for VxWorks or LynxOS.
23946
23947 @node GNAT Float_Control g-flocon ads,GNAT Formatted_String g-forstr ads,GNAT Expect TTY g-exptty ads,The GNAT Library
23948 @anchor{gnat_rm/the_gnat_library id81}@anchor{371}@anchor{gnat_rm/the_gnat_library gnat-float-control-g-flocon-ads}@anchor{372}
23949 @section @code{GNAT.Float_Control} (@code{g-flocon.ads})
23950
23951
23952 @geindex GNAT.Float_Control (g-flocon.ads)
23953
23954 @geindex Floating-Point Processor
23955
23956 Provides an interface for resetting the floating-point processor into the
23957 mode required for correct semantic operation in Ada. Some third party
23958 library calls may cause this mode to be modified, and the Reset procedure
23959 in this package can be used to reestablish the required mode.
23960
23961 @node GNAT Formatted_String g-forstr ads,GNAT Heap_Sort g-heasor ads,GNAT Float_Control g-flocon ads,The GNAT Library
23962 @anchor{gnat_rm/the_gnat_library id82}@anchor{373}@anchor{gnat_rm/the_gnat_library gnat-formatted-string-g-forstr-ads}@anchor{374}
23963 @section @code{GNAT.Formatted_String} (@code{g-forstr.ads})
23964
23965
23966 @geindex GNAT.Formatted_String (g-forstr.ads)
23967
23968 @geindex Formatted String
23969
23970 Provides support for C/C++ printf() formatted strings. The format is
23971 copied from the printf() routine and should therefore gives identical
23972 output. Some generic routines are provided to be able to use types
23973 derived from Integer, Float or enumerations as values for the
23974 formatted string.
23975
23976 @node GNAT Heap_Sort g-heasor ads,GNAT Heap_Sort_A g-hesora ads,GNAT Formatted_String g-forstr ads,The GNAT Library
23977 @anchor{gnat_rm/the_gnat_library id83}@anchor{375}@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-heasor-ads}@anchor{376}
23978 @section @code{GNAT.Heap_Sort} (@code{g-heasor.ads})
23979
23980
23981 @geindex GNAT.Heap_Sort (g-heasor.ads)
23982
23983 @geindex Sorting
23984
23985 Provides a general implementation of heap sort usable for sorting arbitrary
23986 data items. Exchange and comparison procedures are provided by passing
23987 access-to-procedure values. The algorithm used is a modified heap sort
23988 that performs approximately N*log(N) comparisons in the worst case.
23989
23990 @node GNAT Heap_Sort_A g-hesora ads,GNAT Heap_Sort_G g-hesorg ads,GNAT Heap_Sort g-heasor ads,The GNAT Library
23991 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-a-g-hesora-ads}@anchor{377}@anchor{gnat_rm/the_gnat_library id84}@anchor{378}
23992 @section @code{GNAT.Heap_Sort_A} (@code{g-hesora.ads})
23993
23994
23995 @geindex GNAT.Heap_Sort_A (g-hesora.ads)
23996
23997 @geindex Sorting
23998
23999 Provides a general implementation of heap sort usable for sorting arbitrary
24000 data items. Move and comparison procedures are provided by passing
24001 access-to-procedure values. The algorithm used is a modified heap sort
24002 that performs approximately N*log(N) comparisons in the worst case.
24003 This differs from @code{GNAT.Heap_Sort} in having a less convenient
24004 interface, but may be slightly more efficient.
24005
24006 @node GNAT Heap_Sort_G g-hesorg ads,GNAT HTable g-htable ads,GNAT Heap_Sort_A g-hesora ads,The GNAT Library
24007 @anchor{gnat_rm/the_gnat_library id85}@anchor{379}@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-g-hesorg-ads}@anchor{37a}
24008 @section @code{GNAT.Heap_Sort_G} (@code{g-hesorg.ads})
24009
24010
24011 @geindex GNAT.Heap_Sort_G (g-hesorg.ads)
24012
24013 @geindex Sorting
24014
24015 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
24016 are provided as generic parameters, this improves efficiency, especially
24017 if the procedures can be inlined, at the expense of duplicating code for
24018 multiple instantiations.
24019
24020 @node GNAT HTable g-htable ads,GNAT IO g-io ads,GNAT Heap_Sort_G g-hesorg ads,The GNAT Library
24021 @anchor{gnat_rm/the_gnat_library id86}@anchor{37b}@anchor{gnat_rm/the_gnat_library gnat-htable-g-htable-ads}@anchor{37c}
24022 @section @code{GNAT.HTable} (@code{g-htable.ads})
24023
24024
24025 @geindex GNAT.HTable (g-htable.ads)
24026
24027 @geindex Hash tables
24028
24029 A generic implementation of hash tables that can be used to hash arbitrary
24030 data. Provides two approaches, one a simple static approach, and the other
24031 allowing arbitrary dynamic hash tables.
24032
24033 @node GNAT IO g-io ads,GNAT IO_Aux g-io_aux ads,GNAT HTable g-htable ads,The GNAT Library
24034 @anchor{gnat_rm/the_gnat_library id87}@anchor{37d}@anchor{gnat_rm/the_gnat_library gnat-io-g-io-ads}@anchor{37e}
24035 @section @code{GNAT.IO} (@code{g-io.ads})
24036
24037
24038 @geindex GNAT.IO (g-io.ads)
24039
24040 @geindex Simple I/O
24041
24042 @geindex Input/Output facilities
24043
24044 A simple preelaborable input-output package that provides a subset of
24045 simple Text_IO functions for reading characters and strings from
24046 Standard_Input, and writing characters, strings and integers to either
24047 Standard_Output or Standard_Error.
24048
24049 @node GNAT IO_Aux g-io_aux ads,GNAT Lock_Files g-locfil ads,GNAT IO g-io ads,The GNAT Library
24050 @anchor{gnat_rm/the_gnat_library id88}@anchor{37f}@anchor{gnat_rm/the_gnat_library gnat-io-aux-g-io-aux-ads}@anchor{380}
24051 @section @code{GNAT.IO_Aux} (@code{g-io_aux.ads})
24052
24053
24054 @geindex GNAT.IO_Aux (g-io_aux.ads)
24055
24056 @geindex Text_IO
24057
24058 @geindex Input/Output facilities
24059
24060 Provides some auxiliary functions for use with Text_IO, including a test
24061 for whether a file exists, and functions for reading a line of text.
24062
24063 @node GNAT Lock_Files g-locfil ads,GNAT MBBS_Discrete_Random g-mbdira ads,GNAT IO_Aux g-io_aux ads,The GNAT Library
24064 @anchor{gnat_rm/the_gnat_library id89}@anchor{381}@anchor{gnat_rm/the_gnat_library gnat-lock-files-g-locfil-ads}@anchor{382}
24065 @section @code{GNAT.Lock_Files} (@code{g-locfil.ads})
24066
24067
24068 @geindex GNAT.Lock_Files (g-locfil.ads)
24069
24070 @geindex File locking
24071
24072 @geindex Locking using files
24073
24074 Provides a general interface for using files as locks. Can be used for
24075 providing program level synchronization.
24076
24077 @node GNAT MBBS_Discrete_Random g-mbdira ads,GNAT MBBS_Float_Random g-mbflra ads,GNAT Lock_Files g-locfil ads,The GNAT Library
24078 @anchor{gnat_rm/the_gnat_library id90}@anchor{383}@anchor{gnat_rm/the_gnat_library gnat-mbbs-discrete-random-g-mbdira-ads}@anchor{384}
24079 @section @code{GNAT.MBBS_Discrete_Random} (@code{g-mbdira.ads})
24080
24081
24082 @geindex GNAT.MBBS_Discrete_Random (g-mbdira.ads)
24083
24084 @geindex Random number generation
24085
24086 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
24087 a modified version of the Blum-Blum-Shub generator.
24088
24089 @node GNAT MBBS_Float_Random g-mbflra ads,GNAT MD5 g-md5 ads,GNAT MBBS_Discrete_Random g-mbdira ads,The GNAT Library
24090 @anchor{gnat_rm/the_gnat_library id91}@anchor{385}@anchor{gnat_rm/the_gnat_library gnat-mbbs-float-random-g-mbflra-ads}@anchor{386}
24091 @section @code{GNAT.MBBS_Float_Random} (@code{g-mbflra.ads})
24092
24093
24094 @geindex GNAT.MBBS_Float_Random (g-mbflra.ads)
24095
24096 @geindex Random number generation
24097
24098 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
24099 a modified version of the Blum-Blum-Shub generator.
24100
24101 @node GNAT MD5 g-md5 ads,GNAT Memory_Dump g-memdum ads,GNAT MBBS_Float_Random g-mbflra ads,The GNAT Library
24102 @anchor{gnat_rm/the_gnat_library id92}@anchor{387}@anchor{gnat_rm/the_gnat_library gnat-md5-g-md5-ads}@anchor{388}
24103 @section @code{GNAT.MD5} (@code{g-md5.ads})
24104
24105
24106 @geindex GNAT.MD5 (g-md5.ads)
24107
24108 @geindex Message Digest MD5
24109
24110 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
24111 the HMAC-MD5 message authentication function as described in RFC 2104 and
24112 FIPS PUB 198.
24113
24114 @node GNAT Memory_Dump g-memdum ads,GNAT Most_Recent_Exception g-moreex ads,GNAT MD5 g-md5 ads,The GNAT Library
24115 @anchor{gnat_rm/the_gnat_library id93}@anchor{389}@anchor{gnat_rm/the_gnat_library gnat-memory-dump-g-memdum-ads}@anchor{38a}
24116 @section @code{GNAT.Memory_Dump} (@code{g-memdum.ads})
24117
24118
24119 @geindex GNAT.Memory_Dump (g-memdum.ads)
24120
24121 @geindex Dump Memory
24122
24123 Provides a convenient routine for dumping raw memory to either the
24124 standard output or standard error files. Uses GNAT.IO for actual
24125 output.
24126
24127 @node GNAT Most_Recent_Exception g-moreex ads,GNAT OS_Lib g-os_lib ads,GNAT Memory_Dump g-memdum ads,The GNAT Library
24128 @anchor{gnat_rm/the_gnat_library gnat-most-recent-exception-g-moreex-ads}@anchor{38b}@anchor{gnat_rm/the_gnat_library id94}@anchor{38c}
24129 @section @code{GNAT.Most_Recent_Exception} (@code{g-moreex.ads})
24130
24131
24132 @geindex GNAT.Most_Recent_Exception (g-moreex.ads)
24133
24134 @geindex Exception
24135 @geindex obtaining most recent
24136
24137 Provides access to the most recently raised exception. Can be used for
24138 various logging purposes, including duplicating functionality of some
24139 Ada 83 implementation dependent extensions.
24140
24141 @node GNAT OS_Lib g-os_lib ads,GNAT Perfect_Hash_Generators g-pehage ads,GNAT Most_Recent_Exception g-moreex ads,The GNAT Library
24142 @anchor{gnat_rm/the_gnat_library gnat-os-lib-g-os-lib-ads}@anchor{38d}@anchor{gnat_rm/the_gnat_library id95}@anchor{38e}
24143 @section @code{GNAT.OS_Lib} (@code{g-os_lib.ads})
24144
24145
24146 @geindex GNAT.OS_Lib (g-os_lib.ads)
24147
24148 @geindex Operating System interface
24149
24150 @geindex Spawn capability
24151
24152 Provides a range of target independent operating system interface functions,
24153 including time/date management, file operations, subprocess management,
24154 including a portable spawn procedure, and access to environment variables
24155 and error return codes.
24156
24157 @node GNAT Perfect_Hash_Generators g-pehage ads,GNAT Random_Numbers g-rannum ads,GNAT OS_Lib g-os_lib ads,The GNAT Library
24158 @anchor{gnat_rm/the_gnat_library gnat-perfect-hash-generators-g-pehage-ads}@anchor{38f}@anchor{gnat_rm/the_gnat_library id96}@anchor{390}
24159 @section @code{GNAT.Perfect_Hash_Generators} (@code{g-pehage.ads})
24160
24161
24162 @geindex GNAT.Perfect_Hash_Generators (g-pehage.ads)
24163
24164 @geindex Hash functions
24165
24166 Provides a generator of static minimal perfect hash functions. No
24167 collisions occur and each item can be retrieved from the table in one
24168 probe (perfect property). The hash table size corresponds to the exact
24169 size of the key set and no larger (minimal property). The key set has to
24170 be know in advance (static property). The hash functions are also order
24171 preserving. If w2 is inserted after w1 in the generator, their
24172 hashcode are in the same order. These hashing functions are very
24173 convenient for use with realtime applications.
24174
24175 @node GNAT Random_Numbers g-rannum ads,GNAT Regexp g-regexp ads,GNAT Perfect_Hash_Generators g-pehage ads,The GNAT Library
24176 @anchor{gnat_rm/the_gnat_library gnat-random-numbers-g-rannum-ads}@anchor{391}@anchor{gnat_rm/the_gnat_library id97}@anchor{392}
24177 @section @code{GNAT.Random_Numbers} (@code{g-rannum.ads})
24178
24179
24180 @geindex GNAT.Random_Numbers (g-rannum.ads)
24181
24182 @geindex Random number generation
24183
24184 Provides random number capabilities which extend those available in the
24185 standard Ada library and are more convenient to use.
24186
24187 @node GNAT Regexp g-regexp ads,GNAT Registry g-regist ads,GNAT Random_Numbers g-rannum ads,The GNAT Library
24188 @anchor{gnat_rm/the_gnat_library id98}@anchor{393}@anchor{gnat_rm/the_gnat_library gnat-regexp-g-regexp-ads}@anchor{258}
24189 @section @code{GNAT.Regexp} (@code{g-regexp.ads})
24190
24191
24192 @geindex GNAT.Regexp (g-regexp.ads)
24193
24194 @geindex Regular expressions
24195
24196 @geindex Pattern matching
24197
24198 A simple implementation of regular expressions, using a subset of regular
24199 expression syntax copied from familiar Unix style utilities. This is the
24200 simplest of the three pattern matching packages provided, and is particularly
24201 suitable for 'file globbing' applications.
24202
24203 @node GNAT Registry g-regist ads,GNAT Regpat g-regpat ads,GNAT Regexp g-regexp ads,The GNAT Library
24204 @anchor{gnat_rm/the_gnat_library id99}@anchor{394}@anchor{gnat_rm/the_gnat_library gnat-registry-g-regist-ads}@anchor{395}
24205 @section @code{GNAT.Registry} (@code{g-regist.ads})
24206
24207
24208 @geindex GNAT.Registry (g-regist.ads)
24209
24210 @geindex Windows Registry
24211
24212 This is a high level binding to the Windows registry. It is possible to
24213 do simple things like reading a key value, creating a new key. For full
24214 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
24215 package provided with the Win32Ada binding
24216
24217 @node GNAT Regpat g-regpat ads,GNAT Rewrite_Data g-rewdat ads,GNAT Registry g-regist ads,The GNAT Library
24218 @anchor{gnat_rm/the_gnat_library id100}@anchor{396}@anchor{gnat_rm/the_gnat_library gnat-regpat-g-regpat-ads}@anchor{397}
24219 @section @code{GNAT.Regpat} (@code{g-regpat.ads})
24220
24221
24222 @geindex GNAT.Regpat (g-regpat.ads)
24223
24224 @geindex Regular expressions
24225
24226 @geindex Pattern matching
24227
24228 A complete implementation of Unix-style regular expression matching, copied
24229 from the original V7 style regular expression library written in C by
24230 Henry Spencer (and binary compatible with this C library).
24231
24232 @node GNAT Rewrite_Data g-rewdat ads,GNAT Secondary_Stack_Info g-sestin ads,GNAT Regpat g-regpat ads,The GNAT Library
24233 @anchor{gnat_rm/the_gnat_library id101}@anchor{398}@anchor{gnat_rm/the_gnat_library gnat-rewrite-data-g-rewdat-ads}@anchor{399}
24234 @section @code{GNAT.Rewrite_Data} (@code{g-rewdat.ads})
24235
24236
24237 @geindex GNAT.Rewrite_Data (g-rewdat.ads)
24238
24239 @geindex Rewrite data
24240
24241 A unit to rewrite on-the-fly string occurrences in a stream of
24242 data. The implementation has a very minimal memory footprint as the
24243 full content to be processed is not loaded into memory all at once. This makes
24244 this interface usable for large files or socket streams.
24245
24246 @node GNAT Secondary_Stack_Info g-sestin ads,GNAT Semaphores g-semaph ads,GNAT Rewrite_Data g-rewdat ads,The GNAT Library
24247 @anchor{gnat_rm/the_gnat_library gnat-secondary-stack-info-g-sestin-ads}@anchor{39a}@anchor{gnat_rm/the_gnat_library id102}@anchor{39b}
24248 @section @code{GNAT.Secondary_Stack_Info} (@code{g-sestin.ads})
24249
24250
24251 @geindex GNAT.Secondary_Stack_Info (g-sestin.ads)
24252
24253 @geindex Secondary Stack Info
24254
24255 Provide the capability to query the high water mark of the current task's
24256 secondary stack.
24257
24258 @node GNAT Semaphores g-semaph ads,GNAT Serial_Communications g-sercom ads,GNAT Secondary_Stack_Info g-sestin ads,The GNAT Library
24259 @anchor{gnat_rm/the_gnat_library id103}@anchor{39c}@anchor{gnat_rm/the_gnat_library gnat-semaphores-g-semaph-ads}@anchor{39d}
24260 @section @code{GNAT.Semaphores} (@code{g-semaph.ads})
24261
24262
24263 @geindex GNAT.Semaphores (g-semaph.ads)
24264
24265 @geindex Semaphores
24266
24267 Provides classic counting and binary semaphores using protected types.
24268
24269 @node GNAT Serial_Communications g-sercom ads,GNAT SHA1 g-sha1 ads,GNAT Semaphores g-semaph ads,The GNAT Library
24270 @anchor{gnat_rm/the_gnat_library gnat-serial-communications-g-sercom-ads}@anchor{39e}@anchor{gnat_rm/the_gnat_library id104}@anchor{39f}
24271 @section @code{GNAT.Serial_Communications} (@code{g-sercom.ads})
24272
24273
24274 @geindex GNAT.Serial_Communications (g-sercom.ads)
24275
24276 @geindex Serial_Communications
24277
24278 Provides a simple interface to send and receive data over a serial
24279 port. This is only supported on GNU/Linux and Windows.
24280
24281 @node GNAT SHA1 g-sha1 ads,GNAT SHA224 g-sha224 ads,GNAT Serial_Communications g-sercom ads,The GNAT Library
24282 @anchor{gnat_rm/the_gnat_library gnat-sha1-g-sha1-ads}@anchor{3a0}@anchor{gnat_rm/the_gnat_library id105}@anchor{3a1}
24283 @section @code{GNAT.SHA1} (@code{g-sha1.ads})
24284
24285
24286 @geindex GNAT.SHA1 (g-sha1.ads)
24287
24288 @geindex Secure Hash Algorithm SHA-1
24289
24290 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
24291 and RFC 3174, and the HMAC-SHA1 message authentication function as described
24292 in RFC 2104 and FIPS PUB 198.
24293
24294 @node GNAT SHA224 g-sha224 ads,GNAT SHA256 g-sha256 ads,GNAT SHA1 g-sha1 ads,The GNAT Library
24295 @anchor{gnat_rm/the_gnat_library gnat-sha224-g-sha224-ads}@anchor{3a2}@anchor{gnat_rm/the_gnat_library id106}@anchor{3a3}
24296 @section @code{GNAT.SHA224} (@code{g-sha224.ads})
24297
24298
24299 @geindex GNAT.SHA224 (g-sha224.ads)
24300
24301 @geindex Secure Hash Algorithm SHA-224
24302
24303 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
24304 and the HMAC-SHA224 message authentication function as described
24305 in RFC 2104 and FIPS PUB 198.
24306
24307 @node GNAT SHA256 g-sha256 ads,GNAT SHA384 g-sha384 ads,GNAT SHA224 g-sha224 ads,The GNAT Library
24308 @anchor{gnat_rm/the_gnat_library gnat-sha256-g-sha256-ads}@anchor{3a4}@anchor{gnat_rm/the_gnat_library id107}@anchor{3a5}
24309 @section @code{GNAT.SHA256} (@code{g-sha256.ads})
24310
24311
24312 @geindex GNAT.SHA256 (g-sha256.ads)
24313
24314 @geindex Secure Hash Algorithm SHA-256
24315
24316 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
24317 and the HMAC-SHA256 message authentication function as described
24318 in RFC 2104 and FIPS PUB 198.
24319
24320 @node GNAT SHA384 g-sha384 ads,GNAT SHA512 g-sha512 ads,GNAT SHA256 g-sha256 ads,The GNAT Library
24321 @anchor{gnat_rm/the_gnat_library id108}@anchor{3a6}@anchor{gnat_rm/the_gnat_library gnat-sha384-g-sha384-ads}@anchor{3a7}
24322 @section @code{GNAT.SHA384} (@code{g-sha384.ads})
24323
24324
24325 @geindex GNAT.SHA384 (g-sha384.ads)
24326
24327 @geindex Secure Hash Algorithm SHA-384
24328
24329 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
24330 and the HMAC-SHA384 message authentication function as described
24331 in RFC 2104 and FIPS PUB 198.
24332
24333 @node GNAT SHA512 g-sha512 ads,GNAT Signals g-signal ads,GNAT SHA384 g-sha384 ads,The GNAT Library
24334 @anchor{gnat_rm/the_gnat_library id109}@anchor{3a8}@anchor{gnat_rm/the_gnat_library gnat-sha512-g-sha512-ads}@anchor{3a9}
24335 @section @code{GNAT.SHA512} (@code{g-sha512.ads})
24336
24337
24338 @geindex GNAT.SHA512 (g-sha512.ads)
24339
24340 @geindex Secure Hash Algorithm SHA-512
24341
24342 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
24343 and the HMAC-SHA512 message authentication function as described
24344 in RFC 2104 and FIPS PUB 198.
24345
24346 @node GNAT Signals g-signal ads,GNAT Sockets g-socket ads,GNAT SHA512 g-sha512 ads,The GNAT Library
24347 @anchor{gnat_rm/the_gnat_library gnat-signals-g-signal-ads}@anchor{3aa}@anchor{gnat_rm/the_gnat_library id110}@anchor{3ab}
24348 @section @code{GNAT.Signals} (@code{g-signal.ads})
24349
24350
24351 @geindex GNAT.Signals (g-signal.ads)
24352
24353 @geindex Signals
24354
24355 Provides the ability to manipulate the blocked status of signals on supported
24356 targets.
24357
24358 @node GNAT Sockets g-socket ads,GNAT Source_Info g-souinf ads,GNAT Signals g-signal ads,The GNAT Library
24359 @anchor{gnat_rm/the_gnat_library gnat-sockets-g-socket-ads}@anchor{3ac}@anchor{gnat_rm/the_gnat_library id111}@anchor{3ad}
24360 @section @code{GNAT.Sockets} (@code{g-socket.ads})
24361
24362
24363 @geindex GNAT.Sockets (g-socket.ads)
24364
24365 @geindex Sockets
24366
24367 A high level and portable interface to develop sockets based applications.
24368 This package is based on the sockets thin binding found in
24369 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
24370 on all native GNAT ports and on VxWorks cross prots. It is not implemented for
24371 the LynxOS cross port.
24372
24373 @node GNAT Source_Info g-souinf ads,GNAT Spelling_Checker g-speche ads,GNAT Sockets g-socket ads,The GNAT Library
24374 @anchor{gnat_rm/the_gnat_library gnat-source-info-g-souinf-ads}@anchor{3ae}@anchor{gnat_rm/the_gnat_library id112}@anchor{3af}
24375 @section @code{GNAT.Source_Info} (@code{g-souinf.ads})
24376
24377
24378 @geindex GNAT.Source_Info (g-souinf.ads)
24379
24380 @geindex Source Information
24381
24382 Provides subprograms that give access to source code information known at
24383 compile time, such as the current file name and line number. Also provides
24384 subprograms yielding the date and time of the current compilation (like the
24385 C macros @code{__DATE__} and @code{__TIME__})
24386
24387 @node GNAT Spelling_Checker g-speche ads,GNAT Spelling_Checker_Generic g-spchge ads,GNAT Source_Info g-souinf ads,The GNAT Library
24388 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-g-speche-ads}@anchor{3b0}@anchor{gnat_rm/the_gnat_library id113}@anchor{3b1}
24389 @section @code{GNAT.Spelling_Checker} (@code{g-speche.ads})
24390
24391
24392 @geindex GNAT.Spelling_Checker (g-speche.ads)
24393
24394 @geindex Spell checking
24395
24396 Provides a function for determining whether one string is a plausible
24397 near misspelling of another string.
24398
24399 @node GNAT Spelling_Checker_Generic g-spchge ads,GNAT Spitbol Patterns g-spipat ads,GNAT Spelling_Checker g-speche ads,The GNAT Library
24400 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-generic-g-spchge-ads}@anchor{3b2}@anchor{gnat_rm/the_gnat_library id114}@anchor{3b3}
24401 @section @code{GNAT.Spelling_Checker_Generic} (@code{g-spchge.ads})
24402
24403
24404 @geindex GNAT.Spelling_Checker_Generic (g-spchge.ads)
24405
24406 @geindex Spell checking
24407
24408 Provides a generic function that can be instantiated with a string type for
24409 determining whether one string is a plausible near misspelling of another
24410 string.
24411
24412 @node GNAT Spitbol Patterns g-spipat ads,GNAT Spitbol g-spitbo ads,GNAT Spelling_Checker_Generic g-spchge ads,The GNAT Library
24413 @anchor{gnat_rm/the_gnat_library gnat-spitbol-patterns-g-spipat-ads}@anchor{3b4}@anchor{gnat_rm/the_gnat_library id115}@anchor{3b5}
24414 @section @code{GNAT.Spitbol.Patterns} (@code{g-spipat.ads})
24415
24416
24417 @geindex GNAT.Spitbol.Patterns (g-spipat.ads)
24418
24419 @geindex SPITBOL pattern matching
24420
24421 @geindex Pattern matching
24422
24423 A complete implementation of SNOBOL4 style pattern matching. This is the
24424 most elaborate of the pattern matching packages provided. It fully duplicates
24425 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
24426 efficient algorithm developed by Robert Dewar for the SPITBOL system.
24427
24428 @node GNAT Spitbol g-spitbo ads,GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Patterns g-spipat ads,The GNAT Library
24429 @anchor{gnat_rm/the_gnat_library id116}@anchor{3b6}@anchor{gnat_rm/the_gnat_library gnat-spitbol-g-spitbo-ads}@anchor{3b7}
24430 @section @code{GNAT.Spitbol} (@code{g-spitbo.ads})
24431
24432
24433 @geindex GNAT.Spitbol (g-spitbo.ads)
24434
24435 @geindex SPITBOL interface
24436
24437 The top level package of the collection of SPITBOL-style functionality, this
24438 package provides basic SNOBOL4 string manipulation functions, such as
24439 Pad, Reverse, Trim, Substr capability, as well as a generic table function
24440 useful for constructing arbitrary mappings from strings in the style of
24441 the SNOBOL4 TABLE function.
24442
24443 @node GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol g-spitbo ads,The GNAT Library
24444 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-boolean-g-sptabo-ads}@anchor{3b8}@anchor{gnat_rm/the_gnat_library id117}@anchor{3b9}
24445 @section @code{GNAT.Spitbol.Table_Boolean} (@code{g-sptabo.ads})
24446
24447
24448 @geindex GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
24449
24450 @geindex Sets of strings
24451
24452 @geindex SPITBOL Tables
24453
24454 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24455 for type @code{Standard.Boolean}, giving an implementation of sets of
24456 string values.
24457
24458 @node GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol Table_VString g-sptavs ads,GNAT Spitbol Table_Boolean g-sptabo ads,The GNAT Library
24459 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-integer-g-sptain-ads}@anchor{3ba}@anchor{gnat_rm/the_gnat_library id118}@anchor{3bb}
24460 @section @code{GNAT.Spitbol.Table_Integer} (@code{g-sptain.ads})
24461
24462
24463 @geindex GNAT.Spitbol.Table_Integer (g-sptain.ads)
24464
24465 @geindex Integer maps
24466
24467 @geindex Maps
24468
24469 @geindex SPITBOL Tables
24470
24471 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24472 for type @code{Standard.Integer}, giving an implementation of maps
24473 from string to integer values.
24474
24475 @node GNAT Spitbol Table_VString g-sptavs ads,GNAT SSE g-sse ads,GNAT Spitbol Table_Integer g-sptain ads,The GNAT Library
24476 @anchor{gnat_rm/the_gnat_library id119}@anchor{3bc}@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-vstring-g-sptavs-ads}@anchor{3bd}
24477 @section @code{GNAT.Spitbol.Table_VString} (@code{g-sptavs.ads})
24478
24479
24480 @geindex GNAT.Spitbol.Table_VString (g-sptavs.ads)
24481
24482 @geindex String maps
24483
24484 @geindex Maps
24485
24486 @geindex SPITBOL Tables
24487
24488 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
24489 a variable length string type, giving an implementation of general
24490 maps from strings to strings.
24491
24492 @node GNAT SSE g-sse ads,GNAT SSE Vector_Types g-ssvety ads,GNAT Spitbol Table_VString g-sptavs ads,The GNAT Library
24493 @anchor{gnat_rm/the_gnat_library id120}@anchor{3be}@anchor{gnat_rm/the_gnat_library gnat-sse-g-sse-ads}@anchor{3bf}
24494 @section @code{GNAT.SSE} (@code{g-sse.ads})
24495
24496
24497 @geindex GNAT.SSE (g-sse.ads)
24498
24499 Root of a set of units aimed at offering Ada bindings to a subset of
24500 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
24501 targets. It exposes vector component types together with a general
24502 introduction to the binding contents and use.
24503
24504 @node GNAT SSE Vector_Types g-ssvety ads,GNAT String_Hash g-strhas ads,GNAT SSE g-sse ads,The GNAT Library
24505 @anchor{gnat_rm/the_gnat_library gnat-sse-vector-types-g-ssvety-ads}@anchor{3c0}@anchor{gnat_rm/the_gnat_library id121}@anchor{3c1}
24506 @section @code{GNAT.SSE.Vector_Types} (@code{g-ssvety.ads})
24507
24508
24509 @geindex GNAT.SSE.Vector_Types (g-ssvety.ads)
24510
24511 SSE vector types for use with SSE related intrinsics.
24512
24513 @node GNAT String_Hash g-strhas ads,GNAT Strings g-string ads,GNAT SSE Vector_Types g-ssvety ads,The GNAT Library
24514 @anchor{gnat_rm/the_gnat_library gnat-string-hash-g-strhas-ads}@anchor{3c2}@anchor{gnat_rm/the_gnat_library id122}@anchor{3c3}
24515 @section @code{GNAT.String_Hash} (@code{g-strhas.ads})
24516
24517
24518 @geindex GNAT.String_Hash (g-strhas.ads)
24519
24520 @geindex Hash functions
24521
24522 Provides a generic hash function working on arrays of scalars. Both the scalar
24523 type and the hash result type are parameters.
24524
24525 @node GNAT Strings g-string ads,GNAT String_Split g-strspl ads,GNAT String_Hash g-strhas ads,The GNAT Library
24526 @anchor{gnat_rm/the_gnat_library id123}@anchor{3c4}@anchor{gnat_rm/the_gnat_library gnat-strings-g-string-ads}@anchor{3c5}
24527 @section @code{GNAT.Strings} (@code{g-string.ads})
24528
24529
24530 @geindex GNAT.Strings (g-string.ads)
24531
24532 Common String access types and related subprograms. Basically it
24533 defines a string access and an array of string access types.
24534
24535 @node GNAT String_Split g-strspl ads,GNAT Table g-table ads,GNAT Strings g-string ads,The GNAT Library
24536 @anchor{gnat_rm/the_gnat_library gnat-string-split-g-strspl-ads}@anchor{3c6}@anchor{gnat_rm/the_gnat_library id124}@anchor{3c7}
24537 @section @code{GNAT.String_Split} (@code{g-strspl.ads})
24538
24539
24540 @geindex GNAT.String_Split (g-strspl.ads)
24541
24542 @geindex String splitter
24543
24544 Useful string manipulation routines: given a set of separators, split
24545 a string wherever the separators appear, and provide direct access
24546 to the resulting slices. This package is instantiated from
24547 @code{GNAT.Array_Split}.
24548
24549 @node GNAT Table g-table ads,GNAT Task_Lock g-tasloc ads,GNAT String_Split g-strspl ads,The GNAT Library
24550 @anchor{gnat_rm/the_gnat_library id125}@anchor{3c8}@anchor{gnat_rm/the_gnat_library gnat-table-g-table-ads}@anchor{3c9}
24551 @section @code{GNAT.Table} (@code{g-table.ads})
24552
24553
24554 @geindex GNAT.Table (g-table.ads)
24555
24556 @geindex Table implementation
24557
24558 @geindex Arrays
24559 @geindex extendable
24560
24561 A generic package providing a single dimension array abstraction where the
24562 length of the array can be dynamically modified.
24563
24564 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
24565 except that this package declares a single instance of the table type,
24566 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
24567 used to define dynamic instances of the table.
24568
24569 @node GNAT Task_Lock g-tasloc ads,GNAT Time_Stamp g-timsta ads,GNAT Table g-table ads,The GNAT Library
24570 @anchor{gnat_rm/the_gnat_library id126}@anchor{3ca}@anchor{gnat_rm/the_gnat_library gnat-task-lock-g-tasloc-ads}@anchor{3cb}
24571 @section @code{GNAT.Task_Lock} (@code{g-tasloc.ads})
24572
24573
24574 @geindex GNAT.Task_Lock (g-tasloc.ads)
24575
24576 @geindex Task synchronization
24577
24578 @geindex Task locking
24579
24580 @geindex Locking
24581
24582 A very simple facility for locking and unlocking sections of code using a
24583 single global task lock. Appropriate for use in situations where contention
24584 between tasks is very rarely expected.
24585
24586 @node GNAT Time_Stamp g-timsta ads,GNAT Threads g-thread ads,GNAT Task_Lock g-tasloc ads,The GNAT Library
24587 @anchor{gnat_rm/the_gnat_library id127}@anchor{3cc}@anchor{gnat_rm/the_gnat_library gnat-time-stamp-g-timsta-ads}@anchor{3cd}
24588 @section @code{GNAT.Time_Stamp} (@code{g-timsta.ads})
24589
24590
24591 @geindex GNAT.Time_Stamp (g-timsta.ads)
24592
24593 @geindex Time stamp
24594
24595 @geindex Current time
24596
24597 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
24598 represents the current date and time in ISO 8601 format. This is a very simple
24599 routine with minimal code and there are no dependencies on any other unit.
24600
24601 @node GNAT Threads g-thread ads,GNAT Traceback g-traceb ads,GNAT Time_Stamp g-timsta ads,The GNAT Library
24602 @anchor{gnat_rm/the_gnat_library gnat-threads-g-thread-ads}@anchor{3ce}@anchor{gnat_rm/the_gnat_library id128}@anchor{3cf}
24603 @section @code{GNAT.Threads} (@code{g-thread.ads})
24604
24605
24606 @geindex GNAT.Threads (g-thread.ads)
24607
24608 @geindex Foreign threads
24609
24610 @geindex Threads
24611 @geindex foreign
24612
24613 Provides facilities for dealing with foreign threads which need to be known
24614 by the GNAT run-time system. Consult the documentation of this package for
24615 further details if your program has threads that are created by a non-Ada
24616 environment which then accesses Ada code.
24617
24618 @node GNAT Traceback g-traceb ads,GNAT Traceback Symbolic g-trasym ads,GNAT Threads g-thread ads,The GNAT Library
24619 @anchor{gnat_rm/the_gnat_library id129}@anchor{3d0}@anchor{gnat_rm/the_gnat_library gnat-traceback-g-traceb-ads}@anchor{3d1}
24620 @section @code{GNAT.Traceback} (@code{g-traceb.ads})
24621
24622
24623 @geindex GNAT.Traceback (g-traceb.ads)
24624
24625 @geindex Trace back facilities
24626
24627 Provides a facility for obtaining non-symbolic traceback information, useful
24628 in various debugging situations.
24629
24630 @node GNAT Traceback Symbolic g-trasym ads,GNAT UTF_32 g-table ads,GNAT Traceback g-traceb ads,The GNAT Library
24631 @anchor{gnat_rm/the_gnat_library id130}@anchor{3d2}@anchor{gnat_rm/the_gnat_library gnat-traceback-symbolic-g-trasym-ads}@anchor{3d3}
24632 @section @code{GNAT.Traceback.Symbolic} (@code{g-trasym.ads})
24633
24634
24635 @geindex GNAT.Traceback.Symbolic (g-trasym.ads)
24636
24637 @geindex Trace back facilities
24638
24639 @node GNAT UTF_32 g-table ads,GNAT Wide_Spelling_Checker g-u3spch ads,GNAT Traceback Symbolic g-trasym ads,The GNAT Library
24640 @anchor{gnat_rm/the_gnat_library id131}@anchor{3d4}@anchor{gnat_rm/the_gnat_library gnat-utf-32-g-table-ads}@anchor{3d5}
24641 @section @code{GNAT.UTF_32} (@code{g-table.ads})
24642
24643
24644 @geindex GNAT.UTF_32 (g-table.ads)
24645
24646 @geindex Wide character codes
24647
24648 This is a package intended to be used in conjunction with the
24649 @code{Wide_Character} type in Ada 95 and the
24650 @code{Wide_Wide_Character} type in Ada 2005 (available
24651 in @code{GNAT} in Ada 2005 mode). This package contains
24652 Unicode categorization routines, as well as lexical
24653 categorization routines corresponding to the Ada 2005
24654 lexical rules for identifiers and strings, and also a
24655 lower case to upper case fold routine corresponding to
24656 the Ada 2005 rules for identifier equivalence.
24657
24658 @node GNAT Wide_Spelling_Checker g-u3spch ads,GNAT Wide_Spelling_Checker g-wispch ads,GNAT UTF_32 g-table ads,The GNAT Library
24659 @anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-u3spch-ads}@anchor{3d6}@anchor{gnat_rm/the_gnat_library id132}@anchor{3d7}
24660 @section @code{GNAT.Wide_Spelling_Checker} (@code{g-u3spch.ads})
24661
24662
24663 @geindex GNAT.Wide_Spelling_Checker (g-u3spch.ads)
24664
24665 @geindex Spell checking
24666
24667 Provides a function for determining whether one wide wide string is a plausible
24668 near misspelling of another wide wide string, where the strings are represented
24669 using the UTF_32_String type defined in System.Wch_Cnv.
24670
24671 @node GNAT Wide_Spelling_Checker g-wispch ads,GNAT Wide_String_Split g-wistsp ads,GNAT Wide_Spelling_Checker g-u3spch ads,The GNAT Library
24672 @anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-wispch-ads}@anchor{3d8}@anchor{gnat_rm/the_gnat_library id133}@anchor{3d9}
24673 @section @code{GNAT.Wide_Spelling_Checker} (@code{g-wispch.ads})
24674
24675
24676 @geindex GNAT.Wide_Spelling_Checker (g-wispch.ads)
24677
24678 @geindex Spell checking
24679
24680 Provides a function for determining whether one wide string is a plausible
24681 near misspelling of another wide string.
24682
24683 @node GNAT Wide_String_Split g-wistsp ads,GNAT Wide_Wide_Spelling_Checker g-zspche ads,GNAT Wide_Spelling_Checker g-wispch ads,The GNAT Library
24684 @anchor{gnat_rm/the_gnat_library id134}@anchor{3da}@anchor{gnat_rm/the_gnat_library gnat-wide-string-split-g-wistsp-ads}@anchor{3db}
24685 @section @code{GNAT.Wide_String_Split} (@code{g-wistsp.ads})
24686
24687
24688 @geindex GNAT.Wide_String_Split (g-wistsp.ads)
24689
24690 @geindex Wide_String splitter
24691
24692 Useful wide string manipulation routines: given a set of separators, split
24693 a wide string wherever the separators appear, and provide direct access
24694 to the resulting slices. This package is instantiated from
24695 @code{GNAT.Array_Split}.
24696
24697 @node GNAT Wide_Wide_Spelling_Checker g-zspche ads,GNAT Wide_Wide_String_Split g-zistsp ads,GNAT Wide_String_Split g-wistsp ads,The GNAT Library
24698 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-spelling-checker-g-zspche-ads}@anchor{3dc}@anchor{gnat_rm/the_gnat_library id135}@anchor{3dd}
24699 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@code{g-zspche.ads})
24700
24701
24702 @geindex GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
24703
24704 @geindex Spell checking
24705
24706 Provides a function for determining whether one wide wide string is a plausible
24707 near misspelling of another wide wide string.
24708
24709 @node GNAT Wide_Wide_String_Split g-zistsp ads,Interfaces C Extensions i-cexten ads,GNAT Wide_Wide_Spelling_Checker g-zspche ads,The GNAT Library
24710 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-string-split-g-zistsp-ads}@anchor{3de}@anchor{gnat_rm/the_gnat_library id136}@anchor{3df}
24711 @section @code{GNAT.Wide_Wide_String_Split} (@code{g-zistsp.ads})
24712
24713
24714 @geindex GNAT.Wide_Wide_String_Split (g-zistsp.ads)
24715
24716 @geindex Wide_Wide_String splitter
24717
24718 Useful wide wide string manipulation routines: given a set of separators, split
24719 a wide wide string wherever the separators appear, and provide direct access
24720 to the resulting slices. This package is instantiated from
24721 @code{GNAT.Array_Split}.
24722
24723 @node Interfaces C Extensions i-cexten ads,Interfaces C Streams i-cstrea ads,GNAT Wide_Wide_String_Split g-zistsp ads,The GNAT Library
24724 @anchor{gnat_rm/the_gnat_library interfaces-c-extensions-i-cexten-ads}@anchor{3e0}@anchor{gnat_rm/the_gnat_library id137}@anchor{3e1}
24725 @section @code{Interfaces.C.Extensions} (@code{i-cexten.ads})
24726
24727
24728 @geindex Interfaces.C.Extensions (i-cexten.ads)
24729
24730 This package contains additional C-related definitions, intended
24731 for use with either manually or automatically generated bindings
24732 to C libraries.
24733
24734 @node Interfaces C Streams i-cstrea ads,Interfaces Packed_Decimal i-pacdec ads,Interfaces C Extensions i-cexten ads,The GNAT Library
24735 @anchor{gnat_rm/the_gnat_library id138}@anchor{3e2}@anchor{gnat_rm/the_gnat_library interfaces-c-streams-i-cstrea-ads}@anchor{3e3}
24736 @section @code{Interfaces.C.Streams} (@code{i-cstrea.ads})
24737
24738
24739 @geindex Interfaces.C.Streams (i-cstrea.ads)
24740
24741 @geindex C streams
24742 @geindex interfacing
24743
24744 This package is a binding for the most commonly used operations
24745 on C streams.
24746
24747 @node Interfaces Packed_Decimal i-pacdec ads,Interfaces VxWorks i-vxwork ads,Interfaces C Streams i-cstrea ads,The GNAT Library
24748 @anchor{gnat_rm/the_gnat_library interfaces-packed-decimal-i-pacdec-ads}@anchor{3e4}@anchor{gnat_rm/the_gnat_library id139}@anchor{3e5}
24749 @section @code{Interfaces.Packed_Decimal} (@code{i-pacdec.ads})
24750
24751
24752 @geindex Interfaces.Packed_Decimal (i-pacdec.ads)
24753
24754 @geindex IBM Packed Format
24755
24756 @geindex Packed Decimal
24757
24758 This package provides a set of routines for conversions to and
24759 from a packed decimal format compatible with that used on IBM
24760 mainframes.
24761
24762 @node Interfaces VxWorks i-vxwork ads,Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces Packed_Decimal i-pacdec ads,The GNAT Library
24763 @anchor{gnat_rm/the_gnat_library interfaces-vxworks-i-vxwork-ads}@anchor{3e6}@anchor{gnat_rm/the_gnat_library id140}@anchor{3e7}
24764 @section @code{Interfaces.VxWorks} (@code{i-vxwork.ads})
24765
24766
24767 @geindex Interfaces.VxWorks (i-vxwork.ads)
24768
24769 @geindex Interfacing to VxWorks
24770
24771 @geindex VxWorks
24772 @geindex interfacing
24773
24774 This package provides a limited binding to the VxWorks API.
24775 In particular, it interfaces with the
24776 VxWorks hardware interrupt facilities.
24777
24778 @node Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces VxWorks IO i-vxwoio ads,Interfaces VxWorks i-vxwork ads,The GNAT Library
24779 @anchor{gnat_rm/the_gnat_library interfaces-vxworks-int-connection-i-vxinco-ads}@anchor{3e8}@anchor{gnat_rm/the_gnat_library id141}@anchor{3e9}
24780 @section @code{Interfaces.VxWorks.Int_Connection} (@code{i-vxinco.ads})
24781
24782
24783 @geindex Interfaces.VxWorks.Int_Connection (i-vxinco.ads)
24784
24785 @geindex Interfacing to VxWorks
24786
24787 @geindex VxWorks
24788 @geindex interfacing
24789
24790 This package provides a way for users to replace the use of
24791 intConnect() with a custom routine for installing interrupt
24792 handlers.
24793
24794 @node Interfaces VxWorks IO i-vxwoio ads,System Address_Image s-addima ads,Interfaces VxWorks Int_Connection i-vxinco ads,The GNAT Library
24795 @anchor{gnat_rm/the_gnat_library interfaces-vxworks-io-i-vxwoio-ads}@anchor{3ea}@anchor{gnat_rm/the_gnat_library id142}@anchor{3eb}
24796 @section @code{Interfaces.VxWorks.IO} (@code{i-vxwoio.ads})
24797
24798
24799 @geindex Interfaces.VxWorks.IO (i-vxwoio.ads)
24800
24801 @geindex Interfacing to VxWorks' I/O
24802
24803 @geindex VxWorks
24804 @geindex I/O interfacing
24805
24806 @geindex VxWorks
24807 @geindex Get_Immediate
24808
24809 @geindex Get_Immediate
24810 @geindex VxWorks
24811
24812 This package provides a binding to the ioctl (IO/Control)
24813 function of VxWorks, defining a set of option values and
24814 function codes. A particular use of this package is
24815 to enable the use of Get_Immediate under VxWorks.
24816
24817 @node System Address_Image s-addima ads,System Assertions s-assert ads,Interfaces VxWorks IO i-vxwoio ads,The GNAT Library
24818 @anchor{gnat_rm/the_gnat_library system-address-image-s-addima-ads}@anchor{3ec}@anchor{gnat_rm/the_gnat_library id143}@anchor{3ed}
24819 @section @code{System.Address_Image} (@code{s-addima.ads})
24820
24821
24822 @geindex System.Address_Image (s-addima.ads)
24823
24824 @geindex Address image
24825
24826 @geindex Image
24827 @geindex of an address
24828
24829 This function provides a useful debugging
24830 function that gives an (implementation dependent)
24831 string which identifies an address.
24832
24833 @node System Assertions s-assert ads,System Atomic_Counters s-atocou ads,System Address_Image s-addima ads,The GNAT Library
24834 @anchor{gnat_rm/the_gnat_library id144}@anchor{3ee}@anchor{gnat_rm/the_gnat_library system-assertions-s-assert-ads}@anchor{3ef}
24835 @section @code{System.Assertions} (@code{s-assert.ads})
24836
24837
24838 @geindex System.Assertions (s-assert.ads)
24839
24840 @geindex Assertions
24841
24842 @geindex Assert_Failure
24843 @geindex exception
24844
24845 This package provides the declaration of the exception raised
24846 by an run-time assertion failure, as well as the routine that
24847 is used internally to raise this assertion.
24848
24849 @node System Atomic_Counters s-atocou ads,System Memory s-memory ads,System Assertions s-assert ads,The GNAT Library
24850 @anchor{gnat_rm/the_gnat_library id145}@anchor{3f0}@anchor{gnat_rm/the_gnat_library system-atomic-counters-s-atocou-ads}@anchor{3f1}
24851 @section @code{System.Atomic_Counters} (@code{s-atocou.ads})
24852
24853
24854 @geindex System.Atomic_Counters (s-atocou.ads)
24855
24856 This package provides the declaration of an atomic counter type,
24857 together with efficient routines (using hardware
24858 synchronization primitives) for incrementing, decrementing,
24859 and testing of these counters. This package is implemented
24860 on most targets, including all Alpha, ia64, PowerPC, SPARC V9,
24861 x86, and x86_64 platforms.
24862
24863 @node System Memory s-memory ads,System Multiprocessors s-multip ads,System Atomic_Counters s-atocou ads,The GNAT Library
24864 @anchor{gnat_rm/the_gnat_library system-memory-s-memory-ads}@anchor{3f2}@anchor{gnat_rm/the_gnat_library id146}@anchor{3f3}
24865 @section @code{System.Memory} (@code{s-memory.ads})
24866
24867
24868 @geindex System.Memory (s-memory.ads)
24869
24870 @geindex Memory allocation
24871
24872 This package provides the interface to the low level routines used
24873 by the generated code for allocation and freeing storage for the
24874 default storage pool (analogous to the C routines malloc and free.
24875 It also provides a reallocation interface analogous to the C routine
24876 realloc. The body of this unit may be modified to provide alternative
24877 allocation mechanisms for the default pool, and in addition, direct
24878 calls to this unit may be made for low level allocation uses (for
24879 example see the body of @code{GNAT.Tables}).
24880
24881 @node System Multiprocessors s-multip ads,System Multiprocessors Dispatching_Domains s-mudido ads,System Memory s-memory ads,The GNAT Library
24882 @anchor{gnat_rm/the_gnat_library id147}@anchor{3f4}@anchor{gnat_rm/the_gnat_library system-multiprocessors-s-multip-ads}@anchor{3f5}
24883 @section @code{System.Multiprocessors} (@code{s-multip.ads})
24884
24885
24886 @geindex System.Multiprocessors (s-multip.ads)
24887
24888 @geindex Multiprocessor interface
24889
24890 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
24891 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
24892 technically an implementation-defined addition).
24893
24894 @node System Multiprocessors Dispatching_Domains s-mudido ads,System Partition_Interface s-parint ads,System Multiprocessors s-multip ads,The GNAT Library
24895 @anchor{gnat_rm/the_gnat_library system-multiprocessors-dispatching-domains-s-mudido-ads}@anchor{3f6}@anchor{gnat_rm/the_gnat_library id148}@anchor{3f7}
24896 @section @code{System.Multiprocessors.Dispatching_Domains} (@code{s-mudido.ads})
24897
24898
24899 @geindex System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
24900
24901 @geindex Multiprocessor interface
24902
24903 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
24904 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
24905 technically an implementation-defined addition).
24906
24907 @node System Partition_Interface s-parint ads,System Pool_Global s-pooglo ads,System Multiprocessors Dispatching_Domains s-mudido ads,The GNAT Library
24908 @anchor{gnat_rm/the_gnat_library id149}@anchor{3f8}@anchor{gnat_rm/the_gnat_library system-partition-interface-s-parint-ads}@anchor{3f9}
24909 @section @code{System.Partition_Interface} (@code{s-parint.ads})
24910
24911
24912 @geindex System.Partition_Interface (s-parint.ads)
24913
24914 @geindex Partition interfacing functions
24915
24916 This package provides facilities for partition interfacing. It
24917 is used primarily in a distribution context when using Annex E
24918 with @code{GLADE}.
24919
24920 @node System Pool_Global s-pooglo ads,System Pool_Local s-pooloc ads,System Partition_Interface s-parint ads,The GNAT Library
24921 @anchor{gnat_rm/the_gnat_library id150}@anchor{3fa}@anchor{gnat_rm/the_gnat_library system-pool-global-s-pooglo-ads}@anchor{3fb}
24922 @section @code{System.Pool_Global} (@code{s-pooglo.ads})
24923
24924
24925 @geindex System.Pool_Global (s-pooglo.ads)
24926
24927 @geindex Storage pool
24928 @geindex global
24929
24930 @geindex Global storage pool
24931
24932 This package provides a storage pool that is equivalent to the default
24933 storage pool used for access types for which no pool is specifically
24934 declared. It uses malloc/free to allocate/free and does not attempt to
24935 do any automatic reclamation.
24936
24937 @node System Pool_Local s-pooloc ads,System Restrictions s-restri ads,System Pool_Global s-pooglo ads,The GNAT Library
24938 @anchor{gnat_rm/the_gnat_library system-pool-local-s-pooloc-ads}@anchor{3fc}@anchor{gnat_rm/the_gnat_library id151}@anchor{3fd}
24939 @section @code{System.Pool_Local} (@code{s-pooloc.ads})
24940
24941
24942 @geindex System.Pool_Local (s-pooloc.ads)
24943
24944 @geindex Storage pool
24945 @geindex local
24946
24947 @geindex Local storage pool
24948
24949 This package provides a storage pool that is intended for use with locally
24950 defined access types. It uses malloc/free for allocate/free, and maintains
24951 a list of allocated blocks, so that all storage allocated for the pool can
24952 be freed automatically when the pool is finalized.
24953
24954 @node System Restrictions s-restri ads,System Rident s-rident ads,System Pool_Local s-pooloc ads,The GNAT Library
24955 @anchor{gnat_rm/the_gnat_library id152}@anchor{3fe}@anchor{gnat_rm/the_gnat_library system-restrictions-s-restri-ads}@anchor{3ff}
24956 @section @code{System.Restrictions} (@code{s-restri.ads})
24957
24958
24959 @geindex System.Restrictions (s-restri.ads)
24960
24961 @geindex Run-time restrictions access
24962
24963 This package provides facilities for accessing at run time
24964 the status of restrictions specified at compile time for
24965 the partition. Information is available both with regard
24966 to actual restrictions specified, and with regard to
24967 compiler determined information on which restrictions
24968 are violated by one or more packages in the partition.
24969
24970 @node System Rident s-rident ads,System Strings Stream_Ops s-ststop ads,System Restrictions s-restri ads,The GNAT Library
24971 @anchor{gnat_rm/the_gnat_library system-rident-s-rident-ads}@anchor{400}@anchor{gnat_rm/the_gnat_library id153}@anchor{401}
24972 @section @code{System.Rident} (@code{s-rident.ads})
24973
24974
24975 @geindex System.Rident (s-rident.ads)
24976
24977 @geindex Restrictions definitions
24978
24979 This package provides definitions of the restrictions
24980 identifiers supported by GNAT, and also the format of
24981 the restrictions provided in package System.Restrictions.
24982 It is not normally necessary to @code{with} this generic package
24983 since the necessary instantiation is included in
24984 package System.Restrictions.
24985
24986 @node System Strings Stream_Ops s-ststop ads,System Unsigned_Types s-unstyp ads,System Rident s-rident ads,The GNAT Library
24987 @anchor{gnat_rm/the_gnat_library id154}@anchor{402}@anchor{gnat_rm/the_gnat_library system-strings-stream-ops-s-ststop-ads}@anchor{403}
24988 @section @code{System.Strings.Stream_Ops} (@code{s-ststop.ads})
24989
24990
24991 @geindex System.Strings.Stream_Ops (s-ststop.ads)
24992
24993 @geindex Stream operations
24994
24995 @geindex String stream operations
24996
24997 This package provides a set of stream subprograms for standard string types.
24998 It is intended primarily to support implicit use of such subprograms when
24999 stream attributes are applied to string types, but the subprograms in this
25000 package can be used directly by application programs.
25001
25002 @node System Unsigned_Types s-unstyp ads,System Wch_Cnv s-wchcnv ads,System Strings Stream_Ops s-ststop ads,The GNAT Library
25003 @anchor{gnat_rm/the_gnat_library system-unsigned-types-s-unstyp-ads}@anchor{404}@anchor{gnat_rm/the_gnat_library id155}@anchor{405}
25004 @section @code{System.Unsigned_Types} (@code{s-unstyp.ads})
25005
25006
25007 @geindex System.Unsigned_Types (s-unstyp.ads)
25008
25009 This package contains definitions of standard unsigned types that
25010 correspond in size to the standard signed types declared in Standard,
25011 and (unlike the types in Interfaces) have corresponding names. It
25012 also contains some related definitions for other specialized types
25013 used by the compiler in connection with packed array types.
25014
25015 @node System Wch_Cnv s-wchcnv ads,System Wch_Con s-wchcon ads,System Unsigned_Types s-unstyp ads,The GNAT Library
25016 @anchor{gnat_rm/the_gnat_library system-wch-cnv-s-wchcnv-ads}@anchor{406}@anchor{gnat_rm/the_gnat_library id156}@anchor{407}
25017 @section @code{System.Wch_Cnv} (@code{s-wchcnv.ads})
25018
25019
25020 @geindex System.Wch_Cnv (s-wchcnv.ads)
25021
25022 @geindex Wide Character
25023 @geindex Representation
25024
25025 @geindex Wide String
25026 @geindex Conversion
25027
25028 @geindex Representation of wide characters
25029
25030 This package provides routines for converting between
25031 wide and wide wide characters and a representation as a value of type
25032 @code{Standard.String}, using a specified wide character
25033 encoding method. It uses definitions in
25034 package @code{System.Wch_Con}.
25035
25036 @node System Wch_Con s-wchcon ads,,System Wch_Cnv s-wchcnv ads,The GNAT Library
25037 @anchor{gnat_rm/the_gnat_library id157}@anchor{408}@anchor{gnat_rm/the_gnat_library system-wch-con-s-wchcon-ads}@anchor{409}
25038 @section @code{System.Wch_Con} (@code{s-wchcon.ads})
25039
25040
25041 @geindex System.Wch_Con (s-wchcon.ads)
25042
25043 This package provides definitions and descriptions of
25044 the various methods used for encoding wide characters
25045 in ordinary strings. These definitions are used by
25046 the package @code{System.Wch_Cnv}.
25047
25048 @node Interfacing to Other Languages,Specialized Needs Annexes,The GNAT Library,Top
25049 @anchor{gnat_rm/interfacing_to_other_languages interfacing-to-other-languages}@anchor{11}@anchor{gnat_rm/interfacing_to_other_languages doc}@anchor{40a}@anchor{gnat_rm/interfacing_to_other_languages id1}@anchor{40b}
25050 @chapter Interfacing to Other Languages
25051
25052
25053 The facilities in Annex B of the Ada Reference Manual are fully
25054 implemented in GNAT, and in addition, a full interface to C++ is
25055 provided.
25056
25057 @menu
25058 * Interfacing to C::
25059 * Interfacing to C++::
25060 * Interfacing to COBOL::
25061 * Interfacing to Fortran::
25062 * Interfacing to non-GNAT Ada code::
25063
25064 @end menu
25065
25066 @node Interfacing to C,Interfacing to C++,,Interfacing to Other Languages
25067 @anchor{gnat_rm/interfacing_to_other_languages interfacing-to-c}@anchor{40c}@anchor{gnat_rm/interfacing_to_other_languages id2}@anchor{40d}
25068 @section Interfacing to C
25069
25070
25071 Interfacing to C with GNAT can use one of two approaches:
25072
25073
25074 @itemize *
25075
25076 @item
25077 The types in the package @code{Interfaces.C} may be used.
25078
25079 @item
25080 Standard Ada types may be used directly. This may be less portable to
25081 other compilers, but will work on all GNAT compilers, which guarantee
25082 correspondence between the C and Ada types.
25083 @end itemize
25084
25085 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
25086 effect, since this is the default. The following table shows the
25087 correspondence between Ada scalar types and the corresponding C types.
25088
25089
25090 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
25091 @headitem
25092
25093 Ada Type
25094
25095 @tab
25096
25097 C Type
25098
25099 @item
25100
25101 @code{Integer}
25102
25103 @tab
25104
25105 @code{int}
25106
25107 @item
25108
25109 @code{Short_Integer}
25110
25111 @tab
25112
25113 @code{short}
25114
25115 @item
25116
25117 @code{Short_Short_Integer}
25118
25119 @tab
25120
25121 @code{signed char}
25122
25123 @item
25124
25125 @code{Long_Integer}
25126
25127 @tab
25128
25129 @code{long}
25130
25131 @item
25132
25133 @code{Long_Long_Integer}
25134
25135 @tab
25136
25137 @code{long long}
25138
25139 @item
25140
25141 @code{Short_Float}
25142
25143 @tab
25144
25145 @code{float}
25146
25147 @item
25148
25149 @code{Float}
25150
25151 @tab
25152
25153 @code{float}
25154
25155 @item
25156
25157 @code{Long_Float}
25158
25159 @tab
25160
25161 @code{double}
25162
25163 @item
25164
25165 @code{Long_Long_Float}
25166
25167 @tab
25168
25169 This is the longest floating-point type supported by the hardware.
25170
25171 @end multitable
25172
25173
25174 Additionally, there are the following general correspondences between Ada
25175 and C types:
25176
25177
25178 @itemize *
25179
25180 @item
25181 Ada enumeration types map to C enumeration types directly if pragma
25182 @code{Convention C} is specified, which causes them to have a length of
25183 32 bits, except for boolean types which map to C99 @code{bool} and for
25184 which the length is 8 bits.
25185 Without pragma @code{Convention C}, Ada enumeration types map to
25186 8, 16, or 32 bits (i.e., C types @code{signed char}, @code{short},
25187 @code{int}, respectively) depending on the number of values passed.
25188 This is the only case in which pragma @code{Convention C} affects the
25189 representation of an Ada type.
25190
25191 @item
25192 Ada access types map to C pointers, except for the case of pointers to
25193 unconstrained types in Ada, which have no direct C equivalent.
25194
25195 @item
25196 Ada arrays map directly to C arrays.
25197
25198 @item
25199 Ada records map directly to C structures.
25200
25201 @item
25202 Packed Ada records map to C structures where all members are bit fields
25203 of the length corresponding to the @code{type'Size} value in Ada.
25204 @end itemize
25205
25206 @node Interfacing to C++,Interfacing to COBOL,Interfacing to C,Interfacing to Other Languages
25207 @anchor{gnat_rm/interfacing_to_other_languages id4}@anchor{40e}@anchor{gnat_rm/interfacing_to_other_languages id3}@anchor{47}
25208 @section Interfacing to C++
25209
25210
25211 The interface to C++ makes use of the following pragmas, which are
25212 primarily intended to be constructed automatically using a binding generator
25213 tool, although it is possible to construct them by hand.
25214
25215 Using these pragmas it is possible to achieve complete
25216 inter-operability between Ada tagged types and C++ class definitions.
25217 See @ref{7,,Implementation Defined Pragmas}, for more details.
25218
25219
25220 @table @asis
25221
25222 @item @code{pragma CPP_Class ([Entity =>] @emph{LOCAL_NAME})}
25223
25224 The argument denotes an entity in the current declarative region that is
25225 declared as a tagged or untagged record type. It indicates that the type
25226 corresponds to an externally declared C++ class type, and is to be laid
25227 out the same way that C++ would lay out the type.
25228
25229 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
25230 for backward compatibility but its functionality is available
25231 using pragma @code{Import} with @code{Convention} = @code{CPP}.
25232
25233 @item @code{pragma CPP_Constructor ([Entity =>] @emph{LOCAL_NAME})}
25234
25235 This pragma identifies an imported function (imported in the usual way
25236 with pragma @code{Import}) as corresponding to a C++ constructor.
25237 @end table
25238
25239 A few restrictions are placed on the use of the @code{Access} attribute
25240 in conjunction with subprograms subject to convention @code{CPP}: the
25241 attribute may be used neither on primitive operations of a tagged
25242 record type with convention @code{CPP}, imported or not, nor on
25243 subprograms imported with pragma @code{CPP_Constructor}.
25244
25245 In addition, C++ exceptions are propagated and can be handled in an
25246 @code{others} choice of an exception handler. The corresponding Ada
25247 occurrence has no message, and the simple name of the exception identity
25248 contains @code{Foreign_Exception}. Finalization and awaiting dependent
25249 tasks works properly when such foreign exceptions are propagated.
25250
25251 It is also possible to import a C++ exception using the following syntax:
25252
25253 @example
25254 LOCAL_NAME : exception;
25255 pragma Import (Cpp,
25256 [Entity =>] LOCAL_NAME,
25257 [External_Name =>] static_string_EXPRESSION);
25258 @end example
25259
25260 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
25261 cover a specific C++ exception in an exception handler.
25262
25263 @node Interfacing to COBOL,Interfacing to Fortran,Interfacing to C++,Interfacing to Other Languages
25264 @anchor{gnat_rm/interfacing_to_other_languages id5}@anchor{40f}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-cobol}@anchor{410}
25265 @section Interfacing to COBOL
25266
25267
25268 Interfacing to COBOL is achieved as described in section B.4 of
25269 the Ada Reference Manual.
25270
25271 @node Interfacing to Fortran,Interfacing to non-GNAT Ada code,Interfacing to COBOL,Interfacing to Other Languages
25272 @anchor{gnat_rm/interfacing_to_other_languages id6}@anchor{411}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-fortran}@anchor{412}
25273 @section Interfacing to Fortran
25274
25275
25276 Interfacing to Fortran is achieved as described in section B.5 of the
25277 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
25278 multi-dimensional array causes the array to be stored in column-major
25279 order as required for convenient interface to Fortran.
25280
25281 @node Interfacing to non-GNAT Ada code,,Interfacing to Fortran,Interfacing to Other Languages
25282 @anchor{gnat_rm/interfacing_to_other_languages interfacing-to-non-gnat-ada-code}@anchor{413}@anchor{gnat_rm/interfacing_to_other_languages id7}@anchor{414}
25283 @section Interfacing to non-GNAT Ada code
25284
25285
25286 It is possible to specify the convention @code{Ada} in a pragma
25287 @code{Import} or pragma @code{Export}. However this refers to
25288 the calling conventions used by GNAT, which may or may not be
25289 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
25290 compiler to allow interoperation.
25291
25292 If arguments types are kept simple, and if the foreign compiler generally
25293 follows system calling conventions, then it may be possible to integrate
25294 files compiled by other Ada compilers, provided that the elaboration
25295 issues are adequately addressed (for example by eliminating the
25296 need for any load time elaboration).
25297
25298 In particular, GNAT running on VMS is designed to
25299 be highly compatible with the DEC Ada 83 compiler, so this is one
25300 case in which it is possible to import foreign units of this type,
25301 provided that the data items passed are restricted to simple scalar
25302 values or simple record types without variants, or simple array
25303 types with fixed bounds.
25304
25305 @node Specialized Needs Annexes,Implementation of Specific Ada Features,Interfacing to Other Languages,Top
25306 @anchor{gnat_rm/specialized_needs_annexes specialized-needs-annexes}@anchor{12}@anchor{gnat_rm/specialized_needs_annexes doc}@anchor{415}@anchor{gnat_rm/specialized_needs_annexes id1}@anchor{416}
25307 @chapter Specialized Needs Annexes
25308
25309
25310 Ada 95, Ada 2005, and Ada 2012 define a number of Specialized Needs Annexes, which are not
25311 required in all implementations. However, as described in this chapter,
25312 GNAT implements all of these annexes:
25313
25314
25315 @table @asis
25316
25317 @item @emph{Systems Programming (Annex C)}
25318
25319 The Systems Programming Annex is fully implemented.
25320
25321 @item @emph{Real-Time Systems (Annex D)}
25322
25323 The Real-Time Systems Annex is fully implemented.
25324
25325 @item @emph{Distributed Systems (Annex E)}
25326
25327 Stub generation is fully implemented in the GNAT compiler. In addition,
25328 a complete compatible PCS is available as part of the GLADE system,
25329 a separate product. When the two
25330 products are used in conjunction, this annex is fully implemented.
25331
25332 @item @emph{Information Systems (Annex F)}
25333
25334 The Information Systems annex is fully implemented.
25335
25336 @item @emph{Numerics (Annex G)}
25337
25338 The Numerics Annex is fully implemented.
25339
25340 @item @emph{Safety and Security / High-Integrity Systems (Annex H)}
25341
25342 The Safety and Security Annex (termed the High-Integrity Systems Annex
25343 in Ada 2005) is fully implemented.
25344 @end table
25345
25346 @node Implementation of Specific Ada Features,Implementation of Ada 2012 Features,Specialized Needs Annexes,Top
25347 @anchor{gnat_rm/implementation_of_specific_ada_features implementation-of-specific-ada-features}@anchor{13}@anchor{gnat_rm/implementation_of_specific_ada_features doc}@anchor{417}@anchor{gnat_rm/implementation_of_specific_ada_features id1}@anchor{418}
25348 @chapter Implementation of Specific Ada Features
25349
25350
25351 This chapter describes the GNAT implementation of several Ada language
25352 facilities.
25353
25354 @menu
25355 * Machine Code Insertions::
25356 * GNAT Implementation of Tasking::
25357 * GNAT Implementation of Shared Passive Packages::
25358 * Code Generation for Array Aggregates::
25359 * The Size of Discriminated Records with Default Discriminants::
25360 * Strict Conformance to the Ada Reference Manual::
25361
25362 @end menu
25363
25364 @node Machine Code Insertions,GNAT Implementation of Tasking,,Implementation of Specific Ada Features
25365 @anchor{gnat_rm/implementation_of_specific_ada_features machine-code-insertions}@anchor{169}@anchor{gnat_rm/implementation_of_specific_ada_features id2}@anchor{419}
25366 @section Machine Code Insertions
25367
25368
25369 @geindex Machine Code insertions
25370
25371 Package @code{Machine_Code} provides machine code support as described
25372 in the Ada Reference Manual in two separate forms:
25373
25374
25375 @itemize *
25376
25377 @item
25378 Machine code statements, consisting of qualified expressions that
25379 fit the requirements of RM section 13.8.
25380
25381 @item
25382 An intrinsic callable procedure, providing an alternative mechanism of
25383 including machine instructions in a subprogram.
25384 @end itemize
25385
25386 The two features are similar, and both are closely related to the mechanism
25387 provided by the asm instruction in the GNU C compiler. Full understanding
25388 and use of the facilities in this package requires understanding the asm
25389 instruction, see the section on Extended Asm in
25390 @cite{Using_the_GNU_Compiler_Collection_(GCC)}.
25391
25392 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
25393 semantic restrictions and effects as described below. Both are provided so
25394 that the procedure call can be used as a statement, and the function call
25395 can be used to form a code_statement.
25396
25397 Consider this C @code{asm} instruction:
25398
25399 @example
25400 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
25401 @end example
25402
25403 The equivalent can be written for GNAT as:
25404
25405 @example
25406 Asm ("fsinx %1 %0",
25407 My_Float'Asm_Output ("=f", result),
25408 My_Float'Asm_Input ("f", angle));
25409 @end example
25410
25411 The first argument to @code{Asm} is the assembler template, and is
25412 identical to what is used in GNU C. This string must be a static
25413 expression. The second argument is the output operand list. It is
25414 either a single @code{Asm_Output} attribute reference, or a list of such
25415 references enclosed in parentheses (technically an array aggregate of
25416 such references).
25417
25418 The @code{Asm_Output} attribute denotes a function that takes two
25419 parameters. The first is a string, the second is the name of a variable
25420 of the type designated by the attribute prefix. The first (string)
25421 argument is required to be a static expression and designates the
25422 constraint (see the section on Constraints in
25423 @cite{Using_the_GNU_Compiler_Collection_(GCC)})
25424 for the parameter; e.g., what kind of register is required. The second
25425 argument is the variable to be written or updated with the
25426 result. The possible values for constraint are the same as those used in
25427 the RTL, and are dependent on the configuration file used to build the
25428 GCC back end. If there are no output operands, then this argument may
25429 either be omitted, or explicitly given as @code{No_Output_Operands}.
25430 No support is provided for GNU C's symbolic names for output parameters.
25431
25432 The second argument of @code{my_float'Asm_Output} functions as
25433 though it were an @code{out} parameter, which is a little curious, but
25434 all names have the form of expressions, so there is no syntactic
25435 irregularity, even though normally functions would not be permitted
25436 @code{out} parameters. The third argument is the list of input
25437 operands. It is either a single @code{Asm_Input} attribute reference, or
25438 a list of such references enclosed in parentheses (technically an array
25439 aggregate of such references).
25440
25441 The @code{Asm_Input} attribute denotes a function that takes two
25442 parameters. The first is a string, the second is an expression of the
25443 type designated by the prefix. The first (string) argument is required
25444 to be a static expression, and is the constraint for the parameter,
25445 (e.g., what kind of register is required). The second argument is the
25446 value to be used as the input argument. The possible values for the
25447 constraint are the same as those used in the RTL, and are dependent on
25448 the configuration file used to built the GCC back end.
25449 No support is provided for GNU C's symbolic names for input parameters.
25450
25451 If there are no input operands, this argument may either be omitted, or
25452 explicitly given as @code{No_Input_Operands}. The fourth argument, not
25453 present in the above example, is a list of register names, called the
25454 @emph{clobber} argument. This argument, if given, must be a static string
25455 expression, and is a space or comma separated list of names of registers
25456 that must be considered destroyed as a result of the @code{Asm} call. If
25457 this argument is the null string (the default value), then the code
25458 generator assumes that no additional registers are destroyed.
25459 In addition to registers, the special clobbers @code{memory} and
25460 @code{cc} as described in the GNU C docs are both supported.
25461
25462 The fifth argument, not present in the above example, called the
25463 @emph{volatile} argument, is by default @code{False}. It can be set to
25464 the literal value @code{True} to indicate to the code generator that all
25465 optimizations with respect to the instruction specified should be
25466 suppressed, and in particular an instruction that has outputs
25467 will still be generated, even if none of the outputs are
25468 used. See @cite{Using_the_GNU_Compiler_Collection_(GCC)}
25469 for the full description.
25470 Generally it is strongly advisable to use Volatile for any ASM statement
25471 that is missing either input or output operands or to avoid unwanted
25472 optimizations. A warning is generated if this advice is not followed.
25473
25474 No support is provided for GNU C's @code{asm goto} feature.
25475
25476 The @code{Asm} subprograms may be used in two ways. First the procedure
25477 forms can be used anywhere a procedure call would be valid, and
25478 correspond to what the RM calls 'intrinsic' routines. Such calls can
25479 be used to intersperse machine instructions with other Ada statements.
25480 Second, the function forms, which return a dummy value of the limited
25481 private type @code{Asm_Insn}, can be used in code statements, and indeed
25482 this is the only context where such calls are allowed. Code statements
25483 appear as aggregates of the form:
25484
25485 @example
25486 Asm_Insn'(Asm (...));
25487 Asm_Insn'(Asm_Volatile (...));
25488 @end example
25489
25490 In accordance with RM rules, such code statements are allowed only
25491 within subprograms whose entire body consists of such statements. It is
25492 not permissible to intermix such statements with other Ada statements.
25493
25494 Typically the form using intrinsic procedure calls is more convenient
25495 and more flexible. The code statement form is provided to meet the RM
25496 suggestion that such a facility should be made available. The following
25497 is the exact syntax of the call to @code{Asm}. As usual, if named notation
25498 is used, the arguments may be given in arbitrary order, following the
25499 normal rules for use of positional and named arguments:
25500
25501 @example
25502 ASM_CALL ::= Asm (
25503 [Template =>] static_string_EXPRESSION
25504 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
25505 [,[Inputs =>] INPUT_OPERAND_LIST ]
25506 [,[Clobber =>] static_string_EXPRESSION ]
25507 [,[Volatile =>] static_boolean_EXPRESSION] )
25508
25509 OUTPUT_OPERAND_LIST ::=
25510 [PREFIX.]No_Output_Operands
25511 | OUTPUT_OPERAND_ATTRIBUTE
25512 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
25513
25514 OUTPUT_OPERAND_ATTRIBUTE ::=
25515 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
25516
25517 INPUT_OPERAND_LIST ::=
25518 [PREFIX.]No_Input_Operands
25519 | INPUT_OPERAND_ATTRIBUTE
25520 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
25521
25522 INPUT_OPERAND_ATTRIBUTE ::=
25523 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
25524 @end example
25525
25526 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
25527 are declared in the package @code{Machine_Code} and must be referenced
25528 according to normal visibility rules. In particular if there is no
25529 @code{use} clause for this package, then appropriate package name
25530 qualification is required.
25531
25532 @node GNAT Implementation of Tasking,GNAT Implementation of Shared Passive Packages,Machine Code Insertions,Implementation of Specific Ada Features
25533 @anchor{gnat_rm/implementation_of_specific_ada_features id3}@anchor{41a}@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-tasking}@anchor{41b}
25534 @section GNAT Implementation of Tasking
25535
25536
25537 This chapter outlines the basic GNAT approach to tasking (in particular,
25538 a multi-layered library for portability) and discusses issues related
25539 to compliance with the Real-Time Systems Annex.
25540
25541 @menu
25542 * Mapping Ada Tasks onto the Underlying Kernel Threads::
25543 * Ensuring Compliance with the Real-Time Annex::
25544 * Support for Locking Policies::
25545
25546 @end menu
25547
25548 @node Mapping Ada Tasks onto the Underlying Kernel Threads,Ensuring Compliance with the Real-Time Annex,,GNAT Implementation of Tasking
25549 @anchor{gnat_rm/implementation_of_specific_ada_features mapping-ada-tasks-onto-the-underlying-kernel-threads}@anchor{41c}@anchor{gnat_rm/implementation_of_specific_ada_features id4}@anchor{41d}
25550 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
25551
25552
25553 GNAT's run-time support comprises two layers:
25554
25555
25556 @itemize *
25557
25558 @item
25559 GNARL (GNAT Run-time Layer)
25560
25561 @item
25562 GNULL (GNAT Low-level Library)
25563 @end itemize
25564
25565 In GNAT, Ada's tasking services rely on a platform and OS independent
25566 layer known as GNARL. This code is responsible for implementing the
25567 correct semantics of Ada's task creation, rendezvous, protected
25568 operations etc.
25569
25570 GNARL decomposes Ada's tasking semantics into simpler lower level
25571 operations such as create a thread, set the priority of a thread,
25572 yield, create a lock, lock/unlock, etc. The spec for these low-level
25573 operations constitutes GNULLI, the GNULL Interface. This interface is
25574 directly inspired from the POSIX real-time API.
25575
25576 If the underlying executive or OS implements the POSIX standard
25577 faithfully, the GNULL Interface maps as is to the services offered by
25578 the underlying kernel. Otherwise, some target dependent glue code maps
25579 the services offered by the underlying kernel to the semantics expected
25580 by GNARL.
25581
25582 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
25583 key point is that each Ada task is mapped on a thread in the underlying
25584 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
25585
25586 In addition Ada task priorities map onto the underlying thread priorities.
25587 Mapping Ada tasks onto the underlying kernel threads has several advantages:
25588
25589
25590 @itemize *
25591
25592 @item
25593 The underlying scheduler is used to schedule the Ada tasks. This
25594 makes Ada tasks as efficient as kernel threads from a scheduling
25595 standpoint.
25596
25597 @item
25598 Interaction with code written in C containing threads is eased
25599 since at the lowest level Ada tasks and C threads map onto the same
25600 underlying kernel concept.
25601
25602 @item
25603 When an Ada task is blocked during I/O the remaining Ada tasks are
25604 able to proceed.
25605
25606 @item
25607 On multiprocessor systems Ada tasks can execute in parallel.
25608 @end itemize
25609
25610 Some threads libraries offer a mechanism to fork a new process, with the
25611 child process duplicating the threads from the parent.
25612 GNAT does not
25613 support this functionality when the parent contains more than one task.
25614
25615 @geindex Forking a new process
25616
25617 @node Ensuring Compliance with the Real-Time Annex,Support for Locking Policies,Mapping Ada Tasks onto the Underlying Kernel Threads,GNAT Implementation of Tasking
25618 @anchor{gnat_rm/implementation_of_specific_ada_features id5}@anchor{41e}@anchor{gnat_rm/implementation_of_specific_ada_features ensuring-compliance-with-the-real-time-annex}@anchor{41f}
25619 @subsection Ensuring Compliance with the Real-Time Annex
25620
25621
25622 @geindex Real-Time Systems Annex compliance
25623
25624 Although mapping Ada tasks onto
25625 the underlying threads has significant advantages, it does create some
25626 complications when it comes to respecting the scheduling semantics
25627 specified in the real-time annex (Annex D).
25628
25629 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
25630 scheduling policy states:
25631
25632 @quotation
25633
25634 @emph{When the active priority of a ready task that is not running
25635 changes, or the setting of its base priority takes effect, the
25636 task is removed from the ready queue for its old active priority
25637 and is added at the tail of the ready queue for its new active
25638 priority, except in the case where the active priority is lowered
25639 due to the loss of inherited priority, in which case the task is
25640 added at the head of the ready queue for its new active priority.}
25641 @end quotation
25642
25643 While most kernels do put tasks at the end of the priority queue when
25644 a task changes its priority, (which respects the main
25645 FIFO_Within_Priorities requirement), almost none keep a thread at the
25646 beginning of its priority queue when its priority drops from the loss
25647 of inherited priority.
25648
25649 As a result most vendors have provided incomplete Annex D implementations.
25650
25651 The GNAT run-time, has a nice cooperative solution to this problem
25652 which ensures that accurate FIFO_Within_Priorities semantics are
25653 respected.
25654
25655 The principle is as follows. When an Ada task T is about to start
25656 running, it checks whether some other Ada task R with the same
25657 priority as T has been suspended due to the loss of priority
25658 inheritance. If this is the case, T yields and is placed at the end of
25659 its priority queue. When R arrives at the front of the queue it
25660 executes.
25661
25662 Note that this simple scheme preserves the relative order of the tasks
25663 that were ready to execute in the priority queue where R has been
25664 placed at the end.
25665
25666 @c Support_for_Locking_Policies
25667
25668 @node Support for Locking Policies,,Ensuring Compliance with the Real-Time Annex,GNAT Implementation of Tasking
25669 @anchor{gnat_rm/implementation_of_specific_ada_features support-for-locking-policies}@anchor{420}
25670 @subsection Support for Locking Policies
25671
25672
25673 This section specifies which policies specified by pragma Locking_Policy
25674 are supported on which platforms.
25675
25676 GNAT supports the standard @code{Ceiling_Locking} policy, and the
25677 implementation defined @code{Inheritance_Locking} and
25678 @code{Concurrent_Readers_Locking} policies.
25679
25680 @code{Ceiling_Locking} is supported on all platforms if the operating system
25681 supports it. In particular, @code{Ceiling_Locking} is not supported on
25682 VxWorks.
25683 @code{Inheritance_Locking} is supported on
25684 Linux,
25685 Darwin (Mac OS X),
25686 LynxOS 178,
25687 and VxWorks.
25688 @code{Concurrent_Readers_Locking} is supported on Linux.
25689
25690 Notes about @code{Ceiling_Locking} on Linux:
25691 If the process is running as 'root', ceiling locking is used.
25692 If the capabilities facility is installed
25693 ("sudo apt-get --assume-yes install libcap-dev" on Ubuntu,
25694 for example),
25695 and the program is linked against that library
25696 ("-largs -lcap"),
25697 and the executable file has the cap_sys_nice capability
25698 ("sudo /sbin/setcap cap_sys_nice=ep executable_file_name"),
25699 then ceiling locking is used.
25700 Otherwise, the @code{Ceiling_Locking} policy is ignored.
25701
25702 @node GNAT Implementation of Shared Passive Packages,Code Generation for Array Aggregates,GNAT Implementation of Tasking,Implementation of Specific Ada Features
25703 @anchor{gnat_rm/implementation_of_specific_ada_features id6}@anchor{421}@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-shared-passive-packages}@anchor{422}
25704 @section GNAT Implementation of Shared Passive Packages
25705
25706
25707 @geindex Shared passive packages
25708
25709 GNAT fully implements the
25710 @geindex pragma Shared_Passive
25711 pragma
25712 @code{Shared_Passive} for
25713 the purpose of designating shared passive packages.
25714 This allows the use of passive partitions in the
25715 context described in the Ada Reference Manual; i.e., for communication
25716 between separate partitions of a distributed application using the
25717 features in Annex E.
25718
25719 @geindex Annex E
25720
25721 @geindex Distribution Systems Annex
25722
25723 However, the implementation approach used by GNAT provides for more
25724 extensive usage as follows:
25725
25726
25727 @table @asis
25728
25729 @item @emph{Communication between separate programs}
25730
25731 This allows separate programs to access the data in passive
25732 partitions, using protected objects for synchronization where
25733 needed. The only requirement is that the two programs have a
25734 common shared file system. It is even possible for programs
25735 running on different machines with different architectures
25736 (e.g., different endianness) to communicate via the data in
25737 a passive partition.
25738
25739 @item @emph{Persistence between program runs}
25740
25741 The data in a passive package can persist from one run of a
25742 program to another, so that a later program sees the final
25743 values stored by a previous run of the same program.
25744 @end table
25745
25746 The implementation approach used is to store the data in files. A
25747 separate stream file is created for each object in the package, and
25748 an access to an object causes the corresponding file to be read or
25749 written.
25750
25751 @geindex SHARED_MEMORY_DIRECTORY environment variable
25752
25753 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
25754 set to the directory to be used for these files.
25755 The files in this directory
25756 have names that correspond to their fully qualified names. For
25757 example, if we have the package
25758
25759 @example
25760 package X is
25761 pragma Shared_Passive (X);
25762 Y : Integer;
25763 Z : Float;
25764 end X;
25765 @end example
25766
25767 and the environment variable is set to @code{/stemp/}, then the files created
25768 will have the names:
25769
25770 @example
25771 /stemp/x.y
25772 /stemp/x.z
25773 @end example
25774
25775 These files are created when a value is initially written to the object, and
25776 the files are retained until manually deleted. This provides the persistence
25777 semantics. If no file exists, it means that no partition has assigned a value
25778 to the variable; in this case the initial value declared in the package
25779 will be used. This model ensures that there are no issues in synchronizing
25780 the elaboration process, since elaboration of passive packages elaborates the
25781 initial values, but does not create the files.
25782
25783 The files are written using normal @code{Stream_IO} access.
25784 If you want to be able
25785 to communicate between programs or partitions running on different
25786 architectures, then you should use the XDR versions of the stream attribute
25787 routines, since these are architecture independent.
25788
25789 If active synchronization is required for access to the variables in the
25790 shared passive package, then as described in the Ada Reference Manual, the
25791 package may contain protected objects used for this purpose. In this case
25792 a lock file (whose name is @code{___lock} (three underscores)
25793 is created in the shared memory directory.
25794
25795 @geindex ___lock file (for shared passive packages)
25796
25797 This is used to provide the required locking
25798 semantics for proper protected object synchronization.
25799
25800 @node Code Generation for Array Aggregates,The Size of Discriminated Records with Default Discriminants,GNAT Implementation of Shared Passive Packages,Implementation of Specific Ada Features
25801 @anchor{gnat_rm/implementation_of_specific_ada_features code-generation-for-array-aggregates}@anchor{423}@anchor{gnat_rm/implementation_of_specific_ada_features id7}@anchor{424}
25802 @section Code Generation for Array Aggregates
25803
25804
25805 Aggregates have a rich syntax and allow the user to specify the values of
25806 complex data structures by means of a single construct. As a result, the
25807 code generated for aggregates can be quite complex and involve loops, case
25808 statements and multiple assignments. In the simplest cases, however, the
25809 compiler will recognize aggregates whose components and constraints are
25810 fully static, and in those cases the compiler will generate little or no
25811 executable code. The following is an outline of the code that GNAT generates
25812 for various aggregate constructs. For further details, you will find it
25813 useful to examine the output produced by the -gnatG flag to see the expanded
25814 source that is input to the code generator. You may also want to examine
25815 the assembly code generated at various levels of optimization.
25816
25817 The code generated for aggregates depends on the context, the component values,
25818 and the type. In the context of an object declaration the code generated is
25819 generally simpler than in the case of an assignment. As a general rule, static
25820 component values and static subtypes also lead to simpler code.
25821
25822 @menu
25823 * Static constant aggregates with static bounds::
25824 * Constant aggregates with unconstrained nominal types::
25825 * Aggregates with static bounds::
25826 * Aggregates with nonstatic bounds::
25827 * Aggregates in assignment statements::
25828
25829 @end menu
25830
25831 @node Static constant aggregates with static bounds,Constant aggregates with unconstrained nominal types,,Code Generation for Array Aggregates
25832 @anchor{gnat_rm/implementation_of_specific_ada_features static-constant-aggregates-with-static-bounds}@anchor{425}@anchor{gnat_rm/implementation_of_specific_ada_features id8}@anchor{426}
25833 @subsection Static constant aggregates with static bounds
25834
25835
25836 For the declarations:
25837
25838 @example
25839 type One_Dim is array (1..10) of integer;
25840 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
25841 @end example
25842
25843 GNAT generates no executable code: the constant ar0 is placed in static memory.
25844 The same is true for constant aggregates with named associations:
25845
25846 @example
25847 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
25848 Cr3 : constant One_Dim := (others => 7777);
25849 @end example
25850
25851 The same is true for multidimensional constant arrays such as:
25852
25853 @example
25854 type two_dim is array (1..3, 1..3) of integer;
25855 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
25856 @end example
25857
25858 The same is true for arrays of one-dimensional arrays: the following are
25859 static:
25860
25861 @example
25862 type ar1b is array (1..3) of boolean;
25863 type ar_ar is array (1..3) of ar1b;
25864 None : constant ar1b := (others => false); -- fully static
25865 None2 : constant ar_ar := (1..3 => None); -- fully static
25866 @end example
25867
25868 However, for multidimensional aggregates with named associations, GNAT will
25869 generate assignments and loops, even if all associations are static. The
25870 following two declarations generate a loop for the first dimension, and
25871 individual component assignments for the second dimension:
25872
25873 @example
25874 Zero1: constant two_dim := (1..3 => (1..3 => 0));
25875 Zero2: constant two_dim := (others => (others => 0));
25876 @end example
25877
25878 @node Constant aggregates with unconstrained nominal types,Aggregates with static bounds,Static constant aggregates with static bounds,Code Generation for Array Aggregates
25879 @anchor{gnat_rm/implementation_of_specific_ada_features constant-aggregates-with-unconstrained-nominal-types}@anchor{427}@anchor{gnat_rm/implementation_of_specific_ada_features id9}@anchor{428}
25880 @subsection Constant aggregates with unconstrained nominal types
25881
25882
25883 In such cases the aggregate itself establishes the subtype, so that
25884 associations with @code{others} cannot be used. GNAT determines the
25885 bounds for the actual subtype of the aggregate, and allocates the
25886 aggregate statically as well. No code is generated for the following:
25887
25888 @example
25889 type One_Unc is array (natural range <>) of integer;
25890 Cr_Unc : constant One_Unc := (12,24,36);
25891 @end example
25892
25893 @node Aggregates with static bounds,Aggregates with nonstatic bounds,Constant aggregates with unconstrained nominal types,Code Generation for Array Aggregates
25894 @anchor{gnat_rm/implementation_of_specific_ada_features id10}@anchor{429}@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-static-bounds}@anchor{42a}
25895 @subsection Aggregates with static bounds
25896
25897
25898 In all previous examples the aggregate was the initial (and immutable) value
25899 of a constant. If the aggregate initializes a variable, then code is generated
25900 for it as a combination of individual assignments and loops over the target
25901 object. The declarations
25902
25903 @example
25904 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
25905 Cr_Var2 : One_Dim := (others > -1);
25906 @end example
25907
25908 generate the equivalent of
25909
25910 @example
25911 Cr_Var1 (1) := 2;
25912 Cr_Var1 (2) := 3;
25913 Cr_Var1 (3) := 5;
25914 Cr_Var1 (4) := 11;
25915
25916 for I in Cr_Var2'range loop
25917 Cr_Var2 (I) := -1;
25918 end loop;
25919 @end example
25920
25921 @node Aggregates with nonstatic bounds,Aggregates in assignment statements,Aggregates with static bounds,Code Generation for Array Aggregates
25922 @anchor{gnat_rm/implementation_of_specific_ada_features id11}@anchor{42b}@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-nonstatic-bounds}@anchor{42c}
25923 @subsection Aggregates with nonstatic bounds
25924
25925
25926 If the bounds of the aggregate are not statically compatible with the bounds
25927 of the nominal subtype of the target, then constraint checks have to be
25928 generated on the bounds. For a multidimensional array, constraint checks may
25929 have to be applied to sub-arrays individually, if they do not have statically
25930 compatible subtypes.
25931
25932 @node Aggregates in assignment statements,,Aggregates with nonstatic bounds,Code Generation for Array Aggregates
25933 @anchor{gnat_rm/implementation_of_specific_ada_features id12}@anchor{42d}@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-in-assignment-statements}@anchor{42e}
25934 @subsection Aggregates in assignment statements
25935
25936
25937 In general, aggregate assignment requires the construction of a temporary,
25938 and a copy from the temporary to the target of the assignment. This is because
25939 it is not always possible to convert the assignment into a series of individual
25940 component assignments. For example, consider the simple case:
25941
25942 @example
25943 A := (A(2), A(1));
25944 @end example
25945
25946 This cannot be converted into:
25947
25948 @example
25949 A(1) := A(2);
25950 A(2) := A(1);
25951 @end example
25952
25953 So the aggregate has to be built first in a separate location, and then
25954 copied into the target. GNAT recognizes simple cases where this intermediate
25955 step is not required, and the assignments can be performed in place, directly
25956 into the target. The following sufficient criteria are applied:
25957
25958
25959 @itemize *
25960
25961 @item
25962 The bounds of the aggregate are static, and the associations are static.
25963
25964 @item
25965 The components of the aggregate are static constants, names of
25966 simple variables that are not renamings, or expressions not involving
25967 indexed components whose operands obey these rules.
25968 @end itemize
25969
25970 If any of these conditions are violated, the aggregate will be built in
25971 a temporary (created either by the front-end or the code generator) and then
25972 that temporary will be copied onto the target.
25973
25974 @node The Size of Discriminated Records with Default Discriminants,Strict Conformance to the Ada Reference Manual,Code Generation for Array Aggregates,Implementation of Specific Ada Features
25975 @anchor{gnat_rm/implementation_of_specific_ada_features id13}@anchor{42f}@anchor{gnat_rm/implementation_of_specific_ada_features the-size-of-discriminated-records-with-default-discriminants}@anchor{430}
25976 @section The Size of Discriminated Records with Default Discriminants
25977
25978
25979 If a discriminated type @code{T} has discriminants with default values, it is
25980 possible to declare an object of this type without providing an explicit
25981 constraint:
25982
25983 @example
25984 type Size is range 1..100;
25985
25986 type Rec (D : Size := 15) is record
25987 Name : String (1..D);
25988 end T;
25989
25990 Word : Rec;
25991 @end example
25992
25993 Such an object is said to be @emph{unconstrained}.
25994 The discriminant of the object
25995 can be modified by a full assignment to the object, as long as it preserves the
25996 relation between the value of the discriminant, and the value of the components
25997 that depend on it:
25998
25999 @example
26000 Word := (3, "yes");
26001
26002 Word := (5, "maybe");
26003
26004 Word := (5, "no"); -- raises Constraint_Error
26005 @end example
26006
26007 In order to support this behavior efficiently, an unconstrained object is
26008 given the maximum size that any value of the type requires. In the case
26009 above, @code{Word} has storage for the discriminant and for
26010 a @code{String} of length 100.
26011 It is important to note that unconstrained objects do not require dynamic
26012 allocation. It would be an improper implementation to place on the heap those
26013 components whose size depends on discriminants. (This improper implementation
26014 was used by some Ada83 compilers, where the @code{Name} component above
26015 would have
26016 been stored as a pointer to a dynamic string). Following the principle that
26017 dynamic storage management should never be introduced implicitly,
26018 an Ada compiler should reserve the full size for an unconstrained declared
26019 object, and place it on the stack.
26020
26021 This maximum size approach
26022 has been a source of surprise to some users, who expect the default
26023 values of the discriminants to determine the size reserved for an
26024 unconstrained object: "If the default is 15, why should the object occupy
26025 a larger size?"
26026 The answer, of course, is that the discriminant may be later modified,
26027 and its full range of values must be taken into account. This is why the
26028 declaration:
26029
26030 @example
26031 type Rec (D : Positive := 15) is record
26032 Name : String (1..D);
26033 end record;
26034
26035 Too_Large : Rec;
26036 @end example
26037
26038 is flagged by the compiler with a warning:
26039 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
26040 because the required size includes @code{Positive'Last}
26041 bytes. As the first example indicates, the proper approach is to declare an
26042 index type of 'reasonable' range so that unconstrained objects are not too
26043 large.
26044
26045 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
26046 created in the heap by means of an allocator, then it is @emph{not}
26047 unconstrained:
26048 it is constrained by the default values of the discriminants, and those values
26049 cannot be modified by full assignment. This is because in the presence of
26050 aliasing all views of the object (which may be manipulated by different tasks,
26051 say) must be consistent, so it is imperative that the object, once created,
26052 remain invariant.
26053
26054 @node Strict Conformance to the Ada Reference Manual,,The Size of Discriminated Records with Default Discriminants,Implementation of Specific Ada Features
26055 @anchor{gnat_rm/implementation_of_specific_ada_features strict-conformance-to-the-ada-reference-manual}@anchor{431}@anchor{gnat_rm/implementation_of_specific_ada_features id14}@anchor{432}
26056 @section Strict Conformance to the Ada Reference Manual
26057
26058
26059 The dynamic semantics defined by the Ada Reference Manual impose a set of
26060 run-time checks to be generated. By default, the GNAT compiler will insert many
26061 run-time checks into the compiled code, including most of those required by the
26062 Ada Reference Manual. However, there are two checks that are not enabled in
26063 the default mode for efficiency reasons: checks for access before elaboration
26064 on subprogram calls, and stack overflow checking (most operating systems do not
26065 perform this check by default).
26066
26067 Strict conformance to the Ada Reference Manual can be achieved by adding two
26068 compiler options for dynamic checks for access-before-elaboration on subprogram
26069 calls and generic instantiations (@emph{-gnatE}), and stack overflow checking
26070 (@emph{-fstack-check}).
26071
26072 Note that the result of a floating point arithmetic operation in overflow and
26073 invalid situations, when the @code{Machine_Overflows} attribute of the result
26074 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
26075 case for machines compliant with the IEEE floating-point standard, but on
26076 machines that are not fully compliant with this standard, such as Alpha, the
26077 @emph{-mieee} compiler flag must be used for achieving IEEE confirming
26078 behavior (although at the cost of a significant performance penalty), so
26079 infinite and NaN values are properly generated.
26080
26081 @node Implementation of Ada 2012 Features,Obsolescent Features,Implementation of Specific Ada Features,Top
26082 @anchor{gnat_rm/implementation_of_ada_2012_features doc}@anchor{433}@anchor{gnat_rm/implementation_of_ada_2012_features implementation-of-ada-2012-features}@anchor{14}@anchor{gnat_rm/implementation_of_ada_2012_features id1}@anchor{434}
26083 @chapter Implementation of Ada 2012 Features
26084
26085
26086 @geindex Ada 2012 implementation status
26087
26088 @geindex -gnat12 option (gcc)
26089
26090 @geindex pragma Ada_2012
26091
26092 @geindex configuration pragma Ada_2012
26093
26094 @geindex Ada_2012 configuration pragma
26095
26096 This chapter contains a complete list of Ada 2012 features that have been
26097 implemented.
26098 Generally, these features are only
26099 available if the @emph{-gnat12} (Ada 2012 features enabled) option is set,
26100 which is the default behavior,
26101 or if the configuration pragma @code{Ada_2012} is used.
26102
26103 However, new pragmas, attributes, and restrictions are
26104 unconditionally available, since the Ada 95 standard allows the addition of
26105 new pragmas, attributes, and restrictions (there are exceptions, which are
26106 documented in the individual descriptions), and also certain packages
26107 were made available in earlier versions of Ada.
26108
26109 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
26110 This date shows the implementation date of the feature. Any wavefront
26111 subsequent to this date will contain the indicated feature, as will any
26112 subsequent releases. A date of 0000-00-00 means that GNAT has always
26113 implemented the feature, or implemented it as soon as it appeared as a
26114 binding interpretation.
26115
26116 Each feature corresponds to an Ada Issue ('AI') approved by the Ada
26117 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
26118 The features are ordered based on the relevant sections of the Ada
26119 Reference Manual ("RM"). When a given AI relates to multiple points
26120 in the RM, the earliest is used.
26121
26122 A complete description of the AIs may be found in
26123 @indicateurl{http://www.ada-auth.org/ai05-summary.html}.
26124
26125 @geindex AI-0176 (Ada 2012 feature)
26126
26127
26128 @itemize *
26129
26130 @item
26131 @emph{AI-0176 Quantified expressions (2010-09-29)}
26132
26133 Both universally and existentially quantified expressions are implemented.
26134 They use the new syntax for iterators proposed in AI05-139-2, as well as
26135 the standard Ada loop syntax.
26136
26137 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
26138 @end itemize
26139
26140 @geindex AI-0079 (Ada 2012 feature)
26141
26142
26143 @itemize *
26144
26145 @item
26146 @emph{AI-0079 Allow other_format characters in source (2010-07-10)}
26147
26148 Wide characters in the unicode category @emph{other_format} are now allowed in
26149 source programs between tokens, but not within a token such as an identifier.
26150
26151 RM References: 2.01 (4/2) 2.02 (7)
26152 @end itemize
26153
26154 @geindex AI-0091 (Ada 2012 feature)
26155
26156
26157 @itemize *
26158
26159 @item
26160 @emph{AI-0091 Do not allow other_format in identifiers (0000-00-00)}
26161
26162 Wide characters in the unicode category @emph{other_format} are not permitted
26163 within an identifier, since this can be a security problem. The error
26164 message for this case has been improved to be more specific, but GNAT has
26165 never allowed such characters to appear in identifiers.
26166
26167 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)
26168 @end itemize
26169
26170 @geindex AI-0100 (Ada 2012 feature)
26171
26172
26173 @itemize *
26174
26175 @item
26176 @emph{AI-0100 Placement of pragmas (2010-07-01)}
26177
26178 This AI is an earlier version of AI-163. It simplifies the rules
26179 for legal placement of pragmas. In the case of lists that allow pragmas, if
26180 the list may have no elements, then the list may consist solely of pragmas.
26181
26182 RM References: 2.08 (7)
26183 @end itemize
26184
26185 @geindex AI-0163 (Ada 2012 feature)
26186
26187
26188 @itemize *
26189
26190 @item
26191 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
26192
26193 A statement sequence may be composed entirely of pragmas. It is no longer
26194 necessary to add a dummy @code{null} statement to make the sequence legal.
26195
26196 RM References: 2.08 (7) 2.08 (16)
26197 @end itemize
26198
26199 @geindex AI-0080 (Ada 2012 feature)
26200
26201
26202 @itemize *
26203
26204 @item
26205 @emph{AI-0080 'View of' not needed if clear from context (0000-00-00)}
26206
26207 This is an editorial change only, described as non-testable in the AI.
26208
26209 RM References: 3.01 (7)
26210 @end itemize
26211
26212 @geindex AI-0183 (Ada 2012 feature)
26213
26214
26215 @itemize *
26216
26217 @item
26218 @emph{AI-0183 Aspect specifications (2010-08-16)}
26219
26220 Aspect specifications have been fully implemented except for pre and post-
26221 conditions, and type invariants, which have their own separate AI's. All
26222 forms of declarations listed in the AI are supported. The following is a
26223 list of the aspects supported (with GNAT implementation aspects marked)
26224 @end itemize
26225
26226
26227 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxx}
26228 @headitem
26229
26230 Supported Aspect
26231
26232 @tab
26233
26234 Source
26235
26236 @item
26237
26238 @code{Ada_2005}
26239
26240 @tab
26241
26242 -- GNAT
26243
26244 @item
26245
26246 @code{Ada_2012}
26247
26248 @tab
26249
26250 -- GNAT
26251
26252 @item
26253
26254 @code{Address}
26255
26256 @tab
26257
26258 @item
26259
26260 @code{Alignment}
26261
26262 @tab
26263
26264 @item
26265
26266 @code{Atomic}
26267
26268 @tab
26269
26270 @item
26271
26272 @code{Atomic_Components}
26273
26274 @tab
26275
26276 @item
26277
26278 @code{Bit_Order}
26279
26280 @tab
26281
26282 @item
26283
26284 @code{Component_Size}
26285
26286 @tab
26287
26288 @item
26289
26290 @code{Contract_Cases}
26291
26292 @tab
26293
26294 -- GNAT
26295
26296 @item
26297
26298 @code{Discard_Names}
26299
26300 @tab
26301
26302 @item
26303
26304 @code{External_Tag}
26305
26306 @tab
26307
26308 @item
26309
26310 @code{Favor_Top_Level}
26311
26312 @tab
26313
26314 -- GNAT
26315
26316 @item
26317
26318 @code{Inline}
26319
26320 @tab
26321
26322 @item
26323
26324 @code{Inline_Always}
26325
26326 @tab
26327
26328 -- GNAT
26329
26330 @item
26331
26332 @code{Invariant}
26333
26334 @tab
26335
26336 -- GNAT
26337
26338 @item
26339
26340 @code{Machine_Radix}
26341
26342 @tab
26343
26344 @item
26345
26346 @code{No_Return}
26347
26348 @tab
26349
26350 @item
26351
26352 @code{Object_Size}
26353
26354 @tab
26355
26356 -- GNAT
26357
26358 @item
26359
26360 @code{Pack}
26361
26362 @tab
26363
26364 @item
26365
26366 @code{Persistent_BSS}
26367
26368 @tab
26369
26370 -- GNAT
26371
26372 @item
26373
26374 @code{Post}
26375
26376 @tab
26377
26378 @item
26379
26380 @code{Pre}
26381
26382 @tab
26383
26384 @item
26385
26386 @code{Predicate}
26387
26388 @tab
26389
26390 @item
26391
26392 @code{Preelaborable_Initialization}
26393
26394 @tab
26395
26396 @item
26397
26398 @code{Pure_Function}
26399
26400 @tab
26401
26402 -- GNAT
26403
26404 @item
26405
26406 @code{Remote_Access_Type}
26407
26408 @tab
26409
26410 -- GNAT
26411
26412 @item
26413
26414 @code{Shared}
26415
26416 @tab
26417
26418 -- GNAT
26419
26420 @item
26421
26422 @code{Size}
26423
26424 @tab
26425
26426 @item
26427
26428 @code{Storage_Pool}
26429
26430 @tab
26431
26432 @item
26433
26434 @code{Storage_Size}
26435
26436 @tab
26437
26438 @item
26439
26440 @code{Stream_Size}
26441
26442 @tab
26443
26444 @item
26445
26446 @code{Suppress}
26447
26448 @tab
26449
26450 @item
26451
26452 @code{Suppress_Debug_Info}
26453
26454 @tab
26455
26456 -- GNAT
26457
26458 @item
26459
26460 @code{Test_Case}
26461
26462 @tab
26463
26464 -- GNAT
26465
26466 @item
26467
26468 @code{Thread_Local_Storage}
26469
26470 @tab
26471
26472 -- GNAT
26473
26474 @item
26475
26476 @code{Type_Invariant}
26477
26478 @tab
26479
26480 @item
26481
26482 @code{Unchecked_Union}
26483
26484 @tab
26485
26486 @item
26487
26488 @code{Universal_Aliasing}
26489
26490 @tab
26491
26492 -- GNAT
26493
26494 @item
26495
26496 @code{Unmodified}
26497
26498 @tab
26499
26500 -- GNAT
26501
26502 @item
26503
26504 @code{Unreferenced}
26505
26506 @tab
26507
26508 -- GNAT
26509
26510 @item
26511
26512 @code{Unreferenced_Objects}
26513
26514 @tab
26515
26516 -- GNAT
26517
26518 @item
26519
26520 @code{Unsuppress}
26521
26522 @tab
26523
26524 @item
26525
26526 @code{Value_Size}
26527
26528 @tab
26529
26530 -- GNAT
26531
26532 @item
26533
26534 @code{Volatile}
26535
26536 @tab
26537
26538 @item
26539
26540 @code{Volatile_Components}
26541
26542 @tab
26543
26544 @item
26545
26546 @code{Warnings}
26547
26548 @tab
26549
26550 -- GNAT
26551
26552 @end multitable
26553
26554
26555 @quotation
26556
26557 Note that for aspects with an expression, e.g. @code{Size}, the expression is
26558 treated like a default expression (visibility is analyzed at the point of
26559 occurrence of the aspect, but evaluation of the expression occurs at the
26560 freeze point of the entity involved).
26561
26562 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
26563 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
26564 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
26565 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
26566 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
26567 13.03.01 (0)
26568 @end quotation
26569
26570 @geindex AI-0128 (Ada 2012 feature)
26571
26572
26573 @itemize *
26574
26575 @item
26576 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
26577
26578 If an equality operator ("=") is declared for a type, then the implicitly
26579 declared inequality operator ("/=") is a primitive operation of the type.
26580 This is the only reasonable interpretation, and is the one always implemented
26581 by GNAT, but the RM was not entirely clear in making this point.
26582
26583 RM References: 3.02.03 (6) 6.06 (6)
26584 @end itemize
26585
26586 @geindex AI-0003 (Ada 2012 feature)
26587
26588
26589 @itemize *
26590
26591 @item
26592 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
26593
26594 In Ada 2012, a qualified expression is considered to be syntactically a name,
26595 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
26596 useful in disambiguating some cases of overloading.
26597
26598 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
26599 5.04 (7)
26600 @end itemize
26601
26602 @geindex AI-0120 (Ada 2012 feature)
26603
26604
26605 @itemize *
26606
26607 @item
26608 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
26609
26610 This is an RM editorial change only. The section that lists objects that are
26611 constant failed to include the current instance of a protected object
26612 within a protected function. This has always been treated as a constant
26613 in GNAT.
26614
26615 RM References: 3.03 (21)
26616 @end itemize
26617
26618 @geindex AI-0008 (Ada 2012 feature)
26619
26620
26621 @itemize *
26622
26623 @item
26624 @emph{AI-0008 General access to constrained objects (0000-00-00)}
26625
26626 The wording in the RM implied that if you have a general access to a
26627 constrained object, it could be used to modify the discriminants. This was
26628 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
26629 has always done so in this situation.
26630
26631 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
26632 @end itemize
26633
26634 @geindex AI-0093 (Ada 2012 feature)
26635
26636
26637 @itemize *
26638
26639 @item
26640 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
26641
26642 This is an editorial change only, to make more widespread use of the Ada 2012
26643 'immutably limited'.
26644
26645 RM References: 3.03 (23.4/3)
26646 @end itemize
26647
26648 @geindex AI-0096 (Ada 2012 feature)
26649
26650
26651 @itemize *
26652
26653 @item
26654 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
26655
26656 In general it is illegal for a type derived from a formal limited type to be
26657 nonlimited. This AI makes an exception to this rule: derivation is legal
26658 if it appears in the private part of the generic, and the formal type is not
26659 tagged. If the type is tagged, the legality check must be applied to the
26660 private part of the package.
26661
26662 RM References: 3.04 (5.1/2) 6.02 (7)
26663 @end itemize
26664
26665 @geindex AI-0181 (Ada 2012 feature)
26666
26667
26668 @itemize *
26669
26670 @item
26671 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
26672
26673 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
26674 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
26675 @code{Image} and @code{Value} attributes for the character types. Strictly
26676 speaking this is an inconsistency with Ada 95, but in practice the use of
26677 these attributes is so obscure that it will not cause problems.
26678
26679 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
26680 @end itemize
26681
26682 @geindex AI-0182 (Ada 2012 feature)
26683
26684
26685 @itemize *
26686
26687 @item
26688 @emph{AI-0182 Additional forms for} @code{Character'Value} @emph{(0000-00-00)}
26689
26690 This AI allows @code{Character'Value} to accept the string @code{'?'} where
26691 @code{?} is any character including non-graphic control characters. GNAT has
26692 always accepted such strings. It also allows strings such as
26693 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
26694 permission and raises @code{Constraint_Error}, as is certainly still
26695 permitted.
26696
26697 RM References: 3.05 (56/2)
26698 @end itemize
26699
26700 @geindex AI-0214 (Ada 2012 feature)
26701
26702
26703 @itemize *
26704
26705 @item
26706 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
26707
26708 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
26709 to have default expressions by allowing them when the type is limited. It
26710 is often useful to define a default value for a discriminant even though
26711 it can't be changed by assignment.
26712
26713 RM References: 3.07 (9.1/2) 3.07.02 (3)
26714 @end itemize
26715
26716 @geindex AI-0102 (Ada 2012 feature)
26717
26718
26719 @itemize *
26720
26721 @item
26722 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
26723
26724 It is illegal to assign an anonymous access constant to an anonymous access
26725 variable. The RM did not have a clear rule to prevent this, but GNAT has
26726 always generated an error for this usage.
26727
26728 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
26729 @end itemize
26730
26731 @geindex AI-0158 (Ada 2012 feature)
26732
26733
26734 @itemize *
26735
26736 @item
26737 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
26738
26739 This AI extends the syntax of membership tests to simplify complex conditions
26740 that can be expressed as membership in a subset of values of any type. It
26741 introduces syntax for a list of expressions that may be used in loop contexts
26742 as well.
26743
26744 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
26745 @end itemize
26746
26747 @geindex AI-0173 (Ada 2012 feature)
26748
26749
26750 @itemize *
26751
26752 @item
26753 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
26754
26755 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
26756 with the tag of an abstract type, and @code{False} otherwise.
26757
26758 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
26759 @end itemize
26760
26761 @geindex AI-0076 (Ada 2012 feature)
26762
26763
26764 @itemize *
26765
26766 @item
26767 @emph{AI-0076 function with controlling result (0000-00-00)}
26768
26769 This is an editorial change only. The RM defines calls with controlling
26770 results, but uses the term 'function with controlling result' without an
26771 explicit definition.
26772
26773 RM References: 3.09.02 (2/2)
26774 @end itemize
26775
26776 @geindex AI-0126 (Ada 2012 feature)
26777
26778
26779 @itemize *
26780
26781 @item
26782 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
26783
26784 This AI clarifies dispatching rules, and simply confirms that dispatching
26785 executes the operation of the parent type when there is no explicitly or
26786 implicitly declared operation for the descendant type. This has always been
26787 the case in all versions of GNAT.
26788
26789 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
26790 @end itemize
26791
26792 @geindex AI-0097 (Ada 2012 feature)
26793
26794
26795 @itemize *
26796
26797 @item
26798 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
26799
26800 The RM as written implied that in some cases it was possible to create an
26801 object of an abstract type, by having an abstract extension inherit a non-
26802 abstract constructor from its parent type. This mistake has been corrected
26803 in GNAT and in the RM, and this construct is now illegal.
26804
26805 RM References: 3.09.03 (4/2)
26806 @end itemize
26807
26808 @geindex AI-0203 (Ada 2012 feature)
26809
26810
26811 @itemize *
26812
26813 @item
26814 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
26815
26816 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
26817 permitted such usage.
26818
26819 RM References: 3.09.03 (8/3)
26820 @end itemize
26821
26822 @geindex AI-0198 (Ada 2012 feature)
26823
26824
26825 @itemize *
26826
26827 @item
26828 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
26829
26830 This AI resolves a conflict between two rules involving inherited abstract
26831 operations and predefined operators. If a derived numeric type inherits
26832 an abstract operator, it overrides the predefined one. This interpretation
26833 was always the one implemented in GNAT.
26834
26835 RM References: 3.09.03 (4/3)
26836 @end itemize
26837
26838 @geindex AI-0073 (Ada 2012 feature)
26839
26840
26841 @itemize *
26842
26843 @item
26844 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
26845
26846 This AI covers a number of issues regarding returning abstract types. In
26847 particular generic functions cannot have abstract result types or access
26848 result types designated an abstract type. There are some other cases which
26849 are detailed in the AI. Note that this binding interpretation has not been
26850 retrofitted to operate before Ada 2012 mode, since it caused a significant
26851 number of regressions.
26852
26853 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
26854 @end itemize
26855
26856 @geindex AI-0070 (Ada 2012 feature)
26857
26858
26859 @itemize *
26860
26861 @item
26862 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
26863
26864 This is an editorial change only, there are no testable consequences short of
26865 checking for the absence of generated code for an interface declaration.
26866
26867 RM References: 3.09.04 (18/2)
26868 @end itemize
26869
26870 @geindex AI-0208 (Ada 2012 feature)
26871
26872
26873 @itemize *
26874
26875 @item
26876 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
26877
26878 The wording in the Ada 2005 RM concerning characteristics of incomplete views
26879 was incorrect and implied that some programs intended to be legal were now
26880 illegal. GNAT had never considered such programs illegal, so it has always
26881 implemented the intent of this AI.
26882
26883 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
26884 @end itemize
26885
26886 @geindex AI-0162 (Ada 2012 feature)
26887
26888
26889 @itemize *
26890
26891 @item
26892 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
26893
26894 Incomplete types are made more useful by allowing them to be completed by
26895 private types and private extensions.
26896
26897 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
26898 @end itemize
26899
26900 @geindex AI-0098 (Ada 2012 feature)
26901
26902
26903 @itemize *
26904
26905 @item
26906 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
26907
26908 An unintentional omission in the RM implied some inconsistent restrictions on
26909 the use of anonymous access to subprogram values. These restrictions were not
26910 intentional, and have never been enforced by GNAT.
26911
26912 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
26913 @end itemize
26914
26915 @geindex AI-0199 (Ada 2012 feature)
26916
26917
26918 @itemize *
26919
26920 @item
26921 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
26922
26923 A choice list in a record aggregate can include several components of
26924 (distinct) anonymous access types as long as they have matching designated
26925 subtypes.
26926
26927 RM References: 4.03.01 (16)
26928 @end itemize
26929
26930 @geindex AI-0220 (Ada 2012 feature)
26931
26932
26933 @itemize *
26934
26935 @item
26936 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
26937
26938 This AI addresses a wording problem in the RM that appears to permit some
26939 complex cases of aggregates with nonstatic discriminants. GNAT has always
26940 implemented the intended semantics.
26941
26942 RM References: 4.03.01 (17)
26943 @end itemize
26944
26945 @geindex AI-0147 (Ada 2012 feature)
26946
26947
26948 @itemize *
26949
26950 @item
26951 @emph{AI-0147 Conditional expressions (2009-03-29)}
26952
26953 Conditional expressions are permitted. The form of such an expression is:
26954
26955 @example
26956 (if expr then expr @{elsif expr then expr@} [else expr])
26957 @end example
26958
26959 The parentheses can be omitted in contexts where parentheses are present
26960 anyway, such as subprogram arguments and pragma arguments. If the @strong{else}
26961 clause is omitted, @strong{else} @emph{True} is assumed;
26962 thus @code{(if A then B)} is a way to conveniently represent
26963 @emph{(A implies B)} in standard logic.
26964
26965 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
26966 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
26967 @end itemize
26968
26969 @geindex AI-0037 (Ada 2012 feature)
26970
26971
26972 @itemize *
26973
26974 @item
26975 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
26976
26977 This AI confirms that an association of the form @code{Indx => <>} in an
26978 array aggregate must raise @code{Constraint_Error} if @code{Indx}
26979 is out of range. The RM specified a range check on other associations, but
26980 not when the value of the association was defaulted. GNAT has always inserted
26981 a constraint check on the index value.
26982
26983 RM References: 4.03.03 (29)
26984 @end itemize
26985
26986 @geindex AI-0123 (Ada 2012 feature)
26987
26988
26989 @itemize *
26990
26991 @item
26992 @emph{AI-0123 Composability of equality (2010-04-13)}
26993
26994 Equality of untagged record composes, so that the predefined equality for a
26995 composite type that includes a component of some untagged record type
26996 @code{R} uses the equality operation of @code{R} (which may be user-defined
26997 or predefined). This makes the behavior of untagged records identical to that
26998 of tagged types in this respect.
26999
27000 This change is an incompatibility with previous versions of Ada, but it
27001 corrects a non-uniformity that was often a source of confusion. Analysis of
27002 a large number of industrial programs indicates that in those rare cases
27003 where a composite type had an untagged record component with a user-defined
27004 equality, either there was no use of the composite equality, or else the code
27005 expected the same composability as for tagged types, and thus had a bug that
27006 would be fixed by this change.
27007
27008 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
27009 8.05.04 (8)
27010 @end itemize
27011
27012 @geindex AI-0088 (Ada 2012 feature)
27013
27014
27015 @itemize *
27016
27017 @item
27018 @emph{AI-0088 The value of exponentiation (0000-00-00)}
27019
27020 This AI clarifies the equivalence rule given for the dynamic semantics of
27021 exponentiation: the value of the operation can be obtained by repeated
27022 multiplication, but the operation can be implemented otherwise (for example
27023 using the familiar divide-by-two-and-square algorithm, even if this is less
27024 accurate), and does not imply repeated reads of a volatile base.
27025
27026 RM References: 4.05.06 (11)
27027 @end itemize
27028
27029 @geindex AI-0188 (Ada 2012 feature)
27030
27031
27032 @itemize *
27033
27034 @item
27035 @emph{AI-0188 Case expressions (2010-01-09)}
27036
27037 Case expressions are permitted. This allows use of constructs such as:
27038
27039 @example
27040 X := (case Y is when 1 => 2, when 2 => 3, when others => 31)
27041 @end example
27042
27043 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
27044 @end itemize
27045
27046 @geindex AI-0104 (Ada 2012 feature)
27047
27048
27049 @itemize *
27050
27051 @item
27052 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
27053
27054 The assignment @code{Ptr := new not null Some_Ptr;} will raise
27055 @code{Constraint_Error} because the default value of the allocated object is
27056 @strong{null}. This useless construct is illegal in Ada 2012.
27057
27058 RM References: 4.08 (2)
27059 @end itemize
27060
27061 @geindex AI-0157 (Ada 2012 feature)
27062
27063
27064 @itemize *
27065
27066 @item
27067 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
27068
27069 Allocation and Deallocation from an empty storage pool (i.e. allocation or
27070 deallocation of a pointer for which a static storage size clause of zero
27071 has been given) is now illegal and is detected as such. GNAT
27072 previously gave a warning but not an error.
27073
27074 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
27075 @end itemize
27076
27077 @geindex AI-0179 (Ada 2012 feature)
27078
27079
27080 @itemize *
27081
27082 @item
27083 @emph{AI-0179 Statement not required after label (2010-04-10)}
27084
27085 It is not necessary to have a statement following a label, so a label
27086 can appear at the end of a statement sequence without the need for putting a
27087 null statement afterwards, but it is not allowable to have only labels and
27088 no real statements in a statement sequence.
27089
27090 RM References: 5.01 (2)
27091 @end itemize
27092
27093 @geindex AI-0139-2 (Ada 2012 feature)
27094
27095
27096 @itemize *
27097
27098 @item
27099 @emph{AI-0139-2 Syntactic sugar for iterators (2010-09-29)}
27100
27101 The new syntax for iterating over arrays and containers is now implemented.
27102 Iteration over containers is for now limited to read-only iterators. Only
27103 default iterators are supported, with the syntax: @code{for Elem of C}.
27104
27105 RM References: 5.05
27106 @end itemize
27107
27108 @geindex AI-0134 (Ada 2012 feature)
27109
27110
27111 @itemize *
27112
27113 @item
27114 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
27115
27116 For full conformance, the profiles of anonymous-access-to-subprogram
27117 parameters must match. GNAT has always enforced this rule.
27118
27119 RM References: 6.03.01 (18)
27120 @end itemize
27121
27122 @geindex AI-0207 (Ada 2012 feature)
27123
27124
27125 @itemize *
27126
27127 @item
27128 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
27129
27130 This AI confirms that access_to_constant indication must match for mode
27131 conformance. This was implemented in GNAT when the qualifier was originally
27132 introduced in Ada 2005.
27133
27134 RM References: 6.03.01 (16/2)
27135 @end itemize
27136
27137 @geindex AI-0046 (Ada 2012 feature)
27138
27139
27140 @itemize *
27141
27142 @item
27143 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
27144
27145 For full conformance, in the case of access parameters, the null exclusion
27146 must match (either both or neither must have @code{not null}).
27147
27148 RM References: 6.03.02 (18)
27149 @end itemize
27150
27151 @geindex AI-0118 (Ada 2012 feature)
27152
27153
27154 @itemize *
27155
27156 @item
27157 @emph{AI-0118 The association of parameter associations (0000-00-00)}
27158
27159 This AI clarifies the rules for named associations in subprogram calls and
27160 generic instantiations. The rules have been in place since Ada 83.
27161
27162 RM References: 6.04.01 (2) 12.03 (9)
27163 @end itemize
27164
27165 @geindex AI-0196 (Ada 2012 feature)
27166
27167
27168 @itemize *
27169
27170 @item
27171 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
27172
27173 Null exclusion checks are not made for @code{out} parameters when
27174 evaluating the actual parameters. GNAT has never generated these checks.
27175
27176 RM References: 6.04.01 (13)
27177 @end itemize
27178
27179 @geindex AI-0015 (Ada 2012 feature)
27180
27181
27182 @itemize *
27183
27184 @item
27185 @emph{AI-0015 Constant return objects (0000-00-00)}
27186
27187 The return object declared in an @emph{extended_return_statement} may be
27188 declared constant. This was always intended, and GNAT has always allowed it.
27189
27190 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
27191 6.05 (5.7/2)
27192 @end itemize
27193
27194 @geindex AI-0032 (Ada 2012 feature)
27195
27196
27197 @itemize *
27198
27199 @item
27200 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
27201
27202 If a function returns a class-wide type, the object of an extended return
27203 statement can be declared with a specific type that is covered by the class-
27204 wide type. This has been implemented in GNAT since the introduction of
27205 extended returns. Note AI-0103 complements this AI by imposing matching
27206 rules for constrained return types.
27207
27208 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
27209 6.05 (8/2)
27210 @end itemize
27211
27212 @geindex AI-0103 (Ada 2012 feature)
27213
27214
27215 @itemize *
27216
27217 @item
27218 @emph{AI-0103 Static matching for extended return (2010-07-23)}
27219
27220 If the return subtype of a function is an elementary type or a constrained
27221 type, the subtype indication in an extended return statement must match
27222 statically this return subtype.
27223
27224 RM References: 6.05 (5.2/2)
27225 @end itemize
27226
27227 @geindex AI-0058 (Ada 2012 feature)
27228
27229
27230 @itemize *
27231
27232 @item
27233 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
27234
27235 The RM had some incorrect wording implying wrong treatment of abnormal
27236 completion in an extended return. GNAT has always implemented the intended
27237 correct semantics as described by this AI.
27238
27239 RM References: 6.05 (22/2)
27240 @end itemize
27241
27242 @geindex AI-0050 (Ada 2012 feature)
27243
27244
27245 @itemize *
27246
27247 @item
27248 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
27249
27250 The implementation permissions for raising @code{Constraint_Error} early on a function call
27251 when it was clear an exception would be raised were over-permissive and allowed
27252 mishandling of discriminants in some cases. GNAT did
27253 not take advantage of these incorrect permissions in any case.
27254
27255 RM References: 6.05 (24/2)
27256 @end itemize
27257
27258 @geindex AI-0125 (Ada 2012 feature)
27259
27260
27261 @itemize *
27262
27263 @item
27264 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
27265
27266 In Ada 2012, the declaration of a primitive operation of a type extension
27267 or private extension can also override an inherited primitive that is not
27268 visible at the point of this declaration.
27269
27270 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
27271 @end itemize
27272
27273 @geindex AI-0062 (Ada 2012 feature)
27274
27275
27276 @itemize *
27277
27278 @item
27279 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
27280
27281 A full constant may have a null exclusion even if its associated deferred
27282 constant does not. GNAT has always allowed this.
27283
27284 RM References: 7.04 (6/2) 7.04 (7.1/2)
27285 @end itemize
27286
27287 @geindex AI-0178 (Ada 2012 feature)
27288
27289
27290 @itemize *
27291
27292 @item
27293 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
27294
27295 This AI clarifies the role of incomplete views and plugs an omission in the
27296 RM. GNAT always correctly restricted the use of incomplete views and types.
27297
27298 RM References: 7.05 (3/2) 7.05 (6/2)
27299 @end itemize
27300
27301 @geindex AI-0087 (Ada 2012 feature)
27302
27303
27304 @itemize *
27305
27306 @item
27307 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
27308
27309 The actual for a formal nonlimited derived type cannot be limited. In
27310 particular, a formal derived type that extends a limited interface but which
27311 is not explicitly limited cannot be instantiated with a limited type.
27312
27313 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
27314 @end itemize
27315
27316 @geindex AI-0099 (Ada 2012 feature)
27317
27318
27319 @itemize *
27320
27321 @item
27322 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
27323
27324 This AI clarifies that 'needs finalization' is part of dynamic semantics,
27325 and therefore depends on the run-time characteristics of an object (i.e. its
27326 tag) and not on its nominal type. As the AI indicates: "we do not expect
27327 this to affect any implementation'@w{'}.
27328
27329 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
27330 @end itemize
27331
27332 @geindex AI-0064 (Ada 2012 feature)
27333
27334
27335 @itemize *
27336
27337 @item
27338 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
27339
27340 This is an editorial change only. The intended behavior is already checked
27341 by an existing ACATS test, which GNAT has always executed correctly.
27342
27343 RM References: 7.06.01 (17.1/1)
27344 @end itemize
27345
27346 @geindex AI-0026 (Ada 2012 feature)
27347
27348
27349 @itemize *
27350
27351 @item
27352 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
27353
27354 Record representation clauses concerning Unchecked_Union types cannot mention
27355 the discriminant of the type. The type of a component declared in the variant
27356 part of an Unchecked_Union cannot be controlled, have controlled components,
27357 nor have protected or task parts. If an Unchecked_Union type is declared
27358 within the body of a generic unit or its descendants, then the type of a
27359 component declared in the variant part cannot be a formal private type or a
27360 formal private extension declared within the same generic unit.
27361
27362 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
27363 @end itemize
27364
27365 @geindex AI-0205 (Ada 2012 feature)
27366
27367
27368 @itemize *
27369
27370 @item
27371 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
27372
27373 This AI corrects a simple omission in the RM. Return objects have always
27374 been visible within an extended return statement.
27375
27376 RM References: 8.03 (17)
27377 @end itemize
27378
27379 @geindex AI-0042 (Ada 2012 feature)
27380
27381
27382 @itemize *
27383
27384 @item
27385 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
27386
27387 This AI fixes a wording gap in the RM. An operation of a synchronized
27388 interface can be implemented by a protected or task entry, but the abstract
27389 operation is not being overridden in the usual sense, and it must be stated
27390 separately that this implementation is legal. This has always been the case
27391 in GNAT.
27392
27393 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
27394 @end itemize
27395
27396 @geindex AI-0030 (Ada 2012 feature)
27397
27398
27399 @itemize *
27400
27401 @item
27402 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
27403
27404 Requeue is permitted to a protected, synchronized or task interface primitive
27405 providing it is known that the overriding operation is an entry. Otherwise
27406 the requeue statement has the same effect as a procedure call. Use of pragma
27407 @code{Implemented} provides a way to impose a static requirement on the
27408 overriding operation by adhering to one of the implementation kinds: entry,
27409 protected procedure or any of the above.
27410
27411 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
27412 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
27413 @end itemize
27414
27415 @geindex AI-0201 (Ada 2012 feature)
27416
27417
27418 @itemize *
27419
27420 @item
27421 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
27422
27423 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
27424 attribute, then individual components may not be addressable by independent
27425 tasks. However, if the representation clause has no effect (is confirming),
27426 then independence is not compromised. Furthermore, in GNAT, specification of
27427 other appropriately addressable component sizes (e.g. 16 for 8-bit
27428 characters) also preserves independence. GNAT now gives very clear warnings
27429 both for the declaration of such a type, and for any assignment to its components.
27430
27431 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
27432 @end itemize
27433
27434 @geindex AI-0009 (Ada 2012 feature)
27435
27436
27437 @itemize *
27438
27439 @item
27440 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
27441
27442 This AI introduces the new pragmas @code{Independent} and
27443 @code{Independent_Components},
27444 which control guaranteeing independence of access to objects and components.
27445 The AI also requires independence not unaffected by confirming rep clauses.
27446
27447 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
27448 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
27449 @end itemize
27450
27451 @geindex AI-0072 (Ada 2012 feature)
27452
27453
27454 @itemize *
27455
27456 @item
27457 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
27458
27459 This AI clarifies that task signalling for reading @code{'Terminated} only
27460 occurs if the result is True. GNAT semantics has always been consistent with
27461 this notion of task signalling.
27462
27463 RM References: 9.10 (6.1/1)
27464 @end itemize
27465
27466 @geindex AI-0108 (Ada 2012 feature)
27467
27468
27469 @itemize *
27470
27471 @item
27472 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
27473
27474 This AI confirms that an incomplete type from a limited view does not have
27475 discriminants. This has always been the case in GNAT.
27476
27477 RM References: 10.01.01 (12.3/2)
27478 @end itemize
27479
27480 @geindex AI-0129 (Ada 2012 feature)
27481
27482
27483 @itemize *
27484
27485 @item
27486 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
27487
27488 This AI clarifies the description of limited views: a limited view of a
27489 package includes only one view of a type that has an incomplete declaration
27490 and a full declaration (there is no possible ambiguity in a client package).
27491 This AI also fixes an omission: a nested package in the private part has no
27492 limited view. GNAT always implemented this correctly.
27493
27494 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
27495 @end itemize
27496
27497 @geindex AI-0077 (Ada 2012 feature)
27498
27499
27500 @itemize *
27501
27502 @item
27503 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
27504
27505 This AI clarifies that a declaration does not include a context clause,
27506 and confirms that it is illegal to have a context in which both a limited
27507 and a nonlimited view of a package are accessible. Such double visibility
27508 was always rejected by GNAT.
27509
27510 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
27511 @end itemize
27512
27513 @geindex AI-0122 (Ada 2012 feature)
27514
27515
27516 @itemize *
27517
27518 @item
27519 @emph{AI-0122 Private with and children of generics (0000-00-00)}
27520
27521 This AI clarifies the visibility of private children of generic units within
27522 instantiations of a parent. GNAT has always handled this correctly.
27523
27524 RM References: 10.01.02 (12/2)
27525 @end itemize
27526
27527 @geindex AI-0040 (Ada 2012 feature)
27528
27529
27530 @itemize *
27531
27532 @item
27533 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
27534
27535 This AI confirms that a limited with clause in a child unit cannot name
27536 an ancestor of the unit. This has always been checked in GNAT.
27537
27538 RM References: 10.01.02 (20/2)
27539 @end itemize
27540
27541 @geindex AI-0132 (Ada 2012 feature)
27542
27543
27544 @itemize *
27545
27546 @item
27547 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
27548
27549 This AI fills a gap in the description of library unit pragmas. The pragma
27550 clearly must apply to a library unit, even if it does not carry the name
27551 of the enclosing unit. GNAT has always enforced the required check.
27552
27553 RM References: 10.01.05 (7)
27554 @end itemize
27555
27556 @geindex AI-0034 (Ada 2012 feature)
27557
27558
27559 @itemize *
27560
27561 @item
27562 @emph{AI-0034 Categorization of limited views (0000-00-00)}
27563
27564 The RM makes certain limited with clauses illegal because of categorization
27565 considerations, when the corresponding normal with would be legal. This is
27566 not intended, and GNAT has always implemented the recommended behavior.
27567
27568 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
27569 @end itemize
27570
27571 @geindex AI-0035 (Ada 2012 feature)
27572
27573
27574 @itemize *
27575
27576 @item
27577 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
27578
27579 This AI remedies some inconsistencies in the legality rules for Pure units.
27580 Derived access types are legal in a pure unit (on the assumption that the
27581 rule for a zero storage pool size has been enforced on the ancestor type).
27582 The rules are enforced in generic instances and in subunits. GNAT has always
27583 implemented the recommended behavior.
27584
27585 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)
27586 @end itemize
27587
27588 @geindex AI-0219 (Ada 2012 feature)
27589
27590
27591 @itemize *
27592
27593 @item
27594 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
27595
27596 This AI refines the rules for the cases with limited parameters which do not
27597 allow the implementations to omit 'redundant'. GNAT now properly conforms
27598 to the requirements of this binding interpretation.
27599
27600 RM References: 10.02.01 (18/2)
27601 @end itemize
27602
27603 @geindex AI-0043 (Ada 2012 feature)
27604
27605
27606 @itemize *
27607
27608 @item
27609 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
27610
27611 This AI covers various omissions in the RM regarding the raising of
27612 exceptions. GNAT has always implemented the intended semantics.
27613
27614 RM References: 11.04.01 (10.1/2) 11 (2)
27615 @end itemize
27616
27617 @geindex AI-0200 (Ada 2012 feature)
27618
27619
27620 @itemize *
27621
27622 @item
27623 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
27624
27625 This AI plugs a gap in the RM which appeared to allow some obviously intended
27626 illegal instantiations. GNAT has never allowed these instantiations.
27627
27628 RM References: 12.07 (16)
27629 @end itemize
27630
27631 @geindex AI-0112 (Ada 2012 feature)
27632
27633
27634 @itemize *
27635
27636 @item
27637 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
27638
27639 This AI concerns giving names to various representation aspects, but the
27640 practical effect is simply to make the use of duplicate
27641 @code{Atomic[_Components]},
27642 @code{Volatile[_Components]}, and
27643 @code{Independent[_Components]} pragmas illegal, and GNAT
27644 now performs this required check.
27645
27646 RM References: 13.01 (8)
27647 @end itemize
27648
27649 @geindex AI-0106 (Ada 2012 feature)
27650
27651
27652 @itemize *
27653
27654 @item
27655 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
27656
27657 The RM appeared to allow representation pragmas on generic formal parameters,
27658 but this was not intended, and GNAT has never permitted this usage.
27659
27660 RM References: 13.01 (9.1/1)
27661 @end itemize
27662
27663 @geindex AI-0012 (Ada 2012 feature)
27664
27665
27666 @itemize *
27667
27668 @item
27669 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
27670
27671 It is now illegal to give an inappropriate component size or a pragma
27672 @code{Pack} that attempts to change the component size in the case of atomic
27673 or aliased components. Previously GNAT ignored such an attempt with a
27674 warning.
27675
27676 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
27677 @end itemize
27678
27679 @geindex AI-0039 (Ada 2012 feature)
27680
27681
27682 @itemize *
27683
27684 @item
27685 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
27686
27687 The RM permitted the use of dynamic expressions (such as @code{ptr.all})`
27688 for stream attributes, but these were never useful and are now illegal. GNAT
27689 has always regarded such expressions as illegal.
27690
27691 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
27692 @end itemize
27693
27694 @geindex AI-0095 (Ada 2012 feature)
27695
27696
27697 @itemize *
27698
27699 @item
27700 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
27701
27702 The prefix of @code{'Address} cannot statically denote a subprogram with
27703 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
27704 @code{Program_Error} if the prefix denotes a subprogram with convention
27705 @code{Intrinsic}.
27706
27707 RM References: 13.03 (11/1)
27708 @end itemize
27709
27710 @geindex AI-0116 (Ada 2012 feature)
27711
27712
27713 @itemize *
27714
27715 @item
27716 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
27717
27718 This AI requires that the alignment of a class-wide object be no greater
27719 than the alignment of any type in the class. GNAT has always followed this
27720 recommendation.
27721
27722 RM References: 13.03 (29) 13.11 (16)
27723 @end itemize
27724
27725 @geindex AI-0146 (Ada 2012 feature)
27726
27727
27728 @itemize *
27729
27730 @item
27731 @emph{AI-0146 Type invariants (2009-09-21)}
27732
27733 Type invariants may be specified for private types using the aspect notation.
27734 Aspect @code{Type_Invariant} may be specified for any private type,
27735 @code{Type_Invariant'Class} can
27736 only be specified for tagged types, and is inherited by any descendent of the
27737 tagged types. The invariant is a boolean expression that is tested for being
27738 true in the following situations: conversions to the private type, object
27739 declarations for the private type that are default initialized, and
27740 [@strong{in}] @strong{out}
27741 parameters and returned result on return from any primitive operation for
27742 the type that is visible to a client.
27743 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
27744 @code{Invariant'Class} for @code{Type_Invariant'Class}.
27745
27746 RM References: 13.03.03 (00)
27747 @end itemize
27748
27749 @geindex AI-0078 (Ada 2012 feature)
27750
27751
27752 @itemize *
27753
27754 @item
27755 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
27756
27757 In Ada 2012, compilers are required to support unchecked conversion where the
27758 target alignment is a multiple of the source alignment. GNAT always supported
27759 this case (and indeed all cases of differing alignments, doing copies where
27760 required if the alignment was reduced).
27761
27762 RM References: 13.09 (7)
27763 @end itemize
27764
27765 @geindex AI-0195 (Ada 2012 feature)
27766
27767
27768 @itemize *
27769
27770 @item
27771 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
27772
27773 The handling of invalid values is now designated to be implementation
27774 defined. This is a documentation change only, requiring Annex M in the GNAT
27775 Reference Manual to document this handling.
27776 In GNAT, checks for invalid values are made
27777 only when necessary to avoid erroneous behavior. Operations like assignments
27778 which cannot cause erroneous behavior ignore the possibility of invalid
27779 values and do not do a check. The date given above applies only to the
27780 documentation change, this behavior has always been implemented by GNAT.
27781
27782 RM References: 13.09.01 (10)
27783 @end itemize
27784
27785 @geindex AI-0193 (Ada 2012 feature)
27786
27787
27788 @itemize *
27789
27790 @item
27791 @emph{AI-0193 Alignment of allocators (2010-09-16)}
27792
27793 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
27794 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
27795 of size.
27796
27797 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
27798 13.11.01 (2) 13.11.01 (3)
27799 @end itemize
27800
27801 @geindex AI-0177 (Ada 2012 feature)
27802
27803
27804 @itemize *
27805
27806 @item
27807 @emph{AI-0177 Parameterized expressions (2010-07-10)}
27808
27809 The new Ada 2012 notion of parameterized expressions is implemented. The form
27810 is:
27811
27812 @example
27813 function-specification is (expression)
27814 @end example
27815
27816 This is exactly equivalent to the
27817 corresponding function body that returns the expression, but it can appear
27818 in a package spec. Note that the expression must be parenthesized.
27819
27820 RM References: 13.11.01 (3/2)
27821 @end itemize
27822
27823 @geindex AI-0033 (Ada 2012 feature)
27824
27825
27826 @itemize *
27827
27828 @item
27829 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
27830
27831 Neither of these two pragmas may appear within a generic template, because
27832 the generic might be instantiated at other than the library level.
27833
27834 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
27835 @end itemize
27836
27837 @geindex AI-0161 (Ada 2012 feature)
27838
27839
27840 @itemize *
27841
27842 @item
27843 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
27844
27845 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
27846 of the default stream attributes for elementary types. If this restriction is
27847 in force, then it is necessary to provide explicit subprograms for any
27848 stream attributes used.
27849
27850 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
27851 @end itemize
27852
27853 @geindex AI-0194 (Ada 2012 feature)
27854
27855
27856 @itemize *
27857
27858 @item
27859 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
27860
27861 The @code{Stream_Size} attribute returns the default number of bits in the
27862 stream representation of the given type.
27863 This value is not affected by the presence
27864 of stream subprogram attributes for the type. GNAT has always implemented
27865 this interpretation.
27866
27867 RM References: 13.13.02 (1.2/2)
27868 @end itemize
27869
27870 @geindex AI-0109 (Ada 2012 feature)
27871
27872
27873 @itemize *
27874
27875 @item
27876 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
27877
27878 This AI is an editorial change only. It removes the need for a tag check
27879 that can never fail.
27880
27881 RM References: 13.13.02 (34/2)
27882 @end itemize
27883
27884 @geindex AI-0007 (Ada 2012 feature)
27885
27886
27887 @itemize *
27888
27889 @item
27890 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
27891
27892 The RM as written appeared to limit the possibilities of declaring read
27893 attribute procedures for private scalar types. This limitation was not
27894 intended, and has never been enforced by GNAT.
27895
27896 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
27897 @end itemize
27898
27899 @geindex AI-0065 (Ada 2012 feature)
27900
27901
27902 @itemize *
27903
27904 @item
27905 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
27906
27907 This AI clarifies the fact that all remote access types support external
27908 streaming. This fixes an obvious oversight in the definition of the
27909 language, and GNAT always implemented the intended correct rules.
27910
27911 RM References: 13.13.02 (52/2)
27912 @end itemize
27913
27914 @geindex AI-0019 (Ada 2012 feature)
27915
27916
27917 @itemize *
27918
27919 @item
27920 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
27921
27922 The RM suggests that primitive subprograms of a specific tagged type are
27923 frozen when the tagged type is frozen. This would be an incompatible change
27924 and is not intended. GNAT has never attempted this kind of freezing and its
27925 behavior is consistent with the recommendation of this AI.
27926
27927 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)
27928 @end itemize
27929
27930 @geindex AI-0017 (Ada 2012 feature)
27931
27932
27933 @itemize *
27934
27935 @item
27936 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
27937
27938 So-called 'Taft-amendment types' (i.e., types that are completed in package
27939 bodies) are not frozen by the occurrence of bodies in the
27940 enclosing declarative part. GNAT always implemented this properly.
27941
27942 RM References: 13.14 (3/1)
27943 @end itemize
27944
27945 @geindex AI-0060 (Ada 2012 feature)
27946
27947
27948 @itemize *
27949
27950 @item
27951 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
27952
27953 This AI extends the definition of remote access types to include access
27954 to limited, synchronized, protected or task class-wide interface types.
27955 GNAT already implemented this extension.
27956
27957 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
27958 @end itemize
27959
27960 @geindex AI-0114 (Ada 2012 feature)
27961
27962
27963 @itemize *
27964
27965 @item
27966 @emph{AI-0114 Classification of letters (0000-00-00)}
27967
27968 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
27969 181 (@code{MICRO SIGN}), and
27970 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
27971 lower case letters by Unicode.
27972 However, they are not allowed in identifiers, and they
27973 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
27974 This behavior is consistent with that defined in Ada 95.
27975
27976 RM References: A.03.02 (59) A.04.06 (7)
27977 @end itemize
27978
27979 @geindex AI-0185 (Ada 2012 feature)
27980
27981
27982 @itemize *
27983
27984 @item
27985 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
27986
27987 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
27988 classification functions for @code{Wide_Character} and
27989 @code{Wide_Wide_Character}, as well as providing
27990 case folding routines for @code{Wide_[Wide_]Character} and
27991 @code{Wide_[Wide_]String}.
27992
27993 RM References: A.03.05 (0) A.03.06 (0)
27994 @end itemize
27995
27996 @geindex AI-0031 (Ada 2012 feature)
27997
27998
27999 @itemize *
28000
28001 @item
28002 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
28003
28004 A new version of @code{Find_Token} is added to all relevant string packages,
28005 with an extra parameter @code{From}. Instead of starting at the first
28006 character of the string, the search for a matching Token starts at the
28007 character indexed by the value of @code{From}.
28008 These procedures are available in all versions of Ada
28009 but if used in versions earlier than Ada 2012 they will generate a warning
28010 that an Ada 2012 subprogram is being used.
28011
28012 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
28013 A.04.05 (46)
28014 @end itemize
28015
28016 @geindex AI-0056 (Ada 2012 feature)
28017
28018
28019 @itemize *
28020
28021 @item
28022 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
28023
28024 The wording in the Ada 2005 RM implied an incompatible handling of the
28025 @code{Index} functions, resulting in raising an exception instead of
28026 returning zero in some situations.
28027 This was not intended and has been corrected.
28028 GNAT always returned zero, and is thus consistent with this AI.
28029
28030 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
28031 @end itemize
28032
28033 @geindex AI-0137 (Ada 2012 feature)
28034
28035
28036 @itemize *
28037
28038 @item
28039 @emph{AI-0137 String encoding package (2010-03-25)}
28040
28041 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
28042 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
28043 and @code{Wide_Wide_Strings} have been
28044 implemented. These packages (whose documentation can be found in the spec
28045 files @code{a-stuten.ads}, @code{a-suenco.ads}, @code{a-suenst.ads},
28046 @code{a-suewst.ads}, @code{a-suezst.ads}) allow encoding and decoding of
28047 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
28048 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
28049 UTF-16), as well as conversions between the different UTF encodings. With
28050 the exception of @code{Wide_Wide_Strings}, these packages are available in
28051 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
28052 The @code{Wide_Wide_Strings} package
28053 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
28054 mode since it uses @code{Wide_Wide_Character}).
28055
28056 RM References: A.04.11
28057 @end itemize
28058
28059 @geindex AI-0038 (Ada 2012 feature)
28060
28061
28062 @itemize *
28063
28064 @item
28065 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
28066
28067 These are minor errors in the description on three points. The intent on
28068 all these points has always been clear, and GNAT has always implemented the
28069 correct intended semantics.
28070
28071 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)
28072 @end itemize
28073
28074 @geindex AI-0044 (Ada 2012 feature)
28075
28076
28077 @itemize *
28078
28079 @item
28080 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
28081
28082 This AI places restrictions on allowed instantiations of generic containers.
28083 These restrictions are not checked by the compiler, so there is nothing to
28084 change in the implementation. This affects only the RM documentation.
28085
28086 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)
28087 @end itemize
28088
28089 @geindex AI-0127 (Ada 2012 feature)
28090
28091
28092 @itemize *
28093
28094 @item
28095 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
28096
28097 This package provides an interface for identifying the current locale.
28098
28099 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
28100 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
28101 @end itemize
28102
28103 @geindex AI-0002 (Ada 2012 feature)
28104
28105
28106 @itemize *
28107
28108 @item
28109 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
28110
28111 The compiler is not required to support exporting an Ada subprogram with
28112 convention C if there are parameters or a return type of an unconstrained
28113 array type (such as @code{String}). GNAT allows such declarations but
28114 generates warnings. It is possible, but complicated, to write the
28115 corresponding C code and certainly such code would be specific to GNAT and
28116 non-portable.
28117
28118 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
28119 @end itemize
28120
28121 @geindex AI05-0216 (Ada 2012 feature)
28122
28123
28124 @itemize *
28125
28126 @item
28127 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
28128
28129 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
28130 forbid tasks declared locally within subprograms, or functions returning task
28131 objects, and that is the implementation that GNAT has always provided.
28132 However the language in the RM was not sufficiently clear on this point.
28133 Thus this is a documentation change in the RM only.
28134
28135 RM References: D.07 (3/3)
28136 @end itemize
28137
28138 @geindex AI-0211 (Ada 2012 feature)
28139
28140
28141 @itemize *
28142
28143 @item
28144 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
28145
28146 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
28147 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
28148
28149 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
28150 @end itemize
28151
28152 @geindex AI-0190 (Ada 2012 feature)
28153
28154
28155 @itemize *
28156
28157 @item
28158 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
28159
28160 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
28161 used to control storage pools globally.
28162 In particular, you can force every access
28163 type that is used for allocation (@strong{new}) to have an explicit storage pool,
28164 or you can declare a pool globally to be used for all access types that lack
28165 an explicit one.
28166
28167 RM References: D.07 (8)
28168 @end itemize
28169
28170 @geindex AI-0189 (Ada 2012 feature)
28171
28172
28173 @itemize *
28174
28175 @item
28176 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
28177
28178 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
28179 which says that no dynamic allocation will occur once elaboration is
28180 completed.
28181 In general this requires a run-time check, which is not required, and which
28182 GNAT does not attempt. But the static cases of allocators in a task body or
28183 in the body of the main program are detected and flagged at compile or bind
28184 time.
28185
28186 RM References: D.07 (19.1/2) H.04 (23.3/2)
28187 @end itemize
28188
28189 @geindex AI-0171 (Ada 2012 feature)
28190
28191
28192 @itemize *
28193
28194 @item
28195 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
28196
28197 A new package @code{System.Multiprocessors} is added, together with the
28198 definition of pragma @code{CPU} for controlling task affinity. A new no
28199 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
28200 is added to the Ravenscar profile.
28201
28202 RM References: D.13.01 (4/2) D.16
28203 @end itemize
28204
28205 @geindex AI-0210 (Ada 2012 feature)
28206
28207
28208 @itemize *
28209
28210 @item
28211 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
28212
28213 This is a documentation only issue regarding wording of metric requirements,
28214 that does not affect the implementation of the compiler.
28215
28216 RM References: D.15 (24/2)
28217 @end itemize
28218
28219 @geindex AI-0206 (Ada 2012 feature)
28220
28221
28222 @itemize *
28223
28224 @item
28225 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
28226
28227 Remote types packages are now allowed to depend on preelaborated packages.
28228 This was formerly considered illegal.
28229
28230 RM References: E.02.02 (6)
28231 @end itemize
28232
28233 @geindex AI-0152 (Ada 2012 feature)
28234
28235
28236 @itemize *
28237
28238 @item
28239 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
28240
28241 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
28242 where the type of the returned value is an anonymous access type.
28243
28244 RM References: H.04 (8/1)
28245 @end itemize
28246
28247 @node Obsolescent Features,Compatibility and Porting Guide,Implementation of Ada 2012 Features,Top
28248 @anchor{gnat_rm/obsolescent_features id1}@anchor{435}@anchor{gnat_rm/obsolescent_features doc}@anchor{436}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{15}
28249 @chapter Obsolescent Features
28250
28251
28252 This chapter describes features that are provided by GNAT, but are
28253 considered obsolescent since there are preferred ways of achieving
28254 the same effect. These features are provided solely for historical
28255 compatibility purposes.
28256
28257 @menu
28258 * pragma No_Run_Time::
28259 * pragma Ravenscar::
28260 * pragma Restricted_Run_Time::
28261 * pragma Task_Info::
28262 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads.
28263
28264 @end menu
28265
28266 @node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
28267 @anchor{gnat_rm/obsolescent_features id2}@anchor{437}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{438}
28268 @section pragma No_Run_Time
28269
28270
28271 The pragma @code{No_Run_Time} is used to achieve an affect similar
28272 to the use of the "Zero Foot Print" configurable run time, but without
28273 requiring a specially configured run time. The result of using this
28274 pragma, which must be used for all units in a partition, is to restrict
28275 the use of any language features requiring run-time support code. The
28276 preferred usage is to use an appropriately configured run-time that
28277 includes just those features that are to be made accessible.
28278
28279 @node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
28280 @anchor{gnat_rm/obsolescent_features id3}@anchor{439}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{43a}
28281 @section pragma Ravenscar
28282
28283
28284 The pragma @code{Ravenscar} has exactly the same effect as pragma
28285 @code{Profile (Ravenscar)}. The latter usage is preferred since it
28286 is part of the new Ada 2005 standard.
28287
28288 @node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
28289 @anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{43b}@anchor{gnat_rm/obsolescent_features id4}@anchor{43c}
28290 @section pragma Restricted_Run_Time
28291
28292
28293 The pragma @code{Restricted_Run_Time} has exactly the same effect as
28294 pragma @code{Profile (Restricted)}. The latter usage is
28295 preferred since the Ada 2005 pragma @code{Profile} is intended for
28296 this kind of implementation dependent addition.
28297
28298 @node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
28299 @anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{43d}@anchor{gnat_rm/obsolescent_features id5}@anchor{43e}
28300 @section pragma Task_Info
28301
28302
28303 The functionality provided by pragma @code{Task_Info} is now part of the
28304 Ada language. The @code{CPU} aspect and the package
28305 @code{System.Multiprocessors} offer a less system-dependent way to specify
28306 task affinity or to query the number of processors.
28307
28308 Syntax
28309
28310 @example
28311 pragma Task_Info (EXPRESSION);
28312 @end example
28313
28314 This pragma appears within a task definition (like pragma
28315 @code{Priority}) and applies to the task in which it appears. The
28316 argument must be of type @code{System.Task_Info.Task_Info_Type}.
28317 The @code{Task_Info} pragma provides system dependent control over
28318 aspects of tasking implementation, for example, the ability to map
28319 tasks to specific processors. For details on the facilities available
28320 for the version of GNAT that you are using, see the documentation
28321 in the spec of package System.Task_Info in the runtime
28322 library.
28323
28324 @node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
28325 @anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{43f}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{440}
28326 @section package System.Task_Info (@code{s-tasinf.ads})
28327
28328
28329 This package provides target dependent functionality that is used
28330 to support the @code{Task_Info} pragma. The predefined Ada package
28331 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
28332 standard replacement for GNAT's @code{Task_Info} functionality.
28333
28334 @node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
28335 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{16}@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{441}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{442}
28336 @chapter Compatibility and Porting Guide
28337
28338
28339 This chapter presents some guidelines for developing portable Ada code,
28340 describes the compatibility issues that may arise between
28341 GNAT and other Ada compilation systems (including those for Ada 83),
28342 and shows how GNAT can expedite porting
28343 applications developed in other Ada environments.
28344
28345 @menu
28346 * Writing Portable Fixed-Point Declarations::
28347 * Compatibility with Ada 83::
28348 * Compatibility between Ada 95 and Ada 2005::
28349 * Implementation-dependent characteristics::
28350 * Compatibility with Other Ada Systems::
28351 * Representation Clauses::
28352 * Compatibility with HP Ada 83::
28353
28354 @end menu
28355
28356 @node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
28357 @anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{443}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{444}
28358 @section Writing Portable Fixed-Point Declarations
28359
28360
28361 The Ada Reference Manual gives an implementation freedom to choose bounds
28362 that are narrower by @code{Small} from the given bounds.
28363 For example, if we write
28364
28365 @example
28366 type F1 is delta 1.0 range -128.0 .. +128.0;
28367 @end example
28368
28369 then the implementation is allowed to choose -128.0 .. +127.0 if it
28370 likes, but is not required to do so.
28371
28372 This leads to possible portability problems, so let's have a closer
28373 look at this, and figure out how to avoid these problems.
28374
28375 First, why does this freedom exist, and why would an implementation
28376 take advantage of it? To answer this, take a closer look at the type
28377 declaration for @code{F1} above. If the compiler uses the given bounds,
28378 it would need 9 bits to hold the largest positive value (and typically
28379 that means 16 bits on all machines). But if the implementation chooses
28380 the +127.0 bound then it can fit values of the type in 8 bits.
28381
28382 Why not make the user write +127.0 if that's what is wanted?
28383 The rationale is that if you are thinking of fixed point
28384 as a kind of 'poor man's floating-point', then you don't want
28385 to be thinking about the scaled integers that are used in its
28386 representation. Let's take another example:
28387
28388 @example
28389 type F2 is delta 2.0**(-15) range -1.0 .. +1.0;
28390 @end example
28391
28392 Looking at this declaration, it seems casually as though
28393 it should fit in 16 bits, but again that extra positive value
28394 +1.0 has the scaled integer equivalent of 2**15 which is one too
28395 big for signed 16 bits. The implementation can treat this as:
28396
28397 @example
28398 type F2 is delta 2.0**(-15) range -1.0 .. +1.0-(2.0**(-15));
28399 @end example
28400
28401 and the Ada language design team felt that this was too annoying
28402 to require. We don't need to debate this decision at this point,
28403 since it is well established (the rule about narrowing the ranges
28404 dates to Ada 83).
28405
28406 But the important point is that an implementation is not required
28407 to do this narrowing, so we have a potential portability problem.
28408 We could imagine three types of implementation:
28409
28410
28411 @enumerate a
28412
28413 @item
28414 those that narrow the range automatically if they can figure
28415 out that the narrower range will allow storage in a smaller machine unit,
28416
28417 @item
28418 those that will narrow only if forced to by a @code{'Size} clause, and
28419
28420 @item
28421 those that will never narrow.
28422 @end enumerate
28423
28424 Now if we are language theoreticians, we can imagine a fourth
28425 approach: to narrow all the time, e.g. to treat
28426
28427 @example
28428 type F3 is delta 1.0 range -10.0 .. +23.0;
28429 @end example
28430
28431 as though it had been written:
28432
28433 @example
28434 type F3 is delta 1.0 range -9.0 .. +22.0;
28435 @end example
28436
28437 But although technically allowed, such a behavior would be hostile and silly,
28438 and no real compiler would do this. All real compilers will fall into one of
28439 the categories (a), (b) or (c) above.
28440
28441 So, how do you get the compiler to do what you want? The answer is give the
28442 actual bounds you want, and then use a @code{'Small} clause and a
28443 @code{'Size} clause to absolutely pin down what the compiler does.
28444 E.g., for @code{F2} above, we will write:
28445
28446 @example
28447 My_Small : constant := 2.0**(-15);
28448 My_First : constant := -1.0;
28449 My_Last : constant := +1.0 - My_Small;
28450
28451 type F2 is delta My_Small range My_First .. My_Last;
28452 @end example
28453
28454 and then add
28455
28456 @example
28457 for F2'Small use my_Small;
28458 for F2'Size use 16;
28459 @end example
28460
28461 In practice all compilers will do the same thing here and will give you
28462 what you want, so the above declarations are fully portable. If you really
28463 want to play language lawyer and guard against ludicrous behavior by the
28464 compiler you could add
28465
28466 @example
28467 Test1 : constant := 1 / Boolean'Pos (F2'First = My_First);
28468 Test2 : constant := 1 / Boolean'Pos (F2'Last = My_Last);
28469 @end example
28470
28471 One or other or both are allowed to be illegal if the compiler is
28472 behaving in a silly manner, but at least the silly compiler will not
28473 get away with silently messing with your (very clear) intentions.
28474
28475 If you follow this scheme you will be guaranteed that your fixed-point
28476 types will be portable.
28477
28478 @node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
28479 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{445}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{446}
28480 @section Compatibility with Ada 83
28481
28482
28483 @geindex Compatibility (between Ada 83 and Ada 95 / Ada 2005 / Ada 2012)
28484
28485 Ada 95 and the subsequent revisions Ada 2005 and Ada 2012
28486 are highly upwards compatible with Ada 83. In
28487 particular, the design intention was that the difficulties associated
28488 with moving from Ada 83 to later versions of the standard should be no greater
28489 than those that occur when moving from one Ada 83 system to another.
28490
28491 However, there are a number of points at which there are minor
28492 incompatibilities. The @cite{Ada 95 Annotated Reference Manual} contains
28493 full details of these issues as they relate to Ada 95,
28494 and should be consulted for a complete treatment.
28495 In practice the
28496 following subsections treat the most likely issues to be encountered.
28497
28498 @menu
28499 * Legal Ada 83 programs that are illegal in Ada 95::
28500 * More deterministic semantics::
28501 * Changed semantics::
28502 * Other language compatibility issues::
28503
28504 @end menu
28505
28506 @node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
28507 @anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{447}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{448}
28508 @subsection Legal Ada 83 programs that are illegal in Ada 95
28509
28510
28511 Some legal Ada 83 programs are illegal (i.e., they will fail to compile) in
28512 Ada 95 and later versions of the standard:
28513
28514
28515 @itemize *
28516
28517 @item
28518 @emph{Character literals}
28519
28520 Some uses of character literals are ambiguous. Since Ada 95 has introduced
28521 @code{Wide_Character} as a new predefined character type, some uses of
28522 character literals that were legal in Ada 83 are illegal in Ada 95.
28523 For example:
28524
28525 @example
28526 for Char in 'A' .. 'Z' loop ... end loop;
28527 @end example
28528
28529 The problem is that 'A' and 'Z' could be from either
28530 @code{Character} or @code{Wide_Character}. The simplest correction
28531 is to make the type explicit; e.g.:
28532
28533 @example
28534 for Char in Character range 'A' .. 'Z' loop ... end loop;
28535 @end example
28536
28537 @item
28538 @emph{New reserved words}
28539
28540 The identifiers @code{abstract}, @code{aliased}, @code{protected},
28541 @code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
28542 Existing Ada 83 code using any of these identifiers must be edited to
28543 use some alternative name.
28544
28545 @item
28546 @emph{Freezing rules}
28547
28548 The rules in Ada 95 are slightly different with regard to the point at
28549 which entities are frozen, and representation pragmas and clauses are
28550 not permitted past the freeze point. This shows up most typically in
28551 the form of an error message complaining that a representation item
28552 appears too late, and the appropriate corrective action is to move
28553 the item nearer to the declaration of the entity to which it refers.
28554
28555 A particular case is that representation pragmas
28556 cannot be applied to a subprogram body. If necessary, a separate subprogram
28557 declaration must be introduced to which the pragma can be applied.
28558
28559 @item
28560 @emph{Optional bodies for library packages}
28561
28562 In Ada 83, a package that did not require a package body was nevertheless
28563 allowed to have one. This lead to certain surprises in compiling large
28564 systems (situations in which the body could be unexpectedly ignored by the
28565 binder). In Ada 95, if a package does not require a body then it is not
28566 permitted to have a body. To fix this problem, simply remove a redundant
28567 body if it is empty, or, if it is non-empty, introduce a dummy declaration
28568 into the spec that makes the body required. One approach is to add a private
28569 part to the package declaration (if necessary), and define a parameterless
28570 procedure called @code{Requires_Body}, which must then be given a dummy
28571 procedure body in the package body, which then becomes required.
28572 Another approach (assuming that this does not introduce elaboration
28573 circularities) is to add an @code{Elaborate_Body} pragma to the package spec,
28574 since one effect of this pragma is to require the presence of a package body.
28575
28576 @item
28577 @emph{Numeric_Error is the same exception as Constraint_Error}
28578
28579 In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}.
28580 This means that it is illegal to have separate exception handlers for
28581 the two exceptions. The fix is simply to remove the handler for the
28582 @code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise
28583 @code{Constraint_Error} in place of @code{Numeric_Error} in all cases).
28584
28585 @item
28586 @emph{Indefinite subtypes in generics}
28587
28588 In Ada 83, it was permissible to pass an indefinite type (e.g, @code{String})
28589 as the actual for a generic formal private type, but then the instantiation
28590 would be illegal if there were any instances of declarations of variables
28591 of this type in the generic body. In Ada 95, to avoid this clear violation
28592 of the methodological principle known as the 'contract model',
28593 the generic declaration explicitly indicates whether
28594 or not such instantiations are permitted. If a generic formal parameter
28595 has explicit unknown discriminants, indicated by using @code{(<>)} after the
28596 subtype name, then it can be instantiated with indefinite types, but no
28597 stand-alone variables can be declared of this type. Any attempt to declare
28598 such a variable will result in an illegality at the time the generic is
28599 declared. If the @code{(<>)} notation is not used, then it is illegal
28600 to instantiate the generic with an indefinite type.
28601 This is the potential incompatibility issue when porting Ada 83 code to Ada 95.
28602 It will show up as a compile time error, and
28603 the fix is usually simply to add the @code{(<>)} to the generic declaration.
28604 @end itemize
28605
28606 @node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
28607 @anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{449}@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{44a}
28608 @subsection More deterministic semantics
28609
28610
28611
28612 @itemize *
28613
28614 @item
28615 @emph{Conversions}
28616
28617 Conversions from real types to integer types round away from 0. In Ada 83
28618 the conversion Integer(2.5) could deliver either 2 or 3 as its value. This
28619 implementation freedom was intended to support unbiased rounding in
28620 statistical applications, but in practice it interfered with portability.
28621 In Ada 95 the conversion semantics are unambiguous, and rounding away from 0
28622 is required. Numeric code may be affected by this change in semantics.
28623 Note, though, that this issue is no worse than already existed in Ada 83
28624 when porting code from one vendor to another.
28625
28626 @item
28627 @emph{Tasking}
28628
28629 The Real-Time Annex introduces a set of policies that define the behavior of
28630 features that were implementation dependent in Ada 83, such as the order in
28631 which open select branches are executed.
28632 @end itemize
28633
28634 @node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
28635 @anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{44b}@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{44c}
28636 @subsection Changed semantics
28637
28638
28639 The worst kind of incompatibility is one where a program that is legal in
28640 Ada 83 is also legal in Ada 95 but can have an effect in Ada 95 that was not
28641 possible in Ada 83. Fortunately this is extremely rare, but the one
28642 situation that you should be alert to is the change in the predefined type
28643 @code{Character} from 7-bit ASCII to 8-bit Latin-1.
28644
28645 @quotation
28646
28647 @geindex Latin-1
28648 @end quotation
28649
28650
28651 @itemize *
28652
28653 @item
28654 @emph{Range of type `@w{`}Character`@w{`}}
28655
28656 The range of @code{Standard.Character} is now the full 256 characters
28657 of Latin-1, whereas in most Ada 83 implementations it was restricted
28658 to 128 characters. Although some of the effects of
28659 this change will be manifest in compile-time rejection of legal
28660 Ada 83 programs it is possible for a working Ada 83 program to have
28661 a different effect in Ada 95, one that was not permitted in Ada 83.
28662 As an example, the expression
28663 @code{Character'Pos(Character'Last)} returned @code{127} in Ada 83 and now
28664 delivers @code{255} as its value.
28665 In general, you should look at the logic of any
28666 character-processing Ada 83 program and see whether it needs to be adapted
28667 to work correctly with Latin-1. Note that the predefined Ada 95 API has a
28668 character handling package that may be relevant if code needs to be adapted
28669 to account for the additional Latin-1 elements.
28670 The desirable fix is to
28671 modify the program to accommodate the full character set, but in some cases
28672 it may be convenient to define a subtype or derived type of Character that
28673 covers only the restricted range.
28674 @end itemize
28675
28676 @node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
28677 @anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{44d}@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{44e}
28678 @subsection Other language compatibility issues
28679
28680
28681
28682 @itemize *
28683
28684 @item
28685 @emph{-gnat83} switch
28686
28687 All implementations of GNAT provide a switch that causes GNAT to operate
28688 in Ada 83 mode. In this mode, some but not all compatibility problems
28689 of the type described above are handled automatically. For example, the
28690 new reserved words introduced in Ada 95 and Ada 2005 are treated simply
28691 as identifiers as in Ada 83. However,
28692 in practice, it is usually advisable to make the necessary modifications
28693 to the program to remove the need for using this switch.
28694 See the @code{Compiling Different Versions of Ada} section in
28695 the @cite{GNAT User's Guide}.
28696
28697 @item
28698 Support for removed Ada 83 pragmas and attributes
28699
28700 A number of pragmas and attributes from Ada 83 were removed from Ada 95,
28701 generally because they were replaced by other mechanisms. Ada 95 and Ada 2005
28702 compilers are allowed, but not required, to implement these missing
28703 elements. In contrast with some other compilers, GNAT implements all
28704 such pragmas and attributes, eliminating this compatibility concern. These
28705 include @code{pragma Interface} and the floating point type attributes
28706 (@code{Emax}, @code{Mantissa}, etc.), among other items.
28707 @end itemize
28708
28709 @node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
28710 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{44f}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{450}
28711 @section Compatibility between Ada 95 and Ada 2005
28712
28713
28714 @geindex Compatibility between Ada 95 and Ada 2005
28715
28716 Although Ada 2005 was designed to be upwards compatible with Ada 95, there are
28717 a number of incompatibilities. Several are enumerated below;
28718 for a complete description please see the
28719 @cite{Annotated Ada 2005 Reference Manual}, or section 9.1.1 in
28720 @cite{Rationale for Ada 2005}.
28721
28722
28723 @itemize *
28724
28725 @item
28726 @emph{New reserved words.}
28727
28728 The words @code{interface}, @code{overriding} and @code{synchronized} are
28729 reserved in Ada 2005.
28730 A pre-Ada 2005 program that uses any of these as an identifier will be
28731 illegal.
28732
28733 @item
28734 @emph{New declarations in predefined packages.}
28735
28736 A number of packages in the predefined environment contain new declarations:
28737 @code{Ada.Exceptions}, @code{Ada.Real_Time}, @code{Ada.Strings},
28738 @code{Ada.Strings.Fixed}, @code{Ada.Strings.Bounded},
28739 @code{Ada.Strings.Unbounded}, @code{Ada.Strings.Wide_Fixed},
28740 @code{Ada.Strings.Wide_Bounded}, @code{Ada.Strings.Wide_Unbounded},
28741 @code{Ada.Tags}, @code{Ada.Text_IO}, and @code{Interfaces.C}.
28742 If an Ada 95 program does a @code{with} and @code{use} of any of these
28743 packages, the new declarations may cause name clashes.
28744
28745 @item
28746 @emph{Access parameters.}
28747
28748 A nondispatching subprogram with an access parameter cannot be renamed
28749 as a dispatching operation. This was permitted in Ada 95.
28750
28751 @item
28752 @emph{Access types, discriminants, and constraints.}
28753
28754 Rule changes in this area have led to some incompatibilities; for example,
28755 constrained subtypes of some access types are not permitted in Ada 2005.
28756
28757 @item
28758 @emph{Aggregates for limited types.}
28759
28760 The allowance of aggregates for limited types in Ada 2005 raises the
28761 possibility of ambiguities in legal Ada 95 programs, since additional types
28762 now need to be considered in expression resolution.
28763
28764 @item
28765 @emph{Fixed-point multiplication and division.}
28766
28767 Certain expressions involving '*' or '/' for a fixed-point type, which
28768 were legal in Ada 95 and invoked the predefined versions of these operations,
28769 are now ambiguous.
28770 The ambiguity may be resolved either by applying a type conversion to the
28771 expression, or by explicitly invoking the operation from package
28772 @code{Standard}.
28773
28774 @item
28775 @emph{Return-by-reference types.}
28776
28777 The Ada 95 return-by-reference mechanism has been removed. Instead, the user
28778 can declare a function returning a value from an anonymous access type.
28779 @end itemize
28780
28781 @node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
28782 @anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{451}@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{452}
28783 @section Implementation-dependent characteristics
28784
28785
28786 Although the Ada language defines the semantics of each construct as
28787 precisely as practical, in some situations (for example for reasons of
28788 efficiency, or where the effect is heavily dependent on the host or target
28789 platform) the implementation is allowed some freedom. In porting Ada 83
28790 code to GNAT, you need to be aware of whether / how the existing code
28791 exercised such implementation dependencies. Such characteristics fall into
28792 several categories, and GNAT offers specific support in assisting the
28793 transition from certain Ada 83 compilers.
28794
28795 @menu
28796 * Implementation-defined pragmas::
28797 * Implementation-defined attributes::
28798 * Libraries::
28799 * Elaboration order::
28800 * Target-specific aspects::
28801
28802 @end menu
28803
28804 @node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
28805 @anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{453}@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{454}
28806 @subsection Implementation-defined pragmas
28807
28808
28809 Ada compilers are allowed to supplement the language-defined pragmas, and
28810 these are a potential source of non-portability. All GNAT-defined pragmas
28811 are described in @ref{7,,Implementation Defined Pragmas},
28812 and these include several that are specifically
28813 intended to correspond to other vendors' Ada 83 pragmas.
28814 For migrating from VADS, the pragma @code{Use_VADS_Size} may be useful.
28815 For compatibility with HP Ada 83, GNAT supplies the pragmas
28816 @code{Extend_System}, @code{Ident}, @code{Inline_Generic},
28817 @code{Interface_Name}, @code{Passive}, @code{Suppress_All},
28818 and @code{Volatile}.
28819 Other relevant pragmas include @code{External} and @code{Link_With}.
28820 Some vendor-specific
28821 Ada 83 pragmas (@code{Share_Generic}, @code{Subtitle}, and @code{Title}) are
28822 recognized, thus
28823 avoiding compiler rejection of units that contain such pragmas; they are not
28824 relevant in a GNAT context and hence are not otherwise implemented.
28825
28826 @node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
28827 @anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{455}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{456}
28828 @subsection Implementation-defined attributes
28829
28830
28831 Analogous to pragmas, the set of attributes may be extended by an
28832 implementation. All GNAT-defined attributes are described in
28833 @ref{8,,Implementation Defined Attributes},
28834 and these include several that are specifically intended
28835 to correspond to other vendors' Ada 83 attributes. For migrating from VADS,
28836 the attribute @code{VADS_Size} may be useful. For compatibility with HP
28837 Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
28838 @code{Type_Class}.
28839
28840 @node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
28841 @anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{457}@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{458}
28842 @subsection Libraries
28843
28844
28845 Vendors may supply libraries to supplement the standard Ada API. If Ada 83
28846 code uses vendor-specific libraries then there are several ways to manage
28847 this in Ada 95 and later versions of the standard:
28848
28849
28850 @itemize *
28851
28852 @item
28853 If the source code for the libraries (specs and bodies) are
28854 available, then the libraries can be migrated in the same way as the
28855 application.
28856
28857 @item
28858 If the source code for the specs but not the bodies are
28859 available, then you can reimplement the bodies.
28860
28861 @item
28862 Some features introduced by Ada 95 obviate the need for library support. For
28863 example most Ada 83 vendors supplied a package for unsigned integers. The
28864 Ada 95 modular type feature is the preferred way to handle this need, so
28865 instead of migrating or reimplementing the unsigned integer package it may
28866 be preferable to retrofit the application using modular types.
28867 @end itemize
28868
28869 @node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
28870 @anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{459}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{45a}
28871 @subsection Elaboration order
28872
28873
28874 The implementation can choose any elaboration order consistent with the unit
28875 dependency relationship. This freedom means that some orders can result in
28876 Program_Error being raised due to an 'Access Before Elaboration': an attempt
28877 to invoke a subprogram before its body has been elaborated, or to instantiate
28878 a generic before the generic body has been elaborated. By default GNAT
28879 attempts to choose a safe order (one that will not encounter access before
28880 elaboration problems) by implicitly inserting @code{Elaborate} or
28881 @code{Elaborate_All} pragmas where
28882 needed. However, this can lead to the creation of elaboration circularities
28883 and a resulting rejection of the program by gnatbind. This issue is
28884 thoroughly described in the @emph{Elaboration Order Handling in GNAT} appendix
28885 in the @cite{GNAT User's Guide}.
28886 In brief, there are several
28887 ways to deal with this situation:
28888
28889
28890 @itemize *
28891
28892 @item
28893 Modify the program to eliminate the circularities, e.g., by moving
28894 elaboration-time code into explicitly-invoked procedures
28895
28896 @item
28897 Constrain the elaboration order by including explicit @code{Elaborate_Body} or
28898 @code{Elaborate} pragmas, and then inhibit the generation of implicit
28899 @code{Elaborate_All}
28900 pragmas either globally (as an effect of the @emph{-gnatE} switch) or locally
28901 (by selectively suppressing elaboration checks via pragma
28902 @code{Suppress(Elaboration_Check)} when it is safe to do so).
28903 @end itemize
28904
28905 @node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
28906 @anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{45b}@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{45c}
28907 @subsection Target-specific aspects
28908
28909
28910 Low-level applications need to deal with machine addresses, data
28911 representations, interfacing with assembler code, and similar issues. If
28912 such an Ada 83 application is being ported to different target hardware (for
28913 example where the byte endianness has changed) then you will need to
28914 carefully examine the program logic; the porting effort will heavily depend
28915 on the robustness of the original design. Moreover, Ada 95 (and thus
28916 Ada 2005 and Ada 2012) are sometimes
28917 incompatible with typical Ada 83 compiler practices regarding implicit
28918 packing, the meaning of the Size attribute, and the size of access values.
28919 GNAT's approach to these issues is described in @ref{45d,,Representation Clauses}.
28920
28921 @node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
28922 @anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{45e}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{45f}
28923 @section Compatibility with Other Ada Systems
28924
28925
28926 If programs avoid the use of implementation dependent and
28927 implementation defined features, as documented in the
28928 @cite{Ada Reference Manual}, there should be a high degree of portability between
28929 GNAT and other Ada systems. The following are specific items which
28930 have proved troublesome in moving Ada 95 programs from GNAT to other Ada 95
28931 compilers, but do not affect porting code to GNAT.
28932 (As of January 2007, GNAT is the only compiler available for Ada 2005;
28933 the following issues may or may not arise for Ada 2005 programs
28934 when other compilers appear.)
28935
28936
28937 @itemize *
28938
28939 @item
28940 @emph{Ada 83 Pragmas and Attributes}
28941
28942 Ada 95 compilers are allowed, but not required, to implement the missing
28943 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
28944 GNAT implements all such pragmas and attributes, eliminating this as
28945 a compatibility concern, but some other Ada 95 compilers reject these
28946 pragmas and attributes.
28947
28948 @item
28949 @emph{Specialized Needs Annexes}
28950
28951 GNAT implements the full set of special needs annexes. At the
28952 current time, it is the only Ada 95 compiler to do so. This means that
28953 programs making use of these features may not be portable to other Ada
28954 95 compilation systems.
28955
28956 @item
28957 @emph{Representation Clauses}
28958
28959 Some other Ada 95 compilers implement only the minimal set of
28960 representation clauses required by the Ada 95 reference manual. GNAT goes
28961 far beyond this minimal set, as described in the next section.
28962 @end itemize
28963
28964 @node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
28965 @anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{45d}@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{460}
28966 @section Representation Clauses
28967
28968
28969 The Ada 83 reference manual was quite vague in describing both the minimal
28970 required implementation of representation clauses, and also their precise
28971 effects. Ada 95 (and thus also Ada 2005) are much more explicit, but the
28972 minimal set of capabilities required is still quite limited.
28973
28974 GNAT implements the full required set of capabilities in
28975 Ada 95 and Ada 2005, but also goes much further, and in particular
28976 an effort has been made to be compatible with existing Ada 83 usage to the
28977 greatest extent possible.
28978
28979 A few cases exist in which Ada 83 compiler behavior is incompatible with
28980 the requirements in Ada 95 (and thus also Ada 2005). These are instances of
28981 intentional or accidental dependence on specific implementation dependent
28982 characteristics of these Ada 83 compilers. The following is a list of
28983 the cases most likely to arise in existing Ada 83 code.
28984
28985
28986 @itemize *
28987
28988 @item
28989 @emph{Implicit Packing}
28990
28991 Some Ada 83 compilers allowed a Size specification to cause implicit
28992 packing of an array or record. This could cause expensive implicit
28993 conversions for change of representation in the presence of derived
28994 types, and the Ada design intends to avoid this possibility.
28995 Subsequent AI's were issued to make it clear that such implicit
28996 change of representation in response to a Size clause is inadvisable,
28997 and this recommendation is represented explicitly in the Ada 95 (and Ada 2005)
28998 Reference Manuals as implementation advice that is followed by GNAT.
28999 The problem will show up as an error
29000 message rejecting the size clause. The fix is simply to provide
29001 the explicit pragma @code{Pack}, or for more fine tuned control, provide
29002 a Component_Size clause.
29003
29004 @item
29005 @emph{Meaning of Size Attribute}
29006
29007 The Size attribute in Ada 95 (and Ada 2005) for discrete types is defined as
29008 the minimal number of bits required to hold values of the type. For example,
29009 on a 32-bit machine, the size of @code{Natural} will typically be 31 and not
29010 32 (since no sign bit is required). Some Ada 83 compilers gave 31, and
29011 some 32 in this situation. This problem will usually show up as a compile
29012 time error, but not always. It is a good idea to check all uses of the
29013 'Size attribute when porting Ada 83 code. The GNAT specific attribute
29014 Object_Size can provide a useful way of duplicating the behavior of
29015 some Ada 83 compiler systems.
29016
29017 @item
29018 @emph{Size of Access Types}
29019
29020 A common assumption in Ada 83 code is that an access type is in fact a pointer,
29021 and that therefore it will be the same size as a System.Address value. This
29022 assumption is true for GNAT in most cases with one exception. For the case of
29023 a pointer to an unconstrained array type (where the bounds may vary from one
29024 value of the access type to another), the default is to use a 'fat pointer',
29025 which is represented as two separate pointers, one to the bounds, and one to
29026 the array. This representation has a number of advantages, including improved
29027 efficiency. However, it may cause some difficulties in porting existing Ada 83
29028 code which makes the assumption that, for example, pointers fit in 32 bits on
29029 a machine with 32-bit addressing.
29030
29031 To get around this problem, GNAT also permits the use of 'thin pointers' for
29032 access types in this case (where the designated type is an unconstrained array
29033 type). These thin pointers are indeed the same size as a System.Address value.
29034 To specify a thin pointer, use a size clause for the type, for example:
29035
29036 @example
29037 type X is access all String;
29038 for X'Size use Standard'Address_Size;
29039 @end example
29040
29041 which will cause the type X to be represented using a single pointer.
29042 When using this representation, the bounds are right behind the array.
29043 This representation is slightly less efficient, and does not allow quite
29044 such flexibility in the use of foreign pointers or in using the
29045 Unrestricted_Access attribute to create pointers to non-aliased objects.
29046 But for any standard portable use of the access type it will work in
29047 a functionally correct manner and allow porting of existing code.
29048 Note that another way of forcing a thin pointer representation
29049 is to use a component size clause for the element size in an array,
29050 or a record representation clause for an access field in a record.
29051
29052 See the documentation of Unrestricted_Access in the GNAT RM for a
29053 full discussion of possible problems using this attribute in conjunction
29054 with thin pointers.
29055 @end itemize
29056
29057 @node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
29058 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{461}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{462}
29059 @section Compatibility with HP Ada 83
29060
29061
29062 All the HP Ada 83 pragmas and attributes are recognized, although only a subset
29063 of them can sensibly be implemented. The description of pragmas in
29064 @ref{7,,Implementation Defined Pragmas} indicates whether or not they are
29065 applicable to GNAT.
29066
29067
29068 @itemize *
29069
29070 @item
29071 @emph{Default floating-point representation}
29072
29073 In GNAT, the default floating-point format is IEEE, whereas in HP Ada 83,
29074 it is VMS format.
29075
29076 @item
29077 @emph{System}
29078
29079 the package System in GNAT exactly corresponds to the definition in the
29080 Ada 95 reference manual, which means that it excludes many of the
29081 HP Ada 83 extensions. However, a separate package Aux_DEC is provided
29082 that contains the additional definitions, and a special pragma,
29083 Extend_System allows this package to be treated transparently as an
29084 extension of package System.
29085 @end itemize
29086
29087 @node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
29088 @anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license doc}@anchor{463}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{464}
29089 @chapter GNU Free Documentation License
29090
29091
29092 Version 1.3, 3 November 2008
29093
29094 Copyright 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc
29095 @indicateurl{http://fsf.org/}
29096
29097 Everyone is permitted to copy and distribute verbatim copies of this
29098 license document, but changing it is not allowed.
29099
29100 @strong{Preamble}
29101
29102 The purpose of this License is to make a manual, textbook, or other
29103 functional and useful document "free" in the sense of freedom: to
29104 assure everyone the effective freedom to copy and redistribute it,
29105 with or without modifying it, either commercially or noncommercially.
29106 Secondarily, this License preserves for the author and publisher a way
29107 to get credit for their work, while not being considered responsible
29108 for modifications made by others.
29109
29110 This License is a kind of "copyleft", which means that derivative
29111 works of the document must themselves be free in the same sense. It
29112 complements the GNU General Public License, which is a copyleft
29113 license designed for free software.
29114
29115 We have designed this License in order to use it for manuals for free
29116 software, because free software needs free documentation: a free
29117 program should come with manuals providing the same freedoms that the
29118 software does. But this License is not limited to software manuals;
29119 it can be used for any textual work, regardless of subject matter or
29120 whether it is published as a printed book. We recommend this License
29121 principally for works whose purpose is instruction or reference.
29122
29123 @strong{1. APPLICABILITY AND DEFINITIONS}
29124
29125 This License applies to any manual or other work, in any medium, that
29126 contains a notice placed by the copyright holder saying it can be
29127 distributed under the terms of this License. Such a notice grants a
29128 world-wide, royalty-free license, unlimited in duration, to use that
29129 work under the conditions stated herein. The @strong{Document}, below,
29130 refers to any such manual or work. Any member of the public is a
29131 licensee, and is addressed as "@strong{you}". You accept the license if you
29132 copy, modify or distribute the work in a way requiring permission
29133 under copyright law.
29134
29135 A "@strong{Modified Version}" of the Document means any work containing the
29136 Document or a portion of it, either copied verbatim, or with
29137 modifications and/or translated into another language.
29138
29139 A "@strong{Secondary Section}" is a named appendix or a front-matter section of
29140 the Document that deals exclusively with the relationship of the
29141 publishers or authors of the Document to the Document's overall subject
29142 (or to related matters) and contains nothing that could fall directly
29143 within that overall subject. (Thus, if the Document is in part a
29144 textbook of mathematics, a Secondary Section may not explain any
29145 mathematics.) The relationship could be a matter of historical
29146 connection with the subject or with related matters, or of legal,
29147 commercial, philosophical, ethical or political position regarding
29148 them.
29149
29150 The "@strong{Invariant Sections}" are certain Secondary Sections whose titles
29151 are designated, as being those of Invariant Sections, in the notice
29152 that says that the Document is released under this License. If a
29153 section does not fit the above definition of Secondary then it is not
29154 allowed to be designated as Invariant. The Document may contain zero
29155 Invariant Sections. If the Document does not identify any Invariant
29156 Sections then there are none.
29157
29158 The "@strong{Cover Texts}" are certain short passages of text that are listed,
29159 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
29160 the Document is released under this License. A Front-Cover Text may
29161 be at most 5 words, and a Back-Cover Text may be at most 25 words.
29162
29163 A "@strong{Transparent}" copy of the Document means a machine-readable copy,
29164 represented in a format whose specification is available to the
29165 general public, that is suitable for revising the document
29166 straightforwardly with generic text editors or (for images composed of
29167 pixels) generic paint programs or (for drawings) some widely available
29168 drawing editor, and that is suitable for input to text formatters or
29169 for automatic translation to a variety of formats suitable for input
29170 to text formatters. A copy made in an otherwise Transparent file
29171 format whose markup, or absence of markup, has been arranged to thwart
29172 or discourage subsequent modification by readers is not Transparent.
29173 An image format is not Transparent if used for any substantial amount
29174 of text. A copy that is not "Transparent" is called @strong{Opaque}.
29175
29176 Examples of suitable formats for Transparent copies include plain
29177 ASCII without markup, Texinfo input format, LaTeX input format, SGML
29178 or XML using a publicly available DTD, and standard-conforming simple
29179 HTML, PostScript or PDF designed for human modification. Examples of
29180 transparent image formats include PNG, XCF and JPG. Opaque formats
29181 include proprietary formats that can be read and edited only by
29182 proprietary word processors, SGML or XML for which the DTD and/or
29183 processing tools are not generally available, and the
29184 machine-generated HTML, PostScript or PDF produced by some word
29185 processors for output purposes only.
29186
29187 The "@strong{Title Page}" means, for a printed book, the title page itself,
29188 plus such following pages as are needed to hold, legibly, the material
29189 this License requires to appear in the title page. For works in
29190 formats which do not have any title page as such, "Title Page" means
29191 the text near the most prominent appearance of the work's title,
29192 preceding the beginning of the body of the text.
29193
29194 The "@strong{publisher}" means any person or entity that distributes
29195 copies of the Document to the public.
29196
29197 A section "@strong{Entitled XYZ}" means a named subunit of the Document whose
29198 title either is precisely XYZ or contains XYZ in parentheses following
29199 text that translates XYZ in another language. (Here XYZ stands for a
29200 specific section name mentioned below, such as "@strong{Acknowledgements}",
29201 "@strong{Dedications}", "@strong{Endorsements}", or "@strong{History}".)
29202 To "@strong{Preserve the Title}"
29203 of such a section when you modify the Document means that it remains a
29204 section "Entitled XYZ" according to this definition.
29205
29206 The Document may include Warranty Disclaimers next to the notice which
29207 states that this License applies to the Document. These Warranty
29208 Disclaimers are considered to be included by reference in this
29209 License, but only as regards disclaiming warranties: any other
29210 implication that these Warranty Disclaimers may have is void and has
29211 no effect on the meaning of this License.
29212
29213 @strong{2. VERBATIM COPYING}
29214
29215 You may copy and distribute the Document in any medium, either
29216 commercially or noncommercially, provided that this License, the
29217 copyright notices, and the license notice saying this License applies
29218 to the Document are reproduced in all copies, and that you add no other
29219 conditions whatsoever to those of this License. You may not use
29220 technical measures to obstruct or control the reading or further
29221 copying of the copies you make or distribute. However, you may accept
29222 compensation in exchange for copies. If you distribute a large enough
29223 number of copies you must also follow the conditions in section 3.
29224
29225 You may also lend copies, under the same conditions stated above, and
29226 you may publicly display copies.
29227
29228 @strong{3. COPYING IN QUANTITY}
29229
29230 If you publish printed copies (or copies in media that commonly have
29231 printed covers) of the Document, numbering more than 100, and the
29232 Document's license notice requires Cover Texts, you must enclose the
29233 copies in covers that carry, clearly and legibly, all these Cover
29234 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
29235 the back cover. Both covers must also clearly and legibly identify
29236 you as the publisher of these copies. The front cover must present
29237 the full title with all words of the title equally prominent and
29238 visible. You may add other material on the covers in addition.
29239 Copying with changes limited to the covers, as long as they preserve
29240 the title of the Document and satisfy these conditions, can be treated
29241 as verbatim copying in other respects.
29242
29243 If the required texts for either cover are too voluminous to fit
29244 legibly, you should put the first ones listed (as many as fit
29245 reasonably) on the actual cover, and continue the rest onto adjacent
29246 pages.
29247
29248 If you publish or distribute Opaque copies of the Document numbering
29249 more than 100, you must either include a machine-readable Transparent
29250 copy along with each Opaque copy, or state in or with each Opaque copy
29251 a computer-network location from which the general network-using
29252 public has access to download using public-standard network protocols
29253 a complete Transparent copy of the Document, free of added material.
29254 If you use the latter option, you must take reasonably prudent steps,
29255 when you begin distribution of Opaque copies in quantity, to ensure
29256 that this Transparent copy will remain thus accessible at the stated
29257 location until at least one year after the last time you distribute an
29258 Opaque copy (directly or through your agents or retailers) of that
29259 edition to the public.
29260
29261 It is requested, but not required, that you contact the authors of the
29262 Document well before redistributing any large number of copies, to give
29263 them a chance to provide you with an updated version of the Document.
29264
29265 @strong{4. MODIFICATIONS}
29266
29267 You may copy and distribute a Modified Version of the Document under
29268 the conditions of sections 2 and 3 above, provided that you release
29269 the Modified Version under precisely this License, with the Modified
29270 Version filling the role of the Document, thus licensing distribution
29271 and modification of the Modified Version to whoever possesses a copy
29272 of it. In addition, you must do these things in the Modified Version:
29273
29274
29275 @enumerate A
29276
29277 @item
29278 Use in the Title Page (and on the covers, if any) a title distinct
29279 from that of the Document, and from those of previous versions
29280 (which should, if there were any, be listed in the History section
29281 of the Document). You may use the same title as a previous version
29282 if the original publisher of that version gives permission.
29283
29284 @item
29285 List on the Title Page, as authors, one or more persons or entities
29286 responsible for authorship of the modifications in the Modified
29287 Version, together with at least five of the principal authors of the
29288 Document (all of its principal authors, if it has fewer than five),
29289 unless they release you from this requirement.
29290
29291 @item
29292 State on the Title page the name of the publisher of the
29293 Modified Version, as the publisher.
29294
29295 @item
29296 Preserve all the copyright notices of the Document.
29297
29298 @item
29299 Add an appropriate copyright notice for your modifications
29300 adjacent to the other copyright notices.
29301
29302 @item
29303 Include, immediately after the copyright notices, a license notice
29304 giving the public permission to use the Modified Version under the
29305 terms of this License, in the form shown in the Addendum below.
29306
29307 @item
29308 Preserve in that license notice the full lists of Invariant Sections
29309 and required Cover Texts given in the Document's license notice.
29310
29311 @item
29312 Include an unaltered copy of this License.
29313
29314 @item
29315 Preserve the section Entitled "History", Preserve its Title, and add
29316 to it an item stating at least the title, year, new authors, and
29317 publisher of the Modified Version as given on the Title Page. If
29318 there is no section Entitled "History" in the Document, create one
29319 stating the title, year, authors, and publisher of the Document as
29320 given on its Title Page, then add an item describing the Modified
29321 Version as stated in the previous sentence.
29322
29323 @item
29324 Preserve the network location, if any, given in the Document for
29325 public access to a Transparent copy of the Document, and likewise
29326 the network locations given in the Document for previous versions
29327 it was based on. These may be placed in the "History" section.
29328 You may omit a network location for a work that was published at
29329 least four years before the Document itself, or if the original
29330 publisher of the version it refers to gives permission.
29331
29332 @item
29333 For any section Entitled "Acknowledgements" or "Dedications",
29334 Preserve the Title of the section, and preserve in the section all
29335 the substance and tone of each of the contributor acknowledgements
29336 and/or dedications given therein.
29337
29338 @item
29339 Preserve all the Invariant Sections of the Document,
29340 unaltered in their text and in their titles. Section numbers
29341 or the equivalent are not considered part of the section titles.
29342
29343 @item
29344 Delete any section Entitled "Endorsements". Such a section
29345 may not be included in the Modified Version.
29346
29347 @item
29348 Do not retitle any existing section to be Entitled "Endorsements"
29349 or to conflict in title with any Invariant Section.
29350
29351 @item
29352 Preserve any Warranty Disclaimers.
29353 @end enumerate
29354
29355 If the Modified Version includes new front-matter sections or
29356 appendices that qualify as Secondary Sections and contain no material
29357 copied from the Document, you may at your option designate some or all
29358 of these sections as invariant. To do this, add their titles to the
29359 list of Invariant Sections in the Modified Version's license notice.
29360 These titles must be distinct from any other section titles.
29361
29362 You may add a section Entitled "Endorsements", provided it contains
29363 nothing but endorsements of your Modified Version by various
29364 parties---for example, statements of peer review or that the text has
29365 been approved by an organization as the authoritative definition of a
29366 standard.
29367
29368 You may add a passage of up to five words as a Front-Cover Text, and a
29369 passage of up to 25 words as a Back-Cover Text, to the end of the list
29370 of Cover Texts in the Modified Version. Only one passage of
29371 Front-Cover Text and one of Back-Cover Text may be added by (or
29372 through arrangements made by) any one entity. If the Document already
29373 includes a cover text for the same cover, previously added by you or
29374 by arrangement made by the same entity you are acting on behalf of,
29375 you may not add another; but you may replace the old one, on explicit
29376 permission from the previous publisher that added the old one.
29377
29378 The author(s) and publisher(s) of the Document do not by this License
29379 give permission to use their names for publicity for or to assert or
29380 imply endorsement of any Modified Version.
29381
29382 @strong{5. COMBINING DOCUMENTS}
29383
29384 You may combine the Document with other documents released under this
29385 License, under the terms defined in section 4 above for modified
29386 versions, provided that you include in the combination all of the
29387 Invariant Sections of all of the original documents, unmodified, and
29388 list them all as Invariant Sections of your combined work in its
29389 license notice, and that you preserve all their Warranty Disclaimers.
29390
29391 The combined work need only contain one copy of this License, and
29392 multiple identical Invariant Sections may be replaced with a single
29393 copy. If there are multiple Invariant Sections with the same name but
29394 different contents, make the title of each such section unique by
29395 adding at the end of it, in parentheses, the name of the original
29396 author or publisher of that section if known, or else a unique number.
29397 Make the same adjustment to the section titles in the list of
29398 Invariant Sections in the license notice of the combined work.
29399
29400 In the combination, you must combine any sections Entitled "History"
29401 in the various original documents, forming one section Entitled
29402 "History"; likewise combine any sections Entitled "Acknowledgements",
29403 and any sections Entitled "Dedications". You must delete all sections
29404 Entitled "Endorsements".
29405
29406 @strong{6. COLLECTIONS OF DOCUMENTS}
29407
29408 You may make a collection consisting of the Document and other documents
29409 released under this License, and replace the individual copies of this
29410 License in the various documents with a single copy that is included in
29411 the collection, provided that you follow the rules of this License for
29412 verbatim copying of each of the documents in all other respects.
29413
29414 You may extract a single document from such a collection, and distribute
29415 it individually under this License, provided you insert a copy of this
29416 License into the extracted document, and follow this License in all
29417 other respects regarding verbatim copying of that document.
29418
29419 @strong{7. AGGREGATION WITH INDEPENDENT WORKS}
29420
29421 A compilation of the Document or its derivatives with other separate
29422 and independent documents or works, in or on a volume of a storage or
29423 distribution medium, is called an "aggregate" if the copyright
29424 resulting from the compilation is not used to limit the legal rights
29425 of the compilation's users beyond what the individual works permit.
29426 When the Document is included in an aggregate, this License does not
29427 apply to the other works in the aggregate which are not themselves
29428 derivative works of the Document.
29429
29430 If the Cover Text requirement of section 3 is applicable to these
29431 copies of the Document, then if the Document is less than one half of
29432 the entire aggregate, the Document's Cover Texts may be placed on
29433 covers that bracket the Document within the aggregate, or the
29434 electronic equivalent of covers if the Document is in electronic form.
29435 Otherwise they must appear on printed covers that bracket the whole
29436 aggregate.
29437
29438 @strong{8. TRANSLATION}
29439
29440 Translation is considered a kind of modification, so you may
29441 distribute translations of the Document under the terms of section 4.
29442 Replacing Invariant Sections with translations requires special
29443 permission from their copyright holders, but you may include
29444 translations of some or all Invariant Sections in addition to the
29445 original versions of these Invariant Sections. You may include a
29446 translation of this License, and all the license notices in the
29447 Document, and any Warranty Disclaimers, provided that you also include
29448 the original English version of this License and the original versions
29449 of those notices and disclaimers. In case of a disagreement between
29450 the translation and the original version of this License or a notice
29451 or disclaimer, the original version will prevail.
29452
29453 If a section in the Document is Entitled "Acknowledgements",
29454 "Dedications", or "History", the requirement (section 4) to Preserve
29455 its Title (section 1) will typically require changing the actual
29456 title.
29457
29458 @strong{9. TERMINATION}
29459
29460 You may not copy, modify, sublicense, or distribute the Document
29461 except as expressly provided under this License. Any attempt
29462 otherwise to copy, modify, sublicense, or distribute it is void, and
29463 will automatically terminate your rights under this License.
29464
29465 However, if you cease all violation of this License, then your license
29466 from a particular copyright holder is reinstated (a) provisionally,
29467 unless and until the copyright holder explicitly and finally
29468 terminates your license, and (b) permanently, if the copyright holder
29469 fails to notify you of the violation by some reasonable means prior to
29470 60 days after the cessation.
29471
29472 Moreover, your license from a particular copyright holder is
29473 reinstated permanently if the copyright holder notifies you of the
29474 violation by some reasonable means, this is the first time you have
29475 received notice of violation of this License (for any work) from that
29476 copyright holder, and you cure the violation prior to 30 days after
29477 your receipt of the notice.
29478
29479 Termination of your rights under this section does not terminate the
29480 licenses of parties who have received copies or rights from you under
29481 this License. If your rights have been terminated and not permanently
29482 reinstated, receipt of a copy of some or all of the same material does
29483 not give you any rights to use it.
29484
29485 @strong{10. FUTURE REVISIONS OF THIS LICENSE}
29486
29487 The Free Software Foundation may publish new, revised versions
29488 of the GNU Free Documentation License from time to time. Such new
29489 versions will be similar in spirit to the present version, but may
29490 differ in detail to address new problems or concerns. See
29491 @indicateurl{http://www.gnu.org/copyleft/}.
29492
29493 Each version of the License is given a distinguishing version number.
29494 If the Document specifies that a particular numbered version of this
29495 License "or any later version" applies to it, you have the option of
29496 following the terms and conditions either of that specified version or
29497 of any later version that has been published (not as a draft) by the
29498 Free Software Foundation. If the Document does not specify a version
29499 number of this License, you may choose any version ever published (not
29500 as a draft) by the Free Software Foundation. If the Document
29501 specifies that a proxy can decide which future versions of this
29502 License can be used, that proxy's public statement of acceptance of a
29503 version permanently authorizes you to choose that version for the
29504 Document.
29505
29506 @strong{11. RELICENSING}
29507
29508 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
29509 World Wide Web server that publishes copyrightable works and also
29510 provides prominent facilities for anybody to edit those works. A
29511 public wiki that anybody can edit is an example of such a server. A
29512 "Massive Multiauthor Collaboration" (or "MMC") contained in the
29513 site means any set of copyrightable works thus published on the MMC
29514 site.
29515
29516 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
29517 license published by Creative Commons Corporation, a not-for-profit
29518 corporation with a principal place of business in San Francisco,
29519 California, as well as future copyleft versions of that license
29520 published by that same organization.
29521
29522 "Incorporate" means to publish or republish a Document, in whole or
29523 in part, as part of another Document.
29524
29525 An MMC is "eligible for relicensing" if it is licensed under this
29526 License, and if all works that were first published under this License
29527 somewhere other than this MMC, and subsequently incorporated in whole
29528 or in part into the MMC, (1) had no cover texts or invariant sections,
29529 and (2) were thus incorporated prior to November 1, 2008.
29530
29531 The operator of an MMC Site may republish an MMC contained in the site
29532 under CC-BY-SA on the same site at any time before August 1, 2009,
29533 provided the MMC is eligible for relicensing.
29534
29535 @strong{ADDENDUM: How to use this License for your documents}
29536
29537 To use this License in a document you have written, include a copy of
29538 the License in the document and put the following copyright and
29539 license notices just after the title page:
29540
29541 @quotation
29542
29543 Copyright © YEAR YOUR NAME.
29544 Permission is granted to copy, distribute and/or modify this document
29545 under the terms of the GNU Free Documentation License, Version 1.3
29546 or any later version published by the Free Software Foundation;
29547 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
29548 A copy of the license is included in the section entitled "GNU
29549 Free Documentation License".
29550 @end quotation
29551
29552 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
29553 replace the "with ... Texts." line with this:
29554
29555 @quotation
29556
29557 with the Invariant Sections being LIST THEIR TITLES, with the
29558 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
29559 @end quotation
29560
29561 If you have Invariant Sections without Cover Texts, or some other
29562 combination of the three, merge those two alternatives to suit the
29563 situation.
29564
29565 If your document contains nontrivial examples of program code, we
29566 recommend releasing these examples in parallel under your choice of
29567 free software license, such as the GNU General Public License,
29568 to permit their use in free software.
29569
29570 @node Index,,GNU Free Documentation License,Top
29571 @unnumbered Index
29572
29573
29574 @printindex ge
29575
29576
29577 @c %**end of body
29578 @bye