]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/gnat_rm.texi
c++: Handle multiple aggregate overloads [PR95319].
[thirdparty/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 , May 04, 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 Acc_Parallel::
101 * Pragma Acc_Loop::
102 * Pragma Acc_Kernels::
103 * Pragma Acc_Data::
104 * Pragma Ada_83::
105 * Pragma Ada_95::
106 * Pragma Ada_05::
107 * Pragma Ada_2005::
108 * Pragma Ada_12::
109 * Pragma Ada_2012::
110 * Pragma Aggregate_Individually_Assign::
111 * Pragma Allow_Integer_Address::
112 * Pragma Annotate::
113 * Pragma Assert::
114 * Pragma Assert_And_Cut::
115 * Pragma Assertion_Policy::
116 * Pragma Assume::
117 * Pragma Assume_No_Invalid_Values::
118 * Pragma Async_Readers::
119 * Pragma Async_Writers::
120 * Pragma Attribute_Definition::
121 * Pragma C_Pass_By_Copy::
122 * Pragma Check::
123 * Pragma Check_Float_Overflow::
124 * Pragma Check_Name::
125 * Pragma Check_Policy::
126 * Pragma Comment::
127 * Pragma Common_Object::
128 * Pragma Compile_Time_Error::
129 * Pragma Compile_Time_Warning::
130 * Pragma Compiler_Unit::
131 * Pragma Compiler_Unit_Warning::
132 * Pragma Complete_Representation::
133 * Pragma Complex_Representation::
134 * Pragma Component_Alignment::
135 * Pragma Constant_After_Elaboration::
136 * Pragma Contract_Cases::
137 * Pragma Convention_Identifier::
138 * Pragma CPP_Class::
139 * Pragma CPP_Constructor::
140 * Pragma CPP_Virtual::
141 * Pragma CPP_Vtable::
142 * Pragma CPU::
143 * Pragma Deadline_Floor::
144 * Pragma Default_Initial_Condition::
145 * Pragma Debug::
146 * Pragma Debug_Policy::
147 * Pragma Default_Scalar_Storage_Order::
148 * Pragma Default_Storage_Pool::
149 * Pragma Depends::
150 * Pragma Detect_Blocking::
151 * Pragma Disable_Atomic_Synchronization::
152 * Pragma Dispatching_Domain::
153 * Pragma Effective_Reads::
154 * Pragma Effective_Writes::
155 * Pragma Elaboration_Checks::
156 * Pragma Eliminate::
157 * Pragma Enable_Atomic_Synchronization::
158 * Pragma Export_Function::
159 * Pragma Export_Object::
160 * Pragma Export_Procedure::
161 * Pragma Export_Value::
162 * Pragma Export_Valued_Procedure::
163 * Pragma Extend_System::
164 * Pragma Extensions_Allowed::
165 * Pragma Extensions_Visible::
166 * Pragma External::
167 * Pragma External_Name_Casing::
168 * Pragma Fast_Math::
169 * Pragma Favor_Top_Level::
170 * Pragma Finalize_Storage_Only::
171 * Pragma Float_Representation::
172 * Pragma Ghost::
173 * Pragma Global::
174 * Pragma Ident::
175 * Pragma Ignore_Pragma::
176 * Pragma Implementation_Defined::
177 * Pragma Implemented::
178 * Pragma Implicit_Packing::
179 * Pragma Import_Function::
180 * Pragma Import_Object::
181 * Pragma Import_Procedure::
182 * Pragma Import_Valued_Procedure::
183 * Pragma Independent::
184 * Pragma Independent_Components::
185 * Pragma Initial_Condition::
186 * Pragma Initialize_Scalars::
187 * Pragma Initializes::
188 * Pragma Inline_Always::
189 * Pragma Inline_Generic::
190 * Pragma Interface::
191 * Pragma Interface_Name::
192 * Pragma Interrupt_Handler::
193 * Pragma Interrupt_State::
194 * Pragma Invariant::
195 * Pragma Keep_Names::
196 * Pragma License::
197 * Pragma Link_With::
198 * Pragma Linker_Alias::
199 * Pragma Linker_Constructor::
200 * Pragma Linker_Destructor::
201 * Pragma Linker_Section::
202 * Pragma Lock_Free::
203 * Pragma Loop_Invariant::
204 * Pragma Loop_Optimize::
205 * Pragma Loop_Variant::
206 * Pragma Machine_Attribute::
207 * Pragma Main::
208 * Pragma Main_Storage::
209 * Pragma Max_Queue_Length::
210 * Pragma No_Body::
211 * Pragma No_Caching::
212 * Pragma No_Component_Reordering::
213 * Pragma No_Elaboration_Code_All::
214 * Pragma No_Heap_Finalization::
215 * Pragma No_Inline::
216 * Pragma No_Return::
217 * Pragma No_Strict_Aliasing::
218 * Pragma No_Tagged_Streams::
219 * Pragma Normalize_Scalars::
220 * Pragma Obsolescent::
221 * Pragma Optimize_Alignment::
222 * Pragma Ordered::
223 * Pragma Overflow_Mode::
224 * Pragma Overriding_Renamings::
225 * Pragma Partition_Elaboration_Policy::
226 * Pragma Part_Of::
227 * Pragma Passive::
228 * Pragma Persistent_BSS::
229 * Pragma Polling::
230 * Pragma Post::
231 * Pragma Postcondition::
232 * Pragma Post_Class::
233 * Pragma Rename_Pragma::
234 * Pragma Pre::
235 * Pragma Precondition::
236 * Pragma Predicate::
237 * Pragma Predicate_Failure::
238 * Pragma Preelaborable_Initialization::
239 * Pragma Prefix_Exception_Messages::
240 * Pragma Pre_Class::
241 * Pragma Priority_Specific_Dispatching::
242 * Pragma Profile::
243 * Pragma Profile_Warnings::
244 * Pragma Propagate_Exceptions::
245 * Pragma Provide_Shift_Operators::
246 * Pragma Psect_Object::
247 * Pragma Pure_Function::
248 * Pragma Rational::
249 * Pragma Ravenscar::
250 * Pragma Refined_Depends::
251 * Pragma Refined_Global::
252 * Pragma Refined_Post::
253 * Pragma Refined_State::
254 * Pragma Relative_Deadline::
255 * Pragma Remote_Access_Type::
256 * Pragma Restricted_Run_Time::
257 * Pragma Restriction_Warnings::
258 * Pragma Reviewable::
259 * Pragma Secondary_Stack_Size::
260 * Pragma Share_Generic::
261 * Pragma Shared::
262 * Pragma Short_Circuit_And_Or::
263 * Pragma Short_Descriptors::
264 * Pragma Simple_Storage_Pool_Type::
265 * Pragma Source_File_Name::
266 * Pragma Source_File_Name_Project::
267 * Pragma Source_Reference::
268 * Pragma SPARK_Mode::
269 * Pragma Static_Elaboration_Desired::
270 * Pragma Stream_Convert::
271 * Pragma Style_Checks::
272 * Pragma Subtitle::
273 * Pragma Suppress::
274 * Pragma Suppress_All::
275 * Pragma Suppress_Debug_Info::
276 * Pragma Suppress_Exception_Locations::
277 * Pragma Suppress_Initialization::
278 * Pragma Task_Name::
279 * Pragma Task_Storage::
280 * Pragma Test_Case::
281 * Pragma Thread_Local_Storage::
282 * Pragma Time_Slice::
283 * Pragma Title::
284 * Pragma Type_Invariant::
285 * Pragma Type_Invariant_Class::
286 * Pragma Unchecked_Union::
287 * Pragma Unevaluated_Use_Of_Old::
288 * Pragma Unimplemented_Unit::
289 * Pragma Universal_Aliasing::
290 * Pragma Universal_Data::
291 * Pragma Unmodified::
292 * Pragma Unreferenced::
293 * Pragma Unreferenced_Objects::
294 * Pragma Unreserve_All_Interrupts::
295 * Pragma Unsuppress::
296 * Pragma Use_VADS_Size::
297 * Pragma Unused::
298 * Pragma Validity_Checks::
299 * Pragma Volatile::
300 * Pragma Volatile_Full_Access::
301 * Pragma Volatile_Function::
302 * Pragma Warning_As_Error::
303 * Pragma Warnings::
304 * Pragma Weak_External::
305 * Pragma Wide_Character_Encoding::
306
307 Implementation Defined Aspects
308
309 * Aspect Abstract_State::
310 * Aspect Annotate::
311 * Aspect Async_Readers::
312 * Aspect Async_Writers::
313 * Aspect Constant_After_Elaboration::
314 * Aspect Contract_Cases::
315 * Aspect Depends::
316 * Aspect Default_Initial_Condition::
317 * Aspect Dimension::
318 * Aspect Dimension_System::
319 * Aspect Disable_Controlled::
320 * Aspect Effective_Reads::
321 * Aspect Effective_Writes::
322 * Aspect Extensions_Visible::
323 * Aspect Favor_Top_Level::
324 * Aspect Ghost::
325 * Aspect Global::
326 * Aspect Initial_Condition::
327 * Aspect Initializes::
328 * Aspect Inline_Always::
329 * Aspect Invariant::
330 * Aspect Invariant'Class::
331 * Aspect Iterable::
332 * Aspect Linker_Section::
333 * Aspect Lock_Free::
334 * Aspect Max_Queue_Length::
335 * Aspect No_Caching::
336 * Aspect No_Elaboration_Code_All::
337 * Aspect No_Inline::
338 * Aspect No_Tagged_Streams::
339 * Aspect Object_Size::
340 * Aspect Obsolescent::
341 * Aspect Part_Of::
342 * Aspect Persistent_BSS::
343 * Aspect Predicate::
344 * Aspect Pure_Function::
345 * Aspect Refined_Depends::
346 * Aspect Refined_Global::
347 * Aspect Refined_Post::
348 * Aspect Refined_State::
349 * Aspect Remote_Access_Type::
350 * Aspect Secondary_Stack_Size::
351 * Aspect Scalar_Storage_Order::
352 * Aspect Shared::
353 * Aspect Simple_Storage_Pool::
354 * Aspect Simple_Storage_Pool_Type::
355 * Aspect SPARK_Mode::
356 * Aspect Suppress_Debug_Info::
357 * Aspect Suppress_Initialization::
358 * Aspect Test_Case::
359 * Aspect Thread_Local_Storage::
360 * Aspect Universal_Aliasing::
361 * Aspect Universal_Data::
362 * Aspect Unmodified::
363 * Aspect Unreferenced::
364 * Aspect Unreferenced_Objects::
365 * Aspect Value_Size::
366 * Aspect Volatile_Full_Access::
367 * Aspect Volatile_Function::
368 * Aspect Warnings::
369
370 Implementation Defined Attributes
371
372 * Attribute Abort_Signal::
373 * Attribute Address_Size::
374 * Attribute Asm_Input::
375 * Attribute Asm_Output::
376 * Attribute Atomic_Always_Lock_Free::
377 * Attribute Bit::
378 * Attribute Bit_Position::
379 * Attribute Code_Address::
380 * Attribute Compiler_Version::
381 * Attribute Constrained::
382 * Attribute Default_Bit_Order::
383 * Attribute Default_Scalar_Storage_Order::
384 * Attribute Deref::
385 * Attribute Descriptor_Size::
386 * Attribute Elaborated::
387 * Attribute Elab_Body::
388 * Attribute Elab_Spec::
389 * Attribute Elab_Subp_Body::
390 * Attribute Emax::
391 * Attribute Enabled::
392 * Attribute Enum_Rep::
393 * Attribute Enum_Val::
394 * Attribute Epsilon::
395 * Attribute Fast_Math::
396 * Attribute Finalization_Size::
397 * Attribute Fixed_Value::
398 * Attribute From_Any::
399 * Attribute Has_Access_Values::
400 * Attribute Has_Discriminants::
401 * Attribute Img::
402 * Attribute Integer_Value::
403 * Attribute Invalid_Value::
404 * Attribute Iterable::
405 * Attribute Large::
406 * Attribute Library_Level::
407 * Attribute Lock_Free::
408 * Attribute Loop_Entry::
409 * Attribute Machine_Size::
410 * Attribute Mantissa::
411 * Attribute Maximum_Alignment::
412 * Attribute Mechanism_Code::
413 * Attribute Null_Parameter::
414 * Attribute Object_Size::
415 * Attribute Old::
416 * Attribute Passed_By_Reference::
417 * Attribute Pool_Address::
418 * Attribute Range_Length::
419 * Attribute Restriction_Set::
420 * Attribute Result::
421 * Attribute Safe_Emax::
422 * Attribute Safe_Large::
423 * Attribute Safe_Small::
424 * Attribute Scalar_Storage_Order::
425 * Attribute Simple_Storage_Pool::
426 * Attribute Small::
427 * Attribute Storage_Unit::
428 * Attribute Stub_Type::
429 * Attribute System_Allocator_Alignment::
430 * Attribute Target_Name::
431 * Attribute To_Address::
432 * Attribute To_Any::
433 * Attribute Type_Class::
434 * Attribute Type_Key::
435 * Attribute TypeCode::
436 * Attribute Unconstrained_Array::
437 * Attribute Universal_Literal_String::
438 * Attribute Unrestricted_Access::
439 * Attribute Update::
440 * Attribute Valid_Scalars::
441 * Attribute VADS_Size::
442 * Attribute Value_Size::
443 * Attribute Wchar_T_Size::
444 * Attribute Word_Size::
445
446 Standard and Implementation Defined Restrictions
447
448 * Partition-Wide Restrictions::
449 * Program Unit Level Restrictions::
450
451 Partition-Wide Restrictions
452
453 * Immediate_Reclamation::
454 * Max_Asynchronous_Select_Nesting::
455 * Max_Entry_Queue_Length::
456 * Max_Protected_Entries::
457 * Max_Select_Alternatives::
458 * Max_Storage_At_Blocking::
459 * Max_Task_Entries::
460 * Max_Tasks::
461 * No_Abort_Statements::
462 * No_Access_Parameter_Allocators::
463 * No_Access_Subprograms::
464 * No_Allocators::
465 * No_Anonymous_Allocators::
466 * No_Asynchronous_Control::
467 * No_Calendar::
468 * No_Coextensions::
469 * No_Default_Initialization::
470 * No_Delay::
471 * No_Dependence::
472 * No_Direct_Boolean_Operators::
473 * No_Dispatch::
474 * No_Dispatching_Calls::
475 * No_Dynamic_Attachment::
476 * No_Dynamic_Priorities::
477 * No_Entry_Calls_In_Elaboration_Code::
478 * No_Enumeration_Maps::
479 * No_Exception_Handlers::
480 * No_Exception_Propagation::
481 * No_Exception_Registration::
482 * No_Exceptions::
483 * No_Finalization::
484 * No_Fixed_Point::
485 * No_Floating_Point::
486 * No_Implicit_Conditionals::
487 * No_Implicit_Dynamic_Code::
488 * No_Implicit_Heap_Allocations::
489 * No_Implicit_Protected_Object_Allocations::
490 * No_Implicit_Task_Allocations::
491 * No_Initialize_Scalars::
492 * No_IO::
493 * No_Local_Allocators::
494 * No_Local_Protected_Objects::
495 * No_Local_Timing_Events::
496 * No_Long_Long_Integers::
497 * No_Multiple_Elaboration::
498 * No_Nested_Finalization::
499 * No_Protected_Type_Allocators::
500 * No_Protected_Types::
501 * No_Recursion::
502 * No_Reentrancy::
503 * No_Relative_Delay::
504 * No_Requeue_Statements::
505 * No_Secondary_Stack::
506 * No_Select_Statements::
507 * No_Specific_Termination_Handlers::
508 * No_Specification_of_Aspect::
509 * No_Standard_Allocators_After_Elaboration::
510 * No_Standard_Storage_Pools::
511 * No_Stream_Optimizations::
512 * No_Streams::
513 * No_Task_Allocators::
514 * No_Task_At_Interrupt_Priority::
515 * No_Task_Attributes_Package::
516 * No_Task_Hierarchy::
517 * No_Task_Termination::
518 * No_Tasking::
519 * No_Terminate_Alternatives::
520 * No_Unchecked_Access::
521 * No_Unchecked_Conversion::
522 * No_Unchecked_Deallocation::
523 * No_Use_Of_Entity::
524 * Pure_Barriers::
525 * Simple_Barriers::
526 * Static_Priorities::
527 * Static_Storage_Size::
528
529 Program Unit Level Restrictions
530
531 * No_Elaboration_Code::
532 * No_Dynamic_Sized_Objects::
533 * No_Entry_Queue::
534 * No_Implementation_Aspect_Specifications::
535 * No_Implementation_Attributes::
536 * No_Implementation_Identifiers::
537 * No_Implementation_Pragmas::
538 * No_Implementation_Restrictions::
539 * No_Implementation_Units::
540 * No_Implicit_Aliasing::
541 * No_Implicit_Loops::
542 * No_Obsolescent_Features::
543 * No_Wide_Characters::
544 * Static_Dispatch_Tables::
545 * SPARK_05::
546
547 Implementation Advice
548
549 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection.
550 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units.
551 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors.
552 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas.
553 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas.
554 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets.
555 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types.
556 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types.
557 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values.
558 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types.
559 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays.
560 * RM 9.6(30-31); Duration'Small: RM 9 6 30-31 Duration'Small.
561 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation.
562 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information.
563 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks.
564 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses.
565 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types.
566 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses.
567 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses.
568 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses.
569 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses.
570 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses.
571 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses.
572 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses.
573 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes.
574 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering.
575 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private.
576 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations.
577 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion.
578 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage.
579 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation.
580 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes.
581 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types.
582 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling.
583 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling.
584 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation.
585 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate.
586 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export.
587 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces.
588 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C.
589 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL.
590 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran.
591 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations.
592 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations.
593 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support.
594 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers.
595 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts.
596 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements.
597 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names.
598 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes.
599 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies.
600 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies.
601 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort.
602 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions.
603 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time.
604 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem.
605 * RM F(7); COBOL Support: RM F 7 COBOL Support.
606 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support.
607 * RM G; Numerics: RM G Numerics.
608 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types.
609 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions.
610 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements.
611 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy.
612 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy.
613
614 Intrinsic Subprograms
615
616 * Intrinsic Operators::
617 * Compilation_ISO_Date::
618 * Compilation_Date::
619 * Compilation_Time::
620 * Enclosing_Entity::
621 * Exception_Information::
622 * Exception_Message::
623 * Exception_Name::
624 * File::
625 * Line::
626 * Shifts and Rotates::
627 * Source_Location::
628
629 Representation Clauses and Pragmas
630
631 * Alignment Clauses::
632 * Size Clauses::
633 * Storage_Size Clauses::
634 * Size of Variant Record Objects::
635 * Biased Representation::
636 * Value_Size and Object_Size Clauses::
637 * Component_Size Clauses::
638 * Bit_Order Clauses::
639 * Effect of Bit_Order on Byte Ordering::
640 * Pragma Pack for Arrays::
641 * Pragma Pack for Records::
642 * Record Representation Clauses::
643 * Handling of Records with Holes::
644 * Enumeration Clauses::
645 * Address Clauses::
646 * Use of Address Clauses for Memory-Mapped I/O::
647 * Effect of Convention on Representation::
648 * Conventions and Anonymous Access Types::
649 * Determining the Representations chosen by GNAT::
650
651 The Implementation of Standard I/O
652
653 * Standard I/O Packages::
654 * FORM Strings::
655 * Direct_IO::
656 * Sequential_IO::
657 * Text_IO::
658 * Wide_Text_IO::
659 * Wide_Wide_Text_IO::
660 * Stream_IO::
661 * Text Translation::
662 * Shared Files::
663 * Filenames encoding::
664 * File content encoding::
665 * Open Modes::
666 * Operations on C Streams::
667 * Interfacing to C Streams::
668
669 Text_IO
670
671 * Stream Pointer Positioning::
672 * Reading and Writing Non-Regular Files::
673 * Get_Immediate::
674 * Treating Text_IO Files as Streams::
675 * Text_IO Extensions::
676 * Text_IO Facilities for Unbounded Strings::
677
678 Wide_Text_IO
679
680 * Stream Pointer Positioning: Stream Pointer Positioning<2>.
681 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>.
682
683 Wide_Wide_Text_IO
684
685 * Stream Pointer Positioning: Stream Pointer Positioning<3>.
686 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>.
687
688 The GNAT Library
689
690 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads.
691 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads.
692 * Ada.Characters.Wide_Latin_9 (a-cwila1.ads): Ada Characters Wide_Latin_9 a-cwila1 ads.
693 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads.
694 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads.
695 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads): Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads.
696 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads): Ada Containers Formal_Hashed_Maps a-cfhama ads.
697 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads): Ada Containers Formal_Hashed_Sets a-cfhase ads.
698 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads): Ada Containers Formal_Ordered_Maps a-cforma ads.
699 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads): Ada Containers Formal_Ordered_Sets a-cforse ads.
700 * Ada.Containers.Formal_Vectors (a-cofove.ads): Ada Containers Formal_Vectors a-cofove ads.
701 * Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads): Ada Containers Formal_Indefinite_Vectors a-cfinve ads.
702 * Ada.Containers.Functional_Vectors (a-cofuve.ads): Ada Containers Functional_Vectors a-cofuve ads.
703 * Ada.Containers.Functional_Sets (a-cofuse.ads): Ada Containers Functional_Sets a-cofuse ads.
704 * Ada.Containers.Functional_Maps (a-cofuma.ads): Ada Containers Functional_Maps a-cofuma ads.
705 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads.
706 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads.
707 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads.
708 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads.
709 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads.
710 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads.
711 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads.
712 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads.
713 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads.
714 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads.
715 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads.
716 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads.
717 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads.
718 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads.
719 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads.
720 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads.
721 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads.
722 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads.
723 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads.
724 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads.
725 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads.
726 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads.
727 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads.
728 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads.
729 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads.
730 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads.
731 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads.
732 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads.
733 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads.
734 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads.
735 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads.
736 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads.
737 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads.
738 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads.
739 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads.
740 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads.
741 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads.
742 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads.
743 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads.
744 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads.
745 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads.
746 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads.
747 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads.
748 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads.
749 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads.
750 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads.
751 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads.
752 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads.
753 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads.
754 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads.
755 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads.
756 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads.
757 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads.
758 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads.
759 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads.
760 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads.
761 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads.
762 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads.
763 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads.
764 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads.
765 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads.
766 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads.
767 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads.
768 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads.
769 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads.
770 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads.
771 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads.
772 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads.
773 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads.
774 * GNAT.IO (g-io.ads): GNAT IO g-io ads.
775 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads.
776 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads.
777 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads.
778 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads.
779 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads.
780 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads.
781 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads.
782 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads.
783 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads.
784 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads.
785 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads.
786 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads.
787 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads.
788 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads.
789 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads.
790 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads.
791 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads.
792 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads.
793 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads.
794 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads.
795 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads.
796 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads.
797 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads.
798 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads.
799 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads.
800 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads.
801 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads.
802 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads.
803 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads.
804 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads.
805 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads.
806 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads.
807 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads.
808 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads.
809 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads.
810 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads.
811 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads.
812 * GNAT.Table (g-table.ads): GNAT Table g-table ads.
813 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads.
814 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads.
815 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads.
816 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads.
817 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads.
818 * GNAT.UTF_32 (g-table.ads): GNAT UTF_32 g-table ads.
819 * GNAT.Wide_Spelling_Checker (g-u3spch.ads): GNAT Wide_Spelling_Checker g-u3spch ads.
820 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads.
821 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads.
822 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads.
823 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads.
824 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads.
825 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads.
826 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads.
827 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads.
828 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads.
829 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads.
830 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads.
831 * System.Assertions (s-assert.ads): System Assertions s-assert ads.
832 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads.
833 * System.Memory (s-memory.ads): System Memory s-memory ads.
834 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads.
835 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads.
836 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads.
837 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads.
838 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads.
839 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads.
840 * System.Rident (s-rident.ads): System Rident s-rident ads.
841 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads.
842 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads.
843 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads.
844 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads.
845
846 Interfacing to Other Languages
847
848 * Interfacing to C::
849 * Interfacing to C++::
850 * Interfacing to COBOL::
851 * Interfacing to Fortran::
852 * Interfacing to non-GNAT Ada code::
853
854 Implementation of Specific Ada Features
855
856 * Machine Code Insertions::
857 * GNAT Implementation of Tasking::
858 * GNAT Implementation of Shared Passive Packages::
859 * Code Generation for Array Aggregates::
860 * The Size of Discriminated Records with Default Discriminants::
861 * Strict Conformance to the Ada Reference Manual::
862
863 GNAT Implementation of Tasking
864
865 * Mapping Ada Tasks onto the Underlying Kernel Threads::
866 * Ensuring Compliance with the Real-Time Annex::
867 * Support for Locking Policies::
868
869 Code Generation for Array Aggregates
870
871 * Static constant aggregates with static bounds::
872 * Constant aggregates with unconstrained nominal types::
873 * Aggregates with static bounds::
874 * Aggregates with nonstatic bounds::
875 * Aggregates in assignment statements::
876
877 Obsolescent Features
878
879 * pragma No_Run_Time::
880 * pragma Ravenscar::
881 * pragma Restricted_Run_Time::
882 * pragma Task_Info::
883 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads.
884
885 Compatibility and Porting Guide
886
887 * Writing Portable Fixed-Point Declarations::
888 * Compatibility with Ada 83::
889 * Compatibility between Ada 95 and Ada 2005::
890 * Implementation-dependent characteristics::
891 * Compatibility with Other Ada Systems::
892 * Representation Clauses::
893 * Compatibility with HP Ada 83::
894
895 Compatibility with Ada 83
896
897 * Legal Ada 83 programs that are illegal in Ada 95::
898 * More deterministic semantics::
899 * Changed semantics::
900 * Other language compatibility issues::
901
902 Implementation-dependent characteristics
903
904 * Implementation-defined pragmas::
905 * Implementation-defined attributes::
906 * Libraries::
907 * Elaboration order::
908 * Target-specific aspects::
909
910 @end detailmenu
911 @end menu
912
913 @node About This Guide,Implementation Defined Pragmas,Top,Top
914 @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}
915 @chapter About This Guide
916
917
918
919 This manual contains useful information in writing programs using the
920 GNAT compiler. It includes information on implementation dependent
921 characteristics of GNAT, including all the information required by
922 Annex M of the Ada language standard.
923
924 GNAT implements Ada 95, Ada 2005 and Ada 2012, and it may also be
925 invoked in Ada 83 compatibility mode.
926 By default, GNAT assumes Ada 2012,
927 but you can override with a compiler switch
928 to explicitly specify the language version.
929 (Please refer to the @emph{GNAT User's Guide} for details on these switches.)
930 Throughout this manual, references to 'Ada' without a year suffix
931 apply to all the Ada versions of the language.
932
933 Ada is designed to be highly portable.
934 In general, a program will have the same effect even when compiled by
935 different compilers on different platforms.
936 However, since Ada is designed to be used in a
937 wide variety of applications, it also contains a number of system
938 dependent features to be used in interfacing to the external world.
939
940 @geindex Implementation-dependent features
941
942 @geindex Portability
943
944 Note: Any program that makes use of implementation-dependent features
945 may be non-portable. You should follow good programming practice and
946 isolate and clearly document any sections of your program that make use
947 of these features in a non-portable manner.
948
949 @menu
950 * What This Reference Manual Contains::
951 * Conventions::
952 * Related Information::
953
954 @end menu
955
956 @node What This Reference Manual Contains,Conventions,,About This Guide
957 @anchor{gnat_rm/about_this_guide what-this-reference-manual-contains}@anchor{6}
958 @section What This Reference Manual Contains
959
960
961 This reference manual contains the following chapters:
962
963
964 @itemize *
965
966 @item
967 @ref{7,,Implementation Defined Pragmas}, lists GNAT implementation-dependent
968 pragmas, which can be used to extend and enhance the functionality of the
969 compiler.
970
971 @item
972 @ref{8,,Implementation Defined Attributes}, lists GNAT
973 implementation-dependent attributes, which can be used to extend and
974 enhance the functionality of the compiler.
975
976 @item
977 @ref{9,,Standard and Implementation Defined Restrictions}, lists GNAT
978 implementation-dependent restrictions, which can be used to extend and
979 enhance the functionality of the compiler.
980
981 @item
982 @ref{a,,Implementation Advice}, provides information on generally
983 desirable behavior which are not requirements that all compilers must
984 follow since it cannot be provided on all systems, or which may be
985 undesirable on some systems.
986
987 @item
988 @ref{b,,Implementation Defined Characteristics}, provides a guide to
989 minimizing implementation dependent features.
990
991 @item
992 @ref{c,,Intrinsic Subprograms}, describes the intrinsic subprograms
993 implemented by GNAT, and how they can be imported into user
994 application programs.
995
996 @item
997 @ref{d,,Representation Clauses and Pragmas}, describes in detail the
998 way that GNAT represents data, and in particular the exact set
999 of representation clauses and pragmas that is accepted.
1000
1001 @item
1002 @ref{e,,Standard Library Routines}, provides a listing of packages and a
1003 brief description of the functionality that is provided by Ada's
1004 extensive set of standard library routines as implemented by GNAT.
1005
1006 @item
1007 @ref{f,,The Implementation of Standard I/O}, details how the GNAT
1008 implementation of the input-output facilities.
1009
1010 @item
1011 @ref{10,,The GNAT Library}, is a catalog of packages that complement
1012 the Ada predefined library.
1013
1014 @item
1015 @ref{11,,Interfacing to Other Languages}, describes how programs
1016 written in Ada using GNAT can be interfaced to other programming
1017 languages.
1018
1019 @item
1020 @ref{12,,Specialized Needs Annexes}, describes the GNAT implementation of all
1021 of the specialized needs annexes.
1022
1023 @item
1024 @ref{13,,Implementation of Specific Ada Features}, discusses issues related
1025 to GNAT's implementation of machine code insertions, tasking, and several
1026 other features.
1027
1028 @item
1029 @ref{14,,Implementation of Ada 2012 Features}, describes the status of the
1030 GNAT implementation of the Ada 2012 language standard.
1031
1032 @item
1033 @ref{15,,Obsolescent Features} documents implementation dependent features,
1034 including pragmas and attributes, which are considered obsolescent, since
1035 there are other preferred ways of achieving the same results. These
1036 obsolescent forms are retained for backwards compatibility.
1037
1038 @item
1039 @ref{16,,Compatibility and Porting Guide} presents some guidelines for
1040 developing portable Ada code, describes the compatibility issues that
1041 may arise between GNAT and other Ada compilation systems (including those
1042 for Ada 83), and shows how GNAT can expedite porting applications
1043 developed in other Ada environments.
1044
1045 @item
1046 @ref{1,,GNU Free Documentation License} contains the license for this document.
1047 @end itemize
1048
1049 @geindex Ada 95 Language Reference Manual
1050
1051 @geindex Ada 2005 Language Reference Manual
1052
1053 This reference manual assumes a basic familiarity with the Ada 95 language, as
1054 described in the
1055 @cite{International Standard ANSI/ISO/IEC-8652:1995}.
1056 It does not require knowledge of the new features introduced by Ada 2005 or
1057 Ada 2012.
1058 All three reference manuals are included in the GNAT documentation
1059 package.
1060
1061 @node Conventions,Related Information,What This Reference Manual Contains,About This Guide
1062 @anchor{gnat_rm/about_this_guide conventions}@anchor{17}
1063 @section Conventions
1064
1065
1066 @geindex Conventions
1067 @geindex typographical
1068
1069 @geindex Typographical conventions
1070
1071 Following are examples of the typographical and graphic conventions used
1072 in this guide:
1073
1074
1075 @itemize *
1076
1077 @item
1078 @code{Functions}, @code{utility program names}, @code{standard names},
1079 and @code{classes}.
1080
1081 @item
1082 @code{Option flags}
1083
1084 @item
1085 @code{File names}
1086
1087 @item
1088 @code{Variables}
1089
1090 @item
1091 @emph{Emphasis}
1092
1093 @item
1094 [optional information or parameters]
1095
1096 @item
1097 Examples are described by text
1098
1099 @example
1100 and then shown this way.
1101 @end example
1102
1103 @item
1104 Commands that are entered by the user are shown as preceded by a prompt string
1105 comprising the @code{$} character followed by a space.
1106 @end itemize
1107
1108 @node Related Information,,Conventions,About This Guide
1109 @anchor{gnat_rm/about_this_guide related-information}@anchor{18}
1110 @section Related Information
1111
1112
1113 See the following documents for further information on GNAT:
1114
1115
1116 @itemize *
1117
1118 @item
1119 @cite{GNAT User's Guide for Native Platforms},
1120 which provides information on how to use the
1121 GNAT development environment.
1122
1123 @item
1124 @cite{Ada 95 Reference Manual}, the Ada 95 programming language standard.
1125
1126 @item
1127 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
1128 of the Ada 95 standard. The annotations describe
1129 detailed aspects of the design decision, and in particular contain useful
1130 sections on Ada 83 compatibility.
1131
1132 @item
1133 @cite{Ada 2005 Reference Manual}, the Ada 2005 programming language standard.
1134
1135 @item
1136 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
1137 of the Ada 2005 standard. The annotations describe
1138 detailed aspects of the design decision.
1139
1140 @item
1141 @cite{Ada 2012 Reference Manual}, the Ada 2012 programming language standard.
1142
1143 @item
1144 @cite{DEC Ada@comma{} Technical Overview and Comparison on DIGITAL Platforms},
1145 which contains specific information on compatibility between GNAT and
1146 DEC Ada 83 systems.
1147
1148 @item
1149 @cite{DEC Ada@comma{} Language Reference Manual}, part number AA-PYZAB-TK, which
1150 describes in detail the pragmas and attributes provided by the DEC Ada 83
1151 compiler system.
1152 @end itemize
1153
1154 @node Implementation Defined Pragmas,Implementation Defined Aspects,About This Guide,Top
1155 @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}
1156 @chapter Implementation Defined Pragmas
1157
1158
1159 Ada defines a set of pragmas that can be used to supply additional
1160 information to the compiler. These language defined pragmas are
1161 implemented in GNAT and work as described in the Ada Reference Manual.
1162
1163 In addition, Ada allows implementations to define additional pragmas
1164 whose meaning is defined by the implementation. GNAT provides a number
1165 of these implementation-defined pragmas, which can be used to extend
1166 and enhance the functionality of the compiler. This section of the GNAT
1167 Reference Manual describes these additional pragmas.
1168
1169 Note that any program using these pragmas might not be portable to other
1170 compilers (although GNAT implements this set of pragmas on all
1171 platforms). Therefore if portability to other compilers is an important
1172 consideration, the use of these pragmas should be minimized.
1173
1174 @menu
1175 * Pragma Abort_Defer::
1176 * Pragma Abstract_State::
1177 * Pragma Acc_Parallel::
1178 * Pragma Acc_Loop::
1179 * Pragma Acc_Kernels::
1180 * Pragma Acc_Data::
1181 * Pragma Ada_83::
1182 * Pragma Ada_95::
1183 * Pragma Ada_05::
1184 * Pragma Ada_2005::
1185 * Pragma Ada_12::
1186 * Pragma Ada_2012::
1187 * Pragma Aggregate_Individually_Assign::
1188 * Pragma Allow_Integer_Address::
1189 * Pragma Annotate::
1190 * Pragma Assert::
1191 * Pragma Assert_And_Cut::
1192 * Pragma Assertion_Policy::
1193 * Pragma Assume::
1194 * Pragma Assume_No_Invalid_Values::
1195 * Pragma Async_Readers::
1196 * Pragma Async_Writers::
1197 * Pragma Attribute_Definition::
1198 * Pragma C_Pass_By_Copy::
1199 * Pragma Check::
1200 * Pragma Check_Float_Overflow::
1201 * Pragma Check_Name::
1202 * Pragma Check_Policy::
1203 * Pragma Comment::
1204 * Pragma Common_Object::
1205 * Pragma Compile_Time_Error::
1206 * Pragma Compile_Time_Warning::
1207 * Pragma Compiler_Unit::
1208 * Pragma Compiler_Unit_Warning::
1209 * Pragma Complete_Representation::
1210 * Pragma Complex_Representation::
1211 * Pragma Component_Alignment::
1212 * Pragma Constant_After_Elaboration::
1213 * Pragma Contract_Cases::
1214 * Pragma Convention_Identifier::
1215 * Pragma CPP_Class::
1216 * Pragma CPP_Constructor::
1217 * Pragma CPP_Virtual::
1218 * Pragma CPP_Vtable::
1219 * Pragma CPU::
1220 * Pragma Deadline_Floor::
1221 * Pragma Default_Initial_Condition::
1222 * Pragma Debug::
1223 * Pragma Debug_Policy::
1224 * Pragma Default_Scalar_Storage_Order::
1225 * Pragma Default_Storage_Pool::
1226 * Pragma Depends::
1227 * Pragma Detect_Blocking::
1228 * Pragma Disable_Atomic_Synchronization::
1229 * Pragma Dispatching_Domain::
1230 * Pragma Effective_Reads::
1231 * Pragma Effective_Writes::
1232 * Pragma Elaboration_Checks::
1233 * Pragma Eliminate::
1234 * Pragma Enable_Atomic_Synchronization::
1235 * Pragma Export_Function::
1236 * Pragma Export_Object::
1237 * Pragma Export_Procedure::
1238 * Pragma Export_Value::
1239 * Pragma Export_Valued_Procedure::
1240 * Pragma Extend_System::
1241 * Pragma Extensions_Allowed::
1242 * Pragma Extensions_Visible::
1243 * Pragma External::
1244 * Pragma External_Name_Casing::
1245 * Pragma Fast_Math::
1246 * Pragma Favor_Top_Level::
1247 * Pragma Finalize_Storage_Only::
1248 * Pragma Float_Representation::
1249 * Pragma Ghost::
1250 * Pragma Global::
1251 * Pragma Ident::
1252 * Pragma Ignore_Pragma::
1253 * Pragma Implementation_Defined::
1254 * Pragma Implemented::
1255 * Pragma Implicit_Packing::
1256 * Pragma Import_Function::
1257 * Pragma Import_Object::
1258 * Pragma Import_Procedure::
1259 * Pragma Import_Valued_Procedure::
1260 * Pragma Independent::
1261 * Pragma Independent_Components::
1262 * Pragma Initial_Condition::
1263 * Pragma Initialize_Scalars::
1264 * Pragma Initializes::
1265 * Pragma Inline_Always::
1266 * Pragma Inline_Generic::
1267 * Pragma Interface::
1268 * Pragma Interface_Name::
1269 * Pragma Interrupt_Handler::
1270 * Pragma Interrupt_State::
1271 * Pragma Invariant::
1272 * Pragma Keep_Names::
1273 * Pragma License::
1274 * Pragma Link_With::
1275 * Pragma Linker_Alias::
1276 * Pragma Linker_Constructor::
1277 * Pragma Linker_Destructor::
1278 * Pragma Linker_Section::
1279 * Pragma Lock_Free::
1280 * Pragma Loop_Invariant::
1281 * Pragma Loop_Optimize::
1282 * Pragma Loop_Variant::
1283 * Pragma Machine_Attribute::
1284 * Pragma Main::
1285 * Pragma Main_Storage::
1286 * Pragma Max_Queue_Length::
1287 * Pragma No_Body::
1288 * Pragma No_Caching::
1289 * Pragma No_Component_Reordering::
1290 * Pragma No_Elaboration_Code_All::
1291 * Pragma No_Heap_Finalization::
1292 * Pragma No_Inline::
1293 * Pragma No_Return::
1294 * Pragma No_Strict_Aliasing::
1295 * Pragma No_Tagged_Streams::
1296 * Pragma Normalize_Scalars::
1297 * Pragma Obsolescent::
1298 * Pragma Optimize_Alignment::
1299 * Pragma Ordered::
1300 * Pragma Overflow_Mode::
1301 * Pragma Overriding_Renamings::
1302 * Pragma Partition_Elaboration_Policy::
1303 * Pragma Part_Of::
1304 * Pragma Passive::
1305 * Pragma Persistent_BSS::
1306 * Pragma Polling::
1307 * Pragma Post::
1308 * Pragma Postcondition::
1309 * Pragma Post_Class::
1310 * Pragma Rename_Pragma::
1311 * Pragma Pre::
1312 * Pragma Precondition::
1313 * Pragma Predicate::
1314 * Pragma Predicate_Failure::
1315 * Pragma Preelaborable_Initialization::
1316 * Pragma Prefix_Exception_Messages::
1317 * Pragma Pre_Class::
1318 * Pragma Priority_Specific_Dispatching::
1319 * Pragma Profile::
1320 * Pragma Profile_Warnings::
1321 * Pragma Propagate_Exceptions::
1322 * Pragma Provide_Shift_Operators::
1323 * Pragma Psect_Object::
1324 * Pragma Pure_Function::
1325 * Pragma Rational::
1326 * Pragma Ravenscar::
1327 * Pragma Refined_Depends::
1328 * Pragma Refined_Global::
1329 * Pragma Refined_Post::
1330 * Pragma Refined_State::
1331 * Pragma Relative_Deadline::
1332 * Pragma Remote_Access_Type::
1333 * Pragma Restricted_Run_Time::
1334 * Pragma Restriction_Warnings::
1335 * Pragma Reviewable::
1336 * Pragma Secondary_Stack_Size::
1337 * Pragma Share_Generic::
1338 * Pragma Shared::
1339 * Pragma Short_Circuit_And_Or::
1340 * Pragma Short_Descriptors::
1341 * Pragma Simple_Storage_Pool_Type::
1342 * Pragma Source_File_Name::
1343 * Pragma Source_File_Name_Project::
1344 * Pragma Source_Reference::
1345 * Pragma SPARK_Mode::
1346 * Pragma Static_Elaboration_Desired::
1347 * Pragma Stream_Convert::
1348 * Pragma Style_Checks::
1349 * Pragma Subtitle::
1350 * Pragma Suppress::
1351 * Pragma Suppress_All::
1352 * Pragma Suppress_Debug_Info::
1353 * Pragma Suppress_Exception_Locations::
1354 * Pragma Suppress_Initialization::
1355 * Pragma Task_Name::
1356 * Pragma Task_Storage::
1357 * Pragma Test_Case::
1358 * Pragma Thread_Local_Storage::
1359 * Pragma Time_Slice::
1360 * Pragma Title::
1361 * Pragma Type_Invariant::
1362 * Pragma Type_Invariant_Class::
1363 * Pragma Unchecked_Union::
1364 * Pragma Unevaluated_Use_Of_Old::
1365 * Pragma Unimplemented_Unit::
1366 * Pragma Universal_Aliasing::
1367 * Pragma Universal_Data::
1368 * Pragma Unmodified::
1369 * Pragma Unreferenced::
1370 * Pragma Unreferenced_Objects::
1371 * Pragma Unreserve_All_Interrupts::
1372 * Pragma Unsuppress::
1373 * Pragma Use_VADS_Size::
1374 * Pragma Unused::
1375 * Pragma Validity_Checks::
1376 * Pragma Volatile::
1377 * Pragma Volatile_Full_Access::
1378 * Pragma Volatile_Function::
1379 * Pragma Warning_As_Error::
1380 * Pragma Warnings::
1381 * Pragma Weak_External::
1382 * Pragma Wide_Character_Encoding::
1383
1384 @end menu
1385
1386 @node Pragma Abort_Defer,Pragma Abstract_State,,Implementation Defined Pragmas
1387 @anchor{gnat_rm/implementation_defined_pragmas pragma-abort-defer}@anchor{1b}
1388 @section Pragma Abort_Defer
1389
1390
1391 @geindex Deferring aborts
1392
1393 Syntax:
1394
1395 @example
1396 pragma Abort_Defer;
1397 @end example
1398
1399 This pragma must appear at the start of the statement sequence of a
1400 handled sequence of statements (right after the @code{begin}). It has
1401 the effect of deferring aborts for the sequence of statements (but not
1402 for the declarations or handlers, if any, associated with this statement
1403 sequence).
1404
1405 @node Pragma Abstract_State,Pragma Acc_Parallel,Pragma Abort_Defer,Implementation Defined Pragmas
1406 @anchor{gnat_rm/implementation_defined_pragmas pragma-abstract-state}@anchor{1c}@anchor{gnat_rm/implementation_defined_pragmas id2}@anchor{1d}
1407 @section Pragma Abstract_State
1408
1409
1410 Syntax:
1411
1412 @example
1413 pragma Abstract_State (ABSTRACT_STATE_LIST);
1414
1415 ABSTRACT_STATE_LIST ::=
1416 null
1417 | STATE_NAME_WITH_OPTIONS
1418 | (STATE_NAME_WITH_OPTIONS @{, STATE_NAME_WITH_OPTIONS@} )
1419
1420 STATE_NAME_WITH_OPTIONS ::=
1421 STATE_NAME
1422 | (STATE_NAME with OPTION_LIST)
1423
1424 OPTION_LIST ::= OPTION @{, OPTION@}
1425
1426 OPTION ::=
1427 SIMPLE_OPTION
1428 | NAME_VALUE_OPTION
1429
1430 SIMPLE_OPTION ::= Ghost | Synchronous
1431
1432 NAME_VALUE_OPTION ::=
1433 Part_Of => ABSTRACT_STATE
1434 | External [=> EXTERNAL_PROPERTY_LIST]
1435
1436 EXTERNAL_PROPERTY_LIST ::=
1437 EXTERNAL_PROPERTY
1438 | (EXTERNAL_PROPERTY @{, EXTERNAL_PROPERTY@} )
1439
1440 EXTERNAL_PROPERTY ::=
1441 Async_Readers [=> boolean_EXPRESSION]
1442 | Async_Writers [=> boolean_EXPRESSION]
1443 | Effective_Reads [=> boolean_EXPRESSION]
1444 | Effective_Writes [=> boolean_EXPRESSION]
1445 others => boolean_EXPRESSION
1446
1447 STATE_NAME ::= defining_identifier
1448
1449 ABSTRACT_STATE ::= name
1450 @end example
1451
1452 For the semantics of this pragma, see the entry for aspect @code{Abstract_State} in
1453 the SPARK 2014 Reference Manual, section 7.1.4.
1454
1455 @node Pragma Acc_Parallel,Pragma Acc_Loop,Pragma Abstract_State,Implementation Defined Pragmas
1456 @anchor{gnat_rm/implementation_defined_pragmas pragma-acc-parallel}@anchor{1e}
1457 @section Pragma Acc_Parallel
1458
1459
1460 Syntax:
1461
1462 @example
1463 pragma Acc_Parallel [( ACC_PARALLEL_CLAUSE [, ACC_PARALLEL_CLAUSE... ])];
1464
1465 ACC_PARALLEL_CLAUSE ::=
1466 Acc_If => boolean_EXPRESSION
1467 | Acc_Private => IDENTIFIERS
1468 | Async => integer_EXPRESSION
1469 | Copy => IDENTIFIERS
1470 | Copy_In => IDENTIFIERS
1471 | Copy_Out => IDENTIFIERS
1472 | Create => IDENTIFIERS
1473 | Default => None
1474 | Device_Ptr => IDENTIFIERS
1475 | First_Private => IDENTIFIERS
1476 | Num_Gangs => integer_EXPRESSION
1477 | Num_Workers => integer_EXPRESSION
1478 | Present => IDENTIFIERS
1479 | Reduction => (REDUCTION_RECORD)
1480 | Vector_Length => integer_EXPRESSION
1481 | Wait => INTEGERS
1482
1483 REDUCTION_RECORD ::=
1484 "+" => IDENTIFIERS
1485 | "*" => IDENTIFIERS
1486 | "min" => IDENTIFIERS
1487 | "max" => IDENTIFIERS
1488 | "or" => IDENTIFIERS
1489 | "and" => IDENTIFIERS
1490
1491 IDENTIFIERS ::=
1492 | IDENTIFIER
1493 | (IDENTIFIER, IDENTIFIERS)
1494
1495 INTEGERS ::=
1496 | integer_EXPRESSION
1497 | (integer_EXPRESSION, INTEGERS)
1498 @end example
1499
1500 Requires the @code{-fopenacc} flag.
1501
1502 Equivalent to the @code{parallel} directive of the OpenAcc standard. This pragma
1503 should be placed in loops. It offloads the content of the loop to an
1504 accelerator device.
1505
1506 For more information about the effect of the clauses, see the OpenAcc
1507 specification.
1508
1509 @node Pragma Acc_Loop,Pragma Acc_Kernels,Pragma Acc_Parallel,Implementation Defined Pragmas
1510 @anchor{gnat_rm/implementation_defined_pragmas pragma-acc-loop}@anchor{1f}
1511 @section Pragma Acc_Loop
1512
1513
1514 Syntax:
1515
1516 @example
1517 pragma Acc_Loop [( ACC_LOOP_CLAUSE [, ACC_LOOP_CLAUSE... ])];
1518
1519 ACC_LOOP_CLAUSE ::=
1520 Auto
1521 | Collapse => INTEGER_LITERAL
1522 | Gang [=> GANG_ARG]
1523 | Independent
1524 | Private => IDENTIFIERS
1525 | Reduction => (REDUCTION_RECORD)
1526 | Seq
1527 | Tile => SIZE_EXPRESSION
1528 | Vector [=> integer_EXPRESSION]
1529 | Worker [=> integer_EXPRESSION]
1530
1531 GANG_ARG ::=
1532 integer_EXPRESSION
1533 | Static => SIZE_EXPRESSION
1534
1535 SIZE_EXPRESSION ::=
1536 *
1537 | integer_EXPRESSION
1538 @end example
1539
1540 Requires the @code{-fopenacc} flag.
1541
1542 Equivalent to the @code{loop} directive of the OpenAcc standard. This pragma
1543 should be placed in for loops after the "Acc_Parallel" pragma. It tells the
1544 compiler how to parallelize the loop.
1545
1546 For more information about the effect of the clauses, see the OpenAcc
1547 specification.
1548
1549 @node Pragma Acc_Kernels,Pragma Acc_Data,Pragma Acc_Loop,Implementation Defined Pragmas
1550 @anchor{gnat_rm/implementation_defined_pragmas pragma-acc-kernels}@anchor{20}
1551 @section Pragma Acc_Kernels
1552
1553
1554 Syntax:
1555
1556 @example
1557 pragma Acc_Kernels [( ACC_KERNELS_CLAUSE [, ACC_KERNELS_CLAUSE...])];
1558
1559 ACC_KERNELS_CLAUSE ::=
1560 Acc_If => boolean_EXPRESSION
1561 | Async => integer_EXPRESSION
1562 | Copy => IDENTIFIERS
1563 | Copy_In => IDENTIFIERS
1564 | Copy_Out => IDENTIFIERS
1565 | Create => IDENTIFIERS
1566 | Default => None
1567 | Device_Ptr => IDENTIFIERS
1568 | Num_Gangs => integer_EXPRESSION
1569 | Num_Workers => integer_EXPRESSION
1570 | Present => IDENTIFIERS
1571 | Vector_Length => integer_EXPRESSION
1572 | Wait => INTEGERS
1573
1574 IDENTIFIERS ::=
1575 | IDENTIFIER
1576 | (IDENTIFIER, IDENTIFIERS)
1577
1578 INTEGERS ::=
1579 | integer_EXPRESSION
1580 | (integer_EXPRESSION, INTEGERS)
1581 @end example
1582
1583 Requires the @code{-fopenacc} flag.
1584
1585 Equivalent to the kernels directive of the OpenAcc standard. This pragma should
1586 be placed in loops.
1587
1588 For more information about the effect of the clauses, see the OpenAcc
1589 specification.
1590
1591 @node Pragma Acc_Data,Pragma Ada_83,Pragma Acc_Kernels,Implementation Defined Pragmas
1592 @anchor{gnat_rm/implementation_defined_pragmas pragma-acc-data}@anchor{21}
1593 @section Pragma Acc_Data
1594
1595
1596 Syntax:
1597
1598 @example
1599 pragma Acc_Data ([ ACC_DATA_CLAUSE [, ACC_DATA_CLAUSE...]]);
1600
1601 ACC_DATA_CLAUSE ::=
1602 Copy => IDENTIFIERS
1603 | Copy_In => IDENTIFIERS
1604 | Copy_Out => IDENTIFIERS
1605 | Create => IDENTIFIERS
1606 | Device_Ptr => IDENTIFIERS
1607 | Present => IDENTIFIERS
1608 @end example
1609
1610 Requires the @code{-fopenacc} flag.
1611
1612 Equivalent to the @code{data} directive of the OpenAcc standard. This pragma
1613 should be placed in loops.
1614
1615 For more information about the effect of the clauses, see the OpenAcc
1616 specification.
1617
1618 @node Pragma Ada_83,Pragma Ada_95,Pragma Acc_Data,Implementation Defined Pragmas
1619 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-83}@anchor{22}
1620 @section Pragma Ada_83
1621
1622
1623 Syntax:
1624
1625 @example
1626 pragma Ada_83;
1627 @end example
1628
1629 A configuration pragma that establishes Ada 83 mode for the unit to
1630 which it applies, regardless of the mode set by the command line
1631 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1632 the syntax and semantics of Ada 83, as defined in the original Ada
1633 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1634 and Ada 2005 are not recognized, optional package bodies are allowed,
1635 and generics may name types with unknown discriminants without using
1636 the @code{(<>)} notation. In addition, some but not all of the additional
1637 restrictions of Ada 83 are enforced.
1638
1639 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1640 Ada 83 code to be compiled and adapted to GNAT with less effort.
1641 Secondly, it aids in keeping code backwards compatible with Ada 83.
1642 However, there is no guarantee that code that is processed correctly
1643 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1644 83 compiler, since GNAT does not enforce all the additional checks
1645 required by Ada 83.
1646
1647 @node Pragma Ada_95,Pragma Ada_05,Pragma Ada_83,Implementation Defined Pragmas
1648 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-95}@anchor{23}
1649 @section Pragma Ada_95
1650
1651
1652 Syntax:
1653
1654 @example
1655 pragma Ada_95;
1656 @end example
1657
1658 A configuration pragma that establishes Ada 95 mode for the unit to which
1659 it applies, regardless of the mode set by the command line switches.
1660 This mode is set automatically for the @code{Ada} and @code{System}
1661 packages and their children, so you need not specify it in these
1662 contexts. This pragma is useful when writing a reusable component that
1663 itself uses Ada 95 features, but which is intended to be usable from
1664 either Ada 83 or Ada 95 programs.
1665
1666 @node Pragma Ada_05,Pragma Ada_2005,Pragma Ada_95,Implementation Defined Pragmas
1667 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-05}@anchor{24}
1668 @section Pragma Ada_05
1669
1670
1671 Syntax:
1672
1673 @example
1674 pragma Ada_05;
1675 pragma Ada_05 (local_NAME);
1676 @end example
1677
1678 A configuration pragma that establishes Ada 2005 mode for the unit to which
1679 it applies, regardless of the mode set by the command line switches.
1680 This pragma is useful when writing a reusable component that
1681 itself uses Ada 2005 features, but which is intended to be usable from
1682 either Ada 83 or Ada 95 programs.
1683
1684 The one argument form (which is not a configuration pragma)
1685 is used for managing the transition from
1686 Ada 95 to Ada 2005 in the run-time library. If an entity is marked
1687 as Ada_2005 only, then referencing the entity in Ada_83 or Ada_95
1688 mode will generate a warning. In addition, in Ada_83 or Ada_95
1689 mode, a preference rule is established which does not choose
1690 such an entity unless it is unambiguously specified. This avoids
1691 extra subprograms marked this way from generating ambiguities in
1692 otherwise legal pre-Ada_2005 programs. The one argument form is
1693 intended for exclusive use in the GNAT run-time library.
1694
1695 @node Pragma Ada_2005,Pragma Ada_12,Pragma Ada_05,Implementation Defined Pragmas
1696 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2005}@anchor{25}
1697 @section Pragma Ada_2005
1698
1699
1700 Syntax:
1701
1702 @example
1703 pragma Ada_2005;
1704 @end example
1705
1706 This configuration pragma is a synonym for pragma Ada_05 and has the
1707 same syntax and effect.
1708
1709 @node Pragma Ada_12,Pragma Ada_2012,Pragma Ada_2005,Implementation Defined Pragmas
1710 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-12}@anchor{26}
1711 @section Pragma Ada_12
1712
1713
1714 Syntax:
1715
1716 @example
1717 pragma Ada_12;
1718 pragma Ada_12 (local_NAME);
1719 @end example
1720
1721 A configuration pragma that establishes Ada 2012 mode for the unit to which
1722 it applies, regardless of the mode set by the command line switches.
1723 This mode is set automatically for the @code{Ada} and @code{System}
1724 packages and their children, so you need not specify it in these
1725 contexts. This pragma is useful when writing a reusable component that
1726 itself uses Ada 2012 features, but which is intended to be usable from
1727 Ada 83, Ada 95, or Ada 2005 programs.
1728
1729 The one argument form, which is not a configuration pragma,
1730 is used for managing the transition from Ada
1731 2005 to Ada 2012 in the run-time library. If an entity is marked
1732 as Ada_2012 only, then referencing the entity in any pre-Ada_2012
1733 mode will generate a warning. In addition, in any pre-Ada_2012
1734 mode, a preference rule is established which does not choose
1735 such an entity unless it is unambiguously specified. This avoids
1736 extra subprograms marked this way from generating ambiguities in
1737 otherwise legal pre-Ada_2012 programs. The one argument form is
1738 intended for exclusive use in the GNAT run-time library.
1739
1740 @node Pragma Ada_2012,Pragma Aggregate_Individually_Assign,Pragma Ada_12,Implementation Defined Pragmas
1741 @anchor{gnat_rm/implementation_defined_pragmas pragma-ada-2012}@anchor{27}
1742 @section Pragma Ada_2012
1743
1744
1745 Syntax:
1746
1747 @example
1748 pragma Ada_2012;
1749 @end example
1750
1751 This configuration pragma is a synonym for pragma Ada_12 and has the
1752 same syntax and effect.
1753
1754 @node Pragma Aggregate_Individually_Assign,Pragma Allow_Integer_Address,Pragma Ada_2012,Implementation Defined Pragmas
1755 @anchor{gnat_rm/implementation_defined_pragmas pragma-aggregate-individually-assign}@anchor{28}
1756 @section Pragma Aggregate_Individually_Assign
1757
1758
1759 Syntax:
1760
1761 @example
1762 pragma Aggregate_Individually_Assign;
1763 @end example
1764
1765 Where possible, GNAT will store the binary representation of a record aggregate
1766 in memory for space and performance reasons. This configuration pragma changes
1767 this behavior so that record aggregates are instead always converted into
1768 individual assignment statements.
1769
1770 @node Pragma Allow_Integer_Address,Pragma Annotate,Pragma Aggregate_Individually_Assign,Implementation Defined Pragmas
1771 @anchor{gnat_rm/implementation_defined_pragmas pragma-allow-integer-address}@anchor{29}
1772 @section Pragma Allow_Integer_Address
1773
1774
1775 Syntax:
1776
1777 @example
1778 pragma Allow_Integer_Address;
1779 @end example
1780
1781 In almost all versions of GNAT, @code{System.Address} is a private
1782 type in accordance with the implementation advice in the RM. This
1783 means that integer values,
1784 in particular integer literals, are not allowed as address values.
1785 If the configuration pragma
1786 @code{Allow_Integer_Address} is given, then integer expressions may
1787 be used anywhere a value of type @code{System.Address} is required.
1788 The effect is to introduce an implicit unchecked conversion from the
1789 integer value to type @code{System.Address}. The reverse case of using
1790 an address where an integer type is required is handled analogously.
1791 The following example compiles without errors:
1792
1793 @example
1794 pragma Allow_Integer_Address;
1795 with System; use System;
1796 package AddrAsInt is
1797 X : Integer;
1798 Y : Integer;
1799 for X'Address use 16#1240#;
1800 for Y use at 16#3230#;
1801 m : Address := 16#4000#;
1802 n : constant Address := 4000;
1803 p : constant Address := Address (X + Y);
1804 v : Integer := y'Address;
1805 w : constant Integer := Integer (Y'Address);
1806 type R is new integer;
1807 RR : R := 1000;
1808 Z : Integer;
1809 for Z'Address use RR;
1810 end AddrAsInt;
1811 @end example
1812
1813 Note that pragma @code{Allow_Integer_Address} is ignored if @code{System.Address}
1814 is not a private type. In implementations of @code{GNAT} where
1815 System.Address is a visible integer type,
1816 this pragma serves no purpose but is ignored
1817 rather than rejected to allow common sets of sources to be used
1818 in the two situations.
1819
1820 @node Pragma Annotate,Pragma Assert,Pragma Allow_Integer_Address,Implementation Defined Pragmas
1821 @anchor{gnat_rm/implementation_defined_pragmas pragma-annotate}@anchor{2a}@anchor{gnat_rm/implementation_defined_pragmas id3}@anchor{2b}
1822 @section Pragma Annotate
1823
1824
1825 Syntax:
1826
1827 @example
1828 pragma Annotate (IDENTIFIER [, IDENTIFIER @{, ARG@}] [, entity => local_NAME]);
1829
1830 ARG ::= NAME | EXPRESSION
1831 @end example
1832
1833 This pragma is used to annotate programs. IDENTIFIER identifies
1834 the type of annotation. GNAT verifies that it is an identifier, but does
1835 not otherwise analyze it. The second optional identifier is also left
1836 unanalyzed, and by convention is used to control the action of the tool to
1837 which the annotation is addressed. The remaining ARG arguments
1838 can be either string literals or more generally expressions.
1839 String literals (and concatenations of string literals) are assumed to be
1840 either of type
1841 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1842 depending on the character literals they contain.
1843 All other kinds of arguments are analyzed as expressions, and must be
1844 unambiguous. The last argument if present must have the identifier
1845 @code{Entity} and GNAT verifies that a local name is given.
1846
1847 The analyzed pragma is retained in the tree, but not otherwise processed
1848 by any part of the GNAT compiler, except to generate corresponding note
1849 lines in the generated ALI file. For the format of these note lines, see
1850 the compiler source file lib-writ.ads. This pragma is intended for use by
1851 external tools, including ASIS. The use of pragma Annotate does not
1852 affect the compilation process in any way. This pragma may be used as
1853 a configuration pragma.
1854
1855 @node Pragma Assert,Pragma Assert_And_Cut,Pragma Annotate,Implementation Defined Pragmas
1856 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert}@anchor{2c}
1857 @section Pragma Assert
1858
1859
1860 Syntax:
1861
1862 @example
1863 pragma Assert (
1864 boolean_EXPRESSION
1865 [, string_EXPRESSION]);
1866 @end example
1867
1868 The effect of this pragma depends on whether the corresponding command
1869 line switch is set to activate assertions. The pragma expands into code
1870 equivalent to the following:
1871
1872 @example
1873 if assertions-enabled then
1874 if not boolean_EXPRESSION then
1875 System.Assertions.Raise_Assert_Failure
1876 (string_EXPRESSION);
1877 end if;
1878 end if;
1879 @end example
1880
1881 The string argument, if given, is the message that will be associated
1882 with the exception occurrence if the exception is raised. If no second
1883 argument is given, the default message is @code{file}:@code{nnn},
1884 where @code{file} is the name of the source file containing the assert,
1885 and @code{nnn} is the line number of the assert.
1886
1887 Note that, as with the @code{if} statement to which it is equivalent, the
1888 type of the expression is either @code{Standard.Boolean}, or any type derived
1889 from this standard type.
1890
1891 Assert checks can be either checked or ignored. By default they are ignored.
1892 They will be checked if either the command line switch @emph{-gnata} is
1893 used, or if an @code{Assertion_Policy} or @code{Check_Policy} pragma is used
1894 to enable @code{Assert_Checks}.
1895
1896 If assertions are ignored, then there
1897 is no run-time effect (and in particular, any side effects from the
1898 expression will not occur at run time). (The expression is still
1899 analyzed at compile time, and may cause types to be frozen if they are
1900 mentioned here for the first time).
1901
1902 If assertions are checked, then the given expression is tested, and if
1903 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1904 which results in the raising of @code{Assert_Failure} with the given message.
1905
1906 You should generally avoid side effects in the expression arguments of
1907 this pragma, because these side effects will turn on and off with the
1908 setting of the assertions mode, resulting in assertions that have an
1909 effect on the program. However, the expressions are analyzed for
1910 semantic correctness whether or not assertions are enabled, so turning
1911 assertions on and off cannot affect the legality of a program.
1912
1913 Note that the implementation defined policy @code{DISABLE}, given in a
1914 pragma @code{Assertion_Policy}, can be used to suppress this semantic analysis.
1915
1916 Note: this is a standard language-defined pragma in versions
1917 of Ada from 2005 on. In GNAT, it is implemented in all versions
1918 of Ada, and the DISABLE policy is an implementation-defined
1919 addition.
1920
1921 @node Pragma Assert_And_Cut,Pragma Assertion_Policy,Pragma Assert,Implementation Defined Pragmas
1922 @anchor{gnat_rm/implementation_defined_pragmas pragma-assert-and-cut}@anchor{2d}
1923 @section Pragma Assert_And_Cut
1924
1925
1926 Syntax:
1927
1928 @example
1929 pragma Assert_And_Cut (
1930 boolean_EXPRESSION
1931 [, string_EXPRESSION]);
1932 @end example
1933
1934 The effect of this pragma is identical to that of pragma @code{Assert},
1935 except that in an @code{Assertion_Policy} pragma, the identifier
1936 @code{Assert_And_Cut} is used to control whether it is ignored or checked
1937 (or disabled).
1938
1939 The intention is that this be used within a subprogram when the
1940 given test expresion sums up all the work done so far in the
1941 subprogram, so that the rest of the subprogram can be verified
1942 (informally or formally) using only the entry preconditions,
1943 and the expression in this pragma. This allows dividing up
1944 a subprogram into sections for the purposes of testing or
1945 formal verification. The pragma also serves as useful
1946 documentation.
1947
1948 @node Pragma Assertion_Policy,Pragma Assume,Pragma Assert_And_Cut,Implementation Defined Pragmas
1949 @anchor{gnat_rm/implementation_defined_pragmas pragma-assertion-policy}@anchor{2e}
1950 @section Pragma Assertion_Policy
1951
1952
1953 Syntax:
1954
1955 @example
1956 pragma Assertion_Policy (CHECK | DISABLE | IGNORE | SUPPRESSIBLE);
1957
1958 pragma Assertion_Policy (
1959 ASSERTION_KIND => POLICY_IDENTIFIER
1960 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1961
1962 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1963
1964 RM_ASSERTION_KIND ::= Assert |
1965 Static_Predicate |
1966 Dynamic_Predicate |
1967 Pre |
1968 Pre'Class |
1969 Post |
1970 Post'Class |
1971 Type_Invariant |
1972 Type_Invariant'Class
1973
1974 ID_ASSERTION_KIND ::= Assertions |
1975 Assert_And_Cut |
1976 Assume |
1977 Contract_Cases |
1978 Debug |
1979 Ghost |
1980 Invariant |
1981 Invariant'Class |
1982 Loop_Invariant |
1983 Loop_Variant |
1984 Postcondition |
1985 Precondition |
1986 Predicate |
1987 Refined_Post |
1988 Statement_Assertions
1989
1990 POLICY_IDENTIFIER ::= Check | Disable | Ignore | Suppressible
1991 @end example
1992
1993 This is a standard Ada 2012 pragma that is available as an
1994 implementation-defined pragma in earlier versions of Ada.
1995 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1996 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1997 are implementation defined additions recognized by the GNAT compiler.
1998
1999 The pragma applies in both cases to pragmas and aspects with matching
2000 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
2001 applies to both the @code{Precondition} pragma
2002 and the aspect @code{Precondition}. Note that the identifiers for
2003 pragmas Pre_Class and Post_Class are Pre'Class and Post'Class (not
2004 Pre_Class and Post_Class), since these pragmas are intended to be
2005 identical to the corresponding aspects).
2006
2007 If the policy is @code{CHECK}, then assertions are enabled, i.e.
2008 the corresponding pragma or aspect is activated.
2009 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
2010 the corresponding pragma or aspect is deactivated.
2011 This pragma overrides the effect of the @emph{-gnata} switch on the
2012 command line.
2013 If the policy is @code{SUPPRESSIBLE}, then assertions are enabled by default,
2014 however, if the @emph{-gnatp} switch is specified all assertions are ignored.
2015
2016 The implementation defined policy @code{DISABLE} is like
2017 @code{IGNORE} except that it completely disables semantic
2018 checking of the corresponding pragma or aspect. This is
2019 useful when the pragma or aspect argument references subprograms
2020 in a with'ed package which is replaced by a dummy package
2021 for the final build.
2022
2023 The implementation defined assertion kind @code{Assertions} applies to all
2024 assertion kinds. The form with no assertion kind given implies this
2025 choice, so it applies to all assertion kinds (RM defined, and
2026 implementation defined).
2027
2028 The implementation defined assertion kind @code{Statement_Assertions}
2029 applies to @code{Assert}, @code{Assert_And_Cut},
2030 @code{Assume}, @code{Loop_Invariant}, and @code{Loop_Variant}.
2031
2032 @node Pragma Assume,Pragma Assume_No_Invalid_Values,Pragma Assertion_Policy,Implementation Defined Pragmas
2033 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume}@anchor{2f}
2034 @section Pragma Assume
2035
2036
2037 Syntax:
2038
2039 @example
2040 pragma Assume (
2041 boolean_EXPRESSION
2042 [, string_EXPRESSION]);
2043 @end example
2044
2045 The effect of this pragma is identical to that of pragma @code{Assert},
2046 except that in an @code{Assertion_Policy} pragma, the identifier
2047 @code{Assume} is used to control whether it is ignored or checked
2048 (or disabled).
2049
2050 The intention is that this be used for assumptions about the
2051 external environment. So you cannot expect to verify formally
2052 or informally that the condition is met, this must be
2053 established by examining things outside the program itself.
2054 For example, we may have code that depends on the size of
2055 @code{Long_Long_Integer} being at least 64. So we could write:
2056
2057 @example
2058 pragma Assume (Long_Long_Integer'Size >= 64);
2059 @end example
2060
2061 This assumption cannot be proved from the program itself,
2062 but it acts as a useful run-time check that the assumption
2063 is met, and documents the need to ensure that it is met by
2064 reference to information outside the program.
2065
2066 @node Pragma Assume_No_Invalid_Values,Pragma Async_Readers,Pragma Assume,Implementation Defined Pragmas
2067 @anchor{gnat_rm/implementation_defined_pragmas pragma-assume-no-invalid-values}@anchor{30}
2068 @section Pragma Assume_No_Invalid_Values
2069
2070
2071 @geindex Invalid representations
2072
2073 @geindex Invalid values
2074
2075 Syntax:
2076
2077 @example
2078 pragma Assume_No_Invalid_Values (On | Off);
2079 @end example
2080
2081 This is a configuration pragma that controls the assumptions made by the
2082 compiler about the occurrence of invalid representations (invalid values)
2083 in the code.
2084
2085 The default behavior (corresponding to an Off argument for this pragma), is
2086 to assume that values may in general be invalid unless the compiler can
2087 prove they are valid. Consider the following example:
2088
2089 @example
2090 V1 : Integer range 1 .. 10;
2091 V2 : Integer range 11 .. 20;
2092 ...
2093 for J in V2 .. V1 loop
2094 ...
2095 end loop;
2096 @end example
2097
2098 if V1 and V2 have valid values, then the loop is known at compile
2099 time not to execute since the lower bound must be greater than the
2100 upper bound. However in default mode, no such assumption is made,
2101 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
2102 is given, the compiler will assume that any occurrence of a variable
2103 other than in an explicit @code{'Valid} test always has a valid
2104 value, and the loop above will be optimized away.
2105
2106 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
2107 you know your code is free of uninitialized variables and other
2108 possible sources of invalid representations, and may result in
2109 more efficient code. A program that accesses an invalid representation
2110 with this pragma in effect is erroneous, so no guarantees can be made
2111 about its behavior.
2112
2113 It is peculiar though permissible to use this pragma in conjunction
2114 with validity checking (-gnatVa). In such cases, accessing invalid
2115 values will generally give an exception, though formally the program
2116 is erroneous so there are no guarantees that this will always be the
2117 case, and it is recommended that these two options not be used together.
2118
2119 @node Pragma Async_Readers,Pragma Async_Writers,Pragma Assume_No_Invalid_Values,Implementation Defined Pragmas
2120 @anchor{gnat_rm/implementation_defined_pragmas pragma-async-readers}@anchor{31}@anchor{gnat_rm/implementation_defined_pragmas id4}@anchor{32}
2121 @section Pragma Async_Readers
2122
2123
2124 Syntax:
2125
2126 @example
2127 pragma Async_Readers [ (boolean_EXPRESSION) ];
2128 @end example
2129
2130 For the semantics of this pragma, see the entry for aspect @code{Async_Readers} in
2131 the SPARK 2014 Reference Manual, section 7.1.2.
2132
2133 @node Pragma Async_Writers,Pragma Attribute_Definition,Pragma Async_Readers,Implementation Defined Pragmas
2134 @anchor{gnat_rm/implementation_defined_pragmas id5}@anchor{33}@anchor{gnat_rm/implementation_defined_pragmas pragma-async-writers}@anchor{34}
2135 @section Pragma Async_Writers
2136
2137
2138 Syntax:
2139
2140 @example
2141 pragma Async_Writers [ (boolean_EXPRESSION) ];
2142 @end example
2143
2144 For the semantics of this pragma, see the entry for aspect @code{Async_Writers} in
2145 the SPARK 2014 Reference Manual, section 7.1.2.
2146
2147 @node Pragma Attribute_Definition,Pragma C_Pass_By_Copy,Pragma Async_Writers,Implementation Defined Pragmas
2148 @anchor{gnat_rm/implementation_defined_pragmas pragma-attribute-definition}@anchor{35}
2149 @section Pragma Attribute_Definition
2150
2151
2152 Syntax:
2153
2154 @example
2155 pragma Attribute_Definition
2156 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
2157 [Entity =>] LOCAL_NAME,
2158 [Expression =>] EXPRESSION | NAME);
2159 @end example
2160
2161 If @code{Attribute} is a known attribute name, this pragma is equivalent to
2162 the attribute definition clause:
2163
2164 @example
2165 for Entity'Attribute use Expression;
2166 @end example
2167
2168 If @code{Attribute} is not a recognized attribute name, the pragma is
2169 ignored, and a warning is emitted. This allows source
2170 code to be written that takes advantage of some new attribute, while remaining
2171 compilable with earlier compilers.
2172
2173 @node Pragma C_Pass_By_Copy,Pragma Check,Pragma Attribute_Definition,Implementation Defined Pragmas
2174 @anchor{gnat_rm/implementation_defined_pragmas pragma-c-pass-by-copy}@anchor{36}
2175 @section Pragma C_Pass_By_Copy
2176
2177
2178 @geindex Passing by copy
2179
2180 Syntax:
2181
2182 @example
2183 pragma C_Pass_By_Copy
2184 ([Max_Size =>] static_integer_EXPRESSION);
2185 @end example
2186
2187 Normally the default mechanism for passing C convention records to C
2188 convention subprograms is to pass them by reference, as suggested by RM
2189 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
2190 this default, by requiring that record formal parameters be passed by
2191 copy if all of the following conditions are met:
2192
2193
2194 @itemize *
2195
2196 @item
2197 The size of the record type does not exceed the value specified for
2198 @code{Max_Size}.
2199
2200 @item
2201 The record type has @code{Convention C}.
2202
2203 @item
2204 The formal parameter has this record type, and the subprogram has a
2205 foreign (non-Ada) convention.
2206 @end itemize
2207
2208 If these conditions are met the argument is passed by copy; i.e., in a
2209 manner consistent with what C expects if the corresponding formal in the
2210 C prototype is a struct (rather than a pointer to a struct).
2211
2212 You can also pass records by copy by specifying the convention
2213 @code{C_Pass_By_Copy} for the record type, or by using the extended
2214 @code{Import} and @code{Export} pragmas, which allow specification of
2215 passing mechanisms on a parameter by parameter basis.
2216
2217 @node Pragma Check,Pragma Check_Float_Overflow,Pragma C_Pass_By_Copy,Implementation Defined Pragmas
2218 @anchor{gnat_rm/implementation_defined_pragmas pragma-check}@anchor{37}
2219 @section Pragma Check
2220
2221
2222 @geindex Assertions
2223
2224 @geindex Named assertions
2225
2226 Syntax:
2227
2228 @example
2229 pragma Check (
2230 [Name =>] CHECK_KIND,
2231 [Check =>] Boolean_EXPRESSION
2232 [, [Message =>] string_EXPRESSION] );
2233
2234 CHECK_KIND ::= IDENTIFIER |
2235 Pre'Class |
2236 Post'Class |
2237 Type_Invariant'Class |
2238 Invariant'Class
2239 @end example
2240
2241 This pragma is similar to the predefined pragma @code{Assert} except that an
2242 extra identifier argument is present. In conjunction with pragma
2243 @code{Check_Policy}, this can be used to define groups of assertions that can
2244 be independently controlled. The identifier @code{Assertion} is special, it
2245 refers to the normal set of pragma @code{Assert} statements.
2246
2247 Checks introduced by this pragma are normally deactivated by default. They can
2248 be activated either by the command line option @emph{-gnata}, which turns on
2249 all checks, or individually controlled using pragma @code{Check_Policy}.
2250
2251 The identifiers @code{Assertions} and @code{Statement_Assertions} are not
2252 permitted as check kinds, since this would cause confusion with the use
2253 of these identifiers in @code{Assertion_Policy} and @code{Check_Policy}
2254 pragmas, where they are used to refer to sets of assertions.
2255
2256 @node Pragma Check_Float_Overflow,Pragma Check_Name,Pragma Check,Implementation Defined Pragmas
2257 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-float-overflow}@anchor{38}
2258 @section Pragma Check_Float_Overflow
2259
2260
2261 @geindex Floating-point overflow
2262
2263 Syntax:
2264
2265 @example
2266 pragma Check_Float_Overflow;
2267 @end example
2268
2269 In Ada, the predefined floating-point types (@code{Short_Float},
2270 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
2271 defined to be @emph{unconstrained}. This means that even though each
2272 has a well-defined base range, an operation that delivers a result
2273 outside this base range is not required to raise an exception.
2274 This implementation permission accommodates the notion
2275 of infinities in IEEE floating-point, and corresponds to the
2276 efficient execution mode on most machines. GNAT will not raise
2277 overflow exceptions on these machines; instead it will generate
2278 infinities and NaN's as defined in the IEEE standard.
2279
2280 Generating infinities, although efficient, is not always desirable.
2281 Often the preferable approach is to check for overflow, even at the
2282 (perhaps considerable) expense of run-time performance.
2283 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
2284 range constraints -- and indeed such a subtype
2285 can have the same base range as its base type. For example:
2286
2287 @example
2288 subtype My_Float is Float range Float'Range;
2289 @end example
2290
2291 Here @code{My_Float} has the same range as
2292 @code{Float} but is constrained, so operations on
2293 @code{My_Float} values will be checked for overflow
2294 against this range.
2295
2296 This style will achieve the desired goal, but
2297 it is often more convenient to be able to simply use
2298 the standard predefined floating-point types as long
2299 as overflow checking could be guaranteed.
2300 The @code{Check_Float_Overflow}
2301 configuration pragma achieves this effect. If a unit is compiled
2302 subject to this configuration pragma, then all operations
2303 on predefined floating-point types including operations on
2304 base types of these floating-point types will be treated as
2305 though those types were constrained, and overflow checks
2306 will be generated. The @code{Constraint_Error}
2307 exception is raised if the result is out of range.
2308
2309 This mode can also be set by use of the compiler
2310 switch @emph{-gnateF}.
2311
2312 @node Pragma Check_Name,Pragma Check_Policy,Pragma Check_Float_Overflow,Implementation Defined Pragmas
2313 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-name}@anchor{39}
2314 @section Pragma Check_Name
2315
2316
2317 @geindex Defining check names
2318
2319 @geindex Check names
2320 @geindex defining
2321
2322 Syntax:
2323
2324 @example
2325 pragma Check_Name (check_name_IDENTIFIER);
2326 @end example
2327
2328 This is a configuration pragma that defines a new implementation
2329 defined check name (unless IDENTIFIER matches one of the predefined
2330 check names, in which case the pragma has no effect). Check names
2331 are global to a partition, so if two or more configuration pragmas
2332 are present in a partition mentioning the same name, only one new
2333 check name is introduced.
2334
2335 An implementation defined check name introduced with this pragma may
2336 be used in only three contexts: @code{pragma Suppress},
2337 @code{pragma Unsuppress},
2338 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
2339 any of these three cases, the check name must be visible. A check
2340 name is visible if it is in the configuration pragmas applying to
2341 the current unit, or if it appears at the start of any unit that
2342 is part of the dependency set of the current unit (e.g., units that
2343 are mentioned in @code{with} clauses).
2344
2345 Check names introduced by this pragma are subject to control by compiler
2346 switches (in particular -gnatp) in the usual manner.
2347
2348 @node Pragma Check_Policy,Pragma Comment,Pragma Check_Name,Implementation Defined Pragmas
2349 @anchor{gnat_rm/implementation_defined_pragmas pragma-check-policy}@anchor{3a}
2350 @section Pragma Check_Policy
2351
2352
2353 @geindex Controlling assertions
2354
2355 @geindex Assertions
2356 @geindex control
2357
2358 @geindex Check pragma control
2359
2360 @geindex Named assertions
2361
2362 Syntax:
2363
2364 @example
2365 pragma Check_Policy
2366 ([Name =>] CHECK_KIND,
2367 [Policy =>] POLICY_IDENTIFIER);
2368
2369 pragma Check_Policy (
2370 CHECK_KIND => POLICY_IDENTIFIER
2371 @{, CHECK_KIND => POLICY_IDENTIFIER@});
2372
2373 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
2374
2375 CHECK_KIND ::= IDENTIFIER |
2376 Pre'Class |
2377 Post'Class |
2378 Type_Invariant'Class |
2379 Invariant'Class
2380
2381 The identifiers Name and Policy are not allowed as CHECK_KIND values. This
2382 avoids confusion between the two possible syntax forms for this pragma.
2383
2384 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
2385 @end example
2386
2387 This pragma is used to set the checking policy for assertions (specified
2388 by aspects or pragmas), the @code{Debug} pragma, or additional checks
2389 to be checked using the @code{Check} pragma. It may appear either as
2390 a configuration pragma, or within a declarative part of package. In the
2391 latter case, it applies from the point where it appears to the end of
2392 the declarative region (like pragma @code{Suppress}).
2393
2394 The @code{Check_Policy} pragma is similar to the
2395 predefined @code{Assertion_Policy} pragma,
2396 and if the check kind corresponds to one of the assertion kinds that
2397 are allowed by @code{Assertion_Policy}, then the effect is identical.
2398
2399 If the first argument is Debug, then the policy applies to Debug pragmas,
2400 disabling their effect if the policy is @code{OFF}, @code{DISABLE}, or
2401 @code{IGNORE}, and allowing them to execute with normal semantics if
2402 the policy is @code{ON} or @code{CHECK}. In addition if the policy is
2403 @code{DISABLE}, then the procedure call in @code{Debug} pragmas will
2404 be totally ignored and not analyzed semantically.
2405
2406 Finally the first argument may be some other identifier than the above
2407 possibilities, in which case it controls a set of named assertions
2408 that can be checked using pragma @code{Check}. For example, if the pragma:
2409
2410 @example
2411 pragma Check_Policy (Critical_Error, OFF);
2412 @end example
2413
2414 is given, then subsequent @code{Check} pragmas whose first argument is also
2415 @code{Critical_Error} will be disabled.
2416
2417 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
2418 to turn on corresponding checks. The default for a set of checks for which no
2419 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
2420 @emph{-gnata} is given, which turns on all checks by default.
2421
2422 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
2423 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
2424 compatibility with the standard @code{Assertion_Policy} pragma. The check
2425 policy setting @code{DISABLE} causes the second argument of a corresponding
2426 @code{Check} pragma to be completely ignored and not analyzed.
2427
2428 @node Pragma Comment,Pragma Common_Object,Pragma Check_Policy,Implementation Defined Pragmas
2429 @anchor{gnat_rm/implementation_defined_pragmas pragma-comment}@anchor{3b}
2430 @section Pragma Comment
2431
2432
2433 Syntax:
2434
2435 @example
2436 pragma Comment (static_string_EXPRESSION);
2437 @end example
2438
2439 This is almost identical in effect to pragma @code{Ident}. It allows the
2440 placement of a comment into the object file and hence into the
2441 executable file if the operating system permits such usage. The
2442 difference is that @code{Comment}, unlike @code{Ident}, has
2443 no limitations on placement of the pragma (it can be placed
2444 anywhere in the main source unit), and if more than one pragma
2445 is used, all comments are retained.
2446
2447 @node Pragma Common_Object,Pragma Compile_Time_Error,Pragma Comment,Implementation Defined Pragmas
2448 @anchor{gnat_rm/implementation_defined_pragmas pragma-common-object}@anchor{3c}
2449 @section Pragma Common_Object
2450
2451
2452 Syntax:
2453
2454 @example
2455 pragma Common_Object (
2456 [Internal =>] LOCAL_NAME
2457 [, [External =>] EXTERNAL_SYMBOL]
2458 [, [Size =>] EXTERNAL_SYMBOL] );
2459
2460 EXTERNAL_SYMBOL ::=
2461 IDENTIFIER
2462 | static_string_EXPRESSION
2463 @end example
2464
2465 This pragma enables the shared use of variables stored in overlaid
2466 linker areas corresponding to the use of @code{COMMON}
2467 in Fortran. The single
2468 object @code{LOCAL_NAME} is assigned to the area designated by
2469 the @code{External} argument.
2470 You may define a record to correspond to a series
2471 of fields. The @code{Size} argument
2472 is syntax checked in GNAT, but otherwise ignored.
2473
2474 @code{Common_Object} is not supported on all platforms. If no
2475 support is available, then the code generator will issue a message
2476 indicating that the necessary attribute for implementation of this
2477 pragma is not available.
2478
2479 @node Pragma Compile_Time_Error,Pragma Compile_Time_Warning,Pragma Common_Object,Implementation Defined Pragmas
2480 @anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-error}@anchor{3d}
2481 @section Pragma Compile_Time_Error
2482
2483
2484 Syntax:
2485
2486 @example
2487 pragma Compile_Time_Error
2488 (boolean_EXPRESSION, static_string_EXPRESSION);
2489 @end example
2490
2491 This pragma can be used to generate additional compile time
2492 error messages. It
2493 is particularly useful in generics, where errors can be issued for
2494 specific problematic instantiations. The first parameter is a boolean
2495 expression. The pragma ensures that the value of an expression
2496 is known at compile time, and has the value False. The set of expressions
2497 whose values are known at compile time includes all static boolean
2498 expressions, and also other values which the compiler can determine
2499 at compile time (e.g., the size of a record type set by an explicit
2500 size representation clause, or the value of a variable which was
2501 initialized to a constant and is known not to have been modified).
2502 If these conditions are not met, an error message is generated using
2503 the value given as the second argument. This string value may contain
2504 embedded ASCII.LF characters to break the message into multiple lines.
2505
2506 @node Pragma Compile_Time_Warning,Pragma Compiler_Unit,Pragma Compile_Time_Error,Implementation Defined Pragmas
2507 @anchor{gnat_rm/implementation_defined_pragmas pragma-compile-time-warning}@anchor{3e}
2508 @section Pragma Compile_Time_Warning
2509
2510
2511 Syntax:
2512
2513 @example
2514 pragma Compile_Time_Warning
2515 (boolean_EXPRESSION, static_string_EXPRESSION);
2516 @end example
2517
2518 Same as pragma Compile_Time_Error, except a warning is issued instead
2519 of an error message. If switch @emph{-gnatw_C} is used, a warning is only issued
2520 if the value of the expression is known to be True at compile time, not when
2521 the value of the expression is not known at compile time.
2522 Note that if this pragma is used in a package that
2523 is with'ed by a client, the client will get the warning even though it
2524 is issued by a with'ed package (normally warnings in with'ed units are
2525 suppressed, but this is a special exception to that rule).
2526
2527 One typical use is within a generic where compile time known characteristics
2528 of formal parameters are tested, and warnings given appropriately. Another use
2529 with a first parameter of True is to warn a client about use of a package,
2530 for example that it is not fully implemented.
2531
2532 @node Pragma Compiler_Unit,Pragma Compiler_Unit_Warning,Pragma Compile_Time_Warning,Implementation Defined Pragmas
2533 @anchor{gnat_rm/implementation_defined_pragmas pragma-compiler-unit}@anchor{3f}
2534 @section Pragma Compiler_Unit
2535
2536
2537 Syntax:
2538
2539 @example
2540 pragma Compiler_Unit;
2541 @end example
2542
2543 This pragma is obsolete. It is equivalent to Compiler_Unit_Warning. It is
2544 retained so that old versions of the GNAT run-time that use this pragma can
2545 be compiled with newer versions of the compiler.
2546
2547 @node Pragma Compiler_Unit_Warning,Pragma Complete_Representation,Pragma Compiler_Unit,Implementation Defined Pragmas
2548 @anchor{gnat_rm/implementation_defined_pragmas pragma-compiler-unit-warning}@anchor{40}
2549 @section Pragma Compiler_Unit_Warning
2550
2551
2552 Syntax:
2553
2554 @example
2555 pragma Compiler_Unit_Warning;
2556 @end example
2557
2558 This pragma is intended only for internal use in the GNAT run-time library.
2559 It indicates that the unit is used as part of the compiler build. The effect
2560 is to generate warnings for the use of constructs (for example, conditional
2561 expressions) that would cause trouble when bootstrapping using an older
2562 version of GNAT. For the exact list of restrictions, see the compiler sources
2563 and references to Check_Compiler_Unit.
2564
2565 @node Pragma Complete_Representation,Pragma Complex_Representation,Pragma Compiler_Unit_Warning,Implementation Defined Pragmas
2566 @anchor{gnat_rm/implementation_defined_pragmas pragma-complete-representation}@anchor{41}
2567 @section Pragma Complete_Representation
2568
2569
2570 Syntax:
2571
2572 @example
2573 pragma Complete_Representation;
2574 @end example
2575
2576 This pragma must appear immediately within a record representation
2577 clause. Typical placements are before the first component clause
2578 or after the last component clause. The effect is to give an error
2579 message if any component is missing a component clause. This pragma
2580 may be used to ensure that a record representation clause is
2581 complete, and that this invariant is maintained if fields are
2582 added to the record in the future.
2583
2584 @node Pragma Complex_Representation,Pragma Component_Alignment,Pragma Complete_Representation,Implementation Defined Pragmas
2585 @anchor{gnat_rm/implementation_defined_pragmas pragma-complex-representation}@anchor{42}
2586 @section Pragma Complex_Representation
2587
2588
2589 Syntax:
2590
2591 @example
2592 pragma Complex_Representation
2593 ([Entity =>] LOCAL_NAME);
2594 @end example
2595
2596 The @code{Entity} argument must be the name of a record type which has
2597 two fields of the same floating-point type. The effect of this pragma is
2598 to force gcc to use the special internal complex representation form for
2599 this record, which may be more efficient. Note that this may result in
2600 the code for this type not conforming to standard ABI (application
2601 binary interface) requirements for the handling of record types. For
2602 example, in some environments, there is a requirement for passing
2603 records by pointer, and the use of this pragma may result in passing
2604 this type in floating-point registers.
2605
2606 @node Pragma Component_Alignment,Pragma Constant_After_Elaboration,Pragma Complex_Representation,Implementation Defined Pragmas
2607 @anchor{gnat_rm/implementation_defined_pragmas pragma-component-alignment}@anchor{43}
2608 @section Pragma Component_Alignment
2609
2610
2611 @geindex Alignments of components
2612
2613 @geindex Pragma Component_Alignment
2614
2615 Syntax:
2616
2617 @example
2618 pragma Component_Alignment (
2619 [Form =>] ALIGNMENT_CHOICE
2620 [, [Name =>] type_LOCAL_NAME]);
2621
2622 ALIGNMENT_CHOICE ::=
2623 Component_Size
2624 | Component_Size_4
2625 | Storage_Unit
2626 | Default
2627 @end example
2628
2629 Specifies the alignment of components in array or record types.
2630 The meaning of the @code{Form} argument is as follows:
2631
2632 @quotation
2633
2634 @geindex Component_Size (in pragma Component_Alignment)
2635 @end quotation
2636
2637
2638 @table @asis
2639
2640 @item @emph{Component_Size}
2641
2642 Aligns scalar components and subcomponents of the array or record type
2643 on boundaries appropriate to their inherent size (naturally
2644 aligned). For example, 1-byte components are aligned on byte boundaries,
2645 2-byte integer components are aligned on 2-byte boundaries, 4-byte
2646 integer components are aligned on 4-byte boundaries and so on. These
2647 alignment rules correspond to the normal rules for C compilers on all
2648 machines except the VAX.
2649
2650 @geindex Component_Size_4 (in pragma Component_Alignment)
2651
2652 @item @emph{Component_Size_4}
2653
2654 Naturally aligns components with a size of four or fewer
2655 bytes. Components that are larger than 4 bytes are placed on the next
2656 4-byte boundary.
2657
2658 @geindex Storage_Unit (in pragma Component_Alignment)
2659
2660 @item @emph{Storage_Unit}
2661
2662 Specifies that array or record components are byte aligned, i.e.,
2663 aligned on boundaries determined by the value of the constant
2664 @code{System.Storage_Unit}.
2665
2666 @geindex Default (in pragma Component_Alignment)
2667
2668 @item @emph{Default}
2669
2670 Specifies that array or record components are aligned on default
2671 boundaries, appropriate to the underlying hardware or operating system or
2672 both. The @code{Default} choice is the same as @code{Component_Size} (natural
2673 alignment).
2674 @end table
2675
2676 If the @code{Name} parameter is present, @code{type_LOCAL_NAME} must
2677 refer to a local record or array type, and the specified alignment
2678 choice applies to the specified type. The use of
2679 @code{Component_Alignment} together with a pragma @code{Pack} causes the
2680 @code{Component_Alignment} pragma to be ignored. The use of
2681 @code{Component_Alignment} together with a record representation clause
2682 is only effective for fields not specified by the representation clause.
2683
2684 If the @code{Name} parameter is absent, the pragma can be used as either
2685 a configuration pragma, in which case it applies to one or more units in
2686 accordance with the normal rules for configuration pragmas, or it can be
2687 used within a declarative part, in which case it applies to types that
2688 are declared within this declarative part, or within any nested scope
2689 within this declarative part. In either case it specifies the alignment
2690 to be applied to any record or array type which has otherwise standard
2691 representation.
2692
2693 If the alignment for a record or array type is not specified (using
2694 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
2695 clause), the GNAT uses the default alignment as described previously.
2696
2697 @node Pragma Constant_After_Elaboration,Pragma Contract_Cases,Pragma Component_Alignment,Implementation Defined Pragmas
2698 @anchor{gnat_rm/implementation_defined_pragmas id6}@anchor{44}@anchor{gnat_rm/implementation_defined_pragmas pragma-constant-after-elaboration}@anchor{45}
2699 @section Pragma Constant_After_Elaboration
2700
2701
2702 Syntax:
2703
2704 @example
2705 pragma Constant_After_Elaboration [ (boolean_EXPRESSION) ];
2706 @end example
2707
2708 For the semantics of this pragma, see the entry for aspect
2709 @code{Constant_After_Elaboration} in the SPARK 2014 Reference Manual, section 3.3.1.
2710
2711 @node Pragma Contract_Cases,Pragma Convention_Identifier,Pragma Constant_After_Elaboration,Implementation Defined Pragmas
2712 @anchor{gnat_rm/implementation_defined_pragmas id7}@anchor{46}@anchor{gnat_rm/implementation_defined_pragmas pragma-contract-cases}@anchor{47}
2713 @section Pragma Contract_Cases
2714
2715
2716 @geindex Contract cases
2717
2718 Syntax:
2719
2720 @example
2721 pragma Contract_Cases ((CONTRACT_CASE @{, CONTRACT_CASE));
2722
2723 CONTRACT_CASE ::= CASE_GUARD => CONSEQUENCE
2724
2725 CASE_GUARD ::= boolean_EXPRESSION | others
2726
2727 CONSEQUENCE ::= boolean_EXPRESSION
2728 @end example
2729
2730 The @code{Contract_Cases} pragma allows defining fine-grain specifications
2731 that can complement or replace the contract given by a precondition and a
2732 postcondition. Additionally, the @code{Contract_Cases} pragma can be used
2733 by testing and formal verification tools. The compiler checks its validity and,
2734 depending on the assertion policy at the point of declaration of the pragma,
2735 it may insert a check in the executable. For code generation, the contract
2736 cases
2737
2738 @example
2739 pragma Contract_Cases (
2740 Cond1 => Pred1,
2741 Cond2 => Pred2);
2742 @end example
2743
2744 are equivalent to
2745
2746 @example
2747 C1 : constant Boolean := Cond1; -- evaluated at subprogram entry
2748 C2 : constant Boolean := Cond2; -- evaluated at subprogram entry
2749 pragma Precondition ((C1 and not C2) or (C2 and not C1));
2750 pragma Postcondition (if C1 then Pred1);
2751 pragma Postcondition (if C2 then Pred2);
2752 @end example
2753
2754 The precondition ensures that one and only one of the case guards is
2755 satisfied on entry to the subprogram.
2756 The postcondition ensures that for the case guard that was True on entry,
2757 the corresponding consequence is True on exit. Other consequence expressions
2758 are not evaluated.
2759
2760 A precondition @code{P} and postcondition @code{Q} can also be
2761 expressed as contract cases:
2762
2763 @example
2764 pragma Contract_Cases (P => Q);
2765 @end example
2766
2767 The placement and visibility rules for @code{Contract_Cases} pragmas are
2768 identical to those described for preconditions and postconditions.
2769
2770 The compiler checks that boolean expressions given in case guards and
2771 consequences are valid, where the rules for case guards are the same as
2772 the rule for an expression in @code{Precondition} and the rules for
2773 consequences are the same as the rule for an expression in
2774 @code{Postcondition}. In particular, attributes @code{'Old} and
2775 @code{'Result} can only be used within consequence expressions.
2776 The case guard for the last contract case may be @code{others}, to denote
2777 any case not captured by the previous cases. The
2778 following is an example of use within a package spec:
2779
2780 @example
2781 package Math_Functions is
2782 ...
2783 function Sqrt (Arg : Float) return Float;
2784 pragma Contract_Cases (((Arg in 0.0 .. 99.0) => Sqrt'Result < 10.0,
2785 Arg >= 100.0 => Sqrt'Result >= 10.0,
2786 others => Sqrt'Result = 0.0));
2787 ...
2788 end Math_Functions;
2789 @end example
2790
2791 The meaning of contract cases is that only one case should apply at each
2792 call, as determined by the corresponding case guard evaluating to True,
2793 and that the consequence for this case should hold when the subprogram
2794 returns.
2795
2796 @node Pragma Convention_Identifier,Pragma CPP_Class,Pragma Contract_Cases,Implementation Defined Pragmas
2797 @anchor{gnat_rm/implementation_defined_pragmas pragma-convention-identifier}@anchor{48}
2798 @section Pragma Convention_Identifier
2799
2800
2801 @geindex Conventions
2802 @geindex synonyms
2803
2804 Syntax:
2805
2806 @example
2807 pragma Convention_Identifier (
2808 [Name =>] IDENTIFIER,
2809 [Convention =>] convention_IDENTIFIER);
2810 @end example
2811
2812 This pragma provides a mechanism for supplying synonyms for existing
2813 convention identifiers. The @code{Name} identifier can subsequently
2814 be used as a synonym for the given convention in other pragmas (including
2815 for example pragma @code{Import} or another @code{Convention_Identifier}
2816 pragma). As an example of the use of this, suppose you had legacy code
2817 which used Fortran77 as the identifier for Fortran. Then the pragma:
2818
2819 @example
2820 pragma Convention_Identifier (Fortran77, Fortran);
2821 @end example
2822
2823 would allow the use of the convention identifier @code{Fortran77} in
2824 subsequent code, avoiding the need to modify the sources. As another
2825 example, you could use this to parameterize convention requirements
2826 according to systems. Suppose you needed to use @code{Stdcall} on
2827 windows systems, and @code{C} on some other system, then you could
2828 define a convention identifier @code{Library} and use a single
2829 @code{Convention_Identifier} pragma to specify which convention
2830 would be used system-wide.
2831
2832 @node Pragma CPP_Class,Pragma CPP_Constructor,Pragma Convention_Identifier,Implementation Defined Pragmas
2833 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-class}@anchor{49}
2834 @section Pragma CPP_Class
2835
2836
2837 @geindex Interfacing with C++
2838
2839 Syntax:
2840
2841 @example
2842 pragma CPP_Class ([Entity =>] LOCAL_NAME);
2843 @end example
2844
2845 The argument denotes an entity in the current declarative region that is
2846 declared as a record type. It indicates that the type corresponds to an
2847 externally declared C++ class type, and is to be laid out the same way
2848 that C++ would lay out the type. If the C++ class has virtual primitives
2849 then the record must be declared as a tagged record type.
2850
2851 Types for which @code{CPP_Class} is specified do not have assignment or
2852 equality operators defined (such operations can be imported or declared
2853 as subprograms as required). Initialization is allowed only by constructor
2854 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2855 limited if not explicitly declared as limited or derived from a limited
2856 type, and an error is issued in that case.
2857
2858 See @ref{4a,,Interfacing to C++} for related information.
2859
2860 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2861 for backward compatibility but its functionality is available
2862 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2863
2864 @node Pragma CPP_Constructor,Pragma CPP_Virtual,Pragma CPP_Class,Implementation Defined Pragmas
2865 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-constructor}@anchor{4b}
2866 @section Pragma CPP_Constructor
2867
2868
2869 @geindex Interfacing with C++
2870
2871 Syntax:
2872
2873 @example
2874 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2875 [, [External_Name =>] static_string_EXPRESSION ]
2876 [, [Link_Name =>] static_string_EXPRESSION ]);
2877 @end example
2878
2879 This pragma identifies an imported function (imported in the usual way
2880 with pragma @code{Import}) as corresponding to a C++ constructor. If
2881 @code{External_Name} and @code{Link_Name} are not specified then the
2882 @code{Entity} argument is a name that must have been previously mentioned
2883 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2884 must be of one of the following forms:
2885
2886
2887 @itemize *
2888
2889 @item
2890 @strong{function} @code{Fname} @strong{return} T`
2891
2892 @item
2893 @strong{function} @code{Fname} @strong{return} T'Class
2894
2895 @item
2896 @strong{function} @code{Fname} (...) @strong{return} T`
2897
2898 @item
2899 @strong{function} @code{Fname} (...) @strong{return} T'Class
2900 @end itemize
2901
2902 where @code{T} is a limited record type imported from C++ with pragma
2903 @code{Import} and @code{Convention} = @code{CPP}.
2904
2905 The first two forms import the default constructor, used when an object
2906 of type @code{T} is created on the Ada side with no explicit constructor.
2907 The latter two forms cover all the non-default constructors of the type.
2908 See the GNAT User's Guide for details.
2909
2910 If no constructors are imported, it is impossible to create any objects
2911 on the Ada side and the type is implicitly declared abstract.
2912
2913 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2914 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2915 GCC switch).
2916 See @ref{4a,,Interfacing to C++} for more related information.
2917
2918 Note: The use of functions returning class-wide types for constructors is
2919 currently obsolete. They are supported for backward compatibility. The
2920 use of functions returning the type T leave the Ada sources more clear
2921 because the imported C++ constructors always return an object of type T;
2922 that is, they never return an object whose type is a descendant of type T.
2923
2924 @node Pragma CPP_Virtual,Pragma CPP_Vtable,Pragma CPP_Constructor,Implementation Defined Pragmas
2925 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-virtual}@anchor{4c}
2926 @section Pragma CPP_Virtual
2927
2928
2929 @geindex Interfacing to C++
2930
2931 This pragma is now obsolete and, other than generating a warning if warnings
2932 on obsolescent features are enabled, is completely ignored.
2933 It is retained for compatibility
2934 purposes. It used to be required to ensure compoatibility with C++, but
2935 is no longer required for that purpose because GNAT generates
2936 the same object layout as the G++ compiler by default.
2937
2938 See @ref{4a,,Interfacing to C++} for related information.
2939
2940 @node Pragma CPP_Vtable,Pragma CPU,Pragma CPP_Virtual,Implementation Defined Pragmas
2941 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpp-vtable}@anchor{4d}
2942 @section Pragma CPP_Vtable
2943
2944
2945 @geindex Interfacing with C++
2946
2947 This pragma is now obsolete and, other than generating a warning if warnings
2948 on obsolescent features are enabled, is completely ignored.
2949 It used to be required to ensure compatibility with C++, but
2950 is no longer required for that purpose because GNAT generates
2951 the same object layout as the G++ compiler by default.
2952
2953 See @ref{4a,,Interfacing to C++} for related information.
2954
2955 @node Pragma CPU,Pragma Deadline_Floor,Pragma CPP_Vtable,Implementation Defined Pragmas
2956 @anchor{gnat_rm/implementation_defined_pragmas pragma-cpu}@anchor{4e}
2957 @section Pragma CPU
2958
2959
2960 Syntax:
2961
2962 @example
2963 pragma CPU (EXPRESSION);
2964 @end example
2965
2966 This pragma is standard in Ada 2012, but is available in all earlier
2967 versions of Ada as an implementation-defined pragma.
2968 See Ada 2012 Reference Manual for details.
2969
2970 @node Pragma Deadline_Floor,Pragma Default_Initial_Condition,Pragma CPU,Implementation Defined Pragmas
2971 @anchor{gnat_rm/implementation_defined_pragmas pragma-deadline-floor}@anchor{4f}
2972 @section Pragma Deadline_Floor
2973
2974
2975 Syntax:
2976
2977 @example
2978 pragma Deadline_Floor (time_span_EXPRESSION);
2979 @end example
2980
2981 This pragma applies only to protected types and specifies the floor
2982 deadline inherited by a task when the task enters a protected object.
2983 It is effective only when the EDF scheduling policy is used.
2984
2985 @node Pragma Default_Initial_Condition,Pragma Debug,Pragma Deadline_Floor,Implementation Defined Pragmas
2986 @anchor{gnat_rm/implementation_defined_pragmas id8}@anchor{50}@anchor{gnat_rm/implementation_defined_pragmas pragma-default-initial-condition}@anchor{51}
2987 @section Pragma Default_Initial_Condition
2988
2989
2990 Syntax:
2991
2992 @example
2993 pragma Default_Initial_Condition [ (null | boolean_EXPRESSION) ];
2994 @end example
2995
2996 For the semantics of this pragma, see the entry for aspect
2997 @code{Default_Initial_Condition} in the SPARK 2014 Reference Manual, section 7.3.3.
2998
2999 @node Pragma Debug,Pragma Debug_Policy,Pragma Default_Initial_Condition,Implementation Defined Pragmas
3000 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug}@anchor{52}
3001 @section Pragma Debug
3002
3003
3004 Syntax:
3005
3006 @example
3007 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
3008
3009 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
3010 PROCEDURE_NAME
3011 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
3012 @end example
3013
3014 The procedure call argument has the syntactic form of an expression, meeting
3015 the syntactic requirements for pragmas.
3016
3017 If debug pragmas are not enabled or if the condition is present and evaluates
3018 to False, this pragma has no effect. If debug pragmas are enabled, the
3019 semantics of the pragma is exactly equivalent to the procedure call statement
3020 corresponding to the argument with a terminating semicolon. Pragmas are
3021 permitted in sequences of declarations, so you can use pragma @code{Debug} to
3022 intersperse calls to debug procedures in the middle of declarations. Debug
3023 pragmas can be enabled either by use of the command line switch @emph{-gnata}
3024 or by use of the pragma @code{Check_Policy} with a first argument of
3025 @code{Debug}.
3026
3027 @node Pragma Debug_Policy,Pragma Default_Scalar_Storage_Order,Pragma Debug,Implementation Defined Pragmas
3028 @anchor{gnat_rm/implementation_defined_pragmas pragma-debug-policy}@anchor{53}
3029 @section Pragma Debug_Policy
3030
3031
3032 Syntax:
3033
3034 @example
3035 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
3036 @end example
3037
3038 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
3039 with a first argument of @code{Debug}. It is retained for historical
3040 compatibility reasons.
3041
3042 @node Pragma Default_Scalar_Storage_Order,Pragma Default_Storage_Pool,Pragma Debug_Policy,Implementation Defined Pragmas
3043 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-scalar-storage-order}@anchor{54}
3044 @section Pragma Default_Scalar_Storage_Order
3045
3046
3047 @geindex Default_Scalar_Storage_Order
3048
3049 @geindex Scalar_Storage_Order
3050
3051 Syntax:
3052
3053 @example
3054 pragma Default_Scalar_Storage_Order (High_Order_First | Low_Order_First);
3055 @end example
3056
3057 Normally if no explicit @code{Scalar_Storage_Order} is given for a record
3058 type or array type, then the scalar storage order defaults to the ordinary
3059 default for the target. But this default may be overridden using this pragma.
3060 The pragma may appear as a configuration pragma, or locally within a package
3061 spec or declarative part. In the latter case, it applies to all subsequent
3062 types declared within that package spec or declarative part.
3063
3064 The following example shows the use of this pragma:
3065
3066 @example
3067 pragma Default_Scalar_Storage_Order (High_Order_First);
3068 with System; use System;
3069 package DSSO1 is
3070 type H1 is record
3071 a : Integer;
3072 end record;
3073
3074 type L2 is record
3075 a : Integer;
3076 end record;
3077 for L2'Scalar_Storage_Order use Low_Order_First;
3078
3079 type L2a is new L2;
3080
3081 package Inner is
3082 type H3 is record
3083 a : Integer;
3084 end record;
3085
3086 pragma Default_Scalar_Storage_Order (Low_Order_First);
3087
3088 type L4 is record
3089 a : Integer;
3090 end record;
3091 end Inner;
3092
3093 type H4a is new Inner.L4;
3094
3095 type H5 is record
3096 a : Integer;
3097 end record;
3098 end DSSO1;
3099 @end example
3100
3101 In this example record types with names starting with @emph{L} have @cite{Low_Order_First} scalar
3102 storage order, and record types with names starting with @emph{H} have @code{High_Order_First}.
3103 Note that in the case of @code{H4a}, the order is not inherited
3104 from the parent type. Only an explicitly set @code{Scalar_Storage_Order}
3105 gets inherited on type derivation.
3106
3107 If this pragma is used as a configuration pragma which appears within a
3108 configuration pragma file (as opposed to appearing explicitly at the start
3109 of a single unit), then the binder will require that all units in a partition
3110 be compiled in a similar manner, other than run-time units, which are not
3111 affected by this pragma. Note that the use of this form is discouraged because
3112 it may significantly degrade the run-time performance of the software, instead
3113 the default scalar storage order ought to be changed only on a local basis.
3114
3115 @node Pragma Default_Storage_Pool,Pragma Depends,Pragma Default_Scalar_Storage_Order,Implementation Defined Pragmas
3116 @anchor{gnat_rm/implementation_defined_pragmas pragma-default-storage-pool}@anchor{55}
3117 @section Pragma Default_Storage_Pool
3118
3119
3120 @geindex Default_Storage_Pool
3121
3122 Syntax:
3123
3124 @example
3125 pragma Default_Storage_Pool (storage_pool_NAME | null);
3126 @end example
3127
3128 This pragma is standard in Ada 2012, but is available in all earlier
3129 versions of Ada as an implementation-defined pragma.
3130 See Ada 2012 Reference Manual for details.
3131
3132 @node Pragma Depends,Pragma Detect_Blocking,Pragma Default_Storage_Pool,Implementation Defined Pragmas
3133 @anchor{gnat_rm/implementation_defined_pragmas pragma-depends}@anchor{56}@anchor{gnat_rm/implementation_defined_pragmas id9}@anchor{57}
3134 @section Pragma Depends
3135
3136
3137 Syntax:
3138
3139 @example
3140 pragma Depends (DEPENDENCY_RELATION);
3141
3142 DEPENDENCY_RELATION ::=
3143 null
3144 | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
3145
3146 DEPENDENCY_CLAUSE ::=
3147 OUTPUT_LIST =>[+] INPUT_LIST
3148 | NULL_DEPENDENCY_CLAUSE
3149
3150 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
3151
3152 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
3153
3154 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
3155
3156 OUTPUT ::= NAME | FUNCTION_RESULT
3157 INPUT ::= NAME
3158
3159 where FUNCTION_RESULT is a function Result attribute_reference
3160 @end example
3161
3162 For the semantics of this pragma, see the entry for aspect @code{Depends} in the
3163 SPARK 2014 Reference Manual, section 6.1.5.
3164
3165 @node Pragma Detect_Blocking,Pragma Disable_Atomic_Synchronization,Pragma Depends,Implementation Defined Pragmas
3166 @anchor{gnat_rm/implementation_defined_pragmas pragma-detect-blocking}@anchor{58}
3167 @section Pragma Detect_Blocking
3168
3169
3170 Syntax:
3171
3172 @example
3173 pragma Detect_Blocking;
3174 @end example
3175
3176 This is a standard pragma in Ada 2005, that is available in all earlier
3177 versions of Ada as an implementation-defined pragma.
3178
3179 This is a configuration pragma that forces the detection of potentially
3180 blocking operations within a protected operation, and to raise Program_Error
3181 if that happens.
3182
3183 @node Pragma Disable_Atomic_Synchronization,Pragma Dispatching_Domain,Pragma Detect_Blocking,Implementation Defined Pragmas
3184 @anchor{gnat_rm/implementation_defined_pragmas pragma-disable-atomic-synchronization}@anchor{59}
3185 @section Pragma Disable_Atomic_Synchronization
3186
3187
3188 @geindex Atomic Synchronization
3189
3190 Syntax:
3191
3192 @example
3193 pragma Disable_Atomic_Synchronization [(Entity)];
3194 @end example
3195
3196 Ada requires that accesses (reads or writes) of an atomic variable be
3197 regarded as synchronization points in the case of multiple tasks.
3198 Particularly in the case of multi-processors this may require special
3199 handling, e.g. the generation of memory barriers. This capability may
3200 be turned off using this pragma in cases where it is known not to be
3201 required.
3202
3203 The placement and scope rules for this pragma are the same as those
3204 for @code{pragma Suppress}. In particular it can be used as a
3205 configuration pragma, or in a declaration sequence where it applies
3206 till the end of the scope. If an @code{Entity} argument is present,
3207 the action applies only to that entity.
3208
3209 @node Pragma Dispatching_Domain,Pragma Effective_Reads,Pragma Disable_Atomic_Synchronization,Implementation Defined Pragmas
3210 @anchor{gnat_rm/implementation_defined_pragmas pragma-dispatching-domain}@anchor{5a}
3211 @section Pragma Dispatching_Domain
3212
3213
3214 Syntax:
3215
3216 @example
3217 pragma Dispatching_Domain (EXPRESSION);
3218 @end example
3219
3220 This pragma is standard in Ada 2012, but is available in all earlier
3221 versions of Ada as an implementation-defined pragma.
3222 See Ada 2012 Reference Manual for details.
3223
3224 @node Pragma Effective_Reads,Pragma Effective_Writes,Pragma Dispatching_Domain,Implementation Defined Pragmas
3225 @anchor{gnat_rm/implementation_defined_pragmas id10}@anchor{5b}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-reads}@anchor{5c}
3226 @section Pragma Effective_Reads
3227
3228
3229 Syntax:
3230
3231 @example
3232 pragma Effective_Reads [ (boolean_EXPRESSION) ];
3233 @end example
3234
3235 For the semantics of this pragma, see the entry for aspect @code{Effective_Reads} in
3236 the SPARK 2014 Reference Manual, section 7.1.2.
3237
3238 @node Pragma Effective_Writes,Pragma Elaboration_Checks,Pragma Effective_Reads,Implementation Defined Pragmas
3239 @anchor{gnat_rm/implementation_defined_pragmas id11}@anchor{5d}@anchor{gnat_rm/implementation_defined_pragmas pragma-effective-writes}@anchor{5e}
3240 @section Pragma Effective_Writes
3241
3242
3243 Syntax:
3244
3245 @example
3246 pragma Effective_Writes [ (boolean_EXPRESSION) ];
3247 @end example
3248
3249 For the semantics of this pragma, see the entry for aspect @code{Effective_Writes}
3250 in the SPARK 2014 Reference Manual, section 7.1.2.
3251
3252 @node Pragma Elaboration_Checks,Pragma Eliminate,Pragma Effective_Writes,Implementation Defined Pragmas
3253 @anchor{gnat_rm/implementation_defined_pragmas pragma-elaboration-checks}@anchor{5f}
3254 @section Pragma Elaboration_Checks
3255
3256
3257 @geindex Elaboration control
3258
3259 Syntax:
3260
3261 @example
3262 pragma Elaboration_Checks (Dynamic | Static);
3263 @end example
3264
3265 This is a configuration pragma which specifies the elaboration model to be
3266 used during compilation. For more information on the elaboration models of
3267 GNAT, consult the chapter on elaboration order handling in the @emph{GNAT User's
3268 Guide}.
3269
3270 The pragma may appear in the following contexts:
3271
3272
3273 @itemize *
3274
3275 @item
3276 Configuration pragmas file
3277
3278 @item
3279 Prior to the context clauses of a compilation unit's initial declaration
3280 @end itemize
3281
3282 Any other placement of the pragma will result in a warning and the effects of
3283 the offending pragma will be ignored.
3284
3285 If the pragma argument is @code{Dynamic}, then the dynamic elaboration model is in
3286 effect. If the pragma argument is @code{Static}, then the static elaboration model
3287 is in effect.
3288
3289 @node Pragma Eliminate,Pragma Enable_Atomic_Synchronization,Pragma Elaboration_Checks,Implementation Defined Pragmas
3290 @anchor{gnat_rm/implementation_defined_pragmas pragma-eliminate}@anchor{60}
3291 @section Pragma Eliminate
3292
3293
3294 @geindex Elimination of unused subprograms
3295
3296 Syntax:
3297
3298 @example
3299 pragma Eliminate (
3300 [ Unit_Name => ] IDENTIFIER | SELECTED_COMPONENT ,
3301 [ Entity => ] IDENTIFIER |
3302 SELECTED_COMPONENT |
3303 STRING_LITERAL
3304 [, Source_Location => SOURCE_TRACE ] );
3305
3306 SOURCE_TRACE ::= STRING_LITERAL
3307 @end example
3308
3309 This pragma indicates that the given entity is not used in the program to be
3310 compiled and built, thus allowing the compiler to
3311 eliminate the code or data associated with the named entity. Any reference to
3312 an eliminated entity causes a compile-time or link-time error.
3313
3314 The pragma has the following semantics, where @code{U} is the unit specified by
3315 the @code{Unit_Name} argument and @code{E} is the entity specified by the @code{Entity}
3316 argument:
3317
3318
3319 @itemize *
3320
3321 @item
3322 @code{E} must be a subprogram that is explicitly declared either:
3323
3324 o Within @code{U}, or
3325
3326 o Within a generic package that is instantiated in @code{U}, or
3327
3328 o As an instance of generic subprogram instantiated in @code{U}.
3329
3330 Otherwise the pragma is ignored.
3331
3332 @item
3333 If @code{E} is overloaded within @code{U} then, in the absence of a
3334 @code{Source_Location} argument, all overloadings are eliminated.
3335
3336 @item
3337 If @code{E} is overloaded within @code{U} and only some overloadings
3338 are to be eliminated, then each overloading to be eliminated
3339 must be specified in a corresponding pragma @code{Eliminate}
3340 with a @code{Source_Location} argument identifying the line where the
3341 declaration appears, as described below.
3342
3343 @item
3344 If @code{E} is declared as the result of a generic instantiation, then
3345 a @code{Source_Location} argument is needed, as described below
3346 @end itemize
3347
3348 Pragma @code{Eliminate} allows a program to be compiled in a system-independent
3349 manner, so that unused entities are eliminated but without
3350 needing to modify the source text. Normally the required set of
3351 @code{Eliminate} pragmas is constructed automatically using the @code{gnatelim} tool.
3352
3353 Any source file change that removes, splits, or
3354 adds lines may make the set of @code{Eliminate} pragmas invalid because their
3355 @code{Source_Location} argument values may get out of date.
3356
3357 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
3358 operation. In this case all the subprograms to which the given operation can
3359 dispatch are considered to be unused (are never called as a result of a direct
3360 or a dispatching call).
3361
3362 The string literal given for the source location specifies the line number
3363 of the declaration of the entity, using the following syntax for @code{SOURCE_TRACE}:
3364
3365 @example
3366 SOURCE_TRACE ::= SOURCE_REFERENCE [ LBRACKET SOURCE_TRACE RBRACKET ]
3367
3368 LBRACKET ::= '['
3369 RBRACKET ::= ']'
3370
3371 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
3372
3373 LINE_NUMBER ::= DIGIT @{DIGIT@}
3374 @end example
3375
3376 Spaces around the colon in a @code{SOURCE_REFERENCE} are optional.
3377
3378 The source trace that is given as the @code{Source_Location} must obey the
3379 following rules (or else the pragma is ignored), where @code{U} is
3380 the unit @code{U} specified by the @code{Unit_Name} argument and @code{E} is the
3381 subprogram specified by the @code{Entity} argument:
3382
3383
3384 @itemize *
3385
3386 @item
3387 @code{FILE_NAME} is the short name (with no directory
3388 information) of the Ada source file for @code{U}, using the required syntax
3389 for the underlying file system (e.g. case is significant if the underlying
3390 operating system is case sensitive).
3391 If @code{U} is a package and @code{E} is a subprogram declared in the package
3392 specification and its full declaration appears in the package body,
3393 then the relevant source file is the one for the package specification;
3394 analogously if @code{U} is a generic package.
3395
3396 @item
3397 If @code{E} is not declared in a generic instantiation (this includes
3398 generic subprogram instances), the source trace includes only one source
3399 line reference. @code{LINE_NUMBER} gives the line number of the occurrence
3400 of the declaration of @code{E} within the source file (as a decimal literal
3401 without an exponent or point).
3402
3403 @item
3404 If @code{E} is declared by a generic instantiation, its source trace
3405 (from left to right) starts with the source location of the
3406 declaration of @code{E} in the generic unit and ends with the source
3407 location of the instantiation, given in square brackets. This approach is
3408 applied recursively with nested instantiations: the rightmost (nested
3409 most deeply in square brackets) element of the source trace is the location
3410 of the outermost instantiation, and the leftmost element (that is, outside
3411 of any square brackets) is the location of the declaration of @code{E} in
3412 the generic unit.
3413 @end itemize
3414
3415 Examples:
3416
3417 @quotation
3418
3419 @example
3420 pragma Eliminate (Pkg0, Proc);
3421 -- Eliminate (all overloadings of) Proc in Pkg0
3422
3423 pragma Eliminate (Pkg1, Proc,
3424 Source_Location => "pkg1.ads:8");
3425 -- Eliminate overloading of Proc at line 8 in pkg1.ads
3426
3427 -- Assume the following file contents:
3428 -- gen_pkg.ads
3429 -- 1: generic
3430 -- 2: type T is private;
3431 -- 3: package Gen_Pkg is
3432 -- 4: procedure Proc(N : T);
3433 -- ... ...
3434 -- ... end Gen_Pkg;
3435 --
3436 -- q.adb
3437 -- 1: with Gen_Pkg;
3438 -- 2: procedure Q is
3439 -- 3: package Inst_Pkg is new Gen_Pkg(Integer);
3440 -- ... -- No calls on Inst_Pkg.Proc
3441 -- ... end Q;
3442
3443 -- The following pragma eliminates Inst_Pkg.Proc from Q
3444 pragma Eliminate (Q, Proc,
3445 Source_Location => "gen_pkg.ads:4[q.adb:3]");
3446 @end example
3447 @end quotation
3448
3449 @node Pragma Enable_Atomic_Synchronization,Pragma Export_Function,Pragma Eliminate,Implementation Defined Pragmas
3450 @anchor{gnat_rm/implementation_defined_pragmas pragma-enable-atomic-synchronization}@anchor{61}
3451 @section Pragma Enable_Atomic_Synchronization
3452
3453
3454 @geindex Atomic Synchronization
3455
3456 Syntax:
3457
3458 @example
3459 pragma Enable_Atomic_Synchronization [(Entity)];
3460 @end example
3461
3462 Ada requires that accesses (reads or writes) of an atomic variable be
3463 regarded as synchronization points in the case of multiple tasks.
3464 Particularly in the case of multi-processors this may require special
3465 handling, e.g. the generation of memory barriers. This synchronization
3466 is performed by default, but can be turned off using
3467 @code{pragma Disable_Atomic_Synchronization}. The
3468 @code{Enable_Atomic_Synchronization} pragma can be used to turn
3469 it back on.
3470
3471 The placement and scope rules for this pragma are the same as those
3472 for @code{pragma Unsuppress}. In particular it can be used as a
3473 configuration pragma, or in a declaration sequence where it applies
3474 till the end of the scope. If an @code{Entity} argument is present,
3475 the action applies only to that entity.
3476
3477 @node Pragma Export_Function,Pragma Export_Object,Pragma Enable_Atomic_Synchronization,Implementation Defined Pragmas
3478 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-function}@anchor{62}
3479 @section Pragma Export_Function
3480
3481
3482 @geindex Argument passing mechanisms
3483
3484 Syntax:
3485
3486 @example
3487 pragma Export_Function (
3488 [Internal =>] LOCAL_NAME
3489 [, [External =>] EXTERNAL_SYMBOL]
3490 [, [Parameter_Types =>] PARAMETER_TYPES]
3491 [, [Result_Type =>] result_SUBTYPE_MARK]
3492 [, [Mechanism =>] MECHANISM]
3493 [, [Result_Mechanism =>] MECHANISM_NAME]);
3494
3495 EXTERNAL_SYMBOL ::=
3496 IDENTIFIER
3497 | static_string_EXPRESSION
3498 | ""
3499
3500 PARAMETER_TYPES ::=
3501 null
3502 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3503
3504 TYPE_DESIGNATOR ::=
3505 subtype_NAME
3506 | subtype_Name ' Access
3507
3508 MECHANISM ::=
3509 MECHANISM_NAME
3510 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3511
3512 MECHANISM_ASSOCIATION ::=
3513 [formal_parameter_NAME =>] MECHANISM_NAME
3514
3515 MECHANISM_NAME ::= Value | Reference
3516 @end example
3517
3518 Use this pragma to make a function externally callable and optionally
3519 provide information on mechanisms to be used for passing parameter and
3520 result values. We recommend, for the purposes of improving portability,
3521 this pragma always be used in conjunction with a separate pragma
3522 @code{Export}, which must precede the pragma @code{Export_Function}.
3523 GNAT does not require a separate pragma @code{Export}, but if none is
3524 present, @code{Convention Ada} is assumed, which is usually
3525 not what is wanted, so it is usually appropriate to use this
3526 pragma in conjunction with a @code{Export} or @code{Convention}
3527 pragma that specifies the desired foreign convention.
3528 Pragma @code{Export_Function}
3529 (and @code{Export}, if present) must appear in the same declarative
3530 region as the function to which they apply.
3531
3532 The @code{internal_name} must uniquely designate the function to which the
3533 pragma applies. If more than one function name exists of this name in
3534 the declarative part you must use the @code{Parameter_Types} and
3535 @code{Result_Type} parameters to achieve the required
3536 unique designation. The @cite{subtype_mark}s in these parameters must
3537 exactly match the subtypes in the corresponding function specification,
3538 using positional notation to match parameters with subtype marks.
3539 The form with an @code{'Access} attribute can be used to match an
3540 anonymous access parameter.
3541
3542 @geindex Suppressing external name
3543
3544 Special treatment is given if the EXTERNAL is an explicit null
3545 string or a static string expressions that evaluates to the null
3546 string. In this case, no external name is generated. This form
3547 still allows the specification of parameter mechanisms.
3548
3549 @node Pragma Export_Object,Pragma Export_Procedure,Pragma Export_Function,Implementation Defined Pragmas
3550 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-object}@anchor{63}
3551 @section Pragma Export_Object
3552
3553
3554 Syntax:
3555
3556 @example
3557 pragma Export_Object
3558 [Internal =>] LOCAL_NAME
3559 [, [External =>] EXTERNAL_SYMBOL]
3560 [, [Size =>] EXTERNAL_SYMBOL]
3561
3562 EXTERNAL_SYMBOL ::=
3563 IDENTIFIER
3564 | static_string_EXPRESSION
3565 @end example
3566
3567 This pragma designates an object as exported, and apart from the
3568 extended rules for external symbols, is identical in effect to the use of
3569 the normal @code{Export} pragma applied to an object. You may use a
3570 separate Export pragma (and you probably should from the point of view
3571 of portability), but it is not required. @code{Size} is syntax checked,
3572 but otherwise ignored by GNAT.
3573
3574 @node Pragma Export_Procedure,Pragma Export_Value,Pragma Export_Object,Implementation Defined Pragmas
3575 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-procedure}@anchor{64}
3576 @section Pragma Export_Procedure
3577
3578
3579 Syntax:
3580
3581 @example
3582 pragma Export_Procedure (
3583 [Internal =>] LOCAL_NAME
3584 [, [External =>] EXTERNAL_SYMBOL]
3585 [, [Parameter_Types =>] PARAMETER_TYPES]
3586 [, [Mechanism =>] MECHANISM]);
3587
3588 EXTERNAL_SYMBOL ::=
3589 IDENTIFIER
3590 | static_string_EXPRESSION
3591 | ""
3592
3593 PARAMETER_TYPES ::=
3594 null
3595 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3596
3597 TYPE_DESIGNATOR ::=
3598 subtype_NAME
3599 | subtype_Name ' Access
3600
3601 MECHANISM ::=
3602 MECHANISM_NAME
3603 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3604
3605 MECHANISM_ASSOCIATION ::=
3606 [formal_parameter_NAME =>] MECHANISM_NAME
3607
3608 MECHANISM_NAME ::= Value | Reference
3609 @end example
3610
3611 This pragma is identical to @code{Export_Function} except that it
3612 applies to a procedure rather than a function and the parameters
3613 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3614 GNAT does not require a separate pragma @code{Export}, but if none is
3615 present, @code{Convention Ada} is assumed, which is usually
3616 not what is wanted, so it is usually appropriate to use this
3617 pragma in conjunction with a @code{Export} or @code{Convention}
3618 pragma that specifies the desired foreign convention.
3619
3620 @geindex Suppressing external name
3621
3622 Special treatment is given if the EXTERNAL is an explicit null
3623 string or a static string expressions that evaluates to the null
3624 string. In this case, no external name is generated. This form
3625 still allows the specification of parameter mechanisms.
3626
3627 @node Pragma Export_Value,Pragma Export_Valued_Procedure,Pragma Export_Procedure,Implementation Defined Pragmas
3628 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-value}@anchor{65}
3629 @section Pragma Export_Value
3630
3631
3632 Syntax:
3633
3634 @example
3635 pragma Export_Value (
3636 [Value =>] static_integer_EXPRESSION,
3637 [Link_Name =>] static_string_EXPRESSION);
3638 @end example
3639
3640 This pragma serves to export a static integer value for external use.
3641 The first argument specifies the value to be exported. The Link_Name
3642 argument specifies the symbolic name to be associated with the integer
3643 value. This pragma is useful for defining a named static value in Ada
3644 that can be referenced in assembly language units to be linked with
3645 the application. This pragma is currently supported only for the
3646 AAMP target and is ignored for other targets.
3647
3648 @node Pragma Export_Valued_Procedure,Pragma Extend_System,Pragma Export_Value,Implementation Defined Pragmas
3649 @anchor{gnat_rm/implementation_defined_pragmas pragma-export-valued-procedure}@anchor{66}
3650 @section Pragma Export_Valued_Procedure
3651
3652
3653 Syntax:
3654
3655 @example
3656 pragma Export_Valued_Procedure (
3657 [Internal =>] LOCAL_NAME
3658 [, [External =>] EXTERNAL_SYMBOL]
3659 [, [Parameter_Types =>] PARAMETER_TYPES]
3660 [, [Mechanism =>] MECHANISM]);
3661
3662 EXTERNAL_SYMBOL ::=
3663 IDENTIFIER
3664 | static_string_EXPRESSION
3665 | ""
3666
3667 PARAMETER_TYPES ::=
3668 null
3669 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3670
3671 TYPE_DESIGNATOR ::=
3672 subtype_NAME
3673 | subtype_Name ' Access
3674
3675 MECHANISM ::=
3676 MECHANISM_NAME
3677 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3678
3679 MECHANISM_ASSOCIATION ::=
3680 [formal_parameter_NAME =>] MECHANISM_NAME
3681
3682 MECHANISM_NAME ::= Value | Reference
3683 @end example
3684
3685 This pragma is identical to @code{Export_Procedure} except that the
3686 first parameter of @code{LOCAL_NAME}, which must be present, must be of
3687 mode @code{out}, and externally the subprogram is treated as a function
3688 with this parameter as the result of the function. GNAT provides for
3689 this capability to allow the use of @code{out} and @code{in out}
3690 parameters in interfacing to external functions (which are not permitted
3691 in Ada functions).
3692 GNAT does not require a separate pragma @code{Export}, but if none is
3693 present, @code{Convention Ada} is assumed, which is almost certainly
3694 not what is wanted since the whole point of this pragma is to interface
3695 with foreign language functions, so it is usually appropriate to use this
3696 pragma in conjunction with a @code{Export} or @code{Convention}
3697 pragma that specifies the desired foreign convention.
3698
3699 @geindex Suppressing external name
3700
3701 Special treatment is given if the EXTERNAL is an explicit null
3702 string or a static string expressions that evaluates to the null
3703 string. In this case, no external name is generated. This form
3704 still allows the specification of parameter mechanisms.
3705
3706 @node Pragma Extend_System,Pragma Extensions_Allowed,Pragma Export_Valued_Procedure,Implementation Defined Pragmas
3707 @anchor{gnat_rm/implementation_defined_pragmas pragma-extend-system}@anchor{67}
3708 @section Pragma Extend_System
3709
3710
3711 @geindex System
3712 @geindex extending
3713
3714 @geindex DEC Ada 83
3715
3716 Syntax:
3717
3718 @example
3719 pragma Extend_System ([Name =>] IDENTIFIER);
3720 @end example
3721
3722 This pragma is used to provide backwards compatibility with other
3723 implementations that extend the facilities of package @code{System}. In
3724 GNAT, @code{System} contains only the definitions that are present in
3725 the Ada RM. However, other implementations, notably the DEC Ada 83
3726 implementation, provide many extensions to package @code{System}.
3727
3728 For each such implementation accommodated by this pragma, GNAT provides a
3729 package @code{Aux_@emph{xxx}}, e.g., @code{Aux_DEC} for the DEC Ada 83
3730 implementation, which provides the required additional definitions. You
3731 can use this package in two ways. You can @code{with} it in the normal
3732 way and access entities either by selection or using a @code{use}
3733 clause. In this case no special processing is required.
3734
3735 However, if existing code contains references such as
3736 @code{System.@emph{xxx}} where @emph{xxx} is an entity in the extended
3737 definitions provided in package @code{System}, you may use this pragma
3738 to extend visibility in @code{System} in a non-standard way that
3739 provides greater compatibility with the existing code. Pragma
3740 @code{Extend_System} is a configuration pragma whose single argument is
3741 the name of the package containing the extended definition
3742 (e.g., @code{Aux_DEC} for the DEC Ada case). A unit compiled under
3743 control of this pragma will be processed using special visibility
3744 processing that looks in package @code{System.Aux_@emph{xxx}} where
3745 @code{Aux_@emph{xxx}} is the pragma argument for any entity referenced in
3746 package @code{System}, but not found in package @code{System}.
3747
3748 You can use this pragma either to access a predefined @code{System}
3749 extension supplied with the compiler, for example @code{Aux_DEC} or
3750 you can construct your own extension unit following the above
3751 definition. Note that such a package is a child of @code{System}
3752 and thus is considered part of the implementation.
3753 To compile it you will have to use the @emph{-gnatg} switch
3754 for compiling System units, as explained in the
3755 GNAT User's Guide.
3756
3757 @node Pragma Extensions_Allowed,Pragma Extensions_Visible,Pragma Extend_System,Implementation Defined Pragmas
3758 @anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-allowed}@anchor{68}
3759 @section Pragma Extensions_Allowed
3760
3761
3762 @geindex Ada Extensions
3763
3764 @geindex GNAT Extensions
3765
3766 Syntax:
3767
3768 @example
3769 pragma Extensions_Allowed (On | Off);
3770 @end example
3771
3772 This configuration pragma enables or disables the implementation
3773 extension mode (the use of Off as a parameter cancels the effect
3774 of the @emph{-gnatX} command switch).
3775
3776 In extension mode, the latest version of the Ada language is
3777 implemented (currently Ada 2012), and in addition a small number
3778 of GNAT specific extensions are recognized as follows:
3779
3780
3781 @table @asis
3782
3783 @item @emph{Constrained attribute for generic objects}
3784
3785 The @code{Constrained} attribute is permitted for objects of
3786 generic types. The result indicates if the corresponding actual
3787 is constrained.
3788 @end table
3789
3790 @node Pragma Extensions_Visible,Pragma External,Pragma Extensions_Allowed,Implementation Defined Pragmas
3791 @anchor{gnat_rm/implementation_defined_pragmas id12}@anchor{69}@anchor{gnat_rm/implementation_defined_pragmas pragma-extensions-visible}@anchor{6a}
3792 @section Pragma Extensions_Visible
3793
3794
3795 Syntax:
3796
3797 @example
3798 pragma Extensions_Visible [ (boolean_EXPRESSION) ];
3799 @end example
3800
3801 For the semantics of this pragma, see the entry for aspect @code{Extensions_Visible}
3802 in the SPARK 2014 Reference Manual, section 6.1.7.
3803
3804 @node Pragma External,Pragma External_Name_Casing,Pragma Extensions_Visible,Implementation Defined Pragmas
3805 @anchor{gnat_rm/implementation_defined_pragmas pragma-external}@anchor{6b}
3806 @section Pragma External
3807
3808
3809 Syntax:
3810
3811 @example
3812 pragma External (
3813 [ Convention =>] convention_IDENTIFIER,
3814 [ Entity =>] LOCAL_NAME
3815 [, [External_Name =>] static_string_EXPRESSION ]
3816 [, [Link_Name =>] static_string_EXPRESSION ]);
3817 @end example
3818
3819 This pragma is identical in syntax and semantics to pragma
3820 @code{Export} as defined in the Ada Reference Manual. It is
3821 provided for compatibility with some Ada 83 compilers that
3822 used this pragma for exactly the same purposes as pragma
3823 @code{Export} before the latter was standardized.
3824
3825 @node Pragma External_Name_Casing,Pragma Fast_Math,Pragma External,Implementation Defined Pragmas
3826 @anchor{gnat_rm/implementation_defined_pragmas pragma-external-name-casing}@anchor{6c}
3827 @section Pragma External_Name_Casing
3828
3829
3830 @geindex Dec Ada 83 casing compatibility
3831
3832 @geindex External Names
3833 @geindex casing
3834
3835 @geindex Casing of External names
3836
3837 Syntax:
3838
3839 @example
3840 pragma External_Name_Casing (
3841 Uppercase | Lowercase
3842 [, Uppercase | Lowercase | As_Is]);
3843 @end example
3844
3845 This pragma provides control over the casing of external names associated
3846 with Import and Export pragmas. There are two cases to consider:
3847
3848
3849 @itemize *
3850
3851 @item
3852 Implicit external names
3853
3854 Implicit external names are derived from identifiers. The most common case
3855 arises when a standard Ada Import or Export pragma is used with only two
3856 arguments, as in:
3857
3858 @example
3859 pragma Import (C, C_Routine);
3860 @end example
3861
3862 Since Ada is a case-insensitive language, the spelling of the identifier in
3863 the Ada source program does not provide any information on the desired
3864 casing of the external name, and so a convention is needed. In GNAT the
3865 default treatment is that such names are converted to all lower case
3866 letters. This corresponds to the normal C style in many environments.
3867 The first argument of pragma @code{External_Name_Casing} can be used to
3868 control this treatment. If @code{Uppercase} is specified, then the name
3869 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3870 then the normal default of all lower case letters will be used.
3871
3872 This same implicit treatment is also used in the case of extended DEC Ada 83
3873 compatible Import and Export pragmas where an external name is explicitly
3874 specified using an identifier rather than a string.
3875
3876 @item
3877 Explicit external names
3878
3879 Explicit external names are given as string literals. The most common case
3880 arises when a standard Ada Import or Export pragma is used with three
3881 arguments, as in:
3882
3883 @example
3884 pragma Import (C, C_Routine, "C_routine");
3885 @end example
3886
3887 In this case, the string literal normally provides the exact casing required
3888 for the external name. The second argument of pragma
3889 @code{External_Name_Casing} may be used to modify this behavior.
3890 If @code{Uppercase} is specified, then the name
3891 will be forced to all uppercase letters. If @code{Lowercase} is specified,
3892 then the name will be forced to all lowercase letters. A specification of
3893 @code{As_Is} provides the normal default behavior in which the casing is
3894 taken from the string provided.
3895 @end itemize
3896
3897 This pragma may appear anywhere that a pragma is valid. In particular, it
3898 can be used as a configuration pragma in the @code{gnat.adc} file, in which
3899 case it applies to all subsequent compilations, or it can be used as a program
3900 unit pragma, in which case it only applies to the current unit, or it can
3901 be used more locally to control individual Import/Export pragmas.
3902
3903 It was primarily intended for use with OpenVMS systems, where many
3904 compilers convert all symbols to upper case by default. For interfacing to
3905 such compilers (e.g., the DEC C compiler), it may be convenient to use
3906 the pragma:
3907
3908 @example
3909 pragma External_Name_Casing (Uppercase, Uppercase);
3910 @end example
3911
3912 to enforce the upper casing of all external symbols.
3913
3914 @node Pragma Fast_Math,Pragma Favor_Top_Level,Pragma External_Name_Casing,Implementation Defined Pragmas
3915 @anchor{gnat_rm/implementation_defined_pragmas pragma-fast-math}@anchor{6d}
3916 @section Pragma Fast_Math
3917
3918
3919 Syntax:
3920
3921 @example
3922 pragma Fast_Math;
3923 @end example
3924
3925 This is a configuration pragma which activates a mode in which speed is
3926 considered more important for floating-point operations than absolutely
3927 accurate adherence to the requirements of the standard. Currently the
3928 following operations are affected:
3929
3930
3931 @table @asis
3932
3933 @item @emph{Complex Multiplication}
3934
3935 The normal simple formula for complex multiplication can result in intermediate
3936 overflows for numbers near the end of the range. The Ada standard requires that
3937 this situation be detected and corrected by scaling, but in Fast_Math mode such
3938 cases will simply result in overflow. Note that to take advantage of this you
3939 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
3940 under control of the pragma, rather than use the preinstantiated versions.
3941 @end table
3942
3943 @node Pragma Favor_Top_Level,Pragma Finalize_Storage_Only,Pragma Fast_Math,Implementation Defined Pragmas
3944 @anchor{gnat_rm/implementation_defined_pragmas id13}@anchor{6e}@anchor{gnat_rm/implementation_defined_pragmas pragma-favor-top-level}@anchor{6f}
3945 @section Pragma Favor_Top_Level
3946
3947
3948 Syntax:
3949
3950 @example
3951 pragma Favor_Top_Level (type_NAME);
3952 @end example
3953
3954 The argument of pragma @code{Favor_Top_Level} must be a named access-to-subprogram
3955 type. This pragma is an efficiency hint to the compiler, regarding the use of
3956 @code{'Access} or @code{'Unrestricted_Access} on nested (non-library-level) subprograms.
3957 The pragma means that nested subprograms are not used with this type, or are
3958 rare, so that the generated code should be efficient in the top-level case.
3959 When this pragma is used, dynamically generated trampolines may be used on some
3960 targets for nested subprograms. See restriction @code{No_Implicit_Dynamic_Code}.
3961
3962 @node Pragma Finalize_Storage_Only,Pragma Float_Representation,Pragma Favor_Top_Level,Implementation Defined Pragmas
3963 @anchor{gnat_rm/implementation_defined_pragmas pragma-finalize-storage-only}@anchor{70}
3964 @section Pragma Finalize_Storage_Only
3965
3966
3967 Syntax:
3968
3969 @example
3970 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
3971 @end example
3972
3973 The argument of pragma @code{Finalize_Storage_Only} must denote a local type which
3974 is derived from @code{Ada.Finalization.Controlled} or @code{Limited_Controlled}. The
3975 pragma suppresses the call to @code{Finalize} for declared library-level objects
3976 of the argument type. This is mostly useful for types where finalization is
3977 only used to deal with storage reclamation since in most environments it is
3978 not necessary to reclaim memory just before terminating execution, hence the
3979 name. Note that this pragma does not suppress Finalize calls for library-level
3980 heap-allocated objects (see pragma @code{No_Heap_Finalization}).
3981
3982 @node Pragma Float_Representation,Pragma Ghost,Pragma Finalize_Storage_Only,Implementation Defined Pragmas
3983 @anchor{gnat_rm/implementation_defined_pragmas pragma-float-representation}@anchor{71}
3984 @section Pragma Float_Representation
3985
3986
3987 Syntax:
3988
3989 @example
3990 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
3991
3992 FLOAT_REP ::= VAX_Float | IEEE_Float
3993 @end example
3994
3995 In the one argument form, this pragma is a configuration pragma which
3996 allows control over the internal representation chosen for the predefined
3997 floating point types declared in the packages @code{Standard} and
3998 @code{System}. This pragma is only provided for compatibility and has no effect.
3999
4000 The two argument form specifies the representation to be used for
4001 the specified floating-point type. The argument must
4002 be @code{IEEE_Float} to specify the use of IEEE format, as follows:
4003
4004
4005 @itemize *
4006
4007 @item
4008 For a digits value of 6, 32-bit IEEE short format will be used.
4009
4010 @item
4011 For a digits value of 15, 64-bit IEEE long format will be used.
4012
4013 @item
4014 No other value of digits is permitted.
4015 @end itemize
4016
4017 @node Pragma Ghost,Pragma Global,Pragma Float_Representation,Implementation Defined Pragmas
4018 @anchor{gnat_rm/implementation_defined_pragmas pragma-ghost}@anchor{72}@anchor{gnat_rm/implementation_defined_pragmas id14}@anchor{73}
4019 @section Pragma Ghost
4020
4021
4022 Syntax:
4023
4024 @example
4025 pragma Ghost [ (boolean_EXPRESSION) ];
4026 @end example
4027
4028 For the semantics of this pragma, see the entry for aspect @code{Ghost} in the SPARK
4029 2014 Reference Manual, section 6.9.
4030
4031 @node Pragma Global,Pragma Ident,Pragma Ghost,Implementation Defined Pragmas
4032 @anchor{gnat_rm/implementation_defined_pragmas pragma-global}@anchor{74}@anchor{gnat_rm/implementation_defined_pragmas id15}@anchor{75}
4033 @section Pragma Global
4034
4035
4036 Syntax:
4037
4038 @example
4039 pragma Global (GLOBAL_SPECIFICATION);
4040
4041 GLOBAL_SPECIFICATION ::=
4042 null
4043 | (GLOBAL_LIST)
4044 | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
4045
4046 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
4047
4048 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
4049 GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
4050 GLOBAL_ITEM ::= NAME
4051 @end example
4052
4053 For the semantics of this pragma, see the entry for aspect @code{Global} in the
4054 SPARK 2014 Reference Manual, section 6.1.4.
4055
4056 @node Pragma Ident,Pragma Ignore_Pragma,Pragma Global,Implementation Defined Pragmas
4057 @anchor{gnat_rm/implementation_defined_pragmas pragma-ident}@anchor{76}
4058 @section Pragma Ident
4059
4060
4061 Syntax:
4062
4063 @example
4064 pragma Ident (static_string_EXPRESSION);
4065 @end example
4066
4067 This pragma is identical in effect to pragma @code{Comment}. It is provided
4068 for compatibility with other Ada compilers providing this pragma.
4069
4070 @node Pragma Ignore_Pragma,Pragma Implementation_Defined,Pragma Ident,Implementation Defined Pragmas
4071 @anchor{gnat_rm/implementation_defined_pragmas pragma-ignore-pragma}@anchor{77}
4072 @section Pragma Ignore_Pragma
4073
4074
4075 Syntax:
4076
4077 @example
4078 pragma Ignore_Pragma (pragma_IDENTIFIER);
4079 @end example
4080
4081 This is a configuration pragma
4082 that takes a single argument that is a simple identifier. Any subsequent
4083 use of a pragma whose pragma identifier matches this argument will be
4084 silently ignored. This may be useful when legacy code or code intended
4085 for compilation with some other compiler contains pragmas that match the
4086 name, but not the exact implementation, of a GNAT pragma. The use of this
4087 pragma allows such pragmas to be ignored, which may be useful in CodePeer
4088 mode, or during porting of legacy code.
4089
4090 @node Pragma Implementation_Defined,Pragma Implemented,Pragma Ignore_Pragma,Implementation Defined Pragmas
4091 @anchor{gnat_rm/implementation_defined_pragmas pragma-implementation-defined}@anchor{78}
4092 @section Pragma Implementation_Defined
4093
4094
4095 Syntax:
4096
4097 @example
4098 pragma Implementation_Defined (local_NAME);
4099 @end example
4100
4101 This pragma marks a previously declared entity as implementation-defined.
4102 For an overloaded entity, applies to the most recent homonym.
4103
4104 @example
4105 pragma Implementation_Defined;
4106 @end example
4107
4108 The form with no arguments appears anywhere within a scope, most
4109 typically a package spec, and indicates that all entities that are
4110 defined within the package spec are Implementation_Defined.
4111
4112 This pragma is used within the GNAT runtime library to identify
4113 implementation-defined entities introduced in language-defined units,
4114 for the purpose of implementing the No_Implementation_Identifiers
4115 restriction.
4116
4117 @node Pragma Implemented,Pragma Implicit_Packing,Pragma Implementation_Defined,Implementation Defined Pragmas
4118 @anchor{gnat_rm/implementation_defined_pragmas pragma-implemented}@anchor{79}
4119 @section Pragma Implemented
4120
4121
4122 Syntax:
4123
4124 @example
4125 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
4126
4127 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
4128 @end example
4129
4130 This is an Ada 2012 representation pragma which applies to protected, task
4131 and synchronized interface primitives. The use of pragma Implemented provides
4132 a way to impose a static requirement on the overriding operation by adhering
4133 to one of the three implementation kinds: entry, protected procedure or any of
4134 the above. This pragma is available in all earlier versions of Ada as an
4135 implementation-defined pragma.
4136
4137 @example
4138 type Synch_Iface is synchronized interface;
4139 procedure Prim_Op (Obj : in out Iface) is abstract;
4140 pragma Implemented (Prim_Op, By_Protected_Procedure);
4141
4142 protected type Prot_1 is new Synch_Iface with
4143 procedure Prim_Op; -- Legal
4144 end Prot_1;
4145
4146 protected type Prot_2 is new Synch_Iface with
4147 entry Prim_Op; -- Illegal
4148 end Prot_2;
4149
4150 task type Task_Typ is new Synch_Iface with
4151 entry Prim_Op; -- Illegal
4152 end Task_Typ;
4153 @end example
4154
4155 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
4156 Implemented determines the runtime behavior of the requeue. Implementation kind
4157 By_Entry guarantees that the action of requeueing will proceed from an entry to
4158 another entry. Implementation kind By_Protected_Procedure transforms the
4159 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
4160 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
4161 the target's overriding subprogram kind.
4162
4163 @node Pragma Implicit_Packing,Pragma Import_Function,Pragma Implemented,Implementation Defined Pragmas
4164 @anchor{gnat_rm/implementation_defined_pragmas pragma-implicit-packing}@anchor{7a}
4165 @section Pragma Implicit_Packing
4166
4167
4168 @geindex Rational Profile
4169
4170 Syntax:
4171
4172 @example
4173 pragma Implicit_Packing;
4174 @end example
4175
4176 This is a configuration pragma that requests implicit packing for packed
4177 arrays for which a size clause is given but no explicit pragma Pack or
4178 specification of Component_Size is present. It also applies to records
4179 where no record representation clause is present. Consider this example:
4180
4181 @example
4182 type R is array (0 .. 7) of Boolean;
4183 for R'Size use 8;
4184 @end example
4185
4186 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
4187 does not change the layout of a composite object. So the Size clause in the
4188 above example is normally rejected, since the default layout of the array uses
4189 8-bit components, and thus the array requires a minimum of 64 bits.
4190
4191 If this declaration is compiled in a region of code covered by an occurrence
4192 of the configuration pragma Implicit_Packing, then the Size clause in this
4193 and similar examples will cause implicit packing and thus be accepted. For
4194 this implicit packing to occur, the type in question must be an array of small
4195 components whose size is known at compile time, and the Size clause must
4196 specify the exact size that corresponds to the number of elements in the array
4197 multiplied by the size in bits of the component type (both single and
4198 multi-dimensioned arrays can be controlled with this pragma).
4199
4200 @geindex Array packing
4201
4202 Similarly, the following example shows the use in the record case
4203
4204 @example
4205 type r is record
4206 a, b, c, d, e, f, g, h : boolean;
4207 chr : character;
4208 end record;
4209 for r'size use 16;
4210 @end example
4211
4212 Without a pragma Pack, each Boolean field requires 8 bits, so the
4213 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
4214 sufficient. The use of pragma Implicit_Packing allows this record
4215 declaration to compile without an explicit pragma Pack.
4216
4217 @node Pragma Import_Function,Pragma Import_Object,Pragma Implicit_Packing,Implementation Defined Pragmas
4218 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-function}@anchor{7b}
4219 @section Pragma Import_Function
4220
4221
4222 Syntax:
4223
4224 @example
4225 pragma Import_Function (
4226 [Internal =>] LOCAL_NAME,
4227 [, [External =>] EXTERNAL_SYMBOL]
4228 [, [Parameter_Types =>] PARAMETER_TYPES]
4229 [, [Result_Type =>] SUBTYPE_MARK]
4230 [, [Mechanism =>] MECHANISM]
4231 [, [Result_Mechanism =>] MECHANISM_NAME]);
4232
4233 EXTERNAL_SYMBOL ::=
4234 IDENTIFIER
4235 | static_string_EXPRESSION
4236
4237 PARAMETER_TYPES ::=
4238 null
4239 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4240
4241 TYPE_DESIGNATOR ::=
4242 subtype_NAME
4243 | subtype_Name ' Access
4244
4245 MECHANISM ::=
4246 MECHANISM_NAME
4247 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4248
4249 MECHANISM_ASSOCIATION ::=
4250 [formal_parameter_NAME =>] MECHANISM_NAME
4251
4252 MECHANISM_NAME ::=
4253 Value
4254 | Reference
4255 @end example
4256
4257 This pragma is used in conjunction with a pragma @code{Import} to
4258 specify additional information for an imported function. The pragma
4259 @code{Import} (or equivalent pragma @code{Interface}) must precede the
4260 @code{Import_Function} pragma and both must appear in the same
4261 declarative part as the function specification.
4262
4263 The @code{Internal} argument must uniquely designate
4264 the function to which the
4265 pragma applies. If more than one function name exists of this name in
4266 the declarative part you must use the @code{Parameter_Types} and
4267 @code{Result_Type} parameters to achieve the required unique
4268 designation. Subtype marks in these parameters must exactly match the
4269 subtypes in the corresponding function specification, using positional
4270 notation to match parameters with subtype marks.
4271 The form with an @code{'Access} attribute can be used to match an
4272 anonymous access parameter.
4273
4274 You may optionally use the @code{Mechanism} and @code{Result_Mechanism}
4275 parameters to specify passing mechanisms for the
4276 parameters and result. If you specify a single mechanism name, it
4277 applies to all parameters. Otherwise you may specify a mechanism on a
4278 parameter by parameter basis using either positional or named
4279 notation. If the mechanism is not specified, the default mechanism
4280 is used.
4281
4282 @node Pragma Import_Object,Pragma Import_Procedure,Pragma Import_Function,Implementation Defined Pragmas
4283 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-object}@anchor{7c}
4284 @section Pragma Import_Object
4285
4286
4287 Syntax:
4288
4289 @example
4290 pragma Import_Object
4291 [Internal =>] LOCAL_NAME
4292 [, [External =>] EXTERNAL_SYMBOL]
4293 [, [Size =>] EXTERNAL_SYMBOL]);
4294
4295 EXTERNAL_SYMBOL ::=
4296 IDENTIFIER
4297 | static_string_EXPRESSION
4298 @end example
4299
4300 This pragma designates an object as imported, and apart from the
4301 extended rules for external symbols, is identical in effect to the use of
4302 the normal @code{Import} pragma applied to an object. Unlike the
4303 subprogram case, you need not use a separate @code{Import} pragma,
4304 although you may do so (and probably should do so from a portability
4305 point of view). @code{size} is syntax checked, but otherwise ignored by
4306 GNAT.
4307
4308 @node Pragma Import_Procedure,Pragma Import_Valued_Procedure,Pragma Import_Object,Implementation Defined Pragmas
4309 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-procedure}@anchor{7d}
4310 @section Pragma Import_Procedure
4311
4312
4313 Syntax:
4314
4315 @example
4316 pragma Import_Procedure (
4317 [Internal =>] LOCAL_NAME
4318 [, [External =>] EXTERNAL_SYMBOL]
4319 [, [Parameter_Types =>] PARAMETER_TYPES]
4320 [, [Mechanism =>] MECHANISM]);
4321
4322 EXTERNAL_SYMBOL ::=
4323 IDENTIFIER
4324 | static_string_EXPRESSION
4325
4326 PARAMETER_TYPES ::=
4327 null
4328 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4329
4330 TYPE_DESIGNATOR ::=
4331 subtype_NAME
4332 | subtype_Name ' Access
4333
4334 MECHANISM ::=
4335 MECHANISM_NAME
4336 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4337
4338 MECHANISM_ASSOCIATION ::=
4339 [formal_parameter_NAME =>] MECHANISM_NAME
4340
4341 MECHANISM_NAME ::= Value | Reference
4342 @end example
4343
4344 This pragma is identical to @code{Import_Function} except that it
4345 applies to a procedure rather than a function and the parameters
4346 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
4347
4348 @node Pragma Import_Valued_Procedure,Pragma Independent,Pragma Import_Procedure,Implementation Defined Pragmas
4349 @anchor{gnat_rm/implementation_defined_pragmas pragma-import-valued-procedure}@anchor{7e}
4350 @section Pragma Import_Valued_Procedure
4351
4352
4353 Syntax:
4354
4355 @example
4356 pragma Import_Valued_Procedure (
4357 [Internal =>] LOCAL_NAME
4358 [, [External =>] EXTERNAL_SYMBOL]
4359 [, [Parameter_Types =>] PARAMETER_TYPES]
4360 [, [Mechanism =>] MECHANISM]);
4361
4362 EXTERNAL_SYMBOL ::=
4363 IDENTIFIER
4364 | static_string_EXPRESSION
4365
4366 PARAMETER_TYPES ::=
4367 null
4368 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
4369
4370 TYPE_DESIGNATOR ::=
4371 subtype_NAME
4372 | subtype_Name ' Access
4373
4374 MECHANISM ::=
4375 MECHANISM_NAME
4376 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
4377
4378 MECHANISM_ASSOCIATION ::=
4379 [formal_parameter_NAME =>] MECHANISM_NAME
4380
4381 MECHANISM_NAME ::= Value | Reference
4382 @end example
4383
4384 This pragma is identical to @code{Import_Procedure} except that the
4385 first parameter of @code{LOCAL_NAME}, which must be present, must be of
4386 mode @code{out}, and externally the subprogram is treated as a function
4387 with this parameter as the result of the function. The purpose of this
4388 capability is to allow the use of @code{out} and @code{in out}
4389 parameters in interfacing to external functions (which are not permitted
4390 in Ada functions). You may optionally use the @code{Mechanism}
4391 parameters to specify passing mechanisms for the parameters.
4392 If you specify a single mechanism name, it applies to all parameters.
4393 Otherwise you may specify a mechanism on a parameter by parameter
4394 basis using either positional or named notation. If the mechanism is not
4395 specified, the default mechanism is used.
4396
4397 Note that it is important to use this pragma in conjunction with a separate
4398 pragma Import that specifies the desired convention, since otherwise the
4399 default convention is Ada, which is almost certainly not what is required.
4400
4401 @node Pragma Independent,Pragma Independent_Components,Pragma Import_Valued_Procedure,Implementation Defined Pragmas
4402 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent}@anchor{7f}
4403 @section Pragma Independent
4404
4405
4406 Syntax:
4407
4408 @example
4409 pragma Independent (Local_NAME);
4410 @end example
4411
4412 This pragma is standard in Ada 2012 mode (which also provides an aspect
4413 of the same name). It is also available as an implementation-defined
4414 pragma in all earlier versions. It specifies that the
4415 designated object or all objects of the designated type must be
4416 independently addressable. This means that separate tasks can safely
4417 manipulate such objects. For example, if two components of a record are
4418 independent, then two separate tasks may access these two components.
4419 This may place
4420 constraints on the representation of the object (for instance prohibiting
4421 tight packing).
4422
4423 @node Pragma Independent_Components,Pragma Initial_Condition,Pragma Independent,Implementation Defined Pragmas
4424 @anchor{gnat_rm/implementation_defined_pragmas pragma-independent-components}@anchor{80}
4425 @section Pragma Independent_Components
4426
4427
4428 Syntax:
4429
4430 @example
4431 pragma Independent_Components (Local_NAME);
4432 @end example
4433
4434 This pragma is standard in Ada 2012 mode (which also provides an aspect
4435 of the same name). It is also available as an implementation-defined
4436 pragma in all earlier versions. It specifies that the components of the
4437 designated object, or the components of each object of the designated
4438 type, must be
4439 independently addressable. This means that separate tasks can safely
4440 manipulate separate components in the composite object. This may place
4441 constraints on the representation of the object (for instance prohibiting
4442 tight packing).
4443
4444 @node Pragma Initial_Condition,Pragma Initialize_Scalars,Pragma Independent_Components,Implementation Defined Pragmas
4445 @anchor{gnat_rm/implementation_defined_pragmas id16}@anchor{81}@anchor{gnat_rm/implementation_defined_pragmas pragma-initial-condition}@anchor{82}
4446 @section Pragma Initial_Condition
4447
4448
4449 Syntax:
4450
4451 @example
4452 pragma Initial_Condition (boolean_EXPRESSION);
4453 @end example
4454
4455 For the semantics of this pragma, see the entry for aspect @code{Initial_Condition}
4456 in the SPARK 2014 Reference Manual, section 7.1.6.
4457
4458 @node Pragma Initialize_Scalars,Pragma Initializes,Pragma Initial_Condition,Implementation Defined Pragmas
4459 @anchor{gnat_rm/implementation_defined_pragmas pragma-initialize-scalars}@anchor{83}
4460 @section Pragma Initialize_Scalars
4461
4462
4463 @geindex debugging with Initialize_Scalars
4464
4465 Syntax:
4466
4467 @example
4468 pragma Initialize_Scalars
4469 [ ( TYPE_VALUE_PAIR @{, TYPE_VALUE_PAIR@} ) ];
4470
4471 TYPE_VALUE_PAIR ::=
4472 SCALAR_TYPE => static_EXPRESSION
4473
4474 SCALAR_TYPE :=
4475 Short_Float
4476 | Float
4477 | Long_Float
4478 | Long_Long_Flat
4479 | Signed_8
4480 | Signed_16
4481 | Signed_32
4482 | Signed_64
4483 | Unsigned_8
4484 | Unsigned_16
4485 | Unsigned_32
4486 | Unsigned_64
4487 @end example
4488
4489 This pragma is similar to @code{Normalize_Scalars} conceptually but has two
4490 important differences.
4491
4492 First, there is no requirement for the pragma to be used uniformly in all units
4493 of a partition. In particular, it is fine to use this just for some or all of
4494 the application units of a partition, without needing to recompile the run-time
4495 library. In the case where some units are compiled with the pragma, and some
4496 without, then a declaration of a variable where the type is defined in package
4497 Standard or is locally declared will always be subject to initialization, as
4498 will any declaration of a scalar variable. For composite variables, whether the
4499 variable is initialized may also depend on whether the package in which the
4500 type of the variable is declared is compiled with the pragma.
4501
4502 The other important difference is that the programmer can control the value
4503 used for initializing scalar objects. This effect can be achieved in several
4504 different ways:
4505
4506
4507 @itemize *
4508
4509 @item
4510 At compile time, the programmer can specify the invalid value for a
4511 particular family of scalar types using the optional arguments of the pragma.
4512
4513 The compile-time approach is intended to optimize the generated code for the
4514 pragma, by possibly using fast operations such as @code{memset}. Note that such
4515 optimizations require using values where the bytes all have the same binary
4516 representation.
4517
4518 @item
4519 At bind time, the programmer has several options:
4520
4521
4522 @itemize *
4523
4524 @item
4525 Initialization with invalid values (similar to Normalize_Scalars, though
4526 for Initialize_Scalars it is not always possible to determine the invalid
4527 values in complex cases like signed component fields with nonstandard
4528 sizes).
4529
4530 @item
4531 Initialization with high values.
4532
4533 @item
4534 Initialization with low values.
4535
4536 @item
4537 Initialization with a specific bit pattern.
4538 @end itemize
4539
4540 See the GNAT User's Guide for binder options for specifying these cases.
4541
4542 The bind-time approach is intended to provide fast turnaround for testing
4543 with different values, without having to recompile the program.
4544
4545 @item
4546 At execution time, the programmer can specify the invalid values using an
4547 environment variable. See the GNAT User's Guide for details.
4548
4549 The execution-time approach is intended to provide fast turnaround for
4550 testing with different values, without having to recompile and rebind the
4551 program.
4552 @end itemize
4553
4554 Note that pragma @code{Initialize_Scalars} is particularly useful in conjunction
4555 with the enhanced validity checking that is now provided in GNAT, which checks
4556 for invalid values under more conditions. Using this feature (see description
4557 of the @emph{-gnatV} flag in the GNAT User's Guide) in conjunction with pragma
4558 @code{Initialize_Scalars} provides a powerful new tool to assist in the detection
4559 of problems caused by uninitialized variables.
4560
4561 Note: the use of @code{Initialize_Scalars} has a fairly extensive effect on the
4562 generated code. This may cause your code to be substantially larger. It may
4563 also cause an increase in the amount of stack required, so it is probably a
4564 good idea to turn on stack checking (see description of stack checking in the
4565 GNAT User's Guide) when using this pragma.
4566
4567 @node Pragma Initializes,Pragma Inline_Always,Pragma Initialize_Scalars,Implementation Defined Pragmas
4568 @anchor{gnat_rm/implementation_defined_pragmas pragma-initializes}@anchor{84}@anchor{gnat_rm/implementation_defined_pragmas id17}@anchor{85}
4569 @section Pragma Initializes
4570
4571
4572 Syntax:
4573
4574 @example
4575 pragma Initializes (INITIALIZATION_LIST);
4576
4577 INITIALIZATION_LIST ::=
4578 null
4579 | (INITIALIZATION_ITEM @{, INITIALIZATION_ITEM@})
4580
4581 INITIALIZATION_ITEM ::= name [=> INPUT_LIST]
4582
4583 INPUT_LIST ::=
4584 null
4585 | INPUT
4586 | (INPUT @{, INPUT@})
4587
4588 INPUT ::= name
4589 @end example
4590
4591 For the semantics of this pragma, see the entry for aspect @code{Initializes} in the
4592 SPARK 2014 Reference Manual, section 7.1.5.
4593
4594 @node Pragma Inline_Always,Pragma Inline_Generic,Pragma Initializes,Implementation Defined Pragmas
4595 @anchor{gnat_rm/implementation_defined_pragmas id18}@anchor{86}@anchor{gnat_rm/implementation_defined_pragmas pragma-inline-always}@anchor{87}
4596 @section Pragma Inline_Always
4597
4598
4599 Syntax:
4600
4601 @example
4602 pragma Inline_Always (NAME [, NAME]);
4603 @end example
4604
4605 Similar to pragma @code{Inline} except that inlining is unconditional.
4606 Inline_Always instructs the compiler to inline every direct call to the
4607 subprogram or else to emit a compilation error, independently of any
4608 option, in particular @emph{-gnatn} or @emph{-gnatN} or the optimization level.
4609 It is an error to take the address or access of @code{NAME}. It is also an error to
4610 apply this pragma to a primitive operation of a tagged type. Thanks to such
4611 restrictions, the compiler is allowed to remove the out-of-line body of @code{NAME}.
4612
4613 @node Pragma Inline_Generic,Pragma Interface,Pragma Inline_Always,Implementation Defined Pragmas
4614 @anchor{gnat_rm/implementation_defined_pragmas pragma-inline-generic}@anchor{88}
4615 @section Pragma Inline_Generic
4616
4617
4618 Syntax:
4619
4620 @example
4621 pragma Inline_Generic (GNAME @{, GNAME@});
4622
4623 GNAME ::= generic_unit_NAME | generic_instance_NAME
4624 @end example
4625
4626 This pragma is provided for compatibility with Dec Ada 83. It has
4627 no effect in GNAT (which always inlines generics), other
4628 than to check that the given names are all names of generic units or
4629 generic instances.
4630
4631 @node Pragma Interface,Pragma Interface_Name,Pragma Inline_Generic,Implementation Defined Pragmas
4632 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface}@anchor{89}
4633 @section Pragma Interface
4634
4635
4636 Syntax:
4637
4638 @example
4639 pragma Interface (
4640 [Convention =>] convention_identifier,
4641 [Entity =>] local_NAME
4642 [, [External_Name =>] static_string_expression]
4643 [, [Link_Name =>] static_string_expression]);
4644 @end example
4645
4646 This pragma is identical in syntax and semantics to
4647 the standard Ada pragma @code{Import}. It is provided for compatibility
4648 with Ada 83. The definition is upwards compatible both with pragma
4649 @code{Interface} as defined in the Ada 83 Reference Manual, and also
4650 with some extended implementations of this pragma in certain Ada 83
4651 implementations. The only difference between pragma @code{Interface}
4652 and pragma @code{Import} is that there is special circuitry to allow
4653 both pragmas to appear for the same subprogram entity (normally it
4654 is illegal to have multiple @code{Import} pragmas. This is useful in
4655 maintaining Ada 83/Ada 95 compatibility and is compatible with other
4656 Ada 83 compilers.
4657
4658 @node Pragma Interface_Name,Pragma Interrupt_Handler,Pragma Interface,Implementation Defined Pragmas
4659 @anchor{gnat_rm/implementation_defined_pragmas pragma-interface-name}@anchor{8a}
4660 @section Pragma Interface_Name
4661
4662
4663 Syntax:
4664
4665 @example
4666 pragma Interface_Name (
4667 [Entity =>] LOCAL_NAME
4668 [, [External_Name =>] static_string_EXPRESSION]
4669 [, [Link_Name =>] static_string_EXPRESSION]);
4670 @end example
4671
4672 This pragma provides an alternative way of specifying the interface name
4673 for an interfaced subprogram, and is provided for compatibility with Ada
4674 83 compilers that use the pragma for this purpose. You must provide at
4675 least one of @code{External_Name} or @code{Link_Name}.
4676
4677 @node Pragma Interrupt_Handler,Pragma Interrupt_State,Pragma Interface_Name,Implementation Defined Pragmas
4678 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-handler}@anchor{8b}
4679 @section Pragma Interrupt_Handler
4680
4681
4682 Syntax:
4683
4684 @example
4685 pragma Interrupt_Handler (procedure_LOCAL_NAME);
4686 @end example
4687
4688 This program unit pragma is supported for parameterless protected procedures
4689 as described in Annex C of the Ada Reference Manual. On the AAMP target
4690 the pragma can also be specified for nonprotected parameterless procedures
4691 that are declared at the library level (which includes procedures
4692 declared at the top level of a library package). In the case of AAMP,
4693 when this pragma is applied to a nonprotected procedure, the instruction
4694 @code{IERET} is generated for returns from the procedure, enabling
4695 maskable interrupts, in place of the normal return instruction.
4696
4697 @node Pragma Interrupt_State,Pragma Invariant,Pragma Interrupt_Handler,Implementation Defined Pragmas
4698 @anchor{gnat_rm/implementation_defined_pragmas pragma-interrupt-state}@anchor{8c}
4699 @section Pragma Interrupt_State
4700
4701
4702 Syntax:
4703
4704 @example
4705 pragma Interrupt_State
4706 ([Name =>] value,
4707 [State =>] SYSTEM | RUNTIME | USER);
4708 @end example
4709
4710 Normally certain interrupts are reserved to the implementation. Any attempt
4711 to attach an interrupt causes Program_Error to be raised, as described in
4712 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
4713 many systems for an @code{Ctrl-C} interrupt. Normally this interrupt is
4714 reserved to the implementation, so that @code{Ctrl-C} can be used to
4715 interrupt execution. Additionally, signals such as @code{SIGSEGV},
4716 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
4717 Ada exceptions, or used to implement run-time functions such as the
4718 @code{abort} statement and stack overflow checking.
4719
4720 Pragma @code{Interrupt_State} provides a general mechanism for overriding
4721 such uses of interrupts. It subsumes the functionality of pragma
4722 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
4723 available on Windows. On all other platforms than VxWorks,
4724 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
4725 and may be used to mark interrupts required by the board support package
4726 as reserved.
4727
4728 Interrupts can be in one of three states:
4729
4730
4731 @itemize *
4732
4733 @item
4734 System
4735
4736 The interrupt is reserved (no Ada handler can be installed), and the
4737 Ada run-time may not install a handler. As a result you are guaranteed
4738 standard system default action if this interrupt is raised. This also allows
4739 installing a low level handler via C APIs such as sigaction(), outside
4740 of Ada control.
4741
4742 @item
4743 Runtime
4744
4745 The interrupt is reserved (no Ada handler can be installed). The run time
4746 is allowed to install a handler for internal control purposes, but is
4747 not required to do so.
4748
4749 @item
4750 User
4751
4752 The interrupt is unreserved. The user may install an Ada handler via
4753 Ada.Interrupts and pragma Interrupt_Handler or Attach_Handler to provide
4754 some other action.
4755 @end itemize
4756
4757 These states are the allowed values of the @code{State} parameter of the
4758 pragma. The @code{Name} parameter is a value of the type
4759 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
4760 @code{Ada.Interrupts.Names}.
4761
4762 This is a configuration pragma, and the binder will check that there
4763 are no inconsistencies between different units in a partition in how a
4764 given interrupt is specified. It may appear anywhere a pragma is legal.
4765
4766 The effect is to move the interrupt to the specified state.
4767
4768 By declaring interrupts to be SYSTEM, you guarantee the standard system
4769 action, such as a core dump.
4770
4771 By declaring interrupts to be USER, you guarantee that you can install
4772 a handler.
4773
4774 Note that certain signals on many operating systems cannot be caught and
4775 handled by applications. In such cases, the pragma is ignored. See the
4776 operating system documentation, or the value of the array @code{Reserved}
4777 declared in the spec of package @code{System.OS_Interface}.
4778
4779 Overriding the default state of signals used by the Ada runtime may interfere
4780 with an application's runtime behavior in the cases of the synchronous signals,
4781 and in the case of the signal used to implement the @code{abort} statement.
4782
4783 @node Pragma Invariant,Pragma Keep_Names,Pragma Interrupt_State,Implementation Defined Pragmas
4784 @anchor{gnat_rm/implementation_defined_pragmas id19}@anchor{8d}@anchor{gnat_rm/implementation_defined_pragmas pragma-invariant}@anchor{8e}
4785 @section Pragma Invariant
4786
4787
4788 Syntax:
4789
4790 @example
4791 pragma Invariant
4792 ([Entity =>] private_type_LOCAL_NAME,
4793 [Check =>] EXPRESSION
4794 [,[Message =>] String_Expression]);
4795 @end example
4796
4797 This pragma provides exactly the same capabilities as the Type_Invariant aspect
4798 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
4799 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
4800 requires the use of the aspect syntax, which is not available except in 2012
4801 mode, it is not possible to use the Type_Invariant aspect in earlier versions
4802 of Ada. However the Invariant pragma may be used in any version of Ada. Also
4803 note that the aspect Invariant is a synonym in GNAT for the aspect
4804 Type_Invariant, but there is no pragma Type_Invariant.
4805
4806 The pragma must appear within the visible part of the package specification,
4807 after the type to which its Entity argument appears. As with the Invariant
4808 aspect, the Check expression is not analyzed until the end of the visible
4809 part of the package, so it may contain forward references. The Message
4810 argument, if present, provides the exception message used if the invariant
4811 is violated. If no Message parameter is provided, a default message that
4812 identifies the line on which the pragma appears is used.
4813
4814 It is permissible to have multiple Invariants for the same type entity, in
4815 which case they are and'ed together. It is permissible to use this pragma
4816 in Ada 2012 mode, but you cannot have both an invariant aspect and an
4817 invariant pragma for the same entity.
4818
4819 For further details on the use of this pragma, see the Ada 2012 documentation
4820 of the Type_Invariant aspect.
4821
4822 @node Pragma Keep_Names,Pragma License,Pragma Invariant,Implementation Defined Pragmas
4823 @anchor{gnat_rm/implementation_defined_pragmas pragma-keep-names}@anchor{8f}
4824 @section Pragma Keep_Names
4825
4826
4827 Syntax:
4828
4829 @example
4830 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
4831 @end example
4832
4833 The @code{LOCAL_NAME} argument
4834 must refer to an enumeration first subtype
4835 in the current declarative part. The effect is to retain the enumeration
4836 literal names for use by @code{Image} and @code{Value} even if a global
4837 @code{Discard_Names} pragma applies. This is useful when you want to
4838 generally suppress enumeration literal names and for example you therefore
4839 use a @code{Discard_Names} pragma in the @code{gnat.adc} file, but you
4840 want to retain the names for specific enumeration types.
4841
4842 @node Pragma License,Pragma Link_With,Pragma Keep_Names,Implementation Defined Pragmas
4843 @anchor{gnat_rm/implementation_defined_pragmas pragma-license}@anchor{90}
4844 @section Pragma License
4845
4846
4847 @geindex License checking
4848
4849 Syntax:
4850
4851 @example
4852 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
4853 @end example
4854
4855 This pragma is provided to allow automated checking for appropriate license
4856 conditions with respect to the standard and modified GPL. A pragma
4857 @code{License}, which is a configuration pragma that typically appears at
4858 the start of a source file or in a separate @code{gnat.adc} file, specifies
4859 the licensing conditions of a unit as follows:
4860
4861
4862 @itemize *
4863
4864 @item
4865 Unrestricted
4866 This is used for a unit that can be freely used with no license restrictions.
4867 Examples of such units are public domain units, and units from the Ada
4868 Reference Manual.
4869
4870 @item
4871 GPL
4872 This is used for a unit that is licensed under the unmodified GPL, and which
4873 therefore cannot be @code{with}ed by a restricted unit.
4874
4875 @item
4876 Modified_GPL
4877 This is used for a unit licensed under the GNAT modified GPL that includes
4878 a special exception paragraph that specifically permits the inclusion of
4879 the unit in programs without requiring the entire program to be released
4880 under the GPL.
4881
4882 @item
4883 Restricted
4884 This is used for a unit that is restricted in that it is not permitted to
4885 depend on units that are licensed under the GPL. Typical examples are
4886 proprietary code that is to be released under more restrictive license
4887 conditions. Note that restricted units are permitted to @code{with} units
4888 which are licensed under the modified GPL (this is the whole point of the
4889 modified GPL).
4890 @end itemize
4891
4892 Normally a unit with no @code{License} pragma is considered to have an
4893 unknown license, and no checking is done. However, standard GNAT headers
4894 are recognized, and license information is derived from them as follows.
4895
4896 A GNAT license header starts with a line containing 78 hyphens. The following
4897 comment text is searched for the appearance of any of the following strings.
4898
4899 If the string 'GNU General Public License' is found, then the unit is assumed
4900 to have GPL license, unless the string 'As a special exception' follows, in
4901 which case the license is assumed to be modified GPL.
4902
4903 If one of the strings
4904 'This specification is adapted from the Ada Semantic Interface' or
4905 'This specification is derived from the Ada Reference Manual' is found
4906 then the unit is assumed to be unrestricted.
4907
4908 These default actions means that a program with a restricted license pragma
4909 will automatically get warnings if a GPL unit is inappropriately
4910 @code{with}ed. For example, the program:
4911
4912 @example
4913 with Sem_Ch3;
4914 with GNAT.Sockets;
4915 procedure Secret_Stuff is
4916 ...
4917 end Secret_Stuff
4918 @end example
4919
4920 if compiled with pragma @code{License} (@code{Restricted}) in a
4921 @code{gnat.adc} file will generate the warning:
4922
4923 @example
4924 1. with Sem_Ch3;
4925 |
4926 >>> license of withed unit "Sem_Ch3" is incompatible
4927
4928 2. with GNAT.Sockets;
4929 3. procedure Secret_Stuff is
4930 @end example
4931
4932 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
4933 compiler and is licensed under the
4934 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
4935 run time, and is therefore licensed under the modified GPL.
4936
4937 @node Pragma Link_With,Pragma Linker_Alias,Pragma License,Implementation Defined Pragmas
4938 @anchor{gnat_rm/implementation_defined_pragmas pragma-link-with}@anchor{91}
4939 @section Pragma Link_With
4940
4941
4942 Syntax:
4943
4944 @example
4945 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
4946 @end example
4947
4948 This pragma is provided for compatibility with certain Ada 83 compilers.
4949 It has exactly the same effect as pragma @code{Linker_Options} except
4950 that spaces occurring within one of the string expressions are treated
4951 as separators. For example, in the following case:
4952
4953 @example
4954 pragma Link_With ("-labc -ldef");
4955 @end example
4956
4957 results in passing the strings @code{-labc} and @code{-ldef} as two
4958 separate arguments to the linker. In addition pragma Link_With allows
4959 multiple arguments, with the same effect as successive pragmas.
4960
4961 @node Pragma Linker_Alias,Pragma Linker_Constructor,Pragma Link_With,Implementation Defined Pragmas
4962 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-alias}@anchor{92}
4963 @section Pragma Linker_Alias
4964
4965
4966 Syntax:
4967
4968 @example
4969 pragma Linker_Alias (
4970 [Entity =>] LOCAL_NAME,
4971 [Target =>] static_string_EXPRESSION);
4972 @end example
4973
4974 @code{LOCAL_NAME} must refer to an object that is declared at the library
4975 level. This pragma establishes the given entity as a linker alias for the
4976 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
4977 and causes @code{LOCAL_NAME} to be emitted as an alias for the symbol
4978 @code{static_string_EXPRESSION} in the object file, that is to say no space
4979 is reserved for @code{LOCAL_NAME} by the assembler and it will be resolved
4980 to the same address as @code{static_string_EXPRESSION} by the linker.
4981
4982 The actual linker name for the target must be used (e.g., the fully
4983 encoded name with qualification in Ada, or the mangled name in C++),
4984 or it must be declared using the C convention with @code{pragma Import}
4985 or @code{pragma Export}.
4986
4987 Not all target machines support this pragma. On some of them it is accepted
4988 only if @code{pragma Weak_External} has been applied to @code{LOCAL_NAME}.
4989
4990 @example
4991 -- Example of the use of pragma Linker_Alias
4992
4993 package p is
4994 i : Integer := 1;
4995 pragma Export (C, i);
4996
4997 new_name_for_i : Integer;
4998 pragma Linker_Alias (new_name_for_i, "i");
4999 end p;
5000 @end example
5001
5002 @node Pragma Linker_Constructor,Pragma Linker_Destructor,Pragma Linker_Alias,Implementation Defined Pragmas
5003 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-constructor}@anchor{93}
5004 @section Pragma Linker_Constructor
5005
5006
5007 Syntax:
5008
5009 @example
5010 pragma Linker_Constructor (procedure_LOCAL_NAME);
5011 @end example
5012
5013 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
5014 is declared at the library level. A procedure to which this pragma is
5015 applied will be treated as an initialization routine by the linker.
5016 It is equivalent to @code{__attribute__((constructor))} in GNU C and
5017 causes @code{procedure_LOCAL_NAME} to be invoked before the entry point
5018 of the executable is called (or immediately after the shared library is
5019 loaded if the procedure is linked in a shared library), in particular
5020 before the Ada run-time environment is set up.
5021
5022 Because of these specific contexts, the set of operations such a procedure
5023 can perform is very limited and the type of objects it can manipulate is
5024 essentially restricted to the elementary types. In particular, it must only
5025 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
5026
5027 This pragma is used by GNAT to implement auto-initialization of shared Stand
5028 Alone Libraries, which provides a related capability without the restrictions
5029 listed above. Where possible, the use of Stand Alone Libraries is preferable
5030 to the use of this pragma.
5031
5032 @node Pragma Linker_Destructor,Pragma Linker_Section,Pragma Linker_Constructor,Implementation Defined Pragmas
5033 @anchor{gnat_rm/implementation_defined_pragmas pragma-linker-destructor}@anchor{94}
5034 @section Pragma Linker_Destructor
5035
5036
5037 Syntax:
5038
5039 @example
5040 pragma Linker_Destructor (procedure_LOCAL_NAME);
5041 @end example
5042
5043 @code{procedure_LOCAL_NAME} must refer to a parameterless procedure that
5044 is declared at the library level. A procedure to which this pragma is
5045 applied will be treated as a finalization routine by the linker.
5046 It is equivalent to @code{__attribute__((destructor))} in GNU C and
5047 causes @code{procedure_LOCAL_NAME} to be invoked after the entry point
5048 of the executable has exited (or immediately before the shared library
5049 is unloaded if the procedure is linked in a shared library), in particular
5050 after the Ada run-time environment is shut down.
5051
5052 See @code{pragma Linker_Constructor} for the set of restrictions that apply
5053 because of these specific contexts.
5054
5055 @node Pragma Linker_Section,Pragma Lock_Free,Pragma Linker_Destructor,Implementation Defined Pragmas
5056 @anchor{gnat_rm/implementation_defined_pragmas id20}@anchor{95}@anchor{gnat_rm/implementation_defined_pragmas pragma-linker-section}@anchor{96}
5057 @section Pragma Linker_Section
5058
5059
5060 Syntax:
5061
5062 @example
5063 pragma Linker_Section (
5064 [Entity =>] LOCAL_NAME,
5065 [Section =>] static_string_EXPRESSION);
5066 @end example
5067
5068 @code{LOCAL_NAME} must refer to an object, type, or subprogram that is
5069 declared at the library level. This pragma specifies the name of the
5070 linker section for the given entity. It is equivalent to
5071 @code{__attribute__((section))} in GNU C and causes @code{LOCAL_NAME} to
5072 be placed in the @code{static_string_EXPRESSION} section of the
5073 executable (assuming the linker doesn't rename the section).
5074 GNAT also provides an implementation defined aspect of the same name.
5075
5076 In the case of specifying this aspect for a type, the effect is to
5077 specify the corresponding section for all library-level objects of
5078 the type that do not have an explicit linker section set. Note that
5079 this only applies to whole objects, not to components of composite objects.
5080
5081 In the case of a subprogram, the linker section applies to all previously
5082 declared matching overloaded subprograms in the current declarative part
5083 which do not already have a linker section assigned. The linker section
5084 aspect is useful in this case for specifying different linker sections
5085 for different elements of such an overloaded set.
5086
5087 Note that an empty string specifies that no linker section is specified.
5088 This is not quite the same as omitting the pragma or aspect, since it
5089 can be used to specify that one element of an overloaded set of subprograms
5090 has the default linker section, or that one object of a type for which a
5091 linker section is specified should has the default linker section.
5092
5093 The compiler normally places library-level entities in standard sections
5094 depending on the class: procedures and functions generally go in the
5095 @code{.text} section, initialized variables in the @code{.data} section
5096 and uninitialized variables in the @code{.bss} section.
5097
5098 Other, special sections may exist on given target machines to map special
5099 hardware, for example I/O ports or flash memory. This pragma is a means to
5100 defer the final layout of the executable to the linker, thus fully working
5101 at the symbolic level with the compiler.
5102
5103 Some file formats do not support arbitrary sections so not all target
5104 machines support this pragma. The use of this pragma may cause a program
5105 execution to be erroneous if it is used to place an entity into an
5106 inappropriate section (e.g., a modified variable into the @code{.text}
5107 section). See also @code{pragma Persistent_BSS}.
5108
5109 @example
5110 -- Example of the use of pragma Linker_Section
5111
5112 package IO_Card is
5113 Port_A : Integer;
5114 pragma Volatile (Port_A);
5115 pragma Linker_Section (Port_A, ".bss.port_a");
5116
5117 Port_B : Integer;
5118 pragma Volatile (Port_B);
5119 pragma Linker_Section (Port_B, ".bss.port_b");
5120
5121 type Port_Type is new Integer with Linker_Section => ".bss";
5122 PA : Port_Type with Linker_Section => ".bss.PA";
5123 PB : Port_Type; -- ends up in linker section ".bss"
5124
5125 procedure Q with Linker_Section => "Qsection";
5126 end IO_Card;
5127 @end example
5128
5129 @node Pragma Lock_Free,Pragma Loop_Invariant,Pragma Linker_Section,Implementation Defined Pragmas
5130 @anchor{gnat_rm/implementation_defined_pragmas id21}@anchor{97}@anchor{gnat_rm/implementation_defined_pragmas pragma-lock-free}@anchor{98}
5131 @section Pragma Lock_Free
5132
5133
5134 Syntax:
5135 This pragma may be specified for protected types or objects. It specifies that
5136 the implementation of protected operations must be implemented without locks.
5137 Compilation fails if the compiler cannot generate lock-free code for the
5138 operations.
5139
5140 The current conditions required to support this pragma are:
5141
5142
5143 @itemize *
5144
5145 @item
5146 Protected type declarations may not contain entries
5147
5148 @item
5149 Protected subprogram declarations may not have nonelementary parameters
5150 @end itemize
5151
5152 In addition, each protected subprogram body must satisfy:
5153
5154
5155 @itemize *
5156
5157 @item
5158 May reference only one protected component
5159
5160 @item
5161 May not reference nonconstant entities outside the protected subprogram
5162 scope.
5163
5164 @item
5165 May not contain address representation items, allocators, or quantified
5166 expressions.
5167
5168 @item
5169 May not contain delay, goto, loop, or procedure-call statements.
5170
5171 @item
5172 May not contain exported and imported entities
5173
5174 @item
5175 May not dereferenced access values
5176
5177 @item
5178 Function calls and attribute references must be static
5179 @end itemize
5180
5181 @node Pragma Loop_Invariant,Pragma Loop_Optimize,Pragma Lock_Free,Implementation Defined Pragmas
5182 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-invariant}@anchor{99}
5183 @section Pragma Loop_Invariant
5184
5185
5186 Syntax:
5187
5188 @example
5189 pragma Loop_Invariant ( boolean_EXPRESSION );
5190 @end example
5191
5192 The effect of this pragma is similar to that of pragma @code{Assert},
5193 except that in an @code{Assertion_Policy} pragma, the identifier
5194 @code{Loop_Invariant} is used to control whether it is ignored or checked
5195 (or disabled).
5196
5197 @code{Loop_Invariant} can only appear as one of the items in the sequence
5198 of statements of a loop body, or nested inside block statements that
5199 appear in the sequence of statements of a loop body.
5200 The intention is that it be used to
5201 represent a "loop invariant" assertion, i.e. something that is true each
5202 time through the loop, and which can be used to show that the loop is
5203 achieving its purpose.
5204
5205 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5206 apply to the same loop should be grouped in the same sequence of
5207 statements.
5208
5209 To aid in writing such invariants, the special attribute @code{Loop_Entry}
5210 may be used to refer to the value of an expression on entry to the loop. This
5211 attribute can only be used within the expression of a @code{Loop_Invariant}
5212 pragma. For full details, see documentation of attribute @code{Loop_Entry}.
5213
5214 @node Pragma Loop_Optimize,Pragma Loop_Variant,Pragma Loop_Invariant,Implementation Defined Pragmas
5215 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-optimize}@anchor{9a}
5216 @section Pragma Loop_Optimize
5217
5218
5219 Syntax:
5220
5221 @example
5222 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
5223
5224 OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
5225 @end example
5226
5227 This pragma must appear immediately within a loop statement. It allows the
5228 programmer to specify optimization hints for the enclosing loop. The hints
5229 are not mutually exclusive and can be freely mixed, but not all combinations
5230 will yield a sensible outcome.
5231
5232 There are five supported optimization hints for a loop:
5233
5234
5235 @itemize *
5236
5237 @item
5238 Ivdep
5239
5240 The programmer asserts that there are no loop-carried dependencies
5241 which would prevent consecutive iterations of the loop from being
5242 executed simultaneously.
5243
5244 @item
5245 No_Unroll
5246
5247 The loop must not be unrolled. This is a strong hint: the compiler will not
5248 unroll a loop marked with this hint.
5249
5250 @item
5251 Unroll
5252
5253 The loop should be unrolled. This is a weak hint: the compiler will try to
5254 apply unrolling to this loop preferably to other optimizations, notably
5255 vectorization, but there is no guarantee that the loop will be unrolled.
5256
5257 @item
5258 No_Vector
5259
5260 The loop must not be vectorized. This is a strong hint: the compiler will not
5261 vectorize a loop marked with this hint.
5262
5263 @item
5264 Vector
5265
5266 The loop should be vectorized. This is a weak hint: the compiler will try to
5267 apply vectorization to this loop preferably to other optimizations, notably
5268 unrolling, but there is no guarantee that the loop will be vectorized.
5269 @end itemize
5270
5271 These hints do not remove the need to pass the appropriate switches to the
5272 compiler in order to enable the relevant optimizations, that is to say
5273 @emph{-funroll-loops} for unrolling and @emph{-ftree-vectorize} for
5274 vectorization.
5275
5276 @node Pragma Loop_Variant,Pragma Machine_Attribute,Pragma Loop_Optimize,Implementation Defined Pragmas
5277 @anchor{gnat_rm/implementation_defined_pragmas pragma-loop-variant}@anchor{9b}
5278 @section Pragma Loop_Variant
5279
5280
5281 Syntax:
5282
5283 @example
5284 pragma Loop_Variant ( LOOP_VARIANT_ITEM @{, LOOP_VARIANT_ITEM @} );
5285 LOOP_VARIANT_ITEM ::= CHANGE_DIRECTION => discrete_EXPRESSION
5286 CHANGE_DIRECTION ::= Increases | Decreases
5287 @end example
5288
5289 @code{Loop_Variant} can only appear as one of the items in the sequence
5290 of statements of a loop body, or nested inside block statements that
5291 appear in the sequence of statements of a loop body.
5292 It allows the specification of quantities which must always
5293 decrease or increase in successive iterations of the loop. In its simplest
5294 form, just one expression is specified, whose value must increase or decrease
5295 on each iteration of the loop.
5296
5297 In a more complex form, multiple arguments can be given which are intepreted
5298 in a nesting lexicographic manner. For example:
5299
5300 @example
5301 pragma Loop_Variant (Increases => X, Decreases => Y);
5302 @end example
5303
5304 specifies that each time through the loop either X increases, or X stays
5305 the same and Y decreases. A @code{Loop_Variant} pragma ensures that the
5306 loop is making progress. It can be useful in helping to show informally
5307 or prove formally that the loop always terminates.
5308
5309 @code{Loop_Variant} is an assertion whose effect can be controlled using
5310 an @code{Assertion_Policy} with a check name of @code{Loop_Variant}. The
5311 policy can be @code{Check} to enable the loop variant check, @code{Ignore}
5312 to ignore the check (in which case the pragma has no effect on the program),
5313 or @code{Disable} in which case the pragma is not even checked for correct
5314 syntax.
5315
5316 Multiple @code{Loop_Invariant} and @code{Loop_Variant} pragmas that
5317 apply to the same loop should be grouped in the same sequence of
5318 statements.
5319
5320 The @code{Loop_Entry} attribute may be used within the expressions of the
5321 @code{Loop_Variant} pragma to refer to values on entry to the loop.
5322
5323 @node Pragma Machine_Attribute,Pragma Main,Pragma Loop_Variant,Implementation Defined Pragmas
5324 @anchor{gnat_rm/implementation_defined_pragmas pragma-machine-attribute}@anchor{9c}
5325 @section Pragma Machine_Attribute
5326
5327
5328 Syntax:
5329
5330 @example
5331 pragma Machine_Attribute (
5332 [Entity =>] LOCAL_NAME,
5333 [Attribute_Name =>] static_string_EXPRESSION
5334 [, [Info =>] static_EXPRESSION @{, static_EXPRESSION@}] );
5335 @end example
5336
5337 Machine-dependent attributes can be specified for types and/or
5338 declarations. This pragma is semantically equivalent to
5339 @code{__attribute__((@emph{attribute_name}))} (if @code{info} is not
5340 specified) or @code{__attribute__((@emph{attribute_name(info})))}
5341 or @code{__attribute__((@emph{attribute_name(info,...})))} in GNU C,
5342 where @emph{attribute_name} is recognized by the compiler middle-end
5343 or the @code{TARGET_ATTRIBUTE_TABLE} machine specific macro. Note
5344 that a string literal for the optional parameter @code{info} or the
5345 following ones is transformed by default into an identifier,
5346 which may make this pragma unusable for some attributes.
5347 For further information see @cite{GNU Compiler Collection (GCC) Internals}.
5348
5349 @node Pragma Main,Pragma Main_Storage,Pragma Machine_Attribute,Implementation Defined Pragmas
5350 @anchor{gnat_rm/implementation_defined_pragmas pragma-main}@anchor{9d}
5351 @section Pragma Main
5352
5353
5354 Syntax:
5355
5356 @example
5357 pragma Main
5358 (MAIN_OPTION [, MAIN_OPTION]);
5359
5360 MAIN_OPTION ::=
5361 [Stack_Size =>] static_integer_EXPRESSION
5362 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
5363 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
5364 @end example
5365
5366 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
5367 no effect in GNAT, other than being syntax checked.
5368
5369 @node Pragma Main_Storage,Pragma Max_Queue_Length,Pragma Main,Implementation Defined Pragmas
5370 @anchor{gnat_rm/implementation_defined_pragmas pragma-main-storage}@anchor{9e}
5371 @section Pragma Main_Storage
5372
5373
5374 Syntax:
5375
5376 @example
5377 pragma Main_Storage
5378 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
5379
5380 MAIN_STORAGE_OPTION ::=
5381 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
5382 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
5383 @end example
5384
5385 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
5386 no effect in GNAT, other than being syntax checked.
5387
5388 @node Pragma Max_Queue_Length,Pragma No_Body,Pragma Main_Storage,Implementation Defined Pragmas
5389 @anchor{gnat_rm/implementation_defined_pragmas id22}@anchor{9f}@anchor{gnat_rm/implementation_defined_pragmas pragma-max-queue-length}@anchor{a0}
5390 @section Pragma Max_Queue_Length
5391
5392
5393 Syntax:
5394
5395 @example
5396 pragma Max_Entry_Queue (static_integer_EXPRESSION);
5397 @end example
5398
5399 This pragma is used to specify the maximum callers per entry queue for
5400 individual protected entries and entry families. It accepts a single
5401 integer (-1 or more) as a parameter and must appear after the declaration of an
5402 entry.
5403
5404 A value of -1 represents no additional restriction on queue length.
5405
5406 @node Pragma No_Body,Pragma No_Caching,Pragma Max_Queue_Length,Implementation Defined Pragmas
5407 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-body}@anchor{a1}
5408 @section Pragma No_Body
5409
5410
5411 Syntax:
5412
5413 @example
5414 pragma No_Body;
5415 @end example
5416
5417 There are a number of cases in which a package spec does not require a body,
5418 and in fact a body is not permitted. GNAT will not permit the spec to be
5419 compiled if there is a body around. The pragma No_Body allows you to provide
5420 a body file, even in a case where no body is allowed. The body file must
5421 contain only comments and a single No_Body pragma. This is recognized by
5422 the compiler as indicating that no body is logically present.
5423
5424 This is particularly useful during maintenance when a package is modified in
5425 such a way that a body needed before is no longer needed. The provision of a
5426 dummy body with a No_Body pragma ensures that there is no interference from
5427 earlier versions of the package body.
5428
5429 @node Pragma No_Caching,Pragma No_Component_Reordering,Pragma No_Body,Implementation Defined Pragmas
5430 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-caching}@anchor{a2}@anchor{gnat_rm/implementation_defined_pragmas id23}@anchor{a3}
5431 @section Pragma No_Caching
5432
5433
5434 Syntax:
5435
5436 @example
5437 pragma No_Caching [ (boolean_EXPRESSION) ];
5438 @end example
5439
5440 For the semantics of this pragma, see the entry for aspect @code{No_Caching} in
5441 the SPARK 2014 Reference Manual, section 7.1.2.
5442
5443 @node Pragma No_Component_Reordering,Pragma No_Elaboration_Code_All,Pragma No_Caching,Implementation Defined Pragmas
5444 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-component-reordering}@anchor{a4}
5445 @section Pragma No_Component_Reordering
5446
5447
5448 Syntax:
5449
5450 @example
5451 pragma No_Component_Reordering [([Entity =>] type_LOCAL_NAME)];
5452 @end example
5453
5454 @code{type_LOCAL_NAME} must refer to a record type declaration in the current
5455 declarative part. The effect is to preclude any reordering of components
5456 for the layout of the record, i.e. the record is laid out by the compiler
5457 in the order in which the components are declared textually. The form with
5458 no argument is a configuration pragma which applies to all record types
5459 declared in units to which the pragma applies and there is a requirement
5460 that this pragma be used consistently within a partition.
5461
5462 @node Pragma No_Elaboration_Code_All,Pragma No_Heap_Finalization,Pragma No_Component_Reordering,Implementation Defined Pragmas
5463 @anchor{gnat_rm/implementation_defined_pragmas id24}@anchor{a5}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-elaboration-code-all}@anchor{a6}
5464 @section Pragma No_Elaboration_Code_All
5465
5466
5467 Syntax:
5468
5469 @example
5470 pragma No_Elaboration_Code_All [(program_unit_NAME)];
5471 @end example
5472
5473 This is a program unit pragma (there is also an equivalent aspect of the
5474 same name) that establishes the restriction @code{No_Elaboration_Code} for
5475 the current unit and any extended main source units (body and subunits).
5476 It also has the effect of enforcing a transitive application of this
5477 aspect, so that if any unit is implicitly or explicitly with'ed by the
5478 current unit, it must also have the No_Elaboration_Code_All aspect set.
5479 It may be applied to package or subprogram specs or their generic versions.
5480
5481 @node Pragma No_Heap_Finalization,Pragma No_Inline,Pragma No_Elaboration_Code_All,Implementation Defined Pragmas
5482 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-heap-finalization}@anchor{a7}
5483 @section Pragma No_Heap_Finalization
5484
5485
5486 Syntax:
5487
5488 @example
5489 pragma No_Heap_Finalization [ (first_subtype_LOCAL_NAME) ];
5490 @end example
5491
5492 Pragma @code{No_Heap_Finalization} may be used as a configuration pragma or as a
5493 type-specific pragma.
5494
5495 In its configuration form, the pragma must appear within a configuration file
5496 such as gnat.adc, without an argument. The pragma suppresses the call to
5497 @code{Finalize} for heap-allocated objects created through library-level named
5498 access-to-object types in cases where the designated type requires finalization
5499 actions.
5500
5501 In its type-specific form, the argument of the pragma must denote a
5502 library-level named access-to-object type. The pragma suppresses the call to
5503 @code{Finalize} for heap-allocated objects created through the specific access type
5504 in cases where the designated type requires finalization actions.
5505
5506 It is still possible to finalize such heap-allocated objects by explicitly
5507 deallocating them.
5508
5509 A library-level named access-to-object type declared within a generic unit will
5510 lose its @code{No_Heap_Finalization} pragma when the corresponding instance does not
5511 appear at the library level.
5512
5513 @node Pragma No_Inline,Pragma No_Return,Pragma No_Heap_Finalization,Implementation Defined Pragmas
5514 @anchor{gnat_rm/implementation_defined_pragmas id25}@anchor{a8}@anchor{gnat_rm/implementation_defined_pragmas pragma-no-inline}@anchor{a9}
5515 @section Pragma No_Inline
5516
5517
5518 Syntax:
5519
5520 @example
5521 pragma No_Inline (NAME @{, NAME@});
5522 @end example
5523
5524 This pragma suppresses inlining for the callable entity or the instances of
5525 the generic subprogram designated by @code{NAME}, including inlining that
5526 results from the use of pragma @code{Inline}. This pragma is always active,
5527 in particular it is not subject to the use of option @emph{-gnatn} or
5528 @emph{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
5529 pragma @code{Inline_Always} for the same @code{NAME}.
5530
5531 @node Pragma No_Return,Pragma No_Strict_Aliasing,Pragma No_Inline,Implementation Defined Pragmas
5532 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-return}@anchor{aa}
5533 @section Pragma No_Return
5534
5535
5536 Syntax:
5537
5538 @example
5539 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
5540 @end example
5541
5542 Each @code{procedure_LOCAL_NAME} argument must refer to one or more procedure
5543 declarations in the current declarative part. A procedure to which this
5544 pragma is applied may not contain any explicit @code{return} statements.
5545 In addition, if the procedure contains any implicit returns from falling
5546 off the end of a statement sequence, then execution of that implicit
5547 return will cause Program_Error to be raised.
5548
5549 One use of this pragma is to identify procedures whose only purpose is to raise
5550 an exception. Another use of this pragma is to suppress incorrect warnings
5551 about missing returns in functions, where the last statement of a function
5552 statement sequence is a call to such a procedure.
5553
5554 Note that in Ada 2005 mode, this pragma is part of the language. It is
5555 available in all earlier versions of Ada as an implementation-defined
5556 pragma.
5557
5558 @node Pragma No_Strict_Aliasing,Pragma No_Tagged_Streams,Pragma No_Return,Implementation Defined Pragmas
5559 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-strict-aliasing}@anchor{ab}
5560 @section Pragma No_Strict_Aliasing
5561
5562
5563 Syntax:
5564
5565 @example
5566 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
5567 @end example
5568
5569 @code{type_LOCAL_NAME} must refer to an access type
5570 declaration in the current declarative part. The effect is to inhibit
5571 strict aliasing optimization for the given type. The form with no
5572 arguments is a configuration pragma which applies to all access types
5573 declared in units to which the pragma applies. For a detailed
5574 description of the strict aliasing optimization, and the situations
5575 in which it must be suppressed, see the section on Optimization and Strict Aliasing
5576 in the @cite{GNAT User's Guide}.
5577
5578 This pragma currently has no effects on access to unconstrained array types.
5579
5580 @node Pragma No_Tagged_Streams,Pragma Normalize_Scalars,Pragma No_Strict_Aliasing,Implementation Defined Pragmas
5581 @anchor{gnat_rm/implementation_defined_pragmas pragma-no-tagged-streams}@anchor{ac}@anchor{gnat_rm/implementation_defined_pragmas id26}@anchor{ad}
5582 @section Pragma No_Tagged_Streams
5583
5584
5585 Syntax:
5586
5587 @example
5588 pragma No_Tagged_Streams [([Entity =>] tagged_type_LOCAL_NAME)];
5589 @end example
5590
5591 Normally when a tagged type is introduced using a full type declaration,
5592 part of the processing includes generating stream access routines to be
5593 used by stream attributes referencing the type (or one of its subtypes
5594 or derived types). This can involve the generation of significant amounts
5595 of code which is wasted space if stream routines are not needed for the
5596 type in question.
5597
5598 The @code{No_Tagged_Streams} pragma causes the generation of these stream
5599 routines to be skipped, and any attempt to use stream operations on
5600 types subject to this pragma will be statically rejected as illegal.
5601
5602 There are two forms of the pragma. The form with no arguments must appear
5603 in a declarative sequence or in the declarations of a package spec. This
5604 pragma affects all subsequent root tagged types declared in the declaration
5605 sequence, and specifies that no stream routines be generated. The form with
5606 an argument (for which there is also a corresponding aspect) specifies a
5607 single root tagged type for which stream routines are not to be generated.
5608
5609 Once the pragma has been given for a particular root tagged type, all subtypes
5610 and derived types of this type inherit the pragma automatically, so the effect
5611 applies to a complete hierarchy (this is necessary to deal with the class-wide
5612 dispatching versions of the stream routines).
5613
5614 When pragmas @code{Discard_Names} and @code{No_Tagged_Streams} are simultaneously
5615 applied to a tagged type its Expanded_Name and External_Tag are initialized
5616 with empty strings. This is useful to avoid exposing entity names at binary
5617 level but has a negative impact on the debuggability of tagged types.
5618
5619 @node Pragma Normalize_Scalars,Pragma Obsolescent,Pragma No_Tagged_Streams,Implementation Defined Pragmas
5620 @anchor{gnat_rm/implementation_defined_pragmas pragma-normalize-scalars}@anchor{ae}
5621 @section Pragma Normalize_Scalars
5622
5623
5624 Syntax:
5625
5626 @example
5627 pragma Normalize_Scalars;
5628 @end example
5629
5630 This is a language defined pragma which is fully implemented in GNAT. The
5631 effect is to cause all scalar objects that are not otherwise initialized
5632 to be initialized. The initial values are implementation dependent and
5633 are as follows:
5634
5635
5636 @table @asis
5637
5638 @item @emph{Standard.Character}
5639
5640 Objects whose root type is Standard.Character are initialized to
5641 Character'Last unless the subtype range excludes NUL (in which case
5642 NUL is used). This choice will always generate an invalid value if
5643 one exists.
5644
5645 @item @emph{Standard.Wide_Character}
5646
5647 Objects whose root type is Standard.Wide_Character are initialized to
5648 Wide_Character'Last unless the subtype range excludes NUL (in which case
5649 NUL is used). This choice will always generate an invalid value if
5650 one exists.
5651
5652 @item @emph{Standard.Wide_Wide_Character}
5653
5654 Objects whose root type is Standard.Wide_Wide_Character are initialized to
5655 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
5656 which case NUL is used). This choice will always generate an invalid value if
5657 one exists.
5658
5659 @item @emph{Integer types}
5660
5661 Objects of an integer type are treated differently depending on whether
5662 negative values are present in the subtype. If no negative values are
5663 present, then all one bits is used as the initial value except in the
5664 special case where zero is excluded from the subtype, in which case
5665 all zero bits are used. This choice will always generate an invalid
5666 value if one exists.
5667
5668 For subtypes with negative values present, the largest negative number
5669 is used, except in the unusual case where this largest negative number
5670 is in the subtype, and the largest positive number is not, in which case
5671 the largest positive value is used. This choice will always generate
5672 an invalid value if one exists.
5673
5674 @item @emph{Floating-Point Types}
5675
5676 Objects of all floating-point types are initialized to all 1-bits. For
5677 standard IEEE format, this corresponds to a NaN (not a number) which is
5678 indeed an invalid value.
5679
5680 @item @emph{Fixed-Point Types}
5681
5682 Objects of all fixed-point types are treated as described above for integers,
5683 with the rules applying to the underlying integer value used to represent
5684 the fixed-point value.
5685
5686 @item @emph{Modular types}
5687
5688 Objects of a modular type are initialized to all one bits, except in
5689 the special case where zero is excluded from the subtype, in which
5690 case all zero bits are used. This choice will always generate an
5691 invalid value if one exists.
5692
5693 @item @emph{Enumeration types}
5694
5695 Objects of an enumeration type are initialized to all one-bits, i.e., to
5696 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
5697 whose Pos value is zero, in which case a code of zero is used. This choice
5698 will always generate an invalid value if one exists.
5699 @end table
5700
5701 @node Pragma Obsolescent,Pragma Optimize_Alignment,Pragma Normalize_Scalars,Implementation Defined Pragmas
5702 @anchor{gnat_rm/implementation_defined_pragmas pragma-obsolescent}@anchor{af}@anchor{gnat_rm/implementation_defined_pragmas id27}@anchor{b0}
5703 @section Pragma Obsolescent
5704
5705
5706 Syntax:
5707
5708 @example
5709 pragma Obsolescent;
5710
5711 pragma Obsolescent (
5712 [Message =>] static_string_EXPRESSION
5713 [,[Version =>] Ada_05]]);
5714
5715 pragma Obsolescent (
5716 [Entity =>] NAME
5717 [,[Message =>] static_string_EXPRESSION
5718 [,[Version =>] Ada_05]] );
5719 @end example
5720
5721 This pragma can occur immediately following a declaration of an entity,
5722 including the case of a record component. If no Entity argument is present,
5723 then this declaration is the one to which the pragma applies. If an Entity
5724 parameter is present, it must either match the name of the entity in this
5725 declaration, or alternatively, the pragma can immediately follow an enumeration
5726 type declaration, where the Entity argument names one of the enumeration
5727 literals.
5728
5729 This pragma is used to indicate that the named entity
5730 is considered obsolescent and should not be used. Typically this is
5731 used when an API must be modified by eventually removing or modifying
5732 existing subprograms or other entities. The pragma can be used at an
5733 intermediate stage when the entity is still present, but will be
5734 removed later.
5735
5736 The effect of this pragma is to output a warning message on a reference to
5737 an entity thus marked that the subprogram is obsolescent if the appropriate
5738 warning option in the compiler is activated. If the @code{Message} parameter is
5739 present, then a second warning message is given containing this text. In
5740 addition, a reference to the entity is considered to be a violation of pragma
5741 @code{Restrictions (No_Obsolescent_Features)}.
5742
5743 This pragma can also be used as a program unit pragma for a package,
5744 in which case the entity name is the name of the package, and the
5745 pragma indicates that the entire package is considered
5746 obsolescent. In this case a client @code{with}ing such a package
5747 violates the restriction, and the @code{with} clause is
5748 flagged with warnings if the warning option is set.
5749
5750 If the @code{Version} parameter is present (which must be exactly
5751 the identifier @code{Ada_05}, no other argument is allowed), then the
5752 indication of obsolescence applies only when compiling in Ada 2005
5753 mode. This is primarily intended for dealing with the situations
5754 in the predefined library where subprograms or packages
5755 have become defined as obsolescent in Ada 2005
5756 (e.g., in @code{Ada.Characters.Handling}), but may be used anywhere.
5757
5758 The following examples show typical uses of this pragma:
5759
5760 @example
5761 package p is
5762 pragma Obsolescent (p, Message => "use pp instead of p");
5763 end p;
5764
5765 package q is
5766 procedure q2;
5767 pragma Obsolescent ("use q2new instead");
5768
5769 type R is new integer;
5770 pragma Obsolescent
5771 (Entity => R,
5772 Message => "use RR in Ada 2005",
5773 Version => Ada_05);
5774
5775 type M is record
5776 F1 : Integer;
5777 F2 : Integer;
5778 pragma Obsolescent;
5779 F3 : Integer;
5780 end record;
5781
5782 type E is (a, bc, 'd', quack);
5783 pragma Obsolescent (Entity => bc)
5784 pragma Obsolescent (Entity => 'd')
5785
5786 function "+"
5787 (a, b : character) return character;
5788 pragma Obsolescent (Entity => "+");
5789 end;
5790 @end example
5791
5792 Note that, as for all pragmas, if you use a pragma argument identifier,
5793 then all subsequent parameters must also use a pragma argument identifier.
5794 So if you specify @code{Entity =>} for the @code{Entity} argument, and a @code{Message}
5795 argument is present, it must be preceded by @code{Message =>}.
5796
5797 @node Pragma Optimize_Alignment,Pragma Ordered,Pragma Obsolescent,Implementation Defined Pragmas
5798 @anchor{gnat_rm/implementation_defined_pragmas pragma-optimize-alignment}@anchor{b1}
5799 @section Pragma Optimize_Alignment
5800
5801
5802 @geindex Alignment
5803 @geindex default settings
5804
5805 Syntax:
5806
5807 @example
5808 pragma Optimize_Alignment (TIME | SPACE | OFF);
5809 @end example
5810
5811 This is a configuration pragma which affects the choice of default alignments
5812 for types and objects where no alignment is explicitly specified. There is a
5813 time/space trade-off in the selection of these values. Large alignments result
5814 in more efficient code, at the expense of larger data space, since sizes have
5815 to be increased to match these alignments. Smaller alignments save space, but
5816 the access code is slower. The normal choice of default alignments for types
5817 and individual alignment promotions for objects (which is what you get if you
5818 do not use this pragma, or if you use an argument of OFF), tries to balance
5819 these two requirements.
5820
5821 Specifying SPACE causes smaller default alignments to be chosen in two cases.
5822 First any packed record is given an alignment of 1. Second, if a size is given
5823 for the type, then the alignment is chosen to avoid increasing this size. For
5824 example, consider:
5825
5826 @example
5827 type R is record
5828 X : Integer;
5829 Y : Character;
5830 end record;
5831
5832 for R'Size use 5*8;
5833 @end example
5834
5835 In the default mode, this type gets an alignment of 4, so that access to the
5836 Integer field X are efficient. But this means that objects of the type end up
5837 with a size of 8 bytes. This is a valid choice, since sizes of objects are
5838 allowed to be bigger than the size of the type, but it can waste space if for
5839 example fields of type R appear in an enclosing record. If the above type is
5840 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
5841
5842 However, there is one case in which SPACE is ignored. If a variable length
5843 record (that is a discriminated record with a component which is an array
5844 whose length depends on a discriminant), has a pragma Pack, then it is not
5845 in general possible to set the alignment of such a record to one, so the
5846 pragma is ignored in this case (with a warning).
5847
5848 Specifying SPACE also disables alignment promotions for standalone objects,
5849 which occur when the compiler increases the alignment of a specific object
5850 without changing the alignment of its type.
5851
5852 Specifying SPACE also disables component reordering in unpacked record types,
5853 which can result in larger sizes in order to meet alignment requirements.
5854
5855 Specifying TIME causes larger default alignments to be chosen in the case of
5856 small types with sizes that are not a power of 2. For example, consider:
5857
5858 @example
5859 type R is record
5860 A : Character;
5861 B : Character;
5862 C : Boolean;
5863 end record;
5864
5865 pragma Pack (R);
5866 for R'Size use 17;
5867 @end example
5868
5869 The default alignment for this record is normally 1, but if this type is
5870 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
5871 to 4, which wastes space for objects of the type, since they are now 4 bytes
5872 long, but results in more efficient access when the whole record is referenced.
5873
5874 As noted above, this is a configuration pragma, and there is a requirement
5875 that all units in a partition be compiled with a consistent setting of the
5876 optimization setting. This would normally be achieved by use of a configuration
5877 pragma file containing the appropriate setting. The exception to this rule is
5878 that units with an explicit configuration pragma in the same file as the source
5879 unit are excluded from the consistency check, as are all predefined units. The
5880 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
5881 pragma appears at the start of the file.
5882
5883 @node Pragma Ordered,Pragma Overflow_Mode,Pragma Optimize_Alignment,Implementation Defined Pragmas
5884 @anchor{gnat_rm/implementation_defined_pragmas pragma-ordered}@anchor{b2}
5885 @section Pragma Ordered
5886
5887
5888 Syntax:
5889
5890 @example
5891 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
5892 @end example
5893
5894 Most enumeration types are from a conceptual point of view unordered.
5895 For example, consider:
5896
5897 @example
5898 type Color is (Red, Blue, Green, Yellow);
5899 @end example
5900
5901 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
5902 but really these relations make no sense; the enumeration type merely
5903 specifies a set of possible colors, and the order is unimportant.
5904
5905 For unordered enumeration types, it is generally a good idea if
5906 clients avoid comparisons (other than equality or inequality) and
5907 explicit ranges. (A @emph{client} is a unit where the type is referenced,
5908 other than the unit where the type is declared, its body, and its subunits.)
5909 For example, if code buried in some client says:
5910
5911 @example
5912 if Current_Color < Yellow then ...
5913 if Current_Color in Blue .. Green then ...
5914 @end example
5915
5916 then the client code is relying on the order, which is undesirable.
5917 It makes the code hard to read and creates maintenance difficulties if
5918 entries have to be added to the enumeration type. Instead,
5919 the code in the client should list the possibilities, or an
5920 appropriate subtype should be declared in the unit that declares
5921 the original enumeration type. E.g., the following subtype could
5922 be declared along with the type @code{Color}:
5923
5924 @example
5925 subtype RBG is Color range Red .. Green;
5926 @end example
5927
5928 and then the client could write:
5929
5930 @example
5931 if Current_Color in RBG then ...
5932 if Current_Color = Blue or Current_Color = Green then ...
5933 @end example
5934
5935 However, some enumeration types are legitimately ordered from a conceptual
5936 point of view. For example, if you declare:
5937
5938 @example
5939 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
5940 @end example
5941
5942 then the ordering imposed by the language is reasonable, and
5943 clients can depend on it, writing for example:
5944
5945 @example
5946 if D in Mon .. Fri then ...
5947 if D < Wed then ...
5948 @end example
5949
5950 The pragma @emph{Ordered} is provided to mark enumeration types that
5951 are conceptually ordered, alerting the reader that clients may depend
5952 on the ordering. GNAT provides a pragma to mark enumerations as ordered
5953 rather than one to mark them as unordered, since in our experience,
5954 the great majority of enumeration types are conceptually unordered.
5955
5956 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
5957 and @code{Wide_Wide_Character}
5958 are considered to be ordered types, so each is declared with a
5959 pragma @code{Ordered} in package @code{Standard}.
5960
5961 Normally pragma @code{Ordered} serves only as documentation and a guide for
5962 coding standards, but GNAT provides a warning switch @emph{-gnatw.u} that
5963 requests warnings for inappropriate uses (comparisons and explicit
5964 subranges) for unordered types. If this switch is used, then any
5965 enumeration type not marked with pragma @code{Ordered} will be considered
5966 as unordered, and will generate warnings for inappropriate uses.
5967
5968 Note that generic types are not considered ordered or unordered (since the
5969 template can be instantiated for both cases), so we never generate warnings
5970 for the case of generic enumerated types.
5971
5972 For additional information please refer to the description of the
5973 @emph{-gnatw.u} switch in the GNAT User's Guide.
5974
5975 @node Pragma Overflow_Mode,Pragma Overriding_Renamings,Pragma Ordered,Implementation Defined Pragmas
5976 @anchor{gnat_rm/implementation_defined_pragmas pragma-overflow-mode}@anchor{b3}
5977 @section Pragma Overflow_Mode
5978
5979
5980 Syntax:
5981
5982 @example
5983 pragma Overflow_Mode
5984 ( [General =>] MODE
5985 [,[Assertions =>] MODE]);
5986
5987 MODE ::= STRICT | MINIMIZED | ELIMINATED
5988 @end example
5989
5990 This pragma sets the current overflow mode to the given setting. For details
5991 of the meaning of these modes, please refer to the
5992 'Overflow Check Handling in GNAT' appendix in the
5993 GNAT User's Guide. If only the @code{General} parameter is present,
5994 the given mode applies to all expressions. If both parameters are present,
5995 the @code{General} mode applies to expressions outside assertions, and
5996 the @code{Eliminated} mode applies to expressions within assertions.
5997
5998 The case of the @code{MODE} parameter is ignored,
5999 so @code{MINIMIZED}, @code{Minimized} and
6000 @code{minimized} all have the same effect.
6001
6002 The @code{Overflow_Mode} pragma has the same scoping and placement
6003 rules as pragma @code{Suppress}, so it can occur either as a
6004 configuration pragma, specifying a default for the whole
6005 program, or in a declarative scope, where it applies to the
6006 remaining declarations and statements in that scope.
6007
6008 The pragma @code{Suppress (Overflow_Check)} suppresses
6009 overflow checking, but does not affect the overflow mode.
6010
6011 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
6012 overflow checking, but does not affect the overflow mode.
6013
6014 @node Pragma Overriding_Renamings,Pragma Partition_Elaboration_Policy,Pragma Overflow_Mode,Implementation Defined Pragmas
6015 @anchor{gnat_rm/implementation_defined_pragmas pragma-overriding-renamings}@anchor{b4}
6016 @section Pragma Overriding_Renamings
6017
6018
6019 @geindex Rational profile
6020
6021 @geindex Rational compatibility
6022
6023 Syntax:
6024
6025 @example
6026 pragma Overriding_Renamings;
6027 @end example
6028
6029 This is a GNAT configuration pragma to simplify porting
6030 legacy code accepted by the Rational
6031 Ada compiler. In the presence of this pragma, a renaming declaration that
6032 renames an inherited operation declared in the same scope is legal if selected
6033 notation is used as in:
6034
6035 @example
6036 pragma Overriding_Renamings;
6037 ...
6038 package R is
6039 function F (..);
6040 ...
6041 function F (..) renames R.F;
6042 end R;
6043 @end example
6044
6045 even though
6046 RM 8.3 (15) stipulates that an overridden operation is not visible within the
6047 declaration of the overriding operation.
6048
6049 @node Pragma Partition_Elaboration_Policy,Pragma Part_Of,Pragma Overriding_Renamings,Implementation Defined Pragmas
6050 @anchor{gnat_rm/implementation_defined_pragmas pragma-partition-elaboration-policy}@anchor{b5}
6051 @section Pragma Partition_Elaboration_Policy
6052
6053
6054 Syntax:
6055
6056 @example
6057 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
6058
6059 POLICY_IDENTIFIER ::= Concurrent | Sequential
6060 @end example
6061
6062 This pragma is standard in Ada 2005, but is available in all earlier
6063 versions of Ada as an implementation-defined pragma.
6064 See Ada 2012 Reference Manual for details.
6065
6066 @node Pragma Part_Of,Pragma Passive,Pragma Partition_Elaboration_Policy,Implementation Defined Pragmas
6067 @anchor{gnat_rm/implementation_defined_pragmas id28}@anchor{b6}@anchor{gnat_rm/implementation_defined_pragmas pragma-part-of}@anchor{b7}
6068 @section Pragma Part_Of
6069
6070
6071 Syntax:
6072
6073 @example
6074 pragma Part_Of (ABSTRACT_STATE);
6075
6076 ABSTRACT_STATE ::= NAME
6077 @end example
6078
6079 For the semantics of this pragma, see the entry for aspect @code{Part_Of} in the
6080 SPARK 2014 Reference Manual, section 7.2.6.
6081
6082 @node Pragma Passive,Pragma Persistent_BSS,Pragma Part_Of,Implementation Defined Pragmas
6083 @anchor{gnat_rm/implementation_defined_pragmas pragma-passive}@anchor{b8}
6084 @section Pragma Passive
6085
6086
6087 Syntax:
6088
6089 @example
6090 pragma Passive [(Semaphore | No)];
6091 @end example
6092
6093 Syntax checked, but otherwise ignored by GNAT. This is recognized for
6094 compatibility with DEC Ada 83 implementations, where it is used within a
6095 task definition to request that a task be made passive. If the argument
6096 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
6097 treats the pragma as an assertion that the containing task is passive
6098 and that optimization of context switch with this task is permitted and
6099 desired. If the argument @code{No} is present, the task must not be
6100 optimized. GNAT does not attempt to optimize any tasks in this manner
6101 (since protected objects are available in place of passive tasks).
6102
6103 For more information on the subject of passive tasks, see the section
6104 'Passive Task Optimization' in the GNAT Users Guide.
6105
6106 @node Pragma Persistent_BSS,Pragma Polling,Pragma Passive,Implementation Defined Pragmas
6107 @anchor{gnat_rm/implementation_defined_pragmas id29}@anchor{b9}@anchor{gnat_rm/implementation_defined_pragmas pragma-persistent-bss}@anchor{ba}
6108 @section Pragma Persistent_BSS
6109
6110
6111 Syntax:
6112
6113 @example
6114 pragma Persistent_BSS [(LOCAL_NAME)]
6115 @end example
6116
6117 This pragma allows selected objects to be placed in the @code{.persistent_bss}
6118 section. On some targets the linker and loader provide for special
6119 treatment of this section, allowing a program to be reloaded without
6120 affecting the contents of this data (hence the name persistent).
6121
6122 There are two forms of usage. If an argument is given, it must be the
6123 local name of a library-level object, with no explicit initialization
6124 and whose type is potentially persistent. If no argument is given, then
6125 the pragma is a configuration pragma, and applies to all library-level
6126 objects with no explicit initialization of potentially persistent types.
6127
6128 A potentially persistent type is a scalar type, or an untagged,
6129 non-discriminated record, all of whose components have no explicit
6130 initialization and are themselves of a potentially persistent type,
6131 or an array, all of whose constraints are static, and whose component
6132 type is potentially persistent.
6133
6134 If this pragma is used on a target where this feature is not supported,
6135 then the pragma will be ignored. See also @code{pragma Linker_Section}.
6136
6137 @node Pragma Polling,Pragma Post,Pragma Persistent_BSS,Implementation Defined Pragmas
6138 @anchor{gnat_rm/implementation_defined_pragmas pragma-polling}@anchor{bb}
6139 @section Pragma Polling
6140
6141
6142 Syntax:
6143
6144 @example
6145 pragma Polling (ON | OFF);
6146 @end example
6147
6148 This pragma controls the generation of polling code. This is normally off.
6149 If @code{pragma Polling (ON)} is used then periodic calls are generated to
6150 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
6151 runtime library, and can be found in file @code{a-excpol.adb}.
6152
6153 Pragma @code{Polling} can appear as a configuration pragma (for example it
6154 can be placed in the @code{gnat.adc} file) to enable polling globally, or it
6155 can be used in the statement or declaration sequence to control polling
6156 more locally.
6157
6158 A call to the polling routine is generated at the start of every loop and
6159 at the start of every subprogram call. This guarantees that the @code{Poll}
6160 routine is called frequently, and places an upper bound (determined by
6161 the complexity of the code) on the period between two @code{Poll} calls.
6162
6163 The primary purpose of the polling interface is to enable asynchronous
6164 aborts on targets that cannot otherwise support it (for example Windows
6165 NT), but it may be used for any other purpose requiring periodic polling.
6166 The standard version is null, and can be replaced by a user program. This
6167 will require re-compilation of the @code{Ada.Exceptions} package that can
6168 be found in files @code{a-except.ads} and @code{a-except.adb}.
6169
6170 A standard alternative unit (in file @code{4wexcpol.adb} in the standard GNAT
6171 distribution) is used to enable the asynchronous abort capability on
6172 targets that do not normally support the capability. The version of
6173 @code{Poll} in this file makes a call to the appropriate runtime routine
6174 to test for an abort condition.
6175
6176 Note that polling can also be enabled by use of the @emph{-gnatP} switch.
6177 See the section on switches for gcc in the @cite{GNAT User's Guide}.
6178
6179 @node Pragma Post,Pragma Postcondition,Pragma Polling,Implementation Defined Pragmas
6180 @anchor{gnat_rm/implementation_defined_pragmas pragma-post}@anchor{bc}
6181 @section Pragma Post
6182
6183
6184 @geindex Post
6185
6186 @geindex Checks
6187 @geindex postconditions
6188
6189 Syntax:
6190
6191 @example
6192 pragma Post (Boolean_Expression);
6193 @end example
6194
6195 The @code{Post} pragma is intended to be an exact replacement for
6196 the language-defined
6197 @code{Post} aspect, and shares its restrictions and semantics.
6198 It must appear either immediately following the corresponding
6199 subprogram declaration (only other pragmas may intervene), or
6200 if there is no separate subprogram declaration, then it can
6201 appear at the start of the declarations in a subprogram body
6202 (preceded only by other pragmas).
6203
6204 @node Pragma Postcondition,Pragma Post_Class,Pragma Post,Implementation Defined Pragmas
6205 @anchor{gnat_rm/implementation_defined_pragmas pragma-postcondition}@anchor{bd}
6206 @section Pragma Postcondition
6207
6208
6209 @geindex Postcondition
6210
6211 @geindex Checks
6212 @geindex postconditions
6213
6214 Syntax:
6215
6216 @example
6217 pragma Postcondition (
6218 [Check =>] Boolean_Expression
6219 [,[Message =>] String_Expression]);
6220 @end example
6221
6222 The @code{Postcondition} pragma allows specification of automatic
6223 postcondition checks for subprograms. These checks are similar to
6224 assertions, but are automatically inserted just prior to the return
6225 statements of the subprogram with which they are associated (including
6226 implicit returns at the end of procedure bodies and associated
6227 exception handlers).
6228
6229 In addition, the boolean expression which is the condition which
6230 must be true may contain references to function'Result in the case
6231 of a function to refer to the returned value.
6232
6233 @code{Postcondition} pragmas may appear either immediately following the
6234 (separate) declaration of a subprogram, or at the start of the
6235 declarations of a subprogram body. Only other pragmas may intervene
6236 (that is appear between the subprogram declaration and its
6237 postconditions, or appear before the postcondition in the
6238 declaration sequence in a subprogram body). In the case of a
6239 postcondition appearing after a subprogram declaration, the
6240 formal arguments of the subprogram are visible, and can be
6241 referenced in the postcondition expressions.
6242
6243 The postconditions are collected and automatically tested just
6244 before any return (implicit or explicit) in the subprogram body.
6245 A postcondition is only recognized if postconditions are active
6246 at the time the pragma is encountered. The compiler switch @emph{gnata}
6247 turns on all postconditions by default, and pragma @code{Check_Policy}
6248 with an identifier of @code{Postcondition} can also be used to
6249 control whether postconditions are active.
6250
6251 The general approach is that postconditions are placed in the spec
6252 if they represent functional aspects which make sense to the client.
6253 For example we might have:
6254
6255 @example
6256 function Direction return Integer;
6257 pragma Postcondition
6258 (Direction'Result = +1
6259 or else
6260 Direction'Result = -1);
6261 @end example
6262
6263 which serves to document that the result must be +1 or -1, and
6264 will test that this is the case at run time if postcondition
6265 checking is active.
6266
6267 Postconditions within the subprogram body can be used to
6268 check that some internal aspect of the implementation,
6269 not visible to the client, is operating as expected.
6270 For instance if a square root routine keeps an internal
6271 counter of the number of times it is called, then we
6272 might have the following postcondition:
6273
6274 @example
6275 Sqrt_Calls : Natural := 0;
6276
6277 function Sqrt (Arg : Float) return Float is
6278 pragma Postcondition
6279 (Sqrt_Calls = Sqrt_Calls'Old + 1);
6280 ...
6281 end Sqrt
6282 @end example
6283
6284 As this example, shows, the use of the @code{Old} attribute
6285 is often useful in postconditions to refer to the state on
6286 entry to the subprogram.
6287
6288 Note that postconditions are only checked on normal returns
6289 from the subprogram. If an abnormal return results from
6290 raising an exception, then the postconditions are not checked.
6291
6292 If a postcondition fails, then the exception
6293 @code{System.Assertions.Assert_Failure} is raised. If
6294 a message argument was supplied, then the given string
6295 will be used as the exception message. If no message
6296 argument was supplied, then the default message has
6297 the form "Postcondition failed at file_name:line". The
6298 exception is raised in the context of the subprogram
6299 body, so it is possible to catch postcondition failures
6300 within the subprogram body itself.
6301
6302 Within a package spec, normal visibility rules
6303 in Ada would prevent forward references within a
6304 postcondition pragma to functions defined later in
6305 the same package. This would introduce undesirable
6306 ordering constraints. To avoid this problem, all
6307 postcondition pragmas are analyzed at the end of
6308 the package spec, allowing forward references.
6309
6310 The following example shows that this even allows
6311 mutually recursive postconditions as in:
6312
6313 @example
6314 package Parity_Functions is
6315 function Odd (X : Natural) return Boolean;
6316 pragma Postcondition
6317 (Odd'Result =
6318 (x = 1
6319 or else
6320 (x /= 0 and then Even (X - 1))));
6321
6322 function Even (X : Natural) return Boolean;
6323 pragma Postcondition
6324 (Even'Result =
6325 (x = 0
6326 or else
6327 (x /= 1 and then Odd (X - 1))));
6328
6329 end Parity_Functions;
6330 @end example
6331
6332 There are no restrictions on the complexity or form of
6333 conditions used within @code{Postcondition} pragmas.
6334 The following example shows that it is even possible
6335 to verify performance behavior.
6336
6337 @example
6338 package Sort is
6339
6340 Performance : constant Float;
6341 -- Performance constant set by implementation
6342 -- to match target architecture behavior.
6343
6344 procedure Treesort (Arg : String);
6345 -- Sorts characters of argument using N*logN sort
6346 pragma Postcondition
6347 (Float (Clock - Clock'Old) <=
6348 Float (Arg'Length) *
6349 log (Float (Arg'Length)) *
6350 Performance);
6351 end Sort;
6352 @end example
6353
6354 Note: postcondition pragmas associated with subprograms that are
6355 marked as Inline_Always, or those marked as Inline with front-end
6356 inlining (-gnatN option set) are accepted and legality-checked
6357 by the compiler, but are ignored at run-time even if postcondition
6358 checking is enabled.
6359
6360 Note that pragma @code{Postcondition} differs from the language-defined
6361 @code{Post} aspect (and corresponding @code{Post} pragma) in allowing
6362 multiple occurrences, allowing occurences in the body even if there
6363 is a separate spec, and allowing a second string parameter, and the
6364 use of the pragma identifier @code{Check}. Historically, pragma
6365 @code{Postcondition} was implemented prior to the development of
6366 Ada 2012, and has been retained in its original form for
6367 compatibility purposes.
6368
6369 @node Pragma Post_Class,Pragma Rename_Pragma,Pragma Postcondition,Implementation Defined Pragmas
6370 @anchor{gnat_rm/implementation_defined_pragmas pragma-post-class}@anchor{be}
6371 @section Pragma Post_Class
6372
6373
6374 @geindex Post
6375
6376 @geindex Checks
6377 @geindex postconditions
6378
6379 Syntax:
6380
6381 @example
6382 pragma Post_Class (Boolean_Expression);
6383 @end example
6384
6385 The @code{Post_Class} pragma is intended to be an exact replacement for
6386 the language-defined
6387 @code{Post'Class} aspect, and shares its restrictions and semantics.
6388 It must appear either immediately following the corresponding
6389 subprogram declaration (only other pragmas may intervene), or
6390 if there is no separate subprogram declaration, then it can
6391 appear at the start of the declarations in a subprogram body
6392 (preceded only by other pragmas).
6393
6394 Note: This pragma is called @code{Post_Class} rather than
6395 @code{Post'Class} because the latter would not be strictly
6396 conforming to the allowed syntax for pragmas. The motivation
6397 for provinding pragmas equivalent to the aspects is to allow a program
6398 to be written using the pragmas, and then compiled if necessary
6399 using an Ada compiler that does not recognize the pragmas or
6400 aspects, but is prepared to ignore the pragmas. The assertion
6401 policy that controls this pragma is @code{Post'Class}, not
6402 @code{Post_Class}.
6403
6404 @node Pragma Rename_Pragma,Pragma Pre,Pragma Post_Class,Implementation Defined Pragmas
6405 @anchor{gnat_rm/implementation_defined_pragmas pragma-rename-pragma}@anchor{bf}
6406 @section Pragma Rename_Pragma
6407
6408
6409 @geindex Pragmas
6410 @geindex synonyms
6411
6412 Syntax:
6413
6414 @example
6415 pragma Rename_Pragma (
6416 [New_Name =>] IDENTIFIER,
6417 [Renamed =>] pragma_IDENTIFIER);
6418 @end example
6419
6420 This pragma provides a mechanism for supplying new names for existing
6421 pragmas. The @code{New_Name} identifier can subsequently be used as a synonym for
6422 the Renamed pragma. For example, suppose you have code that was originally
6423 developed on a compiler that supports Inline_Only as an implementation defined
6424 pragma. And suppose the semantics of pragma Inline_Only are identical to (or at
6425 least very similar to) the GNAT implementation defined pragma
6426 Inline_Always. You could globally replace Inline_Only with Inline_Always.
6427
6428 However, to avoid that source modification, you could instead add a
6429 configuration pragma:
6430
6431 @example
6432 pragma Rename_Pragma (
6433 New_Name => Inline_Only,
6434 Renamed => Inline_Always);
6435 @end example
6436
6437 Then GNAT will treat "pragma Inline_Only ..." as if you had written
6438 "pragma Inline_Always ...".
6439
6440 Pragma Inline_Only will not necessarily mean the same thing as the other Ada
6441 compiler; it's up to you to make sure the semantics are close enough.
6442
6443 @node Pragma Pre,Pragma Precondition,Pragma Rename_Pragma,Implementation Defined Pragmas
6444 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre}@anchor{c0}
6445 @section Pragma Pre
6446
6447
6448 @geindex Pre
6449
6450 @geindex Checks
6451 @geindex preconditions
6452
6453 Syntax:
6454
6455 @example
6456 pragma Pre (Boolean_Expression);
6457 @end example
6458
6459 The @code{Pre} pragma is intended to be an exact replacement for
6460 the language-defined
6461 @code{Pre} aspect, and shares its restrictions and semantics.
6462 It must appear either immediately following the corresponding
6463 subprogram declaration (only other pragmas may intervene), or
6464 if there is no separate subprogram declaration, then it can
6465 appear at the start of the declarations in a subprogram body
6466 (preceded only by other pragmas).
6467
6468 @node Pragma Precondition,Pragma Predicate,Pragma Pre,Implementation Defined Pragmas
6469 @anchor{gnat_rm/implementation_defined_pragmas pragma-precondition}@anchor{c1}
6470 @section Pragma Precondition
6471
6472
6473 @geindex Preconditions
6474
6475 @geindex Checks
6476 @geindex preconditions
6477
6478 Syntax:
6479
6480 @example
6481 pragma Precondition (
6482 [Check =>] Boolean_Expression
6483 [,[Message =>] String_Expression]);
6484 @end example
6485
6486 The @code{Precondition} pragma is similar to @code{Postcondition}
6487 except that the corresponding checks take place immediately upon
6488 entry to the subprogram, and if a precondition fails, the exception
6489 is raised in the context of the caller, and the attribute 'Result
6490 cannot be used within the precondition expression.
6491
6492 Otherwise, the placement and visibility rules are identical to those
6493 described for postconditions. The following is an example of use
6494 within a package spec:
6495
6496 @example
6497 package Math_Functions is
6498 ...
6499 function Sqrt (Arg : Float) return Float;
6500 pragma Precondition (Arg >= 0.0)
6501 ...
6502 end Math_Functions;
6503 @end example
6504
6505 @code{Precondition} pragmas may appear either immediately following the
6506 (separate) declaration of a subprogram, or at the start of the
6507 declarations of a subprogram body. Only other pragmas may intervene
6508 (that is appear between the subprogram declaration and its
6509 postconditions, or appear before the postcondition in the
6510 declaration sequence in a subprogram body).
6511
6512 Note: precondition pragmas associated with subprograms that are
6513 marked as Inline_Always, or those marked as Inline with front-end
6514 inlining (-gnatN option set) are accepted and legality-checked
6515 by the compiler, but are ignored at run-time even if precondition
6516 checking is enabled.
6517
6518 Note that pragma @code{Precondition} differs from the language-defined
6519 @code{Pre} aspect (and corresponding @code{Pre} pragma) in allowing
6520 multiple occurrences, allowing occurences in the body even if there
6521 is a separate spec, and allowing a second string parameter, and the
6522 use of the pragma identifier @code{Check}. Historically, pragma
6523 @code{Precondition} was implemented prior to the development of
6524 Ada 2012, and has been retained in its original form for
6525 compatibility purposes.
6526
6527 @node Pragma Predicate,Pragma Predicate_Failure,Pragma Precondition,Implementation Defined Pragmas
6528 @anchor{gnat_rm/implementation_defined_pragmas pragma-predicate}@anchor{c2}@anchor{gnat_rm/implementation_defined_pragmas id30}@anchor{c3}
6529 @section Pragma Predicate
6530
6531
6532 Syntax:
6533
6534 @example
6535 pragma Predicate
6536 ([Entity =>] type_LOCAL_NAME,
6537 [Check =>] EXPRESSION);
6538 @end example
6539
6540 This pragma (available in all versions of Ada in GNAT) encompasses both
6541 the @code{Static_Predicate} and @code{Dynamic_Predicate} aspects in
6542 Ada 2012. A predicate is regarded as static if it has an allowed form
6543 for @code{Static_Predicate} and is otherwise treated as a
6544 @code{Dynamic_Predicate}. Otherwise, predicates specified by this
6545 pragma behave exactly as described in the Ada 2012 reference manual.
6546 For example, if we have
6547
6548 @example
6549 type R is range 1 .. 10;
6550 subtype S is R;
6551 pragma Predicate (Entity => S, Check => S not in 4 .. 6);
6552 subtype Q is R
6553 pragma Predicate (Entity => Q, Check => F(Q) or G(Q));
6554 @end example
6555
6556 the effect is identical to the following Ada 2012 code:
6557
6558 @example
6559 type R is range 1 .. 10;
6560 subtype S is R with
6561 Static_Predicate => S not in 4 .. 6;
6562 subtype Q is R with
6563 Dynamic_Predicate => F(Q) or G(Q);
6564 @end example
6565
6566 Note that there are no pragmas @code{Dynamic_Predicate}
6567 or @code{Static_Predicate}. That is
6568 because these pragmas would affect legality and semantics of
6569 the program and thus do not have a neutral effect if ignored.
6570 The motivation behind providing pragmas equivalent to
6571 corresponding aspects is to allow a program to be written
6572 using the pragmas, and then compiled with a compiler that
6573 will ignore the pragmas. That doesn't work in the case of
6574 static and dynamic predicates, since if the corresponding
6575 pragmas are ignored, then the behavior of the program is
6576 fundamentally changed (for example a membership test
6577 @code{A in B} would not take into account a predicate
6578 defined for subtype B). When following this approach, the
6579 use of predicates should be avoided.
6580
6581 @node Pragma Predicate_Failure,Pragma Preelaborable_Initialization,Pragma Predicate,Implementation Defined Pragmas
6582 @anchor{gnat_rm/implementation_defined_pragmas pragma-predicate-failure}@anchor{c4}
6583 @section Pragma Predicate_Failure
6584
6585
6586 Syntax:
6587
6588 @example
6589 pragma Predicate_Failure
6590 ([Entity =>] type_LOCAL_NAME,
6591 [Message =>] String_Expression);
6592 @end example
6593
6594 The @code{Predicate_Failure} pragma is intended to be an exact replacement for
6595 the language-defined
6596 @code{Predicate_Failure} aspect, and shares its restrictions and semantics.
6597
6598 @node Pragma Preelaborable_Initialization,Pragma Prefix_Exception_Messages,Pragma Predicate_Failure,Implementation Defined Pragmas
6599 @anchor{gnat_rm/implementation_defined_pragmas pragma-preelaborable-initialization}@anchor{c5}
6600 @section Pragma Preelaborable_Initialization
6601
6602
6603 Syntax:
6604
6605 @example
6606 pragma Preelaborable_Initialization (DIRECT_NAME);
6607 @end example
6608
6609 This pragma is standard in Ada 2005, but is available in all earlier
6610 versions of Ada as an implementation-defined pragma.
6611 See Ada 2012 Reference Manual for details.
6612
6613 @node Pragma Prefix_Exception_Messages,Pragma Pre_Class,Pragma Preelaborable_Initialization,Implementation Defined Pragmas
6614 @anchor{gnat_rm/implementation_defined_pragmas pragma-prefix-exception-messages}@anchor{c6}
6615 @section Pragma Prefix_Exception_Messages
6616
6617
6618 @geindex Prefix_Exception_Messages
6619
6620 @geindex exception
6621
6622 @geindex Exception_Message
6623
6624 Syntax:
6625
6626 @example
6627 pragma Prefix_Exception_Messages;
6628 @end example
6629
6630 This is an implementation-defined configuration pragma that affects the
6631 behavior of raise statements with a message given as a static string
6632 constant (typically a string literal). In such cases, the string will
6633 be automatically prefixed by the name of the enclosing entity (giving
6634 the package and subprogram containing the raise statement). This helps
6635 to identify where messages are coming from, and this mode is automatic
6636 for the run-time library.
6637
6638 The pragma has no effect if the message is computed with an expression other
6639 than a static string constant, since the assumption in this case is that
6640 the program computes exactly the string it wants. If you still want the
6641 prefixing in this case, you can always call
6642 @code{GNAT.Source_Info.Enclosing_Entity} and prepend the string manually.
6643
6644 @node Pragma Pre_Class,Pragma Priority_Specific_Dispatching,Pragma Prefix_Exception_Messages,Implementation Defined Pragmas
6645 @anchor{gnat_rm/implementation_defined_pragmas pragma-pre-class}@anchor{c7}
6646 @section Pragma Pre_Class
6647
6648
6649 @geindex Pre_Class
6650
6651 @geindex Checks
6652 @geindex preconditions
6653
6654 Syntax:
6655
6656 @example
6657 pragma Pre_Class (Boolean_Expression);
6658 @end example
6659
6660 The @code{Pre_Class} pragma is intended to be an exact replacement for
6661 the language-defined
6662 @code{Pre'Class} aspect, and shares its restrictions and semantics.
6663 It must appear either immediately following the corresponding
6664 subprogram declaration (only other pragmas may intervene), or
6665 if there is no separate subprogram declaration, then it can
6666 appear at the start of the declarations in a subprogram body
6667 (preceded only by other pragmas).
6668
6669 Note: This pragma is called @code{Pre_Class} rather than
6670 @code{Pre'Class} because the latter would not be strictly
6671 conforming to the allowed syntax for pragmas. The motivation
6672 for providing pragmas equivalent to the aspects is to allow a program
6673 to be written using the pragmas, and then compiled if necessary
6674 using an Ada compiler that does not recognize the pragmas or
6675 aspects, but is prepared to ignore the pragmas. The assertion
6676 policy that controls this pragma is @code{Pre'Class}, not
6677 @code{Pre_Class}.
6678
6679 @node Pragma Priority_Specific_Dispatching,Pragma Profile,Pragma Pre_Class,Implementation Defined Pragmas
6680 @anchor{gnat_rm/implementation_defined_pragmas pragma-priority-specific-dispatching}@anchor{c8}
6681 @section Pragma Priority_Specific_Dispatching
6682
6683
6684 Syntax:
6685
6686 @example
6687 pragma Priority_Specific_Dispatching (
6688 POLICY_IDENTIFIER,
6689 first_priority_EXPRESSION,
6690 last_priority_EXPRESSION)
6691
6692 POLICY_IDENTIFIER ::=
6693 EDF_Across_Priorities |
6694 FIFO_Within_Priorities |
6695 Non_Preemptive_Within_Priorities |
6696 Round_Robin_Within_Priorities
6697 @end example
6698
6699 This pragma is standard in Ada 2005, but is available in all earlier
6700 versions of Ada as an implementation-defined pragma.
6701 See Ada 2012 Reference Manual for details.
6702
6703 @node Pragma Profile,Pragma Profile_Warnings,Pragma Priority_Specific_Dispatching,Implementation Defined Pragmas
6704 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile}@anchor{c9}
6705 @section Pragma Profile
6706
6707
6708 Syntax:
6709
6710 @example
6711 pragma Profile (Ravenscar | Restricted | Rational |
6712 GNAT_Extended_Ravenscar | GNAT_Ravenscar_EDF );
6713 @end example
6714
6715 This pragma is standard in Ada 2005, but is available in all earlier
6716 versions of Ada as an implementation-defined pragma. This is a
6717 configuration pragma that establishes a set of configuration pragmas
6718 that depend on the argument. @code{Ravenscar} is standard in Ada 2005.
6719 The other possibilities (@code{Restricted}, @code{Rational},
6720 @code{GNAT_Extended_Ravenscar}, @code{GNAT_Ravenscar_EDF})
6721 are implementation-defined. The set of configuration pragmas
6722 is defined in the following sections.
6723
6724
6725 @itemize *
6726
6727 @item
6728 Pragma Profile (Ravenscar)
6729
6730 The @code{Ravenscar} profile is standard in Ada 2005,
6731 but is available in all earlier
6732 versions of Ada as an implementation-defined pragma. This profile
6733 establishes the following set of configuration pragmas:
6734
6735
6736 @itemize *
6737
6738 @item
6739 @code{Task_Dispatching_Policy (FIFO_Within_Priorities)}
6740
6741 [RM D.2.2] Tasks are dispatched following a preemptive
6742 priority-ordered scheduling policy.
6743
6744 @item
6745 @code{Locking_Policy (Ceiling_Locking)}
6746
6747 [RM D.3] While tasks and interrupts execute a protected action, they inherit
6748 the ceiling priority of the corresponding protected object.
6749
6750 @item
6751 @code{Detect_Blocking}
6752
6753 This pragma forces the detection of potentially blocking operations within a
6754 protected operation, and to raise Program_Error if that happens.
6755 @end itemize
6756
6757 plus the following set of restrictions:
6758
6759
6760 @itemize *
6761
6762 @item
6763 @code{Max_Entry_Queue_Length => 1}
6764
6765 No task can be queued on a protected entry.
6766
6767 @item
6768 @code{Max_Protected_Entries => 1}
6769
6770 @item
6771 @code{Max_Task_Entries => 0}
6772
6773 No rendezvous statements are allowed.
6774
6775 @item
6776 @code{No_Abort_Statements}
6777
6778 @item
6779 @code{No_Dynamic_Attachment}
6780
6781 @item
6782 @code{No_Dynamic_Priorities}
6783
6784 @item
6785 @code{No_Implicit_Heap_Allocations}
6786
6787 @item
6788 @code{No_Local_Protected_Objects}
6789
6790 @item
6791 @code{No_Local_Timing_Events}
6792
6793 @item
6794 @code{No_Protected_Type_Allocators}
6795
6796 @item
6797 @code{No_Relative_Delay}
6798
6799 @item
6800 @code{No_Requeue_Statements}
6801
6802 @item
6803 @code{No_Select_Statements}
6804
6805 @item
6806 @code{No_Specific_Termination_Handlers}
6807
6808 @item
6809 @code{No_Task_Allocators}
6810
6811 @item
6812 @code{No_Task_Hierarchy}
6813
6814 @item
6815 @code{No_Task_Termination}
6816
6817 @item
6818 @code{Simple_Barriers}
6819 @end itemize
6820
6821 The Ravenscar profile also includes the following restrictions that specify
6822 that there are no semantic dependences on the corresponding predefined
6823 packages:
6824
6825
6826 @itemize *
6827
6828 @item
6829 @code{No_Dependence => Ada.Asynchronous_Task_Control}
6830
6831 @item
6832 @code{No_Dependence => Ada.Calendar}
6833
6834 @item
6835 @code{No_Dependence => Ada.Execution_Time.Group_Budget}
6836
6837 @item
6838 @code{No_Dependence => Ada.Execution_Time.Timers}
6839
6840 @item
6841 @code{No_Dependence => Ada.Task_Attributes}
6842
6843 @item
6844 @code{No_Dependence => System.Multiprocessors.Dispatching_Domains}
6845 @end itemize
6846
6847 This set of configuration pragmas and restrictions correspond to the
6848 definition of the 'Ravenscar Profile' for limited tasking, devised and
6849 published by the @cite{International Real-Time Ada Workshop@comma{} 1997}.
6850 A description is also available at
6851 @indicateurl{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
6852
6853 The original definition of the profile was revised at subsequent IRTAW
6854 meetings. It has been included in the ISO
6855 @cite{Guide for the Use of the Ada Programming Language in High Integrity Systems},
6856 and was made part of the Ada 2005 standard.
6857 The formal definition given by
6858 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
6859 AI-305) available at
6860 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
6861 @indicateurl{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
6862
6863 The above set is a superset of the restrictions provided by pragma
6864 @code{Profile (Restricted)}, it includes six additional restrictions
6865 (@code{Simple_Barriers}, @code{No_Select_Statements},
6866 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
6867 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
6868 that pragma @code{Profile (Ravenscar)}, like the pragma
6869 @code{Profile (Restricted)},
6870 automatically causes the use of a simplified,
6871 more efficient version of the tasking run-time library.
6872
6873 @item
6874 Pragma Profile (GNAT_Extended_Ravenscar)
6875
6876 This profile corresponds to a GNAT specific extension of the
6877 Ravenscar profile. The profile may change in the future although
6878 only in a compatible way: some restrictions may be removed or
6879 relaxed. It is defined as a variation of the Ravenscar profile.
6880
6881 The @code{No_Implicit_Heap_Allocations} restriction has been replaced
6882 by @code{No_Implicit_Task_Allocations} and
6883 @code{No_Implicit_Protected_Object_Allocations}.
6884
6885 The @code{Simple_Barriers} restriction has been replaced by
6886 @code{Pure_Barriers}.
6887
6888 The @code{Max_Protected_Entries}, @code{Max_Entry_Queue_Length}, and
6889 @code{No_Relative_Delay} restrictions have been removed.
6890
6891 @item
6892 Pragma Profile (GNAT_Ravenscar_EDF)
6893
6894 This profile corresponds to the Ravenscar profile but using
6895 EDF_Across_Priority as the Task_Scheduling_Policy.
6896
6897 @item
6898 Pragma Profile (Restricted)
6899
6900 This profile corresponds to the GNAT restricted run time. It
6901 establishes the following set of restrictions:
6902
6903
6904 @itemize *
6905
6906 @item
6907 @code{No_Abort_Statements}
6908
6909 @item
6910 @code{No_Entry_Queue}
6911
6912 @item
6913 @code{No_Task_Hierarchy}
6914
6915 @item
6916 @code{No_Task_Allocators}
6917
6918 @item
6919 @code{No_Dynamic_Priorities}
6920
6921 @item
6922 @code{No_Terminate_Alternatives}
6923
6924 @item
6925 @code{No_Dynamic_Attachment}
6926
6927 @item
6928 @code{No_Protected_Type_Allocators}
6929
6930 @item
6931 @code{No_Local_Protected_Objects}
6932
6933 @item
6934 @code{No_Requeue_Statements}
6935
6936 @item
6937 @code{No_Task_Attributes_Package}
6938
6939 @item
6940 @code{Max_Asynchronous_Select_Nesting = 0}
6941
6942 @item
6943 @code{Max_Task_Entries = 0}
6944
6945 @item
6946 @code{Max_Protected_Entries = 1}
6947
6948 @item
6949 @code{Max_Select_Alternatives = 0}
6950 @end itemize
6951
6952 This set of restrictions causes the automatic selection of a simplified
6953 version of the run time that provides improved performance for the
6954 limited set of tasking functionality permitted by this set of restrictions.
6955
6956 @item
6957 Pragma Profile (Rational)
6958
6959 The Rational profile is intended to facilitate porting legacy code that
6960 compiles with the Rational APEX compiler, even when the code includes non-
6961 conforming Ada constructs. The profile enables the following three pragmas:
6962
6963
6964 @itemize *
6965
6966 @item
6967 @code{pragma Implicit_Packing}
6968
6969 @item
6970 @code{pragma Overriding_Renamings}
6971
6972 @item
6973 @code{pragma Use_VADS_Size}
6974 @end itemize
6975 @end itemize
6976
6977 @node Pragma Profile_Warnings,Pragma Propagate_Exceptions,Pragma Profile,Implementation Defined Pragmas
6978 @anchor{gnat_rm/implementation_defined_pragmas pragma-profile-warnings}@anchor{ca}
6979 @section Pragma Profile_Warnings
6980
6981
6982 Syntax:
6983
6984 @example
6985 pragma Profile_Warnings (Ravenscar | Restricted | Rational);
6986 @end example
6987
6988 This is an implementation-defined pragma that is similar in
6989 effect to @code{pragma Profile} except that instead of
6990 generating @code{Restrictions} pragmas, it generates
6991 @code{Restriction_Warnings} pragmas. The result is that
6992 violations of the profile generate warning messages instead
6993 of error messages.
6994
6995 @node Pragma Propagate_Exceptions,Pragma Provide_Shift_Operators,Pragma Profile_Warnings,Implementation Defined Pragmas
6996 @anchor{gnat_rm/implementation_defined_pragmas pragma-propagate-exceptions}@anchor{cb}
6997 @section Pragma Propagate_Exceptions
6998
6999
7000 @geindex Interfacing to C++
7001
7002 Syntax:
7003
7004 @example
7005 pragma Propagate_Exceptions;
7006 @end example
7007
7008 This pragma is now obsolete and, other than generating a warning if warnings
7009 on obsolescent features are enabled, is ignored.
7010 It is retained for compatibility
7011 purposes. It used to be used in connection with optimization of
7012 a now-obsolete mechanism for implementation of exceptions.
7013
7014 @node Pragma Provide_Shift_Operators,Pragma Psect_Object,Pragma Propagate_Exceptions,Implementation Defined Pragmas
7015 @anchor{gnat_rm/implementation_defined_pragmas pragma-provide-shift-operators}@anchor{cc}
7016 @section Pragma Provide_Shift_Operators
7017
7018
7019 @geindex Shift operators
7020
7021 Syntax:
7022
7023 @example
7024 pragma Provide_Shift_Operators (integer_first_subtype_LOCAL_NAME);
7025 @end example
7026
7027 This pragma can be applied to a first subtype local name that specifies
7028 either an unsigned or signed type. It has the effect of providing the
7029 five shift operators (Shift_Left, Shift_Right, Shift_Right_Arithmetic,
7030 Rotate_Left and Rotate_Right) for the given type. It is similar to
7031 including the function declarations for these five operators, together
7032 with the pragma Import (Intrinsic, ...) statements.
7033
7034 @node Pragma Psect_Object,Pragma Pure_Function,Pragma Provide_Shift_Operators,Implementation Defined Pragmas
7035 @anchor{gnat_rm/implementation_defined_pragmas pragma-psect-object}@anchor{cd}
7036 @section Pragma Psect_Object
7037
7038
7039 Syntax:
7040
7041 @example
7042 pragma Psect_Object (
7043 [Internal =>] LOCAL_NAME,
7044 [, [External =>] EXTERNAL_SYMBOL]
7045 [, [Size =>] EXTERNAL_SYMBOL]);
7046
7047 EXTERNAL_SYMBOL ::=
7048 IDENTIFIER
7049 | static_string_EXPRESSION
7050 @end example
7051
7052 This pragma is identical in effect to pragma @code{Common_Object}.
7053
7054 @node Pragma Pure_Function,Pragma Rational,Pragma Psect_Object,Implementation Defined Pragmas
7055 @anchor{gnat_rm/implementation_defined_pragmas pragma-pure-function}@anchor{ce}@anchor{gnat_rm/implementation_defined_pragmas id31}@anchor{cf}
7056 @section Pragma Pure_Function
7057
7058
7059 Syntax:
7060
7061 @example
7062 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
7063 @end example
7064
7065 This pragma appears in the same declarative part as a function
7066 declaration (or a set of function declarations if more than one
7067 overloaded declaration exists, in which case the pragma applies
7068 to all entities). It specifies that the function @code{Entity} is
7069 to be considered pure for the purposes of code generation. This means
7070 that the compiler can assume that there are no side effects, and
7071 in particular that two calls with identical arguments produce the
7072 same result. It also means that the function can be used in an
7073 address clause.
7074
7075 Note that, quite deliberately, there are no static checks to try
7076 to ensure that this promise is met, so @code{Pure_Function} can be used
7077 with functions that are conceptually pure, even if they do modify
7078 global variables. For example, a square root function that is
7079 instrumented to count the number of times it is called is still
7080 conceptually pure, and can still be optimized, even though it
7081 modifies a global variable (the count). Memo functions are another
7082 example (where a table of previous calls is kept and consulted to
7083 avoid re-computation).
7084
7085 Note also that the normal rules excluding optimization of subprograms
7086 in pure units (when parameter types are descended from System.Address,
7087 or when the full view of a parameter type is limited), do not apply
7088 for the Pure_Function case. If you explicitly specify Pure_Function,
7089 the compiler may optimize away calls with identical arguments, and
7090 if that results in unexpected behavior, the proper action is not to
7091 use the pragma for subprograms that are not (conceptually) pure.
7092
7093 Note: Most functions in a @code{Pure} package are automatically pure, and
7094 there is no need to use pragma @code{Pure_Function} for such functions. One
7095 exception is any function that has at least one formal of type
7096 @code{System.Address} or a type derived from it. Such functions are not
7097 considered pure by default, since the compiler assumes that the
7098 @code{Address} parameter may be functioning as a pointer and that the
7099 referenced data may change even if the address value does not.
7100 Similarly, imported functions are not considered to be pure by default,
7101 since there is no way of checking that they are in fact pure. The use
7102 of pragma @code{Pure_Function} for such a function will override these default
7103 assumption, and cause the compiler to treat a designated subprogram as pure
7104 in these cases.
7105
7106 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
7107 applies to the underlying renamed function. This can be used to
7108 disambiguate cases of overloading where some but not all functions
7109 in a set of overloaded functions are to be designated as pure.
7110
7111 If pragma @code{Pure_Function} is applied to a library-level function, the
7112 function is also considered pure from an optimization point of view, but the
7113 unit is not a Pure unit in the categorization sense. So for example, a function
7114 thus marked is free to @code{with} non-pure units.
7115
7116 @node Pragma Rational,Pragma Ravenscar,Pragma Pure_Function,Implementation Defined Pragmas
7117 @anchor{gnat_rm/implementation_defined_pragmas pragma-rational}@anchor{d0}
7118 @section Pragma Rational
7119
7120
7121 Syntax:
7122
7123 @example
7124 pragma Rational;
7125 @end example
7126
7127 This pragma is considered obsolescent, but is retained for
7128 compatibility purposes. It is equivalent to:
7129
7130 @example
7131 pragma Profile (Rational);
7132 @end example
7133
7134 @node Pragma Ravenscar,Pragma Refined_Depends,Pragma Rational,Implementation Defined Pragmas
7135 @anchor{gnat_rm/implementation_defined_pragmas pragma-ravenscar}@anchor{d1}
7136 @section Pragma Ravenscar
7137
7138
7139 Syntax:
7140
7141 @example
7142 pragma Ravenscar;
7143 @end example
7144
7145 This pragma is considered obsolescent, but is retained for
7146 compatibility purposes. It is equivalent to:
7147
7148 @example
7149 pragma Profile (Ravenscar);
7150 @end example
7151
7152 which is the preferred method of setting the @code{Ravenscar} profile.
7153
7154 @node Pragma Refined_Depends,Pragma Refined_Global,Pragma Ravenscar,Implementation Defined Pragmas
7155 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-depends}@anchor{d2}@anchor{gnat_rm/implementation_defined_pragmas id32}@anchor{d3}
7156 @section Pragma Refined_Depends
7157
7158
7159 Syntax:
7160
7161 @example
7162 pragma Refined_Depends (DEPENDENCY_RELATION);
7163
7164 DEPENDENCY_RELATION ::=
7165 null
7166 | (DEPENDENCY_CLAUSE @{, DEPENDENCY_CLAUSE@})
7167
7168 DEPENDENCY_CLAUSE ::=
7169 OUTPUT_LIST =>[+] INPUT_LIST
7170 | NULL_DEPENDENCY_CLAUSE
7171
7172 NULL_DEPENDENCY_CLAUSE ::= null => INPUT_LIST
7173
7174 OUTPUT_LIST ::= OUTPUT | (OUTPUT @{, OUTPUT@})
7175
7176 INPUT_LIST ::= null | INPUT | (INPUT @{, INPUT@})
7177
7178 OUTPUT ::= NAME | FUNCTION_RESULT
7179 INPUT ::= NAME
7180
7181 where FUNCTION_RESULT is a function Result attribute_reference
7182 @end example
7183
7184 For the semantics of this pragma, see the entry for aspect @code{Refined_Depends} in
7185 the SPARK 2014 Reference Manual, section 6.1.5.
7186
7187 @node Pragma Refined_Global,Pragma Refined_Post,Pragma Refined_Depends,Implementation Defined Pragmas
7188 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-global}@anchor{d4}@anchor{gnat_rm/implementation_defined_pragmas id33}@anchor{d5}
7189 @section Pragma Refined_Global
7190
7191
7192 Syntax:
7193
7194 @example
7195 pragma Refined_Global (GLOBAL_SPECIFICATION);
7196
7197 GLOBAL_SPECIFICATION ::=
7198 null
7199 | (GLOBAL_LIST)
7200 | (MODED_GLOBAL_LIST @{, MODED_GLOBAL_LIST@})
7201
7202 MODED_GLOBAL_LIST ::= MODE_SELECTOR => GLOBAL_LIST
7203
7204 MODE_SELECTOR ::= In_Out | Input | Output | Proof_In
7205 GLOBAL_LIST ::= GLOBAL_ITEM | (GLOBAL_ITEM @{, GLOBAL_ITEM@})
7206 GLOBAL_ITEM ::= NAME
7207 @end example
7208
7209 For the semantics of this pragma, see the entry for aspect @code{Refined_Global} in
7210 the SPARK 2014 Reference Manual, section 6.1.4.
7211
7212 @node Pragma Refined_Post,Pragma Refined_State,Pragma Refined_Global,Implementation Defined Pragmas
7213 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-post}@anchor{d6}@anchor{gnat_rm/implementation_defined_pragmas id34}@anchor{d7}
7214 @section Pragma Refined_Post
7215
7216
7217 Syntax:
7218
7219 @example
7220 pragma Refined_Post (boolean_EXPRESSION);
7221 @end example
7222
7223 For the semantics of this pragma, see the entry for aspect @code{Refined_Post} in
7224 the SPARK 2014 Reference Manual, section 7.2.7.
7225
7226 @node Pragma Refined_State,Pragma Relative_Deadline,Pragma Refined_Post,Implementation Defined Pragmas
7227 @anchor{gnat_rm/implementation_defined_pragmas pragma-refined-state}@anchor{d8}@anchor{gnat_rm/implementation_defined_pragmas id35}@anchor{d9}
7228 @section Pragma Refined_State
7229
7230
7231 Syntax:
7232
7233 @example
7234 pragma Refined_State (REFINEMENT_LIST);
7235
7236 REFINEMENT_LIST ::=
7237 (REFINEMENT_CLAUSE @{, REFINEMENT_CLAUSE@})
7238
7239 REFINEMENT_CLAUSE ::= state_NAME => CONSTITUENT_LIST
7240
7241 CONSTITUENT_LIST ::=
7242 null
7243 | CONSTITUENT
7244 | (CONSTITUENT @{, CONSTITUENT@})
7245
7246 CONSTITUENT ::= object_NAME | state_NAME
7247 @end example
7248
7249 For the semantics of this pragma, see the entry for aspect @code{Refined_State} in
7250 the SPARK 2014 Reference Manual, section 7.2.2.
7251
7252 @node Pragma Relative_Deadline,Pragma Remote_Access_Type,Pragma Refined_State,Implementation Defined Pragmas
7253 @anchor{gnat_rm/implementation_defined_pragmas pragma-relative-deadline}@anchor{da}
7254 @section Pragma Relative_Deadline
7255
7256
7257 Syntax:
7258
7259 @example
7260 pragma Relative_Deadline (time_span_EXPRESSION);
7261 @end example
7262
7263 This pragma is standard in Ada 2005, but is available in all earlier
7264 versions of Ada as an implementation-defined pragma.
7265 See Ada 2012 Reference Manual for details.
7266
7267 @node Pragma Remote_Access_Type,Pragma Restricted_Run_Time,Pragma Relative_Deadline,Implementation Defined Pragmas
7268 @anchor{gnat_rm/implementation_defined_pragmas id36}@anchor{db}@anchor{gnat_rm/implementation_defined_pragmas pragma-remote-access-type}@anchor{dc}
7269 @section Pragma Remote_Access_Type
7270
7271
7272 Syntax:
7273
7274 @example
7275 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
7276 @end example
7277
7278 This pragma appears in the formal part of a generic declaration.
7279 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
7280 the use of a remote access to class-wide type as actual for a formal
7281 access type.
7282
7283 When this pragma applies to a formal access type @code{Entity}, that
7284 type is treated as a remote access to class-wide type in the generic.
7285 It must be a formal general access type, and its designated type must
7286 be the class-wide type of a formal tagged limited private type from the
7287 same generic declaration.
7288
7289 In the generic unit, the formal type is subject to all restrictions
7290 pertaining to remote access to class-wide types. At instantiation, the
7291 actual type must be a remote access to class-wide type.
7292
7293 @node Pragma Restricted_Run_Time,Pragma Restriction_Warnings,Pragma Remote_Access_Type,Implementation Defined Pragmas
7294 @anchor{gnat_rm/implementation_defined_pragmas pragma-restricted-run-time}@anchor{dd}
7295 @section Pragma Restricted_Run_Time
7296
7297
7298 Syntax:
7299
7300 @example
7301 pragma Restricted_Run_Time;
7302 @end example
7303
7304 This pragma is considered obsolescent, but is retained for
7305 compatibility purposes. It is equivalent to:
7306
7307 @example
7308 pragma Profile (Restricted);
7309 @end example
7310
7311 which is the preferred method of setting the restricted run time
7312 profile.
7313
7314 @node Pragma Restriction_Warnings,Pragma Reviewable,Pragma Restricted_Run_Time,Implementation Defined Pragmas
7315 @anchor{gnat_rm/implementation_defined_pragmas pragma-restriction-warnings}@anchor{de}
7316 @section Pragma Restriction_Warnings
7317
7318
7319 Syntax:
7320
7321 @example
7322 pragma Restriction_Warnings
7323 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
7324 @end example
7325
7326 This pragma allows a series of restriction identifiers to be
7327 specified (the list of allowed identifiers is the same as for
7328 pragma @code{Restrictions}). For each of these identifiers
7329 the compiler checks for violations of the restriction, but
7330 generates a warning message rather than an error message
7331 if the restriction is violated.
7332
7333 One use of this is in situations where you want to know
7334 about violations of a restriction, but you want to ignore some of
7335 these violations. Consider this example, where you want to set
7336 Ada_95 mode and enable style checks, but you want to know about
7337 any other use of implementation pragmas:
7338
7339 @example
7340 pragma Restriction_Warnings (No_Implementation_Pragmas);
7341 pragma Warnings (Off, "violation of No_Implementation_Pragmas");
7342 pragma Ada_95;
7343 pragma Style_Checks ("2bfhkM160");
7344 pragma Warnings (On, "violation of No_Implementation_Pragmas");
7345 @end example
7346
7347 By including the above lines in a configuration pragmas file,
7348 the Ada_95 and Style_Checks pragmas are accepted without
7349 generating a warning, but any other use of implementation
7350 defined pragmas will cause a warning to be generated.
7351
7352 @node Pragma Reviewable,Pragma Secondary_Stack_Size,Pragma Restriction_Warnings,Implementation Defined Pragmas
7353 @anchor{gnat_rm/implementation_defined_pragmas pragma-reviewable}@anchor{df}
7354 @section Pragma Reviewable
7355
7356
7357 Syntax:
7358
7359 @example
7360 pragma Reviewable;
7361 @end example
7362
7363 This pragma is an RM-defined standard pragma, but has no effect on the
7364 program being compiled, or on the code generated for the program.
7365
7366 To obtain the required output specified in RM H.3.1, the compiler must be
7367 run with various special switches as follows:
7368
7369
7370 @itemize *
7371
7372 @item
7373 @emph{Where compiler-generated run-time checks remain}
7374
7375 The switch @emph{-gnatGL}
7376 may be used to list the expanded code in pseudo-Ada form.
7377 Runtime checks show up in the listing either as explicit
7378 checks or operators marked with @{@} to indicate a check is present.
7379
7380 @item
7381 @emph{An identification of known exceptions at compile time}
7382
7383 If the program is compiled with @emph{-gnatwa},
7384 the compiler warning messages will indicate all cases where the compiler
7385 detects that an exception is certain to occur at run time.
7386
7387 @item
7388 @emph{Possible reads of uninitialized variables}
7389
7390 The compiler warns of many such cases, but its output is incomplete.
7391 @end itemize
7392
7393
7394 A supplemental static analysis tool
7395 may be used to obtain a comprehensive list of all
7396 possible points at which uninitialized data may be read.
7397
7398
7399 @itemize *
7400
7401 @item
7402 @emph{Where run-time support routines are implicitly invoked}
7403
7404 In the output from @emph{-gnatGL},
7405 run-time calls are explicitly listed as calls to the relevant
7406 run-time routine.
7407
7408 @item
7409 @emph{Object code listing}
7410
7411 This may be obtained either by using the @emph{-S} switch,
7412 or the objdump utility.
7413
7414 @item
7415 @emph{Constructs known to be erroneous at compile time}
7416
7417 These are identified by warnings issued by the compiler (use @emph{-gnatwa}).
7418
7419 @item
7420 @emph{Stack usage information}
7421
7422 Static stack usage data (maximum per-subprogram) can be obtained via the
7423 @emph{-fstack-usage} switch to the compiler.
7424 Dynamic stack usage data (per task) can be obtained via the @emph{-u} switch
7425 to gnatbind
7426 @end itemize
7427
7428
7429
7430 @itemize *
7431
7432 @item
7433 @emph{Object code listing of entire partition}
7434
7435 This can be obtained by compiling the partition with @emph{-S},
7436 or by applying objdump
7437 to all the object files that are part of the partition.
7438
7439 @item
7440 @emph{A description of the run-time model}
7441
7442 The full sources of the run-time are available, and the documentation of
7443 these routines describes how these run-time routines interface to the
7444 underlying operating system facilities.
7445
7446 @item
7447 @emph{Control and data-flow information}
7448 @end itemize
7449
7450
7451 A supplemental static analysis tool
7452 may be used to obtain complete control and data-flow information, as well as
7453 comprehensive messages identifying possible problems based on this
7454 information.
7455
7456 @node Pragma Secondary_Stack_Size,Pragma Share_Generic,Pragma Reviewable,Implementation Defined Pragmas
7457 @anchor{gnat_rm/implementation_defined_pragmas id37}@anchor{e0}@anchor{gnat_rm/implementation_defined_pragmas pragma-secondary-stack-size}@anchor{e1}
7458 @section Pragma Secondary_Stack_Size
7459
7460
7461 Syntax:
7462
7463 @example
7464 pragma Secondary_Stack_Size (integer_EXPRESSION);
7465 @end example
7466
7467 This pragma appears within the task definition of a single task declaration
7468 or a task type declaration (like pragma @code{Storage_Size}) and applies to all
7469 task objects of that type. The argument specifies the size of the secondary
7470 stack to be used by these task objects, and must be of an integer type. The
7471 secondary stack is used to handle functions that return a variable-sized
7472 result, for example a function returning an unconstrained String.
7473
7474 Note this pragma only applies to targets using fixed secondary stacks, like
7475 VxWorks 653 and bare board targets, where a fixed block for the
7476 secondary stack is allocated from the primary stack of the task. By default,
7477 these targets assign a percentage of the primary stack for the secondary stack,
7478 as defined by @code{System.Parameter.Sec_Stack_Percentage}. With this pragma,
7479 an @code{integer_EXPRESSION} of bytes is assigned from the primary stack instead.
7480
7481 For most targets, the pragma does not apply as the secondary stack grows on
7482 demand: allocated as a chain of blocks in the heap. The default size of these
7483 blocks can be modified via the @code{-D} binder option as described in
7484 @cite{GNAT User's Guide}.
7485
7486 Note that no check is made to see if the secondary stack can fit inside the
7487 primary stack.
7488
7489 Note the pragma cannot appear when the restriction @code{No_Secondary_Stack}
7490 is in effect.
7491
7492 @node Pragma Share_Generic,Pragma Shared,Pragma Secondary_Stack_Size,Implementation Defined Pragmas
7493 @anchor{gnat_rm/implementation_defined_pragmas pragma-share-generic}@anchor{e2}
7494 @section Pragma Share_Generic
7495
7496
7497 Syntax:
7498
7499 @example
7500 pragma Share_Generic (GNAME @{, GNAME@});
7501
7502 GNAME ::= generic_unit_NAME | generic_instance_NAME
7503 @end example
7504
7505 This pragma is provided for compatibility with Dec Ada 83. It has
7506 no effect in GNAT (which does not implement shared generics), other
7507 than to check that the given names are all names of generic units or
7508 generic instances.
7509
7510 @node Pragma Shared,Pragma Short_Circuit_And_Or,Pragma Share_Generic,Implementation Defined Pragmas
7511 @anchor{gnat_rm/implementation_defined_pragmas id38}@anchor{e3}@anchor{gnat_rm/implementation_defined_pragmas pragma-shared}@anchor{e4}
7512 @section Pragma Shared
7513
7514
7515 This pragma is provided for compatibility with Ada 83. The syntax and
7516 semantics are identical to pragma Atomic.
7517
7518 @node Pragma Short_Circuit_And_Or,Pragma Short_Descriptors,Pragma Shared,Implementation Defined Pragmas
7519 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-circuit-and-or}@anchor{e5}
7520 @section Pragma Short_Circuit_And_Or
7521
7522
7523 Syntax:
7524
7525 @example
7526 pragma Short_Circuit_And_Or;
7527 @end example
7528
7529 This configuration pragma causes any occurrence of the AND operator applied to
7530 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
7531 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
7532 may be useful in the context of certification protocols requiring the use of
7533 short-circuited logical operators. If this configuration pragma occurs locally
7534 within the file being compiled, it applies only to the file being compiled.
7535 There is no requirement that all units in a partition use this option.
7536
7537 @node Pragma Short_Descriptors,Pragma Simple_Storage_Pool_Type,Pragma Short_Circuit_And_Or,Implementation Defined Pragmas
7538 @anchor{gnat_rm/implementation_defined_pragmas pragma-short-descriptors}@anchor{e6}
7539 @section Pragma Short_Descriptors
7540
7541
7542 Syntax:
7543
7544 @example
7545 pragma Short_Descriptors
7546 @end example
7547
7548 This pragma is provided for compatibility with other Ada implementations. It
7549 is recognized but ignored by all current versions of GNAT.
7550
7551 @node Pragma Simple_Storage_Pool_Type,Pragma Source_File_Name,Pragma Short_Descriptors,Implementation Defined Pragmas
7552 @anchor{gnat_rm/implementation_defined_pragmas pragma-simple-storage-pool-type}@anchor{e7}@anchor{gnat_rm/implementation_defined_pragmas id39}@anchor{e8}
7553 @section Pragma Simple_Storage_Pool_Type
7554
7555
7556 @geindex Storage pool
7557 @geindex simple
7558
7559 @geindex Simple storage pool
7560
7561 Syntax:
7562
7563 @example
7564 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
7565 @end example
7566
7567 A type can be established as a 'simple storage pool type' by applying
7568 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
7569 A type named in the pragma must be a library-level immutably limited record
7570 type or limited tagged type declared immediately within a package declaration.
7571 The type can also be a limited private type whose full type is allowed as
7572 a simple storage pool type.
7573
7574 For a simple storage pool type @code{SSP}, nonabstract primitive subprograms
7575 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
7576 are subtype conformant with the following subprogram declarations:
7577
7578 @example
7579 procedure Allocate
7580 (Pool : in out SSP;
7581 Storage_Address : out System.Address;
7582 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7583 Alignment : System.Storage_Elements.Storage_Count);
7584
7585 procedure Deallocate
7586 (Pool : in out SSP;
7587 Storage_Address : System.Address;
7588 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
7589 Alignment : System.Storage_Elements.Storage_Count);
7590
7591 function Storage_Size (Pool : SSP)
7592 return System.Storage_Elements.Storage_Count;
7593 @end example
7594
7595 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
7596 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
7597 applying an unchecked deallocation has no effect other than to set its actual
7598 parameter to null. If @code{Storage_Size} is not declared, then the
7599 @code{Storage_Size} attribute applied to an access type associated with
7600 a pool object of type SSP returns zero. Additional operations can be declared
7601 for a simple storage pool type (such as for supporting a mark/release
7602 storage-management discipline).
7603
7604 An object of a simple storage pool type can be associated with an access
7605 type by specifying the attribute
7606 @ref{e9,,Simple_Storage_Pool}. For example:
7607
7608 @example
7609 My_Pool : My_Simple_Storage_Pool_Type;
7610
7611 type Acc is access My_Data_Type;
7612
7613 for Acc'Simple_Storage_Pool use My_Pool;
7614 @end example
7615
7616 See attribute @ref{e9,,Simple_Storage_Pool}
7617 for further details.
7618
7619 @node Pragma Source_File_Name,Pragma Source_File_Name_Project,Pragma Simple_Storage_Pool_Type,Implementation Defined Pragmas
7620 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name}@anchor{ea}@anchor{gnat_rm/implementation_defined_pragmas id40}@anchor{eb}
7621 @section Pragma Source_File_Name
7622
7623
7624 Syntax:
7625
7626 @example
7627 pragma Source_File_Name (
7628 [Unit_Name =>] unit_NAME,
7629 Spec_File_Name => STRING_LITERAL,
7630 [Index => INTEGER_LITERAL]);
7631
7632 pragma Source_File_Name (
7633 [Unit_Name =>] unit_NAME,
7634 Body_File_Name => STRING_LITERAL,
7635 [Index => INTEGER_LITERAL]);
7636 @end example
7637
7638 Use this to override the normal naming convention. It is a configuration
7639 pragma, and so has the usual applicability of configuration pragmas
7640 (i.e., it applies to either an entire partition, or to all units in a
7641 compilation, or to a single unit, depending on how it is used.
7642 @code{unit_name} is mapped to @code{file_name_literal}. The identifier for
7643 the second argument is required, and indicates whether this is the file
7644 name for the spec or for the body.
7645
7646 The optional Index argument should be used when a file contains multiple
7647 units, and when you do not want to use @code{gnatchop} to separate then
7648 into multiple files (which is the recommended procedure to limit the
7649 number of recompilations that are needed when some sources change).
7650 For instance, if the source file @code{source.ada} contains
7651
7652 @example
7653 package B is
7654 ...
7655 end B;
7656
7657 with B;
7658 procedure A is
7659 begin
7660 ..
7661 end A;
7662 @end example
7663
7664 you could use the following configuration pragmas:
7665
7666 @example
7667 pragma Source_File_Name
7668 (B, Spec_File_Name => "source.ada", Index => 1);
7669 pragma Source_File_Name
7670 (A, Body_File_Name => "source.ada", Index => 2);
7671 @end example
7672
7673 Note that the @code{gnatname} utility can also be used to generate those
7674 configuration pragmas.
7675
7676 Another form of the @code{Source_File_Name} pragma allows
7677 the specification of patterns defining alternative file naming schemes
7678 to apply to all files.
7679
7680 @example
7681 pragma Source_File_Name
7682 ( [Spec_File_Name =>] STRING_LITERAL
7683 [,[Casing =>] CASING_SPEC]
7684 [,[Dot_Replacement =>] STRING_LITERAL]);
7685
7686 pragma Source_File_Name
7687 ( [Body_File_Name =>] STRING_LITERAL
7688 [,[Casing =>] CASING_SPEC]
7689 [,[Dot_Replacement =>] STRING_LITERAL]);
7690
7691 pragma Source_File_Name
7692 ( [Subunit_File_Name =>] STRING_LITERAL
7693 [,[Casing =>] CASING_SPEC]
7694 [,[Dot_Replacement =>] STRING_LITERAL]);
7695
7696 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
7697 @end example
7698
7699 The first argument is a pattern that contains a single asterisk indicating
7700 the point at which the unit name is to be inserted in the pattern string
7701 to form the file name. The second argument is optional. If present it
7702 specifies the casing of the unit name in the resulting file name string.
7703 The default is lower case. Finally the third argument allows for systematic
7704 replacement of any dots in the unit name by the specified string literal.
7705
7706 Note that Source_File_Name pragmas should not be used if you are using
7707 project files. The reason for this rule is that the project manager is not
7708 aware of these pragmas, and so other tools that use the projet file would not
7709 be aware of the intended naming conventions. If you are using project files,
7710 file naming is controlled by Source_File_Name_Project pragmas, which are
7711 usually supplied automatically by the project manager. A pragma
7712 Source_File_Name cannot appear after a @ref{ec,,Pragma Source_File_Name_Project}.
7713
7714 For more details on the use of the @code{Source_File_Name} pragma, see the
7715 sections on @cite{Using Other File Names} and @cite{Alternative File Naming Schemes}
7716 in the @cite{GNAT User's Guide}.
7717
7718 @node Pragma Source_File_Name_Project,Pragma Source_Reference,Pragma Source_File_Name,Implementation Defined Pragmas
7719 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-file-name-project}@anchor{ec}@anchor{gnat_rm/implementation_defined_pragmas id41}@anchor{ed}
7720 @section Pragma Source_File_Name_Project
7721
7722
7723 This pragma has the same syntax and semantics as pragma Source_File_Name.
7724 It is only allowed as a stand-alone configuration pragma.
7725 It cannot appear after a @ref{ea,,Pragma Source_File_Name}, and
7726 most importantly, once pragma Source_File_Name_Project appears,
7727 no further Source_File_Name pragmas are allowed.
7728
7729 The intention is that Source_File_Name_Project pragmas are always
7730 generated by the Project Manager in a manner consistent with the naming
7731 specified in a project file, and when naming is controlled in this manner,
7732 it is not permissible to attempt to modify this naming scheme using
7733 Source_File_Name or Source_File_Name_Project pragmas (which would not be
7734 known to the project manager).
7735
7736 @node Pragma Source_Reference,Pragma SPARK_Mode,Pragma Source_File_Name_Project,Implementation Defined Pragmas
7737 @anchor{gnat_rm/implementation_defined_pragmas pragma-source-reference}@anchor{ee}
7738 @section Pragma Source_Reference
7739
7740
7741 Syntax:
7742
7743 @example
7744 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
7745 @end example
7746
7747 This pragma must appear as the first line of a source file.
7748 @code{integer_literal} is the logical line number of the line following
7749 the pragma line (for use in error messages and debugging
7750 information). @code{string_literal} is a static string constant that
7751 specifies the file name to be used in error messages and debugging
7752 information. This is most notably used for the output of @code{gnatchop}
7753 with the @emph{-r} switch, to make sure that the original unchopped
7754 source file is the one referred to.
7755
7756 The second argument must be a string literal, it cannot be a static
7757 string expression other than a string literal. This is because its value
7758 is needed for error messages issued by all phases of the compiler.
7759
7760 @node Pragma SPARK_Mode,Pragma Static_Elaboration_Desired,Pragma Source_Reference,Implementation Defined Pragmas
7761 @anchor{gnat_rm/implementation_defined_pragmas pragma-spark-mode}@anchor{ef}@anchor{gnat_rm/implementation_defined_pragmas id42}@anchor{f0}
7762 @section Pragma SPARK_Mode
7763
7764
7765 Syntax:
7766
7767 @example
7768 pragma SPARK_Mode [(On | Off)] ;
7769 @end example
7770
7771 In general a program can have some parts that are in SPARK 2014 (and
7772 follow all the rules in the SPARK Reference Manual), and some parts
7773 that are full Ada 2012.
7774
7775 The SPARK_Mode pragma is used to identify which parts are in SPARK
7776 2014 (by default programs are in full Ada). The SPARK_Mode pragma can
7777 be used in the following places:
7778
7779
7780 @itemize *
7781
7782 @item
7783 As a configuration pragma, in which case it sets the default mode for
7784 all units compiled with this pragma.
7785
7786 @item
7787 Immediately following a library-level subprogram spec
7788
7789 @item
7790 Immediately within a library-level package body
7791
7792 @item
7793 Immediately following the @code{private} keyword of a library-level
7794 package spec
7795
7796 @item
7797 Immediately following the @code{begin} keyword of a library-level
7798 package body
7799
7800 @item
7801 Immediately within a library-level subprogram body
7802 @end itemize
7803
7804 Normally a subprogram or package spec/body inherits the current mode
7805 that is active at the point it is declared. But this can be overridden
7806 by pragma within the spec or body as above.
7807
7808 The basic consistency rule is that you can't turn SPARK_Mode back
7809 @code{On}, once you have explicitly (with a pragma) turned if
7810 @code{Off}. So the following rules apply:
7811
7812 If a subprogram spec has SPARK_Mode @code{Off}, then the body must
7813 also have SPARK_Mode @code{Off}.
7814
7815 For a package, we have four parts:
7816
7817
7818 @itemize *
7819
7820 @item
7821 the package public declarations
7822
7823 @item
7824 the package private part
7825
7826 @item
7827 the body of the package
7828
7829 @item
7830 the elaboration code after @code{begin}
7831 @end itemize
7832
7833 For a package, the rule is that if you explicitly turn SPARK_Mode
7834 @code{Off} for any part, then all the following parts must have
7835 SPARK_Mode @code{Off}. Note that this may require repeating a pragma
7836 SPARK_Mode (@code{Off}) in the body. For example, if we have a
7837 configuration pragma SPARK_Mode (@code{On}) that turns the mode on by
7838 default everywhere, and one particular package spec has pragma
7839 SPARK_Mode (@code{Off}), then that pragma will need to be repeated in
7840 the package body.
7841
7842 @node Pragma Static_Elaboration_Desired,Pragma Stream_Convert,Pragma SPARK_Mode,Implementation Defined Pragmas
7843 @anchor{gnat_rm/implementation_defined_pragmas pragma-static-elaboration-desired}@anchor{f1}
7844 @section Pragma Static_Elaboration_Desired
7845
7846
7847 Syntax:
7848
7849 @example
7850 pragma Static_Elaboration_Desired;
7851 @end example
7852
7853 This pragma is used to indicate that the compiler should attempt to initialize
7854 statically the objects declared in the library unit to which the pragma applies,
7855 when these objects are initialized (explicitly or implicitly) by an aggregate.
7856 In the absence of this pragma, aggregates in object declarations are expanded
7857 into assignments and loops, even when the aggregate components are static
7858 constants. When the aggregate is present the compiler builds a static expression
7859 that requires no run-time code, so that the initialized object can be placed in
7860 read-only data space. If the components are not static, or the aggregate has
7861 more that 100 components, the compiler emits a warning that the pragma cannot
7862 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
7863 construction of larger aggregates with static components that include an others
7864 choice.)
7865
7866 @node Pragma Stream_Convert,Pragma Style_Checks,Pragma Static_Elaboration_Desired,Implementation Defined Pragmas
7867 @anchor{gnat_rm/implementation_defined_pragmas pragma-stream-convert}@anchor{f2}
7868 @section Pragma Stream_Convert
7869
7870
7871 Syntax:
7872
7873 @example
7874 pragma Stream_Convert (
7875 [Entity =>] type_LOCAL_NAME,
7876 [Read =>] function_NAME,
7877 [Write =>] function_NAME);
7878 @end example
7879
7880 This pragma provides an efficient way of providing user-defined stream
7881 attributes. Not only is it simpler to use than specifying the attributes
7882 directly, but more importantly, it allows the specification to be made in such
7883 a way that the predefined unit Ada.Streams is not loaded unless it is actually
7884 needed (i.e. unless the stream attributes are actually used); the use of
7885 the Stream_Convert pragma adds no overhead at all, unless the stream
7886 attributes are actually used on the designated type.
7887
7888 The first argument specifies the type for which stream functions are
7889 provided. The second parameter provides a function used to read values
7890 of this type. It must name a function whose argument type may be any
7891 subtype, and whose returned type must be the type given as the first
7892 argument to the pragma.
7893
7894 The meaning of the @code{Read} parameter is that if a stream attribute directly
7895 or indirectly specifies reading of the type given as the first parameter,
7896 then a value of the type given as the argument to the Read function is
7897 read from the stream, and then the Read function is used to convert this
7898 to the required target type.
7899
7900 Similarly the @code{Write} parameter specifies how to treat write attributes
7901 that directly or indirectly apply to the type given as the first parameter.
7902 It must have an input parameter of the type specified by the first parameter,
7903 and the return type must be the same as the input type of the Read function.
7904 The effect is to first call the Write function to convert to the given stream
7905 type, and then write the result type to the stream.
7906
7907 The Read and Write functions must not be overloaded subprograms. If necessary
7908 renamings can be supplied to meet this requirement.
7909 The usage of this attribute is best illustrated by a simple example, taken
7910 from the GNAT implementation of package Ada.Strings.Unbounded:
7911
7912 @example
7913 function To_Unbounded (S : String) return Unbounded_String
7914 renames To_Unbounded_String;
7915
7916 pragma Stream_Convert
7917 (Unbounded_String, To_Unbounded, To_String);
7918 @end example
7919
7920 The specifications of the referenced functions, as given in the Ada
7921 Reference Manual are:
7922
7923 @example
7924 function To_Unbounded_String (Source : String)
7925 return Unbounded_String;
7926
7927 function To_String (Source : Unbounded_String)
7928 return String;
7929 @end example
7930
7931 The effect is that if the value of an unbounded string is written to a stream,
7932 then the representation of the item in the stream is in the same format that
7933 would be used for @code{Standard.String'Output}, and this same representation
7934 is expected when a value of this type is read from the stream. Note that the
7935 value written always includes the bounds, even for Unbounded_String'Write,
7936 since Unbounded_String is not an array type.
7937
7938 Note that the @code{Stream_Convert} pragma is not effective in the case of
7939 a derived type of a non-limited tagged type. If such a type is specified then
7940 the pragma is silently ignored, and the default implementation of the stream
7941 attributes is used instead.
7942
7943 @node Pragma Style_Checks,Pragma Subtitle,Pragma Stream_Convert,Implementation Defined Pragmas
7944 @anchor{gnat_rm/implementation_defined_pragmas pragma-style-checks}@anchor{f3}
7945 @section Pragma Style_Checks
7946
7947
7948 Syntax:
7949
7950 @example
7951 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
7952 On | Off [, LOCAL_NAME]);
7953 @end example
7954
7955 This pragma is used in conjunction with compiler switches to control the
7956 built in style checking provided by GNAT. The compiler switches, if set,
7957 provide an initial setting for the switches, and this pragma may be used
7958 to modify these settings, or the settings may be provided entirely by
7959 the use of the pragma. This pragma can be used anywhere that a pragma
7960 is legal, including use as a configuration pragma (including use in
7961 the @code{gnat.adc} file).
7962
7963 The form with a string literal specifies which style options are to be
7964 activated. These are additive, so they apply in addition to any previously
7965 set style check options. The codes for the options are the same as those
7966 used in the @emph{-gnaty} switch to @emph{gcc} or @emph{gnatmake}.
7967 For example the following two methods can be used to enable
7968 layout checking:
7969
7970
7971 @itemize *
7972
7973 @item
7974 @example
7975 pragma Style_Checks ("l");
7976 @end example
7977
7978 @item
7979 @example
7980 gcc -c -gnatyl ...
7981 @end example
7982 @end itemize
7983
7984 The form @code{ALL_CHECKS} activates all standard checks (its use is equivalent
7985 to the use of the @code{gnaty} switch with no options.
7986 See the @cite{GNAT User's Guide} for details.)
7987
7988 Note: the behavior is slightly different in GNAT mode (@code{-gnatg} used).
7989 In this case, @code{ALL_CHECKS} implies the standard set of GNAT mode style check
7990 options (i.e. equivalent to @code{-gnatyg}).
7991
7992 The forms with @code{Off} and @code{On}
7993 can be used to temporarily disable style checks
7994 as shown in the following example:
7995
7996 @example
7997 pragma Style_Checks ("k"); -- requires keywords in lower case
7998 pragma Style_Checks (Off); -- turn off style checks
7999 NULL; -- this will not generate an error message
8000 pragma Style_Checks (On); -- turn style checks back on
8001 NULL; -- this will generate an error message
8002 @end example
8003
8004 Finally the two argument form is allowed only if the first argument is
8005 @code{On} or @code{Off}. The effect is to turn of semantic style checks
8006 for the specified entity, as shown in the following example:
8007
8008 @example
8009 pragma Style_Checks ("r"); -- require consistency of identifier casing
8010 Arg : Integer;
8011 Rf1 : Integer := ARG; -- incorrect, wrong case
8012 pragma Style_Checks (Off, Arg);
8013 Rf2 : Integer := ARG; -- OK, no error
8014 @end example
8015
8016 @node Pragma Subtitle,Pragma Suppress,Pragma Style_Checks,Implementation Defined Pragmas
8017 @anchor{gnat_rm/implementation_defined_pragmas pragma-subtitle}@anchor{f4}
8018 @section Pragma Subtitle
8019
8020
8021 Syntax:
8022
8023 @example
8024 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
8025 @end example
8026
8027 This pragma is recognized for compatibility with other Ada compilers
8028 but is ignored by GNAT.
8029
8030 @node Pragma Suppress,Pragma Suppress_All,Pragma Subtitle,Implementation Defined Pragmas
8031 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress}@anchor{f5}
8032 @section Pragma Suppress
8033
8034
8035 Syntax:
8036
8037 @example
8038 pragma Suppress (Identifier [, [On =>] Name]);
8039 @end example
8040
8041 This is a standard pragma, and supports all the check names required in
8042 the RM. It is included here because GNAT recognizes some additional check
8043 names that are implementation defined (as permitted by the RM):
8044
8045
8046 @itemize *
8047
8048 @item
8049 @code{Alignment_Check} can be used to suppress alignment checks
8050 on addresses used in address clauses. Such checks can also be suppressed
8051 by suppressing range checks, but the specific use of @code{Alignment_Check}
8052 allows suppression of alignment checks without suppressing other range checks.
8053 Note that @code{Alignment_Check} is suppressed by default on machines (such as
8054 the x86) with non-strict alignment.
8055
8056 @item
8057 @code{Atomic_Synchronization} can be used to suppress the special memory
8058 synchronization instructions that are normally generated for access to
8059 @code{Atomic} variables to ensure correct synchronization between tasks
8060 that use such variables for synchronization purposes.
8061
8062 @item
8063 @code{Duplicated_Tag_Check} Can be used to suppress the check that is generated
8064 for a duplicated tag value when a tagged type is declared.
8065
8066 @item
8067 @code{Container_Checks} Can be used to suppress all checks within Ada.Containers
8068 and instances of its children, including Tampering_Check.
8069
8070 @item
8071 @code{Tampering_Check} Can be used to suppress tampering check in the containers.
8072
8073 @item
8074 @code{Predicate_Check} can be used to control whether predicate checks are
8075 active. It is applicable only to predicates for which the policy is
8076 @code{Check}. Unlike @code{Assertion_Policy}, which determines if a given
8077 predicate is ignored or checked for the whole program, the use of
8078 @code{Suppress} and @code{Unsuppress} with this check name allows a given
8079 predicate to be turned on and off at specific points in the program.
8080
8081 @item
8082 @code{Validity_Check} can be used specifically to control validity checks.
8083 If @code{Suppress} is used to suppress validity checks, then no validity
8084 checks are performed, including those specified by the appropriate compiler
8085 switch or the @code{Validity_Checks} pragma.
8086
8087 @item
8088 Additional check names previously introduced by use of the @code{Check_Name}
8089 pragma are also allowed.
8090 @end itemize
8091
8092 Note that pragma Suppress gives the compiler permission to omit
8093 checks, but does not require the compiler to omit checks. The compiler
8094 will generate checks if they are essentially free, even when they are
8095 suppressed. In particular, if the compiler can prove that a certain
8096 check will necessarily fail, it will generate code to do an
8097 unconditional 'raise', even if checks are suppressed. The compiler
8098 warns in this case.
8099
8100 Of course, run-time checks are omitted whenever the compiler can prove
8101 that they will not fail, whether or not checks are suppressed.
8102
8103 @node Pragma Suppress_All,Pragma Suppress_Debug_Info,Pragma Suppress,Implementation Defined Pragmas
8104 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-all}@anchor{f6}
8105 @section Pragma Suppress_All
8106
8107
8108 Syntax:
8109
8110 @example
8111 pragma Suppress_All;
8112 @end example
8113
8114 This pragma can appear anywhere within a unit.
8115 The effect is to apply @code{Suppress (All_Checks)} to the unit
8116 in which it appears. This pragma is implemented for compatibility with DEC
8117 Ada 83 usage where it appears at the end of a unit, and for compatibility
8118 with Rational Ada, where it appears as a program unit pragma.
8119 The use of the standard Ada pragma @code{Suppress (All_Checks)}
8120 as a normal configuration pragma is the preferred usage in GNAT.
8121
8122 @node Pragma Suppress_Debug_Info,Pragma Suppress_Exception_Locations,Pragma Suppress_All,Implementation Defined Pragmas
8123 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-debug-info}@anchor{f7}@anchor{gnat_rm/implementation_defined_pragmas id43}@anchor{f8}
8124 @section Pragma Suppress_Debug_Info
8125
8126
8127 Syntax:
8128
8129 @example
8130 pragma Suppress_Debug_Info ([Entity =>] LOCAL_NAME);
8131 @end example
8132
8133 This pragma can be used to suppress generation of debug information
8134 for the specified entity. It is intended primarily for use in debugging
8135 the debugger, and navigating around debugger problems.
8136
8137 @node Pragma Suppress_Exception_Locations,Pragma Suppress_Initialization,Pragma Suppress_Debug_Info,Implementation Defined Pragmas
8138 @anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-exception-locations}@anchor{f9}
8139 @section Pragma Suppress_Exception_Locations
8140
8141
8142 Syntax:
8143
8144 @example
8145 pragma Suppress_Exception_Locations;
8146 @end example
8147
8148 In normal mode, a raise statement for an exception by default generates
8149 an exception message giving the file name and line number for the location
8150 of the raise. This is useful for debugging and logging purposes, but this
8151 entails extra space for the strings for the messages. The configuration
8152 pragma @code{Suppress_Exception_Locations} can be used to suppress the
8153 generation of these strings, with the result that space is saved, but the
8154 exception message for such raises is null. This configuration pragma may
8155 appear in a global configuration pragma file, or in a specific unit as
8156 usual. It is not required that this pragma be used consistently within
8157 a partition, so it is fine to have some units within a partition compiled
8158 with this pragma and others compiled in normal mode without it.
8159
8160 @node Pragma Suppress_Initialization,Pragma Task_Name,Pragma Suppress_Exception_Locations,Implementation Defined Pragmas
8161 @anchor{gnat_rm/implementation_defined_pragmas id44}@anchor{fa}@anchor{gnat_rm/implementation_defined_pragmas pragma-suppress-initialization}@anchor{fb}
8162 @section Pragma Suppress_Initialization
8163
8164
8165 @geindex Suppressing initialization
8166
8167 @geindex Initialization
8168 @geindex suppression of
8169
8170 Syntax:
8171
8172 @example
8173 pragma Suppress_Initialization ([Entity =>] variable_or_subtype_Name);
8174 @end example
8175
8176 Here variable_or_subtype_Name is the name introduced by a type declaration
8177 or subtype declaration or the name of a variable introduced by an
8178 object declaration.
8179
8180 In the case of a type or subtype
8181 this pragma suppresses any implicit or explicit initialization
8182 for all variables of the given type or subtype,
8183 including initialization resulting from the use of pragmas
8184 Normalize_Scalars or Initialize_Scalars.
8185
8186 This is considered a representation item, so it cannot be given after
8187 the type is frozen. It applies to all subsequent object declarations,
8188 and also any allocator that creates objects of the type.
8189
8190 If the pragma is given for the first subtype, then it is considered
8191 to apply to the base type and all its subtypes. If the pragma is given
8192 for other than a first subtype, then it applies only to the given subtype.
8193 The pragma may not be given after the type is frozen.
8194
8195 Note that this includes eliminating initialization of discriminants
8196 for discriminated types, and tags for tagged types. In these cases,
8197 you will have to use some non-portable mechanism (e.g. address
8198 overlays or unchecked conversion) to achieve required initialization
8199 of these fields before accessing any object of the corresponding type.
8200
8201 For the variable case, implicit initialization for the named variable
8202 is suppressed, just as though its subtype had been given in a pragma
8203 Suppress_Initialization, as described above.
8204
8205 @node Pragma Task_Name,Pragma Task_Storage,Pragma Suppress_Initialization,Implementation Defined Pragmas
8206 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-name}@anchor{fc}
8207 @section Pragma Task_Name
8208
8209
8210 Syntax
8211
8212 @example
8213 pragma Task_Name (string_EXPRESSION);
8214 @end example
8215
8216 This pragma appears within a task definition (like pragma
8217 @code{Priority}) and applies to the task in which it appears. The
8218 argument must be of type String, and provides a name to be used for
8219 the task instance when the task is created. Note that this expression
8220 is not required to be static, and in particular, it can contain
8221 references to task discriminants. This facility can be used to
8222 provide different names for different tasks as they are created,
8223 as illustrated in the example below.
8224
8225 The task name is recorded internally in the run-time structures
8226 and is accessible to tools like the debugger. In addition the
8227 routine @code{Ada.Task_Identification.Image} will return this
8228 string, with a unique task address appended.
8229
8230 @example
8231 -- Example of the use of pragma Task_Name
8232
8233 with Ada.Task_Identification;
8234 use Ada.Task_Identification;
8235 with Text_IO; use Text_IO;
8236 procedure t3 is
8237
8238 type Astring is access String;
8239
8240 task type Task_Typ (Name : access String) is
8241 pragma Task_Name (Name.all);
8242 end Task_Typ;
8243
8244 task body Task_Typ is
8245 Nam : constant String := Image (Current_Task);
8246 begin
8247 Put_Line ("-->" & Nam (1 .. 14) & "<--");
8248 end Task_Typ;
8249
8250 type Ptr_Task is access Task_Typ;
8251 Task_Var : Ptr_Task;
8252
8253 begin
8254 Task_Var :=
8255 new Task_Typ (new String'("This is task 1"));
8256 Task_Var :=
8257 new Task_Typ (new String'("This is task 2"));
8258 end;
8259 @end example
8260
8261 @node Pragma Task_Storage,Pragma Test_Case,Pragma Task_Name,Implementation Defined Pragmas
8262 @anchor{gnat_rm/implementation_defined_pragmas pragma-task-storage}@anchor{fd}
8263 @section Pragma Task_Storage
8264
8265
8266 Syntax:
8267
8268 @example
8269 pragma Task_Storage (
8270 [Task_Type =>] LOCAL_NAME,
8271 [Top_Guard =>] static_integer_EXPRESSION);
8272 @end example
8273
8274 This pragma specifies the length of the guard area for tasks. The guard
8275 area is an additional storage area allocated to a task. A value of zero
8276 means that either no guard area is created or a minimal guard area is
8277 created, depending on the target. This pragma can appear anywhere a
8278 @code{Storage_Size} attribute definition clause is allowed for a task
8279 type.
8280
8281 @node Pragma Test_Case,Pragma Thread_Local_Storage,Pragma Task_Storage,Implementation Defined Pragmas
8282 @anchor{gnat_rm/implementation_defined_pragmas pragma-test-case}@anchor{fe}@anchor{gnat_rm/implementation_defined_pragmas id45}@anchor{ff}
8283 @section Pragma Test_Case
8284
8285
8286 @geindex Test cases
8287
8288 Syntax:
8289
8290 @example
8291 pragma Test_Case (
8292 [Name =>] static_string_Expression
8293 ,[Mode =>] (Nominal | Robustness)
8294 [, Requires => Boolean_Expression]
8295 [, Ensures => Boolean_Expression]);
8296 @end example
8297
8298 The @code{Test_Case} pragma allows defining fine-grain specifications
8299 for use by testing tools.
8300 The compiler checks the validity of the @code{Test_Case} pragma, but its
8301 presence does not lead to any modification of the code generated by the
8302 compiler.
8303
8304 @code{Test_Case} pragmas may only appear immediately following the
8305 (separate) declaration of a subprogram in a package declaration, inside
8306 a package spec unit. Only other pragmas may intervene (that is appear
8307 between the subprogram declaration and a test case).
8308
8309 The compiler checks that boolean expressions given in @code{Requires} and
8310 @code{Ensures} are valid, where the rules for @code{Requires} are the
8311 same as the rule for an expression in @code{Precondition} and the rules
8312 for @code{Ensures} are the same as the rule for an expression in
8313 @code{Postcondition}. In particular, attributes @code{'Old} and
8314 @code{'Result} can only be used within the @code{Ensures}
8315 expression. The following is an example of use within a package spec:
8316
8317 @example
8318 package Math_Functions is
8319 ...
8320 function Sqrt (Arg : Float) return Float;
8321 pragma Test_Case (Name => "Test 1",
8322 Mode => Nominal,
8323 Requires => Arg < 10000,
8324 Ensures => Sqrt'Result < 10);
8325 ...
8326 end Math_Functions;
8327 @end example
8328
8329 The meaning of a test case is that there is at least one context where
8330 @code{Requires} holds such that, if the associated subprogram is executed in
8331 that context, then @code{Ensures} holds when the subprogram returns.
8332 Mode @code{Nominal} indicates that the input context should also satisfy the
8333 precondition of the subprogram, and the output context should also satisfy its
8334 postcondition. Mode @code{Robustness} indicates that the precondition and
8335 postcondition of the subprogram should be ignored for this test case.
8336
8337 @node Pragma Thread_Local_Storage,Pragma Time_Slice,Pragma Test_Case,Implementation Defined Pragmas
8338 @anchor{gnat_rm/implementation_defined_pragmas pragma-thread-local-storage}@anchor{100}@anchor{gnat_rm/implementation_defined_pragmas id46}@anchor{101}
8339 @section Pragma Thread_Local_Storage
8340
8341
8342 @geindex Task specific storage
8343
8344 @geindex TLS (Thread Local Storage)
8345
8346 @geindex Task_Attributes
8347
8348 Syntax:
8349
8350 @example
8351 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
8352 @end example
8353
8354 This pragma specifies that the specified entity, which must be
8355 a variable declared in a library-level package, is to be marked as
8356 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
8357 include Windows, Solaris, GNU/Linux, and VxWorks 6), this causes each
8358 thread (and hence each Ada task) to see a distinct copy of the variable.
8359
8360 The variable must not have default initialization, and if there is
8361 an explicit initialization, it must be either @code{null} for an
8362 access variable, a static expression for a scalar variable, or a fully
8363 static aggregate for a composite type, that is to say, an aggregate all
8364 of whose components are static, and which does not include packed or
8365 discriminated components.
8366
8367 This provides a low-level mechanism similar to that provided by
8368 the @code{Ada.Task_Attributes} package, but much more efficient
8369 and is also useful in writing interface code that will interact
8370 with foreign threads.
8371
8372 If this pragma is used on a system where @code{TLS} is not supported,
8373 then an error message will be generated and the program will be rejected.
8374
8375 @node Pragma Time_Slice,Pragma Title,Pragma Thread_Local_Storage,Implementation Defined Pragmas
8376 @anchor{gnat_rm/implementation_defined_pragmas pragma-time-slice}@anchor{102}
8377 @section Pragma Time_Slice
8378
8379
8380 Syntax:
8381
8382 @example
8383 pragma Time_Slice (static_duration_EXPRESSION);
8384 @end example
8385
8386 For implementations of GNAT on operating systems where it is possible
8387 to supply a time slice value, this pragma may be used for this purpose.
8388 It is ignored if it is used in a system that does not allow this control,
8389 or if it appears in other than the main program unit.
8390
8391 @node Pragma Title,Pragma Type_Invariant,Pragma Time_Slice,Implementation Defined Pragmas
8392 @anchor{gnat_rm/implementation_defined_pragmas pragma-title}@anchor{103}
8393 @section Pragma Title
8394
8395
8396 Syntax:
8397
8398 @example
8399 pragma Title (TITLING_OPTION [, TITLING OPTION]);
8400
8401 TITLING_OPTION ::=
8402 [Title =>] STRING_LITERAL,
8403 | [Subtitle =>] STRING_LITERAL
8404 @end example
8405
8406 Syntax checked but otherwise ignored by GNAT. This is a listing control
8407 pragma used in DEC Ada 83 implementations to provide a title and/or
8408 subtitle for the program listing. The program listing generated by GNAT
8409 does not have titles or subtitles.
8410
8411 Unlike other pragmas, the full flexibility of named notation is allowed
8412 for this pragma, i.e., the parameters may be given in any order if named
8413 notation is used, and named and positional notation can be mixed
8414 following the normal rules for procedure calls in Ada.
8415
8416 @node Pragma Type_Invariant,Pragma Type_Invariant_Class,Pragma Title,Implementation Defined Pragmas
8417 @anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant}@anchor{104}
8418 @section Pragma Type_Invariant
8419
8420
8421 Syntax:
8422
8423 @example
8424 pragma Type_Invariant
8425 ([Entity =>] type_LOCAL_NAME,
8426 [Check =>] EXPRESSION);
8427 @end example
8428
8429 The @code{Type_Invariant} pragma is intended to be an exact
8430 replacement for the language-defined @code{Type_Invariant}
8431 aspect, and shares its restrictions and semantics. It differs
8432 from the language defined @code{Invariant} pragma in that it
8433 does not permit a string parameter, and it is
8434 controlled by the assertion identifier @code{Type_Invariant}
8435 rather than @code{Invariant}.
8436
8437 @node Pragma Type_Invariant_Class,Pragma Unchecked_Union,Pragma Type_Invariant,Implementation Defined Pragmas
8438 @anchor{gnat_rm/implementation_defined_pragmas id47}@anchor{105}@anchor{gnat_rm/implementation_defined_pragmas pragma-type-invariant-class}@anchor{106}
8439 @section Pragma Type_Invariant_Class
8440
8441
8442 Syntax:
8443
8444 @example
8445 pragma Type_Invariant_Class
8446 ([Entity =>] type_LOCAL_NAME,
8447 [Check =>] EXPRESSION);
8448 @end example
8449
8450 The @code{Type_Invariant_Class} pragma is intended to be an exact
8451 replacement for the language-defined @code{Type_Invariant'Class}
8452 aspect, and shares its restrictions and semantics.
8453
8454 Note: This pragma is called @code{Type_Invariant_Class} rather than
8455 @code{Type_Invariant'Class} because the latter would not be strictly
8456 conforming to the allowed syntax for pragmas. The motivation
8457 for providing pragmas equivalent to the aspects is to allow a program
8458 to be written using the pragmas, and then compiled if necessary
8459 using an Ada compiler that does not recognize the pragmas or
8460 aspects, but is prepared to ignore the pragmas. The assertion
8461 policy that controls this pragma is @code{Type_Invariant'Class},
8462 not @code{Type_Invariant_Class}.
8463
8464 @node Pragma Unchecked_Union,Pragma Unevaluated_Use_Of_Old,Pragma Type_Invariant_Class,Implementation Defined Pragmas
8465 @anchor{gnat_rm/implementation_defined_pragmas pragma-unchecked-union}@anchor{107}
8466 @section Pragma Unchecked_Union
8467
8468
8469 @geindex Unions in C
8470
8471 Syntax:
8472
8473 @example
8474 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
8475 @end example
8476
8477 This pragma is used to specify a representation of a record type that is
8478 equivalent to a C union. It was introduced as a GNAT implementation defined
8479 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
8480 pragma, making it language defined, and GNAT fully implements this extended
8481 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
8482 details, consult the Ada 2012 Reference Manual, section B.3.3.
8483
8484 @node Pragma Unevaluated_Use_Of_Old,Pragma Unimplemented_Unit,Pragma Unchecked_Union,Implementation Defined Pragmas
8485 @anchor{gnat_rm/implementation_defined_pragmas pragma-unevaluated-use-of-old}@anchor{108}
8486 @section Pragma Unevaluated_Use_Of_Old
8487
8488
8489 @geindex Attribute Old
8490
8491 @geindex Attribute Loop_Entry
8492
8493 @geindex Unevaluated_Use_Of_Old
8494
8495 Syntax:
8496
8497 @example
8498 pragma Unevaluated_Use_Of_Old (Error | Warn | Allow);
8499 @end example
8500
8501 This pragma controls the processing of attributes Old and Loop_Entry.
8502 If either of these attributes is used in a potentially unevaluated
8503 expression (e.g. the then or else parts of an if expression), then
8504 normally this usage is considered illegal if the prefix of the attribute
8505 is other than an entity name. The language requires this
8506 behavior for Old, and GNAT copies the same rule for Loop_Entry.
8507
8508 The reason for this rule is that otherwise, we can have a situation
8509 where we save the Old value, and this results in an exception, even
8510 though we might not evaluate the attribute. Consider this example:
8511
8512 @example
8513 package UnevalOld is
8514 K : Character;
8515 procedure U (A : String; C : Boolean) -- ERROR
8516 with Post => (if C then A(1)'Old = K else True);
8517 end;
8518 @end example
8519
8520 If procedure U is called with a string with a lower bound of 2, and
8521 C false, then an exception would be raised trying to evaluate A(1)
8522 on entry even though the value would not be actually used.
8523
8524 Although the rule guarantees against this possibility, it is sometimes
8525 too restrictive. For example if we know that the string has a lower
8526 bound of 1, then we will never raise an exception.
8527 The pragma @code{Unevaluated_Use_Of_Old} can be
8528 used to modify this behavior. If the argument is @code{Error} then an
8529 error is given (this is the default RM behavior). If the argument is
8530 @code{Warn} then the usage is allowed as legal but with a warning
8531 that an exception might be raised. If the argument is @code{Allow}
8532 then the usage is allowed as legal without generating a warning.
8533
8534 This pragma may appear as a configuration pragma, or in a declarative
8535 part or package specification. In the latter case it applies to
8536 uses up to the end of the corresponding statement sequence or
8537 sequence of package declarations.
8538
8539 @node Pragma Unimplemented_Unit,Pragma Universal_Aliasing,Pragma Unevaluated_Use_Of_Old,Implementation Defined Pragmas
8540 @anchor{gnat_rm/implementation_defined_pragmas pragma-unimplemented-unit}@anchor{109}
8541 @section Pragma Unimplemented_Unit
8542
8543
8544 Syntax:
8545
8546 @example
8547 pragma Unimplemented_Unit;
8548 @end example
8549
8550 If this pragma occurs in a unit that is processed by the compiler, GNAT
8551 aborts with the message @code{xxx not implemented}, where
8552 @code{xxx} is the name of the current compilation unit. This pragma is
8553 intended to allow the compiler to handle unimplemented library units in
8554 a clean manner.
8555
8556 The abort only happens if code is being generated. Thus you can use
8557 specs of unimplemented packages in syntax or semantic checking mode.
8558
8559 @node Pragma Universal_Aliasing,Pragma Universal_Data,Pragma Unimplemented_Unit,Implementation Defined Pragmas
8560 @anchor{gnat_rm/implementation_defined_pragmas pragma-universal-aliasing}@anchor{10a}@anchor{gnat_rm/implementation_defined_pragmas id48}@anchor{10b}
8561 @section Pragma Universal_Aliasing
8562
8563
8564 Syntax:
8565
8566 @example
8567 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
8568 @end example
8569
8570 @code{type_LOCAL_NAME} must refer to a type declaration in the current
8571 declarative part. The effect is to inhibit strict type-based aliasing
8572 optimization for the given type. In other words, the effect is as though
8573 access types designating this type were subject to pragma No_Strict_Aliasing.
8574 For a detailed description of the strict aliasing optimization, and the
8575 situations in which it must be suppressed, see the section on
8576 @code{Optimization and Strict Aliasing} in the @cite{GNAT User's Guide}.
8577
8578 @node Pragma Universal_Data,Pragma Unmodified,Pragma Universal_Aliasing,Implementation Defined Pragmas
8579 @anchor{gnat_rm/implementation_defined_pragmas pragma-universal-data}@anchor{10c}@anchor{gnat_rm/implementation_defined_pragmas id49}@anchor{10d}
8580 @section Pragma Universal_Data
8581
8582
8583 Syntax:
8584
8585 @example
8586 pragma Universal_Data [(library_unit_Name)];
8587 @end example
8588
8589 This pragma is supported only for the AAMP target and is ignored for
8590 other targets. The pragma specifies that all library-level objects
8591 (Counter 0 data) associated with the library unit are to be accessed
8592 and updated using universal addressing (24-bit addresses for AAMP5)
8593 rather than the default of 16-bit Data Environment (DENV) addressing.
8594 Use of this pragma will generally result in less efficient code for
8595 references to global data associated with the library unit, but
8596 allows such data to be located anywhere in memory. This pragma is
8597 a library unit pragma, but can also be used as a configuration pragma
8598 (including use in the @code{gnat.adc} file). The functionality
8599 of this pragma is also available by applying the -univ switch on the
8600 compilations of units where universal addressing of the data is desired.
8601
8602 @node Pragma Unmodified,Pragma Unreferenced,Pragma Universal_Data,Implementation Defined Pragmas
8603 @anchor{gnat_rm/implementation_defined_pragmas id50}@anchor{10e}@anchor{gnat_rm/implementation_defined_pragmas pragma-unmodified}@anchor{10f}
8604 @section Pragma Unmodified
8605
8606
8607 @geindex Warnings
8608 @geindex unmodified
8609
8610 Syntax:
8611
8612 @example
8613 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
8614 @end example
8615
8616 This pragma signals that the assignable entities (variables,
8617 @code{out} parameters, @code{in out} parameters) whose names are listed are
8618 deliberately not assigned in the current source unit. This
8619 suppresses warnings about the
8620 entities being referenced but not assigned, and in addition a warning will be
8621 generated if one of these entities is in fact assigned in the
8622 same unit as the pragma (or in the corresponding body, or one
8623 of its subunits).
8624
8625 This is particularly useful for clearly signaling that a particular
8626 parameter is not modified, even though the spec suggests that it might
8627 be.
8628
8629 For the variable case, warnings are never given for unreferenced variables
8630 whose name contains one of the substrings
8631 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8632 are typically to be used in cases where such warnings are expected.
8633 Thus it is never necessary to use @code{pragma Unmodified} for such
8634 variables, though it is harmless to do so.
8635
8636 @node Pragma Unreferenced,Pragma Unreferenced_Objects,Pragma Unmodified,Implementation Defined Pragmas
8637 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced}@anchor{110}@anchor{gnat_rm/implementation_defined_pragmas id51}@anchor{111}
8638 @section Pragma Unreferenced
8639
8640
8641 @geindex Warnings
8642 @geindex unreferenced
8643
8644 Syntax:
8645
8646 @example
8647 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
8648 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
8649 @end example
8650
8651 This pragma signals that the entities whose names are listed are
8652 deliberately not referenced in the current source unit after the
8653 occurrence of the pragma. This
8654 suppresses warnings about the
8655 entities being unreferenced, and in addition a warning will be
8656 generated if one of these entities is in fact subsequently referenced in the
8657 same unit as the pragma (or in the corresponding body, or one
8658 of its subunits).
8659
8660 This is particularly useful for clearly signaling that a particular
8661 parameter is not referenced in some particular subprogram implementation
8662 and that this is deliberate. It can also be useful in the case of
8663 objects declared only for their initialization or finalization side
8664 effects.
8665
8666 If @code{LOCAL_NAME} identifies more than one matching homonym in the
8667 current scope, then the entity most recently declared is the one to which
8668 the pragma applies. Note that in the case of accept formals, the pragma
8669 Unreferenced may appear immediately after the keyword @code{do} which
8670 allows the indication of whether or not accept formals are referenced
8671 or not to be given individually for each accept statement.
8672
8673 The left hand side of an assignment does not count as a reference for the
8674 purpose of this pragma. Thus it is fine to assign to an entity for which
8675 pragma Unreferenced is given.
8676
8677 Note that if a warning is desired for all calls to a given subprogram,
8678 regardless of whether they occur in the same unit as the subprogram
8679 declaration, then this pragma should not be used (calls from another
8680 unit would not be flagged); pragma Obsolescent can be used instead
8681 for this purpose, see @ref{af,,Pragma Obsolescent}.
8682
8683 The second form of pragma @code{Unreferenced} is used within a context
8684 clause. In this case the arguments must be unit names of units previously
8685 mentioned in @code{with} clauses (similar to the usage of pragma
8686 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
8687 units and unreferenced entities within these units.
8688
8689 For the variable case, warnings are never given for unreferenced variables
8690 whose name contains one of the substrings
8691 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8692 are typically to be used in cases where such warnings are expected.
8693 Thus it is never necessary to use @code{pragma Unreferenced} for such
8694 variables, though it is harmless to do so.
8695
8696 @node Pragma Unreferenced_Objects,Pragma Unreserve_All_Interrupts,Pragma Unreferenced,Implementation Defined Pragmas
8697 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreferenced-objects}@anchor{112}@anchor{gnat_rm/implementation_defined_pragmas id52}@anchor{113}
8698 @section Pragma Unreferenced_Objects
8699
8700
8701 @geindex Warnings
8702 @geindex unreferenced
8703
8704 Syntax:
8705
8706 @example
8707 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
8708 @end example
8709
8710 This pragma signals that for the types or subtypes whose names are
8711 listed, objects which are declared with one of these types or subtypes may
8712 not be referenced, and if no references appear, no warnings are given.
8713
8714 This is particularly useful for objects which are declared solely for their
8715 initialization and finalization effect. Such variables are sometimes referred
8716 to as RAII variables (Resource Acquisition Is Initialization). Using this
8717 pragma on the relevant type (most typically a limited controlled type), the
8718 compiler will automatically suppress unwanted warnings about these variables
8719 not being referenced.
8720
8721 @node Pragma Unreserve_All_Interrupts,Pragma Unsuppress,Pragma Unreferenced_Objects,Implementation Defined Pragmas
8722 @anchor{gnat_rm/implementation_defined_pragmas pragma-unreserve-all-interrupts}@anchor{114}
8723 @section Pragma Unreserve_All_Interrupts
8724
8725
8726 Syntax:
8727
8728 @example
8729 pragma Unreserve_All_Interrupts;
8730 @end example
8731
8732 Normally certain interrupts are reserved to the implementation. Any attempt
8733 to attach an interrupt causes Program_Error to be raised, as described in
8734 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
8735 many systems for a @code{Ctrl-C} interrupt. Normally this interrupt is
8736 reserved to the implementation, so that @code{Ctrl-C} can be used to
8737 interrupt execution.
8738
8739 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
8740 a program, then all such interrupts are unreserved. This allows the
8741 program to handle these interrupts, but disables their standard
8742 functions. For example, if this pragma is used, then pressing
8743 @code{Ctrl-C} will not automatically interrupt execution. However,
8744 a program can then handle the @code{SIGINT} interrupt as it chooses.
8745
8746 For a full list of the interrupts handled in a specific implementation,
8747 see the source code for the spec of @code{Ada.Interrupts.Names} in
8748 file @code{a-intnam.ads}. This is a target dependent file that contains the
8749 list of interrupts recognized for a given target. The documentation in
8750 this file also specifies what interrupts are affected by the use of
8751 the @code{Unreserve_All_Interrupts} pragma.
8752
8753 For a more general facility for controlling what interrupts can be
8754 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
8755 of the @code{Unreserve_All_Interrupts} pragma.
8756
8757 @node Pragma Unsuppress,Pragma Use_VADS_Size,Pragma Unreserve_All_Interrupts,Implementation Defined Pragmas
8758 @anchor{gnat_rm/implementation_defined_pragmas pragma-unsuppress}@anchor{115}
8759 @section Pragma Unsuppress
8760
8761
8762 Syntax:
8763
8764 @example
8765 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
8766 @end example
8767
8768 This pragma undoes the effect of a previous pragma @code{Suppress}. If
8769 there is no corresponding pragma @code{Suppress} in effect, it has no
8770 effect. The range of the effect is the same as for pragma
8771 @code{Suppress}. The meaning of the arguments is identical to that used
8772 in pragma @code{Suppress}.
8773
8774 One important application is to ensure that checks are on in cases where
8775 code depends on the checks for its correct functioning, so that the code
8776 will compile correctly even if the compiler switches are set to suppress
8777 checks. For example, in a program that depends on external names of tagged
8778 types and wants to ensure that the duplicated tag check occurs even if all
8779 run-time checks are suppressed by a compiler switch, the following
8780 configuration pragma will ensure this test is not suppressed:
8781
8782 @example
8783 pragma Unsuppress (Duplicated_Tag_Check);
8784 @end example
8785
8786 This pragma is standard in Ada 2005. It is available in all earlier versions
8787 of Ada as an implementation-defined pragma.
8788
8789 Note that in addition to the checks defined in the Ada RM, GNAT recogizes a
8790 number of implementation-defined check names. See the description of pragma
8791 @code{Suppress} for full details.
8792
8793 @node Pragma Use_VADS_Size,Pragma Unused,Pragma Unsuppress,Implementation Defined Pragmas
8794 @anchor{gnat_rm/implementation_defined_pragmas pragma-use-vads-size}@anchor{116}
8795 @section Pragma Use_VADS_Size
8796
8797
8798 @geindex Size
8799 @geindex VADS compatibility
8800
8801 @geindex Rational profile
8802
8803 Syntax:
8804
8805 @example
8806 pragma Use_VADS_Size;
8807 @end example
8808
8809 This is a configuration pragma. In a unit to which it applies, any use
8810 of the 'Size attribute is automatically interpreted as a use of the
8811 'VADS_Size attribute. Note that this may result in incorrect semantic
8812 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
8813 the handling of existing code which depends on the interpretation of Size
8814 as implemented in the VADS compiler. See description of the VADS_Size
8815 attribute for further details.
8816
8817 @node Pragma Unused,Pragma Validity_Checks,Pragma Use_VADS_Size,Implementation Defined Pragmas
8818 @anchor{gnat_rm/implementation_defined_pragmas pragma-unused}@anchor{117}@anchor{gnat_rm/implementation_defined_pragmas id53}@anchor{118}
8819 @section Pragma Unused
8820
8821
8822 @geindex Warnings
8823 @geindex unused
8824
8825 Syntax:
8826
8827 @example
8828 pragma Unused (LOCAL_NAME @{, LOCAL_NAME@});
8829 @end example
8830
8831 This pragma signals that the assignable entities (variables,
8832 @code{out} parameters, and @code{in out} parameters) whose names are listed
8833 deliberately do not get assigned or referenced in the current source unit
8834 after the occurrence of the pragma in the current source unit. This
8835 suppresses warnings about the entities that are unreferenced and/or not
8836 assigned, and, in addition, a warning will be generated if one of these
8837 entities gets assigned or subsequently referenced in the same unit as the
8838 pragma (in the corresponding body or one of its subunits).
8839
8840 This is particularly useful for clearly signaling that a particular
8841 parameter is not modified or referenced, even though the spec suggests
8842 that it might be.
8843
8844 For the variable case, warnings are never given for unreferenced
8845 variables whose name contains one of the substrings
8846 @code{DISCARD, DUMMY, IGNORE, JUNK, UNUSED} in any casing. Such names
8847 are typically to be used in cases where such warnings are expected.
8848 Thus it is never necessary to use @code{pragma Unmodified} for such
8849 variables, though it is harmless to do so.
8850
8851 @node Pragma Validity_Checks,Pragma Volatile,Pragma Unused,Implementation Defined Pragmas
8852 @anchor{gnat_rm/implementation_defined_pragmas pragma-validity-checks}@anchor{119}
8853 @section Pragma Validity_Checks
8854
8855
8856 Syntax:
8857
8858 @example
8859 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
8860 @end example
8861
8862 This pragma is used in conjunction with compiler switches to control the
8863 built-in validity checking provided by GNAT. The compiler switches, if set
8864 provide an initial setting for the switches, and this pragma may be used
8865 to modify these settings, or the settings may be provided entirely by
8866 the use of the pragma. This pragma can be used anywhere that a pragma
8867 is legal, including use as a configuration pragma (including use in
8868 the @code{gnat.adc} file).
8869
8870 The form with a string literal specifies which validity options are to be
8871 activated. The validity checks are first set to include only the default
8872 reference manual settings, and then a string of letters in the string
8873 specifies the exact set of options required. The form of this string
8874 is exactly as described for the @emph{-gnatVx} compiler switch (see the
8875 GNAT User's Guide for details). For example the following two
8876 methods can be used to enable validity checking for mode @code{in} and
8877 @code{in out} subprogram parameters:
8878
8879
8880 @itemize *
8881
8882 @item
8883 @example
8884 pragma Validity_Checks ("im");
8885 @end example
8886
8887 @item
8888 @example
8889 $ gcc -c -gnatVim ...
8890 @end example
8891 @end itemize
8892
8893 The form ALL_CHECKS activates all standard checks (its use is equivalent
8894 to the use of the @code{gnatVa} switch).
8895
8896 The forms with @code{Off} and @code{On} can be used to temporarily disable
8897 validity checks as shown in the following example:
8898
8899 @example
8900 pragma Validity_Checks ("c"); -- validity checks for copies
8901 pragma Validity_Checks (Off); -- turn off validity checks
8902 A := B; -- B will not be validity checked
8903 pragma Validity_Checks (On); -- turn validity checks back on
8904 A := C; -- C will be validity checked
8905 @end example
8906
8907 @node Pragma Volatile,Pragma Volatile_Full_Access,Pragma Validity_Checks,Implementation Defined Pragmas
8908 @anchor{gnat_rm/implementation_defined_pragmas id54}@anchor{11a}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile}@anchor{11b}
8909 @section Pragma Volatile
8910
8911
8912 Syntax:
8913
8914 @example
8915 pragma Volatile (LOCAL_NAME);
8916 @end example
8917
8918 This pragma is defined by the Ada Reference Manual, and the GNAT
8919 implementation is fully conformant with this definition. The reason it
8920 is mentioned in this section is that a pragma of the same name was supplied
8921 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
8922 implementation of pragma Volatile is upwards compatible with the
8923 implementation in DEC Ada 83.
8924
8925 @node Pragma Volatile_Full_Access,Pragma Volatile_Function,Pragma Volatile,Implementation Defined Pragmas
8926 @anchor{gnat_rm/implementation_defined_pragmas id55}@anchor{11c}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-full-access}@anchor{11d}
8927 @section Pragma Volatile_Full_Access
8928
8929
8930 Syntax:
8931
8932 @example
8933 pragma Volatile_Full_Access (LOCAL_NAME);
8934 @end example
8935
8936 This is similar in effect to pragma Volatile, except that any reference to the
8937 object is guaranteed to be done only with instructions that read or write all
8938 the bits of the object. Furthermore, if the object is of a composite type,
8939 then any reference to a subcomponent of the object is guaranteed to read
8940 and/or write all the bits of the object.
8941
8942 The intention is that this be suitable for use with memory-mapped I/O devices
8943 on some machines. Note that there are two important respects in which this is
8944 different from @code{pragma Atomic}. First a reference to a @code{Volatile_Full_Access}
8945 object is not a sequential action in the RM 9.10 sense and, therefore, does
8946 not create a synchronization point. Second, in the case of @code{pragma Atomic},
8947 there is no guarantee that all the bits will be accessed if the reference
8948 is not to the whole object; the compiler is allowed (and generally will)
8949 access only part of the object in this case.
8950
8951 It is not permissible to specify @code{Atomic} and @code{Volatile_Full_Access} for
8952 the same type or object.
8953
8954 It is not permissible to specify @code{Volatile_Full_Access} for a composite
8955 (record or array) type or object that has an @code{Aliased} subcomponent.
8956
8957 @node Pragma Volatile_Function,Pragma Warning_As_Error,Pragma Volatile_Full_Access,Implementation Defined Pragmas
8958 @anchor{gnat_rm/implementation_defined_pragmas id56}@anchor{11e}@anchor{gnat_rm/implementation_defined_pragmas pragma-volatile-function}@anchor{11f}
8959 @section Pragma Volatile_Function
8960
8961
8962 Syntax:
8963
8964 @example
8965 pragma Volatile_Function [ (boolean_EXPRESSION) ];
8966 @end example
8967
8968 For the semantics of this pragma, see the entry for aspect @code{Volatile_Function}
8969 in the SPARK 2014 Reference Manual, section 7.1.2.
8970
8971 @node Pragma Warning_As_Error,Pragma Warnings,Pragma Volatile_Function,Implementation Defined Pragmas
8972 @anchor{gnat_rm/implementation_defined_pragmas pragma-warning-as-error}@anchor{120}
8973 @section Pragma Warning_As_Error
8974
8975
8976 Syntax:
8977
8978 @example
8979 pragma Warning_As_Error (static_string_EXPRESSION);
8980 @end example
8981
8982 This configuration pragma allows the programmer to specify a set
8983 of warnings that will be treated as errors. Any warning that
8984 matches the pattern given by the pragma argument will be treated
8985 as an error. This gives more precise control than -gnatwe,
8986 which treats warnings as errors.
8987
8988 This pragma can apply to regular warnings (messages enabled by -gnatw)
8989 and to style warnings (messages that start with "(style)",
8990 enabled by -gnaty).
8991
8992 The pattern may contain asterisks, which match zero or more characters
8993 in the message. For example, you can use @code{pragma Warning_As_Error
8994 ("bits of*unused")} to treat the warning message @code{warning: 960 bits of
8995 "a" unused} as an error. All characters other than asterisk are treated
8996 as literal characters in the match. The match is case insensitive; for
8997 example XYZ matches xyz.
8998
8999 Note that the pattern matches if it occurs anywhere within the warning
9000 message string (it is not necessary to put an asterisk at the start and
9001 the end of the message, since this is implied).
9002
9003 Another possibility for the static_string_EXPRESSION which works whether
9004 or not error tags are enabled (@emph{-gnatw.d}) is to use a single
9005 @emph{-gnatw} tag string, enclosed in brackets,
9006 as shown in the example below, to treat one category of warnings as errors.
9007 Note that if you want to treat multiple categories of warnings as errors,
9008 you can use multiple pragma Warning_As_Error.
9009
9010 The above use of patterns to match the message applies only to warning
9011 messages generated by the front end. This pragma can also be applied to
9012 warnings provided by the back end and mentioned in @ref{121,,Pragma Warnings}.
9013 By using a single full @emph{-Wxxx} switch in the pragma, such warnings
9014 can also be treated as errors.
9015
9016 The pragma can appear either in a global configuration pragma file
9017 (e.g. @code{gnat.adc}), or at the start of a file. Given a global
9018 configuration pragma file containing:
9019
9020 @example
9021 pragma Warning_As_Error ("[-gnatwj]");
9022 @end example
9023
9024 which will treat all obsolescent feature warnings as errors, the
9025 following program compiles as shown (compile options here are
9026 @emph{-gnatwa.d -gnatl -gnatj55}).
9027
9028 @example
9029 1. pragma Warning_As_Error ("*never assigned*");
9030 2. function Warnerr return String is
9031 3. X : Integer;
9032 |
9033 >>> error: variable "X" is never read and
9034 never assigned [-gnatwv] [warning-as-error]
9035
9036 4. Y : Integer;
9037 |
9038 >>> warning: variable "Y" is assigned but
9039 never read [-gnatwu]
9040
9041 5. begin
9042 6. Y := 0;
9043 7. return %ABC%;
9044 |
9045 >>> error: use of "%" is an obsolescent
9046 feature (RM J.2(4)), use """ instead
9047 [-gnatwj] [warning-as-error]
9048
9049 8. end;
9050
9051 8 lines: No errors, 3 warnings (2 treated as errors)
9052 @end example
9053
9054 Note that this pragma does not affect the set of warnings issued in
9055 any way, it merely changes the effect of a matching warning if one
9056 is produced as a result of other warnings options. As shown in this
9057 example, if the pragma results in a warning being treated as an error,
9058 the tag is changed from "warning:" to "error:" and the string
9059 "[warning-as-error]" is appended to the end of the message.
9060
9061 @node Pragma Warnings,Pragma Weak_External,Pragma Warning_As_Error,Implementation Defined Pragmas
9062 @anchor{gnat_rm/implementation_defined_pragmas id57}@anchor{122}@anchor{gnat_rm/implementation_defined_pragmas pragma-warnings}@anchor{121}
9063 @section Pragma Warnings
9064
9065
9066 Syntax:
9067
9068 @example
9069 pragma Warnings ([TOOL_NAME,] DETAILS [, REASON]);
9070
9071 DETAILS ::= On | Off
9072 DETAILS ::= On | Off, local_NAME
9073 DETAILS ::= static_string_EXPRESSION
9074 DETAILS ::= On | Off, static_string_EXPRESSION
9075
9076 TOOL_NAME ::= GNAT | GNATProve
9077
9078 REASON ::= Reason => STRING_LITERAL @{& STRING_LITERAL@}
9079 @end example
9080
9081 Note: in Ada 83 mode, a string literal may be used in place of a static string
9082 expression (which does not exist in Ada 83).
9083
9084 Note if the second argument of @code{DETAILS} is a @code{local_NAME} then the
9085 second form is always understood. If the intention is to use
9086 the fourth form, then you can write @code{NAME & ""} to force the
9087 intepretation as a @emph{static_string_EXPRESSION}.
9088
9089 Note: if the first argument is a valid @code{TOOL_NAME}, it will be interpreted
9090 that way. The use of the @code{TOOL_NAME} argument is relevant only to users
9091 of SPARK and GNATprove, see last part of this section for details.
9092
9093 Normally warnings are enabled, with the output being controlled by
9094 the command line switch. Warnings (@code{Off}) turns off generation of
9095 warnings until a Warnings (@code{On}) is encountered or the end of the
9096 current unit. If generation of warnings is turned off using this
9097 pragma, then some or all of the warning messages are suppressed,
9098 regardless of the setting of the command line switches.
9099
9100 The @code{Reason} parameter may optionally appear as the last argument
9101 in any of the forms of this pragma. It is intended purely for the
9102 purposes of documenting the reason for the @code{Warnings} pragma.
9103 The compiler will check that the argument is a static string but
9104 otherwise ignore this argument. Other tools may provide specialized
9105 processing for this string.
9106
9107 The form with a single argument (or two arguments if Reason present),
9108 where the first argument is @code{ON} or @code{OFF}
9109 may be used as a configuration pragma.
9110
9111 If the @code{LOCAL_NAME} parameter is present, warnings are suppressed for
9112 the specified entity. This suppression is effective from the point where
9113 it occurs till the end of the extended scope of the variable (similar to
9114 the scope of @code{Suppress}). This form cannot be used as a configuration
9115 pragma.
9116
9117 In the case where the first argument is other than @code{ON} or
9118 @code{OFF},
9119 the third form with a single static_string_EXPRESSION argument (and possible
9120 reason) provides more precise
9121 control over which warnings are active. The string is a list of letters
9122 specifying which warnings are to be activated and which deactivated. The
9123 code for these letters is the same as the string used in the command
9124 line switch controlling warnings. For a brief summary, use the gnatmake
9125 command with no arguments, which will generate usage information containing
9126 the list of warnings switches supported. For
9127 full details see the section on @code{Warning Message Control} in the
9128 @cite{GNAT User's Guide}.
9129 This form can also be used as a configuration pragma.
9130
9131 The warnings controlled by the @code{-gnatw} switch are generated by the
9132 front end of the compiler. The GCC back end can provide additional warnings
9133 and they are controlled by the @code{-W} switch. Such warnings can be
9134 identified by the appearance of a string of the form @code{[-W@{xxx@}]} in the
9135 message which designates the @code{-W@emph{xxx}} switch that controls the message.
9136 The form with a single @emph{static_string_EXPRESSION} argument also works for these
9137 warnings, but the string must be a single full @code{-W@emph{xxx}} switch in this
9138 case. The above reference lists a few examples of these additional warnings.
9139
9140 The specified warnings will be in effect until the end of the program
9141 or another pragma @code{Warnings} is encountered. The effect of the pragma is
9142 cumulative. Initially the set of warnings is the standard default set
9143 as possibly modified by compiler switches. Then each pragma Warning
9144 modifies this set of warnings as specified. This form of the pragma may
9145 also be used as a configuration pragma.
9146
9147 The fourth form, with an @code{On|Off} parameter and a string, is used to
9148 control individual messages, based on their text. The string argument
9149 is a pattern that is used to match against the text of individual
9150 warning messages (not including the initial "warning: " tag).
9151
9152 The pattern may contain asterisks, which match zero or more characters in
9153 the message. For example, you can use
9154 @code{pragma Warnings (Off, "bits of*unused")} to suppress the warning
9155 message @code{warning: 960 bits of "a" unused}. No other regular
9156 expression notations are permitted. All characters other than asterisk in
9157 these three specific cases are treated as literal characters in the match.
9158 The match is case insensitive, for example XYZ matches xyz.
9159
9160 Note that the pattern matches if it occurs anywhere within the warning
9161 message string (it is not necessary to put an asterisk at the start and
9162 the end of the message, since this is implied).
9163
9164 The above use of patterns to match the message applies only to warning
9165 messages generated by the front end. This form of the pragma with a string
9166 argument can also be used to control warnings provided by the back end and
9167 mentioned above. By using a single full @code{-W@emph{xxx}} switch in the pragma,
9168 such warnings can be turned on and off.
9169
9170 There are two ways to use the pragma in this form. The OFF form can be used
9171 as a configuration pragma. The effect is to suppress all warnings (if any)
9172 that match the pattern string throughout the compilation (or match the
9173 -W switch in the back end case).
9174
9175 The second usage is to suppress a warning locally, and in this case, two
9176 pragmas must appear in sequence:
9177
9178 @example
9179 pragma Warnings (Off, Pattern);
9180 ... code where given warning is to be suppressed
9181 pragma Warnings (On, Pattern);
9182 @end example
9183
9184 In this usage, the pattern string must match in the Off and On
9185 pragmas, and (if @emph{-gnatw.w} is given) at least one matching
9186 warning must be suppressed.
9187
9188 Note: if the ON form is not found, then the effect of the OFF form extends
9189 until the end of the file (pragma Warnings is purely textual, so its effect
9190 does not stop at the end of the enclosing scope).
9191
9192 Note: to write a string that will match any warning, use the string
9193 @code{"***"}. It will not work to use a single asterisk or two
9194 asterisks since this looks like an operator name. This form with three
9195 asterisks is similar in effect to specifying @code{pragma Warnings (Off)} except (if @code{-gnatw.w} is given) that a matching
9196 @code{pragma Warnings (On, "***")} will be required. This can be
9197 helpful in avoiding forgetting to turn warnings back on.
9198
9199 Note: the debug flag @code{-gnatd.i} can be
9200 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
9201 be useful in checking whether obsolete pragmas in existing programs are hiding
9202 real problems.
9203
9204 Note: pragma Warnings does not affect the processing of style messages. See
9205 separate entry for pragma Style_Checks for control of style messages.
9206
9207 Users of the formal verification tool GNATprove for the SPARK subset of Ada may
9208 use the version of the pragma with a @code{TOOL_NAME} parameter.
9209
9210 If present, @code{TOOL_NAME} is the name of a tool, currently either @code{GNAT} for the
9211 compiler or @code{GNATprove} for the formal verification tool. A given tool only
9212 takes into account pragma Warnings that do not specify a tool name, or that
9213 specify the matching tool name. This makes it possible to disable warnings
9214 selectively for each tool, and as a consequence to detect useless pragma
9215 Warnings with switch @code{-gnatw.w}.
9216
9217 @node Pragma Weak_External,Pragma Wide_Character_Encoding,Pragma Warnings,Implementation Defined Pragmas
9218 @anchor{gnat_rm/implementation_defined_pragmas pragma-weak-external}@anchor{123}
9219 @section Pragma Weak_External
9220
9221
9222 Syntax:
9223
9224 @example
9225 pragma Weak_External ([Entity =>] LOCAL_NAME);
9226 @end example
9227
9228 @code{LOCAL_NAME} must refer to an object that is declared at the library
9229 level. This pragma specifies that the given entity should be marked as a
9230 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
9231 in GNU C and causes @code{LOCAL_NAME} to be emitted as a weak symbol instead
9232 of a regular symbol, that is to say a symbol that does not have to be
9233 resolved by the linker if used in conjunction with a pragma Import.
9234
9235 When a weak symbol is not resolved by the linker, its address is set to
9236 zero. This is useful in writing interfaces to external modules that may
9237 or may not be linked in the final executable, for example depending on
9238 configuration settings.
9239
9240 If a program references at run time an entity to which this pragma has been
9241 applied, and the corresponding symbol was not resolved at link time, then
9242 the execution of the program is erroneous. It is not erroneous to take the
9243 Address of such an entity, for example to guard potential references,
9244 as shown in the example below.
9245
9246 Some file formats do not support weak symbols so not all target machines
9247 support this pragma.
9248
9249 @example
9250 -- Example of the use of pragma Weak_External
9251
9252 package External_Module is
9253 key : Integer;
9254 pragma Import (C, key);
9255 pragma Weak_External (key);
9256 function Present return boolean;
9257 end External_Module;
9258
9259 with System; use System;
9260 package body External_Module is
9261 function Present return boolean is
9262 begin
9263 return key'Address /= System.Null_Address;
9264 end Present;
9265 end External_Module;
9266 @end example
9267
9268 @node Pragma Wide_Character_Encoding,,Pragma Weak_External,Implementation Defined Pragmas
9269 @anchor{gnat_rm/implementation_defined_pragmas pragma-wide-character-encoding}@anchor{124}
9270 @section Pragma Wide_Character_Encoding
9271
9272
9273 Syntax:
9274
9275 @example
9276 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
9277 @end example
9278
9279 This pragma specifies the wide character encoding to be used in program
9280 source text appearing subsequently. It is a configuration pragma, but may
9281 also be used at any point that a pragma is allowed, and it is permissible
9282 to have more than one such pragma in a file, allowing multiple encodings
9283 to appear within the same file.
9284
9285 However, note that the pragma cannot immediately precede the relevant
9286 wide character, because then the previous encoding will still be in
9287 effect, causing "illegal character" errors.
9288
9289 The argument can be an identifier or a character literal. In the identifier
9290 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
9291 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
9292 case it is correspondingly one of the characters @code{h}, @code{u},
9293 @code{s}, @code{e}, @code{8}, or @code{b}.
9294
9295 Note that when the pragma is used within a file, it affects only the
9296 encoding within that file, and does not affect withed units, specs,
9297 or subunits.
9298
9299 @node Implementation Defined Aspects,Implementation Defined Attributes,Implementation Defined Pragmas,Top
9300 @anchor{gnat_rm/implementation_defined_aspects implementation-defined-aspects}@anchor{125}@anchor{gnat_rm/implementation_defined_aspects doc}@anchor{126}@anchor{gnat_rm/implementation_defined_aspects id1}@anchor{127}
9301 @chapter Implementation Defined Aspects
9302
9303
9304 Ada defines (throughout the Ada 2012 reference manual, summarized
9305 in Annex K) a set of aspects that can be specified for certain entities.
9306 These language defined aspects are implemented in GNAT in Ada 2012 mode
9307 and work as described in the Ada 2012 Reference Manual.
9308
9309 In addition, Ada 2012 allows implementations to define additional aspects
9310 whose meaning is defined by the implementation. GNAT provides
9311 a number of these implementation-defined aspects which can be used
9312 to extend and enhance the functionality of the compiler. This section of
9313 the GNAT reference manual describes these additional aspects.
9314
9315 Note that any program using these aspects may not be portable to
9316 other compilers (although GNAT implements this set of aspects on all
9317 platforms). Therefore if portability to other compilers is an important
9318 consideration, you should minimize the use of these aspects.
9319
9320 Note that for many of these aspects, the effect is essentially similar
9321 to the use of a pragma or attribute specification with the same name
9322 applied to the entity. For example, if we write:
9323
9324 @example
9325 type R is range 1 .. 100
9326 with Value_Size => 10;
9327 @end example
9328
9329 then the effect is the same as:
9330
9331 @example
9332 type R is range 1 .. 100;
9333 for R'Value_Size use 10;
9334 @end example
9335
9336 and if we write:
9337
9338 @example
9339 type R is new Integer
9340 with Shared => True;
9341 @end example
9342
9343 then the effect is the same as:
9344
9345 @example
9346 type R is new Integer;
9347 pragma Shared (R);
9348 @end example
9349
9350 In the documentation below, such cases are simply marked
9351 as being boolean aspects equivalent to the corresponding pragma
9352 or attribute definition clause.
9353
9354 @menu
9355 * Aspect Abstract_State::
9356 * Aspect Annotate::
9357 * Aspect Async_Readers::
9358 * Aspect Async_Writers::
9359 * Aspect Constant_After_Elaboration::
9360 * Aspect Contract_Cases::
9361 * Aspect Depends::
9362 * Aspect Default_Initial_Condition::
9363 * Aspect Dimension::
9364 * Aspect Dimension_System::
9365 * Aspect Disable_Controlled::
9366 * Aspect Effective_Reads::
9367 * Aspect Effective_Writes::
9368 * Aspect Extensions_Visible::
9369 * Aspect Favor_Top_Level::
9370 * Aspect Ghost::
9371 * Aspect Global::
9372 * Aspect Initial_Condition::
9373 * Aspect Initializes::
9374 * Aspect Inline_Always::
9375 * Aspect Invariant::
9376 * Aspect Invariant'Class::
9377 * Aspect Iterable::
9378 * Aspect Linker_Section::
9379 * Aspect Lock_Free::
9380 * Aspect Max_Queue_Length::
9381 * Aspect No_Caching::
9382 * Aspect No_Elaboration_Code_All::
9383 * Aspect No_Inline::
9384 * Aspect No_Tagged_Streams::
9385 * Aspect Object_Size::
9386 * Aspect Obsolescent::
9387 * Aspect Part_Of::
9388 * Aspect Persistent_BSS::
9389 * Aspect Predicate::
9390 * Aspect Pure_Function::
9391 * Aspect Refined_Depends::
9392 * Aspect Refined_Global::
9393 * Aspect Refined_Post::
9394 * Aspect Refined_State::
9395 * Aspect Remote_Access_Type::
9396 * Aspect Secondary_Stack_Size::
9397 * Aspect Scalar_Storage_Order::
9398 * Aspect Shared::
9399 * Aspect Simple_Storage_Pool::
9400 * Aspect Simple_Storage_Pool_Type::
9401 * Aspect SPARK_Mode::
9402 * Aspect Suppress_Debug_Info::
9403 * Aspect Suppress_Initialization::
9404 * Aspect Test_Case::
9405 * Aspect Thread_Local_Storage::
9406 * Aspect Universal_Aliasing::
9407 * Aspect Universal_Data::
9408 * Aspect Unmodified::
9409 * Aspect Unreferenced::
9410 * Aspect Unreferenced_Objects::
9411 * Aspect Value_Size::
9412 * Aspect Volatile_Full_Access::
9413 * Aspect Volatile_Function::
9414 * Aspect Warnings::
9415
9416 @end menu
9417
9418 @node Aspect Abstract_State,Aspect Annotate,,Implementation Defined Aspects
9419 @anchor{gnat_rm/implementation_defined_aspects aspect-abstract-state}@anchor{128}
9420 @section Aspect Abstract_State
9421
9422
9423 @geindex Abstract_State
9424
9425 This aspect is equivalent to @ref{1c,,pragma Abstract_State}.
9426
9427 @node Aspect Annotate,Aspect Async_Readers,Aspect Abstract_State,Implementation Defined Aspects
9428 @anchor{gnat_rm/implementation_defined_aspects aspect-annotate}@anchor{129}
9429 @section Aspect Annotate
9430
9431
9432 @geindex Annotate
9433
9434 There are three forms of this aspect (where ID is an identifier,
9435 and ARG is a general expression),
9436 corresponding to @ref{2a,,pragma Annotate}.
9437
9438
9439 @table @asis
9440
9441 @item @emph{Annotate => ID}
9442
9443 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9444
9445 @item @emph{Annotate => (ID)}
9446
9447 Equivalent to @code{pragma Annotate (ID, Entity => Name);}
9448
9449 @item @emph{Annotate => (ID ,ID @{, ARG@})}
9450
9451 Equivalent to @code{pragma Annotate (ID, ID @{, ARG@}, Entity => Name);}
9452 @end table
9453
9454 @node Aspect Async_Readers,Aspect Async_Writers,Aspect Annotate,Implementation Defined Aspects
9455 @anchor{gnat_rm/implementation_defined_aspects aspect-async-readers}@anchor{12a}
9456 @section Aspect Async_Readers
9457
9458
9459 @geindex Async_Readers
9460
9461 This boolean aspect is equivalent to @ref{31,,pragma Async_Readers}.
9462
9463 @node Aspect Async_Writers,Aspect Constant_After_Elaboration,Aspect Async_Readers,Implementation Defined Aspects
9464 @anchor{gnat_rm/implementation_defined_aspects aspect-async-writers}@anchor{12b}
9465 @section Aspect Async_Writers
9466
9467
9468 @geindex Async_Writers
9469
9470 This boolean aspect is equivalent to @ref{34,,pragma Async_Writers}.
9471
9472 @node Aspect Constant_After_Elaboration,Aspect Contract_Cases,Aspect Async_Writers,Implementation Defined Aspects
9473 @anchor{gnat_rm/implementation_defined_aspects aspect-constant-after-elaboration}@anchor{12c}
9474 @section Aspect Constant_After_Elaboration
9475
9476
9477 @geindex Constant_After_Elaboration
9478
9479 This aspect is equivalent to @ref{45,,pragma Constant_After_Elaboration}.
9480
9481 @node Aspect Contract_Cases,Aspect Depends,Aspect Constant_After_Elaboration,Implementation Defined Aspects
9482 @anchor{gnat_rm/implementation_defined_aspects aspect-contract-cases}@anchor{12d}
9483 @section Aspect Contract_Cases
9484
9485
9486 @geindex Contract_Cases
9487
9488 This aspect is equivalent to @ref{47,,pragma Contract_Cases}, the sequence
9489 of clauses being enclosed in parentheses so that syntactically it is an
9490 aggregate.
9491
9492 @node Aspect Depends,Aspect Default_Initial_Condition,Aspect Contract_Cases,Implementation Defined Aspects
9493 @anchor{gnat_rm/implementation_defined_aspects aspect-depends}@anchor{12e}
9494 @section Aspect Depends
9495
9496
9497 @geindex Depends
9498
9499 This aspect is equivalent to @ref{56,,pragma Depends}.
9500
9501 @node Aspect Default_Initial_Condition,Aspect Dimension,Aspect Depends,Implementation Defined Aspects
9502 @anchor{gnat_rm/implementation_defined_aspects aspect-default-initial-condition}@anchor{12f}
9503 @section Aspect Default_Initial_Condition
9504
9505
9506 @geindex Default_Initial_Condition
9507
9508 This aspect is equivalent to @ref{51,,pragma Default_Initial_Condition}.
9509
9510 @node Aspect Dimension,Aspect Dimension_System,Aspect Default_Initial_Condition,Implementation Defined Aspects
9511 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension}@anchor{130}
9512 @section Aspect Dimension
9513
9514
9515 @geindex Dimension
9516
9517 The @code{Dimension} aspect is used to specify the dimensions of a given
9518 subtype of a dimensioned numeric type. The aspect also specifies a symbol
9519 used when doing formatted output of dimensioned quantities. The syntax is:
9520
9521 @example
9522 with Dimension =>
9523 ([Symbol =>] SYMBOL, DIMENSION_VALUE @{, DIMENSION_Value@})
9524
9525 SYMBOL ::= STRING_LITERAL | CHARACTER_LITERAL
9526
9527 DIMENSION_VALUE ::=
9528 RATIONAL
9529 | others => RATIONAL
9530 | DISCRETE_CHOICE_LIST => RATIONAL
9531
9532 RATIONAL ::= [-] NUMERIC_LITERAL [/ NUMERIC_LITERAL]
9533 @end example
9534
9535 This aspect can only be applied to a subtype whose parent type has
9536 a @code{Dimension_System} aspect. The aspect must specify values for
9537 all dimensions of the system. The rational values are the powers of the
9538 corresponding dimensions that are used by the compiler to verify that
9539 physical (numeric) computations are dimensionally consistent. For example,
9540 the computation of a force must result in dimensions (L => 1, M => 1, T => -2).
9541 For further examples of the usage
9542 of this aspect, see package @code{System.Dim.Mks}.
9543 Note that when the dimensioned type is an integer type, then any
9544 dimension value must be an integer literal.
9545
9546 @node Aspect Dimension_System,Aspect Disable_Controlled,Aspect Dimension,Implementation Defined Aspects
9547 @anchor{gnat_rm/implementation_defined_aspects aspect-dimension-system}@anchor{131}
9548 @section Aspect Dimension_System
9549
9550
9551 @geindex Dimension_System
9552
9553 The @code{Dimension_System} aspect is used to define a system of
9554 dimensions that will be used in subsequent subtype declarations with
9555 @code{Dimension} aspects that reference this system. The syntax is:
9556
9557 @example
9558 with Dimension_System => (DIMENSION @{, DIMENSION@});
9559
9560 DIMENSION ::= ([Unit_Name =>] IDENTIFIER,
9561 [Unit_Symbol =>] SYMBOL,
9562 [Dim_Symbol =>] SYMBOL)
9563
9564 SYMBOL ::= CHARACTER_LITERAL | STRING_LITERAL
9565 @end example
9566
9567 This aspect is applied to a type, which must be a numeric derived type
9568 (typically a floating-point type), that
9569 will represent values within the dimension system. Each @code{DIMENSION}
9570 corresponds to one particular dimension. A maximum of 7 dimensions may
9571 be specified. @code{Unit_Name} is the name of the dimension (for example
9572 @code{Meter}). @code{Unit_Symbol} is the shorthand used for quantities
9573 of this dimension (for example @code{m} for @code{Meter}).
9574 @code{Dim_Symbol} gives
9575 the identification within the dimension system (typically this is a
9576 single letter, e.g. @code{L} standing for length for unit name @code{Meter}).
9577 The @code{Unit_Symbol} is used in formatted output of dimensioned quantities.
9578 The @code{Dim_Symbol} is used in error messages when numeric operations have
9579 inconsistent dimensions.
9580
9581 GNAT provides the standard definition of the International MKS system in
9582 the run-time package @code{System.Dim.Mks}. You can easily define
9583 similar packages for cgs units or British units, and define conversion factors
9584 between values in different systems. The MKS system is characterized by the
9585 following aspect:
9586
9587 @example
9588 type Mks_Type is new Long_Long_Float with
9589 Dimension_System => (
9590 (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
9591 (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
9592 (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
9593 (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
9594 (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => '@@'),
9595 (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
9596 (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
9597 @end example
9598
9599 Note that in the above type definition, we use the @code{at} symbol (@code{@@}) to
9600 represent a theta character (avoiding the use of extended Latin-1
9601 characters in this context).
9602
9603 See section 'Performing Dimensionality Analysis in GNAT' in the GNAT Users
9604 Guide for detailed examples of use of the dimension system.
9605
9606 @node Aspect Disable_Controlled,Aspect Effective_Reads,Aspect Dimension_System,Implementation Defined Aspects
9607 @anchor{gnat_rm/implementation_defined_aspects aspect-disable-controlled}@anchor{132}
9608 @section Aspect Disable_Controlled
9609
9610
9611 @geindex Disable_Controlled
9612
9613 The aspect @code{Disable_Controlled} is defined for controlled record types. If
9614 active, this aspect causes suppression of all related calls to @code{Initialize},
9615 @code{Adjust}, and @code{Finalize}. The intended use is for conditional compilation,
9616 where for example you might want a record to be controlled or not depending on
9617 whether some run-time check is enabled or suppressed.
9618
9619 @node Aspect Effective_Reads,Aspect Effective_Writes,Aspect Disable_Controlled,Implementation Defined Aspects
9620 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-reads}@anchor{133}
9621 @section Aspect Effective_Reads
9622
9623
9624 @geindex Effective_Reads
9625
9626 This aspect is equivalent to @ref{5c,,pragma Effective_Reads}.
9627
9628 @node Aspect Effective_Writes,Aspect Extensions_Visible,Aspect Effective_Reads,Implementation Defined Aspects
9629 @anchor{gnat_rm/implementation_defined_aspects aspect-effective-writes}@anchor{134}
9630 @section Aspect Effective_Writes
9631
9632
9633 @geindex Effective_Writes
9634
9635 This aspect is equivalent to @ref{5e,,pragma Effective_Writes}.
9636
9637 @node Aspect Extensions_Visible,Aspect Favor_Top_Level,Aspect Effective_Writes,Implementation Defined Aspects
9638 @anchor{gnat_rm/implementation_defined_aspects aspect-extensions-visible}@anchor{135}
9639 @section Aspect Extensions_Visible
9640
9641
9642 @geindex Extensions_Visible
9643
9644 This aspect is equivalent to @ref{6a,,pragma Extensions_Visible}.
9645
9646 @node Aspect Favor_Top_Level,Aspect Ghost,Aspect Extensions_Visible,Implementation Defined Aspects
9647 @anchor{gnat_rm/implementation_defined_aspects aspect-favor-top-level}@anchor{136}
9648 @section Aspect Favor_Top_Level
9649
9650
9651 @geindex Favor_Top_Level
9652
9653 This boolean aspect is equivalent to @ref{6f,,pragma Favor_Top_Level}.
9654
9655 @node Aspect Ghost,Aspect Global,Aspect Favor_Top_Level,Implementation Defined Aspects
9656 @anchor{gnat_rm/implementation_defined_aspects aspect-ghost}@anchor{137}
9657 @section Aspect Ghost
9658
9659
9660 @geindex Ghost
9661
9662 This aspect is equivalent to @ref{72,,pragma Ghost}.
9663
9664 @node Aspect Global,Aspect Initial_Condition,Aspect Ghost,Implementation Defined Aspects
9665 @anchor{gnat_rm/implementation_defined_aspects aspect-global}@anchor{138}
9666 @section Aspect Global
9667
9668
9669 @geindex Global
9670
9671 This aspect is equivalent to @ref{74,,pragma Global}.
9672
9673 @node Aspect Initial_Condition,Aspect Initializes,Aspect Global,Implementation Defined Aspects
9674 @anchor{gnat_rm/implementation_defined_aspects aspect-initial-condition}@anchor{139}
9675 @section Aspect Initial_Condition
9676
9677
9678 @geindex Initial_Condition
9679
9680 This aspect is equivalent to @ref{82,,pragma Initial_Condition}.
9681
9682 @node Aspect Initializes,Aspect Inline_Always,Aspect Initial_Condition,Implementation Defined Aspects
9683 @anchor{gnat_rm/implementation_defined_aspects aspect-initializes}@anchor{13a}
9684 @section Aspect Initializes
9685
9686
9687 @geindex Initializes
9688
9689 This aspect is equivalent to @ref{84,,pragma Initializes}.
9690
9691 @node Aspect Inline_Always,Aspect Invariant,Aspect Initializes,Implementation Defined Aspects
9692 @anchor{gnat_rm/implementation_defined_aspects aspect-inline-always}@anchor{13b}
9693 @section Aspect Inline_Always
9694
9695
9696 @geindex Inline_Always
9697
9698 This boolean aspect is equivalent to @ref{87,,pragma Inline_Always}.
9699
9700 @node Aspect Invariant,Aspect Invariant'Class,Aspect Inline_Always,Implementation Defined Aspects
9701 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant}@anchor{13c}
9702 @section Aspect Invariant
9703
9704
9705 @geindex Invariant
9706
9707 This aspect is equivalent to @ref{8e,,pragma Invariant}. It is a
9708 synonym for the language defined aspect @code{Type_Invariant} except
9709 that it is separately controllable using pragma @code{Assertion_Policy}.
9710
9711 @node Aspect Invariant'Class,Aspect Iterable,Aspect Invariant,Implementation Defined Aspects
9712 @anchor{gnat_rm/implementation_defined_aspects aspect-invariant-class}@anchor{13d}
9713 @section Aspect Invariant'Class
9714
9715
9716 @geindex Invariant'Class
9717
9718 This aspect is equivalent to @ref{106,,pragma Type_Invariant_Class}. It is a
9719 synonym for the language defined aspect @code{Type_Invariant'Class} except
9720 that it is separately controllable using pragma @code{Assertion_Policy}.
9721
9722 @node Aspect Iterable,Aspect Linker_Section,Aspect Invariant'Class,Implementation Defined Aspects
9723 @anchor{gnat_rm/implementation_defined_aspects aspect-iterable}@anchor{13e}
9724 @section Aspect Iterable
9725
9726
9727 @geindex Iterable
9728
9729 This aspect provides a light-weight mechanism for loops and quantified
9730 expressions over container types, without the overhead imposed by the tampering
9731 checks of standard Ada 2012 iterators. The value of the aspect is an aggregate
9732 with six named components, of which the last three are optional: @code{First},
9733 @code{Next}, @code{Has_Element}, @code{Element}, @code{Last}, and @code{Previous}.
9734 When only the first three components are specified, only the
9735 @code{for .. in} form of iteration over cursors is available. When @code{Element}
9736 is specified, both this form and the @code{for .. of} form of iteration over
9737 elements are available. If the last two components are specified, reverse
9738 iterations over the container can be specified (analogous to what can be done
9739 over predefined containers that support the @code{Reverse_Iterator} interface).
9740 The following is a typical example of use:
9741
9742 @example
9743 type List is private with
9744 Iterable => (First => First_Cursor,
9745 Next => Advance,
9746 Has_Element => Cursor_Has_Element,
9747 [Element => Get_Element]);
9748 @end example
9749
9750
9751 @itemize *
9752
9753 @item
9754 The value denoted by @code{First} must denote a primitive operation of the
9755 container type that returns a @code{Cursor}, which must a be a type declared in
9756 the container package or visible from it. For example:
9757 @end itemize
9758
9759 @example
9760 function First_Cursor (Cont : Container) return Cursor;
9761 @end example
9762
9763
9764 @itemize *
9765
9766 @item
9767 The value of @code{Next} is a primitive operation of the container type that takes
9768 both a container and a cursor and yields a cursor. For example:
9769 @end itemize
9770
9771 @example
9772 function Advance (Cont : Container; Position : Cursor) return Cursor;
9773 @end example
9774
9775
9776 @itemize *
9777
9778 @item
9779 The value of @code{Has_Element} is a primitive operation of the container type
9780 that takes both a container and a cursor and yields a boolean. For example:
9781 @end itemize
9782
9783 @example
9784 function Cursor_Has_Element (Cont : Container; Position : Cursor) return Boolean;
9785 @end example
9786
9787
9788 @itemize *
9789
9790 @item
9791 The value of @code{Element} is a primitive operation of the container type that
9792 takes both a container and a cursor and yields an @code{Element_Type}, which must
9793 be a type declared in the container package or visible from it. For example:
9794 @end itemize
9795
9796 @example
9797 function Get_Element (Cont : Container; Position : Cursor) return Element_Type;
9798 @end example
9799
9800 This aspect is used in the GNAT-defined formal container packages.
9801
9802 @node Aspect Linker_Section,Aspect Lock_Free,Aspect Iterable,Implementation Defined Aspects
9803 @anchor{gnat_rm/implementation_defined_aspects aspect-linker-section}@anchor{13f}
9804 @section Aspect Linker_Section
9805
9806
9807 @geindex Linker_Section
9808
9809 This aspect is equivalent to @ref{96,,pragma Linker_Section}.
9810
9811 @node Aspect Lock_Free,Aspect Max_Queue_Length,Aspect Linker_Section,Implementation Defined Aspects
9812 @anchor{gnat_rm/implementation_defined_aspects aspect-lock-free}@anchor{140}
9813 @section Aspect Lock_Free
9814
9815
9816 @geindex Lock_Free
9817
9818 This boolean aspect is equivalent to @ref{98,,pragma Lock_Free}.
9819
9820 @node Aspect Max_Queue_Length,Aspect No_Caching,Aspect Lock_Free,Implementation Defined Aspects
9821 @anchor{gnat_rm/implementation_defined_aspects aspect-max-queue-length}@anchor{141}
9822 @section Aspect Max_Queue_Length
9823
9824
9825 @geindex Max_Queue_Length
9826
9827 This aspect is equivalent to @ref{a0,,pragma Max_Queue_Length}.
9828
9829 @node Aspect No_Caching,Aspect No_Elaboration_Code_All,Aspect Max_Queue_Length,Implementation Defined Aspects
9830 @anchor{gnat_rm/implementation_defined_aspects aspect-no-caching}@anchor{142}
9831 @section Aspect No_Caching
9832
9833
9834 @geindex No_Caching
9835
9836 This boolean aspect is equivalent to @ref{a2,,pragma No_Caching}.
9837
9838 @node Aspect No_Elaboration_Code_All,Aspect No_Inline,Aspect No_Caching,Implementation Defined Aspects
9839 @anchor{gnat_rm/implementation_defined_aspects aspect-no-elaboration-code-all}@anchor{143}
9840 @section Aspect No_Elaboration_Code_All
9841
9842
9843 @geindex No_Elaboration_Code_All
9844
9845 This aspect is equivalent to @ref{a6,,pragma No_Elaboration_Code_All}
9846 for a program unit.
9847
9848 @node Aspect No_Inline,Aspect No_Tagged_Streams,Aspect No_Elaboration_Code_All,Implementation Defined Aspects
9849 @anchor{gnat_rm/implementation_defined_aspects aspect-no-inline}@anchor{144}
9850 @section Aspect No_Inline
9851
9852
9853 @geindex No_Inline
9854
9855 This boolean aspect is equivalent to @ref{a9,,pragma No_Inline}.
9856
9857 @node Aspect No_Tagged_Streams,Aspect Object_Size,Aspect No_Inline,Implementation Defined Aspects
9858 @anchor{gnat_rm/implementation_defined_aspects aspect-no-tagged-streams}@anchor{145}
9859 @section Aspect No_Tagged_Streams
9860
9861
9862 @geindex No_Tagged_Streams
9863
9864 This aspect is equivalent to @ref{ac,,pragma No_Tagged_Streams} with an
9865 argument specifying a root tagged type (thus this aspect can only be
9866 applied to such a type).
9867
9868 @node Aspect Object_Size,Aspect Obsolescent,Aspect No_Tagged_Streams,Implementation Defined Aspects
9869 @anchor{gnat_rm/implementation_defined_aspects aspect-object-size}@anchor{146}
9870 @section Aspect Object_Size
9871
9872
9873 @geindex Object_Size
9874
9875 This aspect is equivalent to @ref{147,,attribute Object_Size}.
9876
9877 @node Aspect Obsolescent,Aspect Part_Of,Aspect Object_Size,Implementation Defined Aspects
9878 @anchor{gnat_rm/implementation_defined_aspects aspect-obsolescent}@anchor{148}
9879 @section Aspect Obsolescent
9880
9881
9882 @geindex Obsolsecent
9883
9884 This aspect is equivalent to @ref{af,,pragma Obsolescent}. Note that the
9885 evaluation of this aspect happens at the point of occurrence, it is not
9886 delayed until the freeze point.
9887
9888 @node Aspect Part_Of,Aspect Persistent_BSS,Aspect Obsolescent,Implementation Defined Aspects
9889 @anchor{gnat_rm/implementation_defined_aspects aspect-part-of}@anchor{149}
9890 @section Aspect Part_Of
9891
9892
9893 @geindex Part_Of
9894
9895 This aspect is equivalent to @ref{b7,,pragma Part_Of}.
9896
9897 @node Aspect Persistent_BSS,Aspect Predicate,Aspect Part_Of,Implementation Defined Aspects
9898 @anchor{gnat_rm/implementation_defined_aspects aspect-persistent-bss}@anchor{14a}
9899 @section Aspect Persistent_BSS
9900
9901
9902 @geindex Persistent_BSS
9903
9904 This boolean aspect is equivalent to @ref{ba,,pragma Persistent_BSS}.
9905
9906 @node Aspect Predicate,Aspect Pure_Function,Aspect Persistent_BSS,Implementation Defined Aspects
9907 @anchor{gnat_rm/implementation_defined_aspects aspect-predicate}@anchor{14b}
9908 @section Aspect Predicate
9909
9910
9911 @geindex Predicate
9912
9913 This aspect is equivalent to @ref{c2,,pragma Predicate}. It is thus
9914 similar to the language defined aspects @code{Dynamic_Predicate}
9915 and @code{Static_Predicate} except that whether the resulting
9916 predicate is static or dynamic is controlled by the form of the
9917 expression. It is also separately controllable using pragma
9918 @code{Assertion_Policy}.
9919
9920 @node Aspect Pure_Function,Aspect Refined_Depends,Aspect Predicate,Implementation Defined Aspects
9921 @anchor{gnat_rm/implementation_defined_aspects aspect-pure-function}@anchor{14c}
9922 @section Aspect Pure_Function
9923
9924
9925 @geindex Pure_Function
9926
9927 This boolean aspect is equivalent to @ref{ce,,pragma Pure_Function}.
9928
9929 @node Aspect Refined_Depends,Aspect Refined_Global,Aspect Pure_Function,Implementation Defined Aspects
9930 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-depends}@anchor{14d}
9931 @section Aspect Refined_Depends
9932
9933
9934 @geindex Refined_Depends
9935
9936 This aspect is equivalent to @ref{d2,,pragma Refined_Depends}.
9937
9938 @node Aspect Refined_Global,Aspect Refined_Post,Aspect Refined_Depends,Implementation Defined Aspects
9939 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-global}@anchor{14e}
9940 @section Aspect Refined_Global
9941
9942
9943 @geindex Refined_Global
9944
9945 This aspect is equivalent to @ref{d4,,pragma Refined_Global}.
9946
9947 @node Aspect Refined_Post,Aspect Refined_State,Aspect Refined_Global,Implementation Defined Aspects
9948 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-post}@anchor{14f}
9949 @section Aspect Refined_Post
9950
9951
9952 @geindex Refined_Post
9953
9954 This aspect is equivalent to @ref{d6,,pragma Refined_Post}.
9955
9956 @node Aspect Refined_State,Aspect Remote_Access_Type,Aspect Refined_Post,Implementation Defined Aspects
9957 @anchor{gnat_rm/implementation_defined_aspects aspect-refined-state}@anchor{150}
9958 @section Aspect Refined_State
9959
9960
9961 @geindex Refined_State
9962
9963 This aspect is equivalent to @ref{d8,,pragma Refined_State}.
9964
9965 @node Aspect Remote_Access_Type,Aspect Secondary_Stack_Size,Aspect Refined_State,Implementation Defined Aspects
9966 @anchor{gnat_rm/implementation_defined_aspects aspect-remote-access-type}@anchor{151}
9967 @section Aspect Remote_Access_Type
9968
9969
9970 @geindex Remote_Access_Type
9971
9972 This aspect is equivalent to @ref{dc,,pragma Remote_Access_Type}.
9973
9974 @node Aspect Secondary_Stack_Size,Aspect Scalar_Storage_Order,Aspect Remote_Access_Type,Implementation Defined Aspects
9975 @anchor{gnat_rm/implementation_defined_aspects aspect-secondary-stack-size}@anchor{152}
9976 @section Aspect Secondary_Stack_Size
9977
9978
9979 @geindex Secondary_Stack_Size
9980
9981 This aspect is equivalent to @ref{e1,,pragma Secondary_Stack_Size}.
9982
9983 @node Aspect Scalar_Storage_Order,Aspect Shared,Aspect Secondary_Stack_Size,Implementation Defined Aspects
9984 @anchor{gnat_rm/implementation_defined_aspects aspect-scalar-storage-order}@anchor{153}
9985 @section Aspect Scalar_Storage_Order
9986
9987
9988 @geindex Scalar_Storage_Order
9989
9990 This aspect is equivalent to a @ref{154,,attribute Scalar_Storage_Order}.
9991
9992 @node Aspect Shared,Aspect Simple_Storage_Pool,Aspect Scalar_Storage_Order,Implementation Defined Aspects
9993 @anchor{gnat_rm/implementation_defined_aspects aspect-shared}@anchor{155}
9994 @section Aspect Shared
9995
9996
9997 @geindex Shared
9998
9999 This boolean aspect is equivalent to @ref{e4,,pragma Shared}
10000 and is thus a synonym for aspect @code{Atomic}.
10001
10002 @node Aspect Simple_Storage_Pool,Aspect Simple_Storage_Pool_Type,Aspect Shared,Implementation Defined Aspects
10003 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool}@anchor{156}
10004 @section Aspect Simple_Storage_Pool
10005
10006
10007 @geindex Simple_Storage_Pool
10008
10009 This aspect is equivalent to @ref{e9,,attribute Simple_Storage_Pool}.
10010
10011 @node Aspect Simple_Storage_Pool_Type,Aspect SPARK_Mode,Aspect Simple_Storage_Pool,Implementation Defined Aspects
10012 @anchor{gnat_rm/implementation_defined_aspects aspect-simple-storage-pool-type}@anchor{157}
10013 @section Aspect Simple_Storage_Pool_Type
10014
10015
10016 @geindex Simple_Storage_Pool_Type
10017
10018 This boolean aspect is equivalent to @ref{e7,,pragma Simple_Storage_Pool_Type}.
10019
10020 @node Aspect SPARK_Mode,Aspect Suppress_Debug_Info,Aspect Simple_Storage_Pool_Type,Implementation Defined Aspects
10021 @anchor{gnat_rm/implementation_defined_aspects aspect-spark-mode}@anchor{158}
10022 @section Aspect SPARK_Mode
10023
10024
10025 @geindex SPARK_Mode
10026
10027 This aspect is equivalent to @ref{ef,,pragma SPARK_Mode} and
10028 may be specified for either or both of the specification and body
10029 of a subprogram or package.
10030
10031 @node Aspect Suppress_Debug_Info,Aspect Suppress_Initialization,Aspect SPARK_Mode,Implementation Defined Aspects
10032 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-debug-info}@anchor{159}
10033 @section Aspect Suppress_Debug_Info
10034
10035
10036 @geindex Suppress_Debug_Info
10037
10038 This boolean aspect is equivalent to @ref{f7,,pragma Suppress_Debug_Info}.
10039
10040 @node Aspect Suppress_Initialization,Aspect Test_Case,Aspect Suppress_Debug_Info,Implementation Defined Aspects
10041 @anchor{gnat_rm/implementation_defined_aspects aspect-suppress-initialization}@anchor{15a}
10042 @section Aspect Suppress_Initialization
10043
10044
10045 @geindex Suppress_Initialization
10046
10047 This boolean aspect is equivalent to @ref{fb,,pragma Suppress_Initialization}.
10048
10049 @node Aspect Test_Case,Aspect Thread_Local_Storage,Aspect Suppress_Initialization,Implementation Defined Aspects
10050 @anchor{gnat_rm/implementation_defined_aspects aspect-test-case}@anchor{15b}
10051 @section Aspect Test_Case
10052
10053
10054 @geindex Test_Case
10055
10056 This aspect is equivalent to @ref{fe,,pragma Test_Case}.
10057
10058 @node Aspect Thread_Local_Storage,Aspect Universal_Aliasing,Aspect Test_Case,Implementation Defined Aspects
10059 @anchor{gnat_rm/implementation_defined_aspects aspect-thread-local-storage}@anchor{15c}
10060 @section Aspect Thread_Local_Storage
10061
10062
10063 @geindex Thread_Local_Storage
10064
10065 This boolean aspect is equivalent to @ref{100,,pragma Thread_Local_Storage}.
10066
10067 @node Aspect Universal_Aliasing,Aspect Universal_Data,Aspect Thread_Local_Storage,Implementation Defined Aspects
10068 @anchor{gnat_rm/implementation_defined_aspects aspect-universal-aliasing}@anchor{15d}
10069 @section Aspect Universal_Aliasing
10070
10071
10072 @geindex Universal_Aliasing
10073
10074 This boolean aspect is equivalent to @ref{10a,,pragma Universal_Aliasing}.
10075
10076 @node Aspect Universal_Data,Aspect Unmodified,Aspect Universal_Aliasing,Implementation Defined Aspects
10077 @anchor{gnat_rm/implementation_defined_aspects aspect-universal-data}@anchor{15e}
10078 @section Aspect Universal_Data
10079
10080
10081 @geindex Universal_Data
10082
10083 This aspect is equivalent to @ref{10c,,pragma Universal_Data}.
10084
10085 @node Aspect Unmodified,Aspect Unreferenced,Aspect Universal_Data,Implementation Defined Aspects
10086 @anchor{gnat_rm/implementation_defined_aspects aspect-unmodified}@anchor{15f}
10087 @section Aspect Unmodified
10088
10089
10090 @geindex Unmodified
10091
10092 This boolean aspect is equivalent to @ref{10f,,pragma Unmodified}.
10093
10094 @node Aspect Unreferenced,Aspect Unreferenced_Objects,Aspect Unmodified,Implementation Defined Aspects
10095 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced}@anchor{160}
10096 @section Aspect Unreferenced
10097
10098
10099 @geindex Unreferenced
10100
10101 This boolean aspect is equivalent to @ref{110,,pragma Unreferenced}. Note that
10102 in the case of formal parameters, it is not permitted to have aspects for
10103 a formal parameter, so in this case the pragma form must be used.
10104
10105 @node Aspect Unreferenced_Objects,Aspect Value_Size,Aspect Unreferenced,Implementation Defined Aspects
10106 @anchor{gnat_rm/implementation_defined_aspects aspect-unreferenced-objects}@anchor{161}
10107 @section Aspect Unreferenced_Objects
10108
10109
10110 @geindex Unreferenced_Objects
10111
10112 This boolean aspect is equivalent to @ref{112,,pragma Unreferenced_Objects}.
10113
10114 @node Aspect Value_Size,Aspect Volatile_Full_Access,Aspect Unreferenced_Objects,Implementation Defined Aspects
10115 @anchor{gnat_rm/implementation_defined_aspects aspect-value-size}@anchor{162}
10116 @section Aspect Value_Size
10117
10118
10119 @geindex Value_Size
10120
10121 This aspect is equivalent to @ref{163,,attribute Value_Size}.
10122
10123 @node Aspect Volatile_Full_Access,Aspect Volatile_Function,Aspect Value_Size,Implementation Defined Aspects
10124 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-full-access}@anchor{164}
10125 @section Aspect Volatile_Full_Access
10126
10127
10128 @geindex Volatile_Full_Access
10129
10130 This boolean aspect is equivalent to @ref{11d,,pragma Volatile_Full_Access}.
10131
10132 @node Aspect Volatile_Function,Aspect Warnings,Aspect Volatile_Full_Access,Implementation Defined Aspects
10133 @anchor{gnat_rm/implementation_defined_aspects aspect-volatile-function}@anchor{165}
10134 @section Aspect Volatile_Function
10135
10136
10137 @geindex Volatile_Function
10138
10139 This boolean aspect is equivalent to @ref{11f,,pragma Volatile_Function}.
10140
10141 @node Aspect Warnings,,Aspect Volatile_Function,Implementation Defined Aspects
10142 @anchor{gnat_rm/implementation_defined_aspects aspect-warnings}@anchor{166}
10143 @section Aspect Warnings
10144
10145
10146 @geindex Warnings
10147
10148 This aspect is equivalent to the two argument form of @ref{121,,pragma Warnings},
10149 where the first argument is @code{ON} or @code{OFF} and the second argument
10150 is the entity.
10151
10152 @node Implementation Defined Attributes,Standard and Implementation Defined Restrictions,Implementation Defined Aspects,Top
10153 @anchor{gnat_rm/implementation_defined_attributes doc}@anchor{167}@anchor{gnat_rm/implementation_defined_attributes implementation-defined-attributes}@anchor{8}@anchor{gnat_rm/implementation_defined_attributes id1}@anchor{168}
10154 @chapter Implementation Defined Attributes
10155
10156
10157 Ada defines (throughout the Ada reference manual,
10158 summarized in Annex K),
10159 a set of attributes that provide useful additional functionality in all
10160 areas of the language. These language defined attributes are implemented
10161 in GNAT and work as described in the Ada Reference Manual.
10162
10163 In addition, Ada allows implementations to define additional
10164 attributes whose meaning is defined by the implementation. GNAT provides
10165 a number of these implementation-dependent attributes which can be used
10166 to extend and enhance the functionality of the compiler. This section of
10167 the GNAT reference manual describes these additional attributes. It also
10168 describes additional implementation-dependent features of standard
10169 language-defined attributes.
10170
10171 Note that any program using these attributes may not be portable to
10172 other compilers (although GNAT implements this set of attributes on all
10173 platforms). Therefore if portability to other compilers is an important
10174 consideration, you should minimize the use of these attributes.
10175
10176 @menu
10177 * Attribute Abort_Signal::
10178 * Attribute Address_Size::
10179 * Attribute Asm_Input::
10180 * Attribute Asm_Output::
10181 * Attribute Atomic_Always_Lock_Free::
10182 * Attribute Bit::
10183 * Attribute Bit_Position::
10184 * Attribute Code_Address::
10185 * Attribute Compiler_Version::
10186 * Attribute Constrained::
10187 * Attribute Default_Bit_Order::
10188 * Attribute Default_Scalar_Storage_Order::
10189 * Attribute Deref::
10190 * Attribute Descriptor_Size::
10191 * Attribute Elaborated::
10192 * Attribute Elab_Body::
10193 * Attribute Elab_Spec::
10194 * Attribute Elab_Subp_Body::
10195 * Attribute Emax::
10196 * Attribute Enabled::
10197 * Attribute Enum_Rep::
10198 * Attribute Enum_Val::
10199 * Attribute Epsilon::
10200 * Attribute Fast_Math::
10201 * Attribute Finalization_Size::
10202 * Attribute Fixed_Value::
10203 * Attribute From_Any::
10204 * Attribute Has_Access_Values::
10205 * Attribute Has_Discriminants::
10206 * Attribute Img::
10207 * Attribute Integer_Value::
10208 * Attribute Invalid_Value::
10209 * Attribute Iterable::
10210 * Attribute Large::
10211 * Attribute Library_Level::
10212 * Attribute Lock_Free::
10213 * Attribute Loop_Entry::
10214 * Attribute Machine_Size::
10215 * Attribute Mantissa::
10216 * Attribute Maximum_Alignment::
10217 * Attribute Mechanism_Code::
10218 * Attribute Null_Parameter::
10219 * Attribute Object_Size::
10220 * Attribute Old::
10221 * Attribute Passed_By_Reference::
10222 * Attribute Pool_Address::
10223 * Attribute Range_Length::
10224 * Attribute Restriction_Set::
10225 * Attribute Result::
10226 * Attribute Safe_Emax::
10227 * Attribute Safe_Large::
10228 * Attribute Safe_Small::
10229 * Attribute Scalar_Storage_Order::
10230 * Attribute Simple_Storage_Pool::
10231 * Attribute Small::
10232 * Attribute Storage_Unit::
10233 * Attribute Stub_Type::
10234 * Attribute System_Allocator_Alignment::
10235 * Attribute Target_Name::
10236 * Attribute To_Address::
10237 * Attribute To_Any::
10238 * Attribute Type_Class::
10239 * Attribute Type_Key::
10240 * Attribute TypeCode::
10241 * Attribute Unconstrained_Array::
10242 * Attribute Universal_Literal_String::
10243 * Attribute Unrestricted_Access::
10244 * Attribute Update::
10245 * Attribute Valid_Scalars::
10246 * Attribute VADS_Size::
10247 * Attribute Value_Size::
10248 * Attribute Wchar_T_Size::
10249 * Attribute Word_Size::
10250
10251 @end menu
10252
10253 @node Attribute Abort_Signal,Attribute Address_Size,,Implementation Defined Attributes
10254 @anchor{gnat_rm/implementation_defined_attributes attribute-abort-signal}@anchor{169}
10255 @section Attribute Abort_Signal
10256
10257
10258 @geindex Abort_Signal
10259
10260 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
10261 prefix) provides the entity for the special exception used to signal
10262 task abort or asynchronous transfer of control. Normally this attribute
10263 should only be used in the tasking runtime (it is highly peculiar, and
10264 completely outside the normal semantics of Ada, for a user program to
10265 intercept the abort exception).
10266
10267 @node Attribute Address_Size,Attribute Asm_Input,Attribute Abort_Signal,Implementation Defined Attributes
10268 @anchor{gnat_rm/implementation_defined_attributes attribute-address-size}@anchor{16a}
10269 @section Attribute Address_Size
10270
10271
10272 @geindex Size of `@w{`}Address`@w{`}
10273
10274 @geindex Address_Size
10275
10276 @code{Standard'Address_Size} (@code{Standard} is the only allowed
10277 prefix) is a static constant giving the number of bits in an
10278 @code{Address}. It is the same value as System.Address'Size,
10279 but has the advantage of being static, while a direct
10280 reference to System.Address'Size is nonstatic because Address
10281 is a private type.
10282
10283 @node Attribute Asm_Input,Attribute Asm_Output,Attribute Address_Size,Implementation Defined Attributes
10284 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-input}@anchor{16b}
10285 @section Attribute Asm_Input
10286
10287
10288 @geindex Asm_Input
10289
10290 The @code{Asm_Input} attribute denotes a function that takes two
10291 parameters. The first is a string, the second is an expression of the
10292 type designated by the prefix. The first (string) argument is required
10293 to be a static expression, and is the constraint for the parameter,
10294 (e.g., what kind of register is required). The second argument is the
10295 value to be used as the input argument. The possible values for the
10296 constant are the same as those used in the RTL, and are dependent on
10297 the configuration file used to built the GCC back end.
10298 @ref{16c,,Machine Code Insertions}
10299
10300 @node Attribute Asm_Output,Attribute Atomic_Always_Lock_Free,Attribute Asm_Input,Implementation Defined Attributes
10301 @anchor{gnat_rm/implementation_defined_attributes attribute-asm-output}@anchor{16d}
10302 @section Attribute Asm_Output
10303
10304
10305 @geindex Asm_Output
10306
10307 The @code{Asm_Output} attribute denotes a function that takes two
10308 parameters. The first is a string, the second is the name of a variable
10309 of the type designated by the attribute prefix. The first (string)
10310 argument is required to be a static expression and designates the
10311 constraint for the parameter (e.g., what kind of register is
10312 required). The second argument is the variable to be updated with the
10313 result. The possible values for constraint are the same as those used in
10314 the RTL, and are dependent on the configuration file used to build the
10315 GCC back end. If there are no output operands, then this argument may
10316 either be omitted, or explicitly given as @code{No_Output_Operands}.
10317 @ref{16c,,Machine Code Insertions}
10318
10319 @node Attribute Atomic_Always_Lock_Free,Attribute Bit,Attribute Asm_Output,Implementation Defined Attributes
10320 @anchor{gnat_rm/implementation_defined_attributes attribute-atomic-always-lock-free}@anchor{16e}
10321 @section Attribute Atomic_Always_Lock_Free
10322
10323
10324 @geindex Atomic_Always_Lock_Free
10325
10326 The prefix of the @code{Atomic_Always_Lock_Free} attribute is a type.
10327 The result is a Boolean value which is True if the type has discriminants,
10328 and False otherwise. The result indicate whether atomic operations are
10329 supported by the target for the given type.
10330
10331 @node Attribute Bit,Attribute Bit_Position,Attribute Atomic_Always_Lock_Free,Implementation Defined Attributes
10332 @anchor{gnat_rm/implementation_defined_attributes attribute-bit}@anchor{16f}
10333 @section Attribute Bit
10334
10335
10336 @geindex Bit
10337
10338 @code{obj'Bit}, where @code{obj} is any object, yields the bit
10339 offset within the storage unit (byte) that contains the first bit of
10340 storage allocated for the object. The value of this attribute is of the
10341 type @emph{universal_integer}, and is always a non-negative number not
10342 exceeding the value of @code{System.Storage_Unit}.
10343
10344 For an object that is a variable or a constant allocated in a register,
10345 the value is zero. (The use of this attribute does not force the
10346 allocation of a variable to memory).
10347
10348 For an object that is a formal parameter, this attribute applies
10349 to either the matching actual parameter or to a copy of the
10350 matching actual parameter.
10351
10352 For an access object the value is zero. Note that
10353 @code{obj.all'Bit} is subject to an @code{Access_Check} for the
10354 designated object. Similarly for a record component
10355 @code{X.C'Bit} is subject to a discriminant check and
10356 @code{X(I).Bit} and @code{X(I1..I2)'Bit}
10357 are subject to index checks.
10358
10359 This attribute is designed to be compatible with the DEC Ada 83 definition
10360 and implementation of the @code{Bit} attribute.
10361
10362 @node Attribute Bit_Position,Attribute Code_Address,Attribute Bit,Implementation Defined Attributes
10363 @anchor{gnat_rm/implementation_defined_attributes attribute-bit-position}@anchor{170}
10364 @section Attribute Bit_Position
10365
10366
10367 @geindex Bit_Position
10368
10369 @code{R.C'Bit_Position}, where @code{R} is a record object and @code{C} is one
10370 of the fields of the record type, yields the bit
10371 offset within the record contains the first bit of
10372 storage allocated for the object. The value of this attribute is of the
10373 type @emph{universal_integer}. The value depends only on the field
10374 @code{C} and is independent of the alignment of
10375 the containing record @code{R}.
10376
10377 @node Attribute Code_Address,Attribute Compiler_Version,Attribute Bit_Position,Implementation Defined Attributes
10378 @anchor{gnat_rm/implementation_defined_attributes attribute-code-address}@anchor{171}
10379 @section Attribute Code_Address
10380
10381
10382 @geindex Code_Address
10383
10384 @geindex Subprogram address
10385
10386 @geindex Address of subprogram code
10387
10388 The @code{'Address}
10389 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
10390 intended effect seems to be to provide
10391 an address value which can be used to call the subprogram by means of
10392 an address clause as in the following example:
10393
10394 @example
10395 procedure K is ...
10396
10397 procedure L;
10398 for L'Address use K'Address;
10399 pragma Import (Ada, L);
10400 @end example
10401
10402 A call to @code{L} is then expected to result in a call to @code{K}.
10403 In Ada 83, where there were no access-to-subprogram values, this was
10404 a common work-around for getting the effect of an indirect call.
10405 GNAT implements the above use of @code{Address} and the technique
10406 illustrated by the example code works correctly.
10407
10408 However, for some purposes, it is useful to have the address of the start
10409 of the generated code for the subprogram. On some architectures, this is
10410 not necessarily the same as the @code{Address} value described above.
10411 For example, the @code{Address} value may reference a subprogram
10412 descriptor rather than the subprogram itself.
10413
10414 The @code{'Code_Address} attribute, which can only be applied to
10415 subprogram entities, always returns the address of the start of the
10416 generated code of the specified subprogram, which may or may not be
10417 the same value as is returned by the corresponding @code{'Address}
10418 attribute.
10419
10420 @node Attribute Compiler_Version,Attribute Constrained,Attribute Code_Address,Implementation Defined Attributes
10421 @anchor{gnat_rm/implementation_defined_attributes attribute-compiler-version}@anchor{172}
10422 @section Attribute Compiler_Version
10423
10424
10425 @geindex Compiler_Version
10426
10427 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
10428 prefix) yields a static string identifying the version of the compiler
10429 being used to compile the unit containing the attribute reference.
10430
10431 @node Attribute Constrained,Attribute Default_Bit_Order,Attribute Compiler_Version,Implementation Defined Attributes
10432 @anchor{gnat_rm/implementation_defined_attributes attribute-constrained}@anchor{173}
10433 @section Attribute Constrained
10434
10435
10436 @geindex Constrained
10437
10438 In addition to the usage of this attribute in the Ada RM, GNAT
10439 also permits the use of the @code{'Constrained} attribute
10440 in a generic template
10441 for any type, including types without discriminants. The value of this
10442 attribute in the generic instance when applied to a scalar type or a
10443 record type without discriminants is always @code{True}. This usage is
10444 compatible with older Ada compilers, including notably DEC Ada.
10445
10446 @node Attribute Default_Bit_Order,Attribute Default_Scalar_Storage_Order,Attribute Constrained,Implementation Defined Attributes
10447 @anchor{gnat_rm/implementation_defined_attributes attribute-default-bit-order}@anchor{174}
10448 @section Attribute Default_Bit_Order
10449
10450
10451 @geindex Big endian
10452
10453 @geindex Little endian
10454
10455 @geindex Default_Bit_Order
10456
10457 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
10458 permissible prefix), provides the value @code{System.Default_Bit_Order}
10459 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
10460 @code{Low_Order_First}). This is used to construct the definition of
10461 @code{Default_Bit_Order} in package @code{System}.
10462
10463 @node Attribute Default_Scalar_Storage_Order,Attribute Deref,Attribute Default_Bit_Order,Implementation Defined Attributes
10464 @anchor{gnat_rm/implementation_defined_attributes attribute-default-scalar-storage-order}@anchor{175}
10465 @section Attribute Default_Scalar_Storage_Order
10466
10467
10468 @geindex Big endian
10469
10470 @geindex Little endian
10471
10472 @geindex Default_Scalar_Storage_Order
10473
10474 @code{Standard'Default_Scalar_Storage_Order} (@code{Standard} is the only
10475 permissible prefix), provides the current value of the default scalar storage
10476 order (as specified using pragma @code{Default_Scalar_Storage_Order}, or
10477 equal to @code{Default_Bit_Order} if unspecified) as a
10478 @code{System.Bit_Order} value. This is a static attribute.
10479
10480 @node Attribute Deref,Attribute Descriptor_Size,Attribute Default_Scalar_Storage_Order,Implementation Defined Attributes
10481 @anchor{gnat_rm/implementation_defined_attributes attribute-deref}@anchor{176}
10482 @section Attribute Deref
10483
10484
10485 @geindex Deref
10486
10487 The attribute @code{typ'Deref(expr)} where @code{expr} is of type @code{System.Address} yields
10488 the variable of type @code{typ} that is located at the given address. It is similar
10489 to @code{(totyp (expr).all)}, where @code{totyp} is an unchecked conversion from address to
10490 a named access-to-@cite{typ} type, except that it yields a variable, so it can be
10491 used on the left side of an assignment.
10492
10493 @node Attribute Descriptor_Size,Attribute Elaborated,Attribute Deref,Implementation Defined Attributes
10494 @anchor{gnat_rm/implementation_defined_attributes attribute-descriptor-size}@anchor{177}
10495 @section Attribute Descriptor_Size
10496
10497
10498 @geindex Descriptor
10499
10500 @geindex Dope vector
10501
10502 @geindex Descriptor_Size
10503
10504 Nonstatic attribute @code{Descriptor_Size} returns the size in bits of the
10505 descriptor allocated for a type. The result is non-zero only for unconstrained
10506 array types and the returned value is of type universal integer. In GNAT, an
10507 array descriptor contains bounds information and is located immediately before
10508 the first element of the array.
10509
10510 @example
10511 type Unconstr_Array is array (Positive range <>) of Boolean;
10512 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
10513 @end example
10514
10515 The attribute takes into account any additional padding due to type alignment.
10516 In the example above, the descriptor contains two values of type
10517 @code{Positive} representing the low and high bound. Since @code{Positive} has
10518 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 * Positive'Size + 2} or 64 bits.
10519
10520 @node Attribute Elaborated,Attribute Elab_Body,Attribute Descriptor_Size,Implementation Defined Attributes
10521 @anchor{gnat_rm/implementation_defined_attributes attribute-elaborated}@anchor{178}
10522 @section Attribute Elaborated
10523
10524
10525 @geindex Elaborated
10526
10527 The prefix of the @code{'Elaborated} attribute must be a unit name. The
10528 value is a Boolean which indicates whether or not the given unit has been
10529 elaborated. This attribute is primarily intended for internal use by the
10530 generated code for dynamic elaboration checking, but it can also be used
10531 in user programs. The value will always be True once elaboration of all
10532 units has been completed. An exception is for units which need no
10533 elaboration, the value is always False for such units.
10534
10535 @node Attribute Elab_Body,Attribute Elab_Spec,Attribute Elaborated,Implementation Defined Attributes
10536 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-body}@anchor{179}
10537 @section Attribute Elab_Body
10538
10539
10540 @geindex Elab_Body
10541
10542 This attribute can only be applied to a program unit name. It returns
10543 the entity for the corresponding elaboration procedure for elaborating
10544 the body of the referenced unit. This is used in the main generated
10545 elaboration procedure by the binder and is not normally used in any
10546 other context. However, there may be specialized situations in which it
10547 is useful to be able to call this elaboration procedure from Ada code,
10548 e.g., if it is necessary to do selective re-elaboration to fix some
10549 error.
10550
10551 @node Attribute Elab_Spec,Attribute Elab_Subp_Body,Attribute Elab_Body,Implementation Defined Attributes
10552 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-spec}@anchor{17a}
10553 @section Attribute Elab_Spec
10554
10555
10556 @geindex Elab_Spec
10557
10558 This attribute can only be applied to a program unit name. It returns
10559 the entity for the corresponding elaboration procedure for elaborating
10560 the spec of the referenced unit. This is used in the main
10561 generated elaboration procedure by the binder and is not normally used
10562 in any other context. However, there may be specialized situations in
10563 which it is useful to be able to call this elaboration procedure from
10564 Ada code, e.g., if it is necessary to do selective re-elaboration to fix
10565 some error.
10566
10567 @node Attribute Elab_Subp_Body,Attribute Emax,Attribute Elab_Spec,Implementation Defined Attributes
10568 @anchor{gnat_rm/implementation_defined_attributes attribute-elab-subp-body}@anchor{17b}
10569 @section Attribute Elab_Subp_Body
10570
10571
10572 @geindex Elab_Subp_Body
10573
10574 This attribute can only be applied to a library level subprogram
10575 name and is only allowed in CodePeer mode. It returns the entity
10576 for the corresponding elaboration procedure for elaborating the body
10577 of the referenced subprogram unit. This is used in the main generated
10578 elaboration procedure by the binder in CodePeer mode only and is unrecognized
10579 otherwise.
10580
10581 @node Attribute Emax,Attribute Enabled,Attribute Elab_Subp_Body,Implementation Defined Attributes
10582 @anchor{gnat_rm/implementation_defined_attributes attribute-emax}@anchor{17c}
10583 @section Attribute Emax
10584
10585
10586 @geindex Ada 83 attributes
10587
10588 @geindex Emax
10589
10590 The @code{Emax} attribute is provided for compatibility with Ada 83. See
10591 the Ada 83 reference manual for an exact description of the semantics of
10592 this attribute.
10593
10594 @node Attribute Enabled,Attribute Enum_Rep,Attribute Emax,Implementation Defined Attributes
10595 @anchor{gnat_rm/implementation_defined_attributes attribute-enabled}@anchor{17d}
10596 @section Attribute Enabled
10597
10598
10599 @geindex Enabled
10600
10601 The @code{Enabled} attribute allows an application program to check at compile
10602 time to see if the designated check is currently enabled. The prefix is a
10603 simple identifier, referencing any predefined check name (other than
10604 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
10605 no argument is given for the attribute, the check is for the general state
10606 of the check, if an argument is given, then it is an entity name, and the
10607 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
10608 given naming the entity (if not, then the argument is ignored).
10609
10610 Note that instantiations inherit the check status at the point of the
10611 instantiation, so a useful idiom is to have a library package that
10612 introduces a check name with @code{pragma Check_Name}, and then contains
10613 generic packages or subprograms which use the @code{Enabled} attribute
10614 to see if the check is enabled. A user of this package can then issue
10615 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
10616 the package or subprogram, controlling whether the check will be present.
10617
10618 @node Attribute Enum_Rep,Attribute Enum_Val,Attribute Enabled,Implementation Defined Attributes
10619 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-rep}@anchor{17e}
10620 @section Attribute Enum_Rep
10621
10622
10623 @geindex Representation of enums
10624
10625 @geindex Enum_Rep
10626
10627 For every enumeration subtype @code{S}, @code{S'Enum_Rep} denotes a
10628 function with the following spec:
10629
10630 @example
10631 function S'Enum_Rep (Arg : S'Base) return <Universal_Integer>;
10632 @end example
10633
10634 It is also allowable to apply @code{Enum_Rep} directly to an object of an
10635 enumeration type or to a non-overloaded enumeration
10636 literal. In this case @code{S'Enum_Rep} is equivalent to
10637 @code{typ'Enum_Rep(S)} where @code{typ} is the type of the
10638 enumeration literal or object.
10639
10640 The function returns the representation value for the given enumeration
10641 value. This will be equal to value of the @code{Pos} attribute in the
10642 absence of an enumeration representation clause. This is a static
10643 attribute (i.e.,:the result is static if the argument is static).
10644
10645 @code{S'Enum_Rep} can also be used with integer types and objects,
10646 in which case it simply returns the integer value. The reason for this
10647 is to allow it to be used for @code{(<>)} discrete formal arguments in
10648 a generic unit that can be instantiated with either enumeration types
10649 or integer types. Note that if @code{Enum_Rep} is used on a modular
10650 type whose upper bound exceeds the upper bound of the largest signed
10651 integer type, and the argument is a variable, so that the universal
10652 integer calculation is done at run time, then the call to @code{Enum_Rep}
10653 may raise @code{Constraint_Error}.
10654
10655 @node Attribute Enum_Val,Attribute Epsilon,Attribute Enum_Rep,Implementation Defined Attributes
10656 @anchor{gnat_rm/implementation_defined_attributes attribute-enum-val}@anchor{17f}
10657 @section Attribute Enum_Val
10658
10659
10660 @geindex Representation of enums
10661
10662 @geindex Enum_Val
10663
10664 For every enumeration subtype @code{S}, @code{S'Enum_Val} denotes a
10665 function with the following spec:
10666
10667 @example
10668 function S'Enum_Val (Arg : <Universal_Integer>) return S'Base;
10669 @end example
10670
10671 The function returns the enumeration value whose representation matches the
10672 argument, or raises Constraint_Error if no enumeration literal of the type
10673 has the matching value.
10674 This will be equal to value of the @code{Val} attribute in the
10675 absence of an enumeration representation clause. This is a static
10676 attribute (i.e., the result is static if the argument is static).
10677
10678 @node Attribute Epsilon,Attribute Fast_Math,Attribute Enum_Val,Implementation Defined Attributes
10679 @anchor{gnat_rm/implementation_defined_attributes attribute-epsilon}@anchor{180}
10680 @section Attribute Epsilon
10681
10682
10683 @geindex Ada 83 attributes
10684
10685 @geindex Epsilon
10686
10687 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
10688 the Ada 83 reference manual for an exact description of the semantics of
10689 this attribute.
10690
10691 @node Attribute Fast_Math,Attribute Finalization_Size,Attribute Epsilon,Implementation Defined Attributes
10692 @anchor{gnat_rm/implementation_defined_attributes attribute-fast-math}@anchor{181}
10693 @section Attribute Fast_Math
10694
10695
10696 @geindex Fast_Math
10697
10698 @code{Standard'Fast_Math} (@code{Standard} is the only allowed
10699 prefix) yields a static Boolean value that is True if pragma
10700 @code{Fast_Math} is active, and False otherwise.
10701
10702 @node Attribute Finalization_Size,Attribute Fixed_Value,Attribute Fast_Math,Implementation Defined Attributes
10703 @anchor{gnat_rm/implementation_defined_attributes attribute-finalization-size}@anchor{182}
10704 @section Attribute Finalization_Size
10705
10706
10707 @geindex Finalization_Size
10708
10709 The prefix of attribute @code{Finalization_Size} must be an object or
10710 a non-class-wide type. This attribute returns the size of any hidden data
10711 reserved by the compiler to handle finalization-related actions. The type of
10712 the attribute is @emph{universal_integer}.
10713
10714 @code{Finalization_Size} yields a value of zero for a type with no controlled
10715 parts, an object whose type has no controlled parts, or an object of a
10716 class-wide type whose tag denotes a type with no controlled parts.
10717
10718 Note that only heap-allocated objects contain finalization data.
10719
10720 @node Attribute Fixed_Value,Attribute From_Any,Attribute Finalization_Size,Implementation Defined Attributes
10721 @anchor{gnat_rm/implementation_defined_attributes attribute-fixed-value}@anchor{183}
10722 @section Attribute Fixed_Value
10723
10724
10725 @geindex Fixed_Value
10726
10727 For every fixed-point type @code{S}, @code{S'Fixed_Value} denotes a
10728 function with the following specification:
10729
10730 @example
10731 function S'Fixed_Value (Arg : <Universal_Integer>) return S;
10732 @end example
10733
10734 The value returned is the fixed-point value @code{V} such that:
10735
10736 @example
10737 V = Arg * S'Small
10738 @end example
10739
10740 The effect is thus similar to first converting the argument to the
10741 integer type used to represent @code{S}, and then doing an unchecked
10742 conversion to the fixed-point type. The difference is
10743 that there are full range checks, to ensure that the result is in range.
10744 This attribute is primarily intended for use in implementation of the
10745 input-output functions for fixed-point values.
10746
10747 @node Attribute From_Any,Attribute Has_Access_Values,Attribute Fixed_Value,Implementation Defined Attributes
10748 @anchor{gnat_rm/implementation_defined_attributes attribute-from-any}@anchor{184}
10749 @section Attribute From_Any
10750
10751
10752 @geindex From_Any
10753
10754 This internal attribute is used for the generation of remote subprogram
10755 stubs in the context of the Distributed Systems Annex.
10756
10757 @node Attribute Has_Access_Values,Attribute Has_Discriminants,Attribute From_Any,Implementation Defined Attributes
10758 @anchor{gnat_rm/implementation_defined_attributes attribute-has-access-values}@anchor{185}
10759 @section Attribute Has_Access_Values
10760
10761
10762 @geindex Access values
10763 @geindex testing for
10764
10765 @geindex Has_Access_Values
10766
10767 The prefix of the @code{Has_Access_Values} attribute is a type. The result
10768 is a Boolean value which is True if the is an access type, or is a composite
10769 type with a component (at any nesting depth) that is an access type, and is
10770 False otherwise.
10771 The intended use of this attribute is in conjunction with generic
10772 definitions. If the attribute is applied to a generic private type, it
10773 indicates whether or not the corresponding actual type has access values.
10774
10775 @node Attribute Has_Discriminants,Attribute Img,Attribute Has_Access_Values,Implementation Defined Attributes
10776 @anchor{gnat_rm/implementation_defined_attributes attribute-has-discriminants}@anchor{186}
10777 @section Attribute Has_Discriminants
10778
10779
10780 @geindex Discriminants
10781 @geindex testing for
10782
10783 @geindex Has_Discriminants
10784
10785 The prefix of the @code{Has_Discriminants} attribute is a type. The result
10786 is a Boolean value which is True if the type has discriminants, and False
10787 otherwise. The intended use of this attribute is in conjunction with generic
10788 definitions. If the attribute is applied to a generic private type, it
10789 indicates whether or not the corresponding actual type has discriminants.
10790
10791 @node Attribute Img,Attribute Integer_Value,Attribute Has_Discriminants,Implementation Defined Attributes
10792 @anchor{gnat_rm/implementation_defined_attributes attribute-img}@anchor{187}
10793 @section Attribute Img
10794
10795
10796 @geindex Img
10797
10798 The @code{Img} attribute differs from @code{Image} in that, while both can be
10799 applied directly to an object, @code{Img} cannot be applied to types.
10800
10801 Example usage of the attribute:
10802
10803 @example
10804 Put_Line ("X = " & X'Img);
10805 @end example
10806
10807 which has the same meaning as the more verbose:
10808
10809 @example
10810 Put_Line ("X = " & T'Image (X));
10811 @end example
10812
10813 where @code{T} is the (sub)type of the object @code{X}.
10814
10815 Note that technically, in analogy to @code{Image},
10816 @code{X'Img} returns a parameterless function
10817 that returns the appropriate string when called. This means that
10818 @code{X'Img} can be renamed as a function-returning-string, or used
10819 in an instantiation as a function parameter.
10820
10821 @node Attribute Integer_Value,Attribute Invalid_Value,Attribute Img,Implementation Defined Attributes
10822 @anchor{gnat_rm/implementation_defined_attributes attribute-integer-value}@anchor{188}
10823 @section Attribute Integer_Value
10824
10825
10826 @geindex Integer_Value
10827
10828 For every integer type @code{S}, @code{S'Integer_Value} denotes a
10829 function with the following spec:
10830
10831 @example
10832 function S'Integer_Value (Arg : <Universal_Fixed>) return S;
10833 @end example
10834
10835 The value returned is the integer value @code{V}, such that:
10836
10837 @example
10838 Arg = V * T'Small
10839 @end example
10840
10841 where @code{T} is the type of @code{Arg}.
10842 The effect is thus similar to first doing an unchecked conversion from
10843 the fixed-point type to its corresponding implementation type, and then
10844 converting the result to the target integer type. The difference is
10845 that there are full range checks, to ensure that the result is in range.
10846 This attribute is primarily intended for use in implementation of the
10847 standard input-output functions for fixed-point values.
10848
10849 @node Attribute Invalid_Value,Attribute Iterable,Attribute Integer_Value,Implementation Defined Attributes
10850 @anchor{gnat_rm/implementation_defined_attributes attribute-invalid-value}@anchor{189}
10851 @section Attribute Invalid_Value
10852
10853
10854 @geindex Invalid_Value
10855
10856 For every scalar type S, S'Invalid_Value returns an undefined value of the
10857 type. If possible this value is an invalid representation for the type. The
10858 value returned is identical to the value used to initialize an otherwise
10859 uninitialized value of the type if pragma Initialize_Scalars is used,
10860 including the ability to modify the value with the binder -Sxx flag and
10861 relevant environment variables at run time.
10862
10863 @node Attribute Iterable,Attribute Large,Attribute Invalid_Value,Implementation Defined Attributes
10864 @anchor{gnat_rm/implementation_defined_attributes attribute-iterable}@anchor{18a}
10865 @section Attribute Iterable
10866
10867
10868 @geindex Iterable
10869
10870 Equivalent to Aspect Iterable.
10871
10872 @node Attribute Large,Attribute Library_Level,Attribute Iterable,Implementation Defined Attributes
10873 @anchor{gnat_rm/implementation_defined_attributes attribute-large}@anchor{18b}
10874 @section Attribute Large
10875
10876
10877 @geindex Ada 83 attributes
10878
10879 @geindex Large
10880
10881 The @code{Large} attribute is provided for compatibility with Ada 83. See
10882 the Ada 83 reference manual for an exact description of the semantics of
10883 this attribute.
10884
10885 @node Attribute Library_Level,Attribute Lock_Free,Attribute Large,Implementation Defined Attributes
10886 @anchor{gnat_rm/implementation_defined_attributes attribute-library-level}@anchor{18c}
10887 @section Attribute Library_Level
10888
10889
10890 @geindex Library_Level
10891
10892 @code{P'Library_Level}, where P is an entity name,
10893 returns a Boolean value which is True if the entity is declared
10894 at the library level, and False otherwise. Note that within a
10895 generic instantition, the name of the generic unit denotes the
10896 instance, which means that this attribute can be used to test
10897 if a generic is instantiated at the library level, as shown
10898 in this example:
10899
10900 @example
10901 generic
10902 ...
10903 package Gen is
10904 pragma Compile_Time_Error
10905 (not Gen'Library_Level,
10906 "Gen can only be instantiated at library level");
10907 ...
10908 end Gen;
10909 @end example
10910
10911 @node Attribute Lock_Free,Attribute Loop_Entry,Attribute Library_Level,Implementation Defined Attributes
10912 @anchor{gnat_rm/implementation_defined_attributes attribute-lock-free}@anchor{18d}
10913 @section Attribute Lock_Free
10914
10915
10916 @geindex Lock_Free
10917
10918 @code{P'Lock_Free}, where P is a protected object, returns True if a
10919 pragma @code{Lock_Free} applies to P.
10920
10921 @node Attribute Loop_Entry,Attribute Machine_Size,Attribute Lock_Free,Implementation Defined Attributes
10922 @anchor{gnat_rm/implementation_defined_attributes attribute-loop-entry}@anchor{18e}
10923 @section Attribute Loop_Entry
10924
10925
10926 @geindex Loop_Entry
10927
10928 Syntax:
10929
10930 @example
10931 X'Loop_Entry [(loop_name)]
10932 @end example
10933
10934 The @code{Loop_Entry} attribute is used to refer to the value that an
10935 expression had upon entry to a given loop in much the same way that the
10936 @code{Old} attribute in a subprogram postcondition can be used to refer
10937 to the value an expression had upon entry to the subprogram. The
10938 relevant loop is either identified by the given loop name, or it is the
10939 innermost enclosing loop when no loop name is given.
10940
10941 A @code{Loop_Entry} attribute can only occur within a
10942 @code{Loop_Variant} or @code{Loop_Invariant} pragma. A common use of
10943 @code{Loop_Entry} is to compare the current value of objects with their
10944 initial value at loop entry, in a @code{Loop_Invariant} pragma.
10945
10946 The effect of using @code{X'Loop_Entry} is the same as declaring
10947 a constant initialized with the initial value of @code{X} at loop
10948 entry. This copy is not performed if the loop is not entered, or if the
10949 corresponding pragmas are ignored or disabled.
10950
10951 @node Attribute Machine_Size,Attribute Mantissa,Attribute Loop_Entry,Implementation Defined Attributes
10952 @anchor{gnat_rm/implementation_defined_attributes attribute-machine-size}@anchor{18f}
10953 @section Attribute Machine_Size
10954
10955
10956 @geindex Machine_Size
10957
10958 This attribute is identical to the @code{Object_Size} attribute. It is
10959 provided for compatibility with the DEC Ada 83 attribute of this name.
10960
10961 @node Attribute Mantissa,Attribute Maximum_Alignment,Attribute Machine_Size,Implementation Defined Attributes
10962 @anchor{gnat_rm/implementation_defined_attributes attribute-mantissa}@anchor{190}
10963 @section Attribute Mantissa
10964
10965
10966 @geindex Ada 83 attributes
10967
10968 @geindex Mantissa
10969
10970 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
10971 the Ada 83 reference manual for an exact description of the semantics of
10972 this attribute.
10973
10974 @node Attribute Maximum_Alignment,Attribute Mechanism_Code,Attribute Mantissa,Implementation Defined Attributes
10975 @anchor{gnat_rm/implementation_defined_attributes attribute-maximum-alignment}@anchor{191}@anchor{gnat_rm/implementation_defined_attributes id2}@anchor{192}
10976 @section Attribute Maximum_Alignment
10977
10978
10979 @geindex Alignment
10980 @geindex maximum
10981
10982 @geindex Maximum_Alignment
10983
10984 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
10985 permissible prefix) provides the maximum useful alignment value for the
10986 target. This is a static value that can be used to specify the alignment
10987 for an object, guaranteeing that it is properly aligned in all
10988 cases.
10989
10990 @node Attribute Mechanism_Code,Attribute Null_Parameter,Attribute Maximum_Alignment,Implementation Defined Attributes
10991 @anchor{gnat_rm/implementation_defined_attributes attribute-mechanism-code}@anchor{193}
10992 @section Attribute Mechanism_Code
10993
10994
10995 @geindex Return values
10996 @geindex passing mechanism
10997
10998 @geindex Parameters
10999 @geindex passing mechanism
11000
11001 @geindex Mechanism_Code
11002
11003 @code{func'Mechanism_Code} yields an integer code for the
11004 mechanism used for the result of function @code{func}, and
11005 @code{subprog'Mechanism_Code (n)} yields the mechanism
11006 used for formal parameter number @emph{n} (a static integer value, with 1
11007 meaning the first parameter) of subprogram @code{subprog}. The code returned is:
11008
11009
11010 @table @asis
11011
11012 @item @emph{1}
11013
11014 by copy (value)
11015
11016 @item @emph{2}
11017
11018 by reference
11019 @end table
11020
11021 @node Attribute Null_Parameter,Attribute Object_Size,Attribute Mechanism_Code,Implementation Defined Attributes
11022 @anchor{gnat_rm/implementation_defined_attributes attribute-null-parameter}@anchor{194}
11023 @section Attribute Null_Parameter
11024
11025
11026 @geindex Zero address
11027 @geindex passing
11028
11029 @geindex Null_Parameter
11030
11031 A reference @code{T'Null_Parameter} denotes an imaginary object of
11032 type or subtype @code{T} allocated at machine address zero. The attribute
11033 is allowed only as the default expression of a formal parameter, or as
11034 an actual expression of a subprogram call. In either case, the
11035 subprogram must be imported.
11036
11037 The identity of the object is represented by the address zero in the
11038 argument list, independent of the passing mechanism (explicit or
11039 default).
11040
11041 This capability is needed to specify that a zero address should be
11042 passed for a record or other composite object passed by reference.
11043 There is no way of indicating this without the @code{Null_Parameter}
11044 attribute.
11045
11046 @node Attribute Object_Size,Attribute Old,Attribute Null_Parameter,Implementation Defined Attributes
11047 @anchor{gnat_rm/implementation_defined_attributes attribute-object-size}@anchor{147}@anchor{gnat_rm/implementation_defined_attributes id3}@anchor{195}
11048 @section Attribute Object_Size
11049
11050
11051 @geindex Size
11052 @geindex used for objects
11053
11054 @geindex Object_Size
11055
11056 The size of an object is not necessarily the same as the size of the type
11057 of an object. This is because by default object sizes are increased to be
11058 a multiple of the alignment of the object. For example,
11059 @code{Natural'Size} is
11060 31, but by default objects of type @code{Natural} will have a size of 32 bits.
11061 Similarly, a record containing an integer and a character:
11062
11063 @example
11064 type Rec is record
11065 I : Integer;
11066 C : Character;
11067 end record;
11068 @end example
11069
11070 will have a size of 40 (that is @code{Rec'Size} will be 40). The
11071 alignment will be 4, because of the
11072 integer field, and so the default size of record objects for this type
11073 will be 64 (8 bytes).
11074
11075 If the alignment of the above record is specified to be 1, then the
11076 object size will be 40 (5 bytes). This is true by default, and also
11077 an object size of 40 can be explicitly specified in this case.
11078
11079 A consequence of this capability is that different object sizes can be
11080 given to subtypes that would otherwise be considered in Ada to be
11081 statically matching. But it makes no sense to consider such subtypes
11082 as statically matching. Consequently, GNAT adds a rule
11083 to the static matching rules that requires object sizes to match.
11084 Consider this example:
11085
11086 @example
11087 1. procedure BadAVConvert is
11088 2. type R is new Integer;
11089 3. subtype R1 is R range 1 .. 10;
11090 4. subtype R2 is R range 1 .. 10;
11091 5. for R1'Object_Size use 8;
11092 6. for R2'Object_Size use 16;
11093 7. type R1P is access all R1;
11094 8. type R2P is access all R2;
11095 9. R1PV : R1P := new R1'(4);
11096 10. R2PV : R2P;
11097 11. begin
11098 12. R2PV := R2P (R1PV);
11099 |
11100 >>> target designated subtype not compatible with
11101 type "R1" defined at line 3
11102
11103 13. end;
11104 @end example
11105
11106 In the absence of lines 5 and 6,
11107 types @code{R1} and @code{R2} statically match and
11108 hence the conversion on line 12 is legal. But since lines 5 and 6
11109 cause the object sizes to differ, GNAT considers that types
11110 @code{R1} and @code{R2} are not statically matching, and line 12
11111 generates the diagnostic shown above.
11112
11113 Similar additional checks are performed in other contexts requiring
11114 statically matching subtypes.
11115
11116 @node Attribute Old,Attribute Passed_By_Reference,Attribute Object_Size,Implementation Defined Attributes
11117 @anchor{gnat_rm/implementation_defined_attributes attribute-old}@anchor{196}
11118 @section Attribute Old
11119
11120
11121 @geindex Old
11122
11123 In addition to the usage of @code{Old} defined in the Ada 2012 RM (usage
11124 within @code{Post} aspect), GNAT also permits the use of this attribute
11125 in implementation defined pragmas @code{Postcondition},
11126 @code{Contract_Cases} and @code{Test_Case}. Also usages of
11127 @code{Old} which would be illegal according to the Ada 2012 RM
11128 definition are allowed under control of
11129 implementation defined pragma @code{Unevaluated_Use_Of_Old}.
11130
11131 @node Attribute Passed_By_Reference,Attribute Pool_Address,Attribute Old,Implementation Defined Attributes
11132 @anchor{gnat_rm/implementation_defined_attributes attribute-passed-by-reference}@anchor{197}
11133 @section Attribute Passed_By_Reference
11134
11135
11136 @geindex Parameters
11137 @geindex when passed by reference
11138
11139 @geindex Passed_By_Reference
11140
11141 @code{typ'Passed_By_Reference} for any subtype @cite{typ} returns
11142 a value of type @code{Boolean} value that is @code{True} if the type is
11143 normally passed by reference and @code{False} if the type is normally
11144 passed by copy in calls. For scalar types, the result is always @code{False}
11145 and is static. For non-scalar types, the result is nonstatic.
11146
11147 @node Attribute Pool_Address,Attribute Range_Length,Attribute Passed_By_Reference,Implementation Defined Attributes
11148 @anchor{gnat_rm/implementation_defined_attributes attribute-pool-address}@anchor{198}
11149 @section Attribute Pool_Address
11150
11151
11152 @geindex Parameters
11153 @geindex when passed by reference
11154
11155 @geindex Pool_Address
11156
11157 @code{X'Pool_Address} for any object @code{X} returns the address
11158 of X within its storage pool. This is the same as
11159 @code{X'Address}, except that for an unconstrained array whose
11160 bounds are allocated just before the first component,
11161 @code{X'Pool_Address} returns the address of those bounds,
11162 whereas @code{X'Address} returns the address of the first
11163 component.
11164
11165 Here, we are interpreting 'storage pool' broadly to mean
11166 @code{wherever the object is allocated}, which could be a
11167 user-defined storage pool,
11168 the global heap, on the stack, or in a static memory area.
11169 For an object created by @code{new}, @code{Ptr.all'Pool_Address} is
11170 what is passed to @code{Allocate} and returned from @code{Deallocate}.
11171
11172 @node Attribute Range_Length,Attribute Restriction_Set,Attribute Pool_Address,Implementation Defined Attributes
11173 @anchor{gnat_rm/implementation_defined_attributes attribute-range-length}@anchor{199}
11174 @section Attribute Range_Length
11175
11176
11177 @geindex Range_Length
11178
11179 @code{typ'Range_Length} for any discrete type @cite{typ} yields
11180 the number of values represented by the subtype (zero for a null
11181 range). The result is static for static subtypes. @code{Range_Length}
11182 applied to the index subtype of a one dimensional array always gives the
11183 same result as @code{Length} applied to the array itself.
11184
11185 @node Attribute Restriction_Set,Attribute Result,Attribute Range_Length,Implementation Defined Attributes
11186 @anchor{gnat_rm/implementation_defined_attributes attribute-restriction-set}@anchor{19a}
11187 @section Attribute Restriction_Set
11188
11189
11190 @geindex Restriction_Set
11191
11192 @geindex Restrictions
11193
11194 This attribute allows compile time testing of restrictions that
11195 are currently in effect. It is primarily intended for specializing
11196 code in the run-time based on restrictions that are active (e.g.
11197 don't need to save fpt registers if restriction No_Floating_Point
11198 is known to be in effect), but can be used anywhere.
11199
11200 There are two forms:
11201
11202 @example
11203 System'Restriction_Set (partition_boolean_restriction_NAME)
11204 System'Restriction_Set (No_Dependence => library_unit_NAME);
11205 @end example
11206
11207 In the case of the first form, the only restriction names
11208 allowed are parameterless restrictions that are checked
11209 for consistency at bind time. For a complete list see the
11210 subtype @code{System.Rident.Partition_Boolean_Restrictions}.
11211
11212 The result returned is True if the restriction is known to
11213 be in effect, and False if the restriction is known not to
11214 be in effect. An important guarantee is that the value of
11215 a Restriction_Set attribute is known to be consistent throughout
11216 all the code of a partition.
11217
11218 This is trivially achieved if the entire partition is compiled
11219 with a consistent set of restriction pragmas. However, the
11220 compilation model does not require this. It is possible to
11221 compile one set of units with one set of pragmas, and another
11222 set of units with another set of pragmas. It is even possible
11223 to compile a spec with one set of pragmas, and then WITH the
11224 same spec with a different set of pragmas. Inconsistencies
11225 in the actual use of the restriction are checked at bind time.
11226
11227 In order to achieve the guarantee of consistency for the
11228 Restriction_Set pragma, we consider that a use of the pragma
11229 that yields False is equivalent to a violation of the
11230 restriction.
11231
11232 So for example if you write
11233
11234 @example
11235 if System'Restriction_Set (No_Floating_Point) then
11236 ...
11237 else
11238 ...
11239 end if;
11240 @end example
11241
11242 And the result is False, so that the else branch is executed,
11243 you can assume that this restriction is not set for any unit
11244 in the partition. This is checked by considering this use of
11245 the restriction pragma to be a violation of the restriction
11246 No_Floating_Point. This means that no other unit can attempt
11247 to set this restriction (if some unit does attempt to set it,
11248 the binder will refuse to bind the partition).
11249
11250 Technical note: The restriction name and the unit name are
11251 intepreted entirely syntactically, as in the corresponding
11252 Restrictions pragma, they are not analyzed semantically,
11253 so they do not have a type.
11254
11255 @node Attribute Result,Attribute Safe_Emax,Attribute Restriction_Set,Implementation Defined Attributes
11256 @anchor{gnat_rm/implementation_defined_attributes attribute-result}@anchor{19b}
11257 @section Attribute Result
11258
11259
11260 @geindex Result
11261
11262 @code{function'Result} can only be used with in a Postcondition pragma
11263 for a function. The prefix must be the name of the corresponding function. This
11264 is used to refer to the result of the function in the postcondition expression.
11265 For a further discussion of the use of this attribute and examples of its use,
11266 see the description of pragma Postcondition.
11267
11268 @node Attribute Safe_Emax,Attribute Safe_Large,Attribute Result,Implementation Defined Attributes
11269 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-emax}@anchor{19c}
11270 @section Attribute Safe_Emax
11271
11272
11273 @geindex Ada 83 attributes
11274
11275 @geindex Safe_Emax
11276
11277 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
11278 the Ada 83 reference manual for an exact description of the semantics of
11279 this attribute.
11280
11281 @node Attribute Safe_Large,Attribute Safe_Small,Attribute Safe_Emax,Implementation Defined Attributes
11282 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-large}@anchor{19d}
11283 @section Attribute Safe_Large
11284
11285
11286 @geindex Ada 83 attributes
11287
11288 @geindex Safe_Large
11289
11290 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
11291 the Ada 83 reference manual for an exact description of the semantics of
11292 this attribute.
11293
11294 @node Attribute Safe_Small,Attribute Scalar_Storage_Order,Attribute Safe_Large,Implementation Defined Attributes
11295 @anchor{gnat_rm/implementation_defined_attributes attribute-safe-small}@anchor{19e}
11296 @section Attribute Safe_Small
11297
11298
11299 @geindex Ada 83 attributes
11300
11301 @geindex Safe_Small
11302
11303 The @code{Safe_Small} attribute is provided for compatibility with Ada 83. See
11304 the Ada 83 reference manual for an exact description of the semantics of
11305 this attribute.
11306
11307 @node Attribute Scalar_Storage_Order,Attribute Simple_Storage_Pool,Attribute Safe_Small,Implementation Defined Attributes
11308 @anchor{gnat_rm/implementation_defined_attributes id4}@anchor{19f}@anchor{gnat_rm/implementation_defined_attributes attribute-scalar-storage-order}@anchor{154}
11309 @section Attribute Scalar_Storage_Order
11310
11311
11312 @geindex Endianness
11313
11314 @geindex Scalar storage order
11315
11316 @geindex Scalar_Storage_Order
11317
11318 For every array or record type @code{S}, the representation attribute
11319 @code{Scalar_Storage_Order} denotes the order in which storage elements
11320 that make up scalar components are ordered within S. The value given must
11321 be a static expression of type System.Bit_Order. The following is an example
11322 of the use of this feature:
11323
11324 @example
11325 -- Component type definitions
11326
11327 subtype Yr_Type is Natural range 0 .. 127;
11328 subtype Mo_Type is Natural range 1 .. 12;
11329 subtype Da_Type is Natural range 1 .. 31;
11330
11331 -- Record declaration
11332
11333 type Date is record
11334 Years_Since_1980 : Yr_Type;
11335 Month : Mo_Type;
11336 Day_Of_Month : Da_Type;
11337 end record;
11338
11339 -- Record representation clause
11340
11341 for Date use record
11342 Years_Since_1980 at 0 range 0 .. 6;
11343 Month at 0 range 7 .. 10;
11344 Day_Of_Month at 0 range 11 .. 15;
11345 end record;
11346
11347 -- Attribute definition clauses
11348
11349 for Date'Bit_Order use System.High_Order_First;
11350 for Date'Scalar_Storage_Order use System.High_Order_First;
11351 -- If Scalar_Storage_Order is specified, it must be consistent with
11352 -- Bit_Order, so it's best to always define the latter explicitly if
11353 -- the former is used.
11354 @end example
11355
11356 Other properties are as for the standard representation attribute @code{Bit_Order}
11357 defined by Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
11358
11359 For a record type @code{T}, if @code{T'Scalar_Storage_Order} is
11360 specified explicitly, it shall be equal to @code{T'Bit_Order}. Note:
11361 this means that if a @code{Scalar_Storage_Order} attribute definition
11362 clause is not confirming, then the type's @code{Bit_Order} shall be
11363 specified explicitly and set to the same value.
11364
11365 Derived types inherit an explicitly set scalar storage order from their parent
11366 types. This may be overridden for the derived type by giving an explicit scalar
11367 storage order for it. However, for a record extension, the derived type must
11368 have the same scalar storage order as the parent type.
11369
11370 A component of a record type that is itself a record or an array and that does
11371 not start and end on a byte boundary must have have the same scalar storage
11372 order as the record type. A component of a bit-packed array type that is itself
11373 a record or an array must have the same scalar storage order as the array type.
11374
11375 No component of a type that has an explicit @code{Scalar_Storage_Order}
11376 attribute definition may be aliased.
11377
11378 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
11379 with a value equal to @code{System.Default_Bit_Order}) has no effect.
11380
11381 If the opposite storage order is specified, then whenever the value of
11382 a scalar component of an object of type @code{S} is read, the storage
11383 elements of the enclosing machine scalar are first reversed (before
11384 retrieving the component value, possibly applying some shift and mask
11385 operatings on the enclosing machine scalar), and the opposite operation
11386 is done for writes.
11387
11388 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
11389 are relaxed. Instead, the following rules apply:
11390
11391
11392 @itemize *
11393
11394 @item
11395 the underlying storage elements are those at positions
11396 @code{(position + first_bit / storage_element_size) .. (position + (last_bit + storage_element_size - 1) / storage_element_size)}
11397
11398 @item
11399 the sequence of underlying storage elements shall have
11400 a size no greater than the largest machine scalar
11401
11402 @item
11403 the enclosing machine scalar is defined as the smallest machine
11404 scalar starting at a position no greater than
11405 @code{position + first_bit / storage_element_size} and covering
11406 storage elements at least up to @code{position + (last_bit + storage_element_size - 1) / storage_element_size`}
11407
11408 @item
11409 the position of the component is interpreted relative to that machine
11410 scalar.
11411 @end itemize
11412
11413 If no scalar storage order is specified for a type (either directly, or by
11414 inheritance in the case of a derived type), then the default is normally
11415 the native ordering of the target, but this default can be overridden using
11416 pragma @code{Default_Scalar_Storage_Order}.
11417
11418 If a component of @code{T} is itself of a record or array type, the specfied
11419 @code{Scalar_Storage_Order} does @emph{not} apply to that nested type: an explicit
11420 attribute definition clause must be provided for the component type as well
11421 if desired.
11422
11423 Note that the scalar storage order only affects the in-memory data
11424 representation. It has no effect on the representation used by stream
11425 attributes.
11426
11427 Note that debuggers may be unable to display the correct value of scalar
11428 components of a type for which the opposite storage order is specified.
11429
11430 @node Attribute Simple_Storage_Pool,Attribute Small,Attribute Scalar_Storage_Order,Implementation Defined Attributes
11431 @anchor{gnat_rm/implementation_defined_attributes attribute-simple-storage-pool}@anchor{e9}@anchor{gnat_rm/implementation_defined_attributes id5}@anchor{1a0}
11432 @section Attribute Simple_Storage_Pool
11433
11434
11435 @geindex Storage pool
11436 @geindex simple
11437
11438 @geindex Simple storage pool
11439
11440 @geindex Simple_Storage_Pool
11441
11442 For every nonformal, nonderived access-to-object type @code{Acc}, the
11443 representation attribute @code{Simple_Storage_Pool} may be specified
11444 via an attribute_definition_clause (or by specifying the equivalent aspect):
11445
11446 @example
11447 My_Pool : My_Simple_Storage_Pool_Type;
11448
11449 type Acc is access My_Data_Type;
11450
11451 for Acc'Simple_Storage_Pool use My_Pool;
11452 @end example
11453
11454 The name given in an attribute_definition_clause for the
11455 @code{Simple_Storage_Pool} attribute shall denote a variable of
11456 a 'simple storage pool type' (see pragma @cite{Simple_Storage_Pool_Type}).
11457
11458 The use of this attribute is only allowed for a prefix denoting a type
11459 for which it has been specified. The type of the attribute is the type
11460 of the variable specified as the simple storage pool of the access type,
11461 and the attribute denotes that variable.
11462
11463 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
11464 for the same access type.
11465
11466 If the @code{Simple_Storage_Pool} attribute has been specified for an access
11467 type, then applying the @code{Storage_Pool} attribute to the type is flagged
11468 with a warning and its evaluation raises the exception @code{Program_Error}.
11469
11470 If the Simple_Storage_Pool attribute has been specified for an access
11471 type @code{S}, then the evaluation of the attribute @code{S'Storage_Size}
11472 returns the result of calling @code{Storage_Size (S'Simple_Storage_Pool)},
11473 which is intended to indicate the number of storage elements reserved for
11474 the simple storage pool. If the Storage_Size function has not been defined
11475 for the simple storage pool type, then this attribute returns zero.
11476
11477 If an access type @code{S} has a specified simple storage pool of type
11478 @code{SSP}, then the evaluation of an allocator for that access type calls
11479 the primitive @code{Allocate} procedure for type @code{SSP}, passing
11480 @code{S'Simple_Storage_Pool} as the pool parameter. The detailed
11481 semantics of such allocators is the same as those defined for allocators
11482 in section 13.11 of the @cite{Ada Reference Manual}, with the term
11483 @emph{simple storage pool} substituted for @emph{storage pool}.
11484
11485 If an access type @code{S} has a specified simple storage pool of type
11486 @code{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
11487 for that access type invokes the primitive @code{Deallocate} procedure
11488 for type @code{SSP}, passing @code{S'Simple_Storage_Pool} as the pool
11489 parameter. The detailed semantics of such unchecked deallocations is the same
11490 as defined in section 13.11.2 of the Ada Reference Manual, except that the
11491 term @emph{simple storage pool} is substituted for @emph{storage pool}.
11492
11493 @node Attribute Small,Attribute Storage_Unit,Attribute Simple_Storage_Pool,Implementation Defined Attributes
11494 @anchor{gnat_rm/implementation_defined_attributes attribute-small}@anchor{1a1}
11495 @section Attribute Small
11496
11497
11498 @geindex Ada 83 attributes
11499
11500 @geindex Small
11501
11502 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
11503 fixed-point types.
11504 GNAT also allows this attribute to be applied to floating-point types
11505 for compatibility with Ada 83. See
11506 the Ada 83 reference manual for an exact description of the semantics of
11507 this attribute when applied to floating-point types.
11508
11509 @node Attribute Storage_Unit,Attribute Stub_Type,Attribute Small,Implementation Defined Attributes
11510 @anchor{gnat_rm/implementation_defined_attributes attribute-storage-unit}@anchor{1a2}
11511 @section Attribute Storage_Unit
11512
11513
11514 @geindex Storage_Unit
11515
11516 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
11517 prefix) provides the same value as @code{System.Storage_Unit}.
11518
11519 @node Attribute Stub_Type,Attribute System_Allocator_Alignment,Attribute Storage_Unit,Implementation Defined Attributes
11520 @anchor{gnat_rm/implementation_defined_attributes attribute-stub-type}@anchor{1a3}
11521 @section Attribute Stub_Type
11522
11523
11524 @geindex Stub_Type
11525
11526 The GNAT implementation of remote access-to-classwide types is
11527 organized as described in AARM section E.4 (20.t): a value of an RACW type
11528 (designating a remote object) is represented as a normal access
11529 value, pointing to a "stub" object which in turn contains the
11530 necessary information to contact the designated remote object. A
11531 call on any dispatching operation of such a stub object does the
11532 remote call, if necessary, using the information in the stub object
11533 to locate the target partition, etc.
11534
11535 For a prefix @code{T} that denotes a remote access-to-classwide type,
11536 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
11537
11538 By construction, the layout of @code{T'Stub_Type} is identical to that of
11539 type @code{RACW_Stub_Type} declared in the internal implementation-defined
11540 unit @code{System.Partition_Interface}. Use of this attribute will create
11541 an implicit dependency on this unit.
11542
11543 @node Attribute System_Allocator_Alignment,Attribute Target_Name,Attribute Stub_Type,Implementation Defined Attributes
11544 @anchor{gnat_rm/implementation_defined_attributes attribute-system-allocator-alignment}@anchor{1a4}
11545 @section Attribute System_Allocator_Alignment
11546
11547
11548 @geindex Alignment
11549 @geindex allocator
11550
11551 @geindex System_Allocator_Alignment
11552
11553 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
11554 permissible prefix) provides the observable guaranted to be honored by
11555 the system allocator (malloc). This is a static value that can be used
11556 in user storage pools based on malloc either to reject allocation
11557 with alignment too large or to enable a realignment circuitry if the
11558 alignment request is larger than this value.
11559
11560 @node Attribute Target_Name,Attribute To_Address,Attribute System_Allocator_Alignment,Implementation Defined Attributes
11561 @anchor{gnat_rm/implementation_defined_attributes attribute-target-name}@anchor{1a5}
11562 @section Attribute Target_Name
11563
11564
11565 @geindex Target_Name
11566
11567 @code{Standard'Target_Name} (@code{Standard} is the only permissible
11568 prefix) provides a static string value that identifies the target
11569 for the current compilation. For GCC implementations, this is the
11570 standard gcc target name without the terminating slash (for
11571 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
11572
11573 @node Attribute To_Address,Attribute To_Any,Attribute Target_Name,Implementation Defined Attributes
11574 @anchor{gnat_rm/implementation_defined_attributes attribute-to-address}@anchor{1a6}
11575 @section Attribute To_Address
11576
11577
11578 @geindex To_Address
11579
11580 The @code{System'To_Address}
11581 (@code{System} is the only permissible prefix)
11582 denotes a function identical to
11583 @code{System.Storage_Elements.To_Address} except that
11584 it is a static attribute. This means that if its argument is
11585 a static expression, then the result of the attribute is a
11586 static expression. This means that such an expression can be
11587 used in contexts (e.g., preelaborable packages) which require a
11588 static expression and where the function call could not be used
11589 (since the function call is always nonstatic, even if its
11590 argument is static). The argument must be in the range
11591 -(2**(m-1)) .. 2**m-1, where m is the memory size
11592 (typically 32 or 64). Negative values are intepreted in a
11593 modular manner (e.g., -1 means the same as 16#FFFF_FFFF# on
11594 a 32 bits machine).
11595
11596 @node Attribute To_Any,Attribute Type_Class,Attribute To_Address,Implementation Defined Attributes
11597 @anchor{gnat_rm/implementation_defined_attributes attribute-to-any}@anchor{1a7}
11598 @section Attribute To_Any
11599
11600
11601 @geindex To_Any
11602
11603 This internal attribute is used for the generation of remote subprogram
11604 stubs in the context of the Distributed Systems Annex.
11605
11606 @node Attribute Type_Class,Attribute Type_Key,Attribute To_Any,Implementation Defined Attributes
11607 @anchor{gnat_rm/implementation_defined_attributes attribute-type-class}@anchor{1a8}
11608 @section Attribute Type_Class
11609
11610
11611 @geindex Type_Class
11612
11613 @code{typ'Type_Class} for any type or subtype @cite{typ} yields
11614 the value of the type class for the full type of @cite{typ}. If
11615 @cite{typ} is a generic formal type, the value is the value for the
11616 corresponding actual subtype. The value of this attribute is of type
11617 @code{System.Aux_DEC.Type_Class}, which has the following definition:
11618
11619 @example
11620 type Type_Class is
11621 (Type_Class_Enumeration,
11622 Type_Class_Integer,
11623 Type_Class_Fixed_Point,
11624 Type_Class_Floating_Point,
11625 Type_Class_Array,
11626 Type_Class_Record,
11627 Type_Class_Access,
11628 Type_Class_Task,
11629 Type_Class_Address);
11630 @end example
11631
11632 Protected types yield the value @code{Type_Class_Task}, which thus
11633 applies to all concurrent types. This attribute is designed to
11634 be compatible with the DEC Ada 83 attribute of the same name.
11635
11636 @node Attribute Type_Key,Attribute TypeCode,Attribute Type_Class,Implementation Defined Attributes
11637 @anchor{gnat_rm/implementation_defined_attributes attribute-type-key}@anchor{1a9}
11638 @section Attribute Type_Key
11639
11640
11641 @geindex Type_Key
11642
11643 The @code{Type_Key} attribute is applicable to a type or subtype and
11644 yields a value of type Standard.String containing encoded information
11645 about the type or subtype. This provides improved compatibility with
11646 other implementations that support this attribute.
11647
11648 @node Attribute TypeCode,Attribute Unconstrained_Array,Attribute Type_Key,Implementation Defined Attributes
11649 @anchor{gnat_rm/implementation_defined_attributes attribute-typecode}@anchor{1aa}
11650 @section Attribute TypeCode
11651
11652
11653 @geindex TypeCode
11654
11655 This internal attribute is used for the generation of remote subprogram
11656 stubs in the context of the Distributed Systems Annex.
11657
11658 @node Attribute Unconstrained_Array,Attribute Universal_Literal_String,Attribute TypeCode,Implementation Defined Attributes
11659 @anchor{gnat_rm/implementation_defined_attributes attribute-unconstrained-array}@anchor{1ab}
11660 @section Attribute Unconstrained_Array
11661
11662
11663 @geindex Unconstrained_Array
11664
11665 The @code{Unconstrained_Array} attribute can be used with a prefix that
11666 denotes any type or subtype. It is a static attribute that yields
11667 @code{True} if the prefix designates an unconstrained array,
11668 and @code{False} otherwise. In a generic instance, the result is
11669 still static, and yields the result of applying this test to the
11670 generic actual.
11671
11672 @node Attribute Universal_Literal_String,Attribute Unrestricted_Access,Attribute Unconstrained_Array,Implementation Defined Attributes
11673 @anchor{gnat_rm/implementation_defined_attributes attribute-universal-literal-string}@anchor{1ac}
11674 @section Attribute Universal_Literal_String
11675
11676
11677 @geindex Named numbers
11678 @geindex representation of
11679
11680 @geindex Universal_Literal_String
11681
11682 The prefix of @code{Universal_Literal_String} must be a named
11683 number. The static result is the string consisting of the characters of
11684 the number as defined in the original source. This allows the user
11685 program to access the actual text of named numbers without intermediate
11686 conversions and without the need to enclose the strings in quotes (which
11687 would preclude their use as numbers).
11688
11689 For example, the following program prints the first 50 digits of pi:
11690
11691 @example
11692 with Text_IO; use Text_IO;
11693 with Ada.Numerics;
11694 procedure Pi is
11695 begin
11696 Put (Ada.Numerics.Pi'Universal_Literal_String);
11697 end;
11698 @end example
11699
11700 @node Attribute Unrestricted_Access,Attribute Update,Attribute Universal_Literal_String,Implementation Defined Attributes
11701 @anchor{gnat_rm/implementation_defined_attributes attribute-unrestricted-access}@anchor{1ad}
11702 @section Attribute Unrestricted_Access
11703
11704
11705 @geindex Access
11706 @geindex unrestricted
11707
11708 @geindex Unrestricted_Access
11709
11710 The @code{Unrestricted_Access} attribute is similar to @code{Access}
11711 except that all accessibility and aliased view checks are omitted. This
11712 is a user-beware attribute.
11713
11714 For objects, it is similar to @code{Address}, for which it is a
11715 desirable replacement where the value desired is an access type.
11716 In other words, its effect is similar to first applying the
11717 @code{Address} attribute and then doing an unchecked conversion to a
11718 desired access type.
11719
11720 For subprograms, @code{P'Unrestricted_Access} may be used where
11721 @code{P'Access} would be illegal, to construct a value of a
11722 less-nested named access type that designates a more-nested
11723 subprogram. This value may be used in indirect calls, so long as the
11724 more-nested subprogram still exists; once the subprogram containing it
11725 has returned, such calls are erroneous. For example:
11726
11727 @example
11728 package body P is
11729
11730 type Less_Nested is not null access procedure;
11731 Global : Less_Nested;
11732
11733 procedure P1 is
11734 begin
11735 Global.all;
11736 end P1;
11737
11738 procedure P2 is
11739 Local_Var : Integer;
11740
11741 procedure More_Nested is
11742 begin
11743 ... Local_Var ...
11744 end More_Nested;
11745 begin
11746 Global := More_Nested'Unrestricted_Access;
11747 P1;
11748 end P2;
11749
11750 end P;
11751 @end example
11752
11753 When P1 is called from P2, the call via Global is OK, but if P1 were
11754 called after P2 returns, it would be an erroneous use of a dangling
11755 pointer.
11756
11757 For objects, it is possible to use @code{Unrestricted_Access} for any
11758 type. However, if the result is of an access-to-unconstrained array
11759 subtype, then the resulting pointer has the same scope as the context
11760 of the attribute, and must not be returned to some enclosing scope.
11761 For instance, if a function uses @code{Unrestricted_Access} to create
11762 an access-to-unconstrained-array and returns that value to the caller,
11763 the result will involve dangling pointers. In addition, it is only
11764 valid to create pointers to unconstrained arrays using this attribute
11765 if the pointer has the normal default 'fat' representation where a
11766 pointer has two components, one points to the array and one points to
11767 the bounds. If a size clause is used to force 'thin' representation
11768 for a pointer to unconstrained where there is only space for a single
11769 pointer, then the resulting pointer is not usable.
11770
11771 In the simple case where a direct use of Unrestricted_Access attempts
11772 to make a thin pointer for a non-aliased object, the compiler will
11773 reject the use as illegal, as shown in the following example:
11774
11775 @example
11776 with System; use System;
11777 procedure SliceUA2 is
11778 type A is access all String;
11779 for A'Size use Standard'Address_Size;
11780
11781 procedure P (Arg : A) is
11782 begin
11783 null;
11784 end P;
11785
11786 X : String := "hello world!";
11787 X2 : aliased String := "hello world!";
11788
11789 AV : A := X'Unrestricted_Access; -- ERROR
11790 |
11791 >>> illegal use of Unrestricted_Access attribute
11792 >>> attempt to generate thin pointer to unaliased object
11793
11794 begin
11795 P (X'Unrestricted_Access); -- ERROR
11796 |
11797 >>> illegal use of Unrestricted_Access attribute
11798 >>> attempt to generate thin pointer to unaliased object
11799
11800 P (X(7 .. 12)'Unrestricted_Access); -- ERROR
11801 |
11802 >>> illegal use of Unrestricted_Access attribute
11803 >>> attempt to generate thin pointer to unaliased object
11804
11805 P (X2'Unrestricted_Access); -- OK
11806 end;
11807 @end example
11808
11809 but other cases cannot be detected by the compiler, and are
11810 considered to be erroneous. Consider the following example:
11811
11812 @example
11813 with System; use System;
11814 with System; use System;
11815 procedure SliceUA is
11816 type AF is access all String;
11817
11818 type A is access all String;
11819 for A'Size use Standard'Address_Size;
11820
11821 procedure P (Arg : A) is
11822 begin
11823 if Arg'Length /= 6 then
11824 raise Program_Error;
11825 end if;
11826 end P;
11827
11828 X : String := "hello world!";
11829 Y : AF := X (7 .. 12)'Unrestricted_Access;
11830
11831 begin
11832 P (A (Y));
11833 end;
11834 @end example
11835
11836 A normal unconstrained array value
11837 or a constrained array object marked as aliased has the bounds in memory
11838 just before the array, so a thin pointer can retrieve both the data and
11839 the bounds. But in this case, the non-aliased object @code{X} does not have the
11840 bounds before the string. If the size clause for type @code{A}
11841 were not present, then the pointer
11842 would be a fat pointer, where one component is a pointer to the bounds,
11843 and all would be well. But with the size clause present, the conversion from
11844 fat pointer to thin pointer in the call loses the bounds, and so this
11845 is erroneous, and the program likely raises a @code{Program_Error} exception.
11846
11847 In general, it is advisable to completely
11848 avoid mixing the use of thin pointers and the use of
11849 @code{Unrestricted_Access} where the designated type is an
11850 unconstrained array. The use of thin pointers should be restricted to
11851 cases of porting legacy code that implicitly assumes the size of pointers,
11852 and such code should not in any case be using this attribute.
11853
11854 Another erroneous situation arises if the attribute is
11855 applied to a constant. The resulting pointer can be used to access the
11856 constant, but the effect of trying to modify a constant in this manner
11857 is not well-defined. Consider this example:
11858
11859 @example
11860 P : constant Integer := 4;
11861 type R is access all Integer;
11862 RV : R := P'Unrestricted_Access;
11863 ..
11864 RV.all := 3;
11865 @end example
11866
11867 Here we attempt to modify the constant P from 4 to 3, but the compiler may
11868 or may not notice this attempt, and subsequent references to P may yield
11869 either the value 3 or the value 4 or the assignment may blow up if the
11870 compiler decides to put P in read-only memory. One particular case where
11871 @code{Unrestricted_Access} can be used in this way is to modify the
11872 value of an @code{in} parameter:
11873
11874 @example
11875 procedure K (S : in String) is
11876 type R is access all Character;
11877 RV : R := S (3)'Unrestricted_Access;
11878 begin
11879 RV.all := 'a';
11880 end;
11881 @end example
11882
11883 In general this is a risky approach. It may appear to "work" but such uses of
11884 @code{Unrestricted_Access} are potentially non-portable, even from one version
11885 of GNAT to another, so are best avoided if possible.
11886
11887 @node Attribute Update,Attribute Valid_Scalars,Attribute Unrestricted_Access,Implementation Defined Attributes
11888 @anchor{gnat_rm/implementation_defined_attributes attribute-update}@anchor{1ae}
11889 @section Attribute Update
11890
11891
11892 @geindex Update
11893
11894 The @code{Update} attribute creates a copy of an array or record value
11895 with one or more modified components. The syntax is:
11896
11897 @example
11898 PREFIX'Update ( RECORD_COMPONENT_ASSOCIATION_LIST )
11899 PREFIX'Update ( ARRAY_COMPONENT_ASSOCIATION @{, ARRAY_COMPONENT_ASSOCIATION @} )
11900 PREFIX'Update ( MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION
11901 @{, MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION @} )
11902
11903 MULTIDIMENSIONAL_ARRAY_COMPONENT_ASSOCIATION ::= INDEX_EXPRESSION_LIST_LIST => EXPRESSION
11904 INDEX_EXPRESSION_LIST_LIST ::= INDEX_EXPRESSION_LIST @{| INDEX_EXPRESSION_LIST @}
11905 INDEX_EXPRESSION_LIST ::= ( EXPRESSION @{, EXPRESSION @} )
11906 @end example
11907
11908 where @code{PREFIX} is the name of an array or record object, the
11909 association list in parentheses does not contain an @code{others}
11910 choice and the box symbol @code{<>} may not appear in any
11911 expression. The effect is to yield a copy of the array or record value
11912 which is unchanged apart from the components mentioned in the
11913 association list, which are changed to the indicated value. The
11914 original value of the array or record value is not affected. For
11915 example:
11916
11917 @example
11918 type Arr is Array (1 .. 5) of Integer;
11919 ...
11920 Avar1 : Arr := (1,2,3,4,5);
11921 Avar2 : Arr := Avar1'Update (2 => 10, 3 .. 4 => 20);
11922 @end example
11923
11924 yields a value for @code{Avar2} of 1,10,20,20,5 with @code{Avar1}
11925 begin unmodified. Similarly:
11926
11927 @example
11928 type Rec is A, B, C : Integer;
11929 ...
11930 Rvar1 : Rec := (A => 1, B => 2, C => 3);
11931 Rvar2 : Rec := Rvar1'Update (B => 20);
11932 @end example
11933
11934 yields a value for @code{Rvar2} of (A => 1, B => 20, C => 3),
11935 with @code{Rvar1} being unmodifed.
11936 Note that the value of the attribute reference is computed
11937 completely before it is used. This means that if you write:
11938
11939 @example
11940 Avar1 := Avar1'Update (1 => 10, 2 => Function_Call);
11941 @end example
11942
11943 then the value of @code{Avar1} is not modified if @code{Function_Call}
11944 raises an exception, unlike the effect of a series of direct assignments
11945 to elements of @code{Avar1}. In general this requires that
11946 two extra complete copies of the object are required, which should be
11947 kept in mind when considering efficiency.
11948
11949 The @code{Update} attribute cannot be applied to prefixes of a limited
11950 type, and cannot reference discriminants in the case of a record type.
11951 The accessibility level of an Update attribute result object is defined
11952 as for an aggregate.
11953
11954 In the record case, no component can be mentioned more than once. In
11955 the array case, two overlapping ranges can appear in the association list,
11956 in which case the modifications are processed left to right.
11957
11958 Multi-dimensional arrays can be modified, as shown by this example:
11959
11960 @example
11961 A : array (1 .. 10, 1 .. 10) of Integer;
11962 ..
11963 A := A'Update ((1, 2) => 20, (3, 4) => 30);
11964 @end example
11965
11966 which changes element (1,2) to 20 and (3,4) to 30.
11967
11968 @node Attribute Valid_Scalars,Attribute VADS_Size,Attribute Update,Implementation Defined Attributes
11969 @anchor{gnat_rm/implementation_defined_attributes attribute-valid-scalars}@anchor{1af}
11970 @section Attribute Valid_Scalars
11971
11972
11973 @geindex Valid_Scalars
11974
11975 The @code{'Valid_Scalars} attribute is intended to make it easier to check the
11976 validity of scalar subcomponents of composite objects. The attribute is defined
11977 for any prefix @code{P} which denotes an object. Prefix @code{P} can be any type
11978 except for tagged private or @code{Unchecked_Union} types. The value of the
11979 attribute is of type @code{Boolean}.
11980
11981 @code{P'Valid_Scalars} yields @code{True} if and only if the evaluation of
11982 @code{C'Valid} yields @code{True} for every scalar subcomponent @code{C} of @code{P}, or if
11983 @code{P} has no scalar subcomponents. Attribute @code{'Valid_Scalars} is equivalent
11984 to attribute @code{'Valid} for scalar types.
11985
11986 It is not specified in what order the subcomponents are checked, nor whether
11987 any more are checked after any one of them is determined to be invalid. If the
11988 prefix @code{P} is of a class-wide type @code{T'Class} (where @code{T} is the associated
11989 specific type), or if the prefix @code{P} is of a specific tagged type @code{T}, then
11990 only the subcomponents of @code{T} are checked; in other words, components of
11991 extensions of @code{T} are not checked even if @code{T'Class (P)'Tag /= T'Tag}.
11992
11993 The compiler will issue a warning if it can be determined at compile time that
11994 the prefix of the attribute has no scalar subcomponents.
11995
11996 Note: @code{Valid_Scalars} can generate a lot of code, especially in the case of
11997 a large variant record. If the attribute is called in many places in the same
11998 program applied to objects of the same type, it can reduce program size to
11999 write a function with a single use of the attribute, and then call that
12000 function from multiple places.
12001
12002 @node Attribute VADS_Size,Attribute Value_Size,Attribute Valid_Scalars,Implementation Defined Attributes
12003 @anchor{gnat_rm/implementation_defined_attributes attribute-vads-size}@anchor{1b0}
12004 @section Attribute VADS_Size
12005
12006
12007 @geindex Size
12008 @geindex VADS compatibility
12009
12010 @geindex VADS_Size
12011
12012 The @code{'VADS_Size} attribute is intended to make it easier to port
12013 legacy code which relies on the semantics of @code{'Size} as implemented
12014 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
12015 same semantic interpretation. In particular, @code{'VADS_Size} applied
12016 to a predefined or other primitive type with no Size clause yields the
12017 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
12018 typical machines). In addition @code{'VADS_Size} applied to an object
12019 gives the result that would be obtained by applying the attribute to
12020 the corresponding type.
12021
12022 @node Attribute Value_Size,Attribute Wchar_T_Size,Attribute VADS_Size,Implementation Defined Attributes
12023 @anchor{gnat_rm/implementation_defined_attributes id6}@anchor{1b1}@anchor{gnat_rm/implementation_defined_attributes attribute-value-size}@anchor{163}
12024 @section Attribute Value_Size
12025
12026
12027 @geindex Size
12028 @geindex setting for not-first subtype
12029
12030 @geindex Value_Size
12031
12032 @code{type'Value_Size} is the number of bits required to represent
12033 a value of the given subtype. It is the same as @code{type'Size},
12034 but, unlike @code{Size}, may be set for non-first subtypes.
12035
12036 @node Attribute Wchar_T_Size,Attribute Word_Size,Attribute Value_Size,Implementation Defined Attributes
12037 @anchor{gnat_rm/implementation_defined_attributes attribute-wchar-t-size}@anchor{1b2}
12038 @section Attribute Wchar_T_Size
12039
12040
12041 @geindex Wchar_T_Size
12042
12043 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
12044 prefix) provides the size in bits of the C @code{wchar_t} type
12045 primarily for constructing the definition of this type in
12046 package @code{Interfaces.C}. The result is a static constant.
12047
12048 @node Attribute Word_Size,,Attribute Wchar_T_Size,Implementation Defined Attributes
12049 @anchor{gnat_rm/implementation_defined_attributes attribute-word-size}@anchor{1b3}
12050 @section Attribute Word_Size
12051
12052
12053 @geindex Word_Size
12054
12055 @code{Standard'Word_Size} (@code{Standard} is the only permissible
12056 prefix) provides the value @code{System.Word_Size}. The result is
12057 a static constant.
12058
12059 @node Standard and Implementation Defined Restrictions,Implementation Advice,Implementation Defined Attributes,Top
12060 @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{1b4}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id1}@anchor{1b5}
12061 @chapter Standard and Implementation Defined Restrictions
12062
12063
12064 All Ada Reference Manual-defined Restriction identifiers are implemented:
12065
12066
12067 @itemize *
12068
12069 @item
12070 language-defined restrictions (see 13.12.1)
12071
12072 @item
12073 tasking restrictions (see D.7)
12074
12075 @item
12076 high integrity restrictions (see H.4)
12077 @end itemize
12078
12079 GNAT implements additional restriction identifiers. All restrictions, whether
12080 language defined or GNAT-specific, are listed in the following.
12081
12082 @menu
12083 * Partition-Wide Restrictions::
12084 * Program Unit Level Restrictions::
12085
12086 @end menu
12087
12088 @node Partition-Wide Restrictions,Program Unit Level Restrictions,,Standard and Implementation Defined Restrictions
12089 @anchor{gnat_rm/standard_and_implementation_defined_restrictions partition-wide-restrictions}@anchor{1b6}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id2}@anchor{1b7}
12090 @section Partition-Wide Restrictions
12091
12092
12093 There are two separate lists of restriction identifiers. The first
12094 set requires consistency throughout a partition (in other words, if the
12095 restriction identifier is used for any compilation unit in the partition,
12096 then all compilation units in the partition must obey the restriction).
12097
12098 @menu
12099 * Immediate_Reclamation::
12100 * Max_Asynchronous_Select_Nesting::
12101 * Max_Entry_Queue_Length::
12102 * Max_Protected_Entries::
12103 * Max_Select_Alternatives::
12104 * Max_Storage_At_Blocking::
12105 * Max_Task_Entries::
12106 * Max_Tasks::
12107 * No_Abort_Statements::
12108 * No_Access_Parameter_Allocators::
12109 * No_Access_Subprograms::
12110 * No_Allocators::
12111 * No_Anonymous_Allocators::
12112 * No_Asynchronous_Control::
12113 * No_Calendar::
12114 * No_Coextensions::
12115 * No_Default_Initialization::
12116 * No_Delay::
12117 * No_Dependence::
12118 * No_Direct_Boolean_Operators::
12119 * No_Dispatch::
12120 * No_Dispatching_Calls::
12121 * No_Dynamic_Attachment::
12122 * No_Dynamic_Priorities::
12123 * No_Entry_Calls_In_Elaboration_Code::
12124 * No_Enumeration_Maps::
12125 * No_Exception_Handlers::
12126 * No_Exception_Propagation::
12127 * No_Exception_Registration::
12128 * No_Exceptions::
12129 * No_Finalization::
12130 * No_Fixed_Point::
12131 * No_Floating_Point::
12132 * No_Implicit_Conditionals::
12133 * No_Implicit_Dynamic_Code::
12134 * No_Implicit_Heap_Allocations::
12135 * No_Implicit_Protected_Object_Allocations::
12136 * No_Implicit_Task_Allocations::
12137 * No_Initialize_Scalars::
12138 * No_IO::
12139 * No_Local_Allocators::
12140 * No_Local_Protected_Objects::
12141 * No_Local_Timing_Events::
12142 * No_Long_Long_Integers::
12143 * No_Multiple_Elaboration::
12144 * No_Nested_Finalization::
12145 * No_Protected_Type_Allocators::
12146 * No_Protected_Types::
12147 * No_Recursion::
12148 * No_Reentrancy::
12149 * No_Relative_Delay::
12150 * No_Requeue_Statements::
12151 * No_Secondary_Stack::
12152 * No_Select_Statements::
12153 * No_Specific_Termination_Handlers::
12154 * No_Specification_of_Aspect::
12155 * No_Standard_Allocators_After_Elaboration::
12156 * No_Standard_Storage_Pools::
12157 * No_Stream_Optimizations::
12158 * No_Streams::
12159 * No_Task_Allocators::
12160 * No_Task_At_Interrupt_Priority::
12161 * No_Task_Attributes_Package::
12162 * No_Task_Hierarchy::
12163 * No_Task_Termination::
12164 * No_Tasking::
12165 * No_Terminate_Alternatives::
12166 * No_Unchecked_Access::
12167 * No_Unchecked_Conversion::
12168 * No_Unchecked_Deallocation::
12169 * No_Use_Of_Entity::
12170 * Pure_Barriers::
12171 * Simple_Barriers::
12172 * Static_Priorities::
12173 * Static_Storage_Size::
12174
12175 @end menu
12176
12177 @node Immediate_Reclamation,Max_Asynchronous_Select_Nesting,,Partition-Wide Restrictions
12178 @anchor{gnat_rm/standard_and_implementation_defined_restrictions immediate-reclamation}@anchor{1b8}
12179 @subsection Immediate_Reclamation
12180
12181
12182 @geindex Immediate_Reclamation
12183
12184 [RM H.4] This restriction ensures that, except for storage occupied by
12185 objects created by allocators and not deallocated via unchecked
12186 deallocation, any storage reserved at run time for an object is
12187 immediately reclaimed when the object no longer exists.
12188
12189 @node Max_Asynchronous_Select_Nesting,Max_Entry_Queue_Length,Immediate_Reclamation,Partition-Wide Restrictions
12190 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-asynchronous-select-nesting}@anchor{1b9}
12191 @subsection Max_Asynchronous_Select_Nesting
12192
12193
12194 @geindex Max_Asynchronous_Select_Nesting
12195
12196 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
12197 selects. Violations of this restriction with a value of zero are
12198 detected at compile time. Violations of this restriction with values
12199 other than zero cause Storage_Error to be raised.
12200
12201 @node Max_Entry_Queue_Length,Max_Protected_Entries,Max_Asynchronous_Select_Nesting,Partition-Wide Restrictions
12202 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-entry-queue-length}@anchor{1ba}
12203 @subsection Max_Entry_Queue_Length
12204
12205
12206 @geindex Max_Entry_Queue_Length
12207
12208 [RM D.7] This restriction is a declaration that any protected entry compiled in
12209 the scope of the restriction has at most the specified number of
12210 tasks waiting on the entry at any one time, and so no queue is required.
12211 Note that this restriction is checked at run time. Violation of this
12212 restriction results in the raising of Program_Error exception at the point of
12213 the call.
12214
12215 @geindex Max_Entry_Queue_Depth
12216
12217 The restriction @code{Max_Entry_Queue_Depth} is recognized as a
12218 synonym for @code{Max_Entry_Queue_Length}. This is retained for historical
12219 compatibility purposes (and a warning will be generated for its use if
12220 warnings on obsolescent features are activated).
12221
12222 @node Max_Protected_Entries,Max_Select_Alternatives,Max_Entry_Queue_Length,Partition-Wide Restrictions
12223 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-protected-entries}@anchor{1bb}
12224 @subsection Max_Protected_Entries
12225
12226
12227 @geindex Max_Protected_Entries
12228
12229 [RM D.7] Specifies the maximum number of entries per protected type. The
12230 bounds of every entry family of a protected unit shall be static, or shall be
12231 defined by a discriminant of a subtype whose corresponding bound is static.
12232
12233 @node Max_Select_Alternatives,Max_Storage_At_Blocking,Max_Protected_Entries,Partition-Wide Restrictions
12234 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-select-alternatives}@anchor{1bc}
12235 @subsection Max_Select_Alternatives
12236
12237
12238 @geindex Max_Select_Alternatives
12239
12240 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
12241
12242 @node Max_Storage_At_Blocking,Max_Task_Entries,Max_Select_Alternatives,Partition-Wide Restrictions
12243 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-storage-at-blocking}@anchor{1bd}
12244 @subsection Max_Storage_At_Blocking
12245
12246
12247 @geindex Max_Storage_At_Blocking
12248
12249 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
12250 Storage_Size that can be retained by a blocked task. A violation of this
12251 restriction causes Storage_Error to be raised.
12252
12253 @node Max_Task_Entries,Max_Tasks,Max_Storage_At_Blocking,Partition-Wide Restrictions
12254 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-task-entries}@anchor{1be}
12255 @subsection Max_Task_Entries
12256
12257
12258 @geindex Max_Task_Entries
12259
12260 [RM D.7] Specifies the maximum number of entries
12261 per task. The bounds of every entry family
12262 of a task unit shall be static, or shall be
12263 defined by a discriminant of a subtype whose
12264 corresponding bound is static.
12265
12266 @node Max_Tasks,No_Abort_Statements,Max_Task_Entries,Partition-Wide Restrictions
12267 @anchor{gnat_rm/standard_and_implementation_defined_restrictions max-tasks}@anchor{1bf}
12268 @subsection Max_Tasks
12269
12270
12271 @geindex Max_Tasks
12272
12273 [RM D.7] Specifies the maximum number of task that may be created, not
12274 counting the creation of the environment task. Violations of this
12275 restriction with a value of zero are detected at compile
12276 time. Violations of this restriction with values other than zero cause
12277 Storage_Error to be raised.
12278
12279 @node No_Abort_Statements,No_Access_Parameter_Allocators,Max_Tasks,Partition-Wide Restrictions
12280 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-abort-statements}@anchor{1c0}
12281 @subsection No_Abort_Statements
12282
12283
12284 @geindex No_Abort_Statements
12285
12286 [RM D.7] There are no abort_statements, and there are
12287 no calls to Task_Identification.Abort_Task.
12288
12289 @node No_Access_Parameter_Allocators,No_Access_Subprograms,No_Abort_Statements,Partition-Wide Restrictions
12290 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-parameter-allocators}@anchor{1c1}
12291 @subsection No_Access_Parameter_Allocators
12292
12293
12294 @geindex No_Access_Parameter_Allocators
12295
12296 [RM H.4] This restriction ensures at compile time that there are no
12297 occurrences of an allocator as the actual parameter to an access
12298 parameter.
12299
12300 @node No_Access_Subprograms,No_Allocators,No_Access_Parameter_Allocators,Partition-Wide Restrictions
12301 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-access-subprograms}@anchor{1c2}
12302 @subsection No_Access_Subprograms
12303
12304
12305 @geindex No_Access_Subprograms
12306
12307 [RM H.4] This restriction ensures at compile time that there are no
12308 declarations of access-to-subprogram types.
12309
12310 @node No_Allocators,No_Anonymous_Allocators,No_Access_Subprograms,Partition-Wide Restrictions
12311 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-allocators}@anchor{1c3}
12312 @subsection No_Allocators
12313
12314
12315 @geindex No_Allocators
12316
12317 [RM H.4] This restriction ensures at compile time that there are no
12318 occurrences of an allocator.
12319
12320 @node No_Anonymous_Allocators,No_Asynchronous_Control,No_Allocators,Partition-Wide Restrictions
12321 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-anonymous-allocators}@anchor{1c4}
12322 @subsection No_Anonymous_Allocators
12323
12324
12325 @geindex No_Anonymous_Allocators
12326
12327 [RM H.4] This restriction ensures at compile time that there are no
12328 occurrences of an allocator of anonymous access type.
12329
12330 @node No_Asynchronous_Control,No_Calendar,No_Anonymous_Allocators,Partition-Wide Restrictions
12331 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-asynchronous-control}@anchor{1c5}
12332 @subsection No_Asynchronous_Control
12333
12334
12335 @geindex No_Asynchronous_Control
12336
12337 [RM J.13] This restriction ensures at compile time that there are no semantic
12338 dependences on the predefined package Asynchronous_Task_Control.
12339
12340 @node No_Calendar,No_Coextensions,No_Asynchronous_Control,Partition-Wide Restrictions
12341 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-calendar}@anchor{1c6}
12342 @subsection No_Calendar
12343
12344
12345 @geindex No_Calendar
12346
12347 [GNAT] This restriction ensures at compile time that there are no semantic
12348 dependences on package Calendar.
12349
12350 @node No_Coextensions,No_Default_Initialization,No_Calendar,Partition-Wide Restrictions
12351 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-coextensions}@anchor{1c7}
12352 @subsection No_Coextensions
12353
12354
12355 @geindex No_Coextensions
12356
12357 [RM H.4] This restriction ensures at compile time that there are no
12358 coextensions. See 3.10.2.
12359
12360 @node No_Default_Initialization,No_Delay,No_Coextensions,Partition-Wide Restrictions
12361 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-default-initialization}@anchor{1c8}
12362 @subsection No_Default_Initialization
12363
12364
12365 @geindex No_Default_Initialization
12366
12367 [GNAT] This restriction prohibits any instance of default initialization
12368 of variables. The binder implements a consistency rule which prevents
12369 any unit compiled without the restriction from with'ing a unit with the
12370 restriction (this allows the generation of initialization procedures to
12371 be skipped, since you can be sure that no call is ever generated to an
12372 initialization procedure in a unit with the restriction active). If used
12373 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
12374 is to prohibit all cases of variables declared without a specific
12375 initializer (including the case of OUT scalar parameters).
12376
12377 @node No_Delay,No_Dependence,No_Default_Initialization,Partition-Wide Restrictions
12378 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-delay}@anchor{1c9}
12379 @subsection No_Delay
12380
12381
12382 @geindex No_Delay
12383
12384 [RM H.4] This restriction ensures at compile time that there are no
12385 delay statements and no semantic dependences on package Calendar.
12386
12387 @node No_Dependence,No_Direct_Boolean_Operators,No_Delay,Partition-Wide Restrictions
12388 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dependence}@anchor{1ca}
12389 @subsection No_Dependence
12390
12391
12392 @geindex No_Dependence
12393
12394 [RM 13.12.1] This restriction ensures at compile time that there are no
12395 dependences on a library unit.
12396
12397 @node No_Direct_Boolean_Operators,No_Dispatch,No_Dependence,Partition-Wide Restrictions
12398 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-direct-boolean-operators}@anchor{1cb}
12399 @subsection No_Direct_Boolean_Operators
12400
12401
12402 @geindex No_Direct_Boolean_Operators
12403
12404 [GNAT] This restriction ensures that no logical operators (and/or/xor)
12405 are used on operands of type Boolean (or any type derived from Boolean).
12406 This is intended for use in safety critical programs where the certification
12407 protocol requires the use of short-circuit (and then, or else) forms for all
12408 composite boolean operations.
12409
12410 @node No_Dispatch,No_Dispatching_Calls,No_Direct_Boolean_Operators,Partition-Wide Restrictions
12411 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatch}@anchor{1cc}
12412 @subsection No_Dispatch
12413
12414
12415 @geindex No_Dispatch
12416
12417 [RM H.4] This restriction ensures at compile time that there are no
12418 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
12419
12420 @node No_Dispatching_Calls,No_Dynamic_Attachment,No_Dispatch,Partition-Wide Restrictions
12421 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dispatching-calls}@anchor{1cd}
12422 @subsection No_Dispatching_Calls
12423
12424
12425 @geindex No_Dispatching_Calls
12426
12427 [GNAT] This restriction ensures at compile time that the code generated by the
12428 compiler involves no dispatching calls. The use of this restriction allows the
12429 safe use of record extensions, classwide membership tests and other classwide
12430 features not involving implicit dispatching. This restriction ensures that
12431 the code contains no indirect calls through a dispatching mechanism. Note that
12432 this includes internally-generated calls created by the compiler, for example
12433 in the implementation of class-wide objects assignments. The
12434 membership test is allowed in the presence of this restriction, because its
12435 implementation requires no dispatching.
12436 This restriction is comparable to the official Ada restriction
12437 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
12438 all classwide constructs that do not imply dispatching.
12439 The following example indicates constructs that violate this restriction.
12440
12441 @example
12442 package Pkg is
12443 type T is tagged record
12444 Data : Natural;
12445 end record;
12446 procedure P (X : T);
12447
12448 type DT is new T with record
12449 More_Data : Natural;
12450 end record;
12451 procedure Q (X : DT);
12452 end Pkg;
12453
12454 with Pkg; use Pkg;
12455 procedure Example is
12456 procedure Test (O : T'Class) is
12457 N : Natural := O'Size;-- Error: Dispatching call
12458 C : T'Class := O; -- Error: implicit Dispatching Call
12459 begin
12460 if O in DT'Class then -- OK : Membership test
12461 Q (DT (O)); -- OK : Type conversion plus direct call
12462 else
12463 P (O); -- Error: Dispatching call
12464 end if;
12465 end Test;
12466
12467 Obj : DT;
12468 begin
12469 P (Obj); -- OK : Direct call
12470 P (T (Obj)); -- OK : Type conversion plus direct call
12471 P (T'Class (Obj)); -- Error: Dispatching call
12472
12473 Test (Obj); -- OK : Type conversion
12474
12475 if Obj in T'Class then -- OK : Membership test
12476 null;
12477 end if;
12478 end Example;
12479 @end example
12480
12481 @node No_Dynamic_Attachment,No_Dynamic_Priorities,No_Dispatching_Calls,Partition-Wide Restrictions
12482 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-attachment}@anchor{1ce}
12483 @subsection No_Dynamic_Attachment
12484
12485
12486 @geindex No_Dynamic_Attachment
12487
12488 [RM D.7] This restriction ensures that there is no call to any of the
12489 operations defined in package Ada.Interrupts
12490 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
12491 Detach_Handler, and Reference).
12492
12493 @geindex No_Dynamic_Interrupts
12494
12495 The restriction @code{No_Dynamic_Interrupts} is recognized as a
12496 synonym for @code{No_Dynamic_Attachment}. This is retained for historical
12497 compatibility purposes (and a warning will be generated for its use if
12498 warnings on obsolescent features are activated).
12499
12500 @node No_Dynamic_Priorities,No_Entry_Calls_In_Elaboration_Code,No_Dynamic_Attachment,Partition-Wide Restrictions
12501 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-priorities}@anchor{1cf}
12502 @subsection No_Dynamic_Priorities
12503
12504
12505 @geindex No_Dynamic_Priorities
12506
12507 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
12508
12509 @node No_Entry_Calls_In_Elaboration_Code,No_Enumeration_Maps,No_Dynamic_Priorities,Partition-Wide Restrictions
12510 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-calls-in-elaboration-code}@anchor{1d0}
12511 @subsection No_Entry_Calls_In_Elaboration_Code
12512
12513
12514 @geindex No_Entry_Calls_In_Elaboration_Code
12515
12516 [GNAT] This restriction ensures at compile time that no task or protected entry
12517 calls are made during elaboration code. As a result of the use of this
12518 restriction, the compiler can assume that no code past an accept statement
12519 in a task can be executed at elaboration time.
12520
12521 @node No_Enumeration_Maps,No_Exception_Handlers,No_Entry_Calls_In_Elaboration_Code,Partition-Wide Restrictions
12522 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-enumeration-maps}@anchor{1d1}
12523 @subsection No_Enumeration_Maps
12524
12525
12526 @geindex No_Enumeration_Maps
12527
12528 [GNAT] This restriction ensures at compile time that no operations requiring
12529 enumeration maps are used (that is Image and Value attributes applied
12530 to enumeration types).
12531
12532 @node No_Exception_Handlers,No_Exception_Propagation,No_Enumeration_Maps,Partition-Wide Restrictions
12533 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-handlers}@anchor{1d2}
12534 @subsection No_Exception_Handlers
12535
12536
12537 @geindex No_Exception_Handlers
12538
12539 [GNAT] This restriction ensures at compile time that there are no explicit
12540 exception handlers. It also indicates that no exception propagation will
12541 be provided. In this mode, exceptions may be raised but will result in
12542 an immediate call to the last chance handler, a routine that the user
12543 must define with the following profile:
12544
12545 @example
12546 procedure Last_Chance_Handler
12547 (Source_Location : System.Address; Line : Integer);
12548 pragma Export (C, Last_Chance_Handler,
12549 "__gnat_last_chance_handler");
12550 @end example
12551
12552 The parameter is a C null-terminated string representing a message to be
12553 associated with the exception (typically the source location of the raise
12554 statement generated by the compiler). The Line parameter when nonzero
12555 represents the line number in the source program where the raise occurs.
12556
12557 @node No_Exception_Propagation,No_Exception_Registration,No_Exception_Handlers,Partition-Wide Restrictions
12558 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-propagation}@anchor{1d3}
12559 @subsection No_Exception_Propagation
12560
12561
12562 @geindex No_Exception_Propagation
12563
12564 [GNAT] This restriction guarantees that exceptions are never propagated
12565 to an outer subprogram scope. The only case in which an exception may
12566 be raised is when the handler is statically in the same subprogram, so
12567 that the effect of a raise is essentially like a goto statement. Any
12568 other raise statement (implicit or explicit) will be considered
12569 unhandled. Exception handlers are allowed, but may not contain an
12570 exception occurrence identifier (exception choice). In addition, use of
12571 the package GNAT.Current_Exception is not permitted, and reraise
12572 statements (raise with no operand) are not permitted.
12573
12574 @node No_Exception_Registration,No_Exceptions,No_Exception_Propagation,Partition-Wide Restrictions
12575 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exception-registration}@anchor{1d4}
12576 @subsection No_Exception_Registration
12577
12578
12579 @geindex No_Exception_Registration
12580
12581 [GNAT] This restriction ensures at compile time that no stream operations for
12582 types Exception_Id or Exception_Occurrence are used. This also makes it
12583 impossible to pass exceptions to or from a partition with this restriction
12584 in a distributed environment. If this restriction is active, the generated
12585 code is simplified by omitting the otherwise-required global registration
12586 of exceptions when they are declared.
12587
12588 @node No_Exceptions,No_Finalization,No_Exception_Registration,Partition-Wide Restrictions
12589 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-exceptions}@anchor{1d5}
12590 @subsection No_Exceptions
12591
12592
12593 @geindex No_Exceptions
12594
12595 [RM H.4] This restriction ensures at compile time that there are no
12596 raise statements and no exception handlers and also suppresses the
12597 generation of language-defined run-time checks.
12598
12599 @node No_Finalization,No_Fixed_Point,No_Exceptions,Partition-Wide Restrictions
12600 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-finalization}@anchor{1d6}
12601 @subsection No_Finalization
12602
12603
12604 @geindex No_Finalization
12605
12606 [GNAT] This restriction disables the language features described in
12607 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
12608 performed by the compiler to support these features. The following types
12609 are no longer considered controlled when this restriction is in effect:
12610
12611
12612 @itemize *
12613
12614 @item
12615 @code{Ada.Finalization.Controlled}
12616
12617 @item
12618 @code{Ada.Finalization.Limited_Controlled}
12619
12620 @item
12621 Derivations from @code{Controlled} or @code{Limited_Controlled}
12622
12623 @item
12624 Class-wide types
12625
12626 @item
12627 Protected types
12628
12629 @item
12630 Task types
12631
12632 @item
12633 Array and record types with controlled components
12634 @end itemize
12635
12636 The compiler no longer generates code to initialize, finalize or adjust an
12637 object or a nested component, either declared on the stack or on the heap. The
12638 deallocation of a controlled object no longer finalizes its contents.
12639
12640 @node No_Fixed_Point,No_Floating_Point,No_Finalization,Partition-Wide Restrictions
12641 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-fixed-point}@anchor{1d7}
12642 @subsection No_Fixed_Point
12643
12644
12645 @geindex No_Fixed_Point
12646
12647 [RM H.4] This restriction ensures at compile time that there are no
12648 occurrences of fixed point types and operations.
12649
12650 @node No_Floating_Point,No_Implicit_Conditionals,No_Fixed_Point,Partition-Wide Restrictions
12651 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-floating-point}@anchor{1d8}
12652 @subsection No_Floating_Point
12653
12654
12655 @geindex No_Floating_Point
12656
12657 [RM H.4] This restriction ensures at compile time that there are no
12658 occurrences of floating point types and operations.
12659
12660 @node No_Implicit_Conditionals,No_Implicit_Dynamic_Code,No_Floating_Point,Partition-Wide Restrictions
12661 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-conditionals}@anchor{1d9}
12662 @subsection No_Implicit_Conditionals
12663
12664
12665 @geindex No_Implicit_Conditionals
12666
12667 [GNAT] This restriction ensures that the generated code does not contain any
12668 implicit conditionals, either by modifying the generated code where possible,
12669 or by rejecting any construct that would otherwise generate an implicit
12670 conditional. Note that this check does not include run time constraint
12671 checks, which on some targets may generate implicit conditionals as
12672 well. To control the latter, constraint checks can be suppressed in the
12673 normal manner. Constructs generating implicit conditionals include comparisons
12674 of composite objects and the Max/Min attributes.
12675
12676 @node No_Implicit_Dynamic_Code,No_Implicit_Heap_Allocations,No_Implicit_Conditionals,Partition-Wide Restrictions
12677 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-dynamic-code}@anchor{1da}
12678 @subsection No_Implicit_Dynamic_Code
12679
12680
12681 @geindex No_Implicit_Dynamic_Code
12682
12683 @geindex trampoline
12684
12685 [GNAT] This restriction prevents the compiler from building 'trampolines'.
12686 This is a structure that is built on the stack and contains dynamic
12687 code to be executed at run time. On some targets, a trampoline is
12688 built for the following features: @code{Access},
12689 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
12690 nested task bodies; primitive operations of nested tagged types.
12691 Trampolines do not work on machines that prevent execution of stack
12692 data. For example, on windows systems, enabling DEP (data execution
12693 protection) will cause trampolines to raise an exception.
12694 Trampolines are also quite slow at run time.
12695
12696 On many targets, trampolines have been largely eliminated. Look at the
12697 version of system.ads for your target --- if it has
12698 Always_Compatible_Rep equal to False, then trampolines are largely
12699 eliminated. In particular, a trampoline is built for the following
12700 features: @code{Address} of a nested subprogram;
12701 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
12702 but only if pragma Favor_Top_Level applies, or the access type has a
12703 foreign-language convention; primitive operations of nested tagged
12704 types.
12705
12706 @node No_Implicit_Heap_Allocations,No_Implicit_Protected_Object_Allocations,No_Implicit_Dynamic_Code,Partition-Wide Restrictions
12707 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-heap-allocations}@anchor{1db}
12708 @subsection No_Implicit_Heap_Allocations
12709
12710
12711 @geindex No_Implicit_Heap_Allocations
12712
12713 [RM D.7] No constructs are allowed to cause implicit heap allocation.
12714
12715 @node No_Implicit_Protected_Object_Allocations,No_Implicit_Task_Allocations,No_Implicit_Heap_Allocations,Partition-Wide Restrictions
12716 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-protected-object-allocations}@anchor{1dc}
12717 @subsection No_Implicit_Protected_Object_Allocations
12718
12719
12720 @geindex No_Implicit_Protected_Object_Allocations
12721
12722 [GNAT] No constructs are allowed to cause implicit heap allocation of a
12723 protected object.
12724
12725 @node No_Implicit_Task_Allocations,No_Initialize_Scalars,No_Implicit_Protected_Object_Allocations,Partition-Wide Restrictions
12726 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-task-allocations}@anchor{1dd}
12727 @subsection No_Implicit_Task_Allocations
12728
12729
12730 @geindex No_Implicit_Task_Allocations
12731
12732 [GNAT] No constructs are allowed to cause implicit heap allocation of a task.
12733
12734 @node No_Initialize_Scalars,No_IO,No_Implicit_Task_Allocations,Partition-Wide Restrictions
12735 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-initialize-scalars}@anchor{1de}
12736 @subsection No_Initialize_Scalars
12737
12738
12739 @geindex No_Initialize_Scalars
12740
12741 [GNAT] This restriction ensures that no unit in the partition is compiled with
12742 pragma Initialize_Scalars. This allows the generation of more efficient
12743 code, and in particular eliminates dummy null initialization routines that
12744 are otherwise generated for some record and array types.
12745
12746 @node No_IO,No_Local_Allocators,No_Initialize_Scalars,Partition-Wide Restrictions
12747 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-io}@anchor{1df}
12748 @subsection No_IO
12749
12750
12751 @geindex No_IO
12752
12753 [RM H.4] This restriction ensures at compile time that there are no
12754 dependences on any of the library units Sequential_IO, Direct_IO,
12755 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
12756
12757 @node No_Local_Allocators,No_Local_Protected_Objects,No_IO,Partition-Wide Restrictions
12758 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-allocators}@anchor{1e0}
12759 @subsection No_Local_Allocators
12760
12761
12762 @geindex No_Local_Allocators
12763
12764 [RM H.4] This restriction ensures at compile time that there are no
12765 occurrences of an allocator in subprograms, generic subprograms, tasks,
12766 and entry bodies.
12767
12768 @node No_Local_Protected_Objects,No_Local_Timing_Events,No_Local_Allocators,Partition-Wide Restrictions
12769 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-protected-objects}@anchor{1e1}
12770 @subsection No_Local_Protected_Objects
12771
12772
12773 @geindex No_Local_Protected_Objects
12774
12775 [RM D.7] This restriction ensures at compile time that protected objects are
12776 only declared at the library level.
12777
12778 @node No_Local_Timing_Events,No_Long_Long_Integers,No_Local_Protected_Objects,Partition-Wide Restrictions
12779 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-local-timing-events}@anchor{1e2}
12780 @subsection No_Local_Timing_Events
12781
12782
12783 @geindex No_Local_Timing_Events
12784
12785 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
12786 declared at the library level.
12787
12788 @node No_Long_Long_Integers,No_Multiple_Elaboration,No_Local_Timing_Events,Partition-Wide Restrictions
12789 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-long-long-integers}@anchor{1e3}
12790 @subsection No_Long_Long_Integers
12791
12792
12793 @geindex No_Long_Long_Integers
12794
12795 [GNAT] This partition-wide restriction forbids any explicit reference to
12796 type Standard.Long_Long_Integer, and also forbids declaring range types whose
12797 implicit base type is Long_Long_Integer, and modular types whose size exceeds
12798 Long_Integer'Size.
12799
12800 @node No_Multiple_Elaboration,No_Nested_Finalization,No_Long_Long_Integers,Partition-Wide Restrictions
12801 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-multiple-elaboration}@anchor{1e4}
12802 @subsection No_Multiple_Elaboration
12803
12804
12805 @geindex No_Multiple_Elaboration
12806
12807 [GNAT] When this restriction is active and the static elaboration model is
12808 used, and -fpreserve-control-flow is not used, the compiler is allowed to
12809 suppress the elaboration counter normally associated with the unit, even if
12810 the unit has elaboration code. This counter is typically used to check for
12811 access before elaboration and to control multiple elaboration attempts. If the
12812 restriction is used, then the situations in which multiple elaboration is
12813 possible, including non-Ada main programs and Stand Alone libraries, are not
12814 permitted and will be diagnosed by the binder.
12815
12816 @node No_Nested_Finalization,No_Protected_Type_Allocators,No_Multiple_Elaboration,Partition-Wide Restrictions
12817 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-nested-finalization}@anchor{1e5}
12818 @subsection No_Nested_Finalization
12819
12820
12821 @geindex No_Nested_Finalization
12822
12823 [RM D.7] All objects requiring finalization are declared at the library level.
12824
12825 @node No_Protected_Type_Allocators,No_Protected_Types,No_Nested_Finalization,Partition-Wide Restrictions
12826 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-type-allocators}@anchor{1e6}
12827 @subsection No_Protected_Type_Allocators
12828
12829
12830 @geindex No_Protected_Type_Allocators
12831
12832 [RM D.7] This restriction ensures at compile time that there are no allocator
12833 expressions that attempt to allocate protected objects.
12834
12835 @node No_Protected_Types,No_Recursion,No_Protected_Type_Allocators,Partition-Wide Restrictions
12836 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-protected-types}@anchor{1e7}
12837 @subsection No_Protected_Types
12838
12839
12840 @geindex No_Protected_Types
12841
12842 [RM H.4] This restriction ensures at compile time that there are no
12843 declarations of protected types or protected objects.
12844
12845 @node No_Recursion,No_Reentrancy,No_Protected_Types,Partition-Wide Restrictions
12846 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-recursion}@anchor{1e8}
12847 @subsection No_Recursion
12848
12849
12850 @geindex No_Recursion
12851
12852 [RM H.4] A program execution is erroneous if a subprogram is invoked as
12853 part of its execution.
12854
12855 @node No_Reentrancy,No_Relative_Delay,No_Recursion,Partition-Wide Restrictions
12856 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-reentrancy}@anchor{1e9}
12857 @subsection No_Reentrancy
12858
12859
12860 @geindex No_Reentrancy
12861
12862 [RM H.4] A program execution is erroneous if a subprogram is executed by
12863 two tasks at the same time.
12864
12865 @node No_Relative_Delay,No_Requeue_Statements,No_Reentrancy,Partition-Wide Restrictions
12866 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-relative-delay}@anchor{1ea}
12867 @subsection No_Relative_Delay
12868
12869
12870 @geindex No_Relative_Delay
12871
12872 [RM D.7] This restriction ensures at compile time that there are no delay
12873 relative statements and prevents expressions such as @code{delay 1.23;} from
12874 appearing in source code.
12875
12876 @node No_Requeue_Statements,No_Secondary_Stack,No_Relative_Delay,Partition-Wide Restrictions
12877 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-requeue-statements}@anchor{1eb}
12878 @subsection No_Requeue_Statements
12879
12880
12881 @geindex No_Requeue_Statements
12882
12883 [RM D.7] This restriction ensures at compile time that no requeue statements
12884 are permitted and prevents keyword @code{requeue} from being used in source
12885 code.
12886
12887 @geindex No_Requeue
12888
12889 The restriction @code{No_Requeue} is recognized as a
12890 synonym for @code{No_Requeue_Statements}. This is retained for historical
12891 compatibility purposes (and a warning will be generated for its use if
12892 warnings on oNobsolescent features are activated).
12893
12894 @node No_Secondary_Stack,No_Select_Statements,No_Requeue_Statements,Partition-Wide Restrictions
12895 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-secondary-stack}@anchor{1ec}
12896 @subsection No_Secondary_Stack
12897
12898
12899 @geindex No_Secondary_Stack
12900
12901 [GNAT] This restriction ensures at compile time that the generated code
12902 does not contain any reference to the secondary stack. The secondary
12903 stack is used to implement functions returning unconstrained objects
12904 (arrays or records) on some targets. Suppresses the allocation of
12905 secondary stacks for tasks (excluding the environment task) at run time.
12906
12907 @node No_Select_Statements,No_Specific_Termination_Handlers,No_Secondary_Stack,Partition-Wide Restrictions
12908 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-select-statements}@anchor{1ed}
12909 @subsection No_Select_Statements
12910
12911
12912 @geindex No_Select_Statements
12913
12914 [RM D.7] This restriction ensures at compile time no select statements of any
12915 kind are permitted, that is the keyword @code{select} may not appear.
12916
12917 @node No_Specific_Termination_Handlers,No_Specification_of_Aspect,No_Select_Statements,Partition-Wide Restrictions
12918 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specific-termination-handlers}@anchor{1ee}
12919 @subsection No_Specific_Termination_Handlers
12920
12921
12922 @geindex No_Specific_Termination_Handlers
12923
12924 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
12925 or to Ada.Task_Termination.Specific_Handler.
12926
12927 @node No_Specification_of_Aspect,No_Standard_Allocators_After_Elaboration,No_Specific_Termination_Handlers,Partition-Wide Restrictions
12928 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-specification-of-aspect}@anchor{1ef}
12929 @subsection No_Specification_of_Aspect
12930
12931
12932 @geindex No_Specification_of_Aspect
12933
12934 [RM 13.12.1] This restriction checks at compile time that no aspect
12935 specification, attribute definition clause, or pragma is given for a
12936 given aspect.
12937
12938 @node No_Standard_Allocators_After_Elaboration,No_Standard_Storage_Pools,No_Specification_of_Aspect,Partition-Wide Restrictions
12939 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-allocators-after-elaboration}@anchor{1f0}
12940 @subsection No_Standard_Allocators_After_Elaboration
12941
12942
12943 @geindex No_Standard_Allocators_After_Elaboration
12944
12945 [RM D.7] Specifies that an allocator using a standard storage pool
12946 should never be evaluated at run time after the elaboration of the
12947 library items of the partition has completed. Otherwise, Storage_Error
12948 is raised.
12949
12950 @node No_Standard_Storage_Pools,No_Stream_Optimizations,No_Standard_Allocators_After_Elaboration,Partition-Wide Restrictions
12951 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-standard-storage-pools}@anchor{1f1}
12952 @subsection No_Standard_Storage_Pools
12953
12954
12955 @geindex No_Standard_Storage_Pools
12956
12957 [GNAT] This restriction ensures at compile time that no access types
12958 use the standard default storage pool. Any access type declared must
12959 have an explicit Storage_Pool attribute defined specifying a
12960 user-defined storage pool.
12961
12962 @node No_Stream_Optimizations,No_Streams,No_Standard_Storage_Pools,Partition-Wide Restrictions
12963 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-stream-optimizations}@anchor{1f2}
12964 @subsection No_Stream_Optimizations
12965
12966
12967 @geindex No_Stream_Optimizations
12968
12969 [GNAT] This restriction affects the performance of stream operations on types
12970 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
12971 compiler uses block reads and writes when manipulating @code{String} objects
12972 due to their superior performance. When this restriction is in effect, the
12973 compiler performs all IO operations on a per-character basis.
12974
12975 @node No_Streams,No_Task_Allocators,No_Stream_Optimizations,Partition-Wide Restrictions
12976 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-streams}@anchor{1f3}
12977 @subsection No_Streams
12978
12979
12980 @geindex No_Streams
12981
12982 [GNAT] This restriction ensures at compile/bind time that there are no
12983 stream objects created and no use of stream attributes.
12984 This restriction does not forbid dependences on the package
12985 @code{Ada.Streams}. So it is permissible to with
12986 @code{Ada.Streams} (or another package that does so itself)
12987 as long as no actual stream objects are created and no
12988 stream attributes are used.
12989
12990 Note that the use of restriction allows optimization of tagged types,
12991 since they do not need to worry about dispatching stream operations.
12992 To take maximum advantage of this space-saving optimization, any
12993 unit declaring a tagged type should be compiled with the restriction,
12994 though this is not required.
12995
12996 @node No_Task_Allocators,No_Task_At_Interrupt_Priority,No_Streams,Partition-Wide Restrictions
12997 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-allocators}@anchor{1f4}
12998 @subsection No_Task_Allocators
12999
13000
13001 @geindex No_Task_Allocators
13002
13003 [RM D.7] There are no allocators for task types
13004 or types containing task subcomponents.
13005
13006 @node No_Task_At_Interrupt_Priority,No_Task_Attributes_Package,No_Task_Allocators,Partition-Wide Restrictions
13007 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-at-interrupt-priority}@anchor{1f5}
13008 @subsection No_Task_At_Interrupt_Priority
13009
13010
13011 @geindex No_Task_At_Interrupt_Priority
13012
13013 [GNAT] This restriction ensures at compile time that there is no
13014 Interrupt_Priority aspect or pragma for a task or a task type. As
13015 a consequence, the tasks are always created with a priority below
13016 that an interrupt priority.
13017
13018 @node No_Task_Attributes_Package,No_Task_Hierarchy,No_Task_At_Interrupt_Priority,Partition-Wide Restrictions
13019 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-attributes-package}@anchor{1f6}
13020 @subsection No_Task_Attributes_Package
13021
13022
13023 @geindex No_Task_Attributes_Package
13024
13025 [GNAT] This restriction ensures at compile time that there are no implicit or
13026 explicit dependencies on the package @code{Ada.Task_Attributes}.
13027
13028 @geindex No_Task_Attributes
13029
13030 The restriction @code{No_Task_Attributes} is recognized as a synonym
13031 for @code{No_Task_Attributes_Package}. This is retained for historical
13032 compatibility purposes (and a warning will be generated for its use if
13033 warnings on obsolescent features are activated).
13034
13035 @node No_Task_Hierarchy,No_Task_Termination,No_Task_Attributes_Package,Partition-Wide Restrictions
13036 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-hierarchy}@anchor{1f7}
13037 @subsection No_Task_Hierarchy
13038
13039
13040 @geindex No_Task_Hierarchy
13041
13042 [RM D.7] All (non-environment) tasks depend
13043 directly on the environment task of the partition.
13044
13045 @node No_Task_Termination,No_Tasking,No_Task_Hierarchy,Partition-Wide Restrictions
13046 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-task-termination}@anchor{1f8}
13047 @subsection No_Task_Termination
13048
13049
13050 @geindex No_Task_Termination
13051
13052 [RM D.7] Tasks that terminate are erroneous.
13053
13054 @node No_Tasking,No_Terminate_Alternatives,No_Task_Termination,Partition-Wide Restrictions
13055 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-tasking}@anchor{1f9}
13056 @subsection No_Tasking
13057
13058
13059 @geindex No_Tasking
13060
13061 [GNAT] This restriction prevents the declaration of tasks or task types
13062 throughout the partition. It is similar in effect to the use of
13063 @code{Max_Tasks => 0} except that violations are caught at compile time
13064 and cause an error message to be output either by the compiler or
13065 binder.
13066
13067 @node No_Terminate_Alternatives,No_Unchecked_Access,No_Tasking,Partition-Wide Restrictions
13068 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-terminate-alternatives}@anchor{1fa}
13069 @subsection No_Terminate_Alternatives
13070
13071
13072 @geindex No_Terminate_Alternatives
13073
13074 [RM D.7] There are no selective accepts with terminate alternatives.
13075
13076 @node No_Unchecked_Access,No_Unchecked_Conversion,No_Terminate_Alternatives,Partition-Wide Restrictions
13077 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-access}@anchor{1fb}
13078 @subsection No_Unchecked_Access
13079
13080
13081 @geindex No_Unchecked_Access
13082
13083 [RM H.4] This restriction ensures at compile time that there are no
13084 occurrences of the Unchecked_Access attribute.
13085
13086 @node No_Unchecked_Conversion,No_Unchecked_Deallocation,No_Unchecked_Access,Partition-Wide Restrictions
13087 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-conversion}@anchor{1fc}
13088 @subsection No_Unchecked_Conversion
13089
13090
13091 @geindex No_Unchecked_Conversion
13092
13093 [RM J.13] This restriction ensures at compile time that there are no semantic
13094 dependences on the predefined generic function Unchecked_Conversion.
13095
13096 @node No_Unchecked_Deallocation,No_Use_Of_Entity,No_Unchecked_Conversion,Partition-Wide Restrictions
13097 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-unchecked-deallocation}@anchor{1fd}
13098 @subsection No_Unchecked_Deallocation
13099
13100
13101 @geindex No_Unchecked_Deallocation
13102
13103 [RM J.13] This restriction ensures at compile time that there are no semantic
13104 dependences on the predefined generic procedure Unchecked_Deallocation.
13105
13106 @node No_Use_Of_Entity,Pure_Barriers,No_Unchecked_Deallocation,Partition-Wide Restrictions
13107 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-use-of-entity}@anchor{1fe}
13108 @subsection No_Use_Of_Entity
13109
13110
13111 @geindex No_Use_Of_Entity
13112
13113 [GNAT] This restriction ensures at compile time that there are no references
13114 to the entity given in the form
13115
13116 @example
13117 No_Use_Of_Entity => Name
13118 @end example
13119
13120 where @code{Name} is the fully qualified entity, for example
13121
13122 @example
13123 No_Use_Of_Entity => Ada.Text_IO.Put_Line
13124 @end example
13125
13126 @node Pure_Barriers,Simple_Barriers,No_Use_Of_Entity,Partition-Wide Restrictions
13127 @anchor{gnat_rm/standard_and_implementation_defined_restrictions pure-barriers}@anchor{1ff}
13128 @subsection Pure_Barriers
13129
13130
13131 @geindex Pure_Barriers
13132
13133 [GNAT] This restriction ensures at compile time that protected entry
13134 barriers are restricted to:
13135
13136
13137 @itemize *
13138
13139 @item
13140 components of the protected object (excluding selection from dereferences),
13141
13142 @item
13143 constant declarations,
13144
13145 @item
13146 named numbers,
13147
13148 @item
13149 enumeration literals,
13150
13151 @item
13152 integer literals,
13153
13154 @item
13155 real literals,
13156
13157 @item
13158 character literals,
13159
13160 @item
13161 implicitly defined comparison operators,
13162
13163 @item
13164 uses of the Standard."not" operator,
13165
13166 @item
13167 short-circuit operator,
13168
13169 @item
13170 the Count attribute
13171 @end itemize
13172
13173 This restriction is a relaxation of the Simple_Barriers restriction,
13174 but still ensures absence of side effects, exceptions, and recursion
13175 during the evaluation of the barriers.
13176
13177 @node Simple_Barriers,Static_Priorities,Pure_Barriers,Partition-Wide Restrictions
13178 @anchor{gnat_rm/standard_and_implementation_defined_restrictions simple-barriers}@anchor{200}
13179 @subsection Simple_Barriers
13180
13181
13182 @geindex Simple_Barriers
13183
13184 [RM D.7] This restriction ensures at compile time that barriers in entry
13185 declarations for protected types are restricted to either static boolean
13186 expressions or references to simple boolean variables defined in the private
13187 part of the protected type. No other form of entry barriers is permitted.
13188
13189 @geindex Boolean_Entry_Barriers
13190
13191 The restriction @code{Boolean_Entry_Barriers} is recognized as a
13192 synonym for @code{Simple_Barriers}. This is retained for historical
13193 compatibility purposes (and a warning will be generated for its use if
13194 warnings on obsolescent features are activated).
13195
13196 @node Static_Priorities,Static_Storage_Size,Simple_Barriers,Partition-Wide Restrictions
13197 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-priorities}@anchor{201}
13198 @subsection Static_Priorities
13199
13200
13201 @geindex Static_Priorities
13202
13203 [GNAT] This restriction ensures at compile time that all priority expressions
13204 are static, and that there are no dependences on the package
13205 @code{Ada.Dynamic_Priorities}.
13206
13207 @node Static_Storage_Size,,Static_Priorities,Partition-Wide Restrictions
13208 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-storage-size}@anchor{202}
13209 @subsection Static_Storage_Size
13210
13211
13212 @geindex Static_Storage_Size
13213
13214 [GNAT] This restriction ensures at compile time that any expression appearing
13215 in a Storage_Size pragma or attribute definition clause is static.
13216
13217 @node Program Unit Level Restrictions,,Partition-Wide Restrictions,Standard and Implementation Defined Restrictions
13218 @anchor{gnat_rm/standard_and_implementation_defined_restrictions program-unit-level-restrictions}@anchor{203}@anchor{gnat_rm/standard_and_implementation_defined_restrictions id3}@anchor{204}
13219 @section Program Unit Level Restrictions
13220
13221
13222 The second set of restriction identifiers
13223 does not require partition-wide consistency.
13224 The restriction may be enforced for a single
13225 compilation unit without any effect on any of the
13226 other compilation units in the partition.
13227
13228 @menu
13229 * No_Elaboration_Code::
13230 * No_Dynamic_Sized_Objects::
13231 * No_Entry_Queue::
13232 * No_Implementation_Aspect_Specifications::
13233 * No_Implementation_Attributes::
13234 * No_Implementation_Identifiers::
13235 * No_Implementation_Pragmas::
13236 * No_Implementation_Restrictions::
13237 * No_Implementation_Units::
13238 * No_Implicit_Aliasing::
13239 * No_Implicit_Loops::
13240 * No_Obsolescent_Features::
13241 * No_Wide_Characters::
13242 * Static_Dispatch_Tables::
13243 * SPARK_05::
13244
13245 @end menu
13246
13247 @node No_Elaboration_Code,No_Dynamic_Sized_Objects,,Program Unit Level Restrictions
13248 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-elaboration-code}@anchor{205}
13249 @subsection No_Elaboration_Code
13250
13251
13252 @geindex No_Elaboration_Code
13253
13254 [GNAT] This restriction ensures at compile time that no elaboration code is
13255 generated. Note that this is not the same condition as is enforced
13256 by pragma @code{Preelaborate}. There are cases in which pragma
13257 @code{Preelaborate} still permits code to be generated (e.g., code
13258 to initialize a large array to all zeroes), and there are cases of units
13259 which do not meet the requirements for pragma @code{Preelaborate},
13260 but for which no elaboration code is generated. Generally, it is
13261 the case that preelaborable units will meet the restrictions, with
13262 the exception of large aggregates initialized with an others_clause,
13263 and exception declarations (which generate calls to a run-time
13264 registry procedure). This restriction is enforced on
13265 a unit by unit basis, it need not be obeyed consistently
13266 throughout a partition.
13267
13268 In the case of aggregates with others, if the aggregate has a dynamic
13269 size, there is no way to eliminate the elaboration code (such dynamic
13270 bounds would be incompatible with @code{Preelaborate} in any case). If
13271 the bounds are static, then use of this restriction actually modifies
13272 the code choice of the compiler to avoid generating a loop, and instead
13273 generate the aggregate statically if possible, no matter how many times
13274 the data for the others clause must be repeatedly generated.
13275
13276 It is not possible to precisely document
13277 the constructs which are compatible with this restriction, since,
13278 unlike most other restrictions, this is not a restriction on the
13279 source code, but a restriction on the generated object code. For
13280 example, if the source contains a declaration:
13281
13282 @example
13283 Val : constant Integer := X;
13284 @end example
13285
13286 where X is not a static constant, it may be possible, depending
13287 on complex optimization circuitry, for the compiler to figure
13288 out the value of X at compile time, in which case this initialization
13289 can be done by the loader, and requires no initialization code. It
13290 is not possible to document the precise conditions under which the
13291 optimizer can figure this out.
13292
13293 Note that this the implementation of this restriction requires full
13294 code generation. If it is used in conjunction with "semantics only"
13295 checking, then some cases of violations may be missed.
13296
13297 When this restriction is active, we are not requesting control-flow
13298 preservation with -fpreserve-control-flow, and the static elaboration model is
13299 used, the compiler is allowed to suppress the elaboration counter normally
13300 associated with the unit. This counter is typically used to check for access
13301 before elaboration and to control multiple elaboration attempts.
13302
13303 @node No_Dynamic_Sized_Objects,No_Entry_Queue,No_Elaboration_Code,Program Unit Level Restrictions
13304 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-dynamic-sized-objects}@anchor{206}
13305 @subsection No_Dynamic_Sized_Objects
13306
13307
13308 @geindex No_Dynamic_Sized_Objects
13309
13310 [GNAT] This restriction disallows certain constructs that might lead to the
13311 creation of dynamic-sized composite objects (or array or discriminated type).
13312 An array subtype indication is illegal if the bounds are not static
13313 or references to discriminants of an enclosing type.
13314 A discriminated subtype indication is illegal if the type has
13315 discriminant-dependent array components or a variant part, and the
13316 discriminants are not static. In addition, array and record aggregates are
13317 illegal in corresponding cases. Note that this restriction does not forbid
13318 access discriminants. It is often a good idea to combine this restriction
13319 with No_Secondary_Stack.
13320
13321 @node No_Entry_Queue,No_Implementation_Aspect_Specifications,No_Dynamic_Sized_Objects,Program Unit Level Restrictions
13322 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-entry-queue}@anchor{207}
13323 @subsection No_Entry_Queue
13324
13325
13326 @geindex No_Entry_Queue
13327
13328 [GNAT] This restriction is a declaration that any protected entry compiled in
13329 the scope of the restriction has at most one task waiting on the entry
13330 at any one time, and so no queue is required. This restriction is not
13331 checked at compile time. A program execution is erroneous if an attempt
13332 is made to queue a second task on such an entry.
13333
13334 @node No_Implementation_Aspect_Specifications,No_Implementation_Attributes,No_Entry_Queue,Program Unit Level Restrictions
13335 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-aspect-specifications}@anchor{208}
13336 @subsection No_Implementation_Aspect_Specifications
13337
13338
13339 @geindex No_Implementation_Aspect_Specifications
13340
13341 [RM 13.12.1] This restriction checks at compile time that no
13342 GNAT-defined aspects are present. With this restriction, the only
13343 aspects that can be used are those defined in the Ada Reference Manual.
13344
13345 @node No_Implementation_Attributes,No_Implementation_Identifiers,No_Implementation_Aspect_Specifications,Program Unit Level Restrictions
13346 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-attributes}@anchor{209}
13347 @subsection No_Implementation_Attributes
13348
13349
13350 @geindex No_Implementation_Attributes
13351
13352 [RM 13.12.1] This restriction checks at compile time that no
13353 GNAT-defined attributes are present. With this restriction, the only
13354 attributes that can be used are those defined in the Ada Reference
13355 Manual.
13356
13357 @node No_Implementation_Identifiers,No_Implementation_Pragmas,No_Implementation_Attributes,Program Unit Level Restrictions
13358 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-identifiers}@anchor{20a}
13359 @subsection No_Implementation_Identifiers
13360
13361
13362 @geindex No_Implementation_Identifiers
13363
13364 [RM 13.12.1] This restriction checks at compile time that no
13365 implementation-defined identifiers (marked with pragma Implementation_Defined)
13366 occur within language-defined packages.
13367
13368 @node No_Implementation_Pragmas,No_Implementation_Restrictions,No_Implementation_Identifiers,Program Unit Level Restrictions
13369 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-pragmas}@anchor{20b}
13370 @subsection No_Implementation_Pragmas
13371
13372
13373 @geindex No_Implementation_Pragmas
13374
13375 [RM 13.12.1] This restriction checks at compile time that no
13376 GNAT-defined pragmas are present. With this restriction, the only
13377 pragmas that can be used are those defined in the Ada Reference Manual.
13378
13379 @node No_Implementation_Restrictions,No_Implementation_Units,No_Implementation_Pragmas,Program Unit Level Restrictions
13380 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-restrictions}@anchor{20c}
13381 @subsection No_Implementation_Restrictions
13382
13383
13384 @geindex No_Implementation_Restrictions
13385
13386 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
13387 identifiers (other than @code{No_Implementation_Restrictions} itself)
13388 are present. With this restriction, the only other restriction identifiers
13389 that can be used are those defined in the Ada Reference Manual.
13390
13391 @node No_Implementation_Units,No_Implicit_Aliasing,No_Implementation_Restrictions,Program Unit Level Restrictions
13392 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implementation-units}@anchor{20d}
13393 @subsection No_Implementation_Units
13394
13395
13396 @geindex No_Implementation_Units
13397
13398 [RM 13.12.1] This restriction checks at compile time that there is no
13399 mention in the context clause of any implementation-defined descendants
13400 of packages Ada, Interfaces, or System.
13401
13402 @node No_Implicit_Aliasing,No_Implicit_Loops,No_Implementation_Units,Program Unit Level Restrictions
13403 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-aliasing}@anchor{20e}
13404 @subsection No_Implicit_Aliasing
13405
13406
13407 @geindex No_Implicit_Aliasing
13408
13409 [GNAT] This restriction, which is not required to be partition-wide consistent,
13410 requires an explicit aliased keyword for an object to which 'Access,
13411 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
13412 the 'Unrestricted_Access attribute for objects. Note: the reason that
13413 Unrestricted_Access is forbidden is that it would require the prefix
13414 to be aliased, and in such cases, it can always be replaced by
13415 the standard attribute Unchecked_Access which is preferable.
13416
13417 @node No_Implicit_Loops,No_Obsolescent_Features,No_Implicit_Aliasing,Program Unit Level Restrictions
13418 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-implicit-loops}@anchor{20f}
13419 @subsection No_Implicit_Loops
13420
13421
13422 @geindex No_Implicit_Loops
13423
13424 [GNAT] This restriction ensures that the generated code of the unit marked
13425 with this restriction does not contain any implicit @code{for} loops, either by
13426 modifying the generated code where possible, or by rejecting any construct
13427 that would otherwise generate an implicit @code{for} loop. If this restriction is
13428 active, it is possible to build large array aggregates with all static
13429 components without generating an intermediate temporary, and without generating
13430 a loop to initialize individual components. Otherwise, a loop is created for
13431 arrays larger than about 5000 scalar components. Note that if this restriction
13432 is set in the spec of a package, it will not apply to its body.
13433
13434 @node No_Obsolescent_Features,No_Wide_Characters,No_Implicit_Loops,Program Unit Level Restrictions
13435 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-obsolescent-features}@anchor{210}
13436 @subsection No_Obsolescent_Features
13437
13438
13439 @geindex No_Obsolescent_Features
13440
13441 [RM 13.12.1] This restriction checks at compile time that no obsolescent
13442 features are used, as defined in Annex J of the Ada Reference Manual.
13443
13444 @node No_Wide_Characters,Static_Dispatch_Tables,No_Obsolescent_Features,Program Unit Level Restrictions
13445 @anchor{gnat_rm/standard_and_implementation_defined_restrictions no-wide-characters}@anchor{211}
13446 @subsection No_Wide_Characters
13447
13448
13449 @geindex No_Wide_Characters
13450
13451 [GNAT] This restriction ensures at compile time that no uses of the types
13452 @code{Wide_Character} or @code{Wide_String} or corresponding wide
13453 wide types
13454 appear, and that no wide or wide wide string or character literals
13455 appear in the program (that is literals representing characters not in
13456 type @code{Character}).
13457
13458 @node Static_Dispatch_Tables,SPARK_05,No_Wide_Characters,Program Unit Level Restrictions
13459 @anchor{gnat_rm/standard_and_implementation_defined_restrictions static-dispatch-tables}@anchor{212}
13460 @subsection Static_Dispatch_Tables
13461
13462
13463 @geindex Static_Dispatch_Tables
13464
13465 [GNAT] This restriction checks at compile time that all the artifacts
13466 associated with dispatch tables can be placed in read-only memory.
13467
13468 @node SPARK_05,,Static_Dispatch_Tables,Program Unit Level Restrictions
13469 @anchor{gnat_rm/standard_and_implementation_defined_restrictions spark-05}@anchor{213}
13470 @subsection SPARK_05
13471
13472
13473 @geindex SPARK_05
13474
13475 [GNAT] This restriction checks at compile time that some constructs forbidden
13476 in SPARK 2005 are not present. Note that SPARK 2005 has been superseded by
13477 SPARK 2014, whose restrictions are checked by the tool GNATprove. To check that
13478 a codebase respects SPARK 2014 restrictions, mark the code with pragma or
13479 aspect @code{SPARK_Mode}, and run the tool GNATprove at Stone assurance level, as
13480 follows:
13481
13482 @example
13483 gnatprove -P project.gpr --mode=stone
13484 @end example
13485
13486 or equivalently:
13487
13488 @example
13489 gnatprove -P project.gpr --mode=check_all
13490 @end example
13491
13492 With restriction @code{SPARK_05}, error messages related to SPARK 2005 restriction
13493 have the form:
13494
13495 @example
13496 violation of restriction "SPARK_05" at <source-location>
13497 <error message>
13498 @end example
13499
13500 @geindex SPARK
13501
13502 The restriction @code{SPARK} is recognized as a synonym for @code{SPARK_05}. This is
13503 retained for historical compatibility purposes (and an unconditional warning
13504 will be generated for its use, advising replacement by @code{SPARK_05}).
13505
13506 This is not a replacement for the semantic checks performed by the
13507 SPARK Examiner tool, as the compiler currently only deals with code,
13508 not SPARK 2005 annotations, and does not guarantee catching all
13509 cases of constructs forbidden by SPARK 2005.
13510
13511 Thus it may well be the case that code which passes the compiler with
13512 the SPARK 2005 restriction is rejected by the SPARK Examiner, e.g. due to
13513 the different visibility rules of the Examiner based on SPARK 2005
13514 @code{inherit} annotations.
13515
13516 This restriction can be useful in providing an initial filter for code
13517 developed using SPARK 2005, or in examining legacy code to see how far
13518 it is from meeting SPARK 2005 restrictions.
13519
13520 The list below summarizes the checks that are performed when this
13521 restriction is in force:
13522
13523
13524 @itemize *
13525
13526 @item
13527 No block statements
13528
13529 @item
13530 No case statements with only an others clause
13531
13532 @item
13533 Exit statements in loops must respect the SPARK 2005 language restrictions
13534
13535 @item
13536 No goto statements
13537
13538 @item
13539 Return can only appear as last statement in function
13540
13541 @item
13542 Function must have return statement
13543
13544 @item
13545 Loop parameter specification must include subtype mark
13546
13547 @item
13548 Prefix of expanded name cannot be a loop statement
13549
13550 @item
13551 Abstract subprogram not allowed
13552
13553 @item
13554 User-defined operators not allowed
13555
13556 @item
13557 Access type parameters not allowed
13558
13559 @item
13560 Default expressions for parameters not allowed
13561
13562 @item
13563 Default expressions for record fields not allowed
13564
13565 @item
13566 No tasking constructs allowed
13567
13568 @item
13569 Label needed at end of subprograms and packages
13570
13571 @item
13572 No mixing of positional and named parameter association
13573
13574 @item
13575 No access types as result type
13576
13577 @item
13578 No unconstrained arrays as result types
13579
13580 @item
13581 No null procedures
13582
13583 @item
13584 Initial and later declarations must be in correct order (declaration can't come after body)
13585
13586 @item
13587 No attributes on private types if full declaration not visible
13588
13589 @item
13590 No package declaration within package specification
13591
13592 @item
13593 No controlled types
13594
13595 @item
13596 No discriminant types
13597
13598 @item
13599 No overloading
13600
13601 @item
13602 Selector name cannot be operator symbol (i.e. operator symbol cannot be prefixed)
13603
13604 @item
13605 Access attribute not allowed
13606
13607 @item
13608 Allocator not allowed
13609
13610 @item
13611 Result of catenation must be String
13612
13613 @item
13614 Operands of catenation must be string literal, static char or another catenation
13615
13616 @item
13617 No conditional expressions
13618
13619 @item
13620 No explicit dereference
13621
13622 @item
13623 Quantified expression not allowed
13624
13625 @item
13626 Slicing not allowed
13627
13628 @item
13629 No exception renaming
13630
13631 @item
13632 No generic renaming
13633
13634 @item
13635 No object renaming
13636
13637 @item
13638 No use clause
13639
13640 @item
13641 Aggregates must be qualified
13642
13643 @item
13644 Nonstatic choice in array aggregates not allowed
13645
13646 @item
13647 The only view conversions which are allowed as in-out parameters are conversions of a tagged type to an ancestor type
13648
13649 @item
13650 No mixing of positional and named association in aggregate, no multi choice
13651
13652 @item
13653 AND, OR and XOR for arrays only allowed when operands have same static bounds
13654
13655 @item
13656 Fixed point operands to * or / must be qualified or converted
13657
13658 @item
13659 Comparison operators not allowed for Booleans or arrays (except strings)
13660
13661 @item
13662 Equality not allowed for arrays with non-matching static bounds (except strings)
13663
13664 @item
13665 Conversion / qualification not allowed for arrays with non-matching static bounds
13666
13667 @item
13668 Subprogram declaration only allowed in package spec (unless followed by import)
13669
13670 @item
13671 Access types not allowed
13672
13673 @item
13674 Incomplete type declaration not allowed
13675
13676 @item
13677 Object and subtype declarations must respect SPARK 2005 restrictions
13678
13679 @item
13680 Digits or delta constraint not allowed
13681
13682 @item
13683 Decimal fixed point type not allowed
13684
13685 @item
13686 Aliasing of objects not allowed
13687
13688 @item
13689 Modular type modulus must be power of 2
13690
13691 @item
13692 Base not allowed on subtype mark
13693
13694 @item
13695 Unary operators not allowed on modular types (except not)
13696
13697 @item
13698 Untagged record cannot be null
13699
13700 @item
13701 No class-wide operations
13702
13703 @item
13704 Initialization expressions must respect SPARK 2005 restrictions
13705
13706 @item
13707 Nonstatic ranges not allowed except in iteration schemes
13708
13709 @item
13710 String subtypes must have lower bound of 1
13711
13712 @item
13713 Subtype of Boolean cannot have constraint
13714
13715 @item
13716 At most one tagged type or extension per package
13717
13718 @item
13719 Interface is not allowed
13720
13721 @item
13722 Character literal cannot be prefixed (selector name cannot be character literal)
13723
13724 @item
13725 Record aggregate cannot contain 'others'
13726
13727 @item
13728 Component association in record aggregate must contain a single choice
13729
13730 @item
13731 Ancestor part cannot be a type mark
13732
13733 @item
13734 Attributes 'Image, 'Width and 'Value not allowed
13735
13736 @item
13737 Functions may not update globals
13738
13739 @item
13740 Subprograms may not contain direct calls to themselves (prevents recursion within unit)
13741
13742 @item
13743 Call to subprogram not allowed in same unit before body has been seen (prevents recursion within unit)
13744 @end itemize
13745
13746 The following restrictions are enforced, but note that they are actually more
13747 strict that the latest SPARK 2005 language definition:
13748
13749
13750 @itemize *
13751
13752 @item
13753 No derived types other than tagged type extensions
13754
13755 @item
13756 Subtype of unconstrained array must have constraint
13757 @end itemize
13758
13759 This list summarises the main SPARK 2005 language rules that are not
13760 currently checked by the SPARK_05 restriction:
13761
13762
13763 @itemize *
13764
13765 @item
13766 SPARK 2005 annotations are treated as comments so are not checked at all
13767
13768 @item
13769 Based real literals not allowed
13770
13771 @item
13772 Objects cannot be initialized at declaration by calls to user-defined functions
13773
13774 @item
13775 Objects cannot be initialized at declaration by assignments from variables
13776
13777 @item
13778 Objects cannot be initialized at declaration by assignments from indexed/selected components
13779
13780 @item
13781 Ranges shall not be null
13782
13783 @item
13784 A fixed point delta expression must be a simple expression
13785
13786 @item
13787 Restrictions on where renaming declarations may be placed
13788
13789 @item
13790 Externals of mode 'out' cannot be referenced
13791
13792 @item
13793 Externals of mode 'in' cannot be updated
13794
13795 @item
13796 Loop with no iteration scheme or exits only allowed as last statement in main program or task
13797
13798 @item
13799 Subprogram cannot have parent unit name
13800
13801 @item
13802 SPARK 2005 inherited subprogram must be prefixed with overriding
13803
13804 @item
13805 External variables (or functions that reference them) may not be passed as actual parameters
13806
13807 @item
13808 Globals must be explicitly mentioned in contract
13809
13810 @item
13811 Deferred constants cannot be completed by pragma Import
13812
13813 @item
13814 Package initialization cannot read/write variables from other packages
13815
13816 @item
13817 Prefix not allowed for entities that are directly visible
13818
13819 @item
13820 Identifier declaration can't override inherited package name
13821
13822 @item
13823 Cannot use Standard or other predefined packages as identifiers
13824
13825 @item
13826 After renaming, cannot use the original name
13827
13828 @item
13829 Subprograms can only be renamed to remove package prefix
13830
13831 @item
13832 Pragma import must be immediately after entity it names
13833
13834 @item
13835 No mutual recursion between multiple units (this can be checked with gnatcheck)
13836 @end itemize
13837
13838 Note that if a unit is compiled in Ada 95 mode with the SPARK 2005 restriction,
13839 violations will be reported for constructs forbidden in SPARK 95,
13840 instead of SPARK 2005.
13841
13842 @node Implementation Advice,Implementation Defined Characteristics,Standard and Implementation Defined Restrictions,Top
13843 @anchor{gnat_rm/implementation_advice doc}@anchor{214}@anchor{gnat_rm/implementation_advice implementation-advice}@anchor{a}@anchor{gnat_rm/implementation_advice id1}@anchor{215}
13844 @chapter Implementation Advice
13845
13846
13847 The main text of the Ada Reference Manual describes the required
13848 behavior of all Ada compilers, and the GNAT compiler conforms to
13849 these requirements.
13850
13851 In addition, there are sections throughout the Ada Reference Manual headed
13852 by the phrase 'Implementation advice'. These sections are not normative,
13853 i.e., they do not specify requirements that all compilers must
13854 follow. Rather they provide advice on generally desirable behavior.
13855 They are not requirements, because they describe behavior that cannot
13856 be provided on all systems, or may be undesirable on some systems.
13857
13858 As far as practical, GNAT follows the implementation advice in
13859 the Ada Reference Manual. Each such RM section corresponds to a section
13860 in this chapter whose title specifies the
13861 RM section number and paragraph number and the subject of
13862 the advice. The contents of each section consists of the RM text within
13863 quotation marks,
13864 followed by the GNAT interpretation of the advice. Most often, this simply says
13865 'followed', which means that GNAT follows the advice. However, in a
13866 number of cases, GNAT deliberately deviates from this advice, in which
13867 case the text describes what GNAT does and why.
13868
13869 @geindex Error detection
13870
13871 @menu
13872 * RM 1.1.3(20); Error Detection: RM 1 1 3 20 Error Detection.
13873 * RM 1.1.3(31); Child Units: RM 1 1 3 31 Child Units.
13874 * RM 1.1.5(12); Bounded Errors: RM 1 1 5 12 Bounded Errors.
13875 * RM 2.8(16); Pragmas: RM 2 8 16 Pragmas.
13876 * RM 2.8(17-19); Pragmas: RM 2 8 17-19 Pragmas.
13877 * RM 3.5.2(5); Alternative Character Sets: RM 3 5 2 5 Alternative Character Sets.
13878 * RM 3.5.4(28); Integer Types: RM 3 5 4 28 Integer Types.
13879 * RM 3.5.4(29); Integer Types: RM 3 5 4 29 Integer Types.
13880 * RM 3.5.5(8); Enumeration Values: RM 3 5 5 8 Enumeration Values.
13881 * RM 3.5.7(17); Float Types: RM 3 5 7 17 Float Types.
13882 * RM 3.6.2(11); Multidimensional Arrays: RM 3 6 2 11 Multidimensional Arrays.
13883 * RM 9.6(30-31); Duration'Small: RM 9 6 30-31 Duration'Small.
13884 * RM 10.2.1(12); Consistent Representation: RM 10 2 1 12 Consistent Representation.
13885 * RM 11.4.1(19); Exception Information: RM 11 4 1 19 Exception Information.
13886 * RM 11.5(28); Suppression of Checks: RM 11 5 28 Suppression of Checks.
13887 * RM 13.1 (21-24); Representation Clauses: RM 13 1 21-24 Representation Clauses.
13888 * RM 13.2(6-8); Packed Types: RM 13 2 6-8 Packed Types.
13889 * RM 13.3(14-19); Address Clauses: RM 13 3 14-19 Address Clauses.
13890 * RM 13.3(29-35); Alignment Clauses: RM 13 3 29-35 Alignment Clauses.
13891 * RM 13.3(42-43); Size Clauses: RM 13 3 42-43 Size Clauses.
13892 * RM 13.3(50-56); Size Clauses: RM 13 3 50-56 Size Clauses.
13893 * RM 13.3(71-73); Component Size Clauses: RM 13 3 71-73 Component Size Clauses.
13894 * RM 13.4(9-10); Enumeration Representation Clauses: RM 13 4 9-10 Enumeration Representation Clauses.
13895 * RM 13.5.1(17-22); Record Representation Clauses: RM 13 5 1 17-22 Record Representation Clauses.
13896 * RM 13.5.2(5); Storage Place Attributes: RM 13 5 2 5 Storage Place Attributes.
13897 * RM 13.5.3(7-8); Bit Ordering: RM 13 5 3 7-8 Bit Ordering.
13898 * RM 13.7(37); Address as Private: RM 13 7 37 Address as Private.
13899 * RM 13.7.1(16); Address Operations: RM 13 7 1 16 Address Operations.
13900 * RM 13.9(14-17); Unchecked Conversion: RM 13 9 14-17 Unchecked Conversion.
13901 * RM 13.11(23-25); Implicit Heap Usage: RM 13 11 23-25 Implicit Heap Usage.
13902 * RM 13.11.2(17); Unchecked Deallocation: RM 13 11 2 17 Unchecked Deallocation.
13903 * RM 13.13.2(1.6); Stream Oriented Attributes: RM 13 13 2 1 6 Stream Oriented Attributes.
13904 * RM A.1(52); Names of Predefined Numeric Types: RM A 1 52 Names of Predefined Numeric Types.
13905 * RM A.3.2(49); Ada.Characters.Handling: RM A 3 2 49 Ada Characters Handling.
13906 * RM A.4.4(106); Bounded-Length String Handling: RM A 4 4 106 Bounded-Length String Handling.
13907 * RM A.5.2(46-47); Random Number Generation: RM A 5 2 46-47 Random Number Generation.
13908 * RM A.10.7(23); Get_Immediate: RM A 10 7 23 Get_Immediate.
13909 * RM B.1(39-41); Pragma Export: RM B 1 39-41 Pragma Export.
13910 * RM B.2(12-13); Package Interfaces: RM B 2 12-13 Package Interfaces.
13911 * RM B.3(63-71); Interfacing with C: RM B 3 63-71 Interfacing with C.
13912 * RM B.4(95-98); Interfacing with COBOL: RM B 4 95-98 Interfacing with COBOL.
13913 * RM B.5(22-26); Interfacing with Fortran: RM B 5 22-26 Interfacing with Fortran.
13914 * RM C.1(3-5); Access to Machine Operations: RM C 1 3-5 Access to Machine Operations.
13915 * RM C.1(10-16); Access to Machine Operations: RM C 1 10-16 Access to Machine Operations.
13916 * RM C.3(28); Interrupt Support: RM C 3 28 Interrupt Support.
13917 * RM C.3.1(20-21); Protected Procedure Handlers: RM C 3 1 20-21 Protected Procedure Handlers.
13918 * RM C.3.2(25); Package Interrupts: RM C 3 2 25 Package Interrupts.
13919 * RM C.4(14); Pre-elaboration Requirements: RM C 4 14 Pre-elaboration Requirements.
13920 * RM C.5(8); Pragma Discard_Names: RM C 5 8 Pragma Discard_Names.
13921 * RM C.7.2(30); The Package Task_Attributes: RM C 7 2 30 The Package Task_Attributes.
13922 * RM D.3(17); Locking Policies: RM D 3 17 Locking Policies.
13923 * RM D.4(16); Entry Queuing Policies: RM D 4 16 Entry Queuing Policies.
13924 * RM D.6(9-10); Preemptive Abort: RM D 6 9-10 Preemptive Abort.
13925 * RM D.7(21); Tasking Restrictions: RM D 7 21 Tasking Restrictions.
13926 * RM D.8(47-49); Monotonic Time: RM D 8 47-49 Monotonic Time.
13927 * RM E.5(28-29); Partition Communication Subsystem: RM E 5 28-29 Partition Communication Subsystem.
13928 * RM F(7); COBOL Support: RM F 7 COBOL Support.
13929 * RM F.1(2); Decimal Radix Support: RM F 1 2 Decimal Radix Support.
13930 * RM G; Numerics: RM G Numerics.
13931 * RM G.1.1(56-58); Complex Types: RM G 1 1 56-58 Complex Types.
13932 * RM G.1.2(49); Complex Elementary Functions: RM G 1 2 49 Complex Elementary Functions.
13933 * RM G.2.4(19); Accuracy Requirements: RM G 2 4 19 Accuracy Requirements.
13934 * RM G.2.6(15); Complex Arithmetic Accuracy: RM G 2 6 15 Complex Arithmetic Accuracy.
13935 * RM H.6(15/2); Pragma Partition_Elaboration_Policy: RM H 6 15/2 Pragma Partition_Elaboration_Policy.
13936
13937 @end menu
13938
13939 @node RM 1 1 3 20 Error Detection,RM 1 1 3 31 Child Units,,Implementation Advice
13940 @anchor{gnat_rm/implementation_advice rm-1-1-3-20-error-detection}@anchor{216}
13941 @section RM 1.1.3(20): Error Detection
13942
13943
13944 @quotation
13945
13946 "If an implementation detects the use of an unsupported Specialized Needs
13947 Annex feature at run time, it should raise @code{Program_Error} if
13948 feasible."
13949 @end quotation
13950
13951 Not relevant. All specialized needs annex features are either supported,
13952 or diagnosed at compile time.
13953
13954 @geindex Child Units
13955
13956 @node RM 1 1 3 31 Child Units,RM 1 1 5 12 Bounded Errors,RM 1 1 3 20 Error Detection,Implementation Advice
13957 @anchor{gnat_rm/implementation_advice rm-1-1-3-31-child-units}@anchor{217}
13958 @section RM 1.1.3(31): Child Units
13959
13960
13961 @quotation
13962
13963 "If an implementation wishes to provide implementation-defined
13964 extensions to the functionality of a language-defined library unit, it
13965 should normally do so by adding children to the library unit."
13966 @end quotation
13967
13968 Followed.
13969
13970 @geindex Bounded errors
13971
13972 @node RM 1 1 5 12 Bounded Errors,RM 2 8 16 Pragmas,RM 1 1 3 31 Child Units,Implementation Advice
13973 @anchor{gnat_rm/implementation_advice rm-1-1-5-12-bounded-errors}@anchor{218}
13974 @section RM 1.1.5(12): Bounded Errors
13975
13976
13977 @quotation
13978
13979 "If an implementation detects a bounded error or erroneous
13980 execution, it should raise @code{Program_Error}."
13981 @end quotation
13982
13983 Followed in all cases in which the implementation detects a bounded
13984 error or erroneous execution. Not all such situations are detected at
13985 runtime.
13986
13987 @geindex Pragmas
13988
13989 @node RM 2 8 16 Pragmas,RM 2 8 17-19 Pragmas,RM 1 1 5 12 Bounded Errors,Implementation Advice
13990 @anchor{gnat_rm/implementation_advice id2}@anchor{219}@anchor{gnat_rm/implementation_advice rm-2-8-16-pragmas}@anchor{21a}
13991 @section RM 2.8(16): Pragmas
13992
13993
13994 @quotation
13995
13996 "Normally, implementation-defined pragmas should have no semantic effect
13997 for error-free programs; that is, if the implementation-defined pragmas
13998 are removed from a working program, the program should still be legal,
13999 and should still have the same semantics."
14000 @end quotation
14001
14002 The following implementation defined pragmas are exceptions to this
14003 rule:
14004
14005
14006 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxx}
14007 @headitem
14008
14009 Pragma
14010
14011 @tab
14012
14013 Explanation
14014
14015 @item
14016
14017 @emph{Abort_Defer}
14018
14019 @tab
14020
14021 Affects semantics
14022
14023 @item
14024
14025 @emph{Ada_83}
14026
14027 @tab
14028
14029 Affects legality
14030
14031 @item
14032
14033 @emph{Assert}
14034
14035 @tab
14036
14037 Affects semantics
14038
14039 @item
14040
14041 @emph{CPP_Class}
14042
14043 @tab
14044
14045 Affects semantics
14046
14047 @item
14048
14049 @emph{CPP_Constructor}
14050
14051 @tab
14052
14053 Affects semantics
14054
14055 @item
14056
14057 @emph{Debug}
14058
14059 @tab
14060
14061 Affects semantics
14062
14063 @item
14064
14065 @emph{Interface_Name}
14066
14067 @tab
14068
14069 Affects semantics
14070
14071 @item
14072
14073 @emph{Machine_Attribute}
14074
14075 @tab
14076
14077 Affects semantics
14078
14079 @item
14080
14081 @emph{Unimplemented_Unit}
14082
14083 @tab
14084
14085 Affects legality
14086
14087 @item
14088
14089 @emph{Unchecked_Union}
14090
14091 @tab
14092
14093 Affects semantics
14094
14095 @end multitable
14096
14097
14098 In each of the above cases, it is essential to the purpose of the pragma
14099 that this advice not be followed. For details see
14100 @ref{7,,Implementation Defined Pragmas}.
14101
14102 @node RM 2 8 17-19 Pragmas,RM 3 5 2 5 Alternative Character Sets,RM 2 8 16 Pragmas,Implementation Advice
14103 @anchor{gnat_rm/implementation_advice rm-2-8-17-19-pragmas}@anchor{21b}
14104 @section RM 2.8(17-19): Pragmas
14105
14106
14107 @quotation
14108
14109 "Normally, an implementation should not define pragmas that can
14110 make an illegal program legal, except as follows:
14111
14112
14113 @itemize *
14114
14115 @item
14116 A pragma used to complete a declaration, such as a pragma @code{Import};
14117
14118 @item
14119 A pragma used to configure the environment by adding, removing, or
14120 replacing @code{library_items}."
14121 @end itemize
14122 @end quotation
14123
14124 See @ref{21a,,RM 2.8(16); Pragmas}.
14125
14126 @geindex Character Sets
14127
14128 @geindex Alternative Character Sets
14129
14130 @node RM 3 5 2 5 Alternative Character Sets,RM 3 5 4 28 Integer Types,RM 2 8 17-19 Pragmas,Implementation Advice
14131 @anchor{gnat_rm/implementation_advice rm-3-5-2-5-alternative-character-sets}@anchor{21c}
14132 @section RM 3.5.2(5): Alternative Character Sets
14133
14134
14135 @quotation
14136
14137 "If an implementation supports a mode with alternative interpretations
14138 for @code{Character} and @code{Wide_Character}, the set of graphic
14139 characters of @code{Character} should nevertheless remain a proper
14140 subset of the set of graphic characters of @code{Wide_Character}. Any
14141 character set 'localizations' should be reflected in the results of
14142 the subprograms defined in the language-defined package
14143 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
14144 an alternative interpretation of @code{Character}, the implementation should
14145 also support a corresponding change in what is a legal
14146 @code{identifier_letter}."
14147 @end quotation
14148
14149 Not all wide character modes follow this advice, in particular the JIS
14150 and IEC modes reflect standard usage in Japan, and in these encoding,
14151 the upper half of the Latin-1 set is not part of the wide-character
14152 subset, since the most significant bit is used for wide character
14153 encoding. However, this only applies to the external forms. Internally
14154 there is no such restriction.
14155
14156 @geindex Integer types
14157
14158 @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
14159 @anchor{gnat_rm/implementation_advice rm-3-5-4-28-integer-types}@anchor{21d}
14160 @section RM 3.5.4(28): Integer Types
14161
14162
14163 @quotation
14164
14165 "An implementation should support @code{Long_Integer} in addition to
14166 @code{Integer} if the target machine supports 32-bit (or longer)
14167 arithmetic. No other named integer subtypes are recommended for package
14168 @code{Standard}. Instead, appropriate named integer subtypes should be
14169 provided in the library package @code{Interfaces} (see B.2)."
14170 @end quotation
14171
14172 @code{Long_Integer} is supported. Other standard integer types are supported
14173 so this advice is not fully followed. These types
14174 are supported for convenient interface to C, and so that all hardware
14175 types of the machine are easily available.
14176
14177 @node RM 3 5 4 29 Integer Types,RM 3 5 5 8 Enumeration Values,RM 3 5 4 28 Integer Types,Implementation Advice
14178 @anchor{gnat_rm/implementation_advice rm-3-5-4-29-integer-types}@anchor{21e}
14179 @section RM 3.5.4(29): Integer Types
14180
14181
14182 @quotation
14183
14184 "An implementation for a two's complement machine should support
14185 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
14186 implementation should support a non-binary modules up to @code{Integer'Last}."
14187 @end quotation
14188
14189 Followed.
14190
14191 @geindex Enumeration values
14192
14193 @node RM 3 5 5 8 Enumeration Values,RM 3 5 7 17 Float Types,RM 3 5 4 29 Integer Types,Implementation Advice
14194 @anchor{gnat_rm/implementation_advice rm-3-5-5-8-enumeration-values}@anchor{21f}
14195 @section RM 3.5.5(8): Enumeration Values
14196
14197
14198 @quotation
14199
14200 "For the evaluation of a call on @code{S'Pos} for an enumeration
14201 subtype, if the value of the operand does not correspond to the internal
14202 code for any enumeration literal of its type (perhaps due to an
14203 un-initialized variable), then the implementation should raise
14204 @code{Program_Error}. This is particularly important for enumeration
14205 types with noncontiguous internal codes specified by an
14206 enumeration_representation_clause."
14207 @end quotation
14208
14209 Followed.
14210
14211 @geindex Float types
14212
14213 @node RM 3 5 7 17 Float Types,RM 3 6 2 11 Multidimensional Arrays,RM 3 5 5 8 Enumeration Values,Implementation Advice
14214 @anchor{gnat_rm/implementation_advice rm-3-5-7-17-float-types}@anchor{220}
14215 @section RM 3.5.7(17): Float Types
14216
14217
14218 @quotation
14219
14220 "An implementation should support @code{Long_Float} in addition to
14221 @code{Float} if the target machine supports 11 or more digits of
14222 precision. No other named floating point subtypes are recommended for
14223 package @code{Standard}. Instead, appropriate named floating point subtypes
14224 should be provided in the library package @code{Interfaces} (see B.2)."
14225 @end quotation
14226
14227 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
14228 former provides improved compatibility with other implementations
14229 supporting this type. The latter corresponds to the highest precision
14230 floating-point type supported by the hardware. On most machines, this
14231 will be the same as @code{Long_Float}, but on some machines, it will
14232 correspond to the IEEE extended form. The notable case is all ia32
14233 (x86) implementations, where @code{Long_Long_Float} corresponds to
14234 the 80-bit extended precision format supported in hardware on this
14235 processor. Note that the 128-bit format on SPARC is not supported,
14236 since this is a software rather than a hardware format.
14237
14238 @geindex Multidimensional arrays
14239
14240 @geindex Arrays
14241 @geindex multidimensional
14242
14243 @node RM 3 6 2 11 Multidimensional Arrays,RM 9 6 30-31 Duration'Small,RM 3 5 7 17 Float Types,Implementation Advice
14244 @anchor{gnat_rm/implementation_advice rm-3-6-2-11-multidimensional-arrays}@anchor{221}
14245 @section RM 3.6.2(11): Multidimensional Arrays
14246
14247
14248 @quotation
14249
14250 "An implementation should normally represent multidimensional arrays in
14251 row-major order, consistent with the notation used for multidimensional
14252 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
14253 (@code{Fortran}, ...) applies to a multidimensional array type, then
14254 column-major order should be used instead (see B.5, @emph{Interfacing with Fortran})."
14255 @end quotation
14256
14257 Followed.
14258
14259 @geindex Duration'Small
14260
14261 @node RM 9 6 30-31 Duration'Small,RM 10 2 1 12 Consistent Representation,RM 3 6 2 11 Multidimensional Arrays,Implementation Advice
14262 @anchor{gnat_rm/implementation_advice rm-9-6-30-31-duration-small}@anchor{222}
14263 @section RM 9.6(30-31): Duration'Small
14264
14265
14266 @quotation
14267
14268 "Whenever possible in an implementation, the value of @code{Duration'Small}
14269 should be no greater than 100 microseconds."
14270 @end quotation
14271
14272 Followed. (@code{Duration'Small} = 10**(-9)).
14273
14274 @quotation
14275
14276 "The time base for @code{delay_relative_statements} should be monotonic;
14277 it need not be the same time base as used for @code{Calendar.Clock}."
14278 @end quotation
14279
14280 Followed.
14281
14282 @node RM 10 2 1 12 Consistent Representation,RM 11 4 1 19 Exception Information,RM 9 6 30-31 Duration'Small,Implementation Advice
14283 @anchor{gnat_rm/implementation_advice rm-10-2-1-12-consistent-representation}@anchor{223}
14284 @section RM 10.2.1(12): Consistent Representation
14285
14286
14287 @quotation
14288
14289 "In an implementation, a type declared in a pre-elaborated package should
14290 have the same representation in every elaboration of a given version of
14291 the package, whether the elaborations occur in distinct executions of
14292 the same program, or in executions of distinct programs or partitions
14293 that include the given version."
14294 @end quotation
14295
14296 Followed, except in the case of tagged types. Tagged types involve
14297 implicit pointers to a local copy of a dispatch table, and these pointers
14298 have representations which thus depend on a particular elaboration of the
14299 package. It is not easy to see how it would be possible to follow this
14300 advice without severely impacting efficiency of execution.
14301
14302 @geindex Exception information
14303
14304 @node RM 11 4 1 19 Exception Information,RM 11 5 28 Suppression of Checks,RM 10 2 1 12 Consistent Representation,Implementation Advice
14305 @anchor{gnat_rm/implementation_advice rm-11-4-1-19-exception-information}@anchor{224}
14306 @section RM 11.4.1(19): Exception Information
14307
14308
14309 @quotation
14310
14311 "@code{Exception_Message} by default and @code{Exception_Information}
14312 should produce information useful for
14313 debugging. @code{Exception_Message} should be short, about one
14314 line. @code{Exception_Information} can be long. @code{Exception_Message}
14315 should not include the
14316 @code{Exception_Name}. @code{Exception_Information} should include both
14317 the @code{Exception_Name} and the @code{Exception_Message}."
14318 @end quotation
14319
14320 Followed. For each exception that doesn't have a specified
14321 @code{Exception_Message}, the compiler generates one containing the location
14322 of the raise statement. This location has the form 'file_name:line', where
14323 file_name is the short file name (without path information) and line is the line
14324 number in the file. Note that in the case of the Zero Cost Exception
14325 mechanism, these messages become redundant with the Exception_Information that
14326 contains a full backtrace of the calling sequence, so they are disabled.
14327 To disable explicitly the generation of the source location message, use the
14328 Pragma @code{Discard_Names}.
14329
14330 @geindex Suppression of checks
14331
14332 @geindex Checks
14333 @geindex suppression of
14334
14335 @node RM 11 5 28 Suppression of Checks,RM 13 1 21-24 Representation Clauses,RM 11 4 1 19 Exception Information,Implementation Advice
14336 @anchor{gnat_rm/implementation_advice rm-11-5-28-suppression-of-checks}@anchor{225}
14337 @section RM 11.5(28): Suppression of Checks
14338
14339
14340 @quotation
14341
14342 "The implementation should minimize the code executed for checks that
14343 have been suppressed."
14344 @end quotation
14345
14346 Followed.
14347
14348 @geindex Representation clauses
14349
14350 @node RM 13 1 21-24 Representation Clauses,RM 13 2 6-8 Packed Types,RM 11 5 28 Suppression of Checks,Implementation Advice
14351 @anchor{gnat_rm/implementation_advice rm-13-1-21-24-representation-clauses}@anchor{226}
14352 @section RM 13.1 (21-24): Representation Clauses
14353
14354
14355 @quotation
14356
14357 "The recommended level of support for all representation items is
14358 qualified as follows:
14359
14360 An implementation need not support representation items containing
14361 nonstatic expressions, except that an implementation should support a
14362 representation item for a given entity if each nonstatic expression in
14363 the representation item is a name that statically denotes a constant
14364 declared before the entity."
14365 @end quotation
14366
14367 Followed. In fact, GNAT goes beyond the recommended level of support
14368 by allowing nonstatic expressions in some representation clauses even
14369 without the need to declare constants initialized with the values of
14370 such expressions.
14371 For example:
14372
14373 @example
14374 X : Integer;
14375 Y : Float;
14376 for Y'Address use X'Address;>>
14377
14378
14379 "An implementation need not support a specification for the `@w{`}Size`@w{`}
14380 for a given composite subtype, nor the size or storage place for an
14381 object (including a component) of a given composite subtype, unless the
14382 constraints on the subtype and its composite subcomponents (if any) are
14383 all static constraints."
14384 @end example
14385
14386 Followed. Size Clauses are not permitted on nonstatic components, as
14387 described above.
14388
14389 @quotation
14390
14391 "An aliased component, or a component whose type is by-reference, should
14392 always be allocated at an addressable location."
14393 @end quotation
14394
14395 Followed.
14396
14397 @geindex Packed types
14398
14399 @node RM 13 2 6-8 Packed Types,RM 13 3 14-19 Address Clauses,RM 13 1 21-24 Representation Clauses,Implementation Advice
14400 @anchor{gnat_rm/implementation_advice rm-13-2-6-8-packed-types}@anchor{227}
14401 @section RM 13.2(6-8): Packed Types
14402
14403
14404 @quotation
14405
14406 "If a type is packed, then the implementation should try to minimize
14407 storage allocated to objects of the type, possibly at the expense of
14408 speed of accessing components, subject to reasonable complexity in
14409 addressing calculations.
14410
14411 The recommended level of support pragma @code{Pack} is:
14412
14413 For a packed record type, the components should be packed as tightly as
14414 possible subject to the Sizes of the component subtypes, and subject to
14415 any @emph{record_representation_clause} that applies to the type; the
14416 implementation may, but need not, reorder components or cross aligned
14417 word boundaries to improve the packing. A component whose @code{Size} is
14418 greater than the word size may be allocated an integral number of words."
14419 @end quotation
14420
14421 Followed. Tight packing of arrays is supported for all component sizes
14422 up to 64-bits. If the array component size is 1 (that is to say, if
14423 the component is a boolean type or an enumeration type with two values)
14424 then values of the type are implicitly initialized to zero. This
14425 happens both for objects of the packed type, and for objects that have a
14426 subcomponent of the packed type.
14427
14428 @quotation
14429
14430 "An implementation should support Address clauses for imported
14431 subprograms."
14432 @end quotation
14433
14434 Followed.
14435
14436 @geindex Address clauses
14437
14438 @node RM 13 3 14-19 Address Clauses,RM 13 3 29-35 Alignment Clauses,RM 13 2 6-8 Packed Types,Implementation Advice
14439 @anchor{gnat_rm/implementation_advice rm-13-3-14-19-address-clauses}@anchor{228}
14440 @section RM 13.3(14-19): Address Clauses
14441
14442
14443 @quotation
14444
14445 "For an array @code{X}, @code{X'Address} should point at the first
14446 component of the array, and not at the array bounds."
14447 @end quotation
14448
14449 Followed.
14450
14451 @quotation
14452
14453 "The recommended level of support for the @code{Address} attribute is:
14454
14455 @code{X'Address} should produce a useful result if @code{X} is an
14456 object that is aliased or of a by-reference type, or is an entity whose
14457 @code{Address} has been specified."
14458 @end quotation
14459
14460 Followed. A valid address will be produced even if none of those
14461 conditions have been met. If necessary, the object is forced into
14462 memory to ensure the address is valid.
14463
14464 @quotation
14465
14466 "An implementation should support @code{Address} clauses for imported
14467 subprograms."
14468 @end quotation
14469
14470 Followed.
14471
14472 @quotation
14473
14474 "Objects (including subcomponents) that are aliased or of a by-reference
14475 type should be allocated on storage element boundaries."
14476 @end quotation
14477
14478 Followed.
14479
14480 @quotation
14481
14482 "If the @code{Address} of an object is specified, or it is imported or exported,
14483 then the implementation should not perform optimizations based on
14484 assumptions of no aliases."
14485 @end quotation
14486
14487 Followed.
14488
14489 @geindex Alignment clauses
14490
14491 @node RM 13 3 29-35 Alignment Clauses,RM 13 3 42-43 Size Clauses,RM 13 3 14-19 Address Clauses,Implementation Advice
14492 @anchor{gnat_rm/implementation_advice rm-13-3-29-35-alignment-clauses}@anchor{229}
14493 @section RM 13.3(29-35): Alignment Clauses
14494
14495
14496 @quotation
14497
14498 "The recommended level of support for the @code{Alignment} attribute for
14499 subtypes is:
14500
14501 An implementation should support specified Alignments that are factors
14502 and multiples of the number of storage elements per word, subject to the
14503 following:"
14504 @end quotation
14505
14506 Followed.
14507
14508 @quotation
14509
14510 "An implementation need not support specified Alignments for
14511 combinations of Sizes and Alignments that cannot be easily
14512 loaded and stored by available machine instructions."
14513 @end quotation
14514
14515 Followed.
14516
14517 @quotation
14518
14519 "An implementation need not support specified Alignments that are
14520 greater than the maximum @code{Alignment} the implementation ever returns by
14521 default."
14522 @end quotation
14523
14524 Followed.
14525
14526 @quotation
14527
14528 "The recommended level of support for the @code{Alignment} attribute for
14529 objects is:
14530
14531 Same as above, for subtypes, but in addition:"
14532 @end quotation
14533
14534 Followed.
14535
14536 @quotation
14537
14538 "For stand-alone library-level objects of statically constrained
14539 subtypes, the implementation should support all alignments
14540 supported by the target linker. For example, page alignment is likely to
14541 be supported for such objects, but not for subtypes."
14542 @end quotation
14543
14544 Followed.
14545
14546 @geindex Size clauses
14547
14548 @node RM 13 3 42-43 Size Clauses,RM 13 3 50-56 Size Clauses,RM 13 3 29-35 Alignment Clauses,Implementation Advice
14549 @anchor{gnat_rm/implementation_advice rm-13-3-42-43-size-clauses}@anchor{22a}
14550 @section RM 13.3(42-43): Size Clauses
14551
14552
14553 @quotation
14554
14555 "The recommended level of support for the @code{Size} attribute of
14556 objects is:
14557
14558 A @code{Size} clause should be supported for an object if the specified
14559 @code{Size} is at least as large as its subtype's @code{Size}, and
14560 corresponds to a size in storage elements that is a multiple of the
14561 object's @code{Alignment} (if the @code{Alignment} is nonzero)."
14562 @end quotation
14563
14564 Followed.
14565
14566 @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
14567 @anchor{gnat_rm/implementation_advice rm-13-3-50-56-size-clauses}@anchor{22b}
14568 @section RM 13.3(50-56): Size Clauses
14569
14570
14571 @quotation
14572
14573 "If the @code{Size} of a subtype is specified, and allows for efficient
14574 independent addressability (see 9.10) on the target architecture, then
14575 the @code{Size} of the following objects of the subtype should equal the
14576 @code{Size} of the subtype:
14577
14578 Aliased objects (including components)."
14579 @end quotation
14580
14581 Followed.
14582
14583 @quotation
14584
14585 "@cite{Size} clause on a composite subtype should not affect the
14586 internal layout of components."
14587 @end quotation
14588
14589 Followed. But note that this can be overridden by use of the implementation
14590 pragma Implicit_Packing in the case of packed arrays.
14591
14592 @quotation
14593
14594 "The recommended level of support for the @code{Size} attribute of subtypes is:
14595
14596 The @code{Size} (if not specified) of a static discrete or fixed point
14597 subtype should be the number of bits needed to represent each value
14598 belonging to the subtype using an unbiased representation, leaving space
14599 for a sign bit only if the subtype contains negative values. If such a
14600 subtype is a first subtype, then an implementation should support a
14601 specified @code{Size} for it that reflects this representation."
14602 @end quotation
14603
14604 Followed.
14605
14606 @quotation
14607
14608 "For a subtype implemented with levels of indirection, the @code{Size}
14609 should include the size of the pointers, but not the size of what they
14610 point at."
14611 @end quotation
14612
14613 Followed.
14614
14615 @geindex Component_Size clauses
14616
14617 @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
14618 @anchor{gnat_rm/implementation_advice rm-13-3-71-73-component-size-clauses}@anchor{22c}
14619 @section RM 13.3(71-73): Component Size Clauses
14620
14621
14622 @quotation
14623
14624 "The recommended level of support for the @code{Component_Size}
14625 attribute is:
14626
14627 An implementation need not support specified @code{Component_Sizes} that are
14628 less than the @code{Size} of the component subtype."
14629 @end quotation
14630
14631 Followed.
14632
14633 @quotation
14634
14635 "An implementation should support specified Component_Sizes that
14636 are factors and multiples of the word size. For such
14637 Component_Sizes, the array should contain no gaps between
14638 components. For other Component_Sizes (if supported), the array
14639 should contain no gaps between components when packing is also
14640 specified; the implementation should forbid this combination in cases
14641 where it cannot support a no-gaps representation."
14642 @end quotation
14643
14644 Followed.
14645
14646 @geindex Enumeration representation clauses
14647
14648 @geindex Representation clauses
14649 @geindex enumeration
14650
14651 @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
14652 @anchor{gnat_rm/implementation_advice rm-13-4-9-10-enumeration-representation-clauses}@anchor{22d}
14653 @section RM 13.4(9-10): Enumeration Representation Clauses
14654
14655
14656 @quotation
14657
14658 "The recommended level of support for enumeration representation clauses
14659 is:
14660
14661 An implementation need not support enumeration representation clauses
14662 for boolean types, but should at minimum support the internal codes in
14663 the range @code{System.Min_Int .. System.Max_Int}."
14664 @end quotation
14665
14666 Followed.
14667
14668 @geindex Record representation clauses
14669
14670 @geindex Representation clauses
14671 @geindex records
14672
14673 @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
14674 @anchor{gnat_rm/implementation_advice rm-13-5-1-17-22-record-representation-clauses}@anchor{22e}
14675 @section RM 13.5.1(17-22): Record Representation Clauses
14676
14677
14678 @quotation
14679
14680 "The recommended level of support for
14681 @emph{record_representation_clause}s is:
14682
14683 An implementation should support storage places that can be extracted
14684 with a load, mask, shift sequence of machine code, and set with a load,
14685 shift, mask, store sequence, given the available machine instructions
14686 and run-time model."
14687 @end quotation
14688
14689 Followed.
14690
14691 @quotation
14692
14693 "A storage place should be supported if its size is equal to the
14694 @code{Size} of the component subtype, and it starts and ends on a
14695 boundary that obeys the @code{Alignment} of the component subtype."
14696 @end quotation
14697
14698 Followed.
14699
14700 @quotation
14701
14702 "If the default bit ordering applies to the declaration of a given type,
14703 then for a component whose subtype's @code{Size} is less than the word
14704 size, any storage place that does not cross an aligned word boundary
14705 should be supported."
14706 @end quotation
14707
14708 Followed.
14709
14710 @quotation
14711
14712 "An implementation may reserve a storage place for the tag field of a
14713 tagged type, and disallow other components from overlapping that place."
14714 @end quotation
14715
14716 Followed. The storage place for the tag field is the beginning of the tagged
14717 record, and its size is Address'Size. GNAT will reject an explicit component
14718 clause for the tag field.
14719
14720 @quotation
14721
14722 "An implementation need not support a @emph{component_clause} for a
14723 component of an extension part if the storage place is not after the
14724 storage places of all components of the parent type, whether or not
14725 those storage places had been specified."
14726 @end quotation
14727
14728 Followed. The above advice on record representation clauses is followed,
14729 and all mentioned features are implemented.
14730
14731 @geindex Storage place attributes
14732
14733 @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
14734 @anchor{gnat_rm/implementation_advice rm-13-5-2-5-storage-place-attributes}@anchor{22f}
14735 @section RM 13.5.2(5): Storage Place Attributes
14736
14737
14738 @quotation
14739
14740 "If a component is represented using some form of pointer (such as an
14741 offset) to the actual data of the component, and this data is contiguous
14742 with the rest of the object, then the storage place attributes should
14743 reflect the place of the actual data, not the pointer. If a component is
14744 allocated discontinuously from the rest of the object, then a warning
14745 should be generated upon reference to one of its storage place
14746 attributes."
14747 @end quotation
14748
14749 Followed. There are no such components in GNAT.
14750
14751 @geindex Bit ordering
14752
14753 @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
14754 @anchor{gnat_rm/implementation_advice rm-13-5-3-7-8-bit-ordering}@anchor{230}
14755 @section RM 13.5.3(7-8): Bit Ordering
14756
14757
14758 @quotation
14759
14760 "The recommended level of support for the non-default bit ordering is:
14761
14762 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
14763 should support the non-default bit ordering in addition to the default
14764 bit ordering."
14765 @end quotation
14766
14767 Followed. Word size does not equal storage size in this implementation.
14768 Thus non-default bit ordering is not supported.
14769
14770 @geindex Address
14771 @geindex as private type
14772
14773 @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
14774 @anchor{gnat_rm/implementation_advice rm-13-7-37-address-as-private}@anchor{231}
14775 @section RM 13.7(37): Address as Private
14776
14777
14778 @quotation
14779
14780 "@cite{Address} should be of a private type."
14781 @end quotation
14782
14783 Followed.
14784
14785 @geindex Operations
14786 @geindex on `@w{`}Address`@w{`}
14787
14788 @geindex Address
14789 @geindex operations of
14790
14791 @node RM 13 7 1 16 Address Operations,RM 13 9 14-17 Unchecked Conversion,RM 13 7 37 Address as Private,Implementation Advice
14792 @anchor{gnat_rm/implementation_advice rm-13-7-1-16-address-operations}@anchor{232}
14793 @section RM 13.7.1(16): Address Operations
14794
14795
14796 @quotation
14797
14798 "Operations in @code{System} and its children should reflect the target
14799 environment semantics as closely as is reasonable. For example, on most
14800 machines, it makes sense for address arithmetic to 'wrap around'.
14801 Operations that do not make sense should raise @code{Program_Error}."
14802 @end quotation
14803
14804 Followed. Address arithmetic is modular arithmetic that wraps around. No
14805 operation raises @code{Program_Error}, since all operations make sense.
14806
14807 @geindex Unchecked conversion
14808
14809 @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
14810 @anchor{gnat_rm/implementation_advice rm-13-9-14-17-unchecked-conversion}@anchor{233}
14811 @section RM 13.9(14-17): Unchecked Conversion
14812
14813
14814 @quotation
14815
14816 "The @code{Size} of an array object should not include its bounds; hence,
14817 the bounds should not be part of the converted data."
14818 @end quotation
14819
14820 Followed.
14821
14822 @quotation
14823
14824 "The implementation should not generate unnecessary run-time checks to
14825 ensure that the representation of @code{S} is a representation of the
14826 target type. It should take advantage of the permission to return by
14827 reference when possible. Restrictions on unchecked conversions should be
14828 avoided unless required by the target environment."
14829 @end quotation
14830
14831 Followed. There are no restrictions on unchecked conversion. A warning is
14832 generated if the source and target types do not have the same size since
14833 the semantics in this case may be target dependent.
14834
14835 @quotation
14836
14837 "The recommended level of support for unchecked conversions is:
14838
14839 Unchecked conversions should be supported and should be reversible in
14840 the cases where this clause defines the result. To enable meaningful use
14841 of unchecked conversion, a contiguous representation should be used for
14842 elementary subtypes, for statically constrained array subtypes whose
14843 component subtype is one of the subtypes described in this paragraph,
14844 and for record subtypes without discriminants whose component subtypes
14845 are described in this paragraph."
14846 @end quotation
14847
14848 Followed.
14849
14850 @geindex Heap usage
14851 @geindex implicit
14852
14853 @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
14854 @anchor{gnat_rm/implementation_advice rm-13-11-23-25-implicit-heap-usage}@anchor{234}
14855 @section RM 13.11(23-25): Implicit Heap Usage
14856
14857
14858 @quotation
14859
14860 "An implementation should document any cases in which it dynamically
14861 allocates heap storage for a purpose other than the evaluation of an
14862 allocator."
14863 @end quotation
14864
14865 Followed, the only other points at which heap storage is dynamically
14866 allocated are as follows:
14867
14868
14869 @itemize *
14870
14871 @item
14872 At initial elaboration time, to allocate dynamically sized global
14873 objects.
14874
14875 @item
14876 To allocate space for a task when a task is created.
14877
14878 @item
14879 To extend the secondary stack dynamically when needed. The secondary
14880 stack is used for returning variable length results.
14881 @end itemize
14882
14883
14884 @quotation
14885
14886 "A default (implementation-provided) storage pool for an
14887 access-to-constant type should not have overhead to support deallocation of
14888 individual objects."
14889 @end quotation
14890
14891 Followed.
14892
14893 @quotation
14894
14895 "A storage pool for an anonymous access type should be created at the
14896 point of an allocator for the type, and be reclaimed when the designated
14897 object becomes inaccessible."
14898 @end quotation
14899
14900 Followed.
14901
14902 @geindex Unchecked deallocation
14903
14904 @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
14905 @anchor{gnat_rm/implementation_advice rm-13-11-2-17-unchecked-deallocation}@anchor{235}
14906 @section RM 13.11.2(17): Unchecked Deallocation
14907
14908
14909 @quotation
14910
14911 "For a standard storage pool, @code{Free} should actually reclaim the
14912 storage."
14913 @end quotation
14914
14915 Followed.
14916
14917 @geindex Stream oriented attributes
14918
14919 @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
14920 @anchor{gnat_rm/implementation_advice rm-13-13-2-1-6-stream-oriented-attributes}@anchor{236}
14921 @section RM 13.13.2(1.6): Stream Oriented Attributes
14922
14923
14924 @quotation
14925
14926 "If not specified, the value of Stream_Size for an elementary type
14927 should be the number of bits that corresponds to the minimum number of
14928 stream elements required by the first subtype of the type, rounded up
14929 to the nearest factor or multiple of the word size that is also a
14930 multiple of the stream element size."
14931 @end quotation
14932
14933 Followed, except that the number of stream elements is a power of 2.
14934 The Stream_Size may be used to override the default choice.
14935
14936 However, such an implementation is based on direct binary
14937 representations and is therefore target- and endianness-dependent. To
14938 address this issue, GNAT also supplies an alternate implementation of
14939 the stream attributes @code{Read} and @code{Write}, which uses the
14940 target-independent XDR standard representation for scalar types.
14941
14942 @geindex XDR representation
14943
14944 @geindex Read attribute
14945
14946 @geindex Write attribute
14947
14948 @geindex Stream oriented attributes
14949
14950 The XDR implementation is provided as an alternative body of the
14951 @code{System.Stream_Attributes} package, in the file
14952 @code{s-stratt-xdr.adb} in the GNAT library.
14953 There is no @code{s-stratt-xdr.ads} file.
14954 In order to install the XDR implementation, do the following:
14955
14956
14957 @itemize *
14958
14959 @item
14960 Replace the default implementation of the
14961 @code{System.Stream_Attributes} package with the XDR implementation.
14962 For example on a Unix platform issue the commands:
14963
14964 @example
14965 $ mv s-stratt.adb s-stratt-default.adb
14966 $ mv s-stratt-xdr.adb s-stratt.adb
14967 @end example
14968
14969 @item
14970 Rebuild the GNAT run-time library as documented in
14971 the @emph{GNAT and Libraries} section of the @cite{GNAT User's Guide}.
14972 @end itemize
14973
14974 @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
14975 @anchor{gnat_rm/implementation_advice rm-a-1-52-names-of-predefined-numeric-types}@anchor{237}
14976 @section RM A.1(52): Names of Predefined Numeric Types
14977
14978
14979 @quotation
14980
14981 "If an implementation provides additional named predefined integer types,
14982 then the names should end with @code{Integer} as in
14983 @code{Long_Integer}. If an implementation provides additional named
14984 predefined floating point types, then the names should end with
14985 @code{Float} as in @code{Long_Float}."
14986 @end quotation
14987
14988 Followed.
14989
14990 @geindex Ada.Characters.Handling
14991
14992 @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
14993 @anchor{gnat_rm/implementation_advice rm-a-3-2-49-ada-characters-handling}@anchor{238}
14994 @section RM A.3.2(49): @code{Ada.Characters.Handling}
14995
14996
14997 @quotation
14998
14999 "If an implementation provides a localized definition of @code{Character}
15000 or @code{Wide_Character}, then the effects of the subprograms in
15001 @code{Characters.Handling} should reflect the localizations.
15002 See also 3.5.2."
15003 @end quotation
15004
15005 Followed. GNAT provides no such localized definitions.
15006
15007 @geindex Bounded-length strings
15008
15009 @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
15010 @anchor{gnat_rm/implementation_advice rm-a-4-4-106-bounded-length-string-handling}@anchor{239}
15011 @section RM A.4.4(106): Bounded-Length String Handling
15012
15013
15014 @quotation
15015
15016 "Bounded string objects should not be implemented by implicit pointers
15017 and dynamic allocation."
15018 @end quotation
15019
15020 Followed. No implicit pointers or dynamic allocation are used.
15021
15022 @geindex Random number generation
15023
15024 @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
15025 @anchor{gnat_rm/implementation_advice rm-a-5-2-46-47-random-number-generation}@anchor{23a}
15026 @section RM A.5.2(46-47): Random Number Generation
15027
15028
15029 @quotation
15030
15031 "Any storage associated with an object of type @code{Generator} should be
15032 reclaimed on exit from the scope of the object."
15033 @end quotation
15034
15035 Followed.
15036
15037 @quotation
15038
15039 "If the generator period is sufficiently long in relation to the number
15040 of distinct initiator values, then each possible value of
15041 @code{Initiator} passed to @code{Reset} should initiate a sequence of
15042 random numbers that does not, in a practical sense, overlap the sequence
15043 initiated by any other value. If this is not possible, then the mapping
15044 between initiator values and generator states should be a rapidly
15045 varying function of the initiator value."
15046 @end quotation
15047
15048 Followed. The generator period is sufficiently long for the first
15049 condition here to hold true.
15050
15051 @geindex Get_Immediate
15052
15053 @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
15054 @anchor{gnat_rm/implementation_advice rm-a-10-7-23-get-immediate}@anchor{23b}
15055 @section RM A.10.7(23): @code{Get_Immediate}
15056
15057
15058 @quotation
15059
15060 "The @code{Get_Immediate} procedures should be implemented with
15061 unbuffered input. For a device such as a keyboard, input should be
15062 available if a key has already been typed, whereas for a disk
15063 file, input should always be available except at end of file. For a file
15064 associated with a keyboard-like device, any line-editing features of the
15065 underlying operating system should be disabled during the execution of
15066 @code{Get_Immediate}."
15067 @end quotation
15068
15069 Followed on all targets except VxWorks. For VxWorks, there is no way to
15070 provide this functionality that does not result in the input buffer being
15071 flushed before the @code{Get_Immediate} call. A special unit
15072 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
15073 this functionality.
15074
15075 @geindex Export
15076
15077 @node RM B 1 39-41 Pragma Export,RM B 2 12-13 Package Interfaces,RM A 10 7 23 Get_Immediate,Implementation Advice
15078 @anchor{gnat_rm/implementation_advice rm-b-1-39-41-pragma-export}@anchor{23c}
15079 @section RM B.1(39-41): Pragma @code{Export}
15080
15081
15082 @quotation
15083
15084 "If an implementation supports pragma @code{Export} to a given language,
15085 then it should also allow the main subprogram to be written in that
15086 language. It should support some mechanism for invoking the elaboration
15087 of the Ada library units included in the system, and for invoking the
15088 finalization of the environment task. On typical systems, the
15089 recommended mechanism is to provide two subprograms whose link names are
15090 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
15091 elaboration code for library units. @code{adafinal} should contain the
15092 finalization code. These subprograms should have no effect the second
15093 and subsequent time they are called."
15094 @end quotation
15095
15096 Followed.
15097
15098 @quotation
15099
15100 "Automatic elaboration of pre-elaborated packages should be
15101 provided when pragma @code{Export} is supported."
15102 @end quotation
15103
15104 Followed when the main program is in Ada. If the main program is in a
15105 foreign language, then
15106 @code{adainit} must be called to elaborate pre-elaborated
15107 packages.
15108
15109 @quotation
15110
15111 "For each supported convention @emph{L} other than @code{Intrinsic}, an
15112 implementation should support @code{Import} and @code{Export} pragmas
15113 for objects of @emph{L}-compatible types and for subprograms, and pragma
15114 @cite{Convention} for @emph{L}-eligible types and for subprograms,
15115 presuming the other language has corresponding features. Pragma
15116 @code{Convention} need not be supported for scalar types."
15117 @end quotation
15118
15119 Followed.
15120
15121 @geindex Package Interfaces
15122
15123 @geindex Interfaces
15124
15125 @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
15126 @anchor{gnat_rm/implementation_advice rm-b-2-12-13-package-interfaces}@anchor{23d}
15127 @section RM B.2(12-13): Package @code{Interfaces}
15128
15129
15130 @quotation
15131
15132 "For each implementation-defined convention identifier, there should be a
15133 child package of package Interfaces with the corresponding name. This
15134 package should contain any declarations that would be useful for
15135 interfacing to the language (implementation) represented by the
15136 convention. Any declarations useful for interfacing to any language on
15137 the given hardware architecture should be provided directly in
15138 @code{Interfaces}."
15139 @end quotation
15140
15141 Followed.
15142
15143 @quotation
15144
15145 "An implementation supporting an interface to C, COBOL, or Fortran should
15146 provide the corresponding package or packages described in the following
15147 clauses."
15148 @end quotation
15149
15150 Followed. GNAT provides all the packages described in this section.
15151
15152 @geindex C
15153 @geindex interfacing with
15154
15155 @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
15156 @anchor{gnat_rm/implementation_advice rm-b-3-63-71-interfacing-with-c}@anchor{23e}
15157 @section RM B.3(63-71): Interfacing with C
15158
15159
15160 @quotation
15161
15162 "An implementation should support the following interface correspondences
15163 between Ada and C."
15164 @end quotation
15165
15166 Followed.
15167
15168 @quotation
15169
15170 "An Ada procedure corresponds to a void-returning C function."
15171 @end quotation
15172
15173 Followed.
15174
15175 @quotation
15176
15177 "An Ada function corresponds to a non-void C function."
15178 @end quotation
15179
15180 Followed.
15181
15182 @quotation
15183
15184 "An Ada @code{in} scalar parameter is passed as a scalar argument to a C
15185 function."
15186 @end quotation
15187
15188 Followed.
15189
15190 @quotation
15191
15192 "An Ada @code{in} parameter of an access-to-object type with designated
15193 type @code{T} is passed as a @code{t*} argument to a C function,
15194 where @code{t} is the C type corresponding to the Ada type @code{T}."
15195 @end quotation
15196
15197 Followed.
15198
15199 @quotation
15200
15201 "An Ada access @code{T} parameter, or an Ada @code{out} or @code{in out}
15202 parameter of an elementary type @code{T}, is passed as a @code{t*}
15203 argument to a C function, where @code{t} is the C type corresponding to
15204 the Ada type @code{T}. In the case of an elementary @code{out} or
15205 @code{in out} parameter, a pointer to a temporary copy is used to
15206 preserve by-copy semantics."
15207 @end quotation
15208
15209 Followed.
15210
15211 @quotation
15212
15213 "An Ada parameter of a record type @code{T}, of any mode, is passed as a
15214 @code{t*} argument to a C function, where @code{t} is the C
15215 structure corresponding to the Ada type @code{T}."
15216 @end quotation
15217
15218 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
15219 pragma, or Convention, or by explicitly specifying the mechanism for a given
15220 call using an extended import or export pragma.
15221
15222 @quotation
15223
15224 "An Ada parameter of an array type with component type @code{T}, of any
15225 mode, is passed as a @code{t*} argument to a C function, where
15226 @code{t} is the C type corresponding to the Ada type @code{T}."
15227 @end quotation
15228
15229 Followed.
15230
15231 @quotation
15232
15233 "An Ada parameter of an access-to-subprogram type is passed as a pointer
15234 to a C function whose prototype corresponds to the designated
15235 subprogram's specification."
15236 @end quotation
15237
15238 Followed.
15239
15240 @geindex COBOL
15241 @geindex interfacing with
15242
15243 @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
15244 @anchor{gnat_rm/implementation_advice rm-b-4-95-98-interfacing-with-cobol}@anchor{23f}
15245 @section RM B.4(95-98): Interfacing with COBOL
15246
15247
15248 @quotation
15249
15250 "An Ada implementation should support the following interface
15251 correspondences between Ada and COBOL."
15252 @end quotation
15253
15254 Followed.
15255
15256 @quotation
15257
15258 "An Ada access @code{T} parameter is passed as a @code{BY REFERENCE} data item of
15259 the COBOL type corresponding to @code{T}."
15260 @end quotation
15261
15262 Followed.
15263
15264 @quotation
15265
15266 "An Ada in scalar parameter is passed as a @code{BY CONTENT} data item of
15267 the corresponding COBOL type."
15268 @end quotation
15269
15270 Followed.
15271
15272 @quotation
15273
15274 "Any other Ada parameter is passed as a @code{BY REFERENCE} data item of the
15275 COBOL type corresponding to the Ada parameter type; for scalars, a local
15276 copy is used if necessary to ensure by-copy semantics."
15277 @end quotation
15278
15279 Followed.
15280
15281 @geindex Fortran
15282 @geindex interfacing with
15283
15284 @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
15285 @anchor{gnat_rm/implementation_advice rm-b-5-22-26-interfacing-with-fortran}@anchor{240}
15286 @section RM B.5(22-26): Interfacing with Fortran
15287
15288
15289 @quotation
15290
15291 "An Ada implementation should support the following interface
15292 correspondences between Ada and Fortran:"
15293 @end quotation
15294
15295 Followed.
15296
15297 @quotation
15298
15299 "An Ada procedure corresponds to a Fortran subroutine."
15300 @end quotation
15301
15302 Followed.
15303
15304 @quotation
15305
15306 "An Ada function corresponds to a Fortran function."
15307 @end quotation
15308
15309 Followed.
15310
15311 @quotation
15312
15313 "An Ada parameter of an elementary, array, or record type @code{T} is
15314 passed as a @code{T} argument to a Fortran procedure, where @code{T} is
15315 the Fortran type corresponding to the Ada type @code{T}, and where the
15316 INTENT attribute of the corresponding dummy argument matches the Ada
15317 formal parameter mode; the Fortran implementation's parameter passing
15318 conventions are used. For elementary types, a local copy is used if
15319 necessary to ensure by-copy semantics."
15320 @end quotation
15321
15322 Followed.
15323
15324 @quotation
15325
15326 "An Ada parameter of an access-to-subprogram type is passed as a
15327 reference to a Fortran procedure whose interface corresponds to the
15328 designated subprogram's specification."
15329 @end quotation
15330
15331 Followed.
15332
15333 @geindex Machine operations
15334
15335 @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
15336 @anchor{gnat_rm/implementation_advice rm-c-1-3-5-access-to-machine-operations}@anchor{241}
15337 @section RM C.1(3-5): Access to Machine Operations
15338
15339
15340 @quotation
15341
15342 "The machine code or intrinsic support should allow access to all
15343 operations normally available to assembly language programmers for the
15344 target environment, including privileged instructions, if any."
15345 @end quotation
15346
15347 Followed.
15348
15349 @quotation
15350
15351 "The interfacing pragmas (see Annex B) should support interface to
15352 assembler; the default assembler should be associated with the
15353 convention identifier @code{Assembler}."
15354 @end quotation
15355
15356 Followed.
15357
15358 @quotation
15359
15360 "If an entity is exported to assembly language, then the implementation
15361 should allocate it at an addressable location, and should ensure that it
15362 is retained by the linking process, even if not otherwise referenced
15363 from the Ada code. The implementation should assume that any call to a
15364 machine code or assembler subprogram is allowed to read or update every
15365 object that is specified as exported."
15366 @end quotation
15367
15368 Followed.
15369
15370 @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
15371 @anchor{gnat_rm/implementation_advice rm-c-1-10-16-access-to-machine-operations}@anchor{242}
15372 @section RM C.1(10-16): Access to Machine Operations
15373
15374
15375 @quotation
15376
15377 "The implementation should ensure that little or no overhead is
15378 associated with calling intrinsic and machine-code subprograms."
15379 @end quotation
15380
15381 Followed for both intrinsics and machine-code subprograms.
15382
15383 @quotation
15384
15385 "It is recommended that intrinsic subprograms be provided for convenient
15386 access to any machine operations that provide special capabilities or
15387 efficiency and that are not otherwise available through the language
15388 constructs."
15389 @end quotation
15390
15391 Followed. A full set of machine operation intrinsic subprograms is provided.
15392
15393 @quotation
15394
15395 "Atomic read-modify-write operations---e.g., test and set, compare and
15396 swap, decrement and test, enqueue/dequeue."
15397 @end quotation
15398
15399 Followed on any target supporting such operations.
15400
15401 @quotation
15402
15403 "Standard numeric functions---e.g.:, sin, log."
15404 @end quotation
15405
15406 Followed on any target supporting such operations.
15407
15408 @quotation
15409
15410 "String manipulation operations---e.g.:, translate and test."
15411 @end quotation
15412
15413 Followed on any target supporting such operations.
15414
15415 @quotation
15416
15417 "Vector operations---e.g.:, compare vector against thresholds."
15418 @end quotation
15419
15420 Followed on any target supporting such operations.
15421
15422 @quotation
15423
15424 "Direct operations on I/O ports."
15425 @end quotation
15426
15427 Followed on any target supporting such operations.
15428
15429 @geindex Interrupt support
15430
15431 @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
15432 @anchor{gnat_rm/implementation_advice rm-c-3-28-interrupt-support}@anchor{243}
15433 @section RM C.3(28): Interrupt Support
15434
15435
15436 @quotation
15437
15438 "If the @code{Ceiling_Locking} policy is not in effect, the
15439 implementation should provide means for the application to specify which
15440 interrupts are to be blocked during protected actions, if the underlying
15441 system allows for a finer-grain control of interrupt blocking."
15442 @end quotation
15443
15444 Followed. The underlying system does not allow for finer-grain control
15445 of interrupt blocking.
15446
15447 @geindex Protected procedure handlers
15448
15449 @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
15450 @anchor{gnat_rm/implementation_advice rm-c-3-1-20-21-protected-procedure-handlers}@anchor{244}
15451 @section RM C.3.1(20-21): Protected Procedure Handlers
15452
15453
15454 @quotation
15455
15456 "Whenever possible, the implementation should allow interrupt handlers to
15457 be called directly by the hardware."
15458 @end quotation
15459
15460 Followed on any target where the underlying operating system permits
15461 such direct calls.
15462
15463 @quotation
15464
15465 "Whenever practical, violations of any
15466 implementation-defined restrictions should be detected before run time."
15467 @end quotation
15468
15469 Followed. Compile time warnings are given when possible.
15470
15471 @geindex Package `@w{`}Interrupts`@w{`}
15472
15473 @geindex Interrupts
15474
15475 @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
15476 @anchor{gnat_rm/implementation_advice rm-c-3-2-25-package-interrupts}@anchor{245}
15477 @section RM C.3.2(25): Package @code{Interrupts}
15478
15479
15480 @quotation
15481
15482 "If implementation-defined forms of interrupt handler procedures are
15483 supported, such as protected procedures with parameters, then for each
15484 such form of a handler, a type analogous to @code{Parameterless_Handler}
15485 should be specified in a child package of @code{Interrupts}, with the
15486 same operations as in the predefined package Interrupts."
15487 @end quotation
15488
15489 Followed.
15490
15491 @geindex Pre-elaboration requirements
15492
15493 @node RM C 4 14 Pre-elaboration Requirements,RM C 5 8 Pragma Discard_Names,RM C 3 2 25 Package Interrupts,Implementation Advice
15494 @anchor{gnat_rm/implementation_advice rm-c-4-14-pre-elaboration-requirements}@anchor{246}
15495 @section RM C.4(14): Pre-elaboration Requirements
15496
15497
15498 @quotation
15499
15500 "It is recommended that pre-elaborated packages be implemented in such a
15501 way that there should be little or no code executed at run time for the
15502 elaboration of entities not already covered by the Implementation
15503 Requirements."
15504 @end quotation
15505
15506 Followed. Executable code is generated in some cases, e.g., loops
15507 to initialize large arrays.
15508
15509 @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
15510 @anchor{gnat_rm/implementation_advice rm-c-5-8-pragma-discard-names}@anchor{247}
15511 @section RM C.5(8): Pragma @code{Discard_Names}
15512
15513
15514 @quotation
15515
15516 "If the pragma applies to an entity, then the implementation should
15517 reduce the amount of storage used for storing names associated with that
15518 entity."
15519 @end quotation
15520
15521 Followed.
15522
15523 @geindex Package Task_Attributes
15524
15525 @geindex Task_Attributes
15526
15527 @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
15528 @anchor{gnat_rm/implementation_advice rm-c-7-2-30-the-package-task-attributes}@anchor{248}
15529 @section RM C.7.2(30): The Package Task_Attributes
15530
15531
15532 @quotation
15533
15534 "Some implementations are targeted to domains in which memory use at run
15535 time must be completely deterministic. For such implementations, it is
15536 recommended that the storage for task attributes will be pre-allocated
15537 statically and not from the heap. This can be accomplished by either
15538 placing restrictions on the number and the size of the task's
15539 attributes, or by using the pre-allocated storage for the first @code{N}
15540 attribute objects, and the heap for the others. In the latter case,
15541 @code{N} should be documented."
15542 @end quotation
15543
15544 Not followed. This implementation is not targeted to such a domain.
15545
15546 @geindex Locking Policies
15547
15548 @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
15549 @anchor{gnat_rm/implementation_advice rm-d-3-17-locking-policies}@anchor{249}
15550 @section RM D.3(17): Locking Policies
15551
15552
15553 @quotation
15554
15555 "The implementation should use names that end with @code{_Locking} for
15556 locking policies defined by the implementation."
15557 @end quotation
15558
15559 Followed. Two implementation-defined locking policies are defined,
15560 whose names (@code{Inheritance_Locking} and
15561 @code{Concurrent_Readers_Locking}) follow this suggestion.
15562
15563 @geindex Entry queuing policies
15564
15565 @node RM D 4 16 Entry Queuing Policies,RM D 6 9-10 Preemptive Abort,RM D 3 17 Locking Policies,Implementation Advice
15566 @anchor{gnat_rm/implementation_advice rm-d-4-16-entry-queuing-policies}@anchor{24a}
15567 @section RM D.4(16): Entry Queuing Policies
15568
15569
15570 @quotation
15571
15572 "Names that end with @code{_Queuing} should be used
15573 for all implementation-defined queuing policies."
15574 @end quotation
15575
15576 Followed. No such implementation-defined queuing policies exist.
15577
15578 @geindex Preemptive abort
15579
15580 @node RM D 6 9-10 Preemptive Abort,RM D 7 21 Tasking Restrictions,RM D 4 16 Entry Queuing Policies,Implementation Advice
15581 @anchor{gnat_rm/implementation_advice rm-d-6-9-10-preemptive-abort}@anchor{24b}
15582 @section RM D.6(9-10): Preemptive Abort
15583
15584
15585 @quotation
15586
15587 "Even though the @emph{abort_statement} is included in the list of
15588 potentially blocking operations (see 9.5.1), it is recommended that this
15589 statement be implemented in a way that never requires the task executing
15590 the @emph{abort_statement} to block."
15591 @end quotation
15592
15593 Followed.
15594
15595 @quotation
15596
15597 "On a multi-processor, the delay associated with aborting a task on
15598 another processor should be bounded; the implementation should use
15599 periodic polling, if necessary, to achieve this."
15600 @end quotation
15601
15602 Followed.
15603
15604 @geindex Tasking restrictions
15605
15606 @node RM D 7 21 Tasking Restrictions,RM D 8 47-49 Monotonic Time,RM D 6 9-10 Preemptive Abort,Implementation Advice
15607 @anchor{gnat_rm/implementation_advice rm-d-7-21-tasking-restrictions}@anchor{24c}
15608 @section RM D.7(21): Tasking Restrictions
15609
15610
15611 @quotation
15612
15613 "When feasible, the implementation should take advantage of the specified
15614 restrictions to produce a more efficient implementation."
15615 @end quotation
15616
15617 GNAT currently takes advantage of these restrictions by providing an optimized
15618 run time when the Ravenscar profile and the GNAT restricted run time set
15619 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
15620 pragma @code{Profile (Restricted)} for more details.
15621
15622 @geindex Time
15623 @geindex monotonic
15624
15625 @node RM D 8 47-49 Monotonic Time,RM E 5 28-29 Partition Communication Subsystem,RM D 7 21 Tasking Restrictions,Implementation Advice
15626 @anchor{gnat_rm/implementation_advice rm-d-8-47-49-monotonic-time}@anchor{24d}
15627 @section RM D.8(47-49): Monotonic Time
15628
15629
15630 @quotation
15631
15632 "When appropriate, implementations should provide configuration
15633 mechanisms to change the value of @code{Tick}."
15634 @end quotation
15635
15636 Such configuration mechanisms are not appropriate to this implementation
15637 and are thus not supported.
15638
15639 @quotation
15640
15641 "It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
15642 be implemented as transformations of the same time base."
15643 @end quotation
15644
15645 Followed.
15646
15647 @quotation
15648
15649 "It is recommended that the best time base which exists in
15650 the underlying system be available to the application through
15651 @code{Clock}. @cite{Best} may mean highest accuracy or largest range."
15652 @end quotation
15653
15654 Followed.
15655
15656 @geindex Partition communication subsystem
15657
15658 @geindex PCS
15659
15660 @node RM E 5 28-29 Partition Communication Subsystem,RM F 7 COBOL Support,RM D 8 47-49 Monotonic Time,Implementation Advice
15661 @anchor{gnat_rm/implementation_advice rm-e-5-28-29-partition-communication-subsystem}@anchor{24e}
15662 @section RM E.5(28-29): Partition Communication Subsystem
15663
15664
15665 @quotation
15666
15667 "Whenever possible, the PCS on the called partition should allow for
15668 multiple tasks to call the RPC-receiver with different messages and
15669 should allow them to block until the corresponding subprogram body
15670 returns."
15671 @end quotation
15672
15673 Followed by GLADE, a separately supplied PCS that can be used with
15674 GNAT.
15675
15676 @quotation
15677
15678 "The @code{Write} operation on a stream of type @code{Params_Stream_Type}
15679 should raise @code{Storage_Error} if it runs out of space trying to
15680 write the @code{Item} into the stream."
15681 @end quotation
15682
15683 Followed by GLADE, a separately supplied PCS that can be used with
15684 GNAT.
15685
15686 @geindex COBOL support
15687
15688 @node RM F 7 COBOL Support,RM F 1 2 Decimal Radix Support,RM E 5 28-29 Partition Communication Subsystem,Implementation Advice
15689 @anchor{gnat_rm/implementation_advice rm-f-7-cobol-support}@anchor{24f}
15690 @section RM F(7): COBOL Support
15691
15692
15693 @quotation
15694
15695 "If COBOL (respectively, C) is widely supported in the target
15696 environment, implementations supporting the Information Systems Annex
15697 should provide the child package @code{Interfaces.COBOL} (respectively,
15698 @code{Interfaces.C}) specified in Annex B and should support a
15699 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
15700 pragmas (see Annex B), thus allowing Ada programs to interface with
15701 programs written in that language."
15702 @end quotation
15703
15704 Followed.
15705
15706 @geindex Decimal radix support
15707
15708 @node RM F 1 2 Decimal Radix Support,RM G Numerics,RM F 7 COBOL Support,Implementation Advice
15709 @anchor{gnat_rm/implementation_advice rm-f-1-2-decimal-radix-support}@anchor{250}
15710 @section RM F.1(2): Decimal Radix Support
15711
15712
15713 @quotation
15714
15715 "Packed decimal should be used as the internal representation for objects
15716 of subtype @code{S} when @code{S}'Machine_Radix = 10."
15717 @end quotation
15718
15719 Not followed. GNAT ignores @code{S}'Machine_Radix and always uses binary
15720 representations.
15721
15722 @geindex Numerics
15723
15724 @node RM G Numerics,RM G 1 1 56-58 Complex Types,RM F 1 2 Decimal Radix Support,Implementation Advice
15725 @anchor{gnat_rm/implementation_advice rm-g-numerics}@anchor{251}
15726 @section RM G: Numerics
15727
15728
15729 @quotation
15730
15731 "If Fortran (respectively, C) is widely supported in the target
15732 environment, implementations supporting the Numerics Annex
15733 should provide the child package @code{Interfaces.Fortran} (respectively,
15734 @code{Interfaces.C}) specified in Annex B and should support a
15735 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
15736 pragmas (see Annex B), thus allowing Ada programs to interface with
15737 programs written in that language."
15738 @end quotation
15739
15740 Followed.
15741
15742 @geindex Complex types
15743
15744 @node RM G 1 1 56-58 Complex Types,RM G 1 2 49 Complex Elementary Functions,RM G Numerics,Implementation Advice
15745 @anchor{gnat_rm/implementation_advice rm-g-1-1-56-58-complex-types}@anchor{252}
15746 @section RM G.1.1(56-58): Complex Types
15747
15748
15749 @quotation
15750
15751 "Because the usual mathematical meaning of multiplication of a complex
15752 operand and a real operand is that of the scaling of both components of
15753 the former by the latter, an implementation should not perform this
15754 operation by first promoting the real operand to complex type and then
15755 performing a full complex multiplication. In systems that, in the
15756 future, support an Ada binding to IEC 559:1989, the latter technique
15757 will not generate the required result when one of the components of the
15758 complex operand is infinite. (Explicit multiplication of the infinite
15759 component by the zero component obtained during promotion yields a NaN
15760 that propagates into the final result.) Analogous advice applies in the
15761 case of multiplication of a complex operand and a pure-imaginary
15762 operand, and in the case of division of a complex operand by a real or
15763 pure-imaginary operand."
15764 @end quotation
15765
15766 Not followed.
15767
15768 @quotation
15769
15770 "Similarly, because the usual mathematical meaning of addition of a
15771 complex operand and a real operand is that the imaginary operand remains
15772 unchanged, an implementation should not perform this operation by first
15773 promoting the real operand to complex type and then performing a full
15774 complex addition. In implementations in which the @code{Signed_Zeros}
15775 attribute of the component type is @code{True} (and which therefore
15776 conform to IEC 559:1989 in regard to the handling of the sign of zero in
15777 predefined arithmetic operations), the latter technique will not
15778 generate the required result when the imaginary component of the complex
15779 operand is a negatively signed zero. (Explicit addition of the negative
15780 zero to the zero obtained during promotion yields a positive zero.)
15781 Analogous advice applies in the case of addition of a complex operand
15782 and a pure-imaginary operand, and in the case of subtraction of a
15783 complex operand and a real or pure-imaginary operand."
15784 @end quotation
15785
15786 Not followed.
15787
15788 @quotation
15789
15790 "Implementations in which @code{Real'Signed_Zeros} is @code{True} should
15791 attempt to provide a rational treatment of the signs of zero results and
15792 result components. As one example, the result of the @code{Argument}
15793 function should have the sign of the imaginary component of the
15794 parameter @code{X} when the point represented by that parameter lies on
15795 the positive real axis; as another, the sign of the imaginary component
15796 of the @code{Compose_From_Polar} function should be the same as
15797 (respectively, the opposite of) that of the @code{Argument} parameter when that
15798 parameter has a value of zero and the @code{Modulus} parameter has a
15799 nonnegative (respectively, negative) value."
15800 @end quotation
15801
15802 Followed.
15803
15804 @geindex Complex elementary functions
15805
15806 @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
15807 @anchor{gnat_rm/implementation_advice rm-g-1-2-49-complex-elementary-functions}@anchor{253}
15808 @section RM G.1.2(49): Complex Elementary Functions
15809
15810
15811 @quotation
15812
15813 "Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
15814 @code{True} should attempt to provide a rational treatment of the signs
15815 of zero results and result components. For example, many of the complex
15816 elementary functions have components that are odd functions of one of
15817 the parameter components; in these cases, the result component should
15818 have the sign of the parameter component at the origin. Other complex
15819 elementary functions have zero components whose sign is opposite that of
15820 a parameter component at the origin, or is always positive or always
15821 negative."
15822 @end quotation
15823
15824 Followed.
15825
15826 @geindex Accuracy requirements
15827
15828 @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
15829 @anchor{gnat_rm/implementation_advice rm-g-2-4-19-accuracy-requirements}@anchor{254}
15830 @section RM G.2.4(19): Accuracy Requirements
15831
15832
15833 @quotation
15834
15835 "The versions of the forward trigonometric functions without a
15836 @code{Cycle} parameter should not be implemented by calling the
15837 corresponding version with a @code{Cycle} parameter of
15838 @code{2.0*Numerics.Pi}, since this will not provide the required
15839 accuracy in some portions of the domain. For the same reason, the
15840 version of @code{Log} without a @code{Base} parameter should not be
15841 implemented by calling the corresponding version with a @code{Base}
15842 parameter of @code{Numerics.e}."
15843 @end quotation
15844
15845 Followed.
15846
15847 @geindex Complex arithmetic accuracy
15848
15849 @geindex Accuracy
15850 @geindex complex arithmetic
15851
15852 @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
15853 @anchor{gnat_rm/implementation_advice rm-g-2-6-15-complex-arithmetic-accuracy}@anchor{255}
15854 @section RM G.2.6(15): Complex Arithmetic Accuracy
15855
15856
15857 @quotation
15858
15859 "The version of the @code{Compose_From_Polar} function without a
15860 @code{Cycle} parameter should not be implemented by calling the
15861 corresponding version with a @code{Cycle} parameter of
15862 @code{2.0*Numerics.Pi}, since this will not provide the required
15863 accuracy in some portions of the domain."
15864 @end quotation
15865
15866 Followed.
15867
15868 @geindex Sequential elaboration policy
15869
15870 @node RM H 6 15/2 Pragma Partition_Elaboration_Policy,,RM G 2 6 15 Complex Arithmetic Accuracy,Implementation Advice
15871 @anchor{gnat_rm/implementation_advice rm-h-6-15-2-pragma-partition-elaboration-policy}@anchor{256}
15872 @section RM H.6(15/2): Pragma Partition_Elaboration_Policy
15873
15874
15875 @quotation
15876
15877 "If the partition elaboration policy is @code{Sequential} and the
15878 Environment task becomes permanently blocked during elaboration then the
15879 partition is deadlocked and it is recommended that the partition be
15880 immediately terminated."
15881 @end quotation
15882
15883 Not followed.
15884
15885 @node Implementation Defined Characteristics,Intrinsic Subprograms,Implementation Advice,Top
15886 @anchor{gnat_rm/implementation_defined_characteristics implementation-defined-characteristics}@anchor{b}@anchor{gnat_rm/implementation_defined_characteristics doc}@anchor{257}@anchor{gnat_rm/implementation_defined_characteristics id1}@anchor{258}
15887 @chapter Implementation Defined Characteristics
15888
15889
15890 In addition to the implementation dependent pragmas and attributes, and the
15891 implementation advice, there are a number of other Ada features that are
15892 potentially implementation dependent and are designated as
15893 implementation-defined. These are mentioned throughout the Ada Reference
15894 Manual, and are summarized in Annex M.
15895
15896 A requirement for conforming Ada compilers is that they provide
15897 documentation describing how the implementation deals with each of these
15898 issues. In this chapter you will find each point in Annex M listed,
15899 followed by a description of how GNAT
15900 handles the implementation dependence.
15901
15902 You can use this chapter as a guide to minimizing implementation
15903 dependent features in your programs if portability to other compilers
15904 and other operating systems is an important consideration. The numbers
15905 in each entry below correspond to the paragraph numbers in the Ada
15906 Reference Manual.
15907
15908
15909 @itemize *
15910
15911 @item
15912 "Whether or not each recommendation given in Implementation
15913 Advice is followed. See 1.1.2(37)."
15914 @end itemize
15915
15916 See @ref{a,,Implementation Advice}.
15917
15918
15919 @itemize *
15920
15921 @item
15922 "Capacity limitations of the implementation. See 1.1.3(3)."
15923 @end itemize
15924
15925 The complexity of programs that can be processed is limited only by the
15926 total amount of available virtual memory, and disk space for the
15927 generated object files.
15928
15929
15930 @itemize *
15931
15932 @item
15933 "Variations from the standard that are impractical to avoid
15934 given the implementation's execution environment. See 1.1.3(6)."
15935 @end itemize
15936
15937 There are no variations from the standard.
15938
15939
15940 @itemize *
15941
15942 @item
15943 "Which code_statements cause external
15944 interactions. See 1.1.3(10)."
15945 @end itemize
15946
15947 Any @emph{code_statement} can potentially cause external interactions.
15948
15949
15950 @itemize *
15951
15952 @item
15953 "The coded representation for the text of an Ada
15954 program. See 2.1(4)."
15955 @end itemize
15956
15957 See separate section on source representation.
15958
15959
15960 @itemize *
15961
15962 @item
15963 "The control functions allowed in comments. See 2.1(14)."
15964 @end itemize
15965
15966 See separate section on source representation.
15967
15968
15969 @itemize *
15970
15971 @item
15972 "The representation for an end of line. See 2.2(2)."
15973 @end itemize
15974
15975 See separate section on source representation.
15976
15977
15978 @itemize *
15979
15980 @item
15981 "Maximum supported line length and lexical element
15982 length. See 2.2(15)."
15983 @end itemize
15984
15985 The maximum line length is 255 characters and the maximum length of
15986 a lexical element is also 255 characters. This is the default setting
15987 if not overridden by the use of compiler switch @emph{-gnaty} (which
15988 sets the maximum to 79) or @emph{-gnatyMnn} which allows the maximum
15989 line length to be specified to be any value up to 32767. The maximum
15990 length of a lexical element is the same as the maximum line length.
15991
15992
15993 @itemize *
15994
15995 @item
15996 "Implementation defined pragmas. See 2.8(14)."
15997 @end itemize
15998
15999 See @ref{7,,Implementation Defined Pragmas}.
16000
16001
16002 @itemize *
16003
16004 @item
16005 "Effect of pragma @code{Optimize}. See 2.8(27)."
16006 @end itemize
16007
16008 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
16009 parameter, checks that the optimization flag is set, and aborts if it is
16010 not.
16011
16012
16013 @itemize *
16014
16015 @item
16016 "The sequence of characters of the value returned by
16017 @code{S'Image} when some of the graphic characters of
16018 @code{S'Wide_Image} are not defined in @code{Character}. See
16019 3.5(37)."
16020 @end itemize
16021
16022 The sequence of characters is as defined by the wide character encoding
16023 method used for the source. See section on source representation for
16024 further details.
16025
16026
16027 @itemize *
16028
16029 @item
16030 "The predefined integer types declared in
16031 @code{Standard}. See 3.5.4(25)."
16032 @end itemize
16033
16034
16035 @multitable {xxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16036 @headitem
16037
16038 Type
16039
16040 @tab
16041
16042 Representation
16043
16044 @item
16045
16046 @emph{Short_Short_Integer}
16047
16048 @tab
16049
16050 8 bit signed
16051
16052 @item
16053
16054 @emph{Short_Integer}
16055
16056 @tab
16057
16058 (Short) 16 bit signed
16059
16060 @item
16061
16062 @emph{Integer}
16063
16064 @tab
16065
16066 32 bit signed
16067
16068 @item
16069
16070 @emph{Long_Integer}
16071
16072 @tab
16073
16074 64 bit signed (on most 64 bit targets,
16075 depending on the C definition of long).
16076 32 bit signed (all other targets)
16077
16078 @item
16079
16080 @emph{Long_Long_Integer}
16081
16082 @tab
16083
16084 64 bit signed
16085
16086 @end multitable
16087
16088
16089
16090 @itemize *
16091
16092 @item
16093 "Any nonstandard integer types and the operators defined
16094 for them. See 3.5.4(26)."
16095 @end itemize
16096
16097 There are no nonstandard integer types.
16098
16099
16100 @itemize *
16101
16102 @item
16103 "Any nonstandard real types and the operators defined for
16104 them. See 3.5.6(8)."
16105 @end itemize
16106
16107 There are no nonstandard real types.
16108
16109
16110 @itemize *
16111
16112 @item
16113 "What combinations of requested decimal precision and range
16114 are supported for floating point types. See 3.5.7(7)."
16115 @end itemize
16116
16117 The precision and range is as defined by the IEEE standard.
16118
16119
16120 @itemize *
16121
16122 @item
16123 "The predefined floating point types declared in
16124 @code{Standard}. See 3.5.7(16)."
16125 @end itemize
16126
16127
16128 @multitable {xxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16129 @headitem
16130
16131 Type
16132
16133 @tab
16134
16135 Representation
16136
16137 @item
16138
16139 @emph{Short_Float}
16140
16141 @tab
16142
16143 32 bit IEEE short
16144
16145 @item
16146
16147 @emph{Float}
16148
16149 @tab
16150
16151 (Short) 32 bit IEEE short
16152
16153 @item
16154
16155 @emph{Long_Float}
16156
16157 @tab
16158
16159 64 bit IEEE long
16160
16161 @item
16162
16163 @emph{Long_Long_Float}
16164
16165 @tab
16166
16167 64 bit IEEE long (80 bit IEEE long on x86 processors)
16168
16169 @end multitable
16170
16171
16172
16173 @itemize *
16174
16175 @item
16176 "The small of an ordinary fixed point type. See 3.5.9(8)."
16177 @end itemize
16178
16179 @code{Fine_Delta} is 2**(-63)
16180
16181
16182 @itemize *
16183
16184 @item
16185 "What combinations of small, range, and digits are
16186 supported for fixed point types. See 3.5.9(10)."
16187 @end itemize
16188
16189 Any combinations are permitted that do not result in a small less than
16190 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
16191 If the mantissa is larger than 53 bits on machines where Long_Long_Float
16192 is 64 bits (true of all architectures except ia32), then the output from
16193 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
16194 is because floating-point conversions are used to convert fixed point.
16195
16196
16197 @itemize *
16198
16199 @item
16200 "The result of @code{Tags.Expanded_Name} for types declared
16201 within an unnamed @emph{block_statement}. See 3.9(10)."
16202 @end itemize
16203
16204 Block numbers of the form @code{B@emph{nnn}}, where @emph{nnn} is a
16205 decimal integer are allocated.
16206
16207
16208 @itemize *
16209
16210 @item
16211 "Implementation-defined attributes. See 4.1.4(12)."
16212 @end itemize
16213
16214 See @ref{8,,Implementation Defined Attributes}.
16215
16216
16217 @itemize *
16218
16219 @item
16220 "Any implementation-defined time types. See 9.6(6)."
16221 @end itemize
16222
16223 There are no implementation-defined time types.
16224
16225
16226 @itemize *
16227
16228 @item
16229 "The time base associated with relative delays."
16230 @end itemize
16231
16232 See 9.6(20). The time base used is that provided by the C library
16233 function @code{gettimeofday}.
16234
16235
16236 @itemize *
16237
16238 @item
16239 "The time base of the type @code{Calendar.Time}. See
16240 9.6(23)."
16241 @end itemize
16242
16243 The time base used is that provided by the C library function
16244 @code{gettimeofday}.
16245
16246
16247 @itemize *
16248
16249 @item
16250 "The time zone used for package @code{Calendar}
16251 operations. See 9.6(24)."
16252 @end itemize
16253
16254 The time zone used by package @code{Calendar} is the current system time zone
16255 setting for local time, as accessed by the C library function
16256 @code{localtime}.
16257
16258
16259 @itemize *
16260
16261 @item
16262 "Any limit on @emph{delay_until_statements} of
16263 @emph{select_statements}. See 9.6(29)."
16264 @end itemize
16265
16266 There are no such limits.
16267
16268
16269 @itemize *
16270
16271 @item
16272 "Whether or not two non-overlapping parts of a composite
16273 object are independently addressable, in the case where packing, record
16274 layout, or @code{Component_Size} is specified for the object. See
16275 9.10(1)."
16276 @end itemize
16277
16278 Separate components are independently addressable if they do not share
16279 overlapping storage units.
16280
16281
16282 @itemize *
16283
16284 @item
16285 "The representation for a compilation. See 10.1(2)."
16286 @end itemize
16287
16288 A compilation is represented by a sequence of files presented to the
16289 compiler in a single invocation of the @emph{gcc} command.
16290
16291
16292 @itemize *
16293
16294 @item
16295 "Any restrictions on compilations that contain multiple
16296 compilation_units. See 10.1(4)."
16297 @end itemize
16298
16299 No single file can contain more than one compilation unit, but any
16300 sequence of files can be presented to the compiler as a single
16301 compilation.
16302
16303
16304 @itemize *
16305
16306 @item
16307 "The mechanisms for creating an environment and for adding
16308 and replacing compilation units. See 10.1.4(3)."
16309 @end itemize
16310
16311 See separate section on compilation model.
16312
16313
16314 @itemize *
16315
16316 @item
16317 "The manner of explicitly assigning library units to a
16318 partition. See 10.2(2)."
16319 @end itemize
16320
16321 If a unit contains an Ada main program, then the Ada units for the partition
16322 are determined by recursive application of the rules in the Ada Reference
16323 Manual section 10.2(2-6). In other words, the Ada units will be those that
16324 are needed by the main program, and then this definition of need is applied
16325 recursively to those units, and the partition contains the transitive
16326 closure determined by this relationship. In short, all the necessary units
16327 are included, with no need to explicitly specify the list. If additional
16328 units are required, e.g., by foreign language units, then all units must be
16329 mentioned in the context clause of one of the needed Ada units.
16330
16331 If the partition contains no main program, or if the main program is in
16332 a language other than Ada, then GNAT
16333 provides the binder options @emph{-z} and @emph{-n} respectively, and in
16334 this case a list of units can be explicitly supplied to the binder for
16335 inclusion in the partition (all units needed by these units will also
16336 be included automatically). For full details on the use of these
16337 options, refer to @emph{GNAT Make Program gnatmake} in the
16338 @cite{GNAT User's Guide}.
16339
16340
16341 @itemize *
16342
16343 @item
16344 "The implementation-defined means, if any, of specifying
16345 which compilation units are needed by a given compilation unit. See
16346 10.2(2)."
16347 @end itemize
16348
16349 The units needed by a given compilation unit are as defined in
16350 the Ada Reference Manual section 10.2(2-6). There are no
16351 implementation-defined pragmas or other implementation-defined
16352 means for specifying needed units.
16353
16354
16355 @itemize *
16356
16357 @item
16358 "The manner of designating the main subprogram of a
16359 partition. See 10.2(7)."
16360 @end itemize
16361
16362 The main program is designated by providing the name of the
16363 corresponding @code{ALI} file as the input parameter to the binder.
16364
16365
16366 @itemize *
16367
16368 @item
16369 "The order of elaboration of @emph{library_items}. See
16370 10.2(18)."
16371 @end itemize
16372
16373 The first constraint on ordering is that it meets the requirements of
16374 Chapter 10 of the Ada Reference Manual. This still leaves some
16375 implementation dependent choices, which are resolved by first
16376 elaborating bodies as early as possible (i.e., in preference to specs
16377 where there is a choice), and second by evaluating the immediate with
16378 clauses of a unit to determine the probably best choice, and
16379 third by elaborating in alphabetical order of unit names
16380 where a choice still remains.
16381
16382
16383 @itemize *
16384
16385 @item
16386 "Parameter passing and function return for the main
16387 subprogram. See 10.2(21)."
16388 @end itemize
16389
16390 The main program has no parameters. It may be a procedure, or a function
16391 returning an integer type. In the latter case, the returned integer
16392 value is the return code of the program (overriding any value that
16393 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
16394
16395
16396 @itemize *
16397
16398 @item
16399 "The mechanisms for building and running partitions. See
16400 10.2(24)."
16401 @end itemize
16402
16403 GNAT itself supports programs with only a single partition. The GNATDIST
16404 tool provided with the GLADE package (which also includes an implementation
16405 of the PCS) provides a completely flexible method for building and running
16406 programs consisting of multiple partitions. See the separate GLADE manual
16407 for details.
16408
16409
16410 @itemize *
16411
16412 @item
16413 "The details of program execution, including program
16414 termination. See 10.2(25)."
16415 @end itemize
16416
16417 See separate section on compilation model.
16418
16419
16420 @itemize *
16421
16422 @item
16423 "The semantics of any non-active partitions supported by the
16424 implementation. See 10.2(28)."
16425 @end itemize
16426
16427 Passive partitions are supported on targets where shared memory is
16428 provided by the operating system. See the GLADE reference manual for
16429 further details.
16430
16431
16432 @itemize *
16433
16434 @item
16435 "The information returned by @code{Exception_Message}. See
16436 11.4.1(10)."
16437 @end itemize
16438
16439 Exception message returns the null string unless a specific message has
16440 been passed by the program.
16441
16442
16443 @itemize *
16444
16445 @item
16446 "The result of @code{Exceptions.Exception_Name} for types
16447 declared within an unnamed @emph{block_statement}. See 11.4.1(12)."
16448 @end itemize
16449
16450 Blocks have implementation defined names of the form @code{B@emph{nnn}}
16451 where @emph{nnn} is an integer.
16452
16453
16454 @itemize *
16455
16456 @item
16457 "The information returned by
16458 @code{Exception_Information}. See 11.4.1(13)."
16459 @end itemize
16460
16461 @code{Exception_Information} returns a string in the following format:
16462
16463 @example
16464 *Exception_Name:* nnnnn
16465 *Message:* mmmmm
16466 *PID:* ppp
16467 *Load address:* 0xhhhh
16468 *Call stack traceback locations:*
16469 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
16470 @end example
16471
16472 where
16473
16474 @quotation
16475
16476
16477 @itemize *
16478
16479 @item
16480 @code{nnnn} is the fully qualified name of the exception in all upper
16481 case letters. This line is always present.
16482
16483 @item
16484 @code{mmmm} is the message (this line present only if message is non-null)
16485
16486 @item
16487 @code{ppp} is the Process Id value as a decimal integer (this line is
16488 present only if the Process Id is nonzero). Currently we are
16489 not making use of this field.
16490
16491 @item
16492 The Load address line, the Call stack traceback locations line and the
16493 following values are present only if at least one traceback location was
16494 recorded. The Load address indicates the address at which the main executable
16495 was loaded; this line may not be present if operating system hasn't relocated
16496 the main executable. The values are given in C style format, with lower case
16497 letters for a-f, and only as many digits present as are necessary.
16498 The line terminator sequence at the end of each line, including
16499 the last line is a single @code{LF} character (@code{16#0A#}).
16500 @end itemize
16501 @end quotation
16502
16503
16504 @itemize *
16505
16506 @item
16507 "Implementation-defined check names. See 11.5(27)."
16508 @end itemize
16509
16510 The implementation defined check names include Alignment_Check,
16511 Atomic_Synchronization, Duplicated_Tag_Check, Container_Checks,
16512 Tampering_Check, Predicate_Check, and Validity_Check. In addition, a user
16513 program can add implementation-defined check names by means of the pragma
16514 Check_Name. See the description of pragma @code{Suppress} for full details.
16515
16516
16517 @itemize *
16518
16519 @item
16520 "The interpretation of each aspect of representation. See
16521 13.1(20)."
16522 @end itemize
16523
16524 See separate section on data representations.
16525
16526
16527 @itemize *
16528
16529 @item
16530 "Any restrictions placed upon representation items. See
16531 13.1(20)."
16532 @end itemize
16533
16534 See separate section on data representations.
16535
16536
16537 @itemize *
16538
16539 @item
16540 "The meaning of @code{Size} for indefinite subtypes. See
16541 13.3(48)."
16542 @end itemize
16543
16544 Size for an indefinite subtype is the maximum possible size, except that
16545 for the case of a subprogram parameter, the size of the parameter object
16546 is the actual size.
16547
16548
16549 @itemize *
16550
16551 @item
16552 "The default external representation for a type tag. See
16553 13.3(75)."
16554 @end itemize
16555
16556 The default external representation for a type tag is the fully expanded
16557 name of the type in upper case letters.
16558
16559
16560 @itemize *
16561
16562 @item
16563 "What determines whether a compilation unit is the same in
16564 two different partitions. See 13.3(76)."
16565 @end itemize
16566
16567 A compilation unit is the same in two different partitions if and only
16568 if it derives from the same source file.
16569
16570
16571 @itemize *
16572
16573 @item
16574 "Implementation-defined components. See 13.5.1(15)."
16575 @end itemize
16576
16577 The only implementation defined component is the tag for a tagged type,
16578 which contains a pointer to the dispatching table.
16579
16580
16581 @itemize *
16582
16583 @item
16584 "If @code{Word_Size} = @code{Storage_Unit}, the default bit
16585 ordering. See 13.5.3(5)."
16586 @end itemize
16587
16588 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
16589 implementation, so no non-default bit ordering is supported. The default
16590 bit ordering corresponds to the natural endianness of the target architecture.
16591
16592
16593 @itemize *
16594
16595 @item
16596 "The contents of the visible part of package @code{System}
16597 and its language-defined children. See 13.7(2)."
16598 @end itemize
16599
16600 See the definition of these packages in files @code{system.ads} and
16601 @code{s-stoele.ads}. Note that two declarations are added to package
16602 System.
16603
16604 @example
16605 Max_Priority : constant Positive := Priority'Last;
16606 Max_Interrupt_Priority : constant Positive := Interrupt_Priority'Last;
16607 @end example
16608
16609
16610 @itemize *
16611
16612 @item
16613 "The contents of the visible part of package
16614 @code{System.Machine_Code}, and the meaning of
16615 @emph{code_statements}. See 13.8(7)."
16616 @end itemize
16617
16618 See the definition and documentation in file @code{s-maccod.ads}.
16619
16620
16621 @itemize *
16622
16623 @item
16624 "The effect of unchecked conversion. See 13.9(11)."
16625 @end itemize
16626
16627 Unchecked conversion between types of the same size
16628 results in an uninterpreted transmission of the bits from one type
16629 to the other. If the types are of unequal sizes, then in the case of
16630 discrete types, a shorter source is first zero or sign extended as
16631 necessary, and a shorter target is simply truncated on the left.
16632 For all non-discrete types, the source is first copied if necessary
16633 to ensure that the alignment requirements of the target are met, then
16634 a pointer is constructed to the source value, and the result is obtained
16635 by dereferencing this pointer after converting it to be a pointer to the
16636 target type. Unchecked conversions where the target subtype is an
16637 unconstrained array are not permitted. If the target alignment is
16638 greater than the source alignment, then a copy of the result is
16639 made with appropriate alignment
16640
16641
16642 @itemize *
16643
16644 @item
16645 "The semantics of operations on invalid representations.
16646 See 13.9.2(10-11)."
16647 @end itemize
16648
16649 For assignments and other operations where the use of invalid values cannot
16650 result in erroneous behavior, the compiler ignores the possibility of invalid
16651 values. An exception is raised at the point where an invalid value would
16652 result in erroneous behavior. For example executing:
16653
16654 @example
16655 procedure invalidvals is
16656 X : Integer := -1;
16657 Y : Natural range 1 .. 10;
16658 for Y'Address use X'Address;
16659 Z : Natural range 1 .. 10;
16660 A : array (Natural range 1 .. 10) of Integer;
16661 begin
16662 Z := Y; -- no exception
16663 A (Z) := 3; -- exception raised;
16664 end;
16665 @end example
16666
16667 As indicated, an exception is raised on the array assignment, but not
16668 on the simple assignment of the invalid negative value from Y to Z.
16669
16670
16671 @itemize *
16672
16673 @item
16674 "The manner of choosing a storage pool for an access type
16675 when @code{Storage_Pool} is not specified for the type. See 13.11(17)."
16676 @end itemize
16677
16678 There are 3 different standard pools used by the compiler when
16679 @code{Storage_Pool} is not specified depending whether the type is local
16680 to a subprogram or defined at the library level and whether
16681 @code{Storage_Size`@w{`}is specified or not. See documentation in the runtime
16682 library units `@w{`}System.Pool_Global}, @code{System.Pool_Size} and
16683 @code{System.Pool_Local} in files @code{s-poosiz.ads},
16684 @code{s-pooglo.ads} and @code{s-pooloc.ads} for full details on the
16685 default pools used.
16686
16687
16688 @itemize *
16689
16690 @item
16691 "Whether or not the implementation provides user-accessible
16692 names for the standard pool type(s). See 13.11(17)."
16693 @end itemize
16694
16695 See documentation in the sources of the run time mentioned in the previous
16696 paragraph. All these pools are accessible by means of @cite{with}ing
16697 these units.
16698
16699
16700 @itemize *
16701
16702 @item
16703 "The meaning of @code{Storage_Size}. See 13.11(18)."
16704 @end itemize
16705
16706 @code{Storage_Size} is measured in storage units, and refers to the
16707 total space available for an access type collection, or to the primary
16708 stack space for a task.
16709
16710
16711 @itemize *
16712
16713 @item
16714 "Implementation-defined aspects of storage pools. See
16715 13.11(22)."
16716 @end itemize
16717
16718 See documentation in the sources of the run time mentioned in the
16719 paragraph about standard storage pools above
16720 for details on GNAT-defined aspects of storage pools.
16721
16722
16723 @itemize *
16724
16725 @item
16726 "The set of restrictions allowed in a pragma
16727 @code{Restrictions}. See 13.12(7)."
16728 @end itemize
16729
16730 See @ref{9,,Standard and Implementation Defined Restrictions}.
16731
16732
16733 @itemize *
16734
16735 @item
16736 "The consequences of violating limitations on
16737 @code{Restrictions} pragmas. See 13.12(9)."
16738 @end itemize
16739
16740 Restrictions that can be checked at compile time result in illegalities
16741 if violated. Currently there are no other consequences of violating
16742 restrictions.
16743
16744
16745 @itemize *
16746
16747 @item
16748 "The representation used by the @code{Read} and
16749 @code{Write} attributes of elementary types in terms of stream
16750 elements. See 13.13.2(9)."
16751 @end itemize
16752
16753 The representation is the in-memory representation of the base type of
16754 the type, using the number of bits corresponding to the
16755 @code{type'Size} value, and the natural ordering of the machine.
16756
16757
16758 @itemize *
16759
16760 @item
16761 "The names and characteristics of the numeric subtypes
16762 declared in the visible part of package @code{Standard}. See A.1(3)."
16763 @end itemize
16764
16765 See items describing the integer and floating-point types supported.
16766
16767
16768 @itemize *
16769
16770 @item
16771 "The string returned by @code{Character_Set_Version}.
16772 See A.3.5(3)."
16773 @end itemize
16774
16775 @code{Ada.Wide_Characters.Handling.Character_Set_Version} returns
16776 the string "Unicode 4.0", referring to version 4.0 of the
16777 Unicode specification.
16778
16779
16780 @itemize *
16781
16782 @item
16783 "The accuracy actually achieved by the elementary
16784 functions. See A.5.1(1)."
16785 @end itemize
16786
16787 The elementary functions correspond to the functions available in the C
16788 library. Only fast math mode is implemented.
16789
16790
16791 @itemize *
16792
16793 @item
16794 "The sign of a zero result from some of the operators or
16795 functions in @code{Numerics.Generic_Elementary_Functions}, when
16796 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46)."
16797 @end itemize
16798
16799 The sign of zeroes follows the requirements of the IEEE 754 standard on
16800 floating-point.
16801
16802
16803 @itemize *
16804
16805 @item
16806 "The value of
16807 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27)."
16808 @end itemize
16809
16810 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16811
16812
16813 @itemize *
16814
16815 @item
16816 "The value of
16817 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27)."
16818 @end itemize
16819
16820 Maximum image width is 6864, see library file @code{s-rannum.ads}.
16821
16822
16823 @itemize *
16824
16825 @item
16826 "The algorithms for random number generation. See
16827 A.5.2(32)."
16828 @end itemize
16829
16830 The algorithm is the Mersenne Twister, as documented in the source file
16831 @code{s-rannum.adb}. This version of the algorithm has a period of
16832 2**19937-1.
16833
16834
16835 @itemize *
16836
16837 @item
16838 "The string representation of a random number generator's
16839 state. See A.5.2(38)."
16840 @end itemize
16841
16842 The value returned by the Image function is the concatenation of
16843 the fixed-width decimal representations of the 624 32-bit integers
16844 of the state vector.
16845
16846
16847 @itemize *
16848
16849 @item
16850 "The minimum time interval between calls to the
16851 time-dependent Reset procedure that are guaranteed to initiate different
16852 random number sequences. See A.5.2(45)."
16853 @end itemize
16854
16855 The minimum period between reset calls to guarantee distinct series of
16856 random numbers is one microsecond.
16857
16858
16859 @itemize *
16860
16861 @item
16862 "The values of the @code{Model_Mantissa},
16863 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
16864 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
16865 Annex is not supported. See A.5.3(72)."
16866 @end itemize
16867
16868 Run the compiler with @emph{-gnatS} to produce a listing of package
16869 @code{Standard}, has the values of all numeric attributes.
16870
16871
16872 @itemize *
16873
16874 @item
16875 "Any implementation-defined characteristics of the
16876 input-output packages. See A.7(14)."
16877 @end itemize
16878
16879 There are no special implementation defined characteristics for these
16880 packages.
16881
16882
16883 @itemize *
16884
16885 @item
16886 "The value of @code{Buffer_Size} in @code{Storage_IO}. See
16887 A.9(10)."
16888 @end itemize
16889
16890 All type representations are contiguous, and the @code{Buffer_Size} is
16891 the value of @code{type'Size} rounded up to the next storage unit
16892 boundary.
16893
16894
16895 @itemize *
16896
16897 @item
16898 "External files for standard input, standard output, and
16899 standard error See A.10(5)."
16900 @end itemize
16901
16902 These files are mapped onto the files provided by the C streams
16903 libraries. See source file @code{i-cstrea.ads} for further details.
16904
16905
16906 @itemize *
16907
16908 @item
16909 "The accuracy of the value produced by @code{Put}. See
16910 A.10.9(36)."
16911 @end itemize
16912
16913 If more digits are requested in the output than are represented by the
16914 precision of the value, zeroes are output in the corresponding least
16915 significant digit positions.
16916
16917
16918 @itemize *
16919
16920 @item
16921 "The meaning of @code{Argument_Count}, @code{Argument}, and
16922 @code{Command_Name}. See A.15(1)."
16923 @end itemize
16924
16925 These are mapped onto the @code{argv} and @code{argc} parameters of the
16926 main program in the natural manner.
16927
16928
16929 @itemize *
16930
16931 @item
16932 "The interpretation of the @code{Form} parameter in procedure
16933 @code{Create_Directory}. See A.16(56)."
16934 @end itemize
16935
16936 The @code{Form} parameter is not used.
16937
16938
16939 @itemize *
16940
16941 @item
16942 "The interpretation of the @code{Form} parameter in procedure
16943 @code{Create_Path}. See A.16(60)."
16944 @end itemize
16945
16946 The @code{Form} parameter is not used.
16947
16948
16949 @itemize *
16950
16951 @item
16952 "The interpretation of the @code{Form} parameter in procedure
16953 @code{Copy_File}. See A.16(68)."
16954 @end itemize
16955
16956 The @code{Form} parameter is case-insensitive.
16957 Two fields are recognized in the @code{Form} parameter:
16958
16959 @example
16960 *preserve=<value>*
16961 *mode=<value>*
16962 @end example
16963
16964 <value> starts immediately after the character '=' and ends with the
16965 character immediately preceding the next comma (',') or with the last
16966 character of the parameter.
16967
16968 The only possible values for preserve= are:
16969
16970
16971 @multitable {xxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
16972 @headitem
16973
16974 Value
16975
16976 @tab
16977
16978 Meaning
16979
16980 @item
16981
16982 @emph{no_attributes}
16983
16984 @tab
16985
16986 Do not try to preserve any file attributes. This is the
16987 default if no preserve= is found in Form.
16988
16989 @item
16990
16991 @emph{all_attributes}
16992
16993 @tab
16994
16995 Try to preserve all file attributes (timestamps, access rights).
16996
16997 @item
16998
16999 @emph{timestamps}
17000
17001 @tab
17002
17003 Preserve the timestamp of the copied file, but not the other
17004 file attributes.
17005
17006 @end multitable
17007
17008
17009 The only possible values for mode= are:
17010
17011
17012 @multitable {xxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
17013 @headitem
17014
17015 Value
17016
17017 @tab
17018
17019 Meaning
17020
17021 @item
17022
17023 @emph{copy}
17024
17025 @tab
17026
17027 Only do the copy if the destination file does not already exist.
17028 If it already exists, Copy_File fails.
17029
17030 @item
17031
17032 @emph{overwrite}
17033
17034 @tab
17035
17036 Copy the file in all cases. Overwrite an already existing destination file.
17037
17038 @item
17039
17040 @emph{append}
17041
17042 @tab
17043
17044 Append the original file to the destination file. If the destination file
17045 does not exist, the destination file is a copy of the source file.
17046 When mode=append, the field preserve=, if it exists, is not taken into account.
17047
17048 @end multitable
17049
17050
17051 If the Form parameter includes one or both of the fields and the value or
17052 values are incorrect, Copy_file fails with Use_Error.
17053
17054 Examples of correct Forms:
17055
17056 @example
17057 Form => "preserve=no_attributes,mode=overwrite" (the default)
17058 Form => "mode=append"
17059 Form => "mode=copy, preserve=all_attributes"
17060 @end example
17061
17062 Examples of incorrect Forms:
17063
17064 @example
17065 Form => "preserve=junk"
17066 Form => "mode=internal, preserve=timestamps"
17067 @end example
17068
17069
17070 @itemize *
17071
17072 @item
17073 "The interpretation of the @code{Pattern} parameter, when not the null string,
17074 in the @code{Start_Search} and @code{Search} procedures.
17075 See A.16(104) and A.16(112)."
17076 @end itemize
17077
17078 When the @code{Pattern} parameter is not the null string, it is interpreted
17079 according to the syntax of regular expressions as defined in the
17080 @code{GNAT.Regexp} package.
17081
17082 See @ref{259,,GNAT.Regexp (g-regexp.ads)}.
17083
17084
17085 @itemize *
17086
17087 @item
17088 "Implementation-defined convention names. See B.1(11)."
17089 @end itemize
17090
17091 The following convention names are supported
17092
17093
17094 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
17095 @headitem
17096
17097 Convention Name
17098
17099 @tab
17100
17101 Interpretation
17102
17103 @item
17104
17105 @emph{Ada}
17106
17107 @tab
17108
17109 Ada
17110
17111 @item
17112
17113 @emph{Ada_Pass_By_Copy}
17114
17115 @tab
17116
17117 Allowed for any types except by-reference types such as limited
17118 records. Compatible with convention Ada, but causes any parameters
17119 with this convention to be passed by copy.
17120
17121 @item
17122
17123 @emph{Ada_Pass_By_Reference}
17124
17125 @tab
17126
17127 Allowed for any types except by-copy types such as scalars.
17128 Compatible with convention Ada, but causes any parameters
17129 with this convention to be passed by reference.
17130
17131 @item
17132
17133 @emph{Assembler}
17134
17135 @tab
17136
17137 Assembly language
17138
17139 @item
17140
17141 @emph{Asm}
17142
17143 @tab
17144
17145 Synonym for Assembler
17146
17147 @item
17148
17149 @emph{Assembly}
17150
17151 @tab
17152
17153 Synonym for Assembler
17154
17155 @item
17156
17157 @emph{C}
17158
17159 @tab
17160
17161 C
17162
17163 @item
17164
17165 @emph{C_Pass_By_Copy}
17166
17167 @tab
17168
17169 Allowed only for record types, like C, but also notes that record
17170 is to be passed by copy rather than reference.
17171
17172 @item
17173
17174 @emph{COBOL}
17175
17176 @tab
17177
17178 COBOL
17179
17180 @item
17181
17182 @emph{C_Plus_Plus (or CPP)}
17183
17184 @tab
17185
17186 C++
17187
17188 @item
17189
17190 @emph{Default}
17191
17192 @tab
17193
17194 Treated the same as C
17195
17196 @item
17197
17198 @emph{External}
17199
17200 @tab
17201
17202 Treated the same as C
17203
17204 @item
17205
17206 @emph{Fortran}
17207
17208 @tab
17209
17210 Fortran
17211
17212 @item
17213
17214 @emph{Intrinsic}
17215
17216 @tab
17217
17218 For support of pragma @code{Import} with convention Intrinsic, see
17219 separate section on Intrinsic Subprograms.
17220
17221 @item
17222
17223 @emph{Stdcall}
17224
17225 @tab
17226
17227 Stdcall (used for Windows implementations only). This convention correspond
17228 to the WINAPI (previously called Pascal convention) C/C++ convention under
17229 Windows. A routine with this convention cleans the stack before
17230 exit. This pragma cannot be applied to a dispatching call.
17231
17232 @item
17233
17234 @emph{DLL}
17235
17236 @tab
17237
17238 Synonym for Stdcall
17239
17240 @item
17241
17242 @emph{Win32}
17243
17244 @tab
17245
17246 Synonym for Stdcall
17247
17248 @item
17249
17250 @emph{Stubbed}
17251
17252 @tab
17253
17254 Stubbed is a special convention used to indicate that the body of the
17255 subprogram will be entirely ignored. Any call to the subprogram
17256 is converted into a raise of the @code{Program_Error} exception. If a
17257 pragma @code{Import} specifies convention @code{stubbed} then no body need
17258 be present at all. This convention is useful during development for the
17259 inclusion of subprograms whose body has not yet been written.
17260 In addition, all otherwise unrecognized convention names are also
17261 treated as being synonymous with convention C. In all implementations,
17262 use of such other names results in a warning.
17263
17264 @end multitable
17265
17266
17267
17268 @itemize *
17269
17270 @item
17271 "The meaning of link names. See B.1(36)."
17272 @end itemize
17273
17274 Link names are the actual names used by the linker.
17275
17276
17277 @itemize *
17278
17279 @item
17280 "The manner of choosing link names when neither the link
17281 name nor the address of an imported or exported entity is specified. See
17282 B.1(36)."
17283 @end itemize
17284
17285 The default linker name is that which would be assigned by the relevant
17286 external language, interpreting the Ada name as being in all lower case
17287 letters.
17288
17289
17290 @itemize *
17291
17292 @item
17293 "The effect of pragma @code{Linker_Options}. See B.1(37)."
17294 @end itemize
17295
17296 The string passed to @code{Linker_Options} is presented uninterpreted as
17297 an argument to the link command, unless it contains ASCII.NUL characters.
17298 NUL characters if they appear act as argument separators, so for example
17299
17300 @example
17301 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
17302 @end example
17303
17304 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
17305 linker. The order of linker options is preserved for a given unit. The final
17306 list of options passed to the linker is in reverse order of the elaboration
17307 order. For example, linker options for a body always appear before the options
17308 from the corresponding package spec.
17309
17310
17311 @itemize *
17312
17313 @item
17314 "The contents of the visible part of package
17315 @code{Interfaces} and its language-defined descendants. See B.2(1)."
17316 @end itemize
17317
17318 See files with prefix @code{i-} in the distributed library.
17319
17320
17321 @itemize *
17322
17323 @item
17324 "Implementation-defined children of package
17325 @code{Interfaces}. The contents of the visible part of package
17326 @code{Interfaces}. See B.2(11)."
17327 @end itemize
17328
17329 See files with prefix @code{i-} in the distributed library.
17330
17331
17332 @itemize *
17333
17334 @item
17335 "The types @code{Floating}, @code{Long_Floating},
17336 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
17337 @code{COBOL_Character}; and the initialization of the variables
17338 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
17339 @code{Interfaces.COBOL}. See B.4(50)."
17340 @end itemize
17341
17342
17343 @multitable {xxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
17344 @headitem
17345
17346 COBOL
17347
17348 @tab
17349
17350 Ada
17351
17352 @item
17353
17354 @emph{Floating}
17355
17356 @tab
17357
17358 Float
17359
17360 @item
17361
17362 @emph{Long_Floating}
17363
17364 @tab
17365
17366 (Floating) Long_Float
17367
17368 @item
17369
17370 @emph{Binary}
17371
17372 @tab
17373
17374 Integer
17375
17376 @item
17377
17378 @emph{Long_Binary}
17379
17380 @tab
17381
17382 Long_Long_Integer
17383
17384 @item
17385
17386 @emph{Decimal_Element}
17387
17388 @tab
17389
17390 Character
17391
17392 @item
17393
17394 @emph{COBOL_Character}
17395
17396 @tab
17397
17398 Character
17399
17400 @end multitable
17401
17402
17403 For initialization, see the file @code{i-cobol.ads} in the distributed library.
17404
17405
17406 @itemize *
17407
17408 @item
17409 "Support for access to machine instructions. See C.1(1)."
17410 @end itemize
17411
17412 See documentation in file @code{s-maccod.ads} in the distributed library.
17413
17414
17415 @itemize *
17416
17417 @item
17418 "Implementation-defined aspects of access to machine
17419 operations. See C.1(9)."
17420 @end itemize
17421
17422 See documentation in file @code{s-maccod.ads} in the distributed library.
17423
17424
17425 @itemize *
17426
17427 @item
17428 "Implementation-defined aspects of interrupts. See C.3(2)."
17429 @end itemize
17430
17431 Interrupts are mapped to signals or conditions as appropriate. See
17432 definition of unit
17433 @code{Ada.Interrupt_Names} in source file @code{a-intnam.ads} for details
17434 on the interrupts supported on a particular target.
17435
17436
17437 @itemize *
17438
17439 @item
17440 "Implementation-defined aspects of pre-elaboration. See
17441 C.4(13)."
17442 @end itemize
17443
17444 GNAT does not permit a partition to be restarted without reloading,
17445 except under control of the debugger.
17446
17447
17448 @itemize *
17449
17450 @item
17451 "The semantics of pragma @code{Discard_Names}. See C.5(7)."
17452 @end itemize
17453
17454 Pragma @code{Discard_Names} causes names of enumeration literals to
17455 be suppressed. In the presence of this pragma, the Image attribute
17456 provides the image of the Pos of the literal, and Value accepts
17457 Pos values.
17458
17459 For tagged types, when pragmas @code{Discard_Names} and @code{No_Tagged_Streams}
17460 simultaneously apply, their Expanded_Name and External_Tag are initialized
17461 with empty strings. This is useful to avoid exposing entity names at binary
17462 level.
17463
17464
17465 @itemize *
17466
17467 @item
17468 "The result of the @code{Task_Identification.Image}
17469 attribute. See C.7.1(7)."
17470 @end itemize
17471
17472 The result of this attribute is a string that identifies
17473 the object or component that denotes a given task. If a variable @code{Var}
17474 has a task type, the image for this task will have the form @code{Var_@emph{XXXXXXXX}},
17475 where the suffix @emph{XXXXXXXX}
17476 is the hexadecimal representation of the virtual address of the corresponding
17477 task control block. If the variable is an array of tasks, the image of each
17478 task will have the form of an indexed component indicating the position of a
17479 given task in the array, e.g., @code{Group(5)_@emph{XXXXXXX}}. If the task is a
17480 component of a record, the image of the task will have the form of a selected
17481 component. These rules are fully recursive, so that the image of a task that
17482 is a subcomponent of a composite object corresponds to the expression that
17483 designates this task.
17484
17485 If a task is created by an allocator, its image depends on the context. If the
17486 allocator is part of an object declaration, the rules described above are used
17487 to construct its image, and this image is not affected by subsequent
17488 assignments. If the allocator appears within an expression, the image
17489 includes only the name of the task type.
17490
17491 If the configuration pragma Discard_Names is present, or if the restriction
17492 No_Implicit_Heap_Allocation is in effect, the image reduces to
17493 the numeric suffix, that is to say the hexadecimal representation of the
17494 virtual address of the control block of the task.
17495
17496
17497 @itemize *
17498
17499 @item
17500 "The value of @code{Current_Task} when in a protected entry
17501 or interrupt handler. See C.7.1(17)."
17502 @end itemize
17503
17504 Protected entries or interrupt handlers can be executed by any
17505 convenient thread, so the value of @code{Current_Task} is undefined.
17506
17507
17508 @itemize *
17509
17510 @item
17511 "The effect of calling @code{Current_Task} from an entry
17512 body or interrupt handler. See C.7.1(19)."
17513 @end itemize
17514
17515 When GNAT can determine statically that @code{Current_Task} is called directly in
17516 the body of an entry (or barrier) then a warning is emitted and @code{Program_Error}
17517 is raised at run time. Otherwise, the effect of calling @code{Current_Task} from an
17518 entry body or interrupt handler is to return the identification of the task
17519 currently executing the code.
17520
17521
17522 @itemize *
17523
17524 @item
17525 "Implementation-defined aspects of
17526 @code{Task_Attributes}. See C.7.2(19)."
17527 @end itemize
17528
17529 There are no implementation-defined aspects of @code{Task_Attributes}.
17530
17531
17532 @itemize *
17533
17534 @item
17535 "Values of all @code{Metrics}. See D(2)."
17536 @end itemize
17537
17538 The metrics information for GNAT depends on the performance of the
17539 underlying operating system. The sources of the run-time for tasking
17540 implementation, together with the output from @emph{-gnatG} can be
17541 used to determine the exact sequence of operating systems calls made
17542 to implement various tasking constructs. Together with appropriate
17543 information on the performance of the underlying operating system,
17544 on the exact target in use, this information can be used to determine
17545 the required metrics.
17546
17547
17548 @itemize *
17549
17550 @item
17551 "The declarations of @code{Any_Priority} and
17552 @code{Priority}. See D.1(11)."
17553 @end itemize
17554
17555 See declarations in file @code{system.ads}.
17556
17557
17558 @itemize *
17559
17560 @item
17561 "Implementation-defined execution resources. See D.1(15)."
17562 @end itemize
17563
17564 There are no implementation-defined execution resources.
17565
17566
17567 @itemize *
17568
17569 @item
17570 "Whether, on a multiprocessor, a task that is waiting for
17571 access to a protected object keeps its processor busy. See D.2.1(3)."
17572 @end itemize
17573
17574 On a multi-processor, a task that is waiting for access to a protected
17575 object does not keep its processor busy.
17576
17577
17578 @itemize *
17579
17580 @item
17581 "The affect of implementation defined execution resources
17582 on task dispatching. See D.2.1(9)."
17583 @end itemize
17584
17585 Tasks map to threads in the threads package used by GNAT. Where possible
17586 and appropriate, these threads correspond to native threads of the
17587 underlying operating system.
17588
17589
17590 @itemize *
17591
17592 @item
17593 "Implementation-defined @emph{policy_identifiers} allowed
17594 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3)."
17595 @end itemize
17596
17597 There are no implementation-defined policy-identifiers allowed in this
17598 pragma.
17599
17600
17601 @itemize *
17602
17603 @item
17604 "Implementation-defined aspects of priority inversion. See
17605 D.2.2(16)."
17606 @end itemize
17607
17608 Execution of a task cannot be preempted by the implementation processing
17609 of delay expirations for lower priority tasks.
17610
17611
17612 @itemize *
17613
17614 @item
17615 "Implementation-defined task dispatching. See D.2.2(18)."
17616 @end itemize
17617
17618 The policy is the same as that of the underlying threads implementation.
17619
17620
17621 @itemize *
17622
17623 @item
17624 "Implementation-defined @emph{policy_identifiers} allowed
17625 in a pragma @code{Locking_Policy}. See D.3(4)."
17626 @end itemize
17627
17628 The two implementation defined policies permitted in GNAT are
17629 @code{Inheritance_Locking} and @code{Concurrent_Readers_Locking}. On
17630 targets that support the @code{Inheritance_Locking} policy, locking is
17631 implemented by inheritance, i.e., the task owning the lock operates
17632 at a priority equal to the highest priority of any task currently
17633 requesting the lock. On targets that support the
17634 @code{Concurrent_Readers_Locking} policy, locking is implemented with a
17635 read/write lock allowing multiple protected object functions to enter
17636 concurrently.
17637
17638
17639 @itemize *
17640
17641 @item
17642 "Default ceiling priorities. See D.3(10)."
17643 @end itemize
17644
17645 The ceiling priority of protected objects of the type
17646 @code{System.Interrupt_Priority'Last} as described in the Ada
17647 Reference Manual D.3(10),
17648
17649
17650 @itemize *
17651
17652 @item
17653 "The ceiling of any protected object used internally by
17654 the implementation. See D.3(16)."
17655 @end itemize
17656
17657 The ceiling priority of internal protected objects is
17658 @code{System.Priority'Last}.
17659
17660
17661 @itemize *
17662
17663 @item
17664 "Implementation-defined queuing policies. See D.4(1)."
17665 @end itemize
17666
17667 There are no implementation-defined queuing policies.
17668
17669
17670 @itemize *
17671
17672 @item
17673 "On a multiprocessor, any conditions that cause the
17674 completion of an aborted construct to be delayed later than what is
17675 specified for a single processor. See D.6(3)."
17676 @end itemize
17677
17678 The semantics for abort on a multi-processor is the same as on a single
17679 processor, there are no further delays.
17680
17681
17682 @itemize *
17683
17684 @item
17685 "Any operations that implicitly require heap storage
17686 allocation. See D.7(8)."
17687 @end itemize
17688
17689 The only operation that implicitly requires heap storage allocation is
17690 task creation.
17691
17692
17693 @itemize *
17694
17695 @item
17696 "What happens when a task terminates in the presence of
17697 pragma @code{No_Task_Termination}. See D.7(15)."
17698 @end itemize
17699
17700 Execution is erroneous in that case.
17701
17702
17703 @itemize *
17704
17705 @item
17706 "Implementation-defined aspects of pragma
17707 @code{Restrictions}. See D.7(20)."
17708 @end itemize
17709
17710 There are no such implementation-defined aspects.
17711
17712
17713 @itemize *
17714
17715 @item
17716 "Implementation-defined aspects of package
17717 @code{Real_Time}. See D.8(17)."
17718 @end itemize
17719
17720 There are no implementation defined aspects of package @code{Real_Time}.
17721
17722
17723 @itemize *
17724
17725 @item
17726 "Implementation-defined aspects of
17727 @emph{delay_statements}. See D.9(8)."
17728 @end itemize
17729
17730 Any difference greater than one microsecond will cause the task to be
17731 delayed (see D.9(7)).
17732
17733
17734 @itemize *
17735
17736 @item
17737 "The upper bound on the duration of interrupt blocking
17738 caused by the implementation. See D.12(5)."
17739 @end itemize
17740
17741 The upper bound is determined by the underlying operating system. In
17742 no cases is it more than 10 milliseconds.
17743
17744
17745 @itemize *
17746
17747 @item
17748 "The means for creating and executing distributed
17749 programs. See E(5)."
17750 @end itemize
17751
17752 The GLADE package provides a utility GNATDIST for creating and executing
17753 distributed programs. See the GLADE reference manual for further details.
17754
17755
17756 @itemize *
17757
17758 @item
17759 "Any events that can result in a partition becoming
17760 inaccessible. See E.1(7)."
17761 @end itemize
17762
17763 See the GLADE reference manual for full details on such events.
17764
17765
17766 @itemize *
17767
17768 @item
17769 "The scheduling policies, treatment of priorities, and
17770 management of shared resources between partitions in certain cases. See
17771 E.1(11)."
17772 @end itemize
17773
17774 See the GLADE reference manual for full details on these aspects of
17775 multi-partition execution.
17776
17777
17778 @itemize *
17779
17780 @item
17781 "Events that cause the version of a compilation unit to
17782 change. See E.3(5)."
17783 @end itemize
17784
17785 Editing the source file of a compilation unit, or the source files of
17786 any units on which it is dependent in a significant way cause the version
17787 to change. No other actions cause the version number to change. All changes
17788 are significant except those which affect only layout, capitalization or
17789 comments.
17790
17791
17792 @itemize *
17793
17794 @item
17795 "Whether the execution of the remote subprogram is
17796 immediately aborted as a result of cancellation. See E.4(13)."
17797 @end itemize
17798
17799 See the GLADE reference manual for details on the effect of abort in
17800 a distributed application.
17801
17802
17803 @itemize *
17804
17805 @item
17806 "Implementation-defined aspects of the PCS. See E.5(25)."
17807 @end itemize
17808
17809 See the GLADE reference manual for a full description of all implementation
17810 defined aspects of the PCS.
17811
17812
17813 @itemize *
17814
17815 @item
17816 "Implementation-defined interfaces in the PCS. See
17817 E.5(26)."
17818 @end itemize
17819
17820 See the GLADE reference manual for a full description of all
17821 implementation defined interfaces.
17822
17823
17824 @itemize *
17825
17826 @item
17827 "The values of named numbers in the package
17828 @code{Decimal}. See F.2(7)."
17829 @end itemize
17830
17831
17832 @multitable {xxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxx}
17833 @headitem
17834
17835 Named Number
17836
17837 @tab
17838
17839 Value
17840
17841 @item
17842
17843 @emph{Max_Scale}
17844
17845 @tab
17846
17847 +18
17848
17849 @item
17850
17851 @emph{Min_Scale}
17852
17853 @tab
17854
17855 -18
17856
17857 @item
17858
17859 @emph{Min_Delta}
17860
17861 @tab
17862
17863 1.0E-18
17864
17865 @item
17866
17867 @emph{Max_Delta}
17868
17869 @tab
17870
17871 1.0E+18
17872
17873 @item
17874
17875 @emph{Max_Decimal_Digits}
17876
17877 @tab
17878
17879 18
17880
17881 @end multitable
17882
17883
17884
17885 @itemize *
17886
17887 @item
17888 "The value of @code{Max_Picture_Length} in the package
17889 @code{Text_IO.Editing}. See F.3.3(16)."
17890 @end itemize
17891
17892 64
17893
17894
17895 @itemize *
17896
17897 @item
17898 "The value of @code{Max_Picture_Length} in the package
17899 @code{Wide_Text_IO.Editing}. See F.3.4(5)."
17900 @end itemize
17901
17902 64
17903
17904
17905 @itemize *
17906
17907 @item
17908 "The accuracy actually achieved by the complex elementary
17909 functions and by other complex arithmetic operations. See G.1(1)."
17910 @end itemize
17911
17912 Standard library functions are used for the complex arithmetic
17913 operations. Only fast math mode is currently supported.
17914
17915
17916 @itemize *
17917
17918 @item
17919 "The sign of a zero result (or a component thereof) from
17920 any operator or function in @code{Numerics.Generic_Complex_Types}, when
17921 @code{Real'Signed_Zeros} is True. See G.1.1(53)."
17922 @end itemize
17923
17924 The signs of zero values are as recommended by the relevant
17925 implementation advice.
17926
17927
17928 @itemize *
17929
17930 @item
17931 "The sign of a zero result (or a component thereof) from
17932 any operator or function in
17933 @code{Numerics.Generic_Complex_Elementary_Functions}, when
17934 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45)."
17935 @end itemize
17936
17937 The signs of zero values are as recommended by the relevant
17938 implementation advice.
17939
17940
17941 @itemize *
17942
17943 @item
17944 "Whether the strict mode or the relaxed mode is the
17945 default. See G.2(2)."
17946 @end itemize
17947
17948 The strict mode is the default. There is no separate relaxed mode. GNAT
17949 provides a highly efficient implementation of strict mode.
17950
17951
17952 @itemize *
17953
17954 @item
17955 "The result interval in certain cases of fixed-to-float
17956 conversion. See G.2.1(10)."
17957 @end itemize
17958
17959 For cases where the result interval is implementation dependent, the
17960 accuracy is that provided by performing all operations in 64-bit IEEE
17961 floating-point format.
17962
17963
17964 @itemize *
17965
17966 @item
17967 "The result of a floating point arithmetic operation in
17968 overflow situations, when the @code{Machine_Overflows} attribute of the
17969 result type is @code{False}. See G.2.1(13)."
17970 @end itemize
17971
17972 Infinite and NaN values are produced as dictated by the IEEE
17973 floating-point standard.
17974 Note that on machines that are not fully compliant with the IEEE
17975 floating-point standard, such as Alpha, the @emph{-mieee} compiler flag
17976 must be used for achieving IEEE conforming behavior (although at the cost
17977 of a significant performance penalty), so infinite and NaN values are
17978 properly generated.
17979
17980
17981 @itemize *
17982
17983 @item
17984 "The result interval for division (or exponentiation by a
17985 negative exponent), when the floating point hardware implements division
17986 as multiplication by a reciprocal. See G.2.1(16)."
17987 @end itemize
17988
17989 Not relevant, division is IEEE exact.
17990
17991
17992 @itemize *
17993
17994 @item
17995 "The definition of close result set, which determines the
17996 accuracy of certain fixed point multiplications and divisions. See
17997 G.2.3(5)."
17998 @end itemize
17999
18000 Operations in the close result set are performed using IEEE long format
18001 floating-point arithmetic. The input operands are converted to
18002 floating-point, the operation is done in floating-point, and the result
18003 is converted to the target type.
18004
18005
18006 @itemize *
18007
18008 @item
18009 "Conditions on a @emph{universal_real} operand of a fixed
18010 point multiplication or division for which the result shall be in the
18011 perfect result set. See G.2.3(22)."
18012 @end itemize
18013
18014 The result is only defined to be in the perfect result set if the result
18015 can be computed by a single scaling operation involving a scale factor
18016 representable in 64-bits.
18017
18018
18019 @itemize *
18020
18021 @item
18022 "The result of a fixed point arithmetic operation in
18023 overflow situations, when the @code{Machine_Overflows} attribute of the
18024 result type is @code{False}. See G.2.3(27)."
18025 @end itemize
18026
18027 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
18028 types.
18029
18030
18031 @itemize *
18032
18033 @item
18034 "The result of an elementary function reference in
18035 overflow situations, when the @code{Machine_Overflows} attribute of the
18036 result type is @code{False}. See G.2.4(4)."
18037 @end itemize
18038
18039 IEEE infinite and Nan values are produced as appropriate.
18040
18041
18042 @itemize *
18043
18044 @item
18045 "The value of the angle threshold, within which certain
18046 elementary functions, complex arithmetic operations, and complex
18047 elementary functions yield results conforming to a maximum relative
18048 error bound. See G.2.4(10)."
18049 @end itemize
18050
18051 Information on this subject is not yet available.
18052
18053
18054 @itemize *
18055
18056 @item
18057 "The accuracy of certain elementary functions for
18058 parameters beyond the angle threshold. See G.2.4(10)."
18059 @end itemize
18060
18061 Information on this subject is not yet available.
18062
18063
18064 @itemize *
18065
18066 @item
18067 "The result of a complex arithmetic operation or complex
18068 elementary function reference in overflow situations, when the
18069 @code{Machine_Overflows} attribute of the corresponding real type is
18070 @code{False}. See G.2.6(5)."
18071 @end itemize
18072
18073 IEEE infinite and Nan values are produced as appropriate.
18074
18075
18076 @itemize *
18077
18078 @item
18079 "The accuracy of certain complex arithmetic operations and
18080 certain complex elementary functions for parameters (or components
18081 thereof) beyond the angle threshold. See G.2.6(8)."
18082 @end itemize
18083
18084 Information on those subjects is not yet available.
18085
18086
18087 @itemize *
18088
18089 @item
18090 "Information regarding bounded errors and erroneous
18091 execution. See H.2(1)."
18092 @end itemize
18093
18094 Information on this subject is not yet available.
18095
18096
18097 @itemize *
18098
18099 @item
18100 "Implementation-defined aspects of pragma
18101 @code{Inspection_Point}. See H.3.2(8)."
18102 @end itemize
18103
18104 Pragma @code{Inspection_Point} ensures that the variable is live and can
18105 be examined by the debugger at the inspection point.
18106
18107
18108 @itemize *
18109
18110 @item
18111 "Implementation-defined aspects of pragma
18112 @code{Restrictions}. See H.4(25)."
18113 @end itemize
18114
18115 There are no implementation-defined aspects of pragma @code{Restrictions}. The
18116 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
18117 generated code. Checks must suppressed by use of pragma @code{Suppress}.
18118
18119
18120 @itemize *
18121
18122 @item
18123 "Any restrictions on pragma @code{Restrictions}. See
18124 H.4(27)."
18125 @end itemize
18126
18127 There are no restrictions on pragma @code{Restrictions}.
18128
18129 @node Intrinsic Subprograms,Representation Clauses and Pragmas,Implementation Defined Characteristics,Top
18130 @anchor{gnat_rm/intrinsic_subprograms doc}@anchor{25a}@anchor{gnat_rm/intrinsic_subprograms intrinsic-subprograms}@anchor{c}@anchor{gnat_rm/intrinsic_subprograms id1}@anchor{25b}
18131 @chapter Intrinsic Subprograms
18132
18133
18134 @geindex Intrinsic Subprograms
18135
18136 GNAT allows a user application program to write the declaration:
18137
18138 @example
18139 pragma Import (Intrinsic, name);
18140 @end example
18141
18142 providing that the name corresponds to one of the implemented intrinsic
18143 subprograms in GNAT, and that the parameter profile of the referenced
18144 subprogram meets the requirements. This chapter describes the set of
18145 implemented intrinsic subprograms, and the requirements on parameter profiles.
18146 Note that no body is supplied; as with other uses of pragma Import, the
18147 body is supplied elsewhere (in this case by the compiler itself). Note
18148 that any use of this feature is potentially non-portable, since the
18149 Ada standard does not require Ada compilers to implement this feature.
18150
18151 @menu
18152 * Intrinsic Operators::
18153 * Compilation_ISO_Date::
18154 * Compilation_Date::
18155 * Compilation_Time::
18156 * Enclosing_Entity::
18157 * Exception_Information::
18158 * Exception_Message::
18159 * Exception_Name::
18160 * File::
18161 * Line::
18162 * Shifts and Rotates::
18163 * Source_Location::
18164
18165 @end menu
18166
18167 @node Intrinsic Operators,Compilation_ISO_Date,,Intrinsic Subprograms
18168 @anchor{gnat_rm/intrinsic_subprograms id2}@anchor{25c}@anchor{gnat_rm/intrinsic_subprograms intrinsic-operators}@anchor{25d}
18169 @section Intrinsic Operators
18170
18171
18172 @geindex Intrinsic operator
18173
18174 All the predefined numeric operators in package Standard
18175 in @code{pragma Import (Intrinsic,..)}
18176 declarations. In the binary operator case, the operands must have the same
18177 size. The operand or operands must also be appropriate for
18178 the operator. For example, for addition, the operands must
18179 both be floating-point or both be fixed-point, and the
18180 right operand for @code{"**"} must have a root type of
18181 @code{Standard.Integer'Base}.
18182 You can use an intrinsic operator declaration as in the following example:
18183
18184 @example
18185 type Int1 is new Integer;
18186 type Int2 is new Integer;
18187
18188 function "+" (X1 : Int1; X2 : Int2) return Int1;
18189 function "+" (X1 : Int1; X2 : Int2) return Int2;
18190 pragma Import (Intrinsic, "+");
18191 @end example
18192
18193 This declaration would permit 'mixed mode' arithmetic on items
18194 of the differing types @code{Int1} and @code{Int2}.
18195 It is also possible to specify such operators for private types, if the
18196 full views are appropriate arithmetic types.
18197
18198 @node Compilation_ISO_Date,Compilation_Date,Intrinsic Operators,Intrinsic Subprograms
18199 @anchor{gnat_rm/intrinsic_subprograms id3}@anchor{25e}@anchor{gnat_rm/intrinsic_subprograms compilation-iso-date}@anchor{25f}
18200 @section Compilation_ISO_Date
18201
18202
18203 @geindex Compilation_ISO_Date
18204
18205 This intrinsic subprogram is used in the implementation of the
18206 library package @code{GNAT.Source_Info}. The only useful use of the
18207 intrinsic import in this case is the one in this unit, so an
18208 application program should simply call the function
18209 @code{GNAT.Source_Info.Compilation_ISO_Date} to obtain the date of
18210 the current compilation (in local time format YYYY-MM-DD).
18211
18212 @node Compilation_Date,Compilation_Time,Compilation_ISO_Date,Intrinsic Subprograms
18213 @anchor{gnat_rm/intrinsic_subprograms compilation-date}@anchor{260}@anchor{gnat_rm/intrinsic_subprograms id4}@anchor{261}
18214 @section Compilation_Date
18215
18216
18217 @geindex Compilation_Date
18218
18219 Same as Compilation_ISO_Date, except the string is in the form
18220 MMM DD YYYY.
18221
18222 @node Compilation_Time,Enclosing_Entity,Compilation_Date,Intrinsic Subprograms
18223 @anchor{gnat_rm/intrinsic_subprograms compilation-time}@anchor{262}@anchor{gnat_rm/intrinsic_subprograms id5}@anchor{263}
18224 @section Compilation_Time
18225
18226
18227 @geindex Compilation_Time
18228
18229 This intrinsic subprogram is used in the implementation of the
18230 library package @code{GNAT.Source_Info}. The only useful use of the
18231 intrinsic import in this case is the one in this unit, so an
18232 application program should simply call the function
18233 @code{GNAT.Source_Info.Compilation_Time} to obtain the time of
18234 the current compilation (in local time format HH:MM:SS).
18235
18236 @node Enclosing_Entity,Exception_Information,Compilation_Time,Intrinsic Subprograms
18237 @anchor{gnat_rm/intrinsic_subprograms id6}@anchor{264}@anchor{gnat_rm/intrinsic_subprograms enclosing-entity}@anchor{265}
18238 @section Enclosing_Entity
18239
18240
18241 @geindex Enclosing_Entity
18242
18243 This intrinsic subprogram is used in the implementation of the
18244 library package @code{GNAT.Source_Info}. The only useful use of the
18245 intrinsic import in this case is the one in this unit, so an
18246 application program should simply call the function
18247 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
18248 the current subprogram, package, task, entry, or protected subprogram.
18249
18250 @node Exception_Information,Exception_Message,Enclosing_Entity,Intrinsic Subprograms
18251 @anchor{gnat_rm/intrinsic_subprograms id7}@anchor{266}@anchor{gnat_rm/intrinsic_subprograms exception-information}@anchor{267}
18252 @section Exception_Information
18253
18254
18255 @geindex Exception_Information'
18256
18257 This intrinsic subprogram is used in the implementation of the
18258 library package @code{GNAT.Current_Exception}. The only useful
18259 use of the intrinsic import in this case is the one in this unit,
18260 so an application program should simply call the function
18261 @code{GNAT.Current_Exception.Exception_Information} to obtain
18262 the exception information associated with the current exception.
18263
18264 @node Exception_Message,Exception_Name,Exception_Information,Intrinsic Subprograms
18265 @anchor{gnat_rm/intrinsic_subprograms exception-message}@anchor{268}@anchor{gnat_rm/intrinsic_subprograms id8}@anchor{269}
18266 @section Exception_Message
18267
18268
18269 @geindex Exception_Message
18270
18271 This intrinsic subprogram is used in the implementation of the
18272 library package @code{GNAT.Current_Exception}. The only useful
18273 use of the intrinsic import in this case is the one in this unit,
18274 so an application program should simply call the function
18275 @code{GNAT.Current_Exception.Exception_Message} to obtain
18276 the message associated with the current exception.
18277
18278 @node Exception_Name,File,Exception_Message,Intrinsic Subprograms
18279 @anchor{gnat_rm/intrinsic_subprograms exception-name}@anchor{26a}@anchor{gnat_rm/intrinsic_subprograms id9}@anchor{26b}
18280 @section Exception_Name
18281
18282
18283 @geindex Exception_Name
18284
18285 This intrinsic subprogram is used in the implementation of the
18286 library package @code{GNAT.Current_Exception}. The only useful
18287 use of the intrinsic import in this case is the one in this unit,
18288 so an application program should simply call the function
18289 @code{GNAT.Current_Exception.Exception_Name} to obtain
18290 the name of the current exception.
18291
18292 @node File,Line,Exception_Name,Intrinsic Subprograms
18293 @anchor{gnat_rm/intrinsic_subprograms id10}@anchor{26c}@anchor{gnat_rm/intrinsic_subprograms file}@anchor{26d}
18294 @section File
18295
18296
18297 @geindex File
18298
18299 This intrinsic subprogram is used in the implementation of the
18300 library package @code{GNAT.Source_Info}. The only useful use of the
18301 intrinsic import in this case is the one in this unit, so an
18302 application program should simply call the function
18303 @code{GNAT.Source_Info.File} to obtain the name of the current
18304 file.
18305
18306 @node Line,Shifts and Rotates,File,Intrinsic Subprograms
18307 @anchor{gnat_rm/intrinsic_subprograms id11}@anchor{26e}@anchor{gnat_rm/intrinsic_subprograms line}@anchor{26f}
18308 @section Line
18309
18310
18311 @geindex Line
18312
18313 This intrinsic subprogram is used in the implementation of the
18314 library package @code{GNAT.Source_Info}. The only useful use of the
18315 intrinsic import in this case is the one in this unit, so an
18316 application program should simply call the function
18317 @code{GNAT.Source_Info.Line} to obtain the number of the current
18318 source line.
18319
18320 @node Shifts and Rotates,Source_Location,Line,Intrinsic Subprograms
18321 @anchor{gnat_rm/intrinsic_subprograms shifts-and-rotates}@anchor{270}@anchor{gnat_rm/intrinsic_subprograms id12}@anchor{271}
18322 @section Shifts and Rotates
18323
18324
18325 @geindex Shift_Left
18326
18327 @geindex Shift_Right
18328
18329 @geindex Shift_Right_Arithmetic
18330
18331 @geindex Rotate_Left
18332
18333 @geindex Rotate_Right
18334
18335 In standard Ada, the shift and rotate functions are available only
18336 for the predefined modular types in package @code{Interfaces}. However, in
18337 GNAT it is possible to define these functions for any integer
18338 type (signed or modular), as in this example:
18339
18340 @example
18341 function Shift_Left
18342 (Value : T;
18343 Amount : Natural) return T;
18344 @end example
18345
18346 The function name must be one of
18347 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
18348 Rotate_Right. T must be an integer type. T'Size must be
18349 8, 16, 32 or 64 bits; if T is modular, the modulus
18350 must be 2**8, 2**16, 2**32 or 2**64.
18351 The result type must be the same as the type of @code{Value}.
18352 The shift amount must be Natural.
18353 The formal parameter names can be anything.
18354
18355 A more convenient way of providing these shift operators is to use
18356 the Provide_Shift_Operators pragma, which provides the function declarations
18357 and corresponding pragma Import's for all five shift functions.
18358
18359 @node Source_Location,,Shifts and Rotates,Intrinsic Subprograms
18360 @anchor{gnat_rm/intrinsic_subprograms source-location}@anchor{272}@anchor{gnat_rm/intrinsic_subprograms id13}@anchor{273}
18361 @section Source_Location
18362
18363
18364 @geindex Source_Location
18365
18366 This intrinsic subprogram is used in the implementation of the
18367 library routine @code{GNAT.Source_Info}. The only useful use of the
18368 intrinsic import in this case is the one in this unit, so an
18369 application program should simply call the function
18370 @code{GNAT.Source_Info.Source_Location} to obtain the current
18371 source file location.
18372
18373 @node Representation Clauses and Pragmas,Standard Library Routines,Intrinsic Subprograms,Top
18374 @anchor{gnat_rm/representation_clauses_and_pragmas representation-clauses-and-pragmas}@anchor{d}@anchor{gnat_rm/representation_clauses_and_pragmas doc}@anchor{274}@anchor{gnat_rm/representation_clauses_and_pragmas id1}@anchor{275}
18375 @chapter Representation Clauses and Pragmas
18376
18377
18378 @geindex Representation Clauses
18379
18380 @geindex Representation Clause
18381
18382 @geindex Representation Pragma
18383
18384 @geindex Pragma
18385 @geindex representation
18386
18387 This section describes the representation clauses accepted by GNAT, and
18388 their effect on the representation of corresponding data objects.
18389
18390 GNAT fully implements Annex C (Systems Programming). This means that all
18391 the implementation advice sections in chapter 13 are fully implemented.
18392 However, these sections only require a minimal level of support for
18393 representation clauses. GNAT provides much more extensive capabilities,
18394 and this section describes the additional capabilities provided.
18395
18396 @menu
18397 * Alignment Clauses::
18398 * Size Clauses::
18399 * Storage_Size Clauses::
18400 * Size of Variant Record Objects::
18401 * Biased Representation::
18402 * Value_Size and Object_Size Clauses::
18403 * Component_Size Clauses::
18404 * Bit_Order Clauses::
18405 * Effect of Bit_Order on Byte Ordering::
18406 * Pragma Pack for Arrays::
18407 * Pragma Pack for Records::
18408 * Record Representation Clauses::
18409 * Handling of Records with Holes::
18410 * Enumeration Clauses::
18411 * Address Clauses::
18412 * Use of Address Clauses for Memory-Mapped I/O::
18413 * Effect of Convention on Representation::
18414 * Conventions and Anonymous Access Types::
18415 * Determining the Representations chosen by GNAT::
18416
18417 @end menu
18418
18419 @node Alignment Clauses,Size Clauses,,Representation Clauses and Pragmas
18420 @anchor{gnat_rm/representation_clauses_and_pragmas id2}@anchor{276}@anchor{gnat_rm/representation_clauses_and_pragmas alignment-clauses}@anchor{277}
18421 @section Alignment Clauses
18422
18423
18424 @geindex Alignment Clause
18425
18426 GNAT requires that all alignment clauses specify 0 or a power of 2, and
18427 all default alignments are always a power of 2. Specifying 0 is the
18428 same as specifying 1.
18429
18430 The default alignment values are as follows:
18431
18432
18433 @itemize *
18434
18435 @item
18436 @emph{Elementary Types}.
18437
18438 For elementary types, the alignment is the minimum of the actual size of
18439 objects of the type divided by @code{Storage_Unit},
18440 and the maximum alignment supported by the target.
18441 (This maximum alignment is given by the GNAT-specific attribute
18442 @code{Standard'Maximum_Alignment}; see @ref{191,,Attribute Maximum_Alignment}.)
18443
18444 @geindex Maximum_Alignment attribute
18445
18446 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
18447 default alignment will be 8 on any target that supports alignments
18448 this large, but on some targets, the maximum alignment may be smaller
18449 than 8, in which case objects of type @code{Long_Float} will be maximally
18450 aligned.
18451
18452 @item
18453 @emph{Arrays}.
18454
18455 For arrays, the alignment is equal to the alignment of the component type
18456 for the normal case where no packing or component size is given. If the
18457 array is packed, and the packing is effective (see separate section on
18458 packed arrays), then the alignment will be either 4, 2, or 1 for long packed
18459 arrays or arrays whose length is not known at compile time, depending on
18460 whether the component size is divisible by 4, 2, or is odd. For short packed
18461 arrays, which are handled internally as modular types, the alignment
18462 will be as described for elementary types, e.g. a packed array of length
18463 31 bits will have an object size of four bytes, and an alignment of 4.
18464
18465 @item
18466 @emph{Records}.
18467
18468 For the normal unpacked case, the alignment of a record is equal to
18469 the maximum alignment of any of its components. For tagged records, this
18470 includes the implicit access type used for the tag. If a pragma @code{Pack}
18471 is used and all components are packable (see separate section on pragma
18472 @code{Pack}), then the resulting alignment is 1, unless the layout of the
18473 record makes it profitable to increase it.
18474
18475 A special case is when:
18476
18477
18478 @itemize *
18479
18480 @item
18481 the size of the record is given explicitly, or a
18482 full record representation clause is given, and
18483
18484 @item
18485 the size of the record is 2, 4, or 8 bytes.
18486 @end itemize
18487
18488 In this case, an alignment is chosen to match the
18489 size of the record. For example, if we have:
18490
18491 @example
18492 type Small is record
18493 A, B : Character;
18494 end record;
18495 for Small'Size use 16;
18496 @end example
18497
18498 then the default alignment of the record type @code{Small} is 2, not 1. This
18499 leads to more efficient code when the record is treated as a unit, and also
18500 allows the type to specified as @code{Atomic} on architectures requiring
18501 strict alignment.
18502 @end itemize
18503
18504 An alignment clause may specify a larger alignment than the default value
18505 up to some maximum value dependent on the target (obtainable by using the
18506 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
18507 a smaller alignment than the default value for enumeration, integer and
18508 fixed point types, as well as for record types, for example
18509
18510 @example
18511 type V is record
18512 A : Integer;
18513 end record;
18514
18515 for V'alignment use 1;
18516 @end example
18517
18518 @geindex Alignment
18519 @geindex default
18520
18521 The default alignment for the type @code{V} is 4, as a result of the
18522 Integer field in the record, but it is permissible, as shown, to
18523 override the default alignment of the record with a smaller value.
18524
18525 @geindex Alignment
18526 @geindex subtypes
18527
18528 Note that according to the Ada standard, an alignment clause applies only
18529 to the first named subtype. If additional subtypes are declared, then the
18530 compiler is allowed to choose any alignment it likes, and there is no way
18531 to control this choice. Consider:
18532
18533 @example
18534 type R is range 1 .. 10_000;
18535 for R'Alignment use 1;
18536 subtype RS is R range 1 .. 1000;
18537 @end example
18538
18539 The alignment clause specifies an alignment of 1 for the first named subtype
18540 @code{R} but this does not necessarily apply to @code{RS}. When writing
18541 portable Ada code, you should avoid writing code that explicitly or
18542 implicitly relies on the alignment of such subtypes.
18543
18544 For the GNAT compiler, if an explicit alignment clause is given, this
18545 value is also used for any subsequent subtypes. So for GNAT, in the
18546 above example, you can count on the alignment of @code{RS} being 1. But this
18547 assumption is non-portable, and other compilers may choose different
18548 alignments for the subtype @code{RS}.
18549
18550 @node Size Clauses,Storage_Size Clauses,Alignment Clauses,Representation Clauses and Pragmas
18551 @anchor{gnat_rm/representation_clauses_and_pragmas id3}@anchor{278}@anchor{gnat_rm/representation_clauses_and_pragmas size-clauses}@anchor{279}
18552 @section Size Clauses
18553
18554
18555 @geindex Size Clause
18556
18557 The default size for a type @code{T} is obtainable through the
18558 language-defined attribute @code{T'Size} and also through the
18559 equivalent GNAT-defined attribute @code{T'Value_Size}.
18560 For objects of type @code{T}, GNAT will generally increase the type size
18561 so that the object size (obtainable through the GNAT-defined attribute
18562 @code{T'Object_Size})
18563 is a multiple of @code{T'Alignment * Storage_Unit}.
18564
18565 For example:
18566
18567 @example
18568 type Smallint is range 1 .. 6;
18569
18570 type Rec is record
18571 Y1 : integer;
18572 Y2 : boolean;
18573 end record;
18574 @end example
18575
18576 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
18577 as specified by the RM rules,
18578 but objects of this type will have a size of 8
18579 (@code{Smallint'Object_Size} = 8),
18580 since objects by default occupy an integral number
18581 of storage units. On some targets, notably older
18582 versions of the Digital Alpha, the size of stand
18583 alone objects of this type may be 32, reflecting
18584 the inability of the hardware to do byte load/stores.
18585
18586 Similarly, the size of type @code{Rec} is 40 bits
18587 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
18588 the alignment is 4, so objects of this type will have
18589 their size increased to 64 bits so that it is a multiple
18590 of the alignment (in bits). This decision is
18591 in accordance with the specific Implementation Advice in RM 13.3(43):
18592
18593 @quotation
18594
18595 "A @code{Size} clause should be supported for an object if the specified
18596 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
18597 to a size in storage elements that is a multiple of the object's
18598 @code{Alignment} (if the @code{Alignment} is nonzero)."
18599 @end quotation
18600
18601 An explicit size clause may be used to override the default size by
18602 increasing it. For example, if we have:
18603
18604 @example
18605 type My_Boolean is new Boolean;
18606 for My_Boolean'Size use 32;
18607 @end example
18608
18609 then values of this type will always be 32 bits long. In the case of
18610 discrete types, the size can be increased up to 64 bits, with the effect
18611 that the entire specified field is used to hold the value, sign- or
18612 zero-extended as appropriate. If more than 64 bits is specified, then
18613 padding space is allocated after the value, and a warning is issued that
18614 there are unused bits.
18615
18616 Similarly the size of records and arrays may be increased, and the effect
18617 is to add padding bits after the value. This also causes a warning message
18618 to be generated.
18619
18620 The largest Size value permitted in GNAT is 2**31-1. Since this is a
18621 Size in bits, this corresponds to an object of size 256 megabytes (minus
18622 one). This limitation is true on all targets. The reason for this
18623 limitation is that it improves the quality of the code in many cases
18624 if it is known that a Size value can be accommodated in an object of
18625 type Integer.
18626
18627 @node Storage_Size Clauses,Size of Variant Record Objects,Size Clauses,Representation Clauses and Pragmas
18628 @anchor{gnat_rm/representation_clauses_and_pragmas storage-size-clauses}@anchor{27a}@anchor{gnat_rm/representation_clauses_and_pragmas id4}@anchor{27b}
18629 @section Storage_Size Clauses
18630
18631
18632 @geindex Storage_Size Clause
18633
18634 For tasks, the @code{Storage_Size} clause specifies the amount of space
18635 to be allocated for the task stack. This cannot be extended, and if the
18636 stack is exhausted, then @code{Storage_Error} will be raised (if stack
18637 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
18638 or a @code{Storage_Size} pragma in the task definition to set the
18639 appropriate required size. A useful technique is to include in every
18640 task definition a pragma of the form:
18641
18642 @example
18643 pragma Storage_Size (Default_Stack_Size);
18644 @end example
18645
18646 Then @code{Default_Stack_Size} can be defined in a global package, and
18647 modified as required. Any tasks requiring stack sizes different from the
18648 default can have an appropriate alternative reference in the pragma.
18649
18650 You can also use the @emph{-d} binder switch to modify the default stack
18651 size.
18652
18653 For access types, the @code{Storage_Size} clause specifies the maximum
18654 space available for allocation of objects of the type. If this space is
18655 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
18656 In the case where the access type is declared local to a subprogram, the
18657 use of a @code{Storage_Size} clause triggers automatic use of a special
18658 predefined storage pool (@code{System.Pool_Size}) that ensures that all
18659 space for the pool is automatically reclaimed on exit from the scope in
18660 which the type is declared.
18661
18662 A special case recognized by the compiler is the specification of a
18663 @code{Storage_Size} of zero for an access type. This means that no
18664 items can be allocated from the pool, and this is recognized at compile
18665 time, and all the overhead normally associated with maintaining a fixed
18666 size storage pool is eliminated. Consider the following example:
18667
18668 @example
18669 procedure p is
18670 type R is array (Natural) of Character;
18671 type P is access all R;
18672 for P'Storage_Size use 0;
18673 -- Above access type intended only for interfacing purposes
18674
18675 y : P;
18676
18677 procedure g (m : P);
18678 pragma Import (C, g);
18679
18680 -- ...
18681
18682 begin
18683 -- ...
18684 y := new R;
18685 end;
18686 @end example
18687
18688 As indicated in this example, these dummy storage pools are often useful in
18689 connection with interfacing where no object will ever be allocated. If you
18690 compile the above example, you get the warning:
18691
18692 @example
18693 p.adb:16:09: warning: allocation from empty storage pool
18694 p.adb:16:09: warning: Storage_Error will be raised at run time
18695 @end example
18696
18697 Of course in practice, there will not be any explicit allocators in the
18698 case of such an access declaration.
18699
18700 @node Size of Variant Record Objects,Biased Representation,Storage_Size Clauses,Representation Clauses and Pragmas
18701 @anchor{gnat_rm/representation_clauses_and_pragmas id5}@anchor{27c}@anchor{gnat_rm/representation_clauses_and_pragmas size-of-variant-record-objects}@anchor{27d}
18702 @section Size of Variant Record Objects
18703
18704
18705 @geindex Size
18706 @geindex variant record objects
18707
18708 @geindex Variant record objects
18709 @geindex size
18710
18711 In the case of variant record objects, there is a question whether Size gives
18712 information about a particular variant, or the maximum size required
18713 for any variant. Consider the following program
18714
18715 @example
18716 with Text_IO; use Text_IO;
18717 procedure q is
18718 type R1 (A : Boolean := False) is record
18719 case A is
18720 when True => X : Character;
18721 when False => null;
18722 end case;
18723 end record;
18724
18725 V1 : R1 (False);
18726 V2 : R1;
18727
18728 begin
18729 Put_Line (Integer'Image (V1'Size));
18730 Put_Line (Integer'Image (V2'Size));
18731 end q;
18732 @end example
18733
18734 Here we are dealing with a variant record, where the True variant
18735 requires 16 bits, and the False variant requires 8 bits.
18736 In the above example, both V1 and V2 contain the False variant,
18737 which is only 8 bits long. However, the result of running the
18738 program is:
18739
18740 @example
18741 8
18742 16
18743 @end example
18744
18745 The reason for the difference here is that the discriminant value of
18746 V1 is fixed, and will always be False. It is not possible to assign
18747 a True variant value to V1, therefore 8 bits is sufficient. On the
18748 other hand, in the case of V2, the initial discriminant value is
18749 False (from the default), but it is possible to assign a True
18750 variant value to V2, therefore 16 bits must be allocated for V2
18751 in the general case, even fewer bits may be needed at any particular
18752 point during the program execution.
18753
18754 As can be seen from the output of this program, the @code{'Size}
18755 attribute applied to such an object in GNAT gives the actual allocated
18756 size of the variable, which is the largest size of any of the variants.
18757 The Ada Reference Manual is not completely clear on what choice should
18758 be made here, but the GNAT behavior seems most consistent with the
18759 language in the RM.
18760
18761 In some cases, it may be desirable to obtain the size of the current
18762 variant, rather than the size of the largest variant. This can be
18763 achieved in GNAT by making use of the fact that in the case of a
18764 subprogram parameter, GNAT does indeed return the size of the current
18765 variant (because a subprogram has no way of knowing how much space
18766 is actually allocated for the actual).
18767
18768 Consider the following modified version of the above program:
18769
18770 @example
18771 with Text_IO; use Text_IO;
18772 procedure q is
18773 type R1 (A : Boolean := False) is record
18774 case A is
18775 when True => X : Character;
18776 when False => null;
18777 end case;
18778 end record;
18779
18780 V2 : R1;
18781
18782 function Size (V : R1) return Integer is
18783 begin
18784 return V'Size;
18785 end Size;
18786
18787 begin
18788 Put_Line (Integer'Image (V2'Size));
18789 Put_Line (Integer'Image (Size (V2)));
18790 V2 := (True, 'x');
18791 Put_Line (Integer'Image (V2'Size));
18792 Put_Line (Integer'Image (Size (V2)));
18793 end q;
18794 @end example
18795
18796 The output from this program is
18797
18798 @example
18799 16
18800 8
18801 16
18802 16
18803 @end example
18804
18805 Here we see that while the @code{'Size} attribute always returns
18806 the maximum size, regardless of the current variant value, the
18807 @code{Size} function does indeed return the size of the current
18808 variant value.
18809
18810 @node Biased Representation,Value_Size and Object_Size Clauses,Size of Variant Record Objects,Representation Clauses and Pragmas
18811 @anchor{gnat_rm/representation_clauses_and_pragmas id6}@anchor{27e}@anchor{gnat_rm/representation_clauses_and_pragmas biased-representation}@anchor{27f}
18812 @section Biased Representation
18813
18814
18815 @geindex Size for biased representation
18816
18817 @geindex Biased representation
18818
18819 In the case of scalars with a range starting at other than zero, it is
18820 possible in some cases to specify a size smaller than the default minimum
18821 value, and in such cases, GNAT uses an unsigned biased representation,
18822 in which zero is used to represent the lower bound, and successive values
18823 represent successive values of the type.
18824
18825 For example, suppose we have the declaration:
18826
18827 @example
18828 type Small is range -7 .. -4;
18829 for Small'Size use 2;
18830 @end example
18831
18832 Although the default size of type @code{Small} is 4, the @code{Size}
18833 clause is accepted by GNAT and results in the following representation
18834 scheme:
18835
18836 @example
18837 -7 is represented as 2#00#
18838 -6 is represented as 2#01#
18839 -5 is represented as 2#10#
18840 -4 is represented as 2#11#
18841 @end example
18842
18843 Biased representation is only used if the specified @code{Size} clause
18844 cannot be accepted in any other manner. These reduced sizes that force
18845 biased representation can be used for all discrete types except for
18846 enumeration types for which a representation clause is given.
18847
18848 @node Value_Size and Object_Size Clauses,Component_Size Clauses,Biased Representation,Representation Clauses and Pragmas
18849 @anchor{gnat_rm/representation_clauses_and_pragmas id7}@anchor{280}@anchor{gnat_rm/representation_clauses_and_pragmas value-size-and-object-size-clauses}@anchor{281}
18850 @section Value_Size and Object_Size Clauses
18851
18852
18853 @geindex Value_Size
18854
18855 @geindex Object_Size
18856
18857 @geindex Size
18858 @geindex of objects
18859
18860 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
18861 number of bits required to hold values of type @code{T}.
18862 Although this interpretation was allowed in Ada 83, it was not required,
18863 and this requirement in practice can cause some significant difficulties.
18864 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
18865 However, in Ada 95 and Ada 2005,
18866 @code{Natural'Size} is
18867 typically 31. This means that code may change in behavior when moving
18868 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
18869
18870 @example
18871 type Rec is record;
18872 A : Natural;
18873 B : Natural;
18874 end record;
18875
18876 for Rec use record
18877 at 0 range 0 .. Natural'Size - 1;
18878 at 0 range Natural'Size .. 2 * Natural'Size - 1;
18879 end record;
18880 @end example
18881
18882 In the above code, since the typical size of @code{Natural} objects
18883 is 32 bits and @code{Natural'Size} is 31, the above code can cause
18884 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
18885 there are cases where the fact that the object size can exceed the
18886 size of the type causes surprises.
18887
18888 To help get around this problem GNAT provides two implementation
18889 defined attributes, @code{Value_Size} and @code{Object_Size}. When
18890 applied to a type, these attributes yield the size of the type
18891 (corresponding to the RM defined size attribute), and the size of
18892 objects of the type respectively.
18893
18894 The @code{Object_Size} is used for determining the default size of
18895 objects and components. This size value can be referred to using the
18896 @code{Object_Size} attribute. The phrase 'is used' here means that it is
18897 the basis of the determination of the size. The backend is free to
18898 pad this up if necessary for efficiency, e.g., an 8-bit stand-alone
18899 character might be stored in 32 bits on a machine with no efficient
18900 byte access instructions such as the Alpha.
18901
18902 The default rules for the value of @code{Object_Size} for
18903 discrete types are as follows:
18904
18905
18906 @itemize *
18907
18908 @item
18909 The @code{Object_Size} for base subtypes reflect the natural hardware
18910 size in bits (run the compiler with @emph{-gnatS} to find those values
18911 for numeric types). Enumeration types and fixed-point base subtypes have
18912 8, 16, 32, or 64 bits for this size, depending on the range of values
18913 to be stored.
18914
18915 @item
18916 The @code{Object_Size} of a subtype is the same as the
18917 @code{Object_Size} of
18918 the type from which it is obtained.
18919
18920 @item
18921 The @code{Object_Size} of a derived base type is copied from the parent
18922 base type, and the @code{Object_Size} of a derived first subtype is copied
18923 from the parent first subtype.
18924 @end itemize
18925
18926 The @code{Value_Size} attribute
18927 is the (minimum) number of bits required to store a value
18928 of the type.
18929 This value is used to determine how tightly to pack
18930 records or arrays with components of this type, and also affects
18931 the semantics of unchecked conversion (unchecked conversions where
18932 the @code{Value_Size} values differ generate a warning, and are potentially
18933 target dependent).
18934
18935 The default rules for the value of @code{Value_Size} are as follows:
18936
18937
18938 @itemize *
18939
18940 @item
18941 The @code{Value_Size} for a base subtype is the minimum number of bits
18942 required to store all values of the type (including the sign bit
18943 only if negative values are possible).
18944
18945 @item
18946 If a subtype statically matches the first subtype of a given type, then it has
18947 by default the same @code{Value_Size} as the first subtype. This is a
18948 consequence of RM 13.1(14): "if two subtypes statically match,
18949 then their subtype-specific aspects are the same".)
18950
18951 @item
18952 All other subtypes have a @code{Value_Size} corresponding to the minimum
18953 number of bits required to store all values of the subtype. For
18954 dynamic bounds, it is assumed that the value can range down or up
18955 to the corresponding bound of the ancestor
18956 @end itemize
18957
18958 The RM defined attribute @code{Size} corresponds to the
18959 @code{Value_Size} attribute.
18960
18961 The @code{Size} attribute may be defined for a first-named subtype. This sets
18962 the @code{Value_Size} of
18963 the first-named subtype to the given value, and the
18964 @code{Object_Size} of this first-named subtype to the given value padded up
18965 to an appropriate boundary. It is a consequence of the default rules
18966 above that this @code{Object_Size} will apply to all further subtypes. On the
18967 other hand, @code{Value_Size} is affected only for the first subtype, any
18968 dynamic subtypes obtained from it directly, and any statically matching
18969 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
18970
18971 @code{Value_Size} and
18972 @code{Object_Size} may be explicitly set for any subtype using
18973 an attribute definition clause. Note that the use of these attributes
18974 can cause the RM 13.1(14) rule to be violated. If two access types
18975 reference aliased objects whose subtypes have differing @code{Object_Size}
18976 values as a result of explicit attribute definition clauses, then it
18977 is illegal to convert from one access subtype to the other. For a more
18978 complete description of this additional legality rule, see the
18979 description of the @code{Object_Size} attribute.
18980
18981 To get a feel for the difference, consider the following examples (note
18982 that in each case the base is @code{Short_Short_Integer} with a size of 8):
18983
18984
18985 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxx}
18986 @headitem
18987
18988 Type or subtype declaration
18989
18990 @tab
18991
18992 Object_Size
18993
18994 @tab
18995
18996 Value_Size
18997
18998 @item
18999
19000 @code{type x1 is range 0 .. 5;}
19001
19002 @tab
19003
19004 8
19005
19006 @tab
19007
19008 3
19009
19010 @item
19011
19012 @code{type x2 is range 0 .. 5;}
19013 @code{for x2'size use 12;}
19014
19015 @tab
19016
19017 16
19018
19019 @tab
19020
19021 12
19022
19023 @item
19024
19025 @code{subtype x3 is x2 range 0 .. 3;}
19026
19027 @tab
19028
19029 16
19030
19031 @tab
19032
19033 2
19034
19035 @item
19036
19037 @code{subtype x4 is x2'base range 0 .. 10;}
19038
19039 @tab
19040
19041 8
19042
19043 @tab
19044
19045 4
19046
19047 @item
19048
19049 @code{dynamic : x2'Base range -64 .. +63;}
19050
19051 @tab
19052
19053 @tab
19054
19055 @item
19056
19057 @code{subtype x5 is x2 range 0 .. dynamic;}
19058
19059 @tab
19060
19061 16
19062
19063 @tab
19064
19065 3*
19066
19067 @item
19068
19069 @code{subtype x6 is x2'base range 0 .. dynamic;}
19070
19071 @tab
19072
19073 8
19074
19075 @tab
19076
19077 7*
19078
19079 @end multitable
19080
19081
19082 Note: the entries marked '*' are not actually specified by the Ada
19083 Reference Manual, which has nothing to say about size in the dynamic
19084 case. What GNAT does is to allocate sufficient bits to accomodate any
19085 possible dynamic values for the bounds at run-time.
19086
19087 So far, so good, but GNAT has to obey the RM rules, so the question is
19088 under what conditions must the RM @code{Size} be used.
19089 The following is a list
19090 of the occasions on which the RM @code{Size} must be used:
19091
19092
19093 @itemize *
19094
19095 @item
19096 Component size for packed arrays or records
19097
19098 @item
19099 Value of the attribute @code{Size} for a type
19100
19101 @item
19102 Warning about sizes not matching for unchecked conversion
19103 @end itemize
19104
19105 For record types, the @code{Object_Size} is always a multiple of the
19106 alignment of the type (this is true for all types). In some cases the
19107 @code{Value_Size} can be smaller. Consider:
19108
19109 @example
19110 type R is record
19111 X : Integer;
19112 Y : Character;
19113 end record;
19114 @end example
19115
19116 On a typical 32-bit architecture, the X component will occupy four bytes
19117 and the Y component will occupy one byte, for a total of 5 bytes. As a
19118 result @code{R'Value_Size} will be 40 (bits) since this is the minimum size
19119 required to store a value of this type. For example, it is permissible
19120 to have a component of type R in an array whose component size is
19121 specified to be 40 bits.
19122
19123 However, @code{R'Object_Size} will be 64 (bits). The difference is due to
19124 the alignment requirement for objects of the record type. The X
19125 component will require four-byte alignment because that is what type
19126 Integer requires, whereas the Y component, a Character, will only
19127 require 1-byte alignment. Since the alignment required for X is the
19128 greatest of all the components' alignments, that is the alignment
19129 required for the enclosing record type, i.e., 4 bytes or 32 bits. As
19130 indicated above, the actual object size must be rounded up so that it is
19131 a multiple of the alignment value. Therefore, 40 bits rounded up to the
19132 next multiple of 32 yields 64 bits.
19133
19134 For all other types, the @code{Object_Size}
19135 and @code{Value_Size} are the same (and equivalent to the RM attribute @code{Size}).
19136 Only @code{Size} may be specified for such types.
19137
19138 Note that @code{Value_Size} can be used to force biased representation
19139 for a particular subtype. Consider this example:
19140
19141 @example
19142 type R is (A, B, C, D, E, F);
19143 subtype RAB is R range A .. B;
19144 subtype REF is R range E .. F;
19145 @end example
19146
19147 By default, @code{RAB}
19148 has a size of 1 (sufficient to accommodate the representation
19149 of @code{A} and @code{B}, 0 and 1), and @code{REF}
19150 has a size of 3 (sufficient to accommodate the representation
19151 of @code{E} and @code{F}, 4 and 5). But if we add the
19152 following @code{Value_Size} attribute definition clause:
19153
19154 @example
19155 for REF'Value_Size use 1;
19156 @end example
19157
19158 then biased representation is forced for @code{REF},
19159 and 0 will represent @code{E} and 1 will represent @code{F}.
19160 A warning is issued when a @code{Value_Size} attribute
19161 definition clause forces biased representation. This
19162 warning can be turned off using @code{-gnatw.B}.
19163
19164 @node Component_Size Clauses,Bit_Order Clauses,Value_Size and Object_Size Clauses,Representation Clauses and Pragmas
19165 @anchor{gnat_rm/representation_clauses_and_pragmas id8}@anchor{282}@anchor{gnat_rm/representation_clauses_and_pragmas component-size-clauses}@anchor{283}
19166 @section Component_Size Clauses
19167
19168
19169 @geindex Component_Size Clause
19170
19171 Normally, the value specified in a component size clause must be consistent
19172 with the subtype of the array component with regard to size and alignment.
19173 In other words, the value specified must be at least equal to the size
19174 of this subtype, and must be a multiple of the alignment value.
19175
19176 In addition, component size clauses are allowed which cause the array
19177 to be packed, by specifying a smaller value. A first case is for
19178 component size values in the range 1 through 63. The value specified
19179 must not be smaller than the Size of the subtype. GNAT will accurately
19180 honor all packing requests in this range. For example, if we have:
19181
19182 @example
19183 type r is array (1 .. 8) of Natural;
19184 for r'Component_Size use 31;
19185 @end example
19186
19187 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
19188 Of course access to the components of such an array is considerably
19189 less efficient than if the natural component size of 32 is used.
19190 A second case is when the subtype of the component is a record type
19191 padded because of its default alignment. For example, if we have:
19192
19193 @example
19194 type r is record
19195 i : Integer;
19196 j : Integer;
19197 b : Boolean;
19198 end record;
19199
19200 type a is array (1 .. 8) of r;
19201 for a'Component_Size use 72;
19202 @end example
19203
19204 then the resulting array has a length of 72 bytes, instead of 96 bytes
19205 if the alignment of the record (4) was obeyed.
19206
19207 Note that there is no point in giving both a component size clause
19208 and a pragma Pack for the same array type. if such duplicate
19209 clauses are given, the pragma Pack will be ignored.
19210
19211 @node Bit_Order Clauses,Effect of Bit_Order on Byte Ordering,Component_Size Clauses,Representation Clauses and Pragmas
19212 @anchor{gnat_rm/representation_clauses_and_pragmas bit-order-clauses}@anchor{284}@anchor{gnat_rm/representation_clauses_and_pragmas id9}@anchor{285}
19213 @section Bit_Order Clauses
19214
19215
19216 @geindex Bit_Order Clause
19217
19218 @geindex bit ordering
19219
19220 @geindex ordering
19221 @geindex of bits
19222
19223 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
19224 attribute. The specification may either correspond to the default bit
19225 order for the target, in which case the specification has no effect and
19226 places no additional restrictions, or it may be for the non-standard
19227 setting (that is the opposite of the default).
19228
19229 In the case where the non-standard value is specified, the effect is
19230 to renumber bits within each byte, but the ordering of bytes is not
19231 affected. There are certain
19232 restrictions placed on component clauses as follows:
19233
19234
19235 @itemize *
19236
19237 @item
19238 Components fitting within a single storage unit.
19239
19240 These are unrestricted, and the effect is merely to renumber bits. For
19241 example if we are on a little-endian machine with @code{Low_Order_First}
19242 being the default, then the following two declarations have exactly
19243 the same effect:
19244
19245 @example
19246 type R1 is record
19247 A : Boolean;
19248 B : Integer range 1 .. 120;
19249 end record;
19250
19251 for R1 use record
19252 A at 0 range 0 .. 0;
19253 B at 0 range 1 .. 7;
19254 end record;
19255
19256 type R2 is record
19257 A : Boolean;
19258 B : Integer range 1 .. 120;
19259 end record;
19260
19261 for R2'Bit_Order use High_Order_First;
19262
19263 for R2 use record
19264 A at 0 range 7 .. 7;
19265 B at 0 range 0 .. 6;
19266 end record;
19267 @end example
19268
19269 The useful application here is to write the second declaration with the
19270 @code{Bit_Order} attribute definition clause, and know that it will be treated
19271 the same, regardless of whether the target is little-endian or big-endian.
19272
19273 @item
19274 Components occupying an integral number of bytes.
19275
19276 These are components that exactly fit in two or more bytes. Such component
19277 declarations are allowed, but have no effect, since it is important to realize
19278 that the @code{Bit_Order} specification does not affect the ordering of bytes.
19279 In particular, the following attempt at getting an endian-independent integer
19280 does not work:
19281
19282 @example
19283 type R2 is record
19284 A : Integer;
19285 end record;
19286
19287 for R2'Bit_Order use High_Order_First;
19288
19289 for R2 use record
19290 A at 0 range 0 .. 31;
19291 end record;
19292 @end example
19293
19294 This declaration will result in a little-endian integer on a
19295 little-endian machine, and a big-endian integer on a big-endian machine.
19296 If byte flipping is required for interoperability between big- and
19297 little-endian machines, this must be explicitly programmed. This capability
19298 is not provided by @code{Bit_Order}.
19299
19300 @item
19301 Components that are positioned across byte boundaries.
19302
19303 but do not occupy an integral number of bytes. Given that bytes are not
19304 reordered, such fields would occupy a non-contiguous sequence of bits
19305 in memory, requiring non-trivial code to reassemble. They are for this
19306 reason not permitted, and any component clause specifying such a layout
19307 will be flagged as illegal by GNAT.
19308 @end itemize
19309
19310 Since the misconception that Bit_Order automatically deals with all
19311 endian-related incompatibilities is a common one, the specification of
19312 a component field that is an integral number of bytes will always
19313 generate a warning. This warning may be suppressed using @code{pragma Warnings (Off)}
19314 if desired. The following section contains additional
19315 details regarding the issue of byte ordering.
19316
19317 @node Effect of Bit_Order on Byte Ordering,Pragma Pack for Arrays,Bit_Order Clauses,Representation Clauses and Pragmas
19318 @anchor{gnat_rm/representation_clauses_and_pragmas id10}@anchor{286}@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-bit-order-on-byte-ordering}@anchor{287}
19319 @section Effect of Bit_Order on Byte Ordering
19320
19321
19322 @geindex byte ordering
19323
19324 @geindex ordering
19325 @geindex of bytes
19326
19327 In this section we will review the effect of the @code{Bit_Order} attribute
19328 definition clause on byte ordering. Briefly, it has no effect at all, but
19329 a detailed example will be helpful. Before giving this
19330 example, let us review the precise
19331 definition of the effect of defining @code{Bit_Order}. The effect of a
19332 non-standard bit order is described in section 13.5.3 of the Ada
19333 Reference Manual:
19334
19335 @quotation
19336
19337 "2 A bit ordering is a method of interpreting the meaning of
19338 the storage place attributes."
19339 @end quotation
19340
19341 To understand the precise definition of storage place attributes in
19342 this context, we visit section 13.5.1 of the manual:
19343
19344 @quotation
19345
19346 "13 A record_representation_clause (without the mod_clause)
19347 specifies the layout. The storage place attributes (see 13.5.2)
19348 are taken from the values of the position, first_bit, and last_bit
19349 expressions after normalizing those values so that first_bit is
19350 less than Storage_Unit."
19351 @end quotation
19352
19353 The critical point here is that storage places are taken from
19354 the values after normalization, not before. So the @code{Bit_Order}
19355 interpretation applies to normalized values. The interpretation
19356 is described in the later part of the 13.5.3 paragraph:
19357
19358 @quotation
19359
19360 "2 A bit ordering is a method of interpreting the meaning of
19361 the storage place attributes. High_Order_First (known in the
19362 vernacular as 'big endian') means that the first bit of a
19363 storage element (bit 0) is the most significant bit (interpreting
19364 the sequence of bits that represent a component as an unsigned
19365 integer value). Low_Order_First (known in the vernacular as
19366 'little endian') means the opposite: the first bit is the
19367 least significant."
19368 @end quotation
19369
19370 Note that the numbering is with respect to the bits of a storage
19371 unit. In other words, the specification affects only the numbering
19372 of bits within a single storage unit.
19373
19374 We can make the effect clearer by giving an example.
19375
19376 Suppose that we have an external device which presents two bytes, the first
19377 byte presented, which is the first (low addressed byte) of the two byte
19378 record is called Master, and the second byte is called Slave.
19379
19380 The left most (most significant bit is called Control for each byte, and
19381 the remaining 7 bits are called V1, V2, ... V7, where V7 is the rightmost
19382 (least significant) bit.
19383
19384 On a big-endian machine, we can write the following representation clause
19385
19386 @example
19387 type Data is record
19388 Master_Control : Bit;
19389 Master_V1 : Bit;
19390 Master_V2 : Bit;
19391 Master_V3 : Bit;
19392 Master_V4 : Bit;
19393 Master_V5 : Bit;
19394 Master_V6 : Bit;
19395 Master_V7 : Bit;
19396 Slave_Control : Bit;
19397 Slave_V1 : Bit;
19398 Slave_V2 : Bit;
19399 Slave_V3 : Bit;
19400 Slave_V4 : Bit;
19401 Slave_V5 : Bit;
19402 Slave_V6 : Bit;
19403 Slave_V7 : Bit;
19404 end record;
19405
19406 for Data use record
19407 Master_Control at 0 range 0 .. 0;
19408 Master_V1 at 0 range 1 .. 1;
19409 Master_V2 at 0 range 2 .. 2;
19410 Master_V3 at 0 range 3 .. 3;
19411 Master_V4 at 0 range 4 .. 4;
19412 Master_V5 at 0 range 5 .. 5;
19413 Master_V6 at 0 range 6 .. 6;
19414 Master_V7 at 0 range 7 .. 7;
19415 Slave_Control at 1 range 0 .. 0;
19416 Slave_V1 at 1 range 1 .. 1;
19417 Slave_V2 at 1 range 2 .. 2;
19418 Slave_V3 at 1 range 3 .. 3;
19419 Slave_V4 at 1 range 4 .. 4;
19420 Slave_V5 at 1 range 5 .. 5;
19421 Slave_V6 at 1 range 6 .. 6;
19422 Slave_V7 at 1 range 7 .. 7;
19423 end record;
19424 @end example
19425
19426 Now if we move this to a little endian machine, then the bit ordering within
19427 the byte is backwards, so we have to rewrite the record rep clause as:
19428
19429 @example
19430 for Data use record
19431 Master_Control at 0 range 7 .. 7;
19432 Master_V1 at 0 range 6 .. 6;
19433 Master_V2 at 0 range 5 .. 5;
19434 Master_V3 at 0 range 4 .. 4;
19435 Master_V4 at 0 range 3 .. 3;
19436 Master_V5 at 0 range 2 .. 2;
19437 Master_V6 at 0 range 1 .. 1;
19438 Master_V7 at 0 range 0 .. 0;
19439 Slave_Control at 1 range 7 .. 7;
19440 Slave_V1 at 1 range 6 .. 6;
19441 Slave_V2 at 1 range 5 .. 5;
19442 Slave_V3 at 1 range 4 .. 4;
19443 Slave_V4 at 1 range 3 .. 3;
19444 Slave_V5 at 1 range 2 .. 2;
19445 Slave_V6 at 1 range 1 .. 1;
19446 Slave_V7 at 1 range 0 .. 0;
19447 end record;
19448 @end example
19449
19450 It is a nuisance to have to rewrite the clause, especially if
19451 the code has to be maintained on both machines. However,
19452 this is a case that we can handle with the
19453 @code{Bit_Order} attribute if it is implemented.
19454 Note that the implementation is not required on byte addressed
19455 machines, but it is indeed implemented in GNAT.
19456 This means that we can simply use the
19457 first record clause, together with the declaration
19458
19459 @example
19460 for Data'Bit_Order use High_Order_First;
19461 @end example
19462
19463 and the effect is what is desired, namely the layout is exactly the same,
19464 independent of whether the code is compiled on a big-endian or little-endian
19465 machine.
19466
19467 The important point to understand is that byte ordering is not affected.
19468 A @code{Bit_Order} attribute definition never affects which byte a field
19469 ends up in, only where it ends up in that byte.
19470 To make this clear, let us rewrite the record rep clause of the previous
19471 example as:
19472
19473 @example
19474 for Data'Bit_Order use High_Order_First;
19475 for Data use record
19476 Master_Control at 0 range 0 .. 0;
19477 Master_V1 at 0 range 1 .. 1;
19478 Master_V2 at 0 range 2 .. 2;
19479 Master_V3 at 0 range 3 .. 3;
19480 Master_V4 at 0 range 4 .. 4;
19481 Master_V5 at 0 range 5 .. 5;
19482 Master_V6 at 0 range 6 .. 6;
19483 Master_V7 at 0 range 7 .. 7;
19484 Slave_Control at 0 range 8 .. 8;
19485 Slave_V1 at 0 range 9 .. 9;
19486 Slave_V2 at 0 range 10 .. 10;
19487 Slave_V3 at 0 range 11 .. 11;
19488 Slave_V4 at 0 range 12 .. 12;
19489 Slave_V5 at 0 range 13 .. 13;
19490 Slave_V6 at 0 range 14 .. 14;
19491 Slave_V7 at 0 range 15 .. 15;
19492 end record;
19493 @end example
19494
19495 This is exactly equivalent to saying (a repeat of the first example):
19496
19497 @example
19498 for Data'Bit_Order use High_Order_First;
19499 for Data use record
19500 Master_Control at 0 range 0 .. 0;
19501 Master_V1 at 0 range 1 .. 1;
19502 Master_V2 at 0 range 2 .. 2;
19503 Master_V3 at 0 range 3 .. 3;
19504 Master_V4 at 0 range 4 .. 4;
19505 Master_V5 at 0 range 5 .. 5;
19506 Master_V6 at 0 range 6 .. 6;
19507 Master_V7 at 0 range 7 .. 7;
19508 Slave_Control at 1 range 0 .. 0;
19509 Slave_V1 at 1 range 1 .. 1;
19510 Slave_V2 at 1 range 2 .. 2;
19511 Slave_V3 at 1 range 3 .. 3;
19512 Slave_V4 at 1 range 4 .. 4;
19513 Slave_V5 at 1 range 5 .. 5;
19514 Slave_V6 at 1 range 6 .. 6;
19515 Slave_V7 at 1 range 7 .. 7;
19516 end record;
19517 @end example
19518
19519 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
19520 field. The storage place attributes are obtained by normalizing the
19521 values given so that the @code{First_Bit} value is less than 8. After
19522 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
19523 we specified in the other case.
19524
19525 Now one might expect that the @code{Bit_Order} attribute might affect
19526 bit numbering within the entire record component (two bytes in this
19527 case, thus affecting which byte fields end up in), but that is not
19528 the way this feature is defined, it only affects numbering of bits,
19529 not which byte they end up in.
19530
19531 Consequently it never makes sense to specify a starting bit number
19532 greater than 7 (for a byte addressable field) if an attribute
19533 definition for @code{Bit_Order} has been given, and indeed it
19534 may be actively confusing to specify such a value, so the compiler
19535 generates a warning for such usage.
19536
19537 If you do need to control byte ordering then appropriate conditional
19538 values must be used. If in our example, the slave byte came first on
19539 some machines we might write:
19540
19541 @example
19542 Master_Byte_First constant Boolean := ...;
19543
19544 Master_Byte : constant Natural :=
19545 1 - Boolean'Pos (Master_Byte_First);
19546 Slave_Byte : constant Natural :=
19547 Boolean'Pos (Master_Byte_First);
19548
19549 for Data'Bit_Order use High_Order_First;
19550 for Data use record
19551 Master_Control at Master_Byte range 0 .. 0;
19552 Master_V1 at Master_Byte range 1 .. 1;
19553 Master_V2 at Master_Byte range 2 .. 2;
19554 Master_V3 at Master_Byte range 3 .. 3;
19555 Master_V4 at Master_Byte range 4 .. 4;
19556 Master_V5 at Master_Byte range 5 .. 5;
19557 Master_V6 at Master_Byte range 6 .. 6;
19558 Master_V7 at Master_Byte range 7 .. 7;
19559 Slave_Control at Slave_Byte range 0 .. 0;
19560 Slave_V1 at Slave_Byte range 1 .. 1;
19561 Slave_V2 at Slave_Byte range 2 .. 2;
19562 Slave_V3 at Slave_Byte range 3 .. 3;
19563 Slave_V4 at Slave_Byte range 4 .. 4;
19564 Slave_V5 at Slave_Byte range 5 .. 5;
19565 Slave_V6 at Slave_Byte range 6 .. 6;
19566 Slave_V7 at Slave_Byte range 7 .. 7;
19567 end record;
19568 @end example
19569
19570 Now to switch between machines, all that is necessary is
19571 to set the boolean constant @code{Master_Byte_First} in
19572 an appropriate manner.
19573
19574 @node Pragma Pack for Arrays,Pragma Pack for Records,Effect of Bit_Order on Byte Ordering,Representation Clauses and Pragmas
19575 @anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-arrays}@anchor{288}@anchor{gnat_rm/representation_clauses_and_pragmas id11}@anchor{289}
19576 @section Pragma Pack for Arrays
19577
19578
19579 @geindex Pragma Pack (for arrays)
19580
19581 Pragma @code{Pack} applied to an array has an effect that depends upon whether the
19582 component type is @emph{packable}. For a component type to be @emph{packable}, it must
19583 be one of the following cases:
19584
19585
19586 @itemize *
19587
19588 @item
19589 Any elementary type.
19590
19591 @item
19592 Any small packed array type with a static size.
19593
19594 @item
19595 Any small simple record type with a static size.
19596 @end itemize
19597
19598 For all these cases, if the component subtype size is in the range
19599 1 through 64, then the effect of the pragma @code{Pack} is exactly as though a
19600 component size were specified giving the component subtype size.
19601
19602 All other types are non-packable, they occupy an integral number of storage
19603 units and the only effect of pragma Pack is to remove alignment gaps.
19604
19605 For example if we have:
19606
19607 @example
19608 type r is range 0 .. 17;
19609
19610 type ar is array (1 .. 8) of r;
19611 pragma Pack (ar);
19612 @end example
19613
19614 Then the component size of @code{ar} will be set to 5 (i.e., to @code{r'size},
19615 and the size of the array @code{ar} will be exactly 40 bits).
19616
19617 Note that in some cases this rather fierce approach to packing can produce
19618 unexpected effects. For example, in Ada 95 and Ada 2005,
19619 subtype @code{Natural} typically has a size of 31, meaning that if you
19620 pack an array of @code{Natural}, you get 31-bit
19621 close packing, which saves a few bits, but results in far less efficient
19622 access. Since many other Ada compilers will ignore such a packing request,
19623 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
19624 might not be what is intended. You can easily remove this warning by
19625 using an explicit @code{Component_Size} setting instead, which never generates
19626 a warning, since the intention of the programmer is clear in this case.
19627
19628 GNAT treats packed arrays in one of two ways. If the size of the array is
19629 known at compile time and is less than 64 bits, then internally the array
19630 is represented as a single modular type, of exactly the appropriate number
19631 of bits. If the length is greater than 63 bits, or is not known at compile
19632 time, then the packed array is represented as an array of bytes, and the
19633 length is always a multiple of 8 bits.
19634
19635 Note that to represent a packed array as a modular type, the alignment must
19636 be suitable for the modular type involved. For example, on typical machines
19637 a 32-bit packed array will be represented by a 32-bit modular integer with
19638 an alignment of four bytes. If you explicitly override the default alignment
19639 with an alignment clause that is too small, the modular representation
19640 cannot be used. For example, consider the following set of declarations:
19641
19642 @example
19643 type R is range 1 .. 3;
19644 type S is array (1 .. 31) of R;
19645 for S'Component_Size use 2;
19646 for S'Size use 62;
19647 for S'Alignment use 1;
19648 @end example
19649
19650 If the alignment clause were not present, then a 62-bit modular
19651 representation would be chosen (typically with an alignment of 4 or 8
19652 bytes depending on the target). But the default alignment is overridden
19653 with the explicit alignment clause. This means that the modular
19654 representation cannot be used, and instead the array of bytes
19655 representation must be used, meaning that the length must be a multiple
19656 of 8. Thus the above set of declarations will result in a diagnostic
19657 rejecting the size clause and noting that the minimum size allowed is 64.
19658
19659 @geindex Pragma Pack (for type Natural)
19660
19661 @geindex Pragma Pack warning
19662
19663 One special case that is worth noting occurs when the base type of the
19664 component size is 8/16/32 and the subtype is one bit less. Notably this
19665 occurs with subtype @code{Natural}. Consider:
19666
19667 @example
19668 type Arr is array (1 .. 32) of Natural;
19669 pragma Pack (Arr);
19670 @end example
19671
19672 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
19673 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
19674 Ada 83 compilers did not attempt 31 bit packing.
19675
19676 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
19677 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
19678 substantial unintended performance penalty when porting legacy Ada 83 code.
19679 To help prevent this, GNAT generates a warning in such cases. If you really
19680 want 31 bit packing in a case like this, you can set the component size
19681 explicitly:
19682
19683 @example
19684 type Arr is array (1 .. 32) of Natural;
19685 for Arr'Component_Size use 31;
19686 @end example
19687
19688 Here 31-bit packing is achieved as required, and no warning is generated,
19689 since in this case the programmer intention is clear.
19690
19691 @node Pragma Pack for Records,Record Representation Clauses,Pragma Pack for Arrays,Representation Clauses and Pragmas
19692 @anchor{gnat_rm/representation_clauses_and_pragmas pragma-pack-for-records}@anchor{28a}@anchor{gnat_rm/representation_clauses_and_pragmas id12}@anchor{28b}
19693 @section Pragma Pack for Records
19694
19695
19696 @geindex Pragma Pack (for records)
19697
19698 Pragma @code{Pack} applied to a record will pack the components to reduce
19699 wasted space from alignment gaps and by reducing the amount of space
19700 taken by components. We distinguish between @emph{packable} components and
19701 @emph{non-packable} components.
19702 Components of the following types are considered packable:
19703
19704
19705 @itemize *
19706
19707 @item
19708 Components of an elementary type are packable unless they are aliased,
19709 independent, or of an atomic type.
19710
19711 @item
19712 Small packed arrays, where the size is statically known, are represented
19713 internally as modular integers, and so they are also packable.
19714
19715 @item
19716 Small simple records, where the size is statically known, are also packable.
19717 @end itemize
19718
19719 For all these cases, if the @code{'Size} value is in the range 1 through 64, the
19720 components occupy the exact number of bits corresponding to this value
19721 and are packed with no padding bits, i.e. they can start on an arbitrary
19722 bit boundary.
19723
19724 All other types are non-packable, they occupy an integral number of storage
19725 units and the only effect of pragma @code{Pack} is to remove alignment gaps.
19726
19727 For example, consider the record
19728
19729 @example
19730 type Rb1 is array (1 .. 13) of Boolean;
19731 pragma Pack (Rb1);
19732
19733 type Rb2 is array (1 .. 65) of Boolean;
19734 pragma Pack (Rb2);
19735
19736 type AF is new Float with Atomic;
19737
19738 type X2 is record
19739 L1 : Boolean;
19740 L2 : Duration;
19741 L3 : AF;
19742 L4 : Boolean;
19743 L5 : Rb1;
19744 L6 : Rb2;
19745 end record;
19746 pragma Pack (X2);
19747 @end example
19748
19749 The representation for the record @code{X2} is as follows:
19750
19751 @example
19752 for X2'Size use 224;
19753 for X2 use record
19754 L1 at 0 range 0 .. 0;
19755 L2 at 0 range 1 .. 64;
19756 L3 at 12 range 0 .. 31;
19757 L4 at 16 range 0 .. 0;
19758 L5 at 16 range 1 .. 13;
19759 L6 at 18 range 0 .. 71;
19760 end record;
19761 @end example
19762
19763 Studying this example, we see that the packable fields @code{L1}
19764 and @code{L2} are
19765 of length equal to their sizes, and placed at specific bit boundaries (and
19766 not byte boundaries) to
19767 eliminate padding. But @code{L3} is of a non-packable float type (because
19768 it is aliased), so it is on the next appropriate alignment boundary.
19769
19770 The next two fields are fully packable, so @code{L4} and @code{L5} are
19771 minimally packed with no gaps. However, type @code{Rb2} is a packed
19772 array that is longer than 64 bits, so it is itself non-packable. Thus
19773 the @code{L6} field is aligned to the next byte boundary, and takes an
19774 integral number of bytes, i.e., 72 bits.
19775
19776 @node Record Representation Clauses,Handling of Records with Holes,Pragma Pack for Records,Representation Clauses and Pragmas
19777 @anchor{gnat_rm/representation_clauses_and_pragmas id13}@anchor{28c}@anchor{gnat_rm/representation_clauses_and_pragmas record-representation-clauses}@anchor{28d}
19778 @section Record Representation Clauses
19779
19780
19781 @geindex Record Representation Clause
19782
19783 Record representation clauses may be given for all record types, including
19784 types obtained by record extension. Component clauses are allowed for any
19785 static component. The restrictions on component clauses depend on the type
19786 of the component.
19787
19788 @geindex Component Clause
19789
19790 For all components of an elementary type, the only restriction on component
19791 clauses is that the size must be at least the @code{'Size} value of the type
19792 (actually the Value_Size). There are no restrictions due to alignment,
19793 and such components may freely cross storage boundaries.
19794
19795 Packed arrays with a size up to and including 64 bits are represented
19796 internally using a modular type with the appropriate number of bits, and
19797 thus the same lack of restriction applies. For example, if you declare:
19798
19799 @example
19800 type R is array (1 .. 49) of Boolean;
19801 pragma Pack (R);
19802 for R'Size use 49;
19803 @end example
19804
19805 then a component clause for a component of type @code{R} may start on any
19806 specified bit boundary, and may specify a value of 49 bits or greater.
19807
19808 For packed bit arrays that are longer than 64 bits, there are two
19809 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
19810 including the important case of single bits or boolean values, then
19811 there are no limitations on placement of such components, and they
19812 may start and end at arbitrary bit boundaries.
19813
19814 If the component size is not a power of 2 (e.g., 3 or 5), then
19815 an array of this type longer than 64 bits must always be placed on
19816 on a storage unit (byte) boundary and occupy an integral number
19817 of storage units (bytes). Any component clause that does not
19818 meet this requirement will be rejected.
19819
19820 Any aliased component, or component of an aliased type, must
19821 have its normal alignment and size. A component clause that
19822 does not meet this requirement will be rejected.
19823
19824 The tag field of a tagged type always occupies an address sized field at
19825 the start of the record. No component clause may attempt to overlay this
19826 tag. When a tagged type appears as a component, the tag field must have
19827 proper alignment
19828
19829 In the case of a record extension @code{T1}, of a type @code{T}, no component clause applied
19830 to the type @code{T1} can specify a storage location that would overlap the first
19831 @code{T'Size} bytes of the record.
19832
19833 For all other component types, including non-bit-packed arrays,
19834 the component can be placed at an arbitrary bit boundary,
19835 so for example, the following is permitted:
19836
19837 @example
19838 type R is array (1 .. 10) of Boolean;
19839 for R'Size use 80;
19840
19841 type Q is record
19842 G, H : Boolean;
19843 L, M : R;
19844 end record;
19845
19846 for Q use record
19847 G at 0 range 0 .. 0;
19848 H at 0 range 1 .. 1;
19849 L at 0 range 2 .. 81;
19850 R at 0 range 82 .. 161;
19851 end record;
19852 @end example
19853
19854 @node Handling of Records with Holes,Enumeration Clauses,Record Representation Clauses,Representation Clauses and Pragmas
19855 @anchor{gnat_rm/representation_clauses_and_pragmas handling-of-records-with-holes}@anchor{28e}@anchor{gnat_rm/representation_clauses_and_pragmas id14}@anchor{28f}
19856 @section Handling of Records with Holes
19857
19858
19859 @geindex Handling of Records with Holes
19860
19861 As a result of alignment considerations, records may contain "holes"
19862 or gaps
19863 which do not correspond to the data bits of any of the components.
19864 Record representation clauses can also result in holes in records.
19865
19866 GNAT does not attempt to clear these holes, so in record objects,
19867 they should be considered to hold undefined rubbish. The generated
19868 equality routine just tests components so does not access these
19869 undefined bits, and assignment and copy operations may or may not
19870 preserve the contents of these holes (for assignments, the holes
19871 in the target will in practice contain either the bits that are
19872 present in the holes in the source, or the bits that were present
19873 in the target before the assignment).
19874
19875 If it is necessary to ensure that holes in records have all zero
19876 bits, then record objects for which this initialization is desired
19877 should be explicitly set to all zero values using Unchecked_Conversion
19878 or address overlays. For example
19879
19880 @example
19881 type HRec is record
19882 C : Character;
19883 I : Integer;
19884 end record;
19885 @end example
19886
19887 On typical machines, integers need to be aligned on a four-byte
19888 boundary, resulting in three bytes of undefined rubbish following
19889 the 8-bit field for C. To ensure that the hole in a variable of
19890 type HRec is set to all zero bits,
19891 you could for example do:
19892
19893 @example
19894 type Base is record
19895 Dummy1, Dummy2 : Integer := 0;
19896 end record;
19897
19898 BaseVar : Base;
19899 RealVar : Hrec;
19900 for RealVar'Address use BaseVar'Address;
19901 @end example
19902
19903 Now the 8-bytes of the value of RealVar start out containing all zero
19904 bits. A safer approach is to just define dummy fields, avoiding the
19905 holes, as in:
19906
19907 @example
19908 type HRec is record
19909 C : Character;
19910 Dummy1 : Short_Short_Integer := 0;
19911 Dummy2 : Short_Short_Integer := 0;
19912 Dummy3 : Short_Short_Integer := 0;
19913 I : Integer;
19914 end record;
19915 @end example
19916
19917 And to make absolutely sure that the intent of this is followed, you
19918 can use representation clauses:
19919
19920 @example
19921 for Hrec use record
19922 C at 0 range 0 .. 7;
19923 Dummy1 at 1 range 0 .. 7;
19924 Dummy2 at 2 range 0 .. 7;
19925 Dummy3 at 3 range 0 .. 7;
19926 I at 4 range 0 .. 31;
19927 end record;
19928 for Hrec'Size use 64;
19929 @end example
19930
19931 @node Enumeration Clauses,Address Clauses,Handling of Records with Holes,Representation Clauses and Pragmas
19932 @anchor{gnat_rm/representation_clauses_and_pragmas enumeration-clauses}@anchor{290}@anchor{gnat_rm/representation_clauses_and_pragmas id15}@anchor{291}
19933 @section Enumeration Clauses
19934
19935
19936 The only restriction on enumeration clauses is that the range of values
19937 must be representable. For the signed case, if one or more of the
19938 representation values are negative, all values must be in the range:
19939
19940 @example
19941 System.Min_Int .. System.Max_Int
19942 @end example
19943
19944 For the unsigned case, where all values are nonnegative, the values must
19945 be in the range:
19946
19947 @example
19948 0 .. System.Max_Binary_Modulus;
19949 @end example
19950
19951 A @emph{confirming} representation clause is one in which the values range
19952 from 0 in sequence, i.e., a clause that confirms the default representation
19953 for an enumeration type.
19954 Such a confirming representation
19955 is permitted by these rules, and is specially recognized by the compiler so
19956 that no extra overhead results from the use of such a clause.
19957
19958 If an array has an index type which is an enumeration type to which an
19959 enumeration clause has been applied, then the array is stored in a compact
19960 manner. Consider the declarations:
19961
19962 @example
19963 type r is (A, B, C);
19964 for r use (A => 1, B => 5, C => 10);
19965 type t is array (r) of Character;
19966 @end example
19967
19968 The array type t corresponds to a vector with exactly three elements and
19969 has a default size equal to @code{3*Character'Size}. This ensures efficient
19970 use of space, but means that accesses to elements of the array will incur
19971 the overhead of converting representation values to the corresponding
19972 positional values, (i.e., the value delivered by the @code{Pos} attribute).
19973
19974 @node Address Clauses,Use of Address Clauses for Memory-Mapped I/O,Enumeration Clauses,Representation Clauses and Pragmas
19975 @anchor{gnat_rm/representation_clauses_and_pragmas id16}@anchor{292}@anchor{gnat_rm/representation_clauses_and_pragmas address-clauses}@anchor{293}
19976 @section Address Clauses
19977
19978
19979 @geindex Address Clause
19980
19981 The reference manual allows a general restriction on representation clauses,
19982 as found in RM 13.1(22):
19983
19984 @quotation
19985
19986 "An implementation need not support representation
19987 items containing nonstatic expressions, except that
19988 an implementation should support a representation item
19989 for a given entity if each nonstatic expression in the
19990 representation item is a name that statically denotes
19991 a constant declared before the entity."
19992 @end quotation
19993
19994 In practice this is applicable only to address clauses, since this is the
19995 only case in which a nonstatic expression is permitted by the syntax. As
19996 the AARM notes in sections 13.1 (22.a-22.h):
19997
19998 @quotation
19999
20000 22.a Reason: This is to avoid the following sort of thing:
20001
20002 22.b X : Integer := F(...);
20003 Y : Address := G(...);
20004 for X'Address use Y;
20005
20006 22.c In the above, we have to evaluate the
20007 initialization expression for X before we
20008 know where to put the result. This seems
20009 like an unreasonable implementation burden.
20010
20011 22.d The above code should instead be written
20012 like this:
20013
20014 22.e Y : constant Address := G(...);
20015 X : Integer := F(...);
20016 for X'Address use Y;
20017
20018 22.f This allows the expression 'Y' to be safely
20019 evaluated before X is created.
20020
20021 22.g The constant could be a formal parameter of mode in.
20022
20023 22.h An implementation can support other nonstatic
20024 expressions if it wants to. Expressions of type
20025 Address are hardly ever static, but their value
20026 might be known at compile time anyway in many
20027 cases.
20028 @end quotation
20029
20030 GNAT does indeed permit many additional cases of nonstatic expressions. In
20031 particular, if the type involved is elementary there are no restrictions
20032 (since in this case, holding a temporary copy of the initialization value,
20033 if one is present, is inexpensive). In addition, if there is no implicit or
20034 explicit initialization, then there are no restrictions. GNAT will reject
20035 only the case where all three of these conditions hold:
20036
20037
20038 @itemize *
20039
20040 @item
20041 The type of the item is non-elementary (e.g., a record or array).
20042
20043 @item
20044 There is explicit or implicit initialization required for the object.
20045 Note that access values are always implicitly initialized.
20046
20047 @item
20048 The address value is nonstatic. Here GNAT is more permissive than the
20049 RM, and allows the address value to be the address of a previously declared
20050 stand-alone variable, as long as it does not itself have an address clause.
20051
20052 @example
20053 Anchor : Some_Initialized_Type;
20054 Overlay : Some_Initialized_Type;
20055 for Overlay'Address use Anchor'Address;
20056 @end example
20057
20058 However, the prefix of the address clause cannot be an array component, or
20059 a component of a discriminated record.
20060 @end itemize
20061
20062 As noted above in section 22.h, address values are typically nonstatic. In
20063 particular the To_Address function, even if applied to a literal value, is
20064 a nonstatic function call. To avoid this minor annoyance, GNAT provides
20065 the implementation defined attribute 'To_Address. The following two
20066 expressions have identical values:
20067
20068 @geindex Attribute
20069
20070 @geindex To_Address
20071
20072 @example
20073 To_Address (16#1234_0000#)
20074 System'To_Address (16#1234_0000#);
20075 @end example
20076
20077 except that the second form is considered to be a static expression, and
20078 thus when used as an address clause value is always permitted.
20079
20080 Additionally, GNAT treats as static an address clause that is an
20081 unchecked_conversion of a static integer value. This simplifies the porting
20082 of legacy code, and provides a portable equivalent to the GNAT attribute
20083 @code{To_Address}.
20084
20085 Another issue with address clauses is the interaction with alignment
20086 requirements. When an address clause is given for an object, the address
20087 value must be consistent with the alignment of the object (which is usually
20088 the same as the alignment of the type of the object). If an address clause
20089 is given that specifies an inappropriately aligned address value, then the
20090 program execution is erroneous.
20091
20092 Since this source of erroneous behavior can have unfortunate effects on
20093 machines with strict alignment requirements, GNAT
20094 checks (at compile time if possible, generating a warning, or at execution
20095 time with a run-time check) that the alignment is appropriate. If the
20096 run-time check fails, then @code{Program_Error} is raised. This run-time
20097 check is suppressed if range checks are suppressed, or if the special GNAT
20098 check Alignment_Check is suppressed, or if
20099 @code{pragma Restrictions (No_Elaboration_Code)} is in effect. It is also
20100 suppressed by default on non-strict alignment machines (such as the x86).
20101
20102 Finally, GNAT does not permit overlaying of objects of class-wide types. In
20103 most cases, the compiler can detect an attempt at such overlays and will
20104 generate a warning at compile time and a Program_Error exception at run time.
20105
20106 @geindex Export
20107
20108 An address clause cannot be given for an exported object. More
20109 understandably the real restriction is that objects with an address
20110 clause cannot be exported. This is because such variables are not
20111 defined by the Ada program, so there is no external object to export.
20112
20113 @geindex Import
20114
20115 It is permissible to give an address clause and a pragma Import for the
20116 same object. In this case, the variable is not really defined by the
20117 Ada program, so there is no external symbol to be linked. The link name
20118 and the external name are ignored in this case. The reason that we allow this
20119 combination is that it provides a useful idiom to avoid unwanted
20120 initializations on objects with address clauses.
20121
20122 When an address clause is given for an object that has implicit or
20123 explicit initialization, then by default initialization takes place. This
20124 means that the effect of the object declaration is to overwrite the
20125 memory at the specified address. This is almost always not what the
20126 programmer wants, so GNAT will output a warning:
20127
20128 @example
20129 with System;
20130 package G is
20131 type R is record
20132 M : Integer := 0;
20133 end record;
20134
20135 Ext : R;
20136 for Ext'Address use System'To_Address (16#1234_1234#);
20137 |
20138 >>> warning: implicit initialization of "Ext" may
20139 modify overlaid storage
20140 >>> warning: use pragma Import for "Ext" to suppress
20141 initialization (RM B(24))
20142
20143 end G;
20144 @end example
20145
20146 As indicated by the warning message, the solution is to use a (dummy) pragma
20147 Import to suppress this initialization. The pragma tell the compiler that the
20148 object is declared and initialized elsewhere. The following package compiles
20149 without warnings (and the initialization is suppressed):
20150
20151 @example
20152 with System;
20153 package G is
20154 type R is record
20155 M : Integer := 0;
20156 end record;
20157
20158 Ext : R;
20159 for Ext'Address use System'To_Address (16#1234_1234#);
20160 pragma Import (Ada, Ext);
20161 end G;
20162 @end example
20163
20164 A final issue with address clauses involves their use for overlaying
20165 variables, as in the following example:
20166
20167 @geindex Overlaying of objects
20168
20169 @example
20170 A : Integer;
20171 B : Integer;
20172 for B'Address use A'Address;
20173 @end example
20174
20175 or alternatively, using the form recommended by the RM:
20176
20177 @example
20178 A : Integer;
20179 Addr : constant Address := A'Address;
20180 B : Integer;
20181 for B'Address use Addr;
20182 @end example
20183
20184 In both of these cases, @code{A} and @code{B} become aliased to one another
20185 via the address clause. This use of address clauses to overlay
20186 variables, achieving an effect similar to unchecked conversion
20187 was erroneous in Ada 83, but in Ada 95 and Ada 2005
20188 the effect is implementation defined. Furthermore, the
20189 Ada RM specifically recommends that in a situation
20190 like this, @code{B} should be subject to the following
20191 implementation advice (RM 13.3(19)):
20192
20193 @quotation
20194
20195 "19 If the Address of an object is specified, or it is imported
20196 or exported, then the implementation should not perform
20197 optimizations based on assumptions of no aliases."
20198 @end quotation
20199
20200 GNAT follows this recommendation, and goes further by also applying
20201 this recommendation to the overlaid variable (@code{A} in the above example)
20202 in this case. This means that the overlay works "as expected", in that
20203 a modification to one of the variables will affect the value of the other.
20204
20205 More generally, GNAT interprets this recommendation conservatively for
20206 address clauses: in the cases other than overlays, it considers that the
20207 object is effectively subject to pragma @code{Volatile} and implements the
20208 associated semantics.
20209
20210 Note that when address clause overlays are used in this way, there is an
20211 issue of unintentional initialization, as shown by this example:
20212
20213 @example
20214 package Overwrite_Record is
20215 type R is record
20216 A : Character := 'C';
20217 B : Character := 'A';
20218 end record;
20219 X : Short_Integer := 3;
20220 Y : R;
20221 for Y'Address use X'Address;
20222 |
20223 >>> warning: default initialization of "Y" may
20224 modify "X", use pragma Import for "Y" to
20225 suppress initialization (RM B.1(24))
20226
20227 end Overwrite_Record;
20228 @end example
20229
20230 Here the default initialization of @code{Y} will clobber the value
20231 of @code{X}, which justifies the warning. The warning notes that
20232 this effect can be eliminated by adding a @code{pragma Import}
20233 which suppresses the initialization:
20234
20235 @example
20236 package Overwrite_Record is
20237 type R is record
20238 A : Character := 'C';
20239 B : Character := 'A';
20240 end record;
20241 X : Short_Integer := 3;
20242 Y : R;
20243 for Y'Address use X'Address;
20244 pragma Import (Ada, Y);
20245 end Overwrite_Record;
20246 @end example
20247
20248 Note that the use of @code{pragma Initialize_Scalars} may cause variables to
20249 be initialized when they would not otherwise have been in the absence
20250 of the use of this pragma. This may cause an overlay to have this
20251 unintended clobbering effect. The compiler avoids this for scalar
20252 types, but not for composite objects (where in general the effect
20253 of @code{Initialize_Scalars} is part of the initialization routine
20254 for the composite object:
20255
20256 @example
20257 pragma Initialize_Scalars;
20258 with Ada.Text_IO; use Ada.Text_IO;
20259 procedure Overwrite_Array is
20260 type Arr is array (1 .. 5) of Integer;
20261 X : Arr := (others => 1);
20262 A : Arr;
20263 for A'Address use X'Address;
20264 |
20265 >>> warning: default initialization of "A" may
20266 modify "X", use pragma Import for "A" to
20267 suppress initialization (RM B.1(24))
20268
20269 begin
20270 if X /= Arr'(others => 1) then
20271 Put_Line ("X was clobbered");
20272 else
20273 Put_Line ("X was not clobbered");
20274 end if;
20275 end Overwrite_Array;
20276 @end example
20277
20278 The above program generates the warning as shown, and at execution
20279 time, prints @code{X was clobbered}. If the @code{pragma Import} is
20280 added as suggested:
20281
20282 @example
20283 pragma Initialize_Scalars;
20284 with Ada.Text_IO; use Ada.Text_IO;
20285 procedure Overwrite_Array is
20286 type Arr is array (1 .. 5) of Integer;
20287 X : Arr := (others => 1);
20288 A : Arr;
20289 for A'Address use X'Address;
20290 pragma Import (Ada, A);
20291 begin
20292 if X /= Arr'(others => 1) then
20293 Put_Line ("X was clobbered");
20294 else
20295 Put_Line ("X was not clobbered");
20296 end if;
20297 end Overwrite_Array;
20298 @end example
20299
20300 then the program compiles without the warning and when run will generate
20301 the output @code{X was not clobbered}.
20302
20303 @node Use of Address Clauses for Memory-Mapped I/O,Effect of Convention on Representation,Address Clauses,Representation Clauses and Pragmas
20304 @anchor{gnat_rm/representation_clauses_and_pragmas id17}@anchor{294}@anchor{gnat_rm/representation_clauses_and_pragmas use-of-address-clauses-for-memory-mapped-i-o}@anchor{295}
20305 @section Use of Address Clauses for Memory-Mapped I/O
20306
20307
20308 @geindex Memory-mapped I/O
20309
20310 A common pattern is to use an address clause to map an atomic variable to
20311 a location in memory that corresponds to a memory-mapped I/O operation or
20312 operations, for example:
20313
20314 @example
20315 type Mem_Word is record
20316 A,B,C,D : Byte;
20317 end record;
20318 pragma Atomic (Mem_Word);
20319 for Mem_Word_Size use 32;
20320
20321 Mem : Mem_Word;
20322 for Mem'Address use some-address;
20323 ...
20324 Temp := Mem;
20325 Temp.A := 32;
20326 Mem := Temp;
20327 @end example
20328
20329 For a full access (reference or modification) of the variable (Mem) in this
20330 case, as in the above examples, GNAT guarantees that the entire atomic word
20331 will be accessed, in accordance with the RM C.6(15) clause.
20332
20333 A problem arises with a component access such as:
20334
20335 @example
20336 Mem.A := 32;
20337 @end example
20338
20339 Note that the component A is not declared as atomic. This means that it is
20340 not clear what this assignment means. It could correspond to full word read
20341 and write as given in the first example, or on architectures that supported
20342 such an operation it might be a single byte store instruction. The RM does
20343 not have anything to say in this situation, and GNAT does not make any
20344 guarantee. The code generated may vary from target to target. GNAT will issue
20345 a warning in such a case:
20346
20347 @example
20348 Mem.A := 32;
20349 |
20350 >>> warning: access to non-atomic component of atomic array,
20351 may cause unexpected accesses to atomic object
20352 @end example
20353
20354 It is best to be explicit in this situation, by either declaring the
20355 components to be atomic if you want the byte store, or explicitly writing
20356 the full word access sequence if that is what the hardware requires.
20357 Alternatively, if the full word access sequence is required, GNAT also
20358 provides the pragma @code{Volatile_Full_Access} which can be used in lieu of
20359 pragma @code{Atomic} and will give the additional guarantee.
20360
20361 @node Effect of Convention on Representation,Conventions and Anonymous Access Types,Use of Address Clauses for Memory-Mapped I/O,Representation Clauses and Pragmas
20362 @anchor{gnat_rm/representation_clauses_and_pragmas id18}@anchor{296}@anchor{gnat_rm/representation_clauses_and_pragmas effect-of-convention-on-representation}@anchor{297}
20363 @section Effect of Convention on Representation
20364
20365
20366 @geindex Convention
20367 @geindex effect on representation
20368
20369 Normally the specification of a foreign language convention for a type or
20370 an object has no effect on the chosen representation. In particular, the
20371 representation chosen for data in GNAT generally meets the standard system
20372 conventions, and for example records are laid out in a manner that is
20373 consistent with C. This means that specifying convention C (for example)
20374 has no effect.
20375
20376 There are four exceptions to this general rule:
20377
20378
20379 @itemize *
20380
20381 @item
20382 @emph{Convention Fortran and array subtypes}.
20383
20384 If pragma Convention Fortran is specified for an array subtype, then in
20385 accordance with the implementation advice in section 3.6.2(11) of the
20386 Ada Reference Manual, the array will be stored in a Fortran-compatible
20387 column-major manner, instead of the normal default row-major order.
20388
20389 @item
20390 @emph{Convention C and enumeration types}
20391
20392 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
20393 to accommodate all values of the type. For example, for the enumeration
20394 type declared by:
20395
20396 @example
20397 type Color is (Red, Green, Blue);
20398 @end example
20399
20400 8 bits is sufficient to store all values of the type, so by default, objects
20401 of type @code{Color} will be represented using 8 bits. However, normal C
20402 convention is to use 32 bits for all enum values in C, since enum values
20403 are essentially of type int. If pragma @code{Convention C} is specified for an
20404 Ada enumeration type, then the size is modified as necessary (usually to
20405 32 bits) to be consistent with the C convention for enum values.
20406
20407 Note that this treatment applies only to types. If Convention C is given for
20408 an enumeration object, where the enumeration type is not Convention C, then
20409 Object_Size bits are allocated. For example, for a normal enumeration type,
20410 with less than 256 elements, only 8 bits will be allocated for the object.
20411 Since this may be a surprise in terms of what C expects, GNAT will issue a
20412 warning in this situation. The warning can be suppressed by giving an explicit
20413 size clause specifying the desired size.
20414
20415 @item
20416 @emph{Convention C/Fortran and Boolean types}
20417
20418 In C, the usual convention for boolean values, that is values used for
20419 conditions, is that zero represents false, and nonzero values represent
20420 true. In Ada, the normal convention is that two specific values, typically
20421 0/1, are used to represent false/true respectively.
20422
20423 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
20424 value represents true).
20425
20426 To accommodate the Fortran and C conventions, if a pragma Convention specifies
20427 C or Fortran convention for a derived Boolean, as in the following example:
20428
20429 @example
20430 type C_Switch is new Boolean;
20431 pragma Convention (C, C_Switch);
20432 @end example
20433
20434 then the GNAT generated code will treat any nonzero value as true. For truth
20435 values generated by GNAT, the conventional value 1 will be used for True, but
20436 when one of these values is read, any nonzero value is treated as True.
20437 @end itemize
20438
20439 @node Conventions and Anonymous Access Types,Determining the Representations chosen by GNAT,Effect of Convention on Representation,Representation Clauses and Pragmas
20440 @anchor{gnat_rm/representation_clauses_and_pragmas conventions-and-anonymous-access-types}@anchor{298}@anchor{gnat_rm/representation_clauses_and_pragmas id19}@anchor{299}
20441 @section Conventions and Anonymous Access Types
20442
20443
20444 @geindex Anonymous access types
20445
20446 @geindex Convention for anonymous access types
20447
20448 The RM is not entirely clear on convention handling in a number of cases,
20449 and in particular, it is not clear on the convention to be given to
20450 anonymous access types in general, and in particular what is to be
20451 done for the case of anonymous access-to-subprogram.
20452
20453 In GNAT, we decide that if an explicit Convention is applied
20454 to an object or component, and its type is such an anonymous type,
20455 then the convention will apply to this anonymous type as well. This
20456 seems to make sense since it is anomolous in any case to have a
20457 different convention for an object and its type, and there is clearly
20458 no way to explicitly specify a convention for an anonymous type, since
20459 it doesn't have a name to specify!
20460
20461 Furthermore, we decide that if a convention is applied to a record type,
20462 then this convention is inherited by any of its components that are of an
20463 anonymous access type which do not have an explicitly specified convention.
20464
20465 The following program shows these conventions in action:
20466
20467 @example
20468 package ConvComp is
20469 type Foo is range 1 .. 10;
20470 type T1 is record
20471 A : access function (X : Foo) return Integer;
20472 B : Integer;
20473 end record;
20474 pragma Convention (C, T1);
20475
20476 type T2 is record
20477 A : access function (X : Foo) return Integer;
20478 pragma Convention (C, A);
20479 B : Integer;
20480 end record;
20481 pragma Convention (COBOL, T2);
20482
20483 type T3 is record
20484 A : access function (X : Foo) return Integer;
20485 pragma Convention (COBOL, A);
20486 B : Integer;
20487 end record;
20488 pragma Convention (C, T3);
20489
20490 type T4 is record
20491 A : access function (X : Foo) return Integer;
20492 B : Integer;
20493 end record;
20494 pragma Convention (COBOL, T4);
20495
20496 function F (X : Foo) return Integer;
20497 pragma Convention (C, F);
20498
20499 function F (X : Foo) return Integer is (13);
20500
20501 TV1 : T1 := (F'Access, 12); -- OK
20502 TV2 : T2 := (F'Access, 13); -- OK
20503
20504 TV3 : T3 := (F'Access, 13); -- ERROR
20505 |
20506 >>> subprogram "F" has wrong convention
20507 >>> does not match access to subprogram declared at line 17
20508 38. TV4 : T4 := (F'Access, 13); -- ERROR
20509 |
20510 >>> subprogram "F" has wrong convention
20511 >>> does not match access to subprogram declared at line 24
20512 39. end ConvComp;
20513 @end example
20514
20515 @node Determining the Representations chosen by GNAT,,Conventions and Anonymous Access Types,Representation Clauses and Pragmas
20516 @anchor{gnat_rm/representation_clauses_and_pragmas id20}@anchor{29a}@anchor{gnat_rm/representation_clauses_and_pragmas determining-the-representations-chosen-by-gnat}@anchor{29b}
20517 @section Determining the Representations chosen by GNAT
20518
20519
20520 @geindex Representation
20521 @geindex determination of
20522
20523 @geindex -gnatR (gcc)
20524
20525 Although the descriptions in this section are intended to be complete, it is
20526 often easier to simply experiment to see what GNAT accepts and what the
20527 effect is on the layout of types and objects.
20528
20529 As required by the Ada RM, if a representation clause is not accepted, then
20530 it must be rejected as illegal by the compiler. However, when a
20531 representation clause or pragma is accepted, there can still be questions
20532 of what the compiler actually does. For example, if a partial record
20533 representation clause specifies the location of some components and not
20534 others, then where are the non-specified components placed? Or if pragma
20535 @code{Pack} is used on a record, then exactly where are the resulting
20536 fields placed? The section on pragma @code{Pack} in this chapter can be
20537 used to answer the second question, but it is often easier to just see
20538 what the compiler does.
20539
20540 For this purpose, GNAT provides the option @emph{-gnatR}. If you compile
20541 with this option, then the compiler will output information on the actual
20542 representations chosen, in a format similar to source representation
20543 clauses. For example, if we compile the package:
20544
20545 @example
20546 package q is
20547 type r (x : boolean) is tagged record
20548 case x is
20549 when True => S : String (1 .. 100);
20550 when False => null;
20551 end case;
20552 end record;
20553
20554 type r2 is new r (false) with record
20555 y2 : integer;
20556 end record;
20557
20558 for r2 use record
20559 y2 at 16 range 0 .. 31;
20560 end record;
20561
20562 type x is record
20563 y : character;
20564 end record;
20565
20566 type x1 is array (1 .. 10) of x;
20567 for x1'component_size use 11;
20568
20569 type ia is access integer;
20570
20571 type Rb1 is array (1 .. 13) of Boolean;
20572 pragma Pack (rb1);
20573
20574 type Rb2 is array (1 .. 65) of Boolean;
20575 pragma Pack (rb2);
20576
20577 type x2 is record
20578 l1 : Boolean;
20579 l2 : Duration;
20580 l3 : Float;
20581 l4 : Boolean;
20582 l5 : Rb1;
20583 l6 : Rb2;
20584 end record;
20585 pragma Pack (x2);
20586 end q;
20587 @end example
20588
20589 using the switch @emph{-gnatR} we obtain the following output:
20590
20591 @example
20592 Representation information for unit q
20593 -------------------------------------
20594
20595 for r'Size use ??;
20596 for r'Alignment use 4;
20597 for r use record
20598 x at 4 range 0 .. 7;
20599 _tag at 0 range 0 .. 31;
20600 s at 5 range 0 .. 799;
20601 end record;
20602
20603 for r2'Size use 160;
20604 for r2'Alignment use 4;
20605 for r2 use record
20606 x at 4 range 0 .. 7;
20607 _tag at 0 range 0 .. 31;
20608 _parent at 0 range 0 .. 63;
20609 y2 at 16 range 0 .. 31;
20610 end record;
20611
20612 for x'Size use 8;
20613 for x'Alignment use 1;
20614 for x use record
20615 y at 0 range 0 .. 7;
20616 end record;
20617
20618 for x1'Size use 112;
20619 for x1'Alignment use 1;
20620 for x1'Component_Size use 11;
20621
20622 for rb1'Size use 13;
20623 for rb1'Alignment use 2;
20624 for rb1'Component_Size use 1;
20625
20626 for rb2'Size use 72;
20627 for rb2'Alignment use 1;
20628 for rb2'Component_Size use 1;
20629
20630 for x2'Size use 224;
20631 for x2'Alignment use 4;
20632 for x2 use record
20633 l1 at 0 range 0 .. 0;
20634 l2 at 0 range 1 .. 64;
20635 l3 at 12 range 0 .. 31;
20636 l4 at 16 range 0 .. 0;
20637 l5 at 16 range 1 .. 13;
20638 l6 at 18 range 0 .. 71;
20639 end record;
20640 @end example
20641
20642 The Size values are actually the Object_Size, i.e., the default size that
20643 will be allocated for objects of the type.
20644 The @code{??} size for type r indicates that we have a variant record, and the
20645 actual size of objects will depend on the discriminant value.
20646
20647 The Alignment values show the actual alignment chosen by the compiler
20648 for each record or array type.
20649
20650 The record representation clause for type r shows where all fields
20651 are placed, including the compiler generated tag field (whose location
20652 cannot be controlled by the programmer).
20653
20654 The record representation clause for the type extension r2 shows all the
20655 fields present, including the parent field, which is a copy of the fields
20656 of the parent type of r2, i.e., r1.
20657
20658 The component size and size clauses for types rb1 and rb2 show
20659 the exact effect of pragma @code{Pack} on these arrays, and the record
20660 representation clause for type x2 shows how pragma @cite{Pack} affects
20661 this record type.
20662
20663 In some cases, it may be useful to cut and paste the representation clauses
20664 generated by the compiler into the original source to fix and guarantee
20665 the actual representation to be used.
20666
20667 @node Standard Library Routines,The Implementation of Standard I/O,Representation Clauses and Pragmas,Top
20668 @anchor{gnat_rm/standard_library_routines standard-library-routines}@anchor{e}@anchor{gnat_rm/standard_library_routines doc}@anchor{29c}@anchor{gnat_rm/standard_library_routines id1}@anchor{29d}
20669 @chapter Standard Library Routines
20670
20671
20672 The Ada Reference Manual contains in Annex A a full description of an
20673 extensive set of standard library routines that can be used in any Ada
20674 program, and which must be provided by all Ada compilers. They are
20675 analogous to the standard C library used by C programs.
20676
20677 GNAT implements all of the facilities described in annex A, and for most
20678 purposes the description in the Ada Reference Manual, or appropriate Ada
20679 text book, will be sufficient for making use of these facilities.
20680
20681 In the case of the input-output facilities,
20682 @ref{f,,The Implementation of Standard I/O},
20683 gives details on exactly how GNAT interfaces to the
20684 file system. For the remaining packages, the Ada Reference Manual
20685 should be sufficient. The following is a list of the packages included,
20686 together with a brief description of the functionality that is provided.
20687
20688 For completeness, references are included to other predefined library
20689 routines defined in other sections of the Ada Reference Manual (these are
20690 cross-indexed from Annex A). For further details see the relevant
20691 package declarations in the run-time library. In particular, a few units
20692 are not implemented, as marked by the presence of pragma Unimplemented_Unit,
20693 and in this case the package declaration contains comments explaining why
20694 the unit is not implemented.
20695
20696
20697 @table @asis
20698
20699 @item @code{Ada} @emph{(A.2)}
20700
20701 This is a parent package for all the standard library packages. It is
20702 usually included implicitly in your program, and itself contains no
20703 useful data or routines.
20704
20705 @item @code{Ada.Assertions} @emph{(11.4.2)}
20706
20707 @code{Assertions} provides the @code{Assert} subprograms, and also
20708 the declaration of the @code{Assertion_Error} exception.
20709
20710 @item @code{Ada.Asynchronous_Task_Control} @emph{(D.11)}
20711
20712 @code{Asynchronous_Task_Control} provides low level facilities for task
20713 synchronization. It is typically not implemented. See package spec for details.
20714
20715 @item @code{Ada.Calendar} @emph{(9.6)}
20716
20717 @code{Calendar} provides time of day access, and routines for
20718 manipulating times and durations.
20719
20720 @item @code{Ada.Calendar.Arithmetic} @emph{(9.6.1)}
20721
20722 This package provides additional arithmetic
20723 operations for @code{Calendar}.
20724
20725 @item @code{Ada.Calendar.Formatting} @emph{(9.6.1)}
20726
20727 This package provides formatting operations for @code{Calendar}.
20728
20729 @item @code{Ada.Calendar.Time_Zones} @emph{(9.6.1)}
20730
20731 This package provides additional @code{Calendar} facilities
20732 for handling time zones.
20733
20734 @item @code{Ada.Characters} @emph{(A.3.1)}
20735
20736 This is a dummy parent package that contains no useful entities
20737
20738 @item @code{Ada.Characters.Conversions} @emph{(A.3.2)}
20739
20740 This package provides character conversion functions.
20741
20742 @item @code{Ada.Characters.Handling} @emph{(A.3.2)}
20743
20744 This package provides some basic character handling capabilities,
20745 including classification functions for classes of characters (e.g., test
20746 for letters, or digits).
20747
20748 @item @code{Ada.Characters.Latin_1} @emph{(A.3.3)}
20749
20750 This package includes a complete set of definitions of the characters
20751 that appear in type CHARACTER. It is useful for writing programs that
20752 will run in international environments. For example, if you want an
20753 upper case E with an acute accent in a string, it is often better to use
20754 the definition of @code{UC_E_Acute} in this package. Then your program
20755 will print in an understandable manner even if your environment does not
20756 support these extended characters.
20757
20758 @item @code{Ada.Command_Line} @emph{(A.15)}
20759
20760 This package provides access to the command line parameters and the name
20761 of the current program (analogous to the use of @code{argc} and @code{argv}
20762 in C), and also allows the exit status for the program to be set in a
20763 system-independent manner.
20764
20765 @item @code{Ada.Complex_Text_IO} @emph{(G.1.3)}
20766
20767 This package provides text input and output of complex numbers.
20768
20769 @item @code{Ada.Containers} @emph{(A.18.1)}
20770
20771 A top level package providing a few basic definitions used by all the
20772 following specific child packages that provide specific kinds of
20773 containers.
20774 @end table
20775
20776 @code{Ada.Containers.Bounded_Priority_Queues} @emph{(A.18.31)}
20777
20778 @code{Ada.Containers.Bounded_Synchronized_Queues} @emph{(A.18.29)}
20779
20780 @code{Ada.Containers.Doubly_Linked_Lists} @emph{(A.18.3)}
20781
20782 @code{Ada.Containers.Generic_Array_Sort} @emph{(A.18.26)}
20783
20784 @code{Ada.Containers.Generic_Constrained_Array_Sort} @emph{(A.18.26)}
20785
20786 @code{Ada.Containers.Generic_Sort} @emph{(A.18.26)}
20787
20788 @code{Ada.Containers.Hashed_Maps} @emph{(A.18.5)}
20789
20790 @code{Ada.Containers.Hashed_Sets} @emph{(A.18.8)}
20791
20792 @code{Ada.Containers.Indefinite_Doubly_Linked_Lists} @emph{(A.18.12)}
20793
20794 @code{Ada.Containers.Indefinite_Hashed_Maps} @emph{(A.18.13)}
20795
20796 @code{Ada.Containers.Indefinite_Hashed_Sets} @emph{(A.18.15)}
20797
20798 @code{Ada.Containers.Indefinite_Holders} @emph{(A.18.18)}
20799
20800 @code{Ada.Containers.Indefinite_Multiway_Trees} @emph{(A.18.17)}
20801
20802 @code{Ada.Containers.Indefinite_Ordered_Maps} @emph{(A.18.14)}
20803
20804 @code{Ada.Containers.Indefinite_Ordered_Sets} @emph{(A.18.16)}
20805
20806 @code{Ada.Containers.Indefinite_Vectors} @emph{(A.18.11)}
20807
20808 @code{Ada.Containers.Multiway_Trees} @emph{(A.18.10)}
20809
20810 @code{Ada.Containers.Ordered_Maps} @emph{(A.18.6)}
20811
20812 @code{Ada.Containers.Ordered_Sets} @emph{(A.18.9)}
20813
20814 @code{Ada.Containers.Synchronized_Queue_Interfaces} @emph{(A.18.27)}
20815
20816 @code{Ada.Containers.Unbounded_Priority_Queues} @emph{(A.18.30)}
20817
20818 @code{Ada.Containers.Unbounded_Synchronized_Queues} @emph{(A.18.28)}
20819
20820 @code{Ada.Containers.Vectors} @emph{(A.18.2)}
20821
20822
20823 @table @asis
20824
20825 @item @code{Ada.Directories} @emph{(A.16)}
20826
20827 This package provides operations on directories.
20828
20829 @item @code{Ada.Directories.Hierarchical_File_Names} @emph{(A.16.1)}
20830
20831 This package provides additional directory operations handling
20832 hiearchical file names.
20833
20834 @item @code{Ada.Directories.Information} @emph{(A.16)}
20835
20836 This is an implementation defined package for additional directory
20837 operations, which is not implemented in GNAT.
20838
20839 @item @code{Ada.Decimal} @emph{(F.2)}
20840
20841 This package provides constants describing the range of decimal numbers
20842 implemented, and also a decimal divide routine (analogous to the COBOL
20843 verb DIVIDE ... GIVING ... REMAINDER ...)
20844
20845 @item @code{Ada.Direct_IO} @emph{(A.8.4)}
20846
20847 This package provides input-output using a model of a set of records of
20848 fixed-length, containing an arbitrary definite Ada type, indexed by an
20849 integer record number.
20850
20851 @item @code{Ada.Dispatching} @emph{(D.2.1)}
20852
20853 A parent package containing definitions for task dispatching operations.
20854
20855 @item @code{Ada.Dispatching.EDF} @emph{(D.2.6)}
20856
20857 Not implemented in GNAT.
20858
20859 @item @code{Ada.Dispatching.Non_Preemptive} @emph{(D.2.4)}
20860
20861 Not implemented in GNAT.
20862
20863 @item @code{Ada.Dispatching.Round_Robin} @emph{(D.2.5)}
20864
20865 Not implemented in GNAT.
20866
20867 @item @code{Ada.Dynamic_Priorities} @emph{(D.5)}
20868
20869 This package allows the priorities of a task to be adjusted dynamically
20870 as the task is running.
20871
20872 @item @code{Ada.Environment_Variables} @emph{(A.17)}
20873
20874 This package provides facilities for accessing environment variables.
20875
20876 @item @code{Ada.Exceptions} @emph{(11.4.1)}
20877
20878 This package provides additional information on exceptions, and also
20879 contains facilities for treating exceptions as data objects, and raising
20880 exceptions with associated messages.
20881
20882 @item @code{Ada.Execution_Time} @emph{(D.14)}
20883
20884 This package provides CPU clock functionalities. It is not implemented on
20885 all targets (see package spec for details).
20886
20887 @item @code{Ada.Execution_Time.Group_Budgets} @emph{(D.14.2)}
20888
20889 Not implemented in GNAT.
20890
20891 @item @code{Ada.Execution_Time.Timers} @emph{(D.14.1)'}
20892
20893 Not implemented in GNAT.
20894
20895 @item @code{Ada.Finalization} @emph{(7.6)}
20896
20897 This package contains the declarations and subprograms to support the
20898 use of controlled types, providing for automatic initialization and
20899 finalization (analogous to the constructors and destructors of C++).
20900
20901 @item @code{Ada.Float_Text_IO} @emph{(A.10.9)}
20902
20903 A library level instantiation of Text_IO.Float_IO for type Float.
20904
20905 @item @code{Ada.Float_Wide_Text_IO} @emph{(A.10.9)}
20906
20907 A library level instantiation of Wide_Text_IO.Float_IO for type Float.
20908
20909 @item @code{Ada.Float_Wide_Wide_Text_IO} @emph{(A.10.9)}
20910
20911 A library level instantiation of Wide_Wide_Text_IO.Float_IO for type Float.
20912
20913 @item @code{Ada.Integer_Text_IO} @emph{(A.10.9)}
20914
20915 A library level instantiation of Text_IO.Integer_IO for type Integer.
20916
20917 @item @code{Ada.Integer_Wide_Text_IO} @emph{(A.10.9)}
20918
20919 A library level instantiation of Wide_Text_IO.Integer_IO for type Integer.
20920
20921 @item @code{Ada.Integer_Wide_Wide_Text_IO} @emph{(A.10.9)}
20922
20923 A library level instantiation of Wide_Wide_Text_IO.Integer_IO for type Integer.
20924
20925 @item @code{Ada.Interrupts} @emph{(C.3.2)}
20926
20927 This package provides facilities for interfacing to interrupts, which
20928 includes the set of signals or conditions that can be raised and
20929 recognized as interrupts.
20930
20931 @item @code{Ada.Interrupts.Names} @emph{(C.3.2)}
20932
20933 This package provides the set of interrupt names (actually signal
20934 or condition names) that can be handled by GNAT.
20935
20936 @item @code{Ada.IO_Exceptions} @emph{(A.13)}
20937
20938 This package defines the set of exceptions that can be raised by use of
20939 the standard IO packages.
20940
20941 @item @code{Ada.Iterator_Interfaces} @emph{(5.5.1)}
20942
20943 This package provides a generic interface to generalized iterators.
20944
20945 @item @code{Ada.Locales} @emph{(A.19)}
20946
20947 This package provides declarations providing information (Language
20948 and Country) about the current locale.
20949
20950 @item @code{Ada.Numerics}
20951
20952 This package contains some standard constants and exceptions used
20953 throughout the numerics packages. Note that the constants pi and e are
20954 defined here, and it is better to use these definitions than rolling
20955 your own.
20956
20957 @item @code{Ada.Numerics.Complex_Arrays} @emph{(G.3.2)}
20958
20959 Provides operations on arrays of complex numbers.
20960
20961 @item @code{Ada.Numerics.Complex_Elementary_Functions}
20962
20963 Provides the implementation of standard elementary functions (such as
20964 log and trigonometric functions) operating on complex numbers using the
20965 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
20966 created by the package @code{Numerics.Complex_Types}.
20967
20968 @item @code{Ada.Numerics.Complex_Types}
20969
20970 This is a predefined instantiation of
20971 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
20972 build the type @code{Complex} and @code{Imaginary}.
20973
20974 @item @code{Ada.Numerics.Discrete_Random}
20975
20976 This generic package provides a random number generator suitable for generating
20977 uniformly distributed values of a specified discrete subtype.
20978
20979 @item @code{Ada.Numerics.Float_Random}
20980
20981 This package provides a random number generator suitable for generating
20982 uniformly distributed floating point values in the unit interval.
20983
20984 @item @code{Ada.Numerics.Generic_Complex_Elementary_Functions}
20985
20986 This is a generic version of the package that provides the
20987 implementation of standard elementary functions (such as log and
20988 trigonometric functions) for an arbitrary complex type.
20989
20990 The following predefined instantiations of this package are provided:
20991
20992
20993 @itemize *
20994
20995 @item
20996 @code{Short_Float}
20997
20998 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
20999
21000 @item
21001 @code{Float}
21002
21003 @code{Ada.Numerics.Complex_Elementary_Functions}
21004
21005 @item
21006 @code{Long_Float}
21007
21008 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
21009 @end itemize
21010
21011 @item @code{Ada.Numerics.Generic_Complex_Types}
21012
21013 This is a generic package that allows the creation of complex types,
21014 with associated complex arithmetic operations.
21015
21016 The following predefined instantiations of this package exist
21017
21018
21019 @itemize *
21020
21021 @item
21022 @code{Short_Float}
21023
21024 @code{Ada.Numerics.Short_Complex_Complex_Types}
21025
21026 @item
21027 @code{Float}
21028
21029 @code{Ada.Numerics.Complex_Complex_Types}
21030
21031 @item
21032 @code{Long_Float}
21033
21034 @code{Ada.Numerics.Long_Complex_Complex_Types}
21035 @end itemize
21036
21037 @item @code{Ada.Numerics.Generic_Elementary_Functions}
21038
21039 This is a generic package that provides the implementation of standard
21040 elementary functions (such as log an trigonometric functions) for an
21041 arbitrary float type.
21042
21043 The following predefined instantiations of this package exist
21044
21045
21046 @itemize *
21047
21048 @item
21049 @code{Short_Float}
21050
21051 @code{Ada.Numerics.Short_Elementary_Functions}
21052
21053 @item
21054 @code{Float}
21055
21056 @code{Ada.Numerics.Elementary_Functions}
21057
21058 @item
21059 @code{Long_Float}
21060
21061 @code{Ada.Numerics.Long_Elementary_Functions}
21062 @end itemize
21063
21064 @item @code{Ada.Numerics.Generic_Real_Arrays} @emph{(G.3.1)}
21065
21066 Generic operations on arrays of reals
21067
21068 @item @code{Ada.Numerics.Real_Arrays} @emph{(G.3.1)}
21069
21070 Preinstantiation of Ada.Numerics.Generic_Real_Arrays (Float).
21071
21072 @item @code{Ada.Real_Time} @emph{(D.8)}
21073
21074 This package provides facilities similar to those of @code{Calendar}, but
21075 operating with a finer clock suitable for real time control. Note that
21076 annex D requires that there be no backward clock jumps, and GNAT generally
21077 guarantees this behavior, but of course if the external clock on which
21078 the GNAT runtime depends is deliberately reset by some external event,
21079 then such a backward jump may occur.
21080
21081 @item @code{Ada.Real_Time.Timing_Events} @emph{(D.15)}
21082
21083 Not implemented in GNAT.
21084
21085 @item @code{Ada.Sequential_IO} @emph{(A.8.1)}
21086
21087 This package provides input-output facilities for sequential files,
21088 which can contain a sequence of values of a single type, which can be
21089 any Ada type, including indefinite (unconstrained) types.
21090
21091 @item @code{Ada.Storage_IO} @emph{(A.9)}
21092
21093 This package provides a facility for mapping arbitrary Ada types to and
21094 from a storage buffer. It is primarily intended for the creation of new
21095 IO packages.
21096
21097 @item @code{Ada.Streams} @emph{(13.13.1)}
21098
21099 This is a generic package that provides the basic support for the
21100 concept of streams as used by the stream attributes (@code{Input},
21101 @code{Output}, @code{Read} and @code{Write}).
21102
21103 @item @code{Ada.Streams.Stream_IO} @emph{(A.12.1)}
21104
21105 This package is a specialization of the type @code{Streams} defined in
21106 package @code{Streams} together with a set of operations providing
21107 Stream_IO capability. The Stream_IO model permits both random and
21108 sequential access to a file which can contain an arbitrary set of values
21109 of one or more Ada types.
21110
21111 @item @code{Ada.Strings} @emph{(A.4.1)}
21112
21113 This package provides some basic constants used by the string handling
21114 packages.
21115
21116 @item @code{Ada.Strings.Bounded} @emph{(A.4.4)}
21117
21118 This package provides facilities for handling variable length
21119 strings. The bounded model requires a maximum length. It is thus
21120 somewhat more limited than the unbounded model, but avoids the use of
21121 dynamic allocation or finalization.
21122
21123 @item @code{Ada.Strings.Bounded.Equal_Case_Insensitive} @emph{(A.4.10)}
21124
21125 Provides case-insensitive comparisons of bounded strings
21126
21127 @item @code{Ada.Strings.Bounded.Hash} @emph{(A.4.9)}
21128
21129 This package provides a generic hash function for bounded strings
21130
21131 @item @code{Ada.Strings.Bounded.Hash_Case_Insensitive} @emph{(A.4.9)}
21132
21133 This package provides a generic hash function for bounded strings that
21134 converts the string to be hashed to lower case.
21135
21136 @item @code{Ada.Strings.Bounded.Less_Case_Insensitive} @emph{(A.4.10)}
21137
21138 This package provides a comparison function for bounded strings that works
21139 in a case insensitive manner by converting to lower case before the comparison.
21140
21141 @item @code{Ada.Strings.Fixed} @emph{(A.4.3)}
21142
21143 This package provides facilities for handling fixed length strings.
21144
21145 @item @code{Ada.Strings.Fixed.Equal_Case_Insensitive} @emph{(A.4.10)}
21146
21147 This package provides an equality function for fixed strings that compares
21148 the strings after converting both to lower case.
21149
21150 @item @code{Ada.Strings.Fixed.Hash_Case_Insensitive} @emph{(A.4.9)}
21151
21152 This package provides a case insensitive hash function for fixed strings that
21153 converts the string to lower case before computing the hash.
21154
21155 @item @code{Ada.Strings.Fixed.Less_Case_Insensitive} @emph{(A.4.10)}
21156
21157 This package provides a comparison function for fixed strings that works
21158 in a case insensitive manner by converting to lower case before the comparison.
21159
21160 @item @code{Ada.Strings.Hash} @emph{(A.4.9)}
21161
21162 This package provides a hash function for strings.
21163
21164 @item @code{Ada.Strings.Hash_Case_Insensitive} @emph{(A.4.9)}
21165
21166 This package provides a hash function for strings that is case insensitive.
21167 The string is converted to lower case before computing the hash.
21168
21169 @item @code{Ada.Strings.Less_Case_Insensitive} @emph{(A.4.10)}
21170
21171 This package provides a comparison function for\strings that works
21172 in a case insensitive manner by converting to lower case before the comparison.
21173
21174 @item @code{Ada.Strings.Maps} @emph{(A.4.2)}
21175
21176 This package provides facilities for handling character mappings and
21177 arbitrarily defined subsets of characters. For instance it is useful in
21178 defining specialized translation tables.
21179
21180 @item @code{Ada.Strings.Maps.Constants} @emph{(A.4.6)}
21181
21182 This package provides a standard set of predefined mappings and
21183 predefined character sets. For example, the standard upper to lower case
21184 conversion table is found in this package. Note that upper to lower case
21185 conversion is non-trivial if you want to take the entire set of
21186 characters, including extended characters like E with an acute accent,
21187 into account. You should use the mappings in this package (rather than
21188 adding 32 yourself) to do case mappings.
21189
21190 @item @code{Ada.Strings.Unbounded} @emph{(A.4.5)}
21191
21192 This package provides facilities for handling variable length
21193 strings. The unbounded model allows arbitrary length strings, but
21194 requires the use of dynamic allocation and finalization.
21195
21196 @item @code{Ada.Strings.Unbounded.Equal_Case_Insensitive} @emph{(A.4.10)}
21197
21198 Provides case-insensitive comparisons of unbounded strings
21199
21200 @item @code{Ada.Strings.Unbounded.Hash} @emph{(A.4.9)}
21201
21202 This package provides a generic hash function for unbounded strings
21203
21204 @item @code{Ada.Strings.Unbounded.Hash_Case_Insensitive} @emph{(A.4.9)}
21205
21206 This package provides a generic hash function for unbounded strings that
21207 converts the string to be hashed to lower case.
21208
21209 @item @code{Ada.Strings.Unbounded.Less_Case_Insensitive} @emph{(A.4.10)}
21210
21211 This package provides a comparison function for unbounded strings that works
21212 in a case insensitive manner by converting to lower case before the comparison.
21213
21214 @item @code{Ada.Strings.UTF_Encoding} @emph{(A.4.11)}
21215
21216 This package provides basic definitions for dealing with UTF-encoded strings.
21217
21218 @item @code{Ada.Strings.UTF_Encoding.Conversions} @emph{(A.4.11)}
21219
21220 This package provides conversion functions for UTF-encoded strings.
21221 @end table
21222
21223 @code{Ada.Strings.UTF_Encoding.Strings} @emph{(A.4.11)}
21224
21225 @code{Ada.Strings.UTF_Encoding.Wide_Strings} @emph{(A.4.11)}
21226
21227
21228 @table @asis
21229
21230 @item @code{Ada.Strings.UTF_Encoding.Wide_Wide_Strings} @emph{(A.4.11)}
21231
21232 These packages provide facilities for handling UTF encodings for
21233 Strings, Wide_Strings and Wide_Wide_Strings.
21234 @end table
21235
21236 @code{Ada.Strings.Wide_Bounded} @emph{(A.4.7)}
21237
21238 @code{Ada.Strings.Wide_Fixed} @emph{(A.4.7)}
21239
21240 @code{Ada.Strings.Wide_Maps} @emph{(A.4.7)}
21241
21242
21243 @table @asis
21244
21245 @item @code{Ada.Strings.Wide_Unbounded} @emph{(A.4.7)}
21246
21247 These packages provide analogous capabilities to the corresponding
21248 packages without @code{Wide_} in the name, but operate with the types
21249 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
21250 and @code{Character}. Versions of all the child packages are available.
21251 @end table
21252
21253 @code{Ada.Strings.Wide_Wide_Bounded} @emph{(A.4.7)}
21254
21255 @code{Ada.Strings.Wide_Wide_Fixed} @emph{(A.4.7)}
21256
21257 @code{Ada.Strings.Wide_Wide_Maps} @emph{(A.4.7)}
21258
21259
21260 @table @asis
21261
21262 @item @code{Ada.Strings.Wide_Wide_Unbounded} @emph{(A.4.7)}
21263
21264 These packages provide analogous capabilities to the corresponding
21265 packages without @code{Wide_} in the name, but operate with the types
21266 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
21267 of @code{String} and @code{Character}.
21268
21269 @item @code{Ada.Synchronous_Barriers} @emph{(D.10.1)}
21270
21271 This package provides facilities for synchronizing tasks at a low level
21272 with barriers.
21273
21274 @item @code{Ada.Synchronous_Task_Control} @emph{(D.10)}
21275
21276 This package provides some standard facilities for controlling task
21277 communication in a synchronous manner.
21278
21279 @item @code{Ada.Synchronous_Task_Control.EDF} @emph{(D.10)}
21280
21281 Not implemented in GNAT.
21282
21283 @item @code{Ada.Tags}
21284
21285 This package contains definitions for manipulation of the tags of tagged
21286 values.
21287
21288 @item @code{Ada.Tags.Generic_Dispatching_Constructor} @emph{(3.9)}
21289
21290 This package provides a way of constructing tagged class-wide values given
21291 only the tag value.
21292
21293 @item @code{Ada.Task_Attributes} @emph{(C.7.2)}
21294
21295 This package provides the capability of associating arbitrary
21296 task-specific data with separate tasks.
21297
21298 @item @code{Ada.Task_Identifification} @emph{(C.7.1)}
21299
21300 This package provides capabilities for task identification.
21301
21302 @item @code{Ada.Task_Termination} @emph{(C.7.3)}
21303
21304 This package provides control over task termination.
21305
21306 @item @code{Ada.Text_IO}
21307
21308 This package provides basic text input-output capabilities for
21309 character, string and numeric data. The subpackages of this
21310 package are listed next. Note that although these are defined
21311 as subpackages in the RM, they are actually transparently
21312 implemented as child packages in GNAT, meaning that they
21313 are only loaded if needed.
21314
21315 @item @code{Ada.Text_IO.Decimal_IO}
21316
21317 Provides input-output facilities for decimal fixed-point types
21318
21319 @item @code{Ada.Text_IO.Enumeration_IO}
21320
21321 Provides input-output facilities for enumeration types.
21322
21323 @item @code{Ada.Text_IO.Fixed_IO}
21324
21325 Provides input-output facilities for ordinary fixed-point types.
21326
21327 @item @code{Ada.Text_IO.Float_IO}
21328
21329 Provides input-output facilities for float types. The following
21330 predefined instantiations of this generic package are available:
21331
21332
21333 @itemize *
21334
21335 @item
21336 @code{Short_Float}
21337
21338 @code{Short_Float_Text_IO}
21339
21340 @item
21341 @code{Float}
21342
21343 @code{Float_Text_IO}
21344
21345 @item
21346 @code{Long_Float}
21347
21348 @code{Long_Float_Text_IO}
21349 @end itemize
21350
21351 @item @code{Ada.Text_IO.Integer_IO}
21352
21353 Provides input-output facilities for integer types. The following
21354 predefined instantiations of this generic package are available:
21355
21356
21357 @itemize *
21358
21359 @item
21360 @code{Short_Short_Integer}
21361
21362 @code{Ada.Short_Short_Integer_Text_IO}
21363
21364 @item
21365 @code{Short_Integer}
21366
21367 @code{Ada.Short_Integer_Text_IO}
21368
21369 @item
21370 @code{Integer}
21371
21372 @code{Ada.Integer_Text_IO}
21373
21374 @item
21375 @code{Long_Integer}
21376
21377 @code{Ada.Long_Integer_Text_IO}
21378
21379 @item
21380 @code{Long_Long_Integer}
21381
21382 @code{Ada.Long_Long_Integer_Text_IO}
21383 @end itemize
21384
21385 @item @code{Ada.Text_IO.Modular_IO}
21386
21387 Provides input-output facilities for modular (unsigned) types.
21388
21389 @item @code{Ada.Text_IO.Bounded_IO (A.10.11)}
21390
21391 Provides input-output facilities for bounded strings.
21392
21393 @item @code{Ada.Text_IO.Complex_IO (G.1.3)}
21394
21395 This package provides basic text input-output capabilities for complex
21396 data.
21397
21398 @item @code{Ada.Text_IO.Editing (F.3.3)}
21399
21400 This package contains routines for edited output, analogous to the use
21401 of pictures in COBOL. The picture formats used by this package are a
21402 close copy of the facility in COBOL.
21403
21404 @item @code{Ada.Text_IO.Text_Streams (A.12.2)}
21405
21406 This package provides a facility that allows Text_IO files to be treated
21407 as streams, so that the stream attributes can be used for writing
21408 arbitrary data, including binary data, to Text_IO files.
21409
21410 @item @code{Ada.Text_IO.Unbounded_IO (A.10.12)}
21411
21412 This package provides input-output facilities for unbounded strings.
21413
21414 @item @code{Ada.Unchecked_Conversion (13.9)}
21415
21416 This generic package allows arbitrary conversion from one type to
21417 another of the same size, providing for breaking the type safety in
21418 special circumstances.
21419
21420 If the types have the same Size (more accurately the same Value_Size),
21421 then the effect is simply to transfer the bits from the source to the
21422 target type without any modification. This usage is well defined, and
21423 for simple types whose representation is typically the same across
21424 all implementations, gives a portable method of performing such
21425 conversions.
21426
21427 If the types do not have the same size, then the result is implementation
21428 defined, and thus may be non-portable. The following describes how GNAT
21429 handles such unchecked conversion cases.
21430
21431 If the types are of different sizes, and are both discrete types, then
21432 the effect is of a normal type conversion without any constraint checking.
21433 In particular if the result type has a larger size, the result will be
21434 zero or sign extended. If the result type has a smaller size, the result
21435 will be truncated by ignoring high order bits.
21436
21437 If the types are of different sizes, and are not both discrete types,
21438 then the conversion works as though pointers were created to the source
21439 and target, and the pointer value is converted. The effect is that bits
21440 are copied from successive low order storage units and bits of the source
21441 up to the length of the target type.
21442
21443 A warning is issued if the lengths differ, since the effect in this
21444 case is implementation dependent, and the above behavior may not match
21445 that of some other compiler.
21446
21447 A pointer to one type may be converted to a pointer to another type using
21448 unchecked conversion. The only case in which the effect is undefined is
21449 when one or both pointers are pointers to unconstrained array types. In
21450 this case, the bounds information may get incorrectly transferred, and in
21451 particular, GNAT uses double size pointers for such types, and it is
21452 meaningless to convert between such pointer types. GNAT will issue a
21453 warning if the alignment of the target designated type is more strict
21454 than the alignment of the source designated type (since the result may
21455 be unaligned in this case).
21456
21457 A pointer other than a pointer to an unconstrained array type may be
21458 converted to and from System.Address. Such usage is common in Ada 83
21459 programs, but note that Ada.Address_To_Access_Conversions is the
21460 preferred method of performing such conversions in Ada 95 and Ada 2005.
21461 Neither
21462 unchecked conversion nor Ada.Address_To_Access_Conversions should be
21463 used in conjunction with pointers to unconstrained objects, since
21464 the bounds information cannot be handled correctly in this case.
21465
21466 @item @code{Ada.Unchecked_Deallocation} @emph{(13.11.2)}
21467
21468 This generic package allows explicit freeing of storage previously
21469 allocated by use of an allocator.
21470
21471 @item @code{Ada.Wide_Text_IO} @emph{(A.11)}
21472
21473 This package is similar to @code{Ada.Text_IO}, except that the external
21474 file supports wide character representations, and the internal types are
21475 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
21476 and @code{String}. The corresponding set of nested packages and child
21477 packages are defined.
21478
21479 @item @code{Ada.Wide_Wide_Text_IO} @emph{(A.11)}
21480
21481 This package is similar to @code{Ada.Text_IO}, except that the external
21482 file supports wide character representations, and the internal types are
21483 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
21484 and @code{String}. The corresponding set of nested packages and child
21485 packages are defined.
21486 @end table
21487
21488 For packages in Interfaces and System, all the RM defined packages are
21489 available in GNAT, see the Ada 2012 RM for full details.
21490
21491 @node The Implementation of Standard I/O,The GNAT Library,Standard Library Routines,Top
21492 @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{29e}@anchor{gnat_rm/the_implementation_of_standard_i_o id1}@anchor{29f}
21493 @chapter The Implementation of Standard I/O
21494
21495
21496 GNAT implements all the required input-output facilities described in
21497 A.6 through A.14. These sections of the Ada Reference Manual describe the
21498 required behavior of these packages from the Ada point of view, and if
21499 you are writing a portable Ada program that does not need to know the
21500 exact manner in which Ada maps to the outside world when it comes to
21501 reading or writing external files, then you do not need to read this
21502 chapter. As long as your files are all regular files (not pipes or
21503 devices), and as long as you write and read the files only from Ada, the
21504 description in the Ada Reference Manual is sufficient.
21505
21506 However, if you want to do input-output to pipes or other devices, such
21507 as the keyboard or screen, or if the files you are dealing with are
21508 either generated by some other language, or to be read by some other
21509 language, then you need to know more about the details of how the GNAT
21510 implementation of these input-output facilities behaves.
21511
21512 In this chapter we give a detailed description of exactly how GNAT
21513 interfaces to the file system. As always, the sources of the system are
21514 available to you for answering questions at an even more detailed level,
21515 but for most purposes the information in this chapter will suffice.
21516
21517 Another reason that you may need to know more about how input-output is
21518 implemented arises when you have a program written in mixed languages
21519 where, for example, files are shared between the C and Ada sections of
21520 the same program. GNAT provides some additional facilities, in the form
21521 of additional child library packages, that facilitate this sharing, and
21522 these additional facilities are also described in this chapter.
21523
21524 @menu
21525 * Standard I/O Packages::
21526 * FORM Strings::
21527 * Direct_IO::
21528 * Sequential_IO::
21529 * Text_IO::
21530 * Wide_Text_IO::
21531 * Wide_Wide_Text_IO::
21532 * Stream_IO::
21533 * Text Translation::
21534 * Shared Files::
21535 * Filenames encoding::
21536 * File content encoding::
21537 * Open Modes::
21538 * Operations on C Streams::
21539 * Interfacing to C Streams::
21540
21541 @end menu
21542
21543 @node Standard I/O Packages,FORM Strings,,The Implementation of Standard I/O
21544 @anchor{gnat_rm/the_implementation_of_standard_i_o standard-i-o-packages}@anchor{2a0}@anchor{gnat_rm/the_implementation_of_standard_i_o id2}@anchor{2a1}
21545 @section Standard I/O Packages
21546
21547
21548 The Standard I/O packages described in Annex A for
21549
21550
21551 @itemize *
21552
21553 @item
21554 Ada.Text_IO
21555
21556 @item
21557 Ada.Text_IO.Complex_IO
21558
21559 @item
21560 Ada.Text_IO.Text_Streams
21561
21562 @item
21563 Ada.Wide_Text_IO
21564
21565 @item
21566 Ada.Wide_Text_IO.Complex_IO
21567
21568 @item
21569 Ada.Wide_Text_IO.Text_Streams
21570
21571 @item
21572 Ada.Wide_Wide_Text_IO
21573
21574 @item
21575 Ada.Wide_Wide_Text_IO.Complex_IO
21576
21577 @item
21578 Ada.Wide_Wide_Text_IO.Text_Streams
21579
21580 @item
21581 Ada.Stream_IO
21582
21583 @item
21584 Ada.Sequential_IO
21585
21586 @item
21587 Ada.Direct_IO
21588 @end itemize
21589
21590 are implemented using the C
21591 library streams facility; where
21592
21593
21594 @itemize *
21595
21596 @item
21597 All files are opened using @code{fopen}.
21598
21599 @item
21600 All input/output operations use @code{fread}/@cite{fwrite}.
21601 @end itemize
21602
21603 There is no internal buffering of any kind at the Ada library level. The only
21604 buffering is that provided at the system level in the implementation of the
21605 library routines that support streams. This facilitates shared use of these
21606 streams by mixed language programs. Note though that system level buffering is
21607 explicitly enabled at elaboration of the standard I/O packages and that can
21608 have an impact on mixed language programs, in particular those using I/O before
21609 calling the Ada elaboration routine (e.g., adainit). It is recommended to call
21610 the Ada elaboration routine before performing any I/O or when impractical,
21611 flush the common I/O streams and in particular Standard_Output before
21612 elaborating the Ada code.
21613
21614 @node FORM Strings,Direct_IO,Standard I/O Packages,The Implementation of Standard I/O
21615 @anchor{gnat_rm/the_implementation_of_standard_i_o form-strings}@anchor{2a2}@anchor{gnat_rm/the_implementation_of_standard_i_o id3}@anchor{2a3}
21616 @section FORM Strings
21617
21618
21619 The format of a FORM string in GNAT is:
21620
21621 @example
21622 "keyword=value,keyword=value,...,keyword=value"
21623 @end example
21624
21625 where letters may be in upper or lower case, and there are no spaces
21626 between values. The order of the entries is not important. Currently
21627 the following keywords defined.
21628
21629 @example
21630 TEXT_TRANSLATION=[YES|NO|TEXT|BINARY|U8TEXT|WTEXT|U16TEXT]
21631 SHARED=[YES|NO]
21632 WCEM=[n|h|u|s|e|8|b]
21633 ENCODING=[UTF8|8BITS]
21634 @end example
21635
21636 The use of these parameters is described later in this section. If an
21637 unrecognized keyword appears in a form string, it is silently ignored
21638 and not considered invalid.
21639
21640 @node Direct_IO,Sequential_IO,FORM Strings,The Implementation of Standard I/O
21641 @anchor{gnat_rm/the_implementation_of_standard_i_o direct-io}@anchor{2a4}@anchor{gnat_rm/the_implementation_of_standard_i_o id4}@anchor{2a5}
21642 @section Direct_IO
21643
21644
21645 Direct_IO can only be instantiated for definite types. This is a
21646 restriction of the Ada language, which means that the records are fixed
21647 length (the length being determined by @code{type'Size}, rounded
21648 up to the next storage unit boundary if necessary).
21649
21650 The records of a Direct_IO file are simply written to the file in index
21651 sequence, with the first record starting at offset zero, and subsequent
21652 records following. There is no control information of any kind. For
21653 example, if 32-bit integers are being written, each record takes
21654 4-bytes, so the record at index @code{K} starts at offset
21655 (@code{K}-1)*4.
21656
21657 There is no limit on the size of Direct_IO files, they are expanded as
21658 necessary to accommodate whatever records are written to the file.
21659
21660 @node Sequential_IO,Text_IO,Direct_IO,The Implementation of Standard I/O
21661 @anchor{gnat_rm/the_implementation_of_standard_i_o sequential-io}@anchor{2a6}@anchor{gnat_rm/the_implementation_of_standard_i_o id5}@anchor{2a7}
21662 @section Sequential_IO
21663
21664
21665 Sequential_IO may be instantiated with either a definite (constrained)
21666 or indefinite (unconstrained) type.
21667
21668 For the definite type case, the elements written to the file are simply
21669 the memory images of the data values with no control information of any
21670 kind. The resulting file should be read using the same type, no validity
21671 checking is performed on input.
21672
21673 For the indefinite type case, the elements written consist of two
21674 parts. First is the size of the data item, written as the memory image
21675 of a @code{Interfaces.C.size_t} value, followed by the memory image of
21676 the data value. The resulting file can only be read using the same
21677 (unconstrained) type. Normal assignment checks are performed on these
21678 read operations, and if these checks fail, @code{Data_Error} is
21679 raised. In particular, in the array case, the lengths must match, and in
21680 the variant record case, if the variable for a particular read operation
21681 is constrained, the discriminants must match.
21682
21683 Note that it is not possible to use Sequential_IO to write variable
21684 length array items, and then read the data back into different length
21685 arrays. For example, the following will raise @code{Data_Error}:
21686
21687 @example
21688 package IO is new Sequential_IO (String);
21689 F : IO.File_Type;
21690 S : String (1..4);
21691 ...
21692 IO.Create (F)
21693 IO.Write (F, "hello!")
21694 IO.Reset (F, Mode=>In_File);
21695 IO.Read (F, S);
21696 Put_Line (S);
21697 @end example
21698
21699 On some Ada implementations, this will print @code{hell}, but the program is
21700 clearly incorrect, since there is only one element in the file, and that
21701 element is the string @code{hello!}.
21702
21703 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
21704 using Stream_IO, and this is the preferred mechanism. In particular, the
21705 above program fragment rewritten to use Stream_IO will work correctly.
21706
21707 @node Text_IO,Wide_Text_IO,Sequential_IO,The Implementation of Standard I/O
21708 @anchor{gnat_rm/the_implementation_of_standard_i_o id6}@anchor{2a8}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io}@anchor{2a9}
21709 @section Text_IO
21710
21711
21712 Text_IO files consist of a stream of characters containing the following
21713 special control characters:
21714
21715 @example
21716 LF (line feed, 16#0A#) Line Mark
21717 FF (form feed, 16#0C#) Page Mark
21718 @end example
21719
21720 A canonical Text_IO file is defined as one in which the following
21721 conditions are met:
21722
21723
21724 @itemize *
21725
21726 @item
21727 The character @code{LF} is used only as a line mark, i.e., to mark the end
21728 of the line.
21729
21730 @item
21731 The character @code{FF} is used only as a page mark, i.e., to mark the
21732 end of a page and consequently can appear only immediately following a
21733 @code{LF} (line mark) character.
21734
21735 @item
21736 The file ends with either @code{LF} (line mark) or @code{LF}-@cite{FF}
21737 (line mark, page mark). In the former case, the page mark is implicitly
21738 assumed to be present.
21739 @end itemize
21740
21741 A file written using Text_IO will be in canonical form provided that no
21742 explicit @code{LF} or @code{FF} characters are written using @code{Put}
21743 or @code{Put_Line}. There will be no @code{FF} character at the end of
21744 the file unless an explicit @code{New_Page} operation was performed
21745 before closing the file.
21746
21747 A canonical Text_IO file that is a regular file (i.e., not a device or a
21748 pipe) can be read using any of the routines in Text_IO. The
21749 semantics in this case will be exactly as defined in the Ada Reference
21750 Manual, and all the routines in Text_IO are fully implemented.
21751
21752 A text file that does not meet the requirements for a canonical Text_IO
21753 file has one of the following:
21754
21755
21756 @itemize *
21757
21758 @item
21759 The file contains @code{FF} characters not immediately following a
21760 @code{LF} character.
21761
21762 @item
21763 The file contains @code{LF} or @code{FF} characters written by
21764 @code{Put} or @code{Put_Line}, which are not logically considered to be
21765 line marks or page marks.
21766
21767 @item
21768 The file ends in a character other than @code{LF} or @code{FF},
21769 i.e., there is no explicit line mark or page mark at the end of the file.
21770 @end itemize
21771
21772 Text_IO can be used to read such non-standard text files but subprograms
21773 to do with line or page numbers do not have defined meanings. In
21774 particular, a @code{FF} character that does not follow a @code{LF}
21775 character may or may not be treated as a page mark from the point of
21776 view of page and line numbering. Every @code{LF} character is considered
21777 to end a line, and there is an implied @code{LF} character at the end of
21778 the file.
21779
21780 @menu
21781 * Stream Pointer Positioning::
21782 * Reading and Writing Non-Regular Files::
21783 * Get_Immediate::
21784 * Treating Text_IO Files as Streams::
21785 * Text_IO Extensions::
21786 * Text_IO Facilities for Unbounded Strings::
21787
21788 @end menu
21789
21790 @node Stream Pointer Positioning,Reading and Writing Non-Regular Files,,Text_IO
21791 @anchor{gnat_rm/the_implementation_of_standard_i_o id7}@anchor{2aa}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning}@anchor{2ab}
21792 @subsection Stream Pointer Positioning
21793
21794
21795 @code{Ada.Text_IO} has a definition of current position for a file that
21796 is being read. No internal buffering occurs in Text_IO, and usually the
21797 physical position in the stream used to implement the file corresponds
21798 to this logical position defined by Text_IO. There are two exceptions:
21799
21800
21801 @itemize *
21802
21803 @item
21804 After a call to @code{End_Of_Page} that returns @code{True}, the stream
21805 is positioned past the @code{LF} (line mark) that precedes the page
21806 mark. Text_IO maintains an internal flag so that subsequent read
21807 operations properly handle the logical position which is unchanged by
21808 the @code{End_Of_Page} call.
21809
21810 @item
21811 After a call to @code{End_Of_File} that returns @code{True}, if the
21812 Text_IO file was positioned before the line mark at the end of file
21813 before the call, then the logical position is unchanged, but the stream
21814 is physically positioned right at the end of file (past the line mark,
21815 and past a possible page mark following the line mark. Again Text_IO
21816 maintains internal flags so that subsequent read operations properly
21817 handle the logical position.
21818 @end itemize
21819
21820 These discrepancies have no effect on the observable behavior of
21821 Text_IO, but if a single Ada stream is shared between a C program and
21822 Ada program, or shared (using @code{shared=yes} in the form string)
21823 between two Ada files, then the difference may be observable in some
21824 situations.
21825
21826 @node Reading and Writing Non-Regular Files,Get_Immediate,Stream Pointer Positioning,Text_IO
21827 @anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files}@anchor{2ac}@anchor{gnat_rm/the_implementation_of_standard_i_o id8}@anchor{2ad}
21828 @subsection Reading and Writing Non-Regular Files
21829
21830
21831 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
21832 can be used for reading and writing. Writing is not affected and the
21833 sequence of characters output is identical to the normal file case, but
21834 for reading, the behavior of Text_IO is modified to avoid undesirable
21835 look-ahead as follows:
21836
21837 An input file that is not a regular file is considered to have no page
21838 marks. Any @code{Ascii.FF} characters (the character normally used for a
21839 page mark) appearing in the file are considered to be data
21840 characters. In particular:
21841
21842
21843 @itemize *
21844
21845 @item
21846 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
21847 following a line mark. If a page mark appears, it will be treated as a
21848 data character.
21849
21850 @item
21851 This avoids the need to wait for an extra character to be typed or
21852 entered from the pipe to complete one of these operations.
21853
21854 @item
21855 @code{End_Of_Page} always returns @code{False}
21856
21857 @item
21858 @code{End_Of_File} will return @code{False} if there is a page mark at
21859 the end of the file.
21860 @end itemize
21861
21862 Output to non-regular files is the same as for regular files. Page marks
21863 may be written to non-regular files using @code{New_Page}, but as noted
21864 above they will not be treated as page marks on input if the output is
21865 piped to another Ada program.
21866
21867 Another important discrepancy when reading non-regular files is that the end
21868 of file indication is not 'sticky'. If an end of file is entered, e.g., by
21869 pressing the @code{EOT} key,
21870 then end of file
21871 is signaled once (i.e., the test @code{End_Of_File}
21872 will yield @code{True}, or a read will
21873 raise @code{End_Error}), but then reading can resume
21874 to read data past that end of
21875 file indication, until another end of file indication is entered.
21876
21877 @node Get_Immediate,Treating Text_IO Files as Streams,Reading and Writing Non-Regular Files,Text_IO
21878 @anchor{gnat_rm/the_implementation_of_standard_i_o get-immediate}@anchor{2ae}@anchor{gnat_rm/the_implementation_of_standard_i_o id9}@anchor{2af}
21879 @subsection Get_Immediate
21880
21881
21882 @geindex Get_Immediate
21883
21884 Get_Immediate returns the next character (including control characters)
21885 from the input file. In particular, Get_Immediate will return LF or FF
21886 characters used as line marks or page marks. Such operations leave the
21887 file positioned past the control character, and it is thus not treated
21888 as having its normal function. This means that page, line and column
21889 counts after this kind of Get_Immediate call are set as though the mark
21890 did not occur. In the case where a Get_Immediate leaves the file
21891 positioned between the line mark and page mark (which is not normally
21892 possible), it is undefined whether the FF character will be treated as a
21893 page mark.
21894
21895 @node Treating Text_IO Files as Streams,Text_IO Extensions,Get_Immediate,Text_IO
21896 @anchor{gnat_rm/the_implementation_of_standard_i_o id10}@anchor{2b0}@anchor{gnat_rm/the_implementation_of_standard_i_o treating-text-io-files-as-streams}@anchor{2b1}
21897 @subsection Treating Text_IO Files as Streams
21898
21899
21900 @geindex Stream files
21901
21902 The package @code{Text_IO.Streams} allows a @code{Text_IO} file to be treated
21903 as a stream. Data written to a @code{Text_IO} file in this stream mode is
21904 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
21905 16#0C# (@code{FF}), the resulting file may have non-standard
21906 format. Similarly if read operations are used to read from a Text_IO
21907 file treated as a stream, then @code{LF} and @code{FF} characters may be
21908 skipped and the effect is similar to that described above for
21909 @code{Get_Immediate}.
21910
21911 @node Text_IO Extensions,Text_IO Facilities for Unbounded Strings,Treating Text_IO Files as Streams,Text_IO
21912 @anchor{gnat_rm/the_implementation_of_standard_i_o id11}@anchor{2b2}@anchor{gnat_rm/the_implementation_of_standard_i_o text-io-extensions}@anchor{2b3}
21913 @subsection Text_IO Extensions
21914
21915
21916 @geindex Text_IO extensions
21917
21918 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
21919 to the standard @code{Text_IO} package:
21920
21921
21922 @itemize *
21923
21924 @item
21925 function File_Exists (Name : String) return Boolean;
21926 Determines if a file of the given name exists.
21927
21928 @item
21929 function Get_Line return String;
21930 Reads a string from the standard input file. The value returned is exactly
21931 the length of the line that was read.
21932
21933 @item
21934 function Get_Line (File : Ada.Text_IO.File_Type) return String;
21935 Similar, except that the parameter File specifies the file from which
21936 the string is to be read.
21937 @end itemize
21938
21939 @node Text_IO Facilities for Unbounded Strings,,Text_IO Extensions,Text_IO
21940 @anchor{gnat_rm/the_implementation_of_standard_i_o text-io-facilities-for-unbounded-strings}@anchor{2b4}@anchor{gnat_rm/the_implementation_of_standard_i_o id12}@anchor{2b5}
21941 @subsection Text_IO Facilities for Unbounded Strings
21942
21943
21944 @geindex Text_IO for unbounded strings
21945
21946 @geindex Unbounded_String
21947 @geindex Text_IO operations
21948
21949 The package @code{Ada.Strings.Unbounded.Text_IO}
21950 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
21951 subprograms useful for Text_IO operations on unbounded strings:
21952
21953
21954 @itemize *
21955
21956 @item
21957 function Get_Line (File : File_Type) return Unbounded_String;
21958 Reads a line from the specified file
21959 and returns the result as an unbounded string.
21960
21961 @item
21962 procedure Put (File : File_Type; U : Unbounded_String);
21963 Writes the value of the given unbounded string to the specified file
21964 Similar to the effect of
21965 @code{Put (To_String (U))} except that an extra copy is avoided.
21966
21967 @item
21968 procedure Put_Line (File : File_Type; U : Unbounded_String);
21969 Writes the value of the given unbounded string to the specified file,
21970 followed by a @code{New_Line}.
21971 Similar to the effect of @code{Put_Line (To_String (U))} except
21972 that an extra copy is avoided.
21973 @end itemize
21974
21975 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
21976 and is optional. If the parameter is omitted, then the standard input or
21977 output file is referenced as appropriate.
21978
21979 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
21980 files @code{a-swuwti.ads} and @code{a-swuwti.adb} provides similar extended
21981 @code{Wide_Text_IO} functionality for unbounded wide strings.
21982
21983 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
21984 files @code{a-szuzti.ads} and @code{a-szuzti.adb} provides similar extended
21985 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
21986
21987 @node Wide_Text_IO,Wide_Wide_Text_IO,Text_IO,The Implementation of Standard I/O
21988 @anchor{gnat_rm/the_implementation_of_standard_i_o wide-text-io}@anchor{2b6}@anchor{gnat_rm/the_implementation_of_standard_i_o id13}@anchor{2b7}
21989 @section Wide_Text_IO
21990
21991
21992 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
21993 both input and output files may contain special sequences that represent
21994 wide character values. The encoding scheme for a given file may be
21995 specified using a FORM parameter:
21996
21997 @example
21998 WCEM=`x`
21999 @end example
22000
22001 as part of the FORM string (WCEM = wide character encoding method),
22002 where @code{x} is one of the following characters
22003
22004
22005 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
22006 @headitem
22007
22008 Character
22009
22010 @tab
22011
22012 Encoding
22013
22014 @item
22015
22016 @emph{h}
22017
22018 @tab
22019
22020 Hex ESC encoding
22021
22022 @item
22023
22024 @emph{u}
22025
22026 @tab
22027
22028 Upper half encoding
22029
22030 @item
22031
22032 @emph{s}
22033
22034 @tab
22035
22036 Shift-JIS encoding
22037
22038 @item
22039
22040 @emph{e}
22041
22042 @tab
22043
22044 EUC Encoding
22045
22046 @item
22047
22048 @emph{8}
22049
22050 @tab
22051
22052 UTF-8 encoding
22053
22054 @item
22055
22056 @emph{b}
22057
22058 @tab
22059
22060 Brackets encoding
22061
22062 @end multitable
22063
22064
22065 The encoding methods match those that
22066 can be used in a source
22067 program, but there is no requirement that the encoding method used for
22068 the source program be the same as the encoding method used for files,
22069 and different files may use different encoding methods.
22070
22071 The default encoding method for the standard files, and for opened files
22072 for which no WCEM parameter is given in the FORM string matches the
22073 wide character encoding specified for the main program (the default
22074 being brackets encoding if no coding method was specified with -gnatW).
22075
22076
22077 @table @asis
22078
22079 @item @emph{Hex Coding}
22080
22081 In this encoding, a wide character is represented by a five character
22082 sequence:
22083 @end table
22084
22085 @example
22086 ESC a b c d
22087 @end example
22088
22089
22090 @quotation
22091
22092 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
22093 characters (using upper case letters) of the wide character code. For
22094 example, ESC A345 is used to represent the wide character with code
22095 16#A345#. This scheme is compatible with use of the full
22096 @code{Wide_Character} set.
22097 @end quotation
22098
22099
22100 @table @asis
22101
22102 @item @emph{Upper Half Coding}
22103
22104 The wide character with encoding 16#abcd#, where the upper bit is on
22105 (i.e., a is in the range 8-F) is represented as two bytes 16#ab# and
22106 16#cd#. The second byte may never be a format control character, but is
22107 not required to be in the upper half. This method can be also used for
22108 shift-JIS or EUC where the internal coding matches the external coding.
22109
22110 @item @emph{Shift JIS Coding}
22111
22112 A wide character is represented by a two character sequence 16#ab# and
22113 16#cd#, with the restrictions described for upper half encoding as
22114 described above. The internal character code is the corresponding JIS
22115 character according to the standard algorithm for Shift-JIS
22116 conversion. Only characters defined in the JIS code set table can be
22117 used with this encoding method.
22118
22119 @item @emph{EUC Coding}
22120
22121 A wide character is represented by a two character sequence 16#ab# and
22122 16#cd#, with both characters being in the upper half. The internal
22123 character code is the corresponding JIS character according to the EUC
22124 encoding algorithm. Only characters defined in the JIS code set table
22125 can be used with this encoding method.
22126
22127 @item @emph{UTF-8 Coding}
22128
22129 A wide character is represented using
22130 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
22131 10646-1/Am.2. Depending on the character value, the representation
22132 is a one, two, or three byte sequence:
22133 @end table
22134
22135 @example
22136 16#0000#-16#007f#: 2#0xxxxxxx#
22137 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
22138 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
22139 @end example
22140
22141
22142 @quotation
22143
22144 where the @code{xxx} bits correspond to the left-padded bits of the
22145 16-bit character value. Note that all lower half ASCII characters
22146 are represented as ASCII bytes and all upper half characters and
22147 other wide characters are represented as sequences of upper-half
22148 (The full UTF-8 scheme allows for encoding 31-bit characters as
22149 6-byte sequences, but in this implementation, all UTF-8 sequences
22150 of four or more bytes length will raise a Constraint_Error, as
22151 will all invalid UTF-8 sequences.)
22152 @end quotation
22153
22154
22155 @table @asis
22156
22157 @item @emph{Brackets Coding}
22158
22159 In this encoding, a wide character is represented by the following eight
22160 character sequence:
22161 @end table
22162
22163 @example
22164 [ " a b c d " ]
22165 @end example
22166
22167
22168 @quotation
22169
22170 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
22171 characters (using uppercase letters) of the wide character code. For
22172 example, @code{["A345"]} is used to represent the wide character with code
22173 @code{16#A345#}.
22174 This scheme is compatible with use of the full Wide_Character set.
22175 On input, brackets coding can also be used for upper half characters,
22176 e.g., @code{["C1"]} for lower case a. However, on output, brackets notation
22177 is only used for wide characters with a code greater than @code{16#FF#}.
22178
22179 Note that brackets coding is not normally used in the context of
22180 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
22181 a portable way of encoding source files. In the context of Wide_Text_IO
22182 or Wide_Wide_Text_IO, it can only be used if the file does not contain
22183 any instance of the left bracket character other than to encode wide
22184 character values using the brackets encoding method. In practice it is
22185 expected that some standard wide character encoding method such
22186 as UTF-8 will be used for text input output.
22187
22188 If brackets notation is used, then any occurrence of a left bracket
22189 in the input file which is not the start of a valid wide character
22190 sequence will cause Constraint_Error to be raised. It is possible to
22191 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
22192 input will interpret this as a left bracket.
22193
22194 However, when a left bracket is output, it will be output as a left bracket
22195 and not as ["5B"]. We make this decision because for normal use of
22196 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
22197 brackets. For example, if we write:
22198
22199 @example
22200 Put_Line ("Start of output [first run]");
22201 @end example
22202
22203 we really do not want to have the left bracket in this message clobbered so
22204 that the output reads:
22205 @end quotation
22206
22207 @example
22208 Start of output ["5B"]first run]
22209 @end example
22210
22211
22212 @quotation
22213
22214 In practice brackets encoding is reasonably useful for normal Put_Line use
22215 since we won't get confused between left brackets and wide character
22216 sequences in the output. But for input, or when files are written out
22217 and read back in, it really makes better sense to use one of the standard
22218 encoding methods such as UTF-8.
22219 @end quotation
22220
22221 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
22222 not all wide character
22223 values can be represented. An attempt to output a character that cannot
22224 be represented using the encoding scheme for the file causes
22225 Constraint_Error to be raised. An invalid wide character sequence on
22226 input also causes Constraint_Error to be raised.
22227
22228 @menu
22229 * Stream Pointer Positioning: Stream Pointer Positioning<2>.
22230 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<2>.
22231
22232 @end menu
22233
22234 @node Stream Pointer Positioning<2>,Reading and Writing Non-Regular Files<2>,,Wide_Text_IO
22235 @anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-1}@anchor{2b8}@anchor{gnat_rm/the_implementation_of_standard_i_o id14}@anchor{2b9}
22236 @subsection Stream Pointer Positioning
22237
22238
22239 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
22240 of stream pointer positioning (@ref{2a9,,Text_IO}). There is one additional
22241 case:
22242
22243 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
22244 normal lower ASCII set (i.e., a character in the range:
22245
22246 @example
22247 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
22248 @end example
22249
22250 then although the logical position of the file pointer is unchanged by
22251 the @code{Look_Ahead} call, the stream is physically positioned past the
22252 wide character sequence. Again this is to avoid the need for buffering
22253 or backup, and all @code{Wide_Text_IO} routines check the internal
22254 indication that this situation has occurred so that this is not visible
22255 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
22256 can be observed if the wide text file shares a stream with another file.
22257
22258 @node Reading and Writing Non-Regular Files<2>,,Stream Pointer Positioning<2>,Wide_Text_IO
22259 @anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-1}@anchor{2ba}@anchor{gnat_rm/the_implementation_of_standard_i_o id15}@anchor{2bb}
22260 @subsection Reading and Writing Non-Regular Files
22261
22262
22263 As in the case of Text_IO, when a non-regular file is read, it is
22264 assumed that the file contains no page marks (any form characters are
22265 treated as data characters), and @code{End_Of_Page} always returns
22266 @code{False}. Similarly, the end of file indication is not sticky, so
22267 it is possible to read beyond an end of file.
22268
22269 @node Wide_Wide_Text_IO,Stream_IO,Wide_Text_IO,The Implementation of Standard I/O
22270 @anchor{gnat_rm/the_implementation_of_standard_i_o id16}@anchor{2bc}@anchor{gnat_rm/the_implementation_of_standard_i_o wide-wide-text-io}@anchor{2bd}
22271 @section Wide_Wide_Text_IO
22272
22273
22274 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
22275 both input and output files may contain special sequences that represent
22276 wide wide character values. The encoding scheme for a given file may be
22277 specified using a FORM parameter:
22278
22279 @example
22280 WCEM=`x`
22281 @end example
22282
22283 as part of the FORM string (WCEM = wide character encoding method),
22284 where @code{x} is one of the following characters
22285
22286
22287 @multitable {xxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxx}
22288 @headitem
22289
22290 Character
22291
22292 @tab
22293
22294 Encoding
22295
22296 @item
22297
22298 @emph{h}
22299
22300 @tab
22301
22302 Hex ESC encoding
22303
22304 @item
22305
22306 @emph{u}
22307
22308 @tab
22309
22310 Upper half encoding
22311
22312 @item
22313
22314 @emph{s}
22315
22316 @tab
22317
22318 Shift-JIS encoding
22319
22320 @item
22321
22322 @emph{e}
22323
22324 @tab
22325
22326 EUC Encoding
22327
22328 @item
22329
22330 @emph{8}
22331
22332 @tab
22333
22334 UTF-8 encoding
22335
22336 @item
22337
22338 @emph{b}
22339
22340 @tab
22341
22342 Brackets encoding
22343
22344 @end multitable
22345
22346
22347 The encoding methods match those that
22348 can be used in a source
22349 program, but there is no requirement that the encoding method used for
22350 the source program be the same as the encoding method used for files,
22351 and different files may use different encoding methods.
22352
22353 The default encoding method for the standard files, and for opened files
22354 for which no WCEM parameter is given in the FORM string matches the
22355 wide character encoding specified for the main program (the default
22356 being brackets encoding if no coding method was specified with -gnatW).
22357
22358
22359 @table @asis
22360
22361 @item @emph{UTF-8 Coding}
22362
22363 A wide character is represented using
22364 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
22365 10646-1/Am.2. Depending on the character value, the representation
22366 is a one, two, three, or four byte sequence:
22367 @end table
22368
22369 @example
22370 16#000000#-16#00007f#: 2#0xxxxxxx#
22371 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
22372 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
22373 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
22374 @end example
22375
22376
22377 @quotation
22378
22379 where the @code{xxx} bits correspond to the left-padded bits of the
22380 21-bit character value. Note that all lower half ASCII characters
22381 are represented as ASCII bytes and all upper half characters and
22382 other wide characters are represented as sequences of upper-half
22383 characters.
22384 @end quotation
22385
22386
22387 @table @asis
22388
22389 @item @emph{Brackets Coding}
22390
22391 In this encoding, a wide wide character is represented by the following eight
22392 character sequence if is in wide character range
22393 @end table
22394
22395 @example
22396 [ " a b c d " ]
22397 @end example
22398
22399
22400 @quotation
22401
22402 and by the following ten character sequence if not
22403 @end quotation
22404
22405 @example
22406 [ " a b c d e f " ]
22407 @end example
22408
22409
22410 @quotation
22411
22412 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
22413 are the four or six hexadecimal
22414 characters (using uppercase letters) of the wide wide character code. For
22415 example, @code{["01A345"]} is used to represent the wide wide character
22416 with code @code{16#01A345#}.
22417
22418 This scheme is compatible with use of the full Wide_Wide_Character set.
22419 On input, brackets coding can also be used for upper half characters,
22420 e.g., @code{["C1"]} for lower case a. However, on output, brackets notation
22421 is only used for wide characters with a code greater than @code{16#FF#}.
22422 @end quotation
22423
22424 If is also possible to use the other Wide_Character encoding methods,
22425 such as Shift-JIS, but the other schemes cannot support the full range
22426 of wide wide characters.
22427 An attempt to output a character that cannot
22428 be represented using the encoding scheme for the file causes
22429 Constraint_Error to be raised. An invalid wide character sequence on
22430 input also causes Constraint_Error to be raised.
22431
22432 @menu
22433 * Stream Pointer Positioning: Stream Pointer Positioning<3>.
22434 * Reading and Writing Non-Regular Files: Reading and Writing Non-Regular Files<3>.
22435
22436 @end menu
22437
22438 @node Stream Pointer Positioning<3>,Reading and Writing Non-Regular Files<3>,,Wide_Wide_Text_IO
22439 @anchor{gnat_rm/the_implementation_of_standard_i_o stream-pointer-positioning-2}@anchor{2be}@anchor{gnat_rm/the_implementation_of_standard_i_o id17}@anchor{2bf}
22440 @subsection Stream Pointer Positioning
22441
22442
22443 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
22444 of stream pointer positioning (@ref{2a9,,Text_IO}). There is one additional
22445 case:
22446
22447 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
22448 normal lower ASCII set (i.e., a character in the range:
22449
22450 @example
22451 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
22452 @end example
22453
22454 then although the logical position of the file pointer is unchanged by
22455 the @code{Look_Ahead} call, the stream is physically positioned past the
22456 wide character sequence. Again this is to avoid the need for buffering
22457 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
22458 indication that this situation has occurred so that this is not visible
22459 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
22460 can be observed if the wide text file shares a stream with another file.
22461
22462 @node Reading and Writing Non-Regular Files<3>,,Stream Pointer Positioning<3>,Wide_Wide_Text_IO
22463 @anchor{gnat_rm/the_implementation_of_standard_i_o id18}@anchor{2c0}@anchor{gnat_rm/the_implementation_of_standard_i_o reading-and-writing-non-regular-files-2}@anchor{2c1}
22464 @subsection Reading and Writing Non-Regular Files
22465
22466
22467 As in the case of Text_IO, when a non-regular file is read, it is
22468 assumed that the file contains no page marks (any form characters are
22469 treated as data characters), and @code{End_Of_Page} always returns
22470 @code{False}. Similarly, the end of file indication is not sticky, so
22471 it is possible to read beyond an end of file.
22472
22473 @node Stream_IO,Text Translation,Wide_Wide_Text_IO,The Implementation of Standard I/O
22474 @anchor{gnat_rm/the_implementation_of_standard_i_o id19}@anchor{2c2}@anchor{gnat_rm/the_implementation_of_standard_i_o stream-io}@anchor{2c3}
22475 @section Stream_IO
22476
22477
22478 A stream file is a sequence of bytes, where individual elements are
22479 written to the file as described in the Ada Reference Manual. The type
22480 @code{Stream_Element} is simply a byte. There are two ways to read or
22481 write a stream file.
22482
22483
22484 @itemize *
22485
22486 @item
22487 The operations @code{Read} and @code{Write} directly read or write a
22488 sequence of stream elements with no control information.
22489
22490 @item
22491 The stream attributes applied to a stream file transfer data in the
22492 manner described for stream attributes.
22493 @end itemize
22494
22495 @node Text Translation,Shared Files,Stream_IO,The Implementation of Standard I/O
22496 @anchor{gnat_rm/the_implementation_of_standard_i_o id20}@anchor{2c4}@anchor{gnat_rm/the_implementation_of_standard_i_o text-translation}@anchor{2c5}
22497 @section Text Translation
22498
22499
22500 @code{Text_Translation=xxx} may be used as the Form parameter
22501 passed to Text_IO.Create and Text_IO.Open. @code{Text_Translation=xxx}
22502 has no effect on Unix systems. Possible values are:
22503
22504
22505 @itemize *
22506
22507 @item
22508 @code{Yes} or @code{Text} is the default, which means to
22509 translate LF to/from CR/LF on Windows systems.
22510
22511 @code{No} disables this translation; i.e. it
22512 uses binary mode. For output files, @code{Text_Translation=No}
22513 may be used to create Unix-style files on
22514 Windows.
22515
22516 @item
22517 @code{wtext} translation enabled in Unicode mode.
22518 (corresponds to _O_WTEXT).
22519
22520 @item
22521 @code{u8text} translation enabled in Unicode UTF-8 mode.
22522 (corresponds to O_U8TEXT).
22523
22524 @item
22525 @code{u16text} translation enabled in Unicode UTF-16
22526 mode. (corresponds to_O_U16TEXT).
22527 @end itemize
22528
22529 @node Shared Files,Filenames encoding,Text Translation,The Implementation of Standard I/O
22530 @anchor{gnat_rm/the_implementation_of_standard_i_o id21}@anchor{2c6}@anchor{gnat_rm/the_implementation_of_standard_i_o shared-files}@anchor{2c7}
22531 @section Shared Files
22532
22533
22534 Section A.14 of the Ada Reference Manual allows implementations to
22535 provide a wide variety of behavior if an attempt is made to access the
22536 same external file with two or more internal files.
22537
22538 To provide a full range of functionality, while at the same time
22539 minimizing the problems of portability caused by this implementation
22540 dependence, GNAT handles file sharing as follows:
22541
22542
22543 @itemize *
22544
22545 @item
22546 In the absence of a @code{shared=xxx} form parameter, an attempt
22547 to open two or more files with the same full name is considered an error
22548 and is not supported. The exception @code{Use_Error} will be
22549 raised. Note that a file that is not explicitly closed by the program
22550 remains open until the program terminates.
22551
22552 @item
22553 If the form parameter @code{shared=no} appears in the form string, the
22554 file can be opened or created with its own separate stream identifier,
22555 regardless of whether other files sharing the same external file are
22556 opened. The exact effect depends on how the C stream routines handle
22557 multiple accesses to the same external files using separate streams.
22558
22559 @item
22560 If the form parameter @code{shared=yes} appears in the form string for
22561 each of two or more files opened using the same full name, the same
22562 stream is shared between these files, and the semantics are as described
22563 in Ada Reference Manual, Section A.14.
22564 @end itemize
22565
22566 When a program that opens multiple files with the same name is ported
22567 from another Ada compiler to GNAT, the effect will be that
22568 @code{Use_Error} is raised.
22569
22570 The documentation of the original compiler and the documentation of the
22571 program should then be examined to determine if file sharing was
22572 expected, and @code{shared=xxx} parameters added to @code{Open}
22573 and @code{Create} calls as required.
22574
22575 When a program is ported from GNAT to some other Ada compiler, no
22576 special attention is required unless the @code{shared=xxx} form
22577 parameter is used in the program. In this case, you must examine the
22578 documentation of the new compiler to see if it supports the required
22579 file sharing semantics, and form strings modified appropriately. Of
22580 course it may be the case that the program cannot be ported if the
22581 target compiler does not support the required functionality. The best
22582 approach in writing portable code is to avoid file sharing (and hence
22583 the use of the @code{shared=xxx} parameter in the form string)
22584 completely.
22585
22586 One common use of file sharing in Ada 83 is the use of instantiations of
22587 Sequential_IO on the same file with different types, to achieve
22588 heterogeneous input-output. Although this approach will work in GNAT if
22589 @code{shared=yes} is specified, it is preferable in Ada to use Stream_IO
22590 for this purpose (using the stream attributes)
22591
22592 @node Filenames encoding,File content encoding,Shared Files,The Implementation of Standard I/O
22593 @anchor{gnat_rm/the_implementation_of_standard_i_o filenames-encoding}@anchor{2c8}@anchor{gnat_rm/the_implementation_of_standard_i_o id22}@anchor{2c9}
22594 @section Filenames encoding
22595
22596
22597 An encoding form parameter can be used to specify the filename
22598 encoding @code{encoding=xxx}.
22599
22600
22601 @itemize *
22602
22603 @item
22604 If the form parameter @code{encoding=utf8} appears in the form string, the
22605 filename must be encoded in UTF-8.
22606
22607 @item
22608 If the form parameter @code{encoding=8bits} appears in the form
22609 string, the filename must be a standard 8bits string.
22610 @end itemize
22611
22612 In the absence of a @code{encoding=xxx} form parameter, the
22613 encoding is controlled by the @code{GNAT_CODE_PAGE} environment
22614 variable. And if not set @code{utf8} is assumed.
22615
22616
22617 @table @asis
22618
22619 @item @emph{CP_ACP}
22620
22621 The current system Windows ANSI code page.
22622
22623 @item @emph{CP_UTF8}
22624
22625 UTF-8 encoding
22626 @end table
22627
22628 This encoding form parameter is only supported on the Windows
22629 platform. On the other Operating Systems the run-time is supporting
22630 UTF-8 natively.
22631
22632 @node File content encoding,Open Modes,Filenames encoding,The Implementation of Standard I/O
22633 @anchor{gnat_rm/the_implementation_of_standard_i_o file-content-encoding}@anchor{2ca}@anchor{gnat_rm/the_implementation_of_standard_i_o id23}@anchor{2cb}
22634 @section File content encoding
22635
22636
22637 For text files it is possible to specify the encoding to use. This is
22638 controlled by the by the @code{GNAT_CCS_ENCODING} environment
22639 variable. And if not set @code{TEXT} is assumed.
22640
22641 The possible values are those supported on Windows:
22642
22643
22644 @table @asis
22645
22646 @item @emph{TEXT}
22647
22648 Translated text mode
22649
22650 @item @emph{WTEXT}
22651
22652 Translated unicode encoding
22653
22654 @item @emph{U16TEXT}
22655
22656 Unicode 16-bit encoding
22657
22658 @item @emph{U8TEXT}
22659
22660 Unicode 8-bit encoding
22661 @end table
22662
22663 This encoding is only supported on the Windows platform.
22664
22665 @node Open Modes,Operations on C Streams,File content encoding,The Implementation of Standard I/O
22666 @anchor{gnat_rm/the_implementation_of_standard_i_o open-modes}@anchor{2cc}@anchor{gnat_rm/the_implementation_of_standard_i_o id24}@anchor{2cd}
22667 @section Open Modes
22668
22669
22670 @code{Open} and @code{Create} calls result in a call to @code{fopen}
22671 using the mode shown in the following table:
22672
22673
22674 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxx}
22675 @headitem
22676
22677 @code{Open} and @code{Create} Call Modes
22678
22679 @tab
22680
22681 @tab
22682
22683 @item
22684
22685 @tab
22686
22687 @strong{OPEN}
22688
22689 @tab
22690
22691 @strong{CREATE}
22692
22693 @item
22694
22695 Append_File
22696
22697 @tab
22698
22699 "r+"
22700
22701 @tab
22702
22703 "w+"
22704
22705 @item
22706
22707 In_File
22708
22709 @tab
22710
22711 "r"
22712
22713 @tab
22714
22715 "w+"
22716
22717 @item
22718
22719 Out_File (Direct_IO)
22720
22721 @tab
22722
22723 "r+"
22724
22725 @tab
22726
22727 "w"
22728
22729 @item
22730
22731 Out_File (all other cases)
22732
22733 @tab
22734
22735 "w"
22736
22737 @tab
22738
22739 "w"
22740
22741 @item
22742
22743 Inout_File
22744
22745 @tab
22746
22747 "r+"
22748
22749 @tab
22750
22751 "w+"
22752
22753 @end multitable
22754
22755
22756 If text file translation is required, then either @code{b} or @code{t}
22757 is added to the mode, depending on the setting of Text. Text file
22758 translation refers to the mapping of CR/LF sequences in an external file
22759 to LF characters internally. This mapping only occurs in DOS and
22760 DOS-like systems, and is not relevant to other systems.
22761
22762 A special case occurs with Stream_IO. As shown in the above table, the
22763 file is initially opened in @code{r} or @code{w} mode for the
22764 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
22765 subsequently requires switching from reading to writing or vice-versa,
22766 then the file is reopened in @code{r+} mode to permit the required operation.
22767
22768 @node Operations on C Streams,Interfacing to C Streams,Open Modes,The Implementation of Standard I/O
22769 @anchor{gnat_rm/the_implementation_of_standard_i_o operations-on-c-streams}@anchor{2ce}@anchor{gnat_rm/the_implementation_of_standard_i_o id25}@anchor{2cf}
22770 @section Operations on C Streams
22771
22772
22773 The package @code{Interfaces.C_Streams} provides an Ada program with direct
22774 access to the C library functions for operations on C streams:
22775
22776 @example
22777 package Interfaces.C_Streams is
22778 -- Note: the reason we do not use the types that are in
22779 -- Interfaces.C is that we want to avoid dragging in the
22780 -- code in this unit if possible.
22781 subtype chars is System.Address;
22782 -- Pointer to null-terminated array of characters
22783 subtype FILEs is System.Address;
22784 -- Corresponds to the C type FILE*
22785 subtype voids is System.Address;
22786 -- Corresponds to the C type void*
22787 subtype int is Integer;
22788 subtype long is Long_Integer;
22789 -- Note: the above types are subtypes deliberately, and it
22790 -- is part of this spec that the above correspondences are
22791 -- guaranteed. This means that it is legitimate to, for
22792 -- example, use Integer instead of int. We provide these
22793 -- synonyms for clarity, but in some cases it may be
22794 -- convenient to use the underlying types (for example to
22795 -- avoid an unnecessary dependency of a spec on the spec
22796 -- of this unit).
22797 type size_t is mod 2 ** Standard'Address_Size;
22798 NULL_Stream : constant FILEs;
22799 -- Value returned (NULL in C) to indicate an
22800 -- fdopen/fopen/tmpfile error
22801 ----------------------------------
22802 -- Constants Defined in stdio.h --
22803 ----------------------------------
22804 EOF : constant int;
22805 -- Used by a number of routines to indicate error or
22806 -- end of file
22807 IOFBF : constant int;
22808 IOLBF : constant int;
22809 IONBF : constant int;
22810 -- Used to indicate buffering mode for setvbuf call
22811 SEEK_CUR : constant int;
22812 SEEK_END : constant int;
22813 SEEK_SET : constant int;
22814 -- Used to indicate origin for fseek call
22815 function stdin return FILEs;
22816 function stdout return FILEs;
22817 function stderr return FILEs;
22818 -- Streams associated with standard files
22819 --------------------------
22820 -- Standard C functions --
22821 --------------------------
22822 -- The functions selected below are ones that are
22823 -- available in UNIX (but not necessarily in ANSI C).
22824 -- These are very thin interfaces
22825 -- which copy exactly the C headers. For more
22826 -- documentation on these functions, see the Microsoft C
22827 -- "Run-Time Library Reference" (Microsoft Press, 1990,
22828 -- ISBN 1-55615-225-6), which includes useful information
22829 -- on system compatibility.
22830 procedure clearerr (stream : FILEs);
22831 function fclose (stream : FILEs) return int;
22832 function fdopen (handle : int; mode : chars) return FILEs;
22833 function feof (stream : FILEs) return int;
22834 function ferror (stream : FILEs) return int;
22835 function fflush (stream : FILEs) return int;
22836 function fgetc (stream : FILEs) return int;
22837 function fgets (strng : chars; n : int; stream : FILEs)
22838 return chars;
22839 function fileno (stream : FILEs) return int;
22840 function fopen (filename : chars; Mode : chars)
22841 return FILEs;
22842 -- Note: to maintain target independence, use
22843 -- text_translation_required, a boolean variable defined in
22844 -- a-sysdep.c to deal with the target dependent text
22845 -- translation requirement. If this variable is set,
22846 -- then b/t should be appended to the standard mode
22847 -- argument to set the text translation mode off or on
22848 -- as required.
22849 function fputc (C : int; stream : FILEs) return int;
22850 function fputs (Strng : chars; Stream : FILEs) return int;
22851 function fread
22852 (buffer : voids;
22853 size : size_t;
22854 count : size_t;
22855 stream : FILEs)
22856 return size_t;
22857 function freopen
22858 (filename : chars;
22859 mode : chars;
22860 stream : FILEs)
22861 return FILEs;
22862 function fseek
22863 (stream : FILEs;
22864 offset : long;
22865 origin : int)
22866 return int;
22867 function ftell (stream : FILEs) return long;
22868 function fwrite
22869 (buffer : voids;
22870 size : size_t;
22871 count : size_t;
22872 stream : FILEs)
22873 return size_t;
22874 function isatty (handle : int) return int;
22875 procedure mktemp (template : chars);
22876 -- The return value (which is just a pointer to template)
22877 -- is discarded
22878 procedure rewind (stream : FILEs);
22879 function rmtmp return int;
22880 function setvbuf
22881 (stream : FILEs;
22882 buffer : chars;
22883 mode : int;
22884 size : size_t)
22885 return int;
22886
22887 function tmpfile return FILEs;
22888 function ungetc (c : int; stream : FILEs) return int;
22889 function unlink (filename : chars) return int;
22890 ---------------------
22891 -- Extra functions --
22892 ---------------------
22893 -- These functions supply slightly thicker bindings than
22894 -- those above. They are derived from functions in the
22895 -- C Run-Time Library, but may do a bit more work than
22896 -- just directly calling one of the Library functions.
22897 function is_regular_file (handle : int) return int;
22898 -- Tests if given handle is for a regular file (result 1)
22899 -- or for a non-regular file (pipe or device, result 0).
22900 ---------------------------------
22901 -- Control of Text/Binary Mode --
22902 ---------------------------------
22903 -- If text_translation_required is true, then the following
22904 -- functions may be used to dynamically switch a file from
22905 -- binary to text mode or vice versa. These functions have
22906 -- no effect if text_translation_required is false (i.e., in
22907 -- normal UNIX mode). Use fileno to get a stream handle.
22908 procedure set_binary_mode (handle : int);
22909 procedure set_text_mode (handle : int);
22910 ----------------------------
22911 -- Full Path Name support --
22912 ----------------------------
22913 procedure full_name (nam : chars; buffer : chars);
22914 -- Given a NUL terminated string representing a file
22915 -- name, returns in buffer a NUL terminated string
22916 -- representing the full path name for the file name.
22917 -- On systems where it is relevant the drive is also
22918 -- part of the full path name. It is the responsibility
22919 -- of the caller to pass an actual parameter for buffer
22920 -- that is big enough for any full path name. Use
22921 -- max_path_len given below as the size of buffer.
22922 max_path_len : integer;
22923 -- Maximum length of an allowable full path name on the
22924 -- system, including a terminating NUL character.
22925 end Interfaces.C_Streams;
22926 @end example
22927
22928 @node Interfacing to C Streams,,Operations on C Streams,The Implementation of Standard I/O
22929 @anchor{gnat_rm/the_implementation_of_standard_i_o interfacing-to-c-streams}@anchor{2d0}@anchor{gnat_rm/the_implementation_of_standard_i_o id26}@anchor{2d1}
22930 @section Interfacing to C Streams
22931
22932
22933 The packages in this section permit interfacing Ada files to C Stream
22934 operations.
22935
22936 @example
22937 with Interfaces.C_Streams;
22938 package Ada.Sequential_IO.C_Streams is
22939 function C_Stream (F : File_Type)
22940 return Interfaces.C_Streams.FILEs;
22941 procedure Open
22942 (File : in out File_Type;
22943 Mode : in File_Mode;
22944 C_Stream : in Interfaces.C_Streams.FILEs;
22945 Form : in String := "");
22946 end Ada.Sequential_IO.C_Streams;
22947
22948 with Interfaces.C_Streams;
22949 package Ada.Direct_IO.C_Streams is
22950 function C_Stream (F : File_Type)
22951 return Interfaces.C_Streams.FILEs;
22952 procedure Open
22953 (File : in out File_Type;
22954 Mode : in File_Mode;
22955 C_Stream : in Interfaces.C_Streams.FILEs;
22956 Form : in String := "");
22957 end Ada.Direct_IO.C_Streams;
22958
22959 with Interfaces.C_Streams;
22960 package Ada.Text_IO.C_Streams is
22961 function C_Stream (F : File_Type)
22962 return Interfaces.C_Streams.FILEs;
22963 procedure Open
22964 (File : in out File_Type;
22965 Mode : in File_Mode;
22966 C_Stream : in Interfaces.C_Streams.FILEs;
22967 Form : in String := "");
22968 end Ada.Text_IO.C_Streams;
22969
22970 with Interfaces.C_Streams;
22971 package Ada.Wide_Text_IO.C_Streams is
22972 function C_Stream (F : File_Type)
22973 return Interfaces.C_Streams.FILEs;
22974 procedure Open
22975 (File : in out File_Type;
22976 Mode : in File_Mode;
22977 C_Stream : in Interfaces.C_Streams.FILEs;
22978 Form : in String := "");
22979 end Ada.Wide_Text_IO.C_Streams;
22980
22981 with Interfaces.C_Streams;
22982 package Ada.Wide_Wide_Text_IO.C_Streams is
22983 function C_Stream (F : File_Type)
22984 return Interfaces.C_Streams.FILEs;
22985 procedure Open
22986 (File : in out File_Type;
22987 Mode : in File_Mode;
22988 C_Stream : in Interfaces.C_Streams.FILEs;
22989 Form : in String := "");
22990 end Ada.Wide_Wide_Text_IO.C_Streams;
22991
22992 with Interfaces.C_Streams;
22993 package Ada.Stream_IO.C_Streams is
22994 function C_Stream (F : File_Type)
22995 return Interfaces.C_Streams.FILEs;
22996 procedure Open
22997 (File : in out File_Type;
22998 Mode : in File_Mode;
22999 C_Stream : in Interfaces.C_Streams.FILEs;
23000 Form : in String := "");
23001 end Ada.Stream_IO.C_Streams;
23002 @end example
23003
23004 In each of these six packages, the @code{C_Stream} function obtains the
23005 @code{FILE} pointer from a currently opened Ada file. It is then
23006 possible to use the @code{Interfaces.C_Streams} package to operate on
23007 this stream, or the stream can be passed to a C program which can
23008 operate on it directly. Of course the program is responsible for
23009 ensuring that only appropriate sequences of operations are executed.
23010
23011 One particular use of relevance to an Ada program is that the
23012 @code{setvbuf} function can be used to control the buffering of the
23013 stream used by an Ada file. In the absence of such a call the standard
23014 default buffering is used.
23015
23016 The @code{Open} procedures in these packages open a file giving an
23017 existing C Stream instead of a file name. Typically this stream is
23018 imported from a C program, allowing an Ada file to operate on an
23019 existing C file.
23020
23021 @node The GNAT Library,Interfacing to Other Languages,The Implementation of Standard I/O,Top
23022 @anchor{gnat_rm/the_gnat_library the-gnat-library}@anchor{10}@anchor{gnat_rm/the_gnat_library doc}@anchor{2d2}@anchor{gnat_rm/the_gnat_library id1}@anchor{2d3}
23023 @chapter The GNAT Library
23024
23025
23026 The GNAT library contains a number of general and special purpose packages.
23027 It represents functionality that the GNAT developers have found useful, and
23028 which is made available to GNAT users. The packages described here are fully
23029 supported, and upwards compatibility will be maintained in future releases,
23030 so you can use these facilities with the confidence that the same functionality
23031 will be available in future releases.
23032
23033 The chapter here simply gives a brief summary of the facilities available.
23034 The full documentation is found in the spec file for the package. The full
23035 sources of these library packages, including both spec and body, are provided
23036 with all GNAT releases. For example, to find out the full specifications of
23037 the SPITBOL pattern matching capability, including a full tutorial and
23038 extensive examples, look in the @code{g-spipat.ads} file in the library.
23039
23040 For each entry here, the package name (as it would appear in a @code{with}
23041 clause) is given, followed by the name of the corresponding spec file in
23042 parentheses. The packages are children in four hierarchies, @code{Ada},
23043 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
23044 GNAT-specific hierarchy.
23045
23046 Note that an application program should only use packages in one of these
23047 four hierarchies if the package is defined in the Ada Reference Manual,
23048 or is listed in this section of the GNAT Programmers Reference Manual.
23049 All other units should be considered internal implementation units and
23050 should not be directly @code{with}ed by application code. The use of
23051 a @code{with} clause that references one of these internal implementation
23052 units makes an application potentially dependent on changes in versions
23053 of GNAT, and will generate a warning message.
23054
23055 @menu
23056 * Ada.Characters.Latin_9 (a-chlat9.ads): Ada Characters Latin_9 a-chlat9 ads.
23057 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads): Ada Characters Wide_Latin_1 a-cwila1 ads.
23058 * Ada.Characters.Wide_Latin_9 (a-cwila1.ads): Ada Characters Wide_Latin_9 a-cwila1 ads.
23059 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads): Ada Characters Wide_Wide_Latin_1 a-chzla1 ads.
23060 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads): Ada Characters Wide_Wide_Latin_9 a-chzla9 ads.
23061 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads): Ada Containers Formal_Doubly_Linked_Lists a-cfdlli ads.
23062 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads): Ada Containers Formal_Hashed_Maps a-cfhama ads.
23063 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads): Ada Containers Formal_Hashed_Sets a-cfhase ads.
23064 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads): Ada Containers Formal_Ordered_Maps a-cforma ads.
23065 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads): Ada Containers Formal_Ordered_Sets a-cforse ads.
23066 * Ada.Containers.Formal_Vectors (a-cofove.ads): Ada Containers Formal_Vectors a-cofove ads.
23067 * Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads): Ada Containers Formal_Indefinite_Vectors a-cfinve ads.
23068 * Ada.Containers.Functional_Vectors (a-cofuve.ads): Ada Containers Functional_Vectors a-cofuve ads.
23069 * Ada.Containers.Functional_Sets (a-cofuse.ads): Ada Containers Functional_Sets a-cofuse ads.
23070 * Ada.Containers.Functional_Maps (a-cofuma.ads): Ada Containers Functional_Maps a-cofuma ads.
23071 * Ada.Containers.Bounded_Holders (a-coboho.ads): Ada Containers Bounded_Holders a-coboho ads.
23072 * Ada.Command_Line.Environment (a-colien.ads): Ada Command_Line Environment a-colien ads.
23073 * Ada.Command_Line.Remove (a-colire.ads): Ada Command_Line Remove a-colire ads.
23074 * Ada.Command_Line.Response_File (a-clrefi.ads): Ada Command_Line Response_File a-clrefi ads.
23075 * Ada.Direct_IO.C_Streams (a-diocst.ads): Ada Direct_IO C_Streams a-diocst ads.
23076 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads): Ada Exceptions Is_Null_Occurrence a-einuoc ads.
23077 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads): Ada Exceptions Last_Chance_Handler a-elchha ads.
23078 * Ada.Exceptions.Traceback (a-exctra.ads): Ada Exceptions Traceback a-exctra ads.
23079 * Ada.Sequential_IO.C_Streams (a-siocst.ads): Ada Sequential_IO C_Streams a-siocst ads.
23080 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads): Ada Streams Stream_IO C_Streams a-ssicst ads.
23081 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads): Ada Strings Unbounded Text_IO a-suteio ads.
23082 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads): Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads.
23083 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads): Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads.
23084 * Ada.Text_IO.C_Streams (a-tiocst.ads): Ada Text_IO C_Streams a-tiocst ads.
23085 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads): Ada Text_IO Reset_Standard_Files a-tirsfi ads.
23086 * Ada.Wide_Characters.Unicode (a-wichun.ads): Ada Wide_Characters Unicode a-wichun ads.
23087 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads): Ada Wide_Text_IO C_Streams a-wtcstr ads.
23088 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads): Ada Wide_Text_IO Reset_Standard_Files a-wrstfi ads.
23089 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads): Ada Wide_Wide_Characters Unicode a-zchuni ads.
23090 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads): Ada Wide_Wide_Text_IO C_Streams a-ztcstr ads.
23091 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads): Ada Wide_Wide_Text_IO Reset_Standard_Files a-zrstfi ads.
23092 * GNAT.Altivec (g-altive.ads): GNAT Altivec g-altive ads.
23093 * GNAT.Altivec.Conversions (g-altcon.ads): GNAT Altivec Conversions g-altcon ads.
23094 * GNAT.Altivec.Vector_Operations (g-alveop.ads): GNAT Altivec Vector_Operations g-alveop ads.
23095 * GNAT.Altivec.Vector_Types (g-alvety.ads): GNAT Altivec Vector_Types g-alvety ads.
23096 * GNAT.Altivec.Vector_Views (g-alvevi.ads): GNAT Altivec Vector_Views g-alvevi ads.
23097 * GNAT.Array_Split (g-arrspl.ads): GNAT Array_Split g-arrspl ads.
23098 * GNAT.AWK (g-awk.ads): GNAT AWK g-awk ads.
23099 * GNAT.Bind_Environment (g-binenv.ads): GNAT Bind_Environment g-binenv ads.
23100 * GNAT.Branch_Prediction (g-brapre.ads): GNAT Branch_Prediction g-brapre ads.
23101 * GNAT.Bounded_Buffers (g-boubuf.ads): GNAT Bounded_Buffers g-boubuf ads.
23102 * GNAT.Bounded_Mailboxes (g-boumai.ads): GNAT Bounded_Mailboxes g-boumai ads.
23103 * GNAT.Bubble_Sort (g-bubsor.ads): GNAT Bubble_Sort g-bubsor ads.
23104 * GNAT.Bubble_Sort_A (g-busora.ads): GNAT Bubble_Sort_A g-busora ads.
23105 * GNAT.Bubble_Sort_G (g-busorg.ads): GNAT Bubble_Sort_G g-busorg ads.
23106 * GNAT.Byte_Order_Mark (g-byorma.ads): GNAT Byte_Order_Mark g-byorma ads.
23107 * GNAT.Byte_Swapping (g-bytswa.ads): GNAT Byte_Swapping g-bytswa ads.
23108 * GNAT.Calendar (g-calend.ads): GNAT Calendar g-calend ads.
23109 * GNAT.Calendar.Time_IO (g-catiio.ads): GNAT Calendar Time_IO g-catiio ads.
23110 * GNAT.CRC32 (g-crc32.ads): GNAT CRC32 g-crc32 ads.
23111 * GNAT.Case_Util (g-casuti.ads): GNAT Case_Util g-casuti ads.
23112 * GNAT.CGI (g-cgi.ads): GNAT CGI g-cgi ads.
23113 * GNAT.CGI.Cookie (g-cgicoo.ads): GNAT CGI Cookie g-cgicoo ads.
23114 * GNAT.CGI.Debug (g-cgideb.ads): GNAT CGI Debug g-cgideb ads.
23115 * GNAT.Command_Line (g-comlin.ads): GNAT Command_Line g-comlin ads.
23116 * GNAT.Compiler_Version (g-comver.ads): GNAT Compiler_Version g-comver ads.
23117 * GNAT.Ctrl_C (g-ctrl_c.ads): GNAT Ctrl_C g-ctrl_c ads.
23118 * GNAT.Current_Exception (g-curexc.ads): GNAT Current_Exception g-curexc ads.
23119 * GNAT.Debug_Pools (g-debpoo.ads): GNAT Debug_Pools g-debpoo ads.
23120 * GNAT.Debug_Utilities (g-debuti.ads): GNAT Debug_Utilities g-debuti ads.
23121 * GNAT.Decode_String (g-decstr.ads): GNAT Decode_String g-decstr ads.
23122 * GNAT.Decode_UTF8_String (g-deutst.ads): GNAT Decode_UTF8_String g-deutst ads.
23123 * GNAT.Directory_Operations (g-dirope.ads): GNAT Directory_Operations g-dirope ads.
23124 * GNAT.Directory_Operations.Iteration (g-diopit.ads): GNAT Directory_Operations Iteration g-diopit ads.
23125 * GNAT.Dynamic_HTables (g-dynhta.ads): GNAT Dynamic_HTables g-dynhta ads.
23126 * GNAT.Dynamic_Tables (g-dyntab.ads): GNAT Dynamic_Tables g-dyntab ads.
23127 * GNAT.Encode_String (g-encstr.ads): GNAT Encode_String g-encstr ads.
23128 * GNAT.Encode_UTF8_String (g-enutst.ads): GNAT Encode_UTF8_String g-enutst ads.
23129 * GNAT.Exception_Actions (g-excact.ads): GNAT Exception_Actions g-excact ads.
23130 * GNAT.Exception_Traces (g-exctra.ads): GNAT Exception_Traces g-exctra ads.
23131 * GNAT.Exceptions (g-except.ads): GNAT Exceptions g-except ads.
23132 * GNAT.Expect (g-expect.ads): GNAT Expect g-expect ads.
23133 * GNAT.Expect.TTY (g-exptty.ads): GNAT Expect TTY g-exptty ads.
23134 * GNAT.Float_Control (g-flocon.ads): GNAT Float_Control g-flocon ads.
23135 * GNAT.Formatted_String (g-forstr.ads): GNAT Formatted_String g-forstr ads.
23136 * GNAT.Heap_Sort (g-heasor.ads): GNAT Heap_Sort g-heasor ads.
23137 * GNAT.Heap_Sort_A (g-hesora.ads): GNAT Heap_Sort_A g-hesora ads.
23138 * GNAT.Heap_Sort_G (g-hesorg.ads): GNAT Heap_Sort_G g-hesorg ads.
23139 * GNAT.HTable (g-htable.ads): GNAT HTable g-htable ads.
23140 * GNAT.IO (g-io.ads): GNAT IO g-io ads.
23141 * GNAT.IO_Aux (g-io_aux.ads): GNAT IO_Aux g-io_aux ads.
23142 * GNAT.Lock_Files (g-locfil.ads): GNAT Lock_Files g-locfil ads.
23143 * GNAT.MBBS_Discrete_Random (g-mbdira.ads): GNAT MBBS_Discrete_Random g-mbdira ads.
23144 * GNAT.MBBS_Float_Random (g-mbflra.ads): GNAT MBBS_Float_Random g-mbflra ads.
23145 * GNAT.MD5 (g-md5.ads): GNAT MD5 g-md5 ads.
23146 * GNAT.Memory_Dump (g-memdum.ads): GNAT Memory_Dump g-memdum ads.
23147 * GNAT.Most_Recent_Exception (g-moreex.ads): GNAT Most_Recent_Exception g-moreex ads.
23148 * GNAT.OS_Lib (g-os_lib.ads): GNAT OS_Lib g-os_lib ads.
23149 * GNAT.Perfect_Hash_Generators (g-pehage.ads): GNAT Perfect_Hash_Generators g-pehage ads.
23150 * GNAT.Random_Numbers (g-rannum.ads): GNAT Random_Numbers g-rannum ads.
23151 * GNAT.Regexp (g-regexp.ads): GNAT Regexp g-regexp ads.
23152 * GNAT.Registry (g-regist.ads): GNAT Registry g-regist ads.
23153 * GNAT.Regpat (g-regpat.ads): GNAT Regpat g-regpat ads.
23154 * GNAT.Rewrite_Data (g-rewdat.ads): GNAT Rewrite_Data g-rewdat ads.
23155 * GNAT.Secondary_Stack_Info (g-sestin.ads): GNAT Secondary_Stack_Info g-sestin ads.
23156 * GNAT.Semaphores (g-semaph.ads): GNAT Semaphores g-semaph ads.
23157 * GNAT.Serial_Communications (g-sercom.ads): GNAT Serial_Communications g-sercom ads.
23158 * GNAT.SHA1 (g-sha1.ads): GNAT SHA1 g-sha1 ads.
23159 * GNAT.SHA224 (g-sha224.ads): GNAT SHA224 g-sha224 ads.
23160 * GNAT.SHA256 (g-sha256.ads): GNAT SHA256 g-sha256 ads.
23161 * GNAT.SHA384 (g-sha384.ads): GNAT SHA384 g-sha384 ads.
23162 * GNAT.SHA512 (g-sha512.ads): GNAT SHA512 g-sha512 ads.
23163 * GNAT.Signals (g-signal.ads): GNAT Signals g-signal ads.
23164 * GNAT.Sockets (g-socket.ads): GNAT Sockets g-socket ads.
23165 * GNAT.Source_Info (g-souinf.ads): GNAT Source_Info g-souinf ads.
23166 * GNAT.Spelling_Checker (g-speche.ads): GNAT Spelling_Checker g-speche ads.
23167 * GNAT.Spelling_Checker_Generic (g-spchge.ads): GNAT Spelling_Checker_Generic g-spchge ads.
23168 * GNAT.Spitbol.Patterns (g-spipat.ads): GNAT Spitbol Patterns g-spipat ads.
23169 * GNAT.Spitbol (g-spitbo.ads): GNAT Spitbol g-spitbo ads.
23170 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads): GNAT Spitbol Table_Boolean g-sptabo ads.
23171 * GNAT.Spitbol.Table_Integer (g-sptain.ads): GNAT Spitbol Table_Integer g-sptain ads.
23172 * GNAT.Spitbol.Table_VString (g-sptavs.ads): GNAT Spitbol Table_VString g-sptavs ads.
23173 * GNAT.SSE (g-sse.ads): GNAT SSE g-sse ads.
23174 * GNAT.SSE.Vector_Types (g-ssvety.ads): GNAT SSE Vector_Types g-ssvety ads.
23175 * GNAT.String_Hash (g-strhas.ads): GNAT String_Hash g-strhas ads.
23176 * GNAT.Strings (g-string.ads): GNAT Strings g-string ads.
23177 * GNAT.String_Split (g-strspl.ads): GNAT String_Split g-strspl ads.
23178 * GNAT.Table (g-table.ads): GNAT Table g-table ads.
23179 * GNAT.Task_Lock (g-tasloc.ads): GNAT Task_Lock g-tasloc ads.
23180 * GNAT.Time_Stamp (g-timsta.ads): GNAT Time_Stamp g-timsta ads.
23181 * GNAT.Threads (g-thread.ads): GNAT Threads g-thread ads.
23182 * GNAT.Traceback (g-traceb.ads): GNAT Traceback g-traceb ads.
23183 * GNAT.Traceback.Symbolic (g-trasym.ads): GNAT Traceback Symbolic g-trasym ads.
23184 * GNAT.UTF_32 (g-table.ads): GNAT UTF_32 g-table ads.
23185 * GNAT.Wide_Spelling_Checker (g-u3spch.ads): GNAT Wide_Spelling_Checker g-u3spch ads.
23186 * GNAT.Wide_Spelling_Checker (g-wispch.ads): GNAT Wide_Spelling_Checker g-wispch ads.
23187 * GNAT.Wide_String_Split (g-wistsp.ads): GNAT Wide_String_Split g-wistsp ads.
23188 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads): GNAT Wide_Wide_Spelling_Checker g-zspche ads.
23189 * GNAT.Wide_Wide_String_Split (g-zistsp.ads): GNAT Wide_Wide_String_Split g-zistsp ads.
23190 * Interfaces.C.Extensions (i-cexten.ads): Interfaces C Extensions i-cexten ads.
23191 * Interfaces.C.Streams (i-cstrea.ads): Interfaces C Streams i-cstrea ads.
23192 * Interfaces.Packed_Decimal (i-pacdec.ads): Interfaces Packed_Decimal i-pacdec ads.
23193 * Interfaces.VxWorks (i-vxwork.ads): Interfaces VxWorks i-vxwork ads.
23194 * Interfaces.VxWorks.Int_Connection (i-vxinco.ads): Interfaces VxWorks Int_Connection i-vxinco ads.
23195 * Interfaces.VxWorks.IO (i-vxwoio.ads): Interfaces VxWorks IO i-vxwoio ads.
23196 * System.Address_Image (s-addima.ads): System Address_Image s-addima ads.
23197 * System.Assertions (s-assert.ads): System Assertions s-assert ads.
23198 * System.Atomic_Counters (s-atocou.ads): System Atomic_Counters s-atocou ads.
23199 * System.Memory (s-memory.ads): System Memory s-memory ads.
23200 * System.Multiprocessors (s-multip.ads): System Multiprocessors s-multip ads.
23201 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads): System Multiprocessors Dispatching_Domains s-mudido ads.
23202 * System.Partition_Interface (s-parint.ads): System Partition_Interface s-parint ads.
23203 * System.Pool_Global (s-pooglo.ads): System Pool_Global s-pooglo ads.
23204 * System.Pool_Local (s-pooloc.ads): System Pool_Local s-pooloc ads.
23205 * System.Restrictions (s-restri.ads): System Restrictions s-restri ads.
23206 * System.Rident (s-rident.ads): System Rident s-rident ads.
23207 * System.Strings.Stream_Ops (s-ststop.ads): System Strings Stream_Ops s-ststop ads.
23208 * System.Unsigned_Types (s-unstyp.ads): System Unsigned_Types s-unstyp ads.
23209 * System.Wch_Cnv (s-wchcnv.ads): System Wch_Cnv s-wchcnv ads.
23210 * System.Wch_Con (s-wchcon.ads): System Wch_Con s-wchcon ads.
23211
23212 @end menu
23213
23214 @node Ada Characters Latin_9 a-chlat9 ads,Ada Characters Wide_Latin_1 a-cwila1 ads,,The GNAT Library
23215 @anchor{gnat_rm/the_gnat_library id2}@anchor{2d4}@anchor{gnat_rm/the_gnat_library ada-characters-latin-9-a-chlat9-ads}@anchor{2d5}
23216 @section @code{Ada.Characters.Latin_9} (@code{a-chlat9.ads})
23217
23218
23219 @geindex Ada.Characters.Latin_9 (a-chlat9.ads)
23220
23221 @geindex Latin_9 constants for Character
23222
23223 This child of @code{Ada.Characters}
23224 provides a set of definitions corresponding to those in the
23225 RM-defined package @code{Ada.Characters.Latin_1} but with the
23226 few modifications required for @code{Latin-9}
23227 The provision of such a package
23228 is specifically authorized by the Ada Reference Manual
23229 (RM A.3.3(27)).
23230
23231 @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
23232 @anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-1-a-cwila1-ads}@anchor{2d6}@anchor{gnat_rm/the_gnat_library id3}@anchor{2d7}
23233 @section @code{Ada.Characters.Wide_Latin_1} (@code{a-cwila1.ads})
23234
23235
23236 @geindex Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
23237
23238 @geindex Latin_1 constants for Wide_Character
23239
23240 This child of @code{Ada.Characters}
23241 provides a set of definitions corresponding to those in the
23242 RM-defined package @code{Ada.Characters.Latin_1} but with the
23243 types of the constants being @code{Wide_Character}
23244 instead of @code{Character}. The provision of such a package
23245 is specifically authorized by the Ada Reference Manual
23246 (RM A.3.3(27)).
23247
23248 @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
23249 @anchor{gnat_rm/the_gnat_library id4}@anchor{2d8}@anchor{gnat_rm/the_gnat_library ada-characters-wide-latin-9-a-cwila1-ads}@anchor{2d9}
23250 @section @code{Ada.Characters.Wide_Latin_9} (@code{a-cwila1.ads})
23251
23252
23253 @geindex Ada.Characters.Wide_Latin_9 (a-cwila1.ads)
23254
23255 @geindex Latin_9 constants for Wide_Character
23256
23257 This child of @code{Ada.Characters}
23258 provides a set of definitions corresponding to those in the
23259 GNAT defined package @code{Ada.Characters.Latin_9} but with the
23260 types of the constants being @code{Wide_Character}
23261 instead of @code{Character}. The provision of such a package
23262 is specifically authorized by the Ada Reference Manual
23263 (RM A.3.3(27)).
23264
23265 @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
23266 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-1-a-chzla1-ads}@anchor{2da}@anchor{gnat_rm/the_gnat_library id5}@anchor{2db}
23267 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@code{a-chzla1.ads})
23268
23269
23270 @geindex Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
23271
23272 @geindex Latin_1 constants for Wide_Wide_Character
23273
23274 This child of @code{Ada.Characters}
23275 provides a set of definitions corresponding to those in the
23276 RM-defined package @code{Ada.Characters.Latin_1} but with the
23277 types of the constants being @code{Wide_Wide_Character}
23278 instead of @code{Character}. The provision of such a package
23279 is specifically authorized by the Ada Reference Manual
23280 (RM A.3.3(27)).
23281
23282 @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
23283 @anchor{gnat_rm/the_gnat_library ada-characters-wide-wide-latin-9-a-chzla9-ads}@anchor{2dc}@anchor{gnat_rm/the_gnat_library id6}@anchor{2dd}
23284 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@code{a-chzla9.ads})
23285
23286
23287 @geindex Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
23288
23289 @geindex Latin_9 constants for Wide_Wide_Character
23290
23291 This child of @code{Ada.Characters}
23292 provides a set of definitions corresponding to those in the
23293 GNAT defined package @code{Ada.Characters.Latin_9} but with the
23294 types of the constants being @code{Wide_Wide_Character}
23295 instead of @code{Character}. The provision of such a package
23296 is specifically authorized by the Ada Reference Manual
23297 (RM A.3.3(27)).
23298
23299 @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
23300 @anchor{gnat_rm/the_gnat_library id7}@anchor{2de}@anchor{gnat_rm/the_gnat_library ada-containers-formal-doubly-linked-lists-a-cfdlli-ads}@anchor{2df}
23301 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@code{a-cfdlli.ads})
23302
23303
23304 @geindex Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
23305
23306 @geindex Formal container for doubly linked lists
23307
23308 This child of @code{Ada.Containers} defines a modified version of the
23309 Ada 2005 container for doubly linked lists, meant to facilitate formal
23310 verification of code using such containers. The specification of this
23311 unit is compatible with SPARK 2014.
23312
23313 Note that although this container was designed with formal verification
23314 in mind, it may well be generally useful in that it is a simplified more
23315 efficient version than the one defined in the standard. In particular it
23316 does not have the complex overhead required to detect cursor tampering.
23317
23318 @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
23319 @anchor{gnat_rm/the_gnat_library id8}@anchor{2e0}@anchor{gnat_rm/the_gnat_library ada-containers-formal-hashed-maps-a-cfhama-ads}@anchor{2e1}
23320 @section @code{Ada.Containers.Formal_Hashed_Maps} (@code{a-cfhama.ads})
23321
23322
23323 @geindex Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
23324
23325 @geindex Formal container for hashed maps
23326
23327 This child of @code{Ada.Containers} defines a modified version of the
23328 Ada 2005 container for hashed maps, meant to facilitate formal
23329 verification of code using such containers. The specification of this
23330 unit is compatible with SPARK 2014.
23331
23332 Note that although this container was designed with formal verification
23333 in mind, it may well be generally useful in that it is a simplified more
23334 efficient version than the one defined in the standard. In particular it
23335 does not have the complex overhead required to detect cursor tampering.
23336
23337 @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
23338 @anchor{gnat_rm/the_gnat_library id9}@anchor{2e2}@anchor{gnat_rm/the_gnat_library ada-containers-formal-hashed-sets-a-cfhase-ads}@anchor{2e3}
23339 @section @code{Ada.Containers.Formal_Hashed_Sets} (@code{a-cfhase.ads})
23340
23341
23342 @geindex Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
23343
23344 @geindex Formal container for hashed sets
23345
23346 This child of @code{Ada.Containers} defines a modified version of the
23347 Ada 2005 container for hashed sets, meant to facilitate formal
23348 verification of code using such containers. The specification of this
23349 unit is compatible with SPARK 2014.
23350
23351 Note that although this container was designed with formal verification
23352 in mind, it may well be generally useful in that it is a simplified more
23353 efficient version than the one defined in the standard. In particular it
23354 does not have the complex overhead required to detect cursor tampering.
23355
23356 @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
23357 @anchor{gnat_rm/the_gnat_library id10}@anchor{2e4}@anchor{gnat_rm/the_gnat_library ada-containers-formal-ordered-maps-a-cforma-ads}@anchor{2e5}
23358 @section @code{Ada.Containers.Formal_Ordered_Maps} (@code{a-cforma.ads})
23359
23360
23361 @geindex Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
23362
23363 @geindex Formal container for ordered maps
23364
23365 This child of @code{Ada.Containers} defines a modified version of the
23366 Ada 2005 container for ordered maps, meant to facilitate formal
23367 verification of code using such containers. The specification of this
23368 unit is compatible with SPARK 2014.
23369
23370 Note that although this container was designed with formal verification
23371 in mind, it may well be generally useful in that it is a simplified more
23372 efficient version than the one defined in the standard. In particular it
23373 does not have the complex overhead required to detect cursor tampering.
23374
23375 @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
23376 @anchor{gnat_rm/the_gnat_library ada-containers-formal-ordered-sets-a-cforse-ads}@anchor{2e6}@anchor{gnat_rm/the_gnat_library id11}@anchor{2e7}
23377 @section @code{Ada.Containers.Formal_Ordered_Sets} (@code{a-cforse.ads})
23378
23379
23380 @geindex Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
23381
23382 @geindex Formal container for ordered sets
23383
23384 This child of @code{Ada.Containers} defines a modified version of the
23385 Ada 2005 container for ordered sets, meant to facilitate formal
23386 verification of code using such containers. The specification of this
23387 unit is compatible with SPARK 2014.
23388
23389 Note that although this container was designed with formal verification
23390 in mind, it may well be generally useful in that it is a simplified more
23391 efficient version than the one defined in the standard. In particular it
23392 does not have the complex overhead required to detect cursor tampering.
23393
23394 @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
23395 @anchor{gnat_rm/the_gnat_library id12}@anchor{2e8}@anchor{gnat_rm/the_gnat_library ada-containers-formal-vectors-a-cofove-ads}@anchor{2e9}
23396 @section @code{Ada.Containers.Formal_Vectors} (@code{a-cofove.ads})
23397
23398
23399 @geindex Ada.Containers.Formal_Vectors (a-cofove.ads)
23400
23401 @geindex Formal container for vectors
23402
23403 This child of @code{Ada.Containers} defines a modified version of the
23404 Ada 2005 container for vectors, meant to facilitate formal
23405 verification of code using such containers. The specification of this
23406 unit is compatible with SPARK 2014.
23407
23408 Note that although this container was designed with formal verification
23409 in mind, it may well be generally useful in that it is a simplified more
23410 efficient version than the one defined in the standard. In particular it
23411 does not have the complex overhead required to detect cursor tampering.
23412
23413 @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
23414 @anchor{gnat_rm/the_gnat_library id13}@anchor{2ea}@anchor{gnat_rm/the_gnat_library ada-containers-formal-indefinite-vectors-a-cfinve-ads}@anchor{2eb}
23415 @section @code{Ada.Containers.Formal_Indefinite_Vectors} (@code{a-cfinve.ads})
23416
23417
23418 @geindex Ada.Containers.Formal_Indefinite_Vectors (a-cfinve.ads)
23419
23420 @geindex Formal container for vectors
23421
23422 This child of @code{Ada.Containers} defines a modified version of the
23423 Ada 2005 container for vectors of indefinite elements, meant to
23424 facilitate formal verification of code using such containers. The
23425 specification of this unit is compatible with SPARK 2014.
23426
23427 Note that although this container was designed with formal verification
23428 in mind, it may well be generally useful in that it is a simplified more
23429 efficient version than the one defined in the standard. In particular it
23430 does not have the complex overhead required to detect cursor tampering.
23431
23432 @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
23433 @anchor{gnat_rm/the_gnat_library id14}@anchor{2ec}@anchor{gnat_rm/the_gnat_library ada-containers-functional-vectors-a-cofuve-ads}@anchor{2ed}
23434 @section @code{Ada.Containers.Functional_Vectors} (@code{a-cofuve.ads})
23435
23436
23437 @geindex Ada.Containers.Functional_Vectors (a-cofuve.ads)
23438
23439 @geindex Functional vectors
23440
23441 This child of @code{Ada.Containers} defines immutable vectors. These
23442 containers are unbounded and may contain indefinite elements. Furthermore, to
23443 be usable in every context, they are neither controlled nor limited. As they
23444 are functional, that is, no primitives are provided which would allow modifying
23445 an existing container, these containers can still be used safely.
23446
23447 Their API features functions creating new containers from existing ones.
23448 As a consequence, these containers are highly inefficient. They are also
23449 memory consuming, as the allocated memory is not reclaimed when the container
23450 is no longer referenced. Thus, they should in general be used in ghost code
23451 and annotations, so that they can be removed from the final executable. The
23452 specification of this unit is compatible with SPARK 2014.
23453
23454 @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
23455 @anchor{gnat_rm/the_gnat_library ada-containers-functional-sets-a-cofuse-ads}@anchor{2ee}@anchor{gnat_rm/the_gnat_library id15}@anchor{2ef}
23456 @section @code{Ada.Containers.Functional_Sets} (@code{a-cofuse.ads})
23457
23458
23459 @geindex Ada.Containers.Functional_Sets (a-cofuse.ads)
23460
23461 @geindex Functional sets
23462
23463 This child of @code{Ada.Containers} defines immutable sets. These containers are
23464 unbounded and may contain indefinite elements. Furthermore, to be usable in
23465 every context, they are neither controlled nor limited. As they are functional,
23466 that is, no primitives are provided which would allow modifying an existing
23467 container, these containers can still be used safely.
23468
23469 Their API features functions creating new containers from existing ones.
23470 As a consequence, these containers are highly inefficient. They are also
23471 memory consuming, as the allocated memory is not reclaimed when the container
23472 is no longer referenced. Thus, they should in general be used in ghost code
23473 and annotations, so that they can be removed from the final executable. The
23474 specification of this unit is compatible with SPARK 2014.
23475
23476 @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
23477 @anchor{gnat_rm/the_gnat_library id16}@anchor{2f0}@anchor{gnat_rm/the_gnat_library ada-containers-functional-maps-a-cofuma-ads}@anchor{2f1}
23478 @section @code{Ada.Containers.Functional_Maps} (@code{a-cofuma.ads})
23479
23480
23481 @geindex Ada.Containers.Functional_Maps (a-cofuma.ads)
23482
23483 @geindex Functional maps
23484
23485 This child of @code{Ada.Containers} defines immutable maps. These containers are
23486 unbounded and may contain indefinite elements. Furthermore, to be usable in
23487 every context, they are neither controlled nor limited. As they are functional,
23488 that is, no primitives are provided which would allow modifying an existing
23489 container, these containers can still be used safely.
23490
23491 Their API features functions creating new containers from existing ones.
23492 As a consequence, these containers are highly inefficient. They are also
23493 memory consuming, as the allocated memory is not reclaimed when the container
23494 is no longer referenced. Thus, they should in general be used in ghost code
23495 and annotations, so that they can be removed from the final executable. The
23496 specification of this unit is compatible with SPARK 2014.
23497
23498 @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
23499 @anchor{gnat_rm/the_gnat_library ada-containers-bounded-holders-a-coboho-ads}@anchor{2f2}@anchor{gnat_rm/the_gnat_library id17}@anchor{2f3}
23500 @section @code{Ada.Containers.Bounded_Holders} (@code{a-coboho.ads})
23501
23502
23503 @geindex Ada.Containers.Bounded_Holders (a-coboho.ads)
23504
23505 @geindex Formal container for vectors
23506
23507 This child of @code{Ada.Containers} defines a modified version of
23508 Indefinite_Holders that avoids heap allocation.
23509
23510 @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
23511 @anchor{gnat_rm/the_gnat_library ada-command-line-environment-a-colien-ads}@anchor{2f4}@anchor{gnat_rm/the_gnat_library id18}@anchor{2f5}
23512 @section @code{Ada.Command_Line.Environment} (@code{a-colien.ads})
23513
23514
23515 @geindex Ada.Command_Line.Environment (a-colien.ads)
23516
23517 @geindex Environment entries
23518
23519 This child of @code{Ada.Command_Line}
23520 provides a mechanism for obtaining environment values on systems
23521 where this concept makes sense.
23522
23523 @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
23524 @anchor{gnat_rm/the_gnat_library id19}@anchor{2f6}@anchor{gnat_rm/the_gnat_library ada-command-line-remove-a-colire-ads}@anchor{2f7}
23525 @section @code{Ada.Command_Line.Remove} (@code{a-colire.ads})
23526
23527
23528 @geindex Ada.Command_Line.Remove (a-colire.ads)
23529
23530 @geindex Removing command line arguments
23531
23532 @geindex Command line
23533 @geindex argument removal
23534
23535 This child of @code{Ada.Command_Line}
23536 provides a mechanism for logically removing
23537 arguments from the argument list. Once removed, an argument is not visible
23538 to further calls on the subprograms in @code{Ada.Command_Line} will not
23539 see the removed argument.
23540
23541 @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
23542 @anchor{gnat_rm/the_gnat_library id20}@anchor{2f8}@anchor{gnat_rm/the_gnat_library ada-command-line-response-file-a-clrefi-ads}@anchor{2f9}
23543 @section @code{Ada.Command_Line.Response_File} (@code{a-clrefi.ads})
23544
23545
23546 @geindex Ada.Command_Line.Response_File (a-clrefi.ads)
23547
23548 @geindex Response file for command line
23549
23550 @geindex Command line
23551 @geindex response file
23552
23553 @geindex Command line
23554 @geindex handling long command lines
23555
23556 This child of @code{Ada.Command_Line} provides a mechanism facilities for
23557 getting command line arguments from a text file, called a "response file".
23558 Using a response file allow passing a set of arguments to an executable longer
23559 than the maximum allowed by the system on the command line.
23560
23561 @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
23562 @anchor{gnat_rm/the_gnat_library id21}@anchor{2fa}@anchor{gnat_rm/the_gnat_library ada-direct-io-c-streams-a-diocst-ads}@anchor{2fb}
23563 @section @code{Ada.Direct_IO.C_Streams} (@code{a-diocst.ads})
23564
23565
23566 @geindex Ada.Direct_IO.C_Streams (a-diocst.ads)
23567
23568 @geindex C Streams
23569 @geindex Interfacing with Direct_IO
23570
23571 This package provides subprograms that allow interfacing between
23572 C streams and @code{Direct_IO}. The stream identifier can be
23573 extracted from a file opened on the Ada side, and an Ada file
23574 can be constructed from a stream opened on the C side.
23575
23576 @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
23577 @anchor{gnat_rm/the_gnat_library id22}@anchor{2fc}@anchor{gnat_rm/the_gnat_library ada-exceptions-is-null-occurrence-a-einuoc-ads}@anchor{2fd}
23578 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@code{a-einuoc.ads})
23579
23580
23581 @geindex Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
23582
23583 @geindex Null_Occurrence
23584 @geindex testing for
23585
23586 This child subprogram provides a way of testing for the null
23587 exception occurrence (@code{Null_Occurrence}) without raising
23588 an exception.
23589
23590 @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
23591 @anchor{gnat_rm/the_gnat_library id23}@anchor{2fe}@anchor{gnat_rm/the_gnat_library ada-exceptions-last-chance-handler-a-elchha-ads}@anchor{2ff}
23592 @section @code{Ada.Exceptions.Last_Chance_Handler} (@code{a-elchha.ads})
23593
23594
23595 @geindex Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
23596
23597 @geindex Null_Occurrence
23598 @geindex testing for
23599
23600 This child subprogram is used for handling otherwise unhandled
23601 exceptions (hence the name last chance), and perform clean ups before
23602 terminating the program. Note that this subprogram never returns.
23603
23604 @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
23605 @anchor{gnat_rm/the_gnat_library ada-exceptions-traceback-a-exctra-ads}@anchor{300}@anchor{gnat_rm/the_gnat_library id24}@anchor{301}
23606 @section @code{Ada.Exceptions.Traceback} (@code{a-exctra.ads})
23607
23608
23609 @geindex Ada.Exceptions.Traceback (a-exctra.ads)
23610
23611 @geindex Traceback for Exception Occurrence
23612
23613 This child package provides the subprogram (@code{Tracebacks}) to
23614 give a traceback array of addresses based on an exception
23615 occurrence.
23616
23617 @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
23618 @anchor{gnat_rm/the_gnat_library ada-sequential-io-c-streams-a-siocst-ads}@anchor{302}@anchor{gnat_rm/the_gnat_library id25}@anchor{303}
23619 @section @code{Ada.Sequential_IO.C_Streams} (@code{a-siocst.ads})
23620
23621
23622 @geindex Ada.Sequential_IO.C_Streams (a-siocst.ads)
23623
23624 @geindex C Streams
23625 @geindex Interfacing with Sequential_IO
23626
23627 This package provides subprograms that allow interfacing between
23628 C streams and @code{Sequential_IO}. The stream identifier can be
23629 extracted from a file opened on the Ada side, and an Ada file
23630 can be constructed from a stream opened on the C side.
23631
23632 @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
23633 @anchor{gnat_rm/the_gnat_library id26}@anchor{304}@anchor{gnat_rm/the_gnat_library ada-streams-stream-io-c-streams-a-ssicst-ads}@anchor{305}
23634 @section @code{Ada.Streams.Stream_IO.C_Streams} (@code{a-ssicst.ads})
23635
23636
23637 @geindex Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
23638
23639 @geindex C Streams
23640 @geindex Interfacing with Stream_IO
23641
23642 This package provides subprograms that allow interfacing between
23643 C streams and @code{Stream_IO}. The stream identifier can be
23644 extracted from a file opened on the Ada side, and an Ada file
23645 can be constructed from a stream opened on the C side.
23646
23647 @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
23648 @anchor{gnat_rm/the_gnat_library ada-strings-unbounded-text-io-a-suteio-ads}@anchor{306}@anchor{gnat_rm/the_gnat_library id27}@anchor{307}
23649 @section @code{Ada.Strings.Unbounded.Text_IO} (@code{a-suteio.ads})
23650
23651
23652 @geindex Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
23653
23654 @geindex Unbounded_String
23655 @geindex IO support
23656
23657 @geindex Text_IO
23658 @geindex extensions for unbounded strings
23659
23660 This package provides subprograms for Text_IO for unbounded
23661 strings, avoiding the necessity for an intermediate operation
23662 with ordinary strings.
23663
23664 @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
23665 @anchor{gnat_rm/the_gnat_library id28}@anchor{308}@anchor{gnat_rm/the_gnat_library ada-strings-wide-unbounded-wide-text-io-a-swuwti-ads}@anchor{309}
23666 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@code{a-swuwti.ads})
23667
23668
23669 @geindex Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
23670
23671 @geindex Unbounded_Wide_String
23672 @geindex IO support
23673
23674 @geindex Text_IO
23675 @geindex extensions for unbounded wide strings
23676
23677 This package provides subprograms for Text_IO for unbounded
23678 wide strings, avoiding the necessity for an intermediate operation
23679 with ordinary wide strings.
23680
23681 @node Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,Ada Text_IO C_Streams a-tiocst ads,Ada Strings Wide_Unbounded Wide_Text_IO a-swuwti ads,The GNAT Library
23682 @anchor{gnat_rm/the_gnat_library id29}@anchor{30a}@anchor{gnat_rm/the_gnat_library ada-strings-wide-wide-unbounded-wide-wide-text-io-a-szuzti-ads}@anchor{30b}
23683 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@code{a-szuzti.ads})
23684
23685
23686 @geindex Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
23687
23688 @geindex Unbounded_Wide_Wide_String
23689 @geindex IO support
23690
23691 @geindex Text_IO
23692 @geindex extensions for unbounded wide wide strings
23693
23694 This package provides subprograms for Text_IO for unbounded
23695 wide wide strings, avoiding the necessity for an intermediate operation
23696 with ordinary wide wide strings.
23697
23698 @node Ada Text_IO C_Streams a-tiocst ads,Ada Text_IO Reset_Standard_Files a-tirsfi ads,Ada Strings Wide_Wide_Unbounded Wide_Wide_Text_IO a-szuzti ads,The GNAT Library
23699 @anchor{gnat_rm/the_gnat_library ada-text-io-c-streams-a-tiocst-ads}@anchor{30c}@anchor{gnat_rm/the_gnat_library id30}@anchor{30d}
23700 @section @code{Ada.Text_IO.C_Streams} (@code{a-tiocst.ads})
23701
23702
23703 @geindex Ada.Text_IO.C_Streams (a-tiocst.ads)
23704
23705 @geindex C Streams
23706 @geindex Interfacing with `@w{`}Text_IO`@w{`}
23707
23708 This package provides subprograms that allow interfacing between
23709 C streams and @code{Text_IO}. The stream identifier can be
23710 extracted from a file opened on the Ada side, and an Ada file
23711 can be constructed from a stream opened on the C side.
23712
23713 @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
23714 @anchor{gnat_rm/the_gnat_library ada-text-io-reset-standard-files-a-tirsfi-ads}@anchor{30e}@anchor{gnat_rm/the_gnat_library id31}@anchor{30f}
23715 @section @code{Ada.Text_IO.Reset_Standard_Files} (@code{a-tirsfi.ads})
23716
23717
23718 @geindex Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
23719
23720 @geindex Text_IO resetting standard files
23721
23722 This procedure is used to reset the status of the standard files used
23723 by Ada.Text_IO. This is useful in a situation (such as a restart in an
23724 embedded application) where the status of the files may change during
23725 execution (for example a standard input file may be redefined to be
23726 interactive).
23727
23728 @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
23729 @anchor{gnat_rm/the_gnat_library id32}@anchor{310}@anchor{gnat_rm/the_gnat_library ada-wide-characters-unicode-a-wichun-ads}@anchor{311}
23730 @section @code{Ada.Wide_Characters.Unicode} (@code{a-wichun.ads})
23731
23732
23733 @geindex Ada.Wide_Characters.Unicode (a-wichun.ads)
23734
23735 @geindex Unicode categorization
23736 @geindex Wide_Character
23737
23738 This package provides subprograms that allow categorization of
23739 Wide_Character values according to Unicode categories.
23740
23741 @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
23742 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-c-streams-a-wtcstr-ads}@anchor{312}@anchor{gnat_rm/the_gnat_library id33}@anchor{313}
23743 @section @code{Ada.Wide_Text_IO.C_Streams} (@code{a-wtcstr.ads})
23744
23745
23746 @geindex Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
23747
23748 @geindex C Streams
23749 @geindex Interfacing with `@w{`}Wide_Text_IO`@w{`}
23750
23751 This package provides subprograms that allow interfacing between
23752 C streams and @code{Wide_Text_IO}. The stream identifier can be
23753 extracted from a file opened on the Ada side, and an Ada file
23754 can be constructed from a stream opened on the C side.
23755
23756 @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
23757 @anchor{gnat_rm/the_gnat_library ada-wide-text-io-reset-standard-files-a-wrstfi-ads}@anchor{314}@anchor{gnat_rm/the_gnat_library id34}@anchor{315}
23758 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@code{a-wrstfi.ads})
23759
23760
23761 @geindex Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
23762
23763 @geindex Wide_Text_IO resetting standard files
23764
23765 This procedure is used to reset the status of the standard files used
23766 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
23767 embedded application) where the status of the files may change during
23768 execution (for example a standard input file may be redefined to be
23769 interactive).
23770
23771 @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
23772 @anchor{gnat_rm/the_gnat_library id35}@anchor{316}@anchor{gnat_rm/the_gnat_library ada-wide-wide-characters-unicode-a-zchuni-ads}@anchor{317}
23773 @section @code{Ada.Wide_Wide_Characters.Unicode} (@code{a-zchuni.ads})
23774
23775
23776 @geindex Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
23777
23778 @geindex Unicode categorization
23779 @geindex Wide_Wide_Character
23780
23781 This package provides subprograms that allow categorization of
23782 Wide_Wide_Character values according to Unicode categories.
23783
23784 @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
23785 @anchor{gnat_rm/the_gnat_library id36}@anchor{318}@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-c-streams-a-ztcstr-ads}@anchor{319}
23786 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@code{a-ztcstr.ads})
23787
23788
23789 @geindex Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
23790
23791 @geindex C Streams
23792 @geindex Interfacing with `@w{`}Wide_Wide_Text_IO`@w{`}
23793
23794 This package provides subprograms that allow interfacing between
23795 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
23796 extracted from a file opened on the Ada side, and an Ada file
23797 can be constructed from a stream opened on the C side.
23798
23799 @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
23800 @anchor{gnat_rm/the_gnat_library id37}@anchor{31a}@anchor{gnat_rm/the_gnat_library ada-wide-wide-text-io-reset-standard-files-a-zrstfi-ads}@anchor{31b}
23801 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@code{a-zrstfi.ads})
23802
23803
23804 @geindex Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
23805
23806 @geindex Wide_Wide_Text_IO resetting standard files
23807
23808 This procedure is used to reset the status of the standard files used
23809 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
23810 restart in an embedded application) where the status of the files may
23811 change during execution (for example a standard input file may be
23812 redefined to be interactive).
23813
23814 @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
23815 @anchor{gnat_rm/the_gnat_library gnat-altivec-g-altive-ads}@anchor{31c}@anchor{gnat_rm/the_gnat_library id38}@anchor{31d}
23816 @section @code{GNAT.Altivec} (@code{g-altive.ads})
23817
23818
23819 @geindex GNAT.Altivec (g-altive.ads)
23820
23821 @geindex AltiVec
23822
23823 This is the root package of the GNAT AltiVec binding. It provides
23824 definitions of constants and types common to all the versions of the
23825 binding.
23826
23827 @node GNAT Altivec Conversions g-altcon ads,GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec g-altive ads,The GNAT Library
23828 @anchor{gnat_rm/the_gnat_library gnat-altivec-conversions-g-altcon-ads}@anchor{31e}@anchor{gnat_rm/the_gnat_library id39}@anchor{31f}
23829 @section @code{GNAT.Altivec.Conversions} (@code{g-altcon.ads})
23830
23831
23832 @geindex GNAT.Altivec.Conversions (g-altcon.ads)
23833
23834 @geindex AltiVec
23835
23836 This package provides the Vector/View conversion routines.
23837
23838 @node GNAT Altivec Vector_Operations g-alveop ads,GNAT Altivec Vector_Types g-alvety ads,GNAT Altivec Conversions g-altcon ads,The GNAT Library
23839 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-operations-g-alveop-ads}@anchor{320}@anchor{gnat_rm/the_gnat_library id40}@anchor{321}
23840 @section @code{GNAT.Altivec.Vector_Operations} (@code{g-alveop.ads})
23841
23842
23843 @geindex GNAT.Altivec.Vector_Operations (g-alveop.ads)
23844
23845 @geindex AltiVec
23846
23847 This package exposes the Ada interface to the AltiVec operations on
23848 vector objects. A soft emulation is included by default in the GNAT
23849 library. The hard binding is provided as a separate package. This unit
23850 is common to both bindings.
23851
23852 @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
23853 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-types-g-alvety-ads}@anchor{322}@anchor{gnat_rm/the_gnat_library id41}@anchor{323}
23854 @section @code{GNAT.Altivec.Vector_Types} (@code{g-alvety.ads})
23855
23856
23857 @geindex GNAT.Altivec.Vector_Types (g-alvety.ads)
23858
23859 @geindex AltiVec
23860
23861 This package exposes the various vector types part of the Ada binding
23862 to AltiVec facilities.
23863
23864 @node GNAT Altivec Vector_Views g-alvevi ads,GNAT Array_Split g-arrspl ads,GNAT Altivec Vector_Types g-alvety ads,The GNAT Library
23865 @anchor{gnat_rm/the_gnat_library gnat-altivec-vector-views-g-alvevi-ads}@anchor{324}@anchor{gnat_rm/the_gnat_library id42}@anchor{325}
23866 @section @code{GNAT.Altivec.Vector_Views} (@code{g-alvevi.ads})
23867
23868
23869 @geindex GNAT.Altivec.Vector_Views (g-alvevi.ads)
23870
23871 @geindex AltiVec
23872
23873 This package provides public 'View' data types from/to which private
23874 vector representations can be converted via
23875 GNAT.Altivec.Conversions. This allows convenient access to individual
23876 vector elements and provides a simple way to initialize vector
23877 objects.
23878
23879 @node GNAT Array_Split g-arrspl ads,GNAT AWK g-awk ads,GNAT Altivec Vector_Views g-alvevi ads,The GNAT Library
23880 @anchor{gnat_rm/the_gnat_library gnat-array-split-g-arrspl-ads}@anchor{326}@anchor{gnat_rm/the_gnat_library id43}@anchor{327}
23881 @section @code{GNAT.Array_Split} (@code{g-arrspl.ads})
23882
23883
23884 @geindex GNAT.Array_Split (g-arrspl.ads)
23885
23886 @geindex Array splitter
23887
23888 Useful array-manipulation routines: given a set of separators, split
23889 an array wherever the separators appear, and provide direct access
23890 to the resulting slices.
23891
23892 @node GNAT AWK g-awk ads,GNAT Bind_Environment g-binenv ads,GNAT Array_Split g-arrspl ads,The GNAT Library
23893 @anchor{gnat_rm/the_gnat_library id44}@anchor{328}@anchor{gnat_rm/the_gnat_library gnat-awk-g-awk-ads}@anchor{329}
23894 @section @code{GNAT.AWK} (@code{g-awk.ads})
23895
23896
23897 @geindex GNAT.AWK (g-awk.ads)
23898
23899 @geindex Parsing
23900
23901 @geindex AWK
23902
23903 Provides AWK-like parsing functions, with an easy interface for parsing one
23904 or more files containing formatted data. The file is viewed as a database
23905 where each record is a line and a field is a data element in this line.
23906
23907 @node GNAT Bind_Environment g-binenv ads,GNAT Branch_Prediction g-brapre ads,GNAT AWK g-awk ads,The GNAT Library
23908 @anchor{gnat_rm/the_gnat_library gnat-bind-environment-g-binenv-ads}@anchor{32a}@anchor{gnat_rm/the_gnat_library id45}@anchor{32b}
23909 @section @code{GNAT.Bind_Environment} (@code{g-binenv.ads})
23910
23911
23912 @geindex GNAT.Bind_Environment (g-binenv.ads)
23913
23914 @geindex Bind environment
23915
23916 Provides access to key=value associations captured at bind time.
23917 These associations can be specified using the @code{-V} binder command
23918 line switch.
23919
23920 @node GNAT Branch_Prediction g-brapre ads,GNAT Bounded_Buffers g-boubuf ads,GNAT Bind_Environment g-binenv ads,The GNAT Library
23921 @anchor{gnat_rm/the_gnat_library id46}@anchor{32c}@anchor{gnat_rm/the_gnat_library gnat-branch-prediction-g-brapre-ads}@anchor{32d}
23922 @section @code{GNAT.Branch_Prediction} (@code{g-brapre.ads})
23923
23924
23925 @geindex GNAT.Branch_Prediction (g-brapre.ads)
23926
23927 @geindex Branch Prediction
23928
23929 Provides routines giving hints to the branch predictor of the code generator.
23930
23931 @node GNAT Bounded_Buffers g-boubuf ads,GNAT Bounded_Mailboxes g-boumai ads,GNAT Branch_Prediction g-brapre ads,The GNAT Library
23932 @anchor{gnat_rm/the_gnat_library id47}@anchor{32e}@anchor{gnat_rm/the_gnat_library gnat-bounded-buffers-g-boubuf-ads}@anchor{32f}
23933 @section @code{GNAT.Bounded_Buffers} (@code{g-boubuf.ads})
23934
23935
23936 @geindex GNAT.Bounded_Buffers (g-boubuf.ads)
23937
23938 @geindex Parsing
23939
23940 @geindex Bounded Buffers
23941
23942 Provides a concurrent generic bounded buffer abstraction. Instances are
23943 useful directly or as parts of the implementations of other abstractions,
23944 such as mailboxes.
23945
23946 @node GNAT Bounded_Mailboxes g-boumai ads,GNAT Bubble_Sort g-bubsor ads,GNAT Bounded_Buffers g-boubuf ads,The GNAT Library
23947 @anchor{gnat_rm/the_gnat_library gnat-bounded-mailboxes-g-boumai-ads}@anchor{330}@anchor{gnat_rm/the_gnat_library id48}@anchor{331}
23948 @section @code{GNAT.Bounded_Mailboxes} (@code{g-boumai.ads})
23949
23950
23951 @geindex GNAT.Bounded_Mailboxes (g-boumai.ads)
23952
23953 @geindex Parsing
23954
23955 @geindex Mailboxes
23956
23957 Provides a thread-safe asynchronous intertask mailbox communication facility.
23958
23959 @node GNAT Bubble_Sort g-bubsor ads,GNAT Bubble_Sort_A g-busora ads,GNAT Bounded_Mailboxes g-boumai ads,The GNAT Library
23960 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-bubsor-ads}@anchor{332}@anchor{gnat_rm/the_gnat_library id49}@anchor{333}
23961 @section @code{GNAT.Bubble_Sort} (@code{g-bubsor.ads})
23962
23963
23964 @geindex GNAT.Bubble_Sort (g-bubsor.ads)
23965
23966 @geindex Sorting
23967
23968 @geindex Bubble sort
23969
23970 Provides a general implementation of bubble sort usable for sorting arbitrary
23971 data items. Exchange and comparison procedures are provided by passing
23972 access-to-procedure values.
23973
23974 @node GNAT Bubble_Sort_A g-busora ads,GNAT Bubble_Sort_G g-busorg ads,GNAT Bubble_Sort g-bubsor ads,The GNAT Library
23975 @anchor{gnat_rm/the_gnat_library id50}@anchor{334}@anchor{gnat_rm/the_gnat_library gnat-bubble-sort-a-g-busora-ads}@anchor{335}
23976 @section @code{GNAT.Bubble_Sort_A} (@code{g-busora.ads})
23977
23978
23979 @geindex GNAT.Bubble_Sort_A (g-busora.ads)
23980
23981 @geindex Sorting
23982
23983 @geindex Bubble sort
23984
23985 Provides a general implementation of bubble sort usable for sorting arbitrary
23986 data items. Move and comparison procedures are provided by passing
23987 access-to-procedure values. This is an older version, retained for
23988 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
23989
23990 @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
23991 @anchor{gnat_rm/the_gnat_library gnat-bubble-sort-g-g-busorg-ads}@anchor{336}@anchor{gnat_rm/the_gnat_library id51}@anchor{337}
23992 @section @code{GNAT.Bubble_Sort_G} (@code{g-busorg.ads})
23993
23994
23995 @geindex GNAT.Bubble_Sort_G (g-busorg.ads)
23996
23997 @geindex Sorting
23998
23999 @geindex Bubble sort
24000
24001 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
24002 are provided as generic parameters, this improves efficiency, especially
24003 if the procedures can be inlined, at the expense of duplicating code for
24004 multiple instantiations.
24005
24006 @node GNAT Byte_Order_Mark g-byorma ads,GNAT Byte_Swapping g-bytswa ads,GNAT Bubble_Sort_G g-busorg ads,The GNAT Library
24007 @anchor{gnat_rm/the_gnat_library gnat-byte-order-mark-g-byorma-ads}@anchor{338}@anchor{gnat_rm/the_gnat_library id52}@anchor{339}
24008 @section @code{GNAT.Byte_Order_Mark} (@code{g-byorma.ads})
24009
24010
24011 @geindex GNAT.Byte_Order_Mark (g-byorma.ads)
24012
24013 @geindex UTF-8 representation
24014
24015 @geindex Wide characte representations
24016
24017 Provides a routine which given a string, reads the start of the string to
24018 see whether it is one of the standard byte order marks (BOM's) which signal
24019 the encoding of the string. The routine includes detection of special XML
24020 sequences for various UCS input formats.
24021
24022 @node GNAT Byte_Swapping g-bytswa ads,GNAT Calendar g-calend ads,GNAT Byte_Order_Mark g-byorma ads,The GNAT Library
24023 @anchor{gnat_rm/the_gnat_library gnat-byte-swapping-g-bytswa-ads}@anchor{33a}@anchor{gnat_rm/the_gnat_library id53}@anchor{33b}
24024 @section @code{GNAT.Byte_Swapping} (@code{g-bytswa.ads})
24025
24026
24027 @geindex GNAT.Byte_Swapping (g-bytswa.ads)
24028
24029 @geindex Byte swapping
24030
24031 @geindex Endianness
24032
24033 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
24034 Machine-specific implementations are available in some cases.
24035
24036 @node GNAT Calendar g-calend ads,GNAT Calendar Time_IO g-catiio ads,GNAT Byte_Swapping g-bytswa ads,The GNAT Library
24037 @anchor{gnat_rm/the_gnat_library id54}@anchor{33c}@anchor{gnat_rm/the_gnat_library gnat-calendar-g-calend-ads}@anchor{33d}
24038 @section @code{GNAT.Calendar} (@code{g-calend.ads})
24039
24040
24041 @geindex GNAT.Calendar (g-calend.ads)
24042
24043 @geindex Calendar
24044
24045 Extends the facilities provided by @code{Ada.Calendar} to include handling
24046 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
24047 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
24048 C @code{timeval} format.
24049
24050 @node GNAT Calendar Time_IO g-catiio ads,GNAT CRC32 g-crc32 ads,GNAT Calendar g-calend ads,The GNAT Library
24051 @anchor{gnat_rm/the_gnat_library id55}@anchor{33e}@anchor{gnat_rm/the_gnat_library gnat-calendar-time-io-g-catiio-ads}@anchor{33f}
24052 @section @code{GNAT.Calendar.Time_IO} (@code{g-catiio.ads})
24053
24054
24055 @geindex Calendar
24056
24057 @geindex Time
24058
24059 @geindex GNAT.Calendar.Time_IO (g-catiio.ads)
24060
24061 @node GNAT CRC32 g-crc32 ads,GNAT Case_Util g-casuti ads,GNAT Calendar Time_IO g-catiio ads,The GNAT Library
24062 @anchor{gnat_rm/the_gnat_library id56}@anchor{340}@anchor{gnat_rm/the_gnat_library gnat-crc32-g-crc32-ads}@anchor{341}
24063 @section @code{GNAT.CRC32} (@code{g-crc32.ads})
24064
24065
24066 @geindex GNAT.CRC32 (g-crc32.ads)
24067
24068 @geindex CRC32
24069
24070 @geindex Cyclic Redundancy Check
24071
24072 This package implements the CRC-32 algorithm. For a full description
24073 of this algorithm see
24074 @emph{Computation of Cyclic Redundancy Checks via Table Look-Up},
24075 @cite{Communications of the ACM}, Vol. 31 No. 8, pp. 1008-1013,
24076 Aug. 1988. Sarwate, D.V.
24077
24078 @node GNAT Case_Util g-casuti ads,GNAT CGI g-cgi ads,GNAT CRC32 g-crc32 ads,The GNAT Library
24079 @anchor{gnat_rm/the_gnat_library id57}@anchor{342}@anchor{gnat_rm/the_gnat_library gnat-case-util-g-casuti-ads}@anchor{343}
24080 @section @code{GNAT.Case_Util} (@code{g-casuti.ads})
24081
24082
24083 @geindex GNAT.Case_Util (g-casuti.ads)
24084
24085 @geindex Casing utilities
24086
24087 @geindex Character handling (`@w{`}GNAT.Case_Util`@w{`})
24088
24089 A set of simple routines for handling upper and lower casing of strings
24090 without the overhead of the full casing tables
24091 in @code{Ada.Characters.Handling}.
24092
24093 @node GNAT CGI g-cgi ads,GNAT CGI Cookie g-cgicoo ads,GNAT Case_Util g-casuti ads,The GNAT Library
24094 @anchor{gnat_rm/the_gnat_library id58}@anchor{344}@anchor{gnat_rm/the_gnat_library gnat-cgi-g-cgi-ads}@anchor{345}
24095 @section @code{GNAT.CGI} (@code{g-cgi.ads})
24096
24097
24098 @geindex GNAT.CGI (g-cgi.ads)
24099
24100 @geindex CGI (Common Gateway Interface)
24101
24102 This is a package for interfacing a GNAT program with a Web server via the
24103 Common Gateway Interface (CGI). Basically this package parses the CGI
24104 parameters, which are a set of key/value pairs sent by the Web server. It
24105 builds a table whose index is the key and provides some services to deal
24106 with this table.
24107
24108 @node GNAT CGI Cookie g-cgicoo ads,GNAT CGI Debug g-cgideb ads,GNAT CGI g-cgi ads,The GNAT Library
24109 @anchor{gnat_rm/the_gnat_library gnat-cgi-cookie-g-cgicoo-ads}@anchor{346}@anchor{gnat_rm/the_gnat_library id59}@anchor{347}
24110 @section @code{GNAT.CGI.Cookie} (@code{g-cgicoo.ads})
24111
24112
24113 @geindex GNAT.CGI.Cookie (g-cgicoo.ads)
24114
24115 @geindex CGI (Common Gateway Interface) cookie support
24116
24117 @geindex Cookie support in CGI
24118
24119 This is a package to interface a GNAT program with a Web server via the
24120 Common Gateway Interface (CGI). It exports services to deal with Web
24121 cookies (piece of information kept in the Web client software).
24122
24123 @node GNAT CGI Debug g-cgideb ads,GNAT Command_Line g-comlin ads,GNAT CGI Cookie g-cgicoo ads,The GNAT Library
24124 @anchor{gnat_rm/the_gnat_library gnat-cgi-debug-g-cgideb-ads}@anchor{348}@anchor{gnat_rm/the_gnat_library id60}@anchor{349}
24125 @section @code{GNAT.CGI.Debug} (@code{g-cgideb.ads})
24126
24127
24128 @geindex GNAT.CGI.Debug (g-cgideb.ads)
24129
24130 @geindex CGI (Common Gateway Interface) debugging
24131
24132 This is a package to help debugging CGI (Common Gateway Interface)
24133 programs written in Ada.
24134
24135 @node GNAT Command_Line g-comlin ads,GNAT Compiler_Version g-comver ads,GNAT CGI Debug g-cgideb ads,The GNAT Library
24136 @anchor{gnat_rm/the_gnat_library id61}@anchor{34a}@anchor{gnat_rm/the_gnat_library gnat-command-line-g-comlin-ads}@anchor{34b}
24137 @section @code{GNAT.Command_Line} (@code{g-comlin.ads})
24138
24139
24140 @geindex GNAT.Command_Line (g-comlin.ads)
24141
24142 @geindex Command line
24143
24144 Provides a high level interface to @code{Ada.Command_Line} facilities,
24145 including the ability to scan for named switches with optional parameters
24146 and expand file names using wildcard notations.
24147
24148 @node GNAT Compiler_Version g-comver ads,GNAT Ctrl_C g-ctrl_c ads,GNAT Command_Line g-comlin ads,The GNAT Library
24149 @anchor{gnat_rm/the_gnat_library gnat-compiler-version-g-comver-ads}@anchor{34c}@anchor{gnat_rm/the_gnat_library id62}@anchor{34d}
24150 @section @code{GNAT.Compiler_Version} (@code{g-comver.ads})
24151
24152
24153 @geindex GNAT.Compiler_Version (g-comver.ads)
24154
24155 @geindex Compiler Version
24156
24157 @geindex Version
24158 @geindex of compiler
24159
24160 Provides a routine for obtaining the version of the compiler used to
24161 compile the program. More accurately this is the version of the binder
24162 used to bind the program (this will normally be the same as the version
24163 of the compiler if a consistent tool set is used to compile all units
24164 of a partition).
24165
24166 @node GNAT Ctrl_C g-ctrl_c ads,GNAT Current_Exception g-curexc ads,GNAT Compiler_Version g-comver ads,The GNAT Library
24167 @anchor{gnat_rm/the_gnat_library gnat-ctrl-c-g-ctrl-c-ads}@anchor{34e}@anchor{gnat_rm/the_gnat_library id63}@anchor{34f}
24168 @section @code{GNAT.Ctrl_C} (@code{g-ctrl_c.ads})
24169
24170
24171 @geindex GNAT.Ctrl_C (g-ctrl_c.ads)
24172
24173 @geindex Interrupt
24174
24175 Provides a simple interface to handle Ctrl-C keyboard events.
24176
24177 @node GNAT Current_Exception g-curexc ads,GNAT Debug_Pools g-debpoo ads,GNAT Ctrl_C g-ctrl_c ads,The GNAT Library
24178 @anchor{gnat_rm/the_gnat_library id64}@anchor{350}@anchor{gnat_rm/the_gnat_library gnat-current-exception-g-curexc-ads}@anchor{351}
24179 @section @code{GNAT.Current_Exception} (@code{g-curexc.ads})
24180
24181
24182 @geindex GNAT.Current_Exception (g-curexc.ads)
24183
24184 @geindex Current exception
24185
24186 @geindex Exception retrieval
24187
24188 Provides access to information on the current exception that has been raised
24189 without the need for using the Ada 95 / Ada 2005 exception choice parameter
24190 specification syntax.
24191 This is particularly useful in simulating typical facilities for
24192 obtaining information about exceptions provided by Ada 83 compilers.
24193
24194 @node GNAT Debug_Pools g-debpoo ads,GNAT Debug_Utilities g-debuti ads,GNAT Current_Exception g-curexc ads,The GNAT Library
24195 @anchor{gnat_rm/the_gnat_library gnat-debug-pools-g-debpoo-ads}@anchor{352}@anchor{gnat_rm/the_gnat_library id65}@anchor{353}
24196 @section @code{GNAT.Debug_Pools} (@code{g-debpoo.ads})
24197
24198
24199 @geindex GNAT.Debug_Pools (g-debpoo.ads)
24200
24201 @geindex Debugging
24202
24203 @geindex Debug pools
24204
24205 @geindex Memory corruption debugging
24206
24207 Provide a debugging storage pools that helps tracking memory corruption
24208 problems.
24209 See @code{The GNAT Debug_Pool Facility} section in the @cite{GNAT User's Guide}.
24210
24211 @node GNAT Debug_Utilities g-debuti ads,GNAT Decode_String g-decstr ads,GNAT Debug_Pools g-debpoo ads,The GNAT Library
24212 @anchor{gnat_rm/the_gnat_library gnat-debug-utilities-g-debuti-ads}@anchor{354}@anchor{gnat_rm/the_gnat_library id66}@anchor{355}
24213 @section @code{GNAT.Debug_Utilities} (@code{g-debuti.ads})
24214
24215
24216 @geindex GNAT.Debug_Utilities (g-debuti.ads)
24217
24218 @geindex Debugging
24219
24220 Provides a few useful utilities for debugging purposes, including conversion
24221 to and from string images of address values. Supports both C and Ada formats
24222 for hexadecimal literals.
24223
24224 @node GNAT Decode_String g-decstr ads,GNAT Decode_UTF8_String g-deutst ads,GNAT Debug_Utilities g-debuti ads,The GNAT Library
24225 @anchor{gnat_rm/the_gnat_library id67}@anchor{356}@anchor{gnat_rm/the_gnat_library gnat-decode-string-g-decstr-ads}@anchor{357}
24226 @section @code{GNAT.Decode_String} (@code{g-decstr.ads})
24227
24228
24229 @geindex GNAT.Decode_String (g-decstr.ads)
24230
24231 @geindex Decoding strings
24232
24233 @geindex String decoding
24234
24235 @geindex Wide character encoding
24236
24237 @geindex UTF-8
24238
24239 @geindex Unicode
24240
24241 A generic package providing routines for decoding wide character and wide wide
24242 character strings encoded as sequences of 8-bit characters using a specified
24243 encoding method. Includes validation routines, and also routines for stepping
24244 to next or previous encoded character in an encoded string.
24245 Useful in conjunction with Unicode character coding. Note there is a
24246 preinstantiation for UTF-8. See next entry.
24247
24248 @node GNAT Decode_UTF8_String g-deutst ads,GNAT Directory_Operations g-dirope ads,GNAT Decode_String g-decstr ads,The GNAT Library
24249 @anchor{gnat_rm/the_gnat_library gnat-decode-utf8-string-g-deutst-ads}@anchor{358}@anchor{gnat_rm/the_gnat_library id68}@anchor{359}
24250 @section @code{GNAT.Decode_UTF8_String} (@code{g-deutst.ads})
24251
24252
24253 @geindex GNAT.Decode_UTF8_String (g-deutst.ads)
24254
24255 @geindex Decoding strings
24256
24257 @geindex Decoding UTF-8 strings
24258
24259 @geindex UTF-8 string decoding
24260
24261 @geindex Wide character decoding
24262
24263 @geindex UTF-8
24264
24265 @geindex Unicode
24266
24267 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
24268
24269 @node GNAT Directory_Operations g-dirope ads,GNAT Directory_Operations Iteration g-diopit ads,GNAT Decode_UTF8_String g-deutst ads,The GNAT Library
24270 @anchor{gnat_rm/the_gnat_library id69}@anchor{35a}@anchor{gnat_rm/the_gnat_library gnat-directory-operations-g-dirope-ads}@anchor{35b}
24271 @section @code{GNAT.Directory_Operations} (@code{g-dirope.ads})
24272
24273
24274 @geindex GNAT.Directory_Operations (g-dirope.ads)
24275
24276 @geindex Directory operations
24277
24278 Provides a set of routines for manipulating directories, including changing
24279 the current directory, making new directories, and scanning the files in a
24280 directory.
24281
24282 @node GNAT Directory_Operations Iteration g-diopit ads,GNAT Dynamic_HTables g-dynhta ads,GNAT Directory_Operations g-dirope ads,The GNAT Library
24283 @anchor{gnat_rm/the_gnat_library id70}@anchor{35c}@anchor{gnat_rm/the_gnat_library gnat-directory-operations-iteration-g-diopit-ads}@anchor{35d}
24284 @section @code{GNAT.Directory_Operations.Iteration} (@code{g-diopit.ads})
24285
24286
24287 @geindex GNAT.Directory_Operations.Iteration (g-diopit.ads)
24288
24289 @geindex Directory operations iteration
24290
24291 A child unit of GNAT.Directory_Operations providing additional operations
24292 for iterating through directories.
24293
24294 @node GNAT Dynamic_HTables g-dynhta ads,GNAT Dynamic_Tables g-dyntab ads,GNAT Directory_Operations Iteration g-diopit ads,The GNAT Library
24295 @anchor{gnat_rm/the_gnat_library id71}@anchor{35e}@anchor{gnat_rm/the_gnat_library gnat-dynamic-htables-g-dynhta-ads}@anchor{35f}
24296 @section @code{GNAT.Dynamic_HTables} (@code{g-dynhta.ads})
24297
24298
24299 @geindex GNAT.Dynamic_HTables (g-dynhta.ads)
24300
24301 @geindex Hash tables
24302
24303 A generic implementation of hash tables that can be used to hash arbitrary
24304 data. Provided in two forms, a simple form with built in hash functions,
24305 and a more complex form in which the hash function is supplied.
24306
24307 This package provides a facility similar to that of @code{GNAT.HTable},
24308 except that this package declares a type that can be used to define
24309 dynamic instances of the hash table, while an instantiation of
24310 @code{GNAT.HTable} creates a single instance of the hash table.
24311
24312 @node GNAT Dynamic_Tables g-dyntab ads,GNAT Encode_String g-encstr ads,GNAT Dynamic_HTables g-dynhta ads,The GNAT Library
24313 @anchor{gnat_rm/the_gnat_library gnat-dynamic-tables-g-dyntab-ads}@anchor{360}@anchor{gnat_rm/the_gnat_library id72}@anchor{361}
24314 @section @code{GNAT.Dynamic_Tables} (@code{g-dyntab.ads})
24315
24316
24317 @geindex GNAT.Dynamic_Tables (g-dyntab.ads)
24318
24319 @geindex Table implementation
24320
24321 @geindex Arrays
24322 @geindex extendable
24323
24324 A generic package providing a single dimension array abstraction where the
24325 length of the array can be dynamically modified.
24326
24327 This package provides a facility similar to that of @code{GNAT.Table},
24328 except that this package declares a type that can be used to define
24329 dynamic instances of the table, while an instantiation of
24330 @code{GNAT.Table} creates a single instance of the table type.
24331
24332 @node GNAT Encode_String g-encstr ads,GNAT Encode_UTF8_String g-enutst ads,GNAT Dynamic_Tables g-dyntab ads,The GNAT Library
24333 @anchor{gnat_rm/the_gnat_library id73}@anchor{362}@anchor{gnat_rm/the_gnat_library gnat-encode-string-g-encstr-ads}@anchor{363}
24334 @section @code{GNAT.Encode_String} (@code{g-encstr.ads})
24335
24336
24337 @geindex GNAT.Encode_String (g-encstr.ads)
24338
24339 @geindex Encoding strings
24340
24341 @geindex String encoding
24342
24343 @geindex Wide character encoding
24344
24345 @geindex UTF-8
24346
24347 @geindex Unicode
24348
24349 A generic package providing routines for encoding wide character and wide
24350 wide character strings as sequences of 8-bit characters using a specified
24351 encoding method. Useful in conjunction with Unicode character coding.
24352 Note there is a preinstantiation for UTF-8. See next entry.
24353
24354 @node GNAT Encode_UTF8_String g-enutst ads,GNAT Exception_Actions g-excact ads,GNAT Encode_String g-encstr ads,The GNAT Library
24355 @anchor{gnat_rm/the_gnat_library gnat-encode-utf8-string-g-enutst-ads}@anchor{364}@anchor{gnat_rm/the_gnat_library id74}@anchor{365}
24356 @section @code{GNAT.Encode_UTF8_String} (@code{g-enutst.ads})
24357
24358
24359 @geindex GNAT.Encode_UTF8_String (g-enutst.ads)
24360
24361 @geindex Encoding strings
24362
24363 @geindex Encoding UTF-8 strings
24364
24365 @geindex UTF-8 string encoding
24366
24367 @geindex Wide character encoding
24368
24369 @geindex UTF-8
24370
24371 @geindex Unicode
24372
24373 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
24374
24375 @node GNAT Exception_Actions g-excact ads,GNAT Exception_Traces g-exctra ads,GNAT Encode_UTF8_String g-enutst ads,The GNAT Library
24376 @anchor{gnat_rm/the_gnat_library gnat-exception-actions-g-excact-ads}@anchor{366}@anchor{gnat_rm/the_gnat_library id75}@anchor{367}
24377 @section @code{GNAT.Exception_Actions} (@code{g-excact.ads})
24378
24379
24380 @geindex GNAT.Exception_Actions (g-excact.ads)
24381
24382 @geindex Exception actions
24383
24384 Provides callbacks when an exception is raised. Callbacks can be registered
24385 for specific exceptions, or when any exception is raised. This
24386 can be used for instance to force a core dump to ease debugging.
24387
24388 @node GNAT Exception_Traces g-exctra ads,GNAT Exceptions g-except ads,GNAT Exception_Actions g-excact ads,The GNAT Library
24389 @anchor{gnat_rm/the_gnat_library gnat-exception-traces-g-exctra-ads}@anchor{368}@anchor{gnat_rm/the_gnat_library id76}@anchor{369}
24390 @section @code{GNAT.Exception_Traces} (@code{g-exctra.ads})
24391
24392
24393 @geindex GNAT.Exception_Traces (g-exctra.ads)
24394
24395 @geindex Exception traces
24396
24397 @geindex Debugging
24398
24399 Provides an interface allowing to control automatic output upon exception
24400 occurrences.
24401
24402 @node GNAT Exceptions g-except ads,GNAT Expect g-expect ads,GNAT Exception_Traces g-exctra ads,The GNAT Library
24403 @anchor{gnat_rm/the_gnat_library id77}@anchor{36a}@anchor{gnat_rm/the_gnat_library gnat-exceptions-g-except-ads}@anchor{36b}
24404 @section @code{GNAT.Exceptions} (@code{g-except.ads})
24405
24406
24407 @geindex GNAT.Exceptions (g-except.ads)
24408
24409 @geindex Exceptions
24410 @geindex Pure
24411
24412 @geindex Pure packages
24413 @geindex exceptions
24414
24415 Normally it is not possible to raise an exception with
24416 a message from a subprogram in a pure package, since the
24417 necessary types and subprograms are in @code{Ada.Exceptions}
24418 which is not a pure unit. @code{GNAT.Exceptions} provides a
24419 facility for getting around this limitation for a few
24420 predefined exceptions, and for example allow raising
24421 @code{Constraint_Error} with a message from a pure subprogram.
24422
24423 @node GNAT Expect g-expect ads,GNAT Expect TTY g-exptty ads,GNAT Exceptions g-except ads,The GNAT Library
24424 @anchor{gnat_rm/the_gnat_library id78}@anchor{36c}@anchor{gnat_rm/the_gnat_library gnat-expect-g-expect-ads}@anchor{36d}
24425 @section @code{GNAT.Expect} (@code{g-expect.ads})
24426
24427
24428 @geindex GNAT.Expect (g-expect.ads)
24429
24430 Provides a set of subprograms similar to what is available
24431 with the standard Tcl Expect tool.
24432 It allows you to easily spawn and communicate with an external process.
24433 You can send commands or inputs to the process, and compare the output
24434 with some expected regular expression. Currently @code{GNAT.Expect}
24435 is implemented on all native GNAT ports.
24436 It is not implemented for cross ports, and in particular is not
24437 implemented for VxWorks or LynxOS.
24438
24439 @node GNAT Expect TTY g-exptty ads,GNAT Float_Control g-flocon ads,GNAT Expect g-expect ads,The GNAT Library
24440 @anchor{gnat_rm/the_gnat_library id79}@anchor{36e}@anchor{gnat_rm/the_gnat_library gnat-expect-tty-g-exptty-ads}@anchor{36f}
24441 @section @code{GNAT.Expect.TTY} (@code{g-exptty.ads})
24442
24443
24444 @geindex GNAT.Expect.TTY (g-exptty.ads)
24445
24446 As GNAT.Expect but using pseudo-terminal.
24447 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
24448 ports. It is not implemented for cross ports, and
24449 in particular is not implemented for VxWorks or LynxOS.
24450
24451 @node GNAT Float_Control g-flocon ads,GNAT Formatted_String g-forstr ads,GNAT Expect TTY g-exptty ads,The GNAT Library
24452 @anchor{gnat_rm/the_gnat_library id80}@anchor{370}@anchor{gnat_rm/the_gnat_library gnat-float-control-g-flocon-ads}@anchor{371}
24453 @section @code{GNAT.Float_Control} (@code{g-flocon.ads})
24454
24455
24456 @geindex GNAT.Float_Control (g-flocon.ads)
24457
24458 @geindex Floating-Point Processor
24459
24460 Provides an interface for resetting the floating-point processor into the
24461 mode required for correct semantic operation in Ada. Some third party
24462 library calls may cause this mode to be modified, and the Reset procedure
24463 in this package can be used to reestablish the required mode.
24464
24465 @node GNAT Formatted_String g-forstr ads,GNAT Heap_Sort g-heasor ads,GNAT Float_Control g-flocon ads,The GNAT Library
24466 @anchor{gnat_rm/the_gnat_library id81}@anchor{372}@anchor{gnat_rm/the_gnat_library gnat-formatted-string-g-forstr-ads}@anchor{373}
24467 @section @code{GNAT.Formatted_String} (@code{g-forstr.ads})
24468
24469
24470 @geindex GNAT.Formatted_String (g-forstr.ads)
24471
24472 @geindex Formatted String
24473
24474 Provides support for C/C++ printf() formatted strings. The format is
24475 copied from the printf() routine and should therefore gives identical
24476 output. Some generic routines are provided to be able to use types
24477 derived from Integer, Float or enumerations as values for the
24478 formatted string.
24479
24480 @node GNAT Heap_Sort g-heasor ads,GNAT Heap_Sort_A g-hesora ads,GNAT Formatted_String g-forstr ads,The GNAT Library
24481 @anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-heasor-ads}@anchor{374}@anchor{gnat_rm/the_gnat_library id82}@anchor{375}
24482 @section @code{GNAT.Heap_Sort} (@code{g-heasor.ads})
24483
24484
24485 @geindex GNAT.Heap_Sort (g-heasor.ads)
24486
24487 @geindex Sorting
24488
24489 Provides a general implementation of heap sort usable for sorting arbitrary
24490 data items. Exchange and comparison procedures are provided by passing
24491 access-to-procedure values. The algorithm used is a modified heap sort
24492 that performs approximately N*log(N) comparisons in the worst case.
24493
24494 @node GNAT Heap_Sort_A g-hesora ads,GNAT Heap_Sort_G g-hesorg ads,GNAT Heap_Sort g-heasor ads,The GNAT Library
24495 @anchor{gnat_rm/the_gnat_library id83}@anchor{376}@anchor{gnat_rm/the_gnat_library gnat-heap-sort-a-g-hesora-ads}@anchor{377}
24496 @section @code{GNAT.Heap_Sort_A} (@code{g-hesora.ads})
24497
24498
24499 @geindex GNAT.Heap_Sort_A (g-hesora.ads)
24500
24501 @geindex Sorting
24502
24503 Provides a general implementation of heap sort usable for sorting arbitrary
24504 data items. Move and comparison procedures are provided by passing
24505 access-to-procedure values. The algorithm used is a modified heap sort
24506 that performs approximately N*log(N) comparisons in the worst case.
24507 This differs from @code{GNAT.Heap_Sort} in having a less convenient
24508 interface, but may be slightly more efficient.
24509
24510 @node GNAT Heap_Sort_G g-hesorg ads,GNAT HTable g-htable ads,GNAT Heap_Sort_A g-hesora ads,The GNAT Library
24511 @anchor{gnat_rm/the_gnat_library id84}@anchor{378}@anchor{gnat_rm/the_gnat_library gnat-heap-sort-g-g-hesorg-ads}@anchor{379}
24512 @section @code{GNAT.Heap_Sort_G} (@code{g-hesorg.ads})
24513
24514
24515 @geindex GNAT.Heap_Sort_G (g-hesorg.ads)
24516
24517 @geindex Sorting
24518
24519 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
24520 are provided as generic parameters, this improves efficiency, especially
24521 if the procedures can be inlined, at the expense of duplicating code for
24522 multiple instantiations.
24523
24524 @node GNAT HTable g-htable ads,GNAT IO g-io ads,GNAT Heap_Sort_G g-hesorg ads,The GNAT Library
24525 @anchor{gnat_rm/the_gnat_library id85}@anchor{37a}@anchor{gnat_rm/the_gnat_library gnat-htable-g-htable-ads}@anchor{37b}
24526 @section @code{GNAT.HTable} (@code{g-htable.ads})
24527
24528
24529 @geindex GNAT.HTable (g-htable.ads)
24530
24531 @geindex Hash tables
24532
24533 A generic implementation of hash tables that can be used to hash arbitrary
24534 data. Provides two approaches, one a simple static approach, and the other
24535 allowing arbitrary dynamic hash tables.
24536
24537 @node GNAT IO g-io ads,GNAT IO_Aux g-io_aux ads,GNAT HTable g-htable ads,The GNAT Library
24538 @anchor{gnat_rm/the_gnat_library id86}@anchor{37c}@anchor{gnat_rm/the_gnat_library gnat-io-g-io-ads}@anchor{37d}
24539 @section @code{GNAT.IO} (@code{g-io.ads})
24540
24541
24542 @geindex GNAT.IO (g-io.ads)
24543
24544 @geindex Simple I/O
24545
24546 @geindex Input/Output facilities
24547
24548 A simple preelaborable input-output package that provides a subset of
24549 simple Text_IO functions for reading characters and strings from
24550 Standard_Input, and writing characters, strings and integers to either
24551 Standard_Output or Standard_Error.
24552
24553 @node GNAT IO_Aux g-io_aux ads,GNAT Lock_Files g-locfil ads,GNAT IO g-io ads,The GNAT Library
24554 @anchor{gnat_rm/the_gnat_library id87}@anchor{37e}@anchor{gnat_rm/the_gnat_library gnat-io-aux-g-io-aux-ads}@anchor{37f}
24555 @section @code{GNAT.IO_Aux} (@code{g-io_aux.ads})
24556
24557
24558 @geindex GNAT.IO_Aux (g-io_aux.ads)
24559
24560 @geindex Text_IO
24561
24562 @geindex Input/Output facilities
24563
24564 Provides some auxiliary functions for use with Text_IO, including a test
24565 for whether a file exists, and functions for reading a line of text.
24566
24567 @node GNAT Lock_Files g-locfil ads,GNAT MBBS_Discrete_Random g-mbdira ads,GNAT IO_Aux g-io_aux ads,The GNAT Library
24568 @anchor{gnat_rm/the_gnat_library id88}@anchor{380}@anchor{gnat_rm/the_gnat_library gnat-lock-files-g-locfil-ads}@anchor{381}
24569 @section @code{GNAT.Lock_Files} (@code{g-locfil.ads})
24570
24571
24572 @geindex GNAT.Lock_Files (g-locfil.ads)
24573
24574 @geindex File locking
24575
24576 @geindex Locking using files
24577
24578 Provides a general interface for using files as locks. Can be used for
24579 providing program level synchronization.
24580
24581 @node GNAT MBBS_Discrete_Random g-mbdira ads,GNAT MBBS_Float_Random g-mbflra ads,GNAT Lock_Files g-locfil ads,The GNAT Library
24582 @anchor{gnat_rm/the_gnat_library id89}@anchor{382}@anchor{gnat_rm/the_gnat_library gnat-mbbs-discrete-random-g-mbdira-ads}@anchor{383}
24583 @section @code{GNAT.MBBS_Discrete_Random} (@code{g-mbdira.ads})
24584
24585
24586 @geindex GNAT.MBBS_Discrete_Random (g-mbdira.ads)
24587
24588 @geindex Random number generation
24589
24590 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
24591 a modified version of the Blum-Blum-Shub generator.
24592
24593 @node GNAT MBBS_Float_Random g-mbflra ads,GNAT MD5 g-md5 ads,GNAT MBBS_Discrete_Random g-mbdira ads,The GNAT Library
24594 @anchor{gnat_rm/the_gnat_library id90}@anchor{384}@anchor{gnat_rm/the_gnat_library gnat-mbbs-float-random-g-mbflra-ads}@anchor{385}
24595 @section @code{GNAT.MBBS_Float_Random} (@code{g-mbflra.ads})
24596
24597
24598 @geindex GNAT.MBBS_Float_Random (g-mbflra.ads)
24599
24600 @geindex Random number generation
24601
24602 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
24603 a modified version of the Blum-Blum-Shub generator.
24604
24605 @node GNAT MD5 g-md5 ads,GNAT Memory_Dump g-memdum ads,GNAT MBBS_Float_Random g-mbflra ads,The GNAT Library
24606 @anchor{gnat_rm/the_gnat_library id91}@anchor{386}@anchor{gnat_rm/the_gnat_library gnat-md5-g-md5-ads}@anchor{387}
24607 @section @code{GNAT.MD5} (@code{g-md5.ads})
24608
24609
24610 @geindex GNAT.MD5 (g-md5.ads)
24611
24612 @geindex Message Digest MD5
24613
24614 Implements the MD5 Message-Digest Algorithm as described in RFC 1321, and
24615 the HMAC-MD5 message authentication function as described in RFC 2104 and
24616 FIPS PUB 198.
24617
24618 @node GNAT Memory_Dump g-memdum ads,GNAT Most_Recent_Exception g-moreex ads,GNAT MD5 g-md5 ads,The GNAT Library
24619 @anchor{gnat_rm/the_gnat_library id92}@anchor{388}@anchor{gnat_rm/the_gnat_library gnat-memory-dump-g-memdum-ads}@anchor{389}
24620 @section @code{GNAT.Memory_Dump} (@code{g-memdum.ads})
24621
24622
24623 @geindex GNAT.Memory_Dump (g-memdum.ads)
24624
24625 @geindex Dump Memory
24626
24627 Provides a convenient routine for dumping raw memory to either the
24628 standard output or standard error files. Uses GNAT.IO for actual
24629 output.
24630
24631 @node GNAT Most_Recent_Exception g-moreex ads,GNAT OS_Lib g-os_lib ads,GNAT Memory_Dump g-memdum ads,The GNAT Library
24632 @anchor{gnat_rm/the_gnat_library gnat-most-recent-exception-g-moreex-ads}@anchor{38a}@anchor{gnat_rm/the_gnat_library id93}@anchor{38b}
24633 @section @code{GNAT.Most_Recent_Exception} (@code{g-moreex.ads})
24634
24635
24636 @geindex GNAT.Most_Recent_Exception (g-moreex.ads)
24637
24638 @geindex Exception
24639 @geindex obtaining most recent
24640
24641 Provides access to the most recently raised exception. Can be used for
24642 various logging purposes, including duplicating functionality of some
24643 Ada 83 implementation dependent extensions.
24644
24645 @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
24646 @anchor{gnat_rm/the_gnat_library gnat-os-lib-g-os-lib-ads}@anchor{38c}@anchor{gnat_rm/the_gnat_library id94}@anchor{38d}
24647 @section @code{GNAT.OS_Lib} (@code{g-os_lib.ads})
24648
24649
24650 @geindex GNAT.OS_Lib (g-os_lib.ads)
24651
24652 @geindex Operating System interface
24653
24654 @geindex Spawn capability
24655
24656 Provides a range of target independent operating system interface functions,
24657 including time/date management, file operations, subprocess management,
24658 including a portable spawn procedure, and access to environment variables
24659 and error return codes.
24660
24661 @node GNAT Perfect_Hash_Generators g-pehage ads,GNAT Random_Numbers g-rannum ads,GNAT OS_Lib g-os_lib ads,The GNAT Library
24662 @anchor{gnat_rm/the_gnat_library gnat-perfect-hash-generators-g-pehage-ads}@anchor{38e}@anchor{gnat_rm/the_gnat_library id95}@anchor{38f}
24663 @section @code{GNAT.Perfect_Hash_Generators} (@code{g-pehage.ads})
24664
24665
24666 @geindex GNAT.Perfect_Hash_Generators (g-pehage.ads)
24667
24668 @geindex Hash functions
24669
24670 Provides a generator of static minimal perfect hash functions. No
24671 collisions occur and each item can be retrieved from the table in one
24672 probe (perfect property). The hash table size corresponds to the exact
24673 size of the key set and no larger (minimal property). The key set has to
24674 be know in advance (static property). The hash functions are also order
24675 preserving. If w2 is inserted after w1 in the generator, their
24676 hashcode are in the same order. These hashing functions are very
24677 convenient for use with realtime applications.
24678
24679 @node GNAT Random_Numbers g-rannum ads,GNAT Regexp g-regexp ads,GNAT Perfect_Hash_Generators g-pehage ads,The GNAT Library
24680 @anchor{gnat_rm/the_gnat_library gnat-random-numbers-g-rannum-ads}@anchor{390}@anchor{gnat_rm/the_gnat_library id96}@anchor{391}
24681 @section @code{GNAT.Random_Numbers} (@code{g-rannum.ads})
24682
24683
24684 @geindex GNAT.Random_Numbers (g-rannum.ads)
24685
24686 @geindex Random number generation
24687
24688 Provides random number capabilities which extend those available in the
24689 standard Ada library and are more convenient to use.
24690
24691 @node GNAT Regexp g-regexp ads,GNAT Registry g-regist ads,GNAT Random_Numbers g-rannum ads,The GNAT Library
24692 @anchor{gnat_rm/the_gnat_library gnat-regexp-g-regexp-ads}@anchor{259}@anchor{gnat_rm/the_gnat_library id97}@anchor{392}
24693 @section @code{GNAT.Regexp} (@code{g-regexp.ads})
24694
24695
24696 @geindex GNAT.Regexp (g-regexp.ads)
24697
24698 @geindex Regular expressions
24699
24700 @geindex Pattern matching
24701
24702 A simple implementation of regular expressions, using a subset of regular
24703 expression syntax copied from familiar Unix style utilities. This is the
24704 simplest of the three pattern matching packages provided, and is particularly
24705 suitable for 'file globbing' applications.
24706
24707 @node GNAT Registry g-regist ads,GNAT Regpat g-regpat ads,GNAT Regexp g-regexp ads,The GNAT Library
24708 @anchor{gnat_rm/the_gnat_library id98}@anchor{393}@anchor{gnat_rm/the_gnat_library gnat-registry-g-regist-ads}@anchor{394}
24709 @section @code{GNAT.Registry} (@code{g-regist.ads})
24710
24711
24712 @geindex GNAT.Registry (g-regist.ads)
24713
24714 @geindex Windows Registry
24715
24716 This is a high level binding to the Windows registry. It is possible to
24717 do simple things like reading a key value, creating a new key. For full
24718 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
24719 package provided with the Win32Ada binding
24720
24721 @node GNAT Regpat g-regpat ads,GNAT Rewrite_Data g-rewdat ads,GNAT Registry g-regist ads,The GNAT Library
24722 @anchor{gnat_rm/the_gnat_library id99}@anchor{395}@anchor{gnat_rm/the_gnat_library gnat-regpat-g-regpat-ads}@anchor{396}
24723 @section @code{GNAT.Regpat} (@code{g-regpat.ads})
24724
24725
24726 @geindex GNAT.Regpat (g-regpat.ads)
24727
24728 @geindex Regular expressions
24729
24730 @geindex Pattern matching
24731
24732 A complete implementation of Unix-style regular expression matching, copied
24733 from the original V7 style regular expression library written in C by
24734 Henry Spencer (and binary compatible with this C library).
24735
24736 @node GNAT Rewrite_Data g-rewdat ads,GNAT Secondary_Stack_Info g-sestin ads,GNAT Regpat g-regpat ads,The GNAT Library
24737 @anchor{gnat_rm/the_gnat_library id100}@anchor{397}@anchor{gnat_rm/the_gnat_library gnat-rewrite-data-g-rewdat-ads}@anchor{398}
24738 @section @code{GNAT.Rewrite_Data} (@code{g-rewdat.ads})
24739
24740
24741 @geindex GNAT.Rewrite_Data (g-rewdat.ads)
24742
24743 @geindex Rewrite data
24744
24745 A unit to rewrite on-the-fly string occurrences in a stream of
24746 data. The implementation has a very minimal memory footprint as the
24747 full content to be processed is not loaded into memory all at once. This makes
24748 this interface usable for large files or socket streams.
24749
24750 @node GNAT Secondary_Stack_Info g-sestin ads,GNAT Semaphores g-semaph ads,GNAT Rewrite_Data g-rewdat ads,The GNAT Library
24751 @anchor{gnat_rm/the_gnat_library id101}@anchor{399}@anchor{gnat_rm/the_gnat_library gnat-secondary-stack-info-g-sestin-ads}@anchor{39a}
24752 @section @code{GNAT.Secondary_Stack_Info} (@code{g-sestin.ads})
24753
24754
24755 @geindex GNAT.Secondary_Stack_Info (g-sestin.ads)
24756
24757 @geindex Secondary Stack Info
24758
24759 Provide the capability to query the high water mark of the current task's
24760 secondary stack.
24761
24762 @node GNAT Semaphores g-semaph ads,GNAT Serial_Communications g-sercom ads,GNAT Secondary_Stack_Info g-sestin ads,The GNAT Library
24763 @anchor{gnat_rm/the_gnat_library id102}@anchor{39b}@anchor{gnat_rm/the_gnat_library gnat-semaphores-g-semaph-ads}@anchor{39c}
24764 @section @code{GNAT.Semaphores} (@code{g-semaph.ads})
24765
24766
24767 @geindex GNAT.Semaphores (g-semaph.ads)
24768
24769 @geindex Semaphores
24770
24771 Provides classic counting and binary semaphores using protected types.
24772
24773 @node GNAT Serial_Communications g-sercom ads,GNAT SHA1 g-sha1 ads,GNAT Semaphores g-semaph ads,The GNAT Library
24774 @anchor{gnat_rm/the_gnat_library gnat-serial-communications-g-sercom-ads}@anchor{39d}@anchor{gnat_rm/the_gnat_library id103}@anchor{39e}
24775 @section @code{GNAT.Serial_Communications} (@code{g-sercom.ads})
24776
24777
24778 @geindex GNAT.Serial_Communications (g-sercom.ads)
24779
24780 @geindex Serial_Communications
24781
24782 Provides a simple interface to send and receive data over a serial
24783 port. This is only supported on GNU/Linux and Windows.
24784
24785 @node GNAT SHA1 g-sha1 ads,GNAT SHA224 g-sha224 ads,GNAT Serial_Communications g-sercom ads,The GNAT Library
24786 @anchor{gnat_rm/the_gnat_library gnat-sha1-g-sha1-ads}@anchor{39f}@anchor{gnat_rm/the_gnat_library id104}@anchor{3a0}
24787 @section @code{GNAT.SHA1} (@code{g-sha1.ads})
24788
24789
24790 @geindex GNAT.SHA1 (g-sha1.ads)
24791
24792 @geindex Secure Hash Algorithm SHA-1
24793
24794 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
24795 and RFC 3174, and the HMAC-SHA1 message authentication function as described
24796 in RFC 2104 and FIPS PUB 198.
24797
24798 @node GNAT SHA224 g-sha224 ads,GNAT SHA256 g-sha256 ads,GNAT SHA1 g-sha1 ads,The GNAT Library
24799 @anchor{gnat_rm/the_gnat_library gnat-sha224-g-sha224-ads}@anchor{3a1}@anchor{gnat_rm/the_gnat_library id105}@anchor{3a2}
24800 @section @code{GNAT.SHA224} (@code{g-sha224.ads})
24801
24802
24803 @geindex GNAT.SHA224 (g-sha224.ads)
24804
24805 @geindex Secure Hash Algorithm SHA-224
24806
24807 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3,
24808 and the HMAC-SHA224 message authentication function as described
24809 in RFC 2104 and FIPS PUB 198.
24810
24811 @node GNAT SHA256 g-sha256 ads,GNAT SHA384 g-sha384 ads,GNAT SHA224 g-sha224 ads,The GNAT Library
24812 @anchor{gnat_rm/the_gnat_library gnat-sha256-g-sha256-ads}@anchor{3a3}@anchor{gnat_rm/the_gnat_library id106}@anchor{3a4}
24813 @section @code{GNAT.SHA256} (@code{g-sha256.ads})
24814
24815
24816 @geindex GNAT.SHA256 (g-sha256.ads)
24817
24818 @geindex Secure Hash Algorithm SHA-256
24819
24820 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3,
24821 and the HMAC-SHA256 message authentication function as described
24822 in RFC 2104 and FIPS PUB 198.
24823
24824 @node GNAT SHA384 g-sha384 ads,GNAT SHA512 g-sha512 ads,GNAT SHA256 g-sha256 ads,The GNAT Library
24825 @anchor{gnat_rm/the_gnat_library gnat-sha384-g-sha384-ads}@anchor{3a5}@anchor{gnat_rm/the_gnat_library id107}@anchor{3a6}
24826 @section @code{GNAT.SHA384} (@code{g-sha384.ads})
24827
24828
24829 @geindex GNAT.SHA384 (g-sha384.ads)
24830
24831 @geindex Secure Hash Algorithm SHA-384
24832
24833 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3,
24834 and the HMAC-SHA384 message authentication function as described
24835 in RFC 2104 and FIPS PUB 198.
24836
24837 @node GNAT SHA512 g-sha512 ads,GNAT Signals g-signal ads,GNAT SHA384 g-sha384 ads,The GNAT Library
24838 @anchor{gnat_rm/the_gnat_library id108}@anchor{3a7}@anchor{gnat_rm/the_gnat_library gnat-sha512-g-sha512-ads}@anchor{3a8}
24839 @section @code{GNAT.SHA512} (@code{g-sha512.ads})
24840
24841
24842 @geindex GNAT.SHA512 (g-sha512.ads)
24843
24844 @geindex Secure Hash Algorithm SHA-512
24845
24846 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3,
24847 and the HMAC-SHA512 message authentication function as described
24848 in RFC 2104 and FIPS PUB 198.
24849
24850 @node GNAT Signals g-signal ads,GNAT Sockets g-socket ads,GNAT SHA512 g-sha512 ads,The GNAT Library
24851 @anchor{gnat_rm/the_gnat_library id109}@anchor{3a9}@anchor{gnat_rm/the_gnat_library gnat-signals-g-signal-ads}@anchor{3aa}
24852 @section @code{GNAT.Signals} (@code{g-signal.ads})
24853
24854
24855 @geindex GNAT.Signals (g-signal.ads)
24856
24857 @geindex Signals
24858
24859 Provides the ability to manipulate the blocked status of signals on supported
24860 targets.
24861
24862 @node GNAT Sockets g-socket ads,GNAT Source_Info g-souinf ads,GNAT Signals g-signal ads,The GNAT Library
24863 @anchor{gnat_rm/the_gnat_library gnat-sockets-g-socket-ads}@anchor{3ab}@anchor{gnat_rm/the_gnat_library id110}@anchor{3ac}
24864 @section @code{GNAT.Sockets} (@code{g-socket.ads})
24865
24866
24867 @geindex GNAT.Sockets (g-socket.ads)
24868
24869 @geindex Sockets
24870
24871 A high level and portable interface to develop sockets based applications.
24872 This package is based on the sockets thin binding found in
24873 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
24874 on all native GNAT ports and on VxWorks cross prots. It is not implemented for
24875 the LynxOS cross port.
24876
24877 @node GNAT Source_Info g-souinf ads,GNAT Spelling_Checker g-speche ads,GNAT Sockets g-socket ads,The GNAT Library
24878 @anchor{gnat_rm/the_gnat_library gnat-source-info-g-souinf-ads}@anchor{3ad}@anchor{gnat_rm/the_gnat_library id111}@anchor{3ae}
24879 @section @code{GNAT.Source_Info} (@code{g-souinf.ads})
24880
24881
24882 @geindex GNAT.Source_Info (g-souinf.ads)
24883
24884 @geindex Source Information
24885
24886 Provides subprograms that give access to source code information known at
24887 compile time, such as the current file name and line number. Also provides
24888 subprograms yielding the date and time of the current compilation (like the
24889 C macros @code{__DATE__} and @code{__TIME__})
24890
24891 @node GNAT Spelling_Checker g-speche ads,GNAT Spelling_Checker_Generic g-spchge ads,GNAT Source_Info g-souinf ads,The GNAT Library
24892 @anchor{gnat_rm/the_gnat_library id112}@anchor{3af}@anchor{gnat_rm/the_gnat_library gnat-spelling-checker-g-speche-ads}@anchor{3b0}
24893 @section @code{GNAT.Spelling_Checker} (@code{g-speche.ads})
24894
24895
24896 @geindex GNAT.Spelling_Checker (g-speche.ads)
24897
24898 @geindex Spell checking
24899
24900 Provides a function for determining whether one string is a plausible
24901 near misspelling of another string.
24902
24903 @node GNAT Spelling_Checker_Generic g-spchge ads,GNAT Spitbol Patterns g-spipat ads,GNAT Spelling_Checker g-speche ads,The GNAT Library
24904 @anchor{gnat_rm/the_gnat_library gnat-spelling-checker-generic-g-spchge-ads}@anchor{3b1}@anchor{gnat_rm/the_gnat_library id113}@anchor{3b2}
24905 @section @code{GNAT.Spelling_Checker_Generic} (@code{g-spchge.ads})
24906
24907
24908 @geindex GNAT.Spelling_Checker_Generic (g-spchge.ads)
24909
24910 @geindex Spell checking
24911
24912 Provides a generic function that can be instantiated with a string type for
24913 determining whether one string is a plausible near misspelling of another
24914 string.
24915
24916 @node GNAT Spitbol Patterns g-spipat ads,GNAT Spitbol g-spitbo ads,GNAT Spelling_Checker_Generic g-spchge ads,The GNAT Library
24917 @anchor{gnat_rm/the_gnat_library gnat-spitbol-patterns-g-spipat-ads}@anchor{3b3}@anchor{gnat_rm/the_gnat_library id114}@anchor{3b4}
24918 @section @code{GNAT.Spitbol.Patterns} (@code{g-spipat.ads})
24919
24920
24921 @geindex GNAT.Spitbol.Patterns (g-spipat.ads)
24922
24923 @geindex SPITBOL pattern matching
24924
24925 @geindex Pattern matching
24926
24927 A complete implementation of SNOBOL4 style pattern matching. This is the
24928 most elaborate of the pattern matching packages provided. It fully duplicates
24929 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
24930 efficient algorithm developed by Robert Dewar for the SPITBOL system.
24931
24932 @node GNAT Spitbol g-spitbo ads,GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Patterns g-spipat ads,The GNAT Library
24933 @anchor{gnat_rm/the_gnat_library gnat-spitbol-g-spitbo-ads}@anchor{3b5}@anchor{gnat_rm/the_gnat_library id115}@anchor{3b6}
24934 @section @code{GNAT.Spitbol} (@code{g-spitbo.ads})
24935
24936
24937 @geindex GNAT.Spitbol (g-spitbo.ads)
24938
24939 @geindex SPITBOL interface
24940
24941 The top level package of the collection of SPITBOL-style functionality, this
24942 package provides basic SNOBOL4 string manipulation functions, such as
24943 Pad, Reverse, Trim, Substr capability, as well as a generic table function
24944 useful for constructing arbitrary mappings from strings in the style of
24945 the SNOBOL4 TABLE function.
24946
24947 @node GNAT Spitbol Table_Boolean g-sptabo ads,GNAT Spitbol Table_Integer g-sptain ads,GNAT Spitbol g-spitbo ads,The GNAT Library
24948 @anchor{gnat_rm/the_gnat_library id116}@anchor{3b7}@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-boolean-g-sptabo-ads}@anchor{3b8}
24949 @section @code{GNAT.Spitbol.Table_Boolean} (@code{g-sptabo.ads})
24950
24951
24952 @geindex GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
24953
24954 @geindex Sets of strings
24955
24956 @geindex SPITBOL Tables
24957
24958 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24959 for type @code{Standard.Boolean}, giving an implementation of sets of
24960 string values.
24961
24962 @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
24963 @anchor{gnat_rm/the_gnat_library gnat-spitbol-table-integer-g-sptain-ads}@anchor{3b9}@anchor{gnat_rm/the_gnat_library id117}@anchor{3ba}
24964 @section @code{GNAT.Spitbol.Table_Integer} (@code{g-sptain.ads})
24965
24966
24967 @geindex GNAT.Spitbol.Table_Integer (g-sptain.ads)
24968
24969 @geindex Integer maps
24970
24971 @geindex Maps
24972
24973 @geindex SPITBOL Tables
24974
24975 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
24976 for type @code{Standard.Integer}, giving an implementation of maps
24977 from string to integer values.
24978
24979 @node GNAT Spitbol Table_VString g-sptavs ads,GNAT SSE g-sse ads,GNAT Spitbol Table_Integer g-sptain ads,The GNAT Library
24980 @anchor{gnat_rm/the_gnat_library id118}@anchor{3bb}@anchor{gnat_rm/the_gnat_library gnat-spitbol-table-vstring-g-sptavs-ads}@anchor{3bc}
24981 @section @code{GNAT.Spitbol.Table_VString} (@code{g-sptavs.ads})
24982
24983
24984 @geindex GNAT.Spitbol.Table_VString (g-sptavs.ads)
24985
24986 @geindex String maps
24987
24988 @geindex Maps
24989
24990 @geindex SPITBOL Tables
24991
24992 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
24993 a variable length string type, giving an implementation of general
24994 maps from strings to strings.
24995
24996 @node GNAT SSE g-sse ads,GNAT SSE Vector_Types g-ssvety ads,GNAT Spitbol Table_VString g-sptavs ads,The GNAT Library
24997 @anchor{gnat_rm/the_gnat_library id119}@anchor{3bd}@anchor{gnat_rm/the_gnat_library gnat-sse-g-sse-ads}@anchor{3be}
24998 @section @code{GNAT.SSE} (@code{g-sse.ads})
24999
25000
25001 @geindex GNAT.SSE (g-sse.ads)
25002
25003 Root of a set of units aimed at offering Ada bindings to a subset of
25004 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
25005 targets. It exposes vector component types together with a general
25006 introduction to the binding contents and use.
25007
25008 @node GNAT SSE Vector_Types g-ssvety ads,GNAT String_Hash g-strhas ads,GNAT SSE g-sse ads,The GNAT Library
25009 @anchor{gnat_rm/the_gnat_library gnat-sse-vector-types-g-ssvety-ads}@anchor{3bf}@anchor{gnat_rm/the_gnat_library id120}@anchor{3c0}
25010 @section @code{GNAT.SSE.Vector_Types} (@code{g-ssvety.ads})
25011
25012
25013 @geindex GNAT.SSE.Vector_Types (g-ssvety.ads)
25014
25015 SSE vector types for use with SSE related intrinsics.
25016
25017 @node GNAT String_Hash g-strhas ads,GNAT Strings g-string ads,GNAT SSE Vector_Types g-ssvety ads,The GNAT Library
25018 @anchor{gnat_rm/the_gnat_library gnat-string-hash-g-strhas-ads}@anchor{3c1}@anchor{gnat_rm/the_gnat_library id121}@anchor{3c2}
25019 @section @code{GNAT.String_Hash} (@code{g-strhas.ads})
25020
25021
25022 @geindex GNAT.String_Hash (g-strhas.ads)
25023
25024 @geindex Hash functions
25025
25026 Provides a generic hash function working on arrays of scalars. Both the scalar
25027 type and the hash result type are parameters.
25028
25029 @node GNAT Strings g-string ads,GNAT String_Split g-strspl ads,GNAT String_Hash g-strhas ads,The GNAT Library
25030 @anchor{gnat_rm/the_gnat_library gnat-strings-g-string-ads}@anchor{3c3}@anchor{gnat_rm/the_gnat_library id122}@anchor{3c4}
25031 @section @code{GNAT.Strings} (@code{g-string.ads})
25032
25033
25034 @geindex GNAT.Strings (g-string.ads)
25035
25036 Common String access types and related subprograms. Basically it
25037 defines a string access and an array of string access types.
25038
25039 @node GNAT String_Split g-strspl ads,GNAT Table g-table ads,GNAT Strings g-string ads,The GNAT Library
25040 @anchor{gnat_rm/the_gnat_library gnat-string-split-g-strspl-ads}@anchor{3c5}@anchor{gnat_rm/the_gnat_library id123}@anchor{3c6}
25041 @section @code{GNAT.String_Split} (@code{g-strspl.ads})
25042
25043
25044 @geindex GNAT.String_Split (g-strspl.ads)
25045
25046 @geindex String splitter
25047
25048 Useful string manipulation routines: given a set of separators, split
25049 a string wherever the separators appear, and provide direct access
25050 to the resulting slices. This package is instantiated from
25051 @code{GNAT.Array_Split}.
25052
25053 @node GNAT Table g-table ads,GNAT Task_Lock g-tasloc ads,GNAT String_Split g-strspl ads,The GNAT Library
25054 @anchor{gnat_rm/the_gnat_library id124}@anchor{3c7}@anchor{gnat_rm/the_gnat_library gnat-table-g-table-ads}@anchor{3c8}
25055 @section @code{GNAT.Table} (@code{g-table.ads})
25056
25057
25058 @geindex GNAT.Table (g-table.ads)
25059
25060 @geindex Table implementation
25061
25062 @geindex Arrays
25063 @geindex extendable
25064
25065 A generic package providing a single dimension array abstraction where the
25066 length of the array can be dynamically modified.
25067
25068 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
25069 except that this package declares a single instance of the table type,
25070 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
25071 used to define dynamic instances of the table.
25072
25073 @node GNAT Task_Lock g-tasloc ads,GNAT Time_Stamp g-timsta ads,GNAT Table g-table ads,The GNAT Library
25074 @anchor{gnat_rm/the_gnat_library id125}@anchor{3c9}@anchor{gnat_rm/the_gnat_library gnat-task-lock-g-tasloc-ads}@anchor{3ca}
25075 @section @code{GNAT.Task_Lock} (@code{g-tasloc.ads})
25076
25077
25078 @geindex GNAT.Task_Lock (g-tasloc.ads)
25079
25080 @geindex Task synchronization
25081
25082 @geindex Task locking
25083
25084 @geindex Locking
25085
25086 A very simple facility for locking and unlocking sections of code using a
25087 single global task lock. Appropriate for use in situations where contention
25088 between tasks is very rarely expected.
25089
25090 @node GNAT Time_Stamp g-timsta ads,GNAT Threads g-thread ads,GNAT Task_Lock g-tasloc ads,The GNAT Library
25091 @anchor{gnat_rm/the_gnat_library id126}@anchor{3cb}@anchor{gnat_rm/the_gnat_library gnat-time-stamp-g-timsta-ads}@anchor{3cc}
25092 @section @code{GNAT.Time_Stamp} (@code{g-timsta.ads})
25093
25094
25095 @geindex GNAT.Time_Stamp (g-timsta.ads)
25096
25097 @geindex Time stamp
25098
25099 @geindex Current time
25100
25101 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
25102 represents the current date and time in ISO 8601 format. This is a very simple
25103 routine with minimal code and there are no dependencies on any other unit.
25104
25105 @node GNAT Threads g-thread ads,GNAT Traceback g-traceb ads,GNAT Time_Stamp g-timsta ads,The GNAT Library
25106 @anchor{gnat_rm/the_gnat_library id127}@anchor{3cd}@anchor{gnat_rm/the_gnat_library gnat-threads-g-thread-ads}@anchor{3ce}
25107 @section @code{GNAT.Threads} (@code{g-thread.ads})
25108
25109
25110 @geindex GNAT.Threads (g-thread.ads)
25111
25112 @geindex Foreign threads
25113
25114 @geindex Threads
25115 @geindex foreign
25116
25117 Provides facilities for dealing with foreign threads which need to be known
25118 by the GNAT run-time system. Consult the documentation of this package for
25119 further details if your program has threads that are created by a non-Ada
25120 environment which then accesses Ada code.
25121
25122 @node GNAT Traceback g-traceb ads,GNAT Traceback Symbolic g-trasym ads,GNAT Threads g-thread ads,The GNAT Library
25123 @anchor{gnat_rm/the_gnat_library id128}@anchor{3cf}@anchor{gnat_rm/the_gnat_library gnat-traceback-g-traceb-ads}@anchor{3d0}
25124 @section @code{GNAT.Traceback} (@code{g-traceb.ads})
25125
25126
25127 @geindex GNAT.Traceback (g-traceb.ads)
25128
25129 @geindex Trace back facilities
25130
25131 Provides a facility for obtaining non-symbolic traceback information, useful
25132 in various debugging situations.
25133
25134 @node GNAT Traceback Symbolic g-trasym ads,GNAT UTF_32 g-table ads,GNAT Traceback g-traceb ads,The GNAT Library
25135 @anchor{gnat_rm/the_gnat_library gnat-traceback-symbolic-g-trasym-ads}@anchor{3d1}@anchor{gnat_rm/the_gnat_library id129}@anchor{3d2}
25136 @section @code{GNAT.Traceback.Symbolic} (@code{g-trasym.ads})
25137
25138
25139 @geindex GNAT.Traceback.Symbolic (g-trasym.ads)
25140
25141 @geindex Trace back facilities
25142
25143 @node GNAT UTF_32 g-table ads,GNAT Wide_Spelling_Checker g-u3spch ads,GNAT Traceback Symbolic g-trasym ads,The GNAT Library
25144 @anchor{gnat_rm/the_gnat_library id130}@anchor{3d3}@anchor{gnat_rm/the_gnat_library gnat-utf-32-g-table-ads}@anchor{3d4}
25145 @section @code{GNAT.UTF_32} (@code{g-table.ads})
25146
25147
25148 @geindex GNAT.UTF_32 (g-table.ads)
25149
25150 @geindex Wide character codes
25151
25152 This is a package intended to be used in conjunction with the
25153 @code{Wide_Character} type in Ada 95 and the
25154 @code{Wide_Wide_Character} type in Ada 2005 (available
25155 in @code{GNAT} in Ada 2005 mode). This package contains
25156 Unicode categorization routines, as well as lexical
25157 categorization routines corresponding to the Ada 2005
25158 lexical rules for identifiers and strings, and also a
25159 lower case to upper case fold routine corresponding to
25160 the Ada 2005 rules for identifier equivalence.
25161
25162 @node GNAT Wide_Spelling_Checker g-u3spch ads,GNAT Wide_Spelling_Checker g-wispch ads,GNAT UTF_32 g-table ads,The GNAT Library
25163 @anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-u3spch-ads}@anchor{3d5}@anchor{gnat_rm/the_gnat_library id131}@anchor{3d6}
25164 @section @code{GNAT.Wide_Spelling_Checker} (@code{g-u3spch.ads})
25165
25166
25167 @geindex GNAT.Wide_Spelling_Checker (g-u3spch.ads)
25168
25169 @geindex Spell checking
25170
25171 Provides a function for determining whether one wide wide string is a plausible
25172 near misspelling of another wide wide string, where the strings are represented
25173 using the UTF_32_String type defined in System.Wch_Cnv.
25174
25175 @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
25176 @anchor{gnat_rm/the_gnat_library gnat-wide-spelling-checker-g-wispch-ads}@anchor{3d7}@anchor{gnat_rm/the_gnat_library id132}@anchor{3d8}
25177 @section @code{GNAT.Wide_Spelling_Checker} (@code{g-wispch.ads})
25178
25179
25180 @geindex GNAT.Wide_Spelling_Checker (g-wispch.ads)
25181
25182 @geindex Spell checking
25183
25184 Provides a function for determining whether one wide string is a plausible
25185 near misspelling of another wide string.
25186
25187 @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
25188 @anchor{gnat_rm/the_gnat_library id133}@anchor{3d9}@anchor{gnat_rm/the_gnat_library gnat-wide-string-split-g-wistsp-ads}@anchor{3da}
25189 @section @code{GNAT.Wide_String_Split} (@code{g-wistsp.ads})
25190
25191
25192 @geindex GNAT.Wide_String_Split (g-wistsp.ads)
25193
25194 @geindex Wide_String splitter
25195
25196 Useful wide string manipulation routines: given a set of separators, split
25197 a wide string wherever the separators appear, and provide direct access
25198 to the resulting slices. This package is instantiated from
25199 @code{GNAT.Array_Split}.
25200
25201 @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
25202 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-spelling-checker-g-zspche-ads}@anchor{3db}@anchor{gnat_rm/the_gnat_library id134}@anchor{3dc}
25203 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@code{g-zspche.ads})
25204
25205
25206 @geindex GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
25207
25208 @geindex Spell checking
25209
25210 Provides a function for determining whether one wide wide string is a plausible
25211 near misspelling of another wide wide string.
25212
25213 @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
25214 @anchor{gnat_rm/the_gnat_library gnat-wide-wide-string-split-g-zistsp-ads}@anchor{3dd}@anchor{gnat_rm/the_gnat_library id135}@anchor{3de}
25215 @section @code{GNAT.Wide_Wide_String_Split} (@code{g-zistsp.ads})
25216
25217
25218 @geindex GNAT.Wide_Wide_String_Split (g-zistsp.ads)
25219
25220 @geindex Wide_Wide_String splitter
25221
25222 Useful wide wide string manipulation routines: given a set of separators, split
25223 a wide wide string wherever the separators appear, and provide direct access
25224 to the resulting slices. This package is instantiated from
25225 @code{GNAT.Array_Split}.
25226
25227 @node Interfaces C Extensions i-cexten ads,Interfaces C Streams i-cstrea ads,GNAT Wide_Wide_String_Split g-zistsp ads,The GNAT Library
25228 @anchor{gnat_rm/the_gnat_library interfaces-c-extensions-i-cexten-ads}@anchor{3df}@anchor{gnat_rm/the_gnat_library id136}@anchor{3e0}
25229 @section @code{Interfaces.C.Extensions} (@code{i-cexten.ads})
25230
25231
25232 @geindex Interfaces.C.Extensions (i-cexten.ads)
25233
25234 This package contains additional C-related definitions, intended
25235 for use with either manually or automatically generated bindings
25236 to C libraries.
25237
25238 @node Interfaces C Streams i-cstrea ads,Interfaces Packed_Decimal i-pacdec ads,Interfaces C Extensions i-cexten ads,The GNAT Library
25239 @anchor{gnat_rm/the_gnat_library interfaces-c-streams-i-cstrea-ads}@anchor{3e1}@anchor{gnat_rm/the_gnat_library id137}@anchor{3e2}
25240 @section @code{Interfaces.C.Streams} (@code{i-cstrea.ads})
25241
25242
25243 @geindex Interfaces.C.Streams (i-cstrea.ads)
25244
25245 @geindex C streams
25246 @geindex interfacing
25247
25248 This package is a binding for the most commonly used operations
25249 on C streams.
25250
25251 @node Interfaces Packed_Decimal i-pacdec ads,Interfaces VxWorks i-vxwork ads,Interfaces C Streams i-cstrea ads,The GNAT Library
25252 @anchor{gnat_rm/the_gnat_library id138}@anchor{3e3}@anchor{gnat_rm/the_gnat_library interfaces-packed-decimal-i-pacdec-ads}@anchor{3e4}
25253 @section @code{Interfaces.Packed_Decimal} (@code{i-pacdec.ads})
25254
25255
25256 @geindex Interfaces.Packed_Decimal (i-pacdec.ads)
25257
25258 @geindex IBM Packed Format
25259
25260 @geindex Packed Decimal
25261
25262 This package provides a set of routines for conversions to and
25263 from a packed decimal format compatible with that used on IBM
25264 mainframes.
25265
25266 @node Interfaces VxWorks i-vxwork ads,Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces Packed_Decimal i-pacdec ads,The GNAT Library
25267 @anchor{gnat_rm/the_gnat_library id139}@anchor{3e5}@anchor{gnat_rm/the_gnat_library interfaces-vxworks-i-vxwork-ads}@anchor{3e6}
25268 @section @code{Interfaces.VxWorks} (@code{i-vxwork.ads})
25269
25270
25271 @geindex Interfaces.VxWorks (i-vxwork.ads)
25272
25273 @geindex Interfacing to VxWorks
25274
25275 @geindex VxWorks
25276 @geindex interfacing
25277
25278 This package provides a limited binding to the VxWorks API.
25279 In particular, it interfaces with the
25280 VxWorks hardware interrupt facilities.
25281
25282 @node Interfaces VxWorks Int_Connection i-vxinco ads,Interfaces VxWorks IO i-vxwoio ads,Interfaces VxWorks i-vxwork ads,The GNAT Library
25283 @anchor{gnat_rm/the_gnat_library interfaces-vxworks-int-connection-i-vxinco-ads}@anchor{3e7}@anchor{gnat_rm/the_gnat_library id140}@anchor{3e8}
25284 @section @code{Interfaces.VxWorks.Int_Connection} (@code{i-vxinco.ads})
25285
25286
25287 @geindex Interfaces.VxWorks.Int_Connection (i-vxinco.ads)
25288
25289 @geindex Interfacing to VxWorks
25290
25291 @geindex VxWorks
25292 @geindex interfacing
25293
25294 This package provides a way for users to replace the use of
25295 intConnect() with a custom routine for installing interrupt
25296 handlers.
25297
25298 @node Interfaces VxWorks IO i-vxwoio ads,System Address_Image s-addima ads,Interfaces VxWorks Int_Connection i-vxinco ads,The GNAT Library
25299 @anchor{gnat_rm/the_gnat_library interfaces-vxworks-io-i-vxwoio-ads}@anchor{3e9}@anchor{gnat_rm/the_gnat_library id141}@anchor{3ea}
25300 @section @code{Interfaces.VxWorks.IO} (@code{i-vxwoio.ads})
25301
25302
25303 @geindex Interfaces.VxWorks.IO (i-vxwoio.ads)
25304
25305 @geindex Interfacing to VxWorks' I/O
25306
25307 @geindex VxWorks
25308 @geindex I/O interfacing
25309
25310 @geindex VxWorks
25311 @geindex Get_Immediate
25312
25313 @geindex Get_Immediate
25314 @geindex VxWorks
25315
25316 This package provides a binding to the ioctl (IO/Control)
25317 function of VxWorks, defining a set of option values and
25318 function codes. A particular use of this package is
25319 to enable the use of Get_Immediate under VxWorks.
25320
25321 @node System Address_Image s-addima ads,System Assertions s-assert ads,Interfaces VxWorks IO i-vxwoio ads,The GNAT Library
25322 @anchor{gnat_rm/the_gnat_library system-address-image-s-addima-ads}@anchor{3eb}@anchor{gnat_rm/the_gnat_library id142}@anchor{3ec}
25323 @section @code{System.Address_Image} (@code{s-addima.ads})
25324
25325
25326 @geindex System.Address_Image (s-addima.ads)
25327
25328 @geindex Address image
25329
25330 @geindex Image
25331 @geindex of an address
25332
25333 This function provides a useful debugging
25334 function that gives an (implementation dependent)
25335 string which identifies an address.
25336
25337 @node System Assertions s-assert ads,System Atomic_Counters s-atocou ads,System Address_Image s-addima ads,The GNAT Library
25338 @anchor{gnat_rm/the_gnat_library system-assertions-s-assert-ads}@anchor{3ed}@anchor{gnat_rm/the_gnat_library id143}@anchor{3ee}
25339 @section @code{System.Assertions} (@code{s-assert.ads})
25340
25341
25342 @geindex System.Assertions (s-assert.ads)
25343
25344 @geindex Assertions
25345
25346 @geindex Assert_Failure
25347 @geindex exception
25348
25349 This package provides the declaration of the exception raised
25350 by an run-time assertion failure, as well as the routine that
25351 is used internally to raise this assertion.
25352
25353 @node System Atomic_Counters s-atocou ads,System Memory s-memory ads,System Assertions s-assert ads,The GNAT Library
25354 @anchor{gnat_rm/the_gnat_library id144}@anchor{3ef}@anchor{gnat_rm/the_gnat_library system-atomic-counters-s-atocou-ads}@anchor{3f0}
25355 @section @code{System.Atomic_Counters} (@code{s-atocou.ads})
25356
25357
25358 @geindex System.Atomic_Counters (s-atocou.ads)
25359
25360 This package provides the declaration of an atomic counter type,
25361 together with efficient routines (using hardware
25362 synchronization primitives) for incrementing, decrementing,
25363 and testing of these counters. This package is implemented
25364 on most targets, including all Alpha, ia64, PowerPC, SPARC V9,
25365 x86, and x86_64 platforms.
25366
25367 @node System Memory s-memory ads,System Multiprocessors s-multip ads,System Atomic_Counters s-atocou ads,The GNAT Library
25368 @anchor{gnat_rm/the_gnat_library system-memory-s-memory-ads}@anchor{3f1}@anchor{gnat_rm/the_gnat_library id145}@anchor{3f2}
25369 @section @code{System.Memory} (@code{s-memory.ads})
25370
25371
25372 @geindex System.Memory (s-memory.ads)
25373
25374 @geindex Memory allocation
25375
25376 This package provides the interface to the low level routines used
25377 by the generated code for allocation and freeing storage for the
25378 default storage pool (analogous to the C routines malloc and free.
25379 It also provides a reallocation interface analogous to the C routine
25380 realloc. The body of this unit may be modified to provide alternative
25381 allocation mechanisms for the default pool, and in addition, direct
25382 calls to this unit may be made for low level allocation uses (for
25383 example see the body of @code{GNAT.Tables}).
25384
25385 @node System Multiprocessors s-multip ads,System Multiprocessors Dispatching_Domains s-mudido ads,System Memory s-memory ads,The GNAT Library
25386 @anchor{gnat_rm/the_gnat_library id146}@anchor{3f3}@anchor{gnat_rm/the_gnat_library system-multiprocessors-s-multip-ads}@anchor{3f4}
25387 @section @code{System.Multiprocessors} (@code{s-multip.ads})
25388
25389
25390 @geindex System.Multiprocessors (s-multip.ads)
25391
25392 @geindex Multiprocessor interface
25393
25394 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
25395 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
25396 technically an implementation-defined addition).
25397
25398 @node System Multiprocessors Dispatching_Domains s-mudido ads,System Partition_Interface s-parint ads,System Multiprocessors s-multip ads,The GNAT Library
25399 @anchor{gnat_rm/the_gnat_library system-multiprocessors-dispatching-domains-s-mudido-ads}@anchor{3f5}@anchor{gnat_rm/the_gnat_library id147}@anchor{3f6}
25400 @section @code{System.Multiprocessors.Dispatching_Domains} (@code{s-mudido.ads})
25401
25402
25403 @geindex System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
25404
25405 @geindex Multiprocessor interface
25406
25407 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
25408 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
25409 technically an implementation-defined addition).
25410
25411 @node System Partition_Interface s-parint ads,System Pool_Global s-pooglo ads,System Multiprocessors Dispatching_Domains s-mudido ads,The GNAT Library
25412 @anchor{gnat_rm/the_gnat_library id148}@anchor{3f7}@anchor{gnat_rm/the_gnat_library system-partition-interface-s-parint-ads}@anchor{3f8}
25413 @section @code{System.Partition_Interface} (@code{s-parint.ads})
25414
25415
25416 @geindex System.Partition_Interface (s-parint.ads)
25417
25418 @geindex Partition interfacing functions
25419
25420 This package provides facilities for partition interfacing. It
25421 is used primarily in a distribution context when using Annex E
25422 with @code{GLADE}.
25423
25424 @node System Pool_Global s-pooglo ads,System Pool_Local s-pooloc ads,System Partition_Interface s-parint ads,The GNAT Library
25425 @anchor{gnat_rm/the_gnat_library id149}@anchor{3f9}@anchor{gnat_rm/the_gnat_library system-pool-global-s-pooglo-ads}@anchor{3fa}
25426 @section @code{System.Pool_Global} (@code{s-pooglo.ads})
25427
25428
25429 @geindex System.Pool_Global (s-pooglo.ads)
25430
25431 @geindex Storage pool
25432 @geindex global
25433
25434 @geindex Global storage pool
25435
25436 This package provides a storage pool that is equivalent to the default
25437 storage pool used for access types for which no pool is specifically
25438 declared. It uses malloc/free to allocate/free and does not attempt to
25439 do any automatic reclamation.
25440
25441 @node System Pool_Local s-pooloc ads,System Restrictions s-restri ads,System Pool_Global s-pooglo ads,The GNAT Library
25442 @anchor{gnat_rm/the_gnat_library system-pool-local-s-pooloc-ads}@anchor{3fb}@anchor{gnat_rm/the_gnat_library id150}@anchor{3fc}
25443 @section @code{System.Pool_Local} (@code{s-pooloc.ads})
25444
25445
25446 @geindex System.Pool_Local (s-pooloc.ads)
25447
25448 @geindex Storage pool
25449 @geindex local
25450
25451 @geindex Local storage pool
25452
25453 This package provides a storage pool that is intended for use with locally
25454 defined access types. It uses malloc/free for allocate/free, and maintains
25455 a list of allocated blocks, so that all storage allocated for the pool can
25456 be freed automatically when the pool is finalized.
25457
25458 @node System Restrictions s-restri ads,System Rident s-rident ads,System Pool_Local s-pooloc ads,The GNAT Library
25459 @anchor{gnat_rm/the_gnat_library system-restrictions-s-restri-ads}@anchor{3fd}@anchor{gnat_rm/the_gnat_library id151}@anchor{3fe}
25460 @section @code{System.Restrictions} (@code{s-restri.ads})
25461
25462
25463 @geindex System.Restrictions (s-restri.ads)
25464
25465 @geindex Run-time restrictions access
25466
25467 This package provides facilities for accessing at run time
25468 the status of restrictions specified at compile time for
25469 the partition. Information is available both with regard
25470 to actual restrictions specified, and with regard to
25471 compiler determined information on which restrictions
25472 are violated by one or more packages in the partition.
25473
25474 @node System Rident s-rident ads,System Strings Stream_Ops s-ststop ads,System Restrictions s-restri ads,The GNAT Library
25475 @anchor{gnat_rm/the_gnat_library system-rident-s-rident-ads}@anchor{3ff}@anchor{gnat_rm/the_gnat_library id152}@anchor{400}
25476 @section @code{System.Rident} (@code{s-rident.ads})
25477
25478
25479 @geindex System.Rident (s-rident.ads)
25480
25481 @geindex Restrictions definitions
25482
25483 This package provides definitions of the restrictions
25484 identifiers supported by GNAT, and also the format of
25485 the restrictions provided in package System.Restrictions.
25486 It is not normally necessary to @code{with} this generic package
25487 since the necessary instantiation is included in
25488 package System.Restrictions.
25489
25490 @node System Strings Stream_Ops s-ststop ads,System Unsigned_Types s-unstyp ads,System Rident s-rident ads,The GNAT Library
25491 @anchor{gnat_rm/the_gnat_library id153}@anchor{401}@anchor{gnat_rm/the_gnat_library system-strings-stream-ops-s-ststop-ads}@anchor{402}
25492 @section @code{System.Strings.Stream_Ops} (@code{s-ststop.ads})
25493
25494
25495 @geindex System.Strings.Stream_Ops (s-ststop.ads)
25496
25497 @geindex Stream operations
25498
25499 @geindex String stream operations
25500
25501 This package provides a set of stream subprograms for standard string types.
25502 It is intended primarily to support implicit use of such subprograms when
25503 stream attributes are applied to string types, but the subprograms in this
25504 package can be used directly by application programs.
25505
25506 @node System Unsigned_Types s-unstyp ads,System Wch_Cnv s-wchcnv ads,System Strings Stream_Ops s-ststop ads,The GNAT Library
25507 @anchor{gnat_rm/the_gnat_library system-unsigned-types-s-unstyp-ads}@anchor{403}@anchor{gnat_rm/the_gnat_library id154}@anchor{404}
25508 @section @code{System.Unsigned_Types} (@code{s-unstyp.ads})
25509
25510
25511 @geindex System.Unsigned_Types (s-unstyp.ads)
25512
25513 This package contains definitions of standard unsigned types that
25514 correspond in size to the standard signed types declared in Standard,
25515 and (unlike the types in Interfaces) have corresponding names. It
25516 also contains some related definitions for other specialized types
25517 used by the compiler in connection with packed array types.
25518
25519 @node System Wch_Cnv s-wchcnv ads,System Wch_Con s-wchcon ads,System Unsigned_Types s-unstyp ads,The GNAT Library
25520 @anchor{gnat_rm/the_gnat_library system-wch-cnv-s-wchcnv-ads}@anchor{405}@anchor{gnat_rm/the_gnat_library id155}@anchor{406}
25521 @section @code{System.Wch_Cnv} (@code{s-wchcnv.ads})
25522
25523
25524 @geindex System.Wch_Cnv (s-wchcnv.ads)
25525
25526 @geindex Wide Character
25527 @geindex Representation
25528
25529 @geindex Wide String
25530 @geindex Conversion
25531
25532 @geindex Representation of wide characters
25533
25534 This package provides routines for converting between
25535 wide and wide wide characters and a representation as a value of type
25536 @code{Standard.String}, using a specified wide character
25537 encoding method. It uses definitions in
25538 package @code{System.Wch_Con}.
25539
25540 @node System Wch_Con s-wchcon ads,,System Wch_Cnv s-wchcnv ads,The GNAT Library
25541 @anchor{gnat_rm/the_gnat_library id156}@anchor{407}@anchor{gnat_rm/the_gnat_library system-wch-con-s-wchcon-ads}@anchor{408}
25542 @section @code{System.Wch_Con} (@code{s-wchcon.ads})
25543
25544
25545 @geindex System.Wch_Con (s-wchcon.ads)
25546
25547 This package provides definitions and descriptions of
25548 the various methods used for encoding wide characters
25549 in ordinary strings. These definitions are used by
25550 the package @code{System.Wch_Cnv}.
25551
25552 @node Interfacing to Other Languages,Specialized Needs Annexes,The GNAT Library,Top
25553 @anchor{gnat_rm/interfacing_to_other_languages interfacing-to-other-languages}@anchor{11}@anchor{gnat_rm/interfacing_to_other_languages doc}@anchor{409}@anchor{gnat_rm/interfacing_to_other_languages id1}@anchor{40a}
25554 @chapter Interfacing to Other Languages
25555
25556
25557 The facilities in Annex B of the Ada Reference Manual are fully
25558 implemented in GNAT, and in addition, a full interface to C++ is
25559 provided.
25560
25561 @menu
25562 * Interfacing to C::
25563 * Interfacing to C++::
25564 * Interfacing to COBOL::
25565 * Interfacing to Fortran::
25566 * Interfacing to non-GNAT Ada code::
25567
25568 @end menu
25569
25570 @node Interfacing to C,Interfacing to C++,,Interfacing to Other Languages
25571 @anchor{gnat_rm/interfacing_to_other_languages interfacing-to-c}@anchor{40b}@anchor{gnat_rm/interfacing_to_other_languages id2}@anchor{40c}
25572 @section Interfacing to C
25573
25574
25575 Interfacing to C with GNAT can use one of two approaches:
25576
25577
25578 @itemize *
25579
25580 @item
25581 The types in the package @code{Interfaces.C} may be used.
25582
25583 @item
25584 Standard Ada types may be used directly. This may be less portable to
25585 other compilers, but will work on all GNAT compilers, which guarantee
25586 correspondence between the C and Ada types.
25587 @end itemize
25588
25589 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
25590 effect, since this is the default. The following table shows the
25591 correspondence between Ada scalar types and the corresponding C types.
25592
25593
25594 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}
25595 @headitem
25596
25597 Ada Type
25598
25599 @tab
25600
25601 C Type
25602
25603 @item
25604
25605 @code{Integer}
25606
25607 @tab
25608
25609 @code{int}
25610
25611 @item
25612
25613 @code{Short_Integer}
25614
25615 @tab
25616
25617 @code{short}
25618
25619 @item
25620
25621 @code{Short_Short_Integer}
25622
25623 @tab
25624
25625 @code{signed char}
25626
25627 @item
25628
25629 @code{Long_Integer}
25630
25631 @tab
25632
25633 @code{long}
25634
25635 @item
25636
25637 @code{Long_Long_Integer}
25638
25639 @tab
25640
25641 @code{long long}
25642
25643 @item
25644
25645 @code{Short_Float}
25646
25647 @tab
25648
25649 @code{float}
25650
25651 @item
25652
25653 @code{Float}
25654
25655 @tab
25656
25657 @code{float}
25658
25659 @item
25660
25661 @code{Long_Float}
25662
25663 @tab
25664
25665 @code{double}
25666
25667 @item
25668
25669 @code{Long_Long_Float}
25670
25671 @tab
25672
25673 This is the longest floating-point type supported by the hardware.
25674
25675 @end multitable
25676
25677
25678 Additionally, there are the following general correspondences between Ada
25679 and C types:
25680
25681
25682 @itemize *
25683
25684 @item
25685 Ada enumeration types map to C enumeration types directly if pragma
25686 @code{Convention C} is specified, which causes them to have a length of
25687 32 bits, except for boolean types which map to C99 @code{bool} and for
25688 which the length is 8 bits.
25689 Without pragma @code{Convention C}, Ada enumeration types map to
25690 8, 16, or 32 bits (i.e., C types @code{signed char}, @code{short},
25691 @code{int}, respectively) depending on the number of values passed.
25692 This is the only case in which pragma @code{Convention C} affects the
25693 representation of an Ada type.
25694
25695 @item
25696 Ada access types map to C pointers, except for the case of pointers to
25697 unconstrained types in Ada, which have no direct C equivalent.
25698
25699 @item
25700 Ada arrays map directly to C arrays.
25701
25702 @item
25703 Ada records map directly to C structures.
25704
25705 @item
25706 Packed Ada records map to C structures where all members are bit fields
25707 of the length corresponding to the @code{type'Size} value in Ada.
25708 @end itemize
25709
25710 @node Interfacing to C++,Interfacing to COBOL,Interfacing to C,Interfacing to Other Languages
25711 @anchor{gnat_rm/interfacing_to_other_languages id4}@anchor{40d}@anchor{gnat_rm/interfacing_to_other_languages id3}@anchor{4a}
25712 @section Interfacing to C++
25713
25714
25715 The interface to C++ makes use of the following pragmas, which are
25716 primarily intended to be constructed automatically using a binding generator
25717 tool, although it is possible to construct them by hand.
25718
25719 Using these pragmas it is possible to achieve complete
25720 inter-operability between Ada tagged types and C++ class definitions.
25721 See @ref{7,,Implementation Defined Pragmas}, for more details.
25722
25723
25724 @table @asis
25725
25726 @item @code{pragma CPP_Class ([Entity =>] @emph{LOCAL_NAME})}
25727
25728 The argument denotes an entity in the current declarative region that is
25729 declared as a tagged or untagged record type. It indicates that the type
25730 corresponds to an externally declared C++ class type, and is to be laid
25731 out the same way that C++ would lay out the type.
25732
25733 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
25734 for backward compatibility but its functionality is available
25735 using pragma @code{Import} with @code{Convention} = @code{CPP}.
25736
25737 @item @code{pragma CPP_Constructor ([Entity =>] @emph{LOCAL_NAME})}
25738
25739 This pragma identifies an imported function (imported in the usual way
25740 with pragma @code{Import}) as corresponding to a C++ constructor.
25741 @end table
25742
25743 A few restrictions are placed on the use of the @code{Access} attribute
25744 in conjunction with subprograms subject to convention @code{CPP}: the
25745 attribute may be used neither on primitive operations of a tagged
25746 record type with convention @code{CPP}, imported or not, nor on
25747 subprograms imported with pragma @code{CPP_Constructor}.
25748
25749 In addition, C++ exceptions are propagated and can be handled in an
25750 @code{others} choice of an exception handler. The corresponding Ada
25751 occurrence has no message, and the simple name of the exception identity
25752 contains @code{Foreign_Exception}. Finalization and awaiting dependent
25753 tasks works properly when such foreign exceptions are propagated.
25754
25755 It is also possible to import a C++ exception using the following syntax:
25756
25757 @example
25758 LOCAL_NAME : exception;
25759 pragma Import (Cpp,
25760 [Entity =>] LOCAL_NAME,
25761 [External_Name =>] static_string_EXPRESSION);
25762 @end example
25763
25764 The @code{External_Name} is the name of the C++ RTTI symbol. You can then
25765 cover a specific C++ exception in an exception handler.
25766
25767 @node Interfacing to COBOL,Interfacing to Fortran,Interfacing to C++,Interfacing to Other Languages
25768 @anchor{gnat_rm/interfacing_to_other_languages id5}@anchor{40e}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-cobol}@anchor{40f}
25769 @section Interfacing to COBOL
25770
25771
25772 Interfacing to COBOL is achieved as described in section B.4 of
25773 the Ada Reference Manual.
25774
25775 @node Interfacing to Fortran,Interfacing to non-GNAT Ada code,Interfacing to COBOL,Interfacing to Other Languages
25776 @anchor{gnat_rm/interfacing_to_other_languages id6}@anchor{410}@anchor{gnat_rm/interfacing_to_other_languages interfacing-to-fortran}@anchor{411}
25777 @section Interfacing to Fortran
25778
25779
25780 Interfacing to Fortran is achieved as described in section B.5 of the
25781 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
25782 multi-dimensional array causes the array to be stored in column-major
25783 order as required for convenient interface to Fortran.
25784
25785 @node Interfacing to non-GNAT Ada code,,Interfacing to Fortran,Interfacing to Other Languages
25786 @anchor{gnat_rm/interfacing_to_other_languages interfacing-to-non-gnat-ada-code}@anchor{412}@anchor{gnat_rm/interfacing_to_other_languages id7}@anchor{413}
25787 @section Interfacing to non-GNAT Ada code
25788
25789
25790 It is possible to specify the convention @code{Ada} in a pragma
25791 @code{Import} or pragma @code{Export}. However this refers to
25792 the calling conventions used by GNAT, which may or may not be
25793 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
25794 compiler to allow interoperation.
25795
25796 If arguments types are kept simple, and if the foreign compiler generally
25797 follows system calling conventions, then it may be possible to integrate
25798 files compiled by other Ada compilers, provided that the elaboration
25799 issues are adequately addressed (for example by eliminating the
25800 need for any load time elaboration).
25801
25802 In particular, GNAT running on VMS is designed to
25803 be highly compatible with the DEC Ada 83 compiler, so this is one
25804 case in which it is possible to import foreign units of this type,
25805 provided that the data items passed are restricted to simple scalar
25806 values or simple record types without variants, or simple array
25807 types with fixed bounds.
25808
25809 @node Specialized Needs Annexes,Implementation of Specific Ada Features,Interfacing to Other Languages,Top
25810 @anchor{gnat_rm/specialized_needs_annexes specialized-needs-annexes}@anchor{12}@anchor{gnat_rm/specialized_needs_annexes doc}@anchor{414}@anchor{gnat_rm/specialized_needs_annexes id1}@anchor{415}
25811 @chapter Specialized Needs Annexes
25812
25813
25814 Ada 95, Ada 2005, and Ada 2012 define a number of Specialized Needs Annexes, which are not
25815 required in all implementations. However, as described in this chapter,
25816 GNAT implements all of these annexes:
25817
25818
25819 @table @asis
25820
25821 @item @emph{Systems Programming (Annex C)}
25822
25823 The Systems Programming Annex is fully implemented.
25824
25825 @item @emph{Real-Time Systems (Annex D)}
25826
25827 The Real-Time Systems Annex is fully implemented.
25828
25829 @item @emph{Distributed Systems (Annex E)}
25830
25831 Stub generation is fully implemented in the GNAT compiler. In addition,
25832 a complete compatible PCS is available as part of the GLADE system,
25833 a separate product. When the two
25834 products are used in conjunction, this annex is fully implemented.
25835
25836 @item @emph{Information Systems (Annex F)}
25837
25838 The Information Systems annex is fully implemented.
25839
25840 @item @emph{Numerics (Annex G)}
25841
25842 The Numerics Annex is fully implemented.
25843
25844 @item @emph{Safety and Security / High-Integrity Systems (Annex H)}
25845
25846 The Safety and Security Annex (termed the High-Integrity Systems Annex
25847 in Ada 2005) is fully implemented.
25848 @end table
25849
25850 @node Implementation of Specific Ada Features,Implementation of Ada 2012 Features,Specialized Needs Annexes,Top
25851 @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{416}@anchor{gnat_rm/implementation_of_specific_ada_features id1}@anchor{417}
25852 @chapter Implementation of Specific Ada Features
25853
25854
25855 This chapter describes the GNAT implementation of several Ada language
25856 facilities.
25857
25858 @menu
25859 * Machine Code Insertions::
25860 * GNAT Implementation of Tasking::
25861 * GNAT Implementation of Shared Passive Packages::
25862 * Code Generation for Array Aggregates::
25863 * The Size of Discriminated Records with Default Discriminants::
25864 * Strict Conformance to the Ada Reference Manual::
25865
25866 @end menu
25867
25868 @node Machine Code Insertions,GNAT Implementation of Tasking,,Implementation of Specific Ada Features
25869 @anchor{gnat_rm/implementation_of_specific_ada_features machine-code-insertions}@anchor{16c}@anchor{gnat_rm/implementation_of_specific_ada_features id2}@anchor{418}
25870 @section Machine Code Insertions
25871
25872
25873 @geindex Machine Code insertions
25874
25875 Package @code{Machine_Code} provides machine code support as described
25876 in the Ada Reference Manual in two separate forms:
25877
25878
25879 @itemize *
25880
25881 @item
25882 Machine code statements, consisting of qualified expressions that
25883 fit the requirements of RM section 13.8.
25884
25885 @item
25886 An intrinsic callable procedure, providing an alternative mechanism of
25887 including machine instructions in a subprogram.
25888 @end itemize
25889
25890 The two features are similar, and both are closely related to the mechanism
25891 provided by the asm instruction in the GNU C compiler. Full understanding
25892 and use of the facilities in this package requires understanding the asm
25893 instruction, see the section on Extended Asm in
25894 @cite{Using_the_GNU_Compiler_Collection_(GCC)}.
25895
25896 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
25897 semantic restrictions and effects as described below. Both are provided so
25898 that the procedure call can be used as a statement, and the function call
25899 can be used to form a code_statement.
25900
25901 Consider this C @code{asm} instruction:
25902
25903 @example
25904 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
25905 @end example
25906
25907 The equivalent can be written for GNAT as:
25908
25909 @example
25910 Asm ("fsinx %1 %0",
25911 My_Float'Asm_Output ("=f", result),
25912 My_Float'Asm_Input ("f", angle));
25913 @end example
25914
25915 The first argument to @code{Asm} is the assembler template, and is
25916 identical to what is used in GNU C. This string must be a static
25917 expression. The second argument is the output operand list. It is
25918 either a single @code{Asm_Output} attribute reference, or a list of such
25919 references enclosed in parentheses (technically an array aggregate of
25920 such references).
25921
25922 The @code{Asm_Output} attribute denotes a function that takes two
25923 parameters. The first is a string, the second is the name of a variable
25924 of the type designated by the attribute prefix. The first (string)
25925 argument is required to be a static expression and designates the
25926 constraint (see the section on Constraints in
25927 @cite{Using_the_GNU_Compiler_Collection_(GCC)})
25928 for the parameter; e.g., what kind of register is required. The second
25929 argument is the variable to be written or updated with the
25930 result. The possible values for constraint are the same as those used in
25931 the RTL, and are dependent on the configuration file used to build the
25932 GCC back end. If there are no output operands, then this argument may
25933 either be omitted, or explicitly given as @code{No_Output_Operands}.
25934 No support is provided for GNU C's symbolic names for output parameters.
25935
25936 The second argument of @code{my_float'Asm_Output} functions as
25937 though it were an @code{out} parameter, which is a little curious, but
25938 all names have the form of expressions, so there is no syntactic
25939 irregularity, even though normally functions would not be permitted
25940 @code{out} parameters. The third argument is the list of input
25941 operands. It is either a single @code{Asm_Input} attribute reference, or
25942 a list of such references enclosed in parentheses (technically an array
25943 aggregate of such references).
25944
25945 The @code{Asm_Input} attribute denotes a function that takes two
25946 parameters. The first is a string, the second is an expression of the
25947 type designated by the prefix. The first (string) argument is required
25948 to be a static expression, and is the constraint for the parameter,
25949 (e.g., what kind of register is required). The second argument is the
25950 value to be used as the input argument. The possible values for the
25951 constraint are the same as those used in the RTL, and are dependent on
25952 the configuration file used to built the GCC back end.
25953 No support is provided for GNU C's symbolic names for input parameters.
25954
25955 If there are no input operands, this argument may either be omitted, or
25956 explicitly given as @code{No_Input_Operands}. The fourth argument, not
25957 present in the above example, is a list of register names, called the
25958 @emph{clobber} argument. This argument, if given, must be a static string
25959 expression, and is a space or comma separated list of names of registers
25960 that must be considered destroyed as a result of the @code{Asm} call. If
25961 this argument is the null string (the default value), then the code
25962 generator assumes that no additional registers are destroyed.
25963 In addition to registers, the special clobbers @code{memory} and
25964 @code{cc} as described in the GNU C docs are both supported.
25965
25966 The fifth argument, not present in the above example, called the
25967 @emph{volatile} argument, is by default @code{False}. It can be set to
25968 the literal value @code{True} to indicate to the code generator that all
25969 optimizations with respect to the instruction specified should be
25970 suppressed, and in particular an instruction that has outputs
25971 will still be generated, even if none of the outputs are
25972 used. See @cite{Using_the_GNU_Compiler_Collection_(GCC)}
25973 for the full description.
25974 Generally it is strongly advisable to use Volatile for any ASM statement
25975 that is missing either input or output operands or to avoid unwanted
25976 optimizations. A warning is generated if this advice is not followed.
25977
25978 No support is provided for GNU C's @code{asm goto} feature.
25979
25980 The @code{Asm} subprograms may be used in two ways. First the procedure
25981 forms can be used anywhere a procedure call would be valid, and
25982 correspond to what the RM calls 'intrinsic' routines. Such calls can
25983 be used to intersperse machine instructions with other Ada statements.
25984 Second, the function forms, which return a dummy value of the limited
25985 private type @code{Asm_Insn}, can be used in code statements, and indeed
25986 this is the only context where such calls are allowed. Code statements
25987 appear as aggregates of the form:
25988
25989 @example
25990 Asm_Insn'(Asm (...));
25991 Asm_Insn'(Asm_Volatile (...));
25992 @end example
25993
25994 In accordance with RM rules, such code statements are allowed only
25995 within subprograms whose entire body consists of such statements. It is
25996 not permissible to intermix such statements with other Ada statements.
25997
25998 Typically the form using intrinsic procedure calls is more convenient
25999 and more flexible. The code statement form is provided to meet the RM
26000 suggestion that such a facility should be made available. The following
26001 is the exact syntax of the call to @code{Asm}. As usual, if named notation
26002 is used, the arguments may be given in arbitrary order, following the
26003 normal rules for use of positional and named arguments:
26004
26005 @example
26006 ASM_CALL ::= Asm (
26007 [Template =>] static_string_EXPRESSION
26008 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
26009 [,[Inputs =>] INPUT_OPERAND_LIST ]
26010 [,[Clobber =>] static_string_EXPRESSION ]
26011 [,[Volatile =>] static_boolean_EXPRESSION] )
26012
26013 OUTPUT_OPERAND_LIST ::=
26014 [PREFIX.]No_Output_Operands
26015 | OUTPUT_OPERAND_ATTRIBUTE
26016 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
26017
26018 OUTPUT_OPERAND_ATTRIBUTE ::=
26019 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
26020
26021 INPUT_OPERAND_LIST ::=
26022 [PREFIX.]No_Input_Operands
26023 | INPUT_OPERAND_ATTRIBUTE
26024 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
26025
26026 INPUT_OPERAND_ATTRIBUTE ::=
26027 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
26028 @end example
26029
26030 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
26031 are declared in the package @code{Machine_Code} and must be referenced
26032 according to normal visibility rules. In particular if there is no
26033 @code{use} clause for this package, then appropriate package name
26034 qualification is required.
26035
26036 @node GNAT Implementation of Tasking,GNAT Implementation of Shared Passive Packages,Machine Code Insertions,Implementation of Specific Ada Features
26037 @anchor{gnat_rm/implementation_of_specific_ada_features id3}@anchor{419}@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-tasking}@anchor{41a}
26038 @section GNAT Implementation of Tasking
26039
26040
26041 This chapter outlines the basic GNAT approach to tasking (in particular,
26042 a multi-layered library for portability) and discusses issues related
26043 to compliance with the Real-Time Systems Annex.
26044
26045 @menu
26046 * Mapping Ada Tasks onto the Underlying Kernel Threads::
26047 * Ensuring Compliance with the Real-Time Annex::
26048 * Support for Locking Policies::
26049
26050 @end menu
26051
26052 @node Mapping Ada Tasks onto the Underlying Kernel Threads,Ensuring Compliance with the Real-Time Annex,,GNAT Implementation of Tasking
26053 @anchor{gnat_rm/implementation_of_specific_ada_features mapping-ada-tasks-onto-the-underlying-kernel-threads}@anchor{41b}@anchor{gnat_rm/implementation_of_specific_ada_features id4}@anchor{41c}
26054 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
26055
26056
26057 GNAT's run-time support comprises two layers:
26058
26059
26060 @itemize *
26061
26062 @item
26063 GNARL (GNAT Run-time Layer)
26064
26065 @item
26066 GNULL (GNAT Low-level Library)
26067 @end itemize
26068
26069 In GNAT, Ada's tasking services rely on a platform and OS independent
26070 layer known as GNARL. This code is responsible for implementing the
26071 correct semantics of Ada's task creation, rendezvous, protected
26072 operations etc.
26073
26074 GNARL decomposes Ada's tasking semantics into simpler lower level
26075 operations such as create a thread, set the priority of a thread,
26076 yield, create a lock, lock/unlock, etc. The spec for these low-level
26077 operations constitutes GNULLI, the GNULL Interface. This interface is
26078 directly inspired from the POSIX real-time API.
26079
26080 If the underlying executive or OS implements the POSIX standard
26081 faithfully, the GNULL Interface maps as is to the services offered by
26082 the underlying kernel. Otherwise, some target dependent glue code maps
26083 the services offered by the underlying kernel to the semantics expected
26084 by GNARL.
26085
26086 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
26087 key point is that each Ada task is mapped on a thread in the underlying
26088 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
26089
26090 In addition Ada task priorities map onto the underlying thread priorities.
26091 Mapping Ada tasks onto the underlying kernel threads has several advantages:
26092
26093
26094 @itemize *
26095
26096 @item
26097 The underlying scheduler is used to schedule the Ada tasks. This
26098 makes Ada tasks as efficient as kernel threads from a scheduling
26099 standpoint.
26100
26101 @item
26102 Interaction with code written in C containing threads is eased
26103 since at the lowest level Ada tasks and C threads map onto the same
26104 underlying kernel concept.
26105
26106 @item
26107 When an Ada task is blocked during I/O the remaining Ada tasks are
26108 able to proceed.
26109
26110 @item
26111 On multiprocessor systems Ada tasks can execute in parallel.
26112 @end itemize
26113
26114 Some threads libraries offer a mechanism to fork a new process, with the
26115 child process duplicating the threads from the parent.
26116 GNAT does not
26117 support this functionality when the parent contains more than one task.
26118
26119 @geindex Forking a new process
26120
26121 @node Ensuring Compliance with the Real-Time Annex,Support for Locking Policies,Mapping Ada Tasks onto the Underlying Kernel Threads,GNAT Implementation of Tasking
26122 @anchor{gnat_rm/implementation_of_specific_ada_features id5}@anchor{41d}@anchor{gnat_rm/implementation_of_specific_ada_features ensuring-compliance-with-the-real-time-annex}@anchor{41e}
26123 @subsection Ensuring Compliance with the Real-Time Annex
26124
26125
26126 @geindex Real-Time Systems Annex compliance
26127
26128 Although mapping Ada tasks onto
26129 the underlying threads has significant advantages, it does create some
26130 complications when it comes to respecting the scheduling semantics
26131 specified in the real-time annex (Annex D).
26132
26133 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
26134 scheduling policy states:
26135
26136 @quotation
26137
26138 @emph{When the active priority of a ready task that is not running
26139 changes, or the setting of its base priority takes effect, the
26140 task is removed from the ready queue for its old active priority
26141 and is added at the tail of the ready queue for its new active
26142 priority, except in the case where the active priority is lowered
26143 due to the loss of inherited priority, in which case the task is
26144 added at the head of the ready queue for its new active priority.}
26145 @end quotation
26146
26147 While most kernels do put tasks at the end of the priority queue when
26148 a task changes its priority, (which respects the main
26149 FIFO_Within_Priorities requirement), almost none keep a thread at the
26150 beginning of its priority queue when its priority drops from the loss
26151 of inherited priority.
26152
26153 As a result most vendors have provided incomplete Annex D implementations.
26154
26155 The GNAT run-time, has a nice cooperative solution to this problem
26156 which ensures that accurate FIFO_Within_Priorities semantics are
26157 respected.
26158
26159 The principle is as follows. When an Ada task T is about to start
26160 running, it checks whether some other Ada task R with the same
26161 priority as T has been suspended due to the loss of priority
26162 inheritance. If this is the case, T yields and is placed at the end of
26163 its priority queue. When R arrives at the front of the queue it
26164 executes.
26165
26166 Note that this simple scheme preserves the relative order of the tasks
26167 that were ready to execute in the priority queue where R has been
26168 placed at the end.
26169
26170 @c Support_for_Locking_Policies
26171
26172 @node Support for Locking Policies,,Ensuring Compliance with the Real-Time Annex,GNAT Implementation of Tasking
26173 @anchor{gnat_rm/implementation_of_specific_ada_features support-for-locking-policies}@anchor{41f}
26174 @subsection Support for Locking Policies
26175
26176
26177 This section specifies which policies specified by pragma Locking_Policy
26178 are supported on which platforms.
26179
26180 GNAT supports the standard @code{Ceiling_Locking} policy, and the
26181 implementation defined @code{Inheritance_Locking} and
26182 @code{Concurrent_Readers_Locking} policies.
26183
26184 @code{Ceiling_Locking} is supported on all platforms if the operating system
26185 supports it. In particular, @code{Ceiling_Locking} is not supported on
26186 VxWorks.
26187 @code{Inheritance_Locking} is supported on
26188 Linux,
26189 Darwin (Mac OS X),
26190 LynxOS 178,
26191 and VxWorks.
26192 @code{Concurrent_Readers_Locking} is supported on Linux.
26193
26194 Notes about @code{Ceiling_Locking} on Linux:
26195 If the process is running as 'root', ceiling locking is used.
26196 If the capabilities facility is installed
26197 ("sudo apt-get --assume-yes install libcap-dev" on Ubuntu,
26198 for example),
26199 and the program is linked against that library
26200 ("-largs -lcap"),
26201 and the executable file has the cap_sys_nice capability
26202 ("sudo /sbin/setcap cap_sys_nice=ep executable_file_name"),
26203 then ceiling locking is used.
26204 Otherwise, the @code{Ceiling_Locking} policy is ignored.
26205
26206 @node GNAT Implementation of Shared Passive Packages,Code Generation for Array Aggregates,GNAT Implementation of Tasking,Implementation of Specific Ada Features
26207 @anchor{gnat_rm/implementation_of_specific_ada_features id6}@anchor{420}@anchor{gnat_rm/implementation_of_specific_ada_features gnat-implementation-of-shared-passive-packages}@anchor{421}
26208 @section GNAT Implementation of Shared Passive Packages
26209
26210
26211 @geindex Shared passive packages
26212
26213 GNAT fully implements the
26214 @geindex pragma Shared_Passive
26215 pragma
26216 @code{Shared_Passive} for
26217 the purpose of designating shared passive packages.
26218 This allows the use of passive partitions in the
26219 context described in the Ada Reference Manual; i.e., for communication
26220 between separate partitions of a distributed application using the
26221 features in Annex E.
26222
26223 @geindex Annex E
26224
26225 @geindex Distribution Systems Annex
26226
26227 However, the implementation approach used by GNAT provides for more
26228 extensive usage as follows:
26229
26230
26231 @table @asis
26232
26233 @item @emph{Communication between separate programs}
26234
26235 This allows separate programs to access the data in passive
26236 partitions, using protected objects for synchronization where
26237 needed. The only requirement is that the two programs have a
26238 common shared file system. It is even possible for programs
26239 running on different machines with different architectures
26240 (e.g., different endianness) to communicate via the data in
26241 a passive partition.
26242
26243 @item @emph{Persistence between program runs}
26244
26245 The data in a passive package can persist from one run of a
26246 program to another, so that a later program sees the final
26247 values stored by a previous run of the same program.
26248 @end table
26249
26250 The implementation approach used is to store the data in files. A
26251 separate stream file is created for each object in the package, and
26252 an access to an object causes the corresponding file to be read or
26253 written.
26254
26255 @geindex SHARED_MEMORY_DIRECTORY environment variable
26256
26257 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
26258 set to the directory to be used for these files.
26259 The files in this directory
26260 have names that correspond to their fully qualified names. For
26261 example, if we have the package
26262
26263 @example
26264 package X is
26265 pragma Shared_Passive (X);
26266 Y : Integer;
26267 Z : Float;
26268 end X;
26269 @end example
26270
26271 and the environment variable is set to @code{/stemp/}, then the files created
26272 will have the names:
26273
26274 @example
26275 /stemp/x.y
26276 /stemp/x.z
26277 @end example
26278
26279 These files are created when a value is initially written to the object, and
26280 the files are retained until manually deleted. This provides the persistence
26281 semantics. If no file exists, it means that no partition has assigned a value
26282 to the variable; in this case the initial value declared in the package
26283 will be used. This model ensures that there are no issues in synchronizing
26284 the elaboration process, since elaboration of passive packages elaborates the
26285 initial values, but does not create the files.
26286
26287 The files are written using normal @code{Stream_IO} access.
26288 If you want to be able
26289 to communicate between programs or partitions running on different
26290 architectures, then you should use the XDR versions of the stream attribute
26291 routines, since these are architecture independent.
26292
26293 If active synchronization is required for access to the variables in the
26294 shared passive package, then as described in the Ada Reference Manual, the
26295 package may contain protected objects used for this purpose. In this case
26296 a lock file (whose name is @code{___lock} (three underscores)
26297 is created in the shared memory directory.
26298
26299 @geindex ___lock file (for shared passive packages)
26300
26301 This is used to provide the required locking
26302 semantics for proper protected object synchronization.
26303
26304 @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
26305 @anchor{gnat_rm/implementation_of_specific_ada_features code-generation-for-array-aggregates}@anchor{422}@anchor{gnat_rm/implementation_of_specific_ada_features id7}@anchor{423}
26306 @section Code Generation for Array Aggregates
26307
26308
26309 Aggregates have a rich syntax and allow the user to specify the values of
26310 complex data structures by means of a single construct. As a result, the
26311 code generated for aggregates can be quite complex and involve loops, case
26312 statements and multiple assignments. In the simplest cases, however, the
26313 compiler will recognize aggregates whose components and constraints are
26314 fully static, and in those cases the compiler will generate little or no
26315 executable code. The following is an outline of the code that GNAT generates
26316 for various aggregate constructs. For further details, you will find it
26317 useful to examine the output produced by the -gnatG flag to see the expanded
26318 source that is input to the code generator. You may also want to examine
26319 the assembly code generated at various levels of optimization.
26320
26321 The code generated for aggregates depends on the context, the component values,
26322 and the type. In the context of an object declaration the code generated is
26323 generally simpler than in the case of an assignment. As a general rule, static
26324 component values and static subtypes also lead to simpler code.
26325
26326 @menu
26327 * Static constant aggregates with static bounds::
26328 * Constant aggregates with unconstrained nominal types::
26329 * Aggregates with static bounds::
26330 * Aggregates with nonstatic bounds::
26331 * Aggregates in assignment statements::
26332
26333 @end menu
26334
26335 @node Static constant aggregates with static bounds,Constant aggregates with unconstrained nominal types,,Code Generation for Array Aggregates
26336 @anchor{gnat_rm/implementation_of_specific_ada_features static-constant-aggregates-with-static-bounds}@anchor{424}@anchor{gnat_rm/implementation_of_specific_ada_features id8}@anchor{425}
26337 @subsection Static constant aggregates with static bounds
26338
26339
26340 For the declarations:
26341
26342 @example
26343 type One_Dim is array (1..10) of integer;
26344 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
26345 @end example
26346
26347 GNAT generates no executable code: the constant ar0 is placed in static memory.
26348 The same is true for constant aggregates with named associations:
26349
26350 @example
26351 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
26352 Cr3 : constant One_Dim := (others => 7777);
26353 @end example
26354
26355 The same is true for multidimensional constant arrays such as:
26356
26357 @example
26358 type two_dim is array (1..3, 1..3) of integer;
26359 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
26360 @end example
26361
26362 The same is true for arrays of one-dimensional arrays: the following are
26363 static:
26364
26365 @example
26366 type ar1b is array (1..3) of boolean;
26367 type ar_ar is array (1..3) of ar1b;
26368 None : constant ar1b := (others => false); -- fully static
26369 None2 : constant ar_ar := (1..3 => None); -- fully static
26370 @end example
26371
26372 However, for multidimensional aggregates with named associations, GNAT will
26373 generate assignments and loops, even if all associations are static. The
26374 following two declarations generate a loop for the first dimension, and
26375 individual component assignments for the second dimension:
26376
26377 @example
26378 Zero1: constant two_dim := (1..3 => (1..3 => 0));
26379 Zero2: constant two_dim := (others => (others => 0));
26380 @end example
26381
26382 @node Constant aggregates with unconstrained nominal types,Aggregates with static bounds,Static constant aggregates with static bounds,Code Generation for Array Aggregates
26383 @anchor{gnat_rm/implementation_of_specific_ada_features constant-aggregates-with-unconstrained-nominal-types}@anchor{426}@anchor{gnat_rm/implementation_of_specific_ada_features id9}@anchor{427}
26384 @subsection Constant aggregates with unconstrained nominal types
26385
26386
26387 In such cases the aggregate itself establishes the subtype, so that
26388 associations with @code{others} cannot be used. GNAT determines the
26389 bounds for the actual subtype of the aggregate, and allocates the
26390 aggregate statically as well. No code is generated for the following:
26391
26392 @example
26393 type One_Unc is array (natural range <>) of integer;
26394 Cr_Unc : constant One_Unc := (12,24,36);
26395 @end example
26396
26397 @node Aggregates with static bounds,Aggregates with nonstatic bounds,Constant aggregates with unconstrained nominal types,Code Generation for Array Aggregates
26398 @anchor{gnat_rm/implementation_of_specific_ada_features id10}@anchor{428}@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-static-bounds}@anchor{429}
26399 @subsection Aggregates with static bounds
26400
26401
26402 In all previous examples the aggregate was the initial (and immutable) value
26403 of a constant. If the aggregate initializes a variable, then code is generated
26404 for it as a combination of individual assignments and loops over the target
26405 object. The declarations
26406
26407 @example
26408 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
26409 Cr_Var2 : One_Dim := (others > -1);
26410 @end example
26411
26412 generate the equivalent of
26413
26414 @example
26415 Cr_Var1 (1) := 2;
26416 Cr_Var1 (2) := 3;
26417 Cr_Var1 (3) := 5;
26418 Cr_Var1 (4) := 11;
26419
26420 for I in Cr_Var2'range loop
26421 Cr_Var2 (I) := -1;
26422 end loop;
26423 @end example
26424
26425 @node Aggregates with nonstatic bounds,Aggregates in assignment statements,Aggregates with static bounds,Code Generation for Array Aggregates
26426 @anchor{gnat_rm/implementation_of_specific_ada_features id11}@anchor{42a}@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-with-nonstatic-bounds}@anchor{42b}
26427 @subsection Aggregates with nonstatic bounds
26428
26429
26430 If the bounds of the aggregate are not statically compatible with the bounds
26431 of the nominal subtype of the target, then constraint checks have to be
26432 generated on the bounds. For a multidimensional array, constraint checks may
26433 have to be applied to sub-arrays individually, if they do not have statically
26434 compatible subtypes.
26435
26436 @node Aggregates in assignment statements,,Aggregates with nonstatic bounds,Code Generation for Array Aggregates
26437 @anchor{gnat_rm/implementation_of_specific_ada_features id12}@anchor{42c}@anchor{gnat_rm/implementation_of_specific_ada_features aggregates-in-assignment-statements}@anchor{42d}
26438 @subsection Aggregates in assignment statements
26439
26440
26441 In general, aggregate assignment requires the construction of a temporary,
26442 and a copy from the temporary to the target of the assignment. This is because
26443 it is not always possible to convert the assignment into a series of individual
26444 component assignments. For example, consider the simple case:
26445
26446 @example
26447 A := (A(2), A(1));
26448 @end example
26449
26450 This cannot be converted into:
26451
26452 @example
26453 A(1) := A(2);
26454 A(2) := A(1);
26455 @end example
26456
26457 So the aggregate has to be built first in a separate location, and then
26458 copied into the target. GNAT recognizes simple cases where this intermediate
26459 step is not required, and the assignments can be performed in place, directly
26460 into the target. The following sufficient criteria are applied:
26461
26462
26463 @itemize *
26464
26465 @item
26466 The bounds of the aggregate are static, and the associations are static.
26467
26468 @item
26469 The components of the aggregate are static constants, names of
26470 simple variables that are not renamings, or expressions not involving
26471 indexed components whose operands obey these rules.
26472 @end itemize
26473
26474 If any of these conditions are violated, the aggregate will be built in
26475 a temporary (created either by the front-end or the code generator) and then
26476 that temporary will be copied onto the target.
26477
26478 @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
26479 @anchor{gnat_rm/implementation_of_specific_ada_features id13}@anchor{42e}@anchor{gnat_rm/implementation_of_specific_ada_features the-size-of-discriminated-records-with-default-discriminants}@anchor{42f}
26480 @section The Size of Discriminated Records with Default Discriminants
26481
26482
26483 If a discriminated type @code{T} has discriminants with default values, it is
26484 possible to declare an object of this type without providing an explicit
26485 constraint:
26486
26487 @example
26488 type Size is range 1..100;
26489
26490 type Rec (D : Size := 15) is record
26491 Name : String (1..D);
26492 end T;
26493
26494 Word : Rec;
26495 @end example
26496
26497 Such an object is said to be @emph{unconstrained}.
26498 The discriminant of the object
26499 can be modified by a full assignment to the object, as long as it preserves the
26500 relation between the value of the discriminant, and the value of the components
26501 that depend on it:
26502
26503 @example
26504 Word := (3, "yes");
26505
26506 Word := (5, "maybe");
26507
26508 Word := (5, "no"); -- raises Constraint_Error
26509 @end example
26510
26511 In order to support this behavior efficiently, an unconstrained object is
26512 given the maximum size that any value of the type requires. In the case
26513 above, @code{Word} has storage for the discriminant and for
26514 a @code{String} of length 100.
26515 It is important to note that unconstrained objects do not require dynamic
26516 allocation. It would be an improper implementation to place on the heap those
26517 components whose size depends on discriminants. (This improper implementation
26518 was used by some Ada83 compilers, where the @code{Name} component above
26519 would have
26520 been stored as a pointer to a dynamic string). Following the principle that
26521 dynamic storage management should never be introduced implicitly,
26522 an Ada compiler should reserve the full size for an unconstrained declared
26523 object, and place it on the stack.
26524
26525 This maximum size approach
26526 has been a source of surprise to some users, who expect the default
26527 values of the discriminants to determine the size reserved for an
26528 unconstrained object: "If the default is 15, why should the object occupy
26529 a larger size?"
26530 The answer, of course, is that the discriminant may be later modified,
26531 and its full range of values must be taken into account. This is why the
26532 declaration:
26533
26534 @example
26535 type Rec (D : Positive := 15) is record
26536 Name : String (1..D);
26537 end record;
26538
26539 Too_Large : Rec;
26540 @end example
26541
26542 is flagged by the compiler with a warning:
26543 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
26544 because the required size includes @code{Positive'Last}
26545 bytes. As the first example indicates, the proper approach is to declare an
26546 index type of 'reasonable' range so that unconstrained objects are not too
26547 large.
26548
26549 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
26550 created in the heap by means of an allocator, then it is @emph{not}
26551 unconstrained:
26552 it is constrained by the default values of the discriminants, and those values
26553 cannot be modified by full assignment. This is because in the presence of
26554 aliasing all views of the object (which may be manipulated by different tasks,
26555 say) must be consistent, so it is imperative that the object, once created,
26556 remain invariant.
26557
26558 @node Strict Conformance to the Ada Reference Manual,,The Size of Discriminated Records with Default Discriminants,Implementation of Specific Ada Features
26559 @anchor{gnat_rm/implementation_of_specific_ada_features strict-conformance-to-the-ada-reference-manual}@anchor{430}@anchor{gnat_rm/implementation_of_specific_ada_features id14}@anchor{431}
26560 @section Strict Conformance to the Ada Reference Manual
26561
26562
26563 The dynamic semantics defined by the Ada Reference Manual impose a set of
26564 run-time checks to be generated. By default, the GNAT compiler will insert many
26565 run-time checks into the compiled code, including most of those required by the
26566 Ada Reference Manual. However, there are two checks that are not enabled in
26567 the default mode for efficiency reasons: checks for access before elaboration
26568 on subprogram calls, and stack overflow checking (most operating systems do not
26569 perform this check by default).
26570
26571 Strict conformance to the Ada Reference Manual can be achieved by adding two
26572 compiler options for dynamic checks for access-before-elaboration on subprogram
26573 calls and generic instantiations (@emph{-gnatE}), and stack overflow checking
26574 (@emph{-fstack-check}).
26575
26576 Note that the result of a floating point arithmetic operation in overflow and
26577 invalid situations, when the @code{Machine_Overflows} attribute of the result
26578 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
26579 case for machines compliant with the IEEE floating-point standard, but on
26580 machines that are not fully compliant with this standard, such as Alpha, the
26581 @emph{-mieee} compiler flag must be used for achieving IEEE confirming
26582 behavior (although at the cost of a significant performance penalty), so
26583 infinite and NaN values are properly generated.
26584
26585 @node Implementation of Ada 2012 Features,Obsolescent Features,Implementation of Specific Ada Features,Top
26586 @anchor{gnat_rm/implementation_of_ada_2012_features doc}@anchor{432}@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{433}
26587 @chapter Implementation of Ada 2012 Features
26588
26589
26590 @geindex Ada 2012 implementation status
26591
26592 @geindex -gnat12 option (gcc)
26593
26594 @geindex pragma Ada_2012
26595
26596 @geindex configuration pragma Ada_2012
26597
26598 @geindex Ada_2012 configuration pragma
26599
26600 This chapter contains a complete list of Ada 2012 features that have been
26601 implemented.
26602 Generally, these features are only
26603 available if the @emph{-gnat12} (Ada 2012 features enabled) option is set,
26604 which is the default behavior,
26605 or if the configuration pragma @code{Ada_2012} is used.
26606
26607 However, new pragmas, attributes, and restrictions are
26608 unconditionally available, since the Ada 95 standard allows the addition of
26609 new pragmas, attributes, and restrictions (there are exceptions, which are
26610 documented in the individual descriptions), and also certain packages
26611 were made available in earlier versions of Ada.
26612
26613 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
26614 This date shows the implementation date of the feature. Any wavefront
26615 subsequent to this date will contain the indicated feature, as will any
26616 subsequent releases. A date of 0000-00-00 means that GNAT has always
26617 implemented the feature, or implemented it as soon as it appeared as a
26618 binding interpretation.
26619
26620 Each feature corresponds to an Ada Issue ('AI') approved by the Ada
26621 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
26622 The features are ordered based on the relevant sections of the Ada
26623 Reference Manual ("RM"). When a given AI relates to multiple points
26624 in the RM, the earliest is used.
26625
26626 A complete description of the AIs may be found in
26627 @indicateurl{http://www.ada-auth.org/ai05-summary.html}.
26628
26629 @geindex AI-0176 (Ada 2012 feature)
26630
26631
26632 @itemize *
26633
26634 @item
26635 @emph{AI-0176 Quantified expressions (2010-09-29)}
26636
26637 Both universally and existentially quantified expressions are implemented.
26638 They use the new syntax for iterators proposed in AI05-139-2, as well as
26639 the standard Ada loop syntax.
26640
26641 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
26642 @end itemize
26643
26644 @geindex AI-0079 (Ada 2012 feature)
26645
26646
26647 @itemize *
26648
26649 @item
26650 @emph{AI-0079 Allow other_format characters in source (2010-07-10)}
26651
26652 Wide characters in the unicode category @emph{other_format} are now allowed in
26653 source programs between tokens, but not within a token such as an identifier.
26654
26655 RM References: 2.01 (4/2) 2.02 (7)
26656 @end itemize
26657
26658 @geindex AI-0091 (Ada 2012 feature)
26659
26660
26661 @itemize *
26662
26663 @item
26664 @emph{AI-0091 Do not allow other_format in identifiers (0000-00-00)}
26665
26666 Wide characters in the unicode category @emph{other_format} are not permitted
26667 within an identifier, since this can be a security problem. The error
26668 message for this case has been improved to be more specific, but GNAT has
26669 never allowed such characters to appear in identifiers.
26670
26671 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)
26672 @end itemize
26673
26674 @geindex AI-0100 (Ada 2012 feature)
26675
26676
26677 @itemize *
26678
26679 @item
26680 @emph{AI-0100 Placement of pragmas (2010-07-01)}
26681
26682 This AI is an earlier version of AI-163. It simplifies the rules
26683 for legal placement of pragmas. In the case of lists that allow pragmas, if
26684 the list may have no elements, then the list may consist solely of pragmas.
26685
26686 RM References: 2.08 (7)
26687 @end itemize
26688
26689 @geindex AI-0163 (Ada 2012 feature)
26690
26691
26692 @itemize *
26693
26694 @item
26695 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
26696
26697 A statement sequence may be composed entirely of pragmas. It is no longer
26698 necessary to add a dummy @code{null} statement to make the sequence legal.
26699
26700 RM References: 2.08 (7) 2.08 (16)
26701 @end itemize
26702
26703 @geindex AI-0080 (Ada 2012 feature)
26704
26705
26706 @itemize *
26707
26708 @item
26709 @emph{AI-0080 'View of' not needed if clear from context (0000-00-00)}
26710
26711 This is an editorial change only, described as non-testable in the AI.
26712
26713 RM References: 3.01 (7)
26714 @end itemize
26715
26716 @geindex AI-0183 (Ada 2012 feature)
26717
26718
26719 @itemize *
26720
26721 @item
26722 @emph{AI-0183 Aspect specifications (2010-08-16)}
26723
26724 Aspect specifications have been fully implemented except for pre and post-
26725 conditions, and type invariants, which have their own separate AI's. All
26726 forms of declarations listed in the AI are supported. The following is a
26727 list of the aspects supported (with GNAT implementation aspects marked)
26728 @end itemize
26729
26730
26731 @multitable {xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx} {xxxxxxxxxxxxx}
26732 @headitem
26733
26734 Supported Aspect
26735
26736 @tab
26737
26738 Source
26739
26740 @item
26741
26742 @code{Ada_2005}
26743
26744 @tab
26745
26746 -- GNAT
26747
26748 @item
26749
26750 @code{Ada_2012}
26751
26752 @tab
26753
26754 -- GNAT
26755
26756 @item
26757
26758 @code{Address}
26759
26760 @tab
26761
26762 @item
26763
26764 @code{Alignment}
26765
26766 @tab
26767
26768 @item
26769
26770 @code{Atomic}
26771
26772 @tab
26773
26774 @item
26775
26776 @code{Atomic_Components}
26777
26778 @tab
26779
26780 @item
26781
26782 @code{Bit_Order}
26783
26784 @tab
26785
26786 @item
26787
26788 @code{Component_Size}
26789
26790 @tab
26791
26792 @item
26793
26794 @code{Contract_Cases}
26795
26796 @tab
26797
26798 -- GNAT
26799
26800 @item
26801
26802 @code{Discard_Names}
26803
26804 @tab
26805
26806 @item
26807
26808 @code{External_Tag}
26809
26810 @tab
26811
26812 @item
26813
26814 @code{Favor_Top_Level}
26815
26816 @tab
26817
26818 -- GNAT
26819
26820 @item
26821
26822 @code{Inline}
26823
26824 @tab
26825
26826 @item
26827
26828 @code{Inline_Always}
26829
26830 @tab
26831
26832 -- GNAT
26833
26834 @item
26835
26836 @code{Invariant}
26837
26838 @tab
26839
26840 -- GNAT
26841
26842 @item
26843
26844 @code{Machine_Radix}
26845
26846 @tab
26847
26848 @item
26849
26850 @code{No_Return}
26851
26852 @tab
26853
26854 @item
26855
26856 @code{Object_Size}
26857
26858 @tab
26859
26860 -- GNAT
26861
26862 @item
26863
26864 @code{Pack}
26865
26866 @tab
26867
26868 @item
26869
26870 @code{Persistent_BSS}
26871
26872 @tab
26873
26874 -- GNAT
26875
26876 @item
26877
26878 @code{Post}
26879
26880 @tab
26881
26882 @item
26883
26884 @code{Pre}
26885
26886 @tab
26887
26888 @item
26889
26890 @code{Predicate}
26891
26892 @tab
26893
26894 @item
26895
26896 @code{Preelaborable_Initialization}
26897
26898 @tab
26899
26900 @item
26901
26902 @code{Pure_Function}
26903
26904 @tab
26905
26906 -- GNAT
26907
26908 @item
26909
26910 @code{Remote_Access_Type}
26911
26912 @tab
26913
26914 -- GNAT
26915
26916 @item
26917
26918 @code{Shared}
26919
26920 @tab
26921
26922 -- GNAT
26923
26924 @item
26925
26926 @code{Size}
26927
26928 @tab
26929
26930 @item
26931
26932 @code{Storage_Pool}
26933
26934 @tab
26935
26936 @item
26937
26938 @code{Storage_Size}
26939
26940 @tab
26941
26942 @item
26943
26944 @code{Stream_Size}
26945
26946 @tab
26947
26948 @item
26949
26950 @code{Suppress}
26951
26952 @tab
26953
26954 @item
26955
26956 @code{Suppress_Debug_Info}
26957
26958 @tab
26959
26960 -- GNAT
26961
26962 @item
26963
26964 @code{Test_Case}
26965
26966 @tab
26967
26968 -- GNAT
26969
26970 @item
26971
26972 @code{Thread_Local_Storage}
26973
26974 @tab
26975
26976 -- GNAT
26977
26978 @item
26979
26980 @code{Type_Invariant}
26981
26982 @tab
26983
26984 @item
26985
26986 @code{Unchecked_Union}
26987
26988 @tab
26989
26990 @item
26991
26992 @code{Universal_Aliasing}
26993
26994 @tab
26995
26996 -- GNAT
26997
26998 @item
26999
27000 @code{Unmodified}
27001
27002 @tab
27003
27004 -- GNAT
27005
27006 @item
27007
27008 @code{Unreferenced}
27009
27010 @tab
27011
27012 -- GNAT
27013
27014 @item
27015
27016 @code{Unreferenced_Objects}
27017
27018 @tab
27019
27020 -- GNAT
27021
27022 @item
27023
27024 @code{Unsuppress}
27025
27026 @tab
27027
27028 @item
27029
27030 @code{Value_Size}
27031
27032 @tab
27033
27034 -- GNAT
27035
27036 @item
27037
27038 @code{Volatile}
27039
27040 @tab
27041
27042 @item
27043
27044 @code{Volatile_Components}
27045
27046 @tab
27047
27048 @item
27049
27050 @code{Warnings}
27051
27052 @tab
27053
27054 -- GNAT
27055
27056 @end multitable
27057
27058
27059 @quotation
27060
27061 Note that for aspects with an expression, e.g. @code{Size}, the expression is
27062 treated like a default expression (visibility is analyzed at the point of
27063 occurrence of the aspect, but evaluation of the expression occurs at the
27064 freeze point of the entity involved).
27065
27066 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
27067 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
27068 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
27069 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
27070 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
27071 13.03.01 (0)
27072 @end quotation
27073
27074 @geindex AI-0128 (Ada 2012 feature)
27075
27076
27077 @itemize *
27078
27079 @item
27080 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
27081
27082 If an equality operator ("=") is declared for a type, then the implicitly
27083 declared inequality operator ("/=") is a primitive operation of the type.
27084 This is the only reasonable interpretation, and is the one always implemented
27085 by GNAT, but the RM was not entirely clear in making this point.
27086
27087 RM References: 3.02.03 (6) 6.06 (6)
27088 @end itemize
27089
27090 @geindex AI-0003 (Ada 2012 feature)
27091
27092
27093 @itemize *
27094
27095 @item
27096 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
27097
27098 In Ada 2012, a qualified expression is considered to be syntactically a name,
27099 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
27100 useful in disambiguating some cases of overloading.
27101
27102 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
27103 5.04 (7)
27104 @end itemize
27105
27106 @geindex AI-0120 (Ada 2012 feature)
27107
27108
27109 @itemize *
27110
27111 @item
27112 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
27113
27114 This is an RM editorial change only. The section that lists objects that are
27115 constant failed to include the current instance of a protected object
27116 within a protected function. This has always been treated as a constant
27117 in GNAT.
27118
27119 RM References: 3.03 (21)
27120 @end itemize
27121
27122 @geindex AI-0008 (Ada 2012 feature)
27123
27124
27125 @itemize *
27126
27127 @item
27128 @emph{AI-0008 General access to constrained objects (0000-00-00)}
27129
27130 The wording in the RM implied that if you have a general access to a
27131 constrained object, it could be used to modify the discriminants. This was
27132 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
27133 has always done so in this situation.
27134
27135 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
27136 @end itemize
27137
27138 @geindex AI-0093 (Ada 2012 feature)
27139
27140
27141 @itemize *
27142
27143 @item
27144 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
27145
27146 This is an editorial change only, to make more widespread use of the Ada 2012
27147 'immutably limited'.
27148
27149 RM References: 3.03 (23.4/3)
27150 @end itemize
27151
27152 @geindex AI-0096 (Ada 2012 feature)
27153
27154
27155 @itemize *
27156
27157 @item
27158 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
27159
27160 In general it is illegal for a type derived from a formal limited type to be
27161 nonlimited. This AI makes an exception to this rule: derivation is legal
27162 if it appears in the private part of the generic, and the formal type is not
27163 tagged. If the type is tagged, the legality check must be applied to the
27164 private part of the package.
27165
27166 RM References: 3.04 (5.1/2) 6.02 (7)
27167 @end itemize
27168
27169 @geindex AI-0181 (Ada 2012 feature)
27170
27171
27172 @itemize *
27173
27174 @item
27175 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
27176
27177 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
27178 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
27179 @code{Image} and @code{Value} attributes for the character types. Strictly
27180 speaking this is an inconsistency with Ada 95, but in practice the use of
27181 these attributes is so obscure that it will not cause problems.
27182
27183 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
27184 @end itemize
27185
27186 @geindex AI-0182 (Ada 2012 feature)
27187
27188
27189 @itemize *
27190
27191 @item
27192 @emph{AI-0182 Additional forms for} @code{Character'Value} @emph{(0000-00-00)}
27193
27194 This AI allows @code{Character'Value} to accept the string @code{'?'} where
27195 @code{?} is any character including non-graphic control characters. GNAT has
27196 always accepted such strings. It also allows strings such as
27197 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
27198 permission and raises @code{Constraint_Error}, as is certainly still
27199 permitted.
27200
27201 RM References: 3.05 (56/2)
27202 @end itemize
27203
27204 @geindex AI-0214 (Ada 2012 feature)
27205
27206
27207 @itemize *
27208
27209 @item
27210 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
27211
27212 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
27213 to have default expressions by allowing them when the type is limited. It
27214 is often useful to define a default value for a discriminant even though
27215 it can't be changed by assignment.
27216
27217 RM References: 3.07 (9.1/2) 3.07.02 (3)
27218 @end itemize
27219
27220 @geindex AI-0102 (Ada 2012 feature)
27221
27222
27223 @itemize *
27224
27225 @item
27226 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
27227
27228 It is illegal to assign an anonymous access constant to an anonymous access
27229 variable. The RM did not have a clear rule to prevent this, but GNAT has
27230 always generated an error for this usage.
27231
27232 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
27233 @end itemize
27234
27235 @geindex AI-0158 (Ada 2012 feature)
27236
27237
27238 @itemize *
27239
27240 @item
27241 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
27242
27243 This AI extends the syntax of membership tests to simplify complex conditions
27244 that can be expressed as membership in a subset of values of any type. It
27245 introduces syntax for a list of expressions that may be used in loop contexts
27246 as well.
27247
27248 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
27249 @end itemize
27250
27251 @geindex AI-0173 (Ada 2012 feature)
27252
27253
27254 @itemize *
27255
27256 @item
27257 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
27258
27259 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
27260 with the tag of an abstract type, and @code{False} otherwise.
27261
27262 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
27263 @end itemize
27264
27265 @geindex AI-0076 (Ada 2012 feature)
27266
27267
27268 @itemize *
27269
27270 @item
27271 @emph{AI-0076 function with controlling result (0000-00-00)}
27272
27273 This is an editorial change only. The RM defines calls with controlling
27274 results, but uses the term 'function with controlling result' without an
27275 explicit definition.
27276
27277 RM References: 3.09.02 (2/2)
27278 @end itemize
27279
27280 @geindex AI-0126 (Ada 2012 feature)
27281
27282
27283 @itemize *
27284
27285 @item
27286 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
27287
27288 This AI clarifies dispatching rules, and simply confirms that dispatching
27289 executes the operation of the parent type when there is no explicitly or
27290 implicitly declared operation for the descendant type. This has always been
27291 the case in all versions of GNAT.
27292
27293 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
27294 @end itemize
27295
27296 @geindex AI-0097 (Ada 2012 feature)
27297
27298
27299 @itemize *
27300
27301 @item
27302 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
27303
27304 The RM as written implied that in some cases it was possible to create an
27305 object of an abstract type, by having an abstract extension inherit a non-
27306 abstract constructor from its parent type. This mistake has been corrected
27307 in GNAT and in the RM, and this construct is now illegal.
27308
27309 RM References: 3.09.03 (4/2)
27310 @end itemize
27311
27312 @geindex AI-0203 (Ada 2012 feature)
27313
27314
27315 @itemize *
27316
27317 @item
27318 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
27319
27320 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
27321 permitted such usage.
27322
27323 RM References: 3.09.03 (8/3)
27324 @end itemize
27325
27326 @geindex AI-0198 (Ada 2012 feature)
27327
27328
27329 @itemize *
27330
27331 @item
27332 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
27333
27334 This AI resolves a conflict between two rules involving inherited abstract
27335 operations and predefined operators. If a derived numeric type inherits
27336 an abstract operator, it overrides the predefined one. This interpretation
27337 was always the one implemented in GNAT.
27338
27339 RM References: 3.09.03 (4/3)
27340 @end itemize
27341
27342 @geindex AI-0073 (Ada 2012 feature)
27343
27344
27345 @itemize *
27346
27347 @item
27348 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
27349
27350 This AI covers a number of issues regarding returning abstract types. In
27351 particular generic functions cannot have abstract result types or access
27352 result types designated an abstract type. There are some other cases which
27353 are detailed in the AI. Note that this binding interpretation has not been
27354 retrofitted to operate before Ada 2012 mode, since it caused a significant
27355 number of regressions.
27356
27357 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
27358 @end itemize
27359
27360 @geindex AI-0070 (Ada 2012 feature)
27361
27362
27363 @itemize *
27364
27365 @item
27366 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
27367
27368 This is an editorial change only, there are no testable consequences short of
27369 checking for the absence of generated code for an interface declaration.
27370
27371 RM References: 3.09.04 (18/2)
27372 @end itemize
27373
27374 @geindex AI-0208 (Ada 2012 feature)
27375
27376
27377 @itemize *
27378
27379 @item
27380 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
27381
27382 The wording in the Ada 2005 RM concerning characteristics of incomplete views
27383 was incorrect and implied that some programs intended to be legal were now
27384 illegal. GNAT had never considered such programs illegal, so it has always
27385 implemented the intent of this AI.
27386
27387 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
27388 @end itemize
27389
27390 @geindex AI-0162 (Ada 2012 feature)
27391
27392
27393 @itemize *
27394
27395 @item
27396 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
27397
27398 Incomplete types are made more useful by allowing them to be completed by
27399 private types and private extensions.
27400
27401 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
27402 @end itemize
27403
27404 @geindex AI-0098 (Ada 2012 feature)
27405
27406
27407 @itemize *
27408
27409 @item
27410 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
27411
27412 An unintentional omission in the RM implied some inconsistent restrictions on
27413 the use of anonymous access to subprogram values. These restrictions were not
27414 intentional, and have never been enforced by GNAT.
27415
27416 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
27417 @end itemize
27418
27419 @geindex AI-0199 (Ada 2012 feature)
27420
27421
27422 @itemize *
27423
27424 @item
27425 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
27426
27427 A choice list in a record aggregate can include several components of
27428 (distinct) anonymous access types as long as they have matching designated
27429 subtypes.
27430
27431 RM References: 4.03.01 (16)
27432 @end itemize
27433
27434 @geindex AI-0220 (Ada 2012 feature)
27435
27436
27437 @itemize *
27438
27439 @item
27440 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
27441
27442 This AI addresses a wording problem in the RM that appears to permit some
27443 complex cases of aggregates with nonstatic discriminants. GNAT has always
27444 implemented the intended semantics.
27445
27446 RM References: 4.03.01 (17)
27447 @end itemize
27448
27449 @geindex AI-0147 (Ada 2012 feature)
27450
27451
27452 @itemize *
27453
27454 @item
27455 @emph{AI-0147 Conditional expressions (2009-03-29)}
27456
27457 Conditional expressions are permitted. The form of such an expression is:
27458
27459 @example
27460 (if expr then expr @{elsif expr then expr@} [else expr])
27461 @end example
27462
27463 The parentheses can be omitted in contexts where parentheses are present
27464 anyway, such as subprogram arguments and pragma arguments. If the @strong{else}
27465 clause is omitted, @strong{else} @emph{True} is assumed;
27466 thus @code{(if A then B)} is a way to conveniently represent
27467 @emph{(A implies B)} in standard logic.
27468
27469 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
27470 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
27471 @end itemize
27472
27473 @geindex AI-0037 (Ada 2012 feature)
27474
27475
27476 @itemize *
27477
27478 @item
27479 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
27480
27481 This AI confirms that an association of the form @code{Indx => <>} in an
27482 array aggregate must raise @code{Constraint_Error} if @code{Indx}
27483 is out of range. The RM specified a range check on other associations, but
27484 not when the value of the association was defaulted. GNAT has always inserted
27485 a constraint check on the index value.
27486
27487 RM References: 4.03.03 (29)
27488 @end itemize
27489
27490 @geindex AI-0123 (Ada 2012 feature)
27491
27492
27493 @itemize *
27494
27495 @item
27496 @emph{AI-0123 Composability of equality (2010-04-13)}
27497
27498 Equality of untagged record composes, so that the predefined equality for a
27499 composite type that includes a component of some untagged record type
27500 @code{R} uses the equality operation of @code{R} (which may be user-defined
27501 or predefined). This makes the behavior of untagged records identical to that
27502 of tagged types in this respect.
27503
27504 This change is an incompatibility with previous versions of Ada, but it
27505 corrects a non-uniformity that was often a source of confusion. Analysis of
27506 a large number of industrial programs indicates that in those rare cases
27507 where a composite type had an untagged record component with a user-defined
27508 equality, either there was no use of the composite equality, or else the code
27509 expected the same composability as for tagged types, and thus had a bug that
27510 would be fixed by this change.
27511
27512 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
27513 8.05.04 (8)
27514 @end itemize
27515
27516 @geindex AI-0088 (Ada 2012 feature)
27517
27518
27519 @itemize *
27520
27521 @item
27522 @emph{AI-0088 The value of exponentiation (0000-00-00)}
27523
27524 This AI clarifies the equivalence rule given for the dynamic semantics of
27525 exponentiation: the value of the operation can be obtained by repeated
27526 multiplication, but the operation can be implemented otherwise (for example
27527 using the familiar divide-by-two-and-square algorithm, even if this is less
27528 accurate), and does not imply repeated reads of a volatile base.
27529
27530 RM References: 4.05.06 (11)
27531 @end itemize
27532
27533 @geindex AI-0188 (Ada 2012 feature)
27534
27535
27536 @itemize *
27537
27538 @item
27539 @emph{AI-0188 Case expressions (2010-01-09)}
27540
27541 Case expressions are permitted. This allows use of constructs such as:
27542
27543 @example
27544 X := (case Y is when 1 => 2, when 2 => 3, when others => 31)
27545 @end example
27546
27547 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
27548 @end itemize
27549
27550 @geindex AI-0104 (Ada 2012 feature)
27551
27552
27553 @itemize *
27554
27555 @item
27556 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
27557
27558 The assignment @code{Ptr := new not null Some_Ptr;} will raise
27559 @code{Constraint_Error} because the default value of the allocated object is
27560 @strong{null}. This useless construct is illegal in Ada 2012.
27561
27562 RM References: 4.08 (2)
27563 @end itemize
27564
27565 @geindex AI-0157 (Ada 2012 feature)
27566
27567
27568 @itemize *
27569
27570 @item
27571 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
27572
27573 Allocation and Deallocation from an empty storage pool (i.e. allocation or
27574 deallocation of a pointer for which a static storage size clause of zero
27575 has been given) is now illegal and is detected as such. GNAT
27576 previously gave a warning but not an error.
27577
27578 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
27579 @end itemize
27580
27581 @geindex AI-0179 (Ada 2012 feature)
27582
27583
27584 @itemize *
27585
27586 @item
27587 @emph{AI-0179 Statement not required after label (2010-04-10)}
27588
27589 It is not necessary to have a statement following a label, so a label
27590 can appear at the end of a statement sequence without the need for putting a
27591 null statement afterwards, but it is not allowable to have only labels and
27592 no real statements in a statement sequence.
27593
27594 RM References: 5.01 (2)
27595 @end itemize
27596
27597 @geindex AI-0139-2 (Ada 2012 feature)
27598
27599
27600 @itemize *
27601
27602 @item
27603 @emph{AI-0139-2 Syntactic sugar for iterators (2010-09-29)}
27604
27605 The new syntax for iterating over arrays and containers is now implemented.
27606 Iteration over containers is for now limited to read-only iterators. Only
27607 default iterators are supported, with the syntax: @code{for Elem of C}.
27608
27609 RM References: 5.05
27610 @end itemize
27611
27612 @geindex AI-0134 (Ada 2012 feature)
27613
27614
27615 @itemize *
27616
27617 @item
27618 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
27619
27620 For full conformance, the profiles of anonymous-access-to-subprogram
27621 parameters must match. GNAT has always enforced this rule.
27622
27623 RM References: 6.03.01 (18)
27624 @end itemize
27625
27626 @geindex AI-0207 (Ada 2012 feature)
27627
27628
27629 @itemize *
27630
27631 @item
27632 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
27633
27634 This AI confirms that access_to_constant indication must match for mode
27635 conformance. This was implemented in GNAT when the qualifier was originally
27636 introduced in Ada 2005.
27637
27638 RM References: 6.03.01 (16/2)
27639 @end itemize
27640
27641 @geindex AI-0046 (Ada 2012 feature)
27642
27643
27644 @itemize *
27645
27646 @item
27647 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
27648
27649 For full conformance, in the case of access parameters, the null exclusion
27650 must match (either both or neither must have @code{not null}).
27651
27652 RM References: 6.03.02 (18)
27653 @end itemize
27654
27655 @geindex AI-0118 (Ada 2012 feature)
27656
27657
27658 @itemize *
27659
27660 @item
27661 @emph{AI-0118 The association of parameter associations (0000-00-00)}
27662
27663 This AI clarifies the rules for named associations in subprogram calls and
27664 generic instantiations. The rules have been in place since Ada 83.
27665
27666 RM References: 6.04.01 (2) 12.03 (9)
27667 @end itemize
27668
27669 @geindex AI-0196 (Ada 2012 feature)
27670
27671
27672 @itemize *
27673
27674 @item
27675 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
27676
27677 Null exclusion checks are not made for @code{out} parameters when
27678 evaluating the actual parameters. GNAT has never generated these checks.
27679
27680 RM References: 6.04.01 (13)
27681 @end itemize
27682
27683 @geindex AI-0015 (Ada 2012 feature)
27684
27685
27686 @itemize *
27687
27688 @item
27689 @emph{AI-0015 Constant return objects (0000-00-00)}
27690
27691 The return object declared in an @emph{extended_return_statement} may be
27692 declared constant. This was always intended, and GNAT has always allowed it.
27693
27694 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
27695 6.05 (5.7/2)
27696 @end itemize
27697
27698 @geindex AI-0032 (Ada 2012 feature)
27699
27700
27701 @itemize *
27702
27703 @item
27704 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
27705
27706 If a function returns a class-wide type, the object of an extended return
27707 statement can be declared with a specific type that is covered by the class-
27708 wide type. This has been implemented in GNAT since the introduction of
27709 extended returns. Note AI-0103 complements this AI by imposing matching
27710 rules for constrained return types.
27711
27712 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
27713 6.05 (8/2)
27714 @end itemize
27715
27716 @geindex AI-0103 (Ada 2012 feature)
27717
27718
27719 @itemize *
27720
27721 @item
27722 @emph{AI-0103 Static matching for extended return (2010-07-23)}
27723
27724 If the return subtype of a function is an elementary type or a constrained
27725 type, the subtype indication in an extended return statement must match
27726 statically this return subtype.
27727
27728 RM References: 6.05 (5.2/2)
27729 @end itemize
27730
27731 @geindex AI-0058 (Ada 2012 feature)
27732
27733
27734 @itemize *
27735
27736 @item
27737 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
27738
27739 The RM had some incorrect wording implying wrong treatment of abnormal
27740 completion in an extended return. GNAT has always implemented the intended
27741 correct semantics as described by this AI.
27742
27743 RM References: 6.05 (22/2)
27744 @end itemize
27745
27746 @geindex AI-0050 (Ada 2012 feature)
27747
27748
27749 @itemize *
27750
27751 @item
27752 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
27753
27754 The implementation permissions for raising @code{Constraint_Error} early on a function call
27755 when it was clear an exception would be raised were over-permissive and allowed
27756 mishandling of discriminants in some cases. GNAT did
27757 not take advantage of these incorrect permissions in any case.
27758
27759 RM References: 6.05 (24/2)
27760 @end itemize
27761
27762 @geindex AI-0125 (Ada 2012 feature)
27763
27764
27765 @itemize *
27766
27767 @item
27768 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
27769
27770 In Ada 2012, the declaration of a primitive operation of a type extension
27771 or private extension can also override an inherited primitive that is not
27772 visible at the point of this declaration.
27773
27774 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
27775 @end itemize
27776
27777 @geindex AI-0062 (Ada 2012 feature)
27778
27779
27780 @itemize *
27781
27782 @item
27783 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
27784
27785 A full constant may have a null exclusion even if its associated deferred
27786 constant does not. GNAT has always allowed this.
27787
27788 RM References: 7.04 (6/2) 7.04 (7.1/2)
27789 @end itemize
27790
27791 @geindex AI-0178 (Ada 2012 feature)
27792
27793
27794 @itemize *
27795
27796 @item
27797 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
27798
27799 This AI clarifies the role of incomplete views and plugs an omission in the
27800 RM. GNAT always correctly restricted the use of incomplete views and types.
27801
27802 RM References: 7.05 (3/2) 7.05 (6/2)
27803 @end itemize
27804
27805 @geindex AI-0087 (Ada 2012 feature)
27806
27807
27808 @itemize *
27809
27810 @item
27811 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
27812
27813 The actual for a formal nonlimited derived type cannot be limited. In
27814 particular, a formal derived type that extends a limited interface but which
27815 is not explicitly limited cannot be instantiated with a limited type.
27816
27817 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
27818 @end itemize
27819
27820 @geindex AI-0099 (Ada 2012 feature)
27821
27822
27823 @itemize *
27824
27825 @item
27826 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
27827
27828 This AI clarifies that 'needs finalization' is part of dynamic semantics,
27829 and therefore depends on the run-time characteristics of an object (i.e. its
27830 tag) and not on its nominal type. As the AI indicates: "we do not expect
27831 this to affect any implementation'@w{'}.
27832
27833 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
27834 @end itemize
27835
27836 @geindex AI-0064 (Ada 2012 feature)
27837
27838
27839 @itemize *
27840
27841 @item
27842 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
27843
27844 This is an editorial change only. The intended behavior is already checked
27845 by an existing ACATS test, which GNAT has always executed correctly.
27846
27847 RM References: 7.06.01 (17.1/1)
27848 @end itemize
27849
27850 @geindex AI-0026 (Ada 2012 feature)
27851
27852
27853 @itemize *
27854
27855 @item
27856 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
27857
27858 Record representation clauses concerning Unchecked_Union types cannot mention
27859 the discriminant of the type. The type of a component declared in the variant
27860 part of an Unchecked_Union cannot be controlled, have controlled components,
27861 nor have protected or task parts. If an Unchecked_Union type is declared
27862 within the body of a generic unit or its descendants, then the type of a
27863 component declared in the variant part cannot be a formal private type or a
27864 formal private extension declared within the same generic unit.
27865
27866 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
27867 @end itemize
27868
27869 @geindex AI-0205 (Ada 2012 feature)
27870
27871
27872 @itemize *
27873
27874 @item
27875 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
27876
27877 This AI corrects a simple omission in the RM. Return objects have always
27878 been visible within an extended return statement.
27879
27880 RM References: 8.03 (17)
27881 @end itemize
27882
27883 @geindex AI-0042 (Ada 2012 feature)
27884
27885
27886 @itemize *
27887
27888 @item
27889 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
27890
27891 This AI fixes a wording gap in the RM. An operation of a synchronized
27892 interface can be implemented by a protected or task entry, but the abstract
27893 operation is not being overridden in the usual sense, and it must be stated
27894 separately that this implementation is legal. This has always been the case
27895 in GNAT.
27896
27897 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
27898 @end itemize
27899
27900 @geindex AI-0030 (Ada 2012 feature)
27901
27902
27903 @itemize *
27904
27905 @item
27906 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
27907
27908 Requeue is permitted to a protected, synchronized or task interface primitive
27909 providing it is known that the overriding operation is an entry. Otherwise
27910 the requeue statement has the same effect as a procedure call. Use of pragma
27911 @code{Implemented} provides a way to impose a static requirement on the
27912 overriding operation by adhering to one of the implementation kinds: entry,
27913 protected procedure or any of the above.
27914
27915 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
27916 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
27917 @end itemize
27918
27919 @geindex AI-0201 (Ada 2012 feature)
27920
27921
27922 @itemize *
27923
27924 @item
27925 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
27926
27927 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
27928 attribute, then individual components may not be addressable by independent
27929 tasks. However, if the representation clause has no effect (is confirming),
27930 then independence is not compromised. Furthermore, in GNAT, specification of
27931 other appropriately addressable component sizes (e.g. 16 for 8-bit
27932 characters) also preserves independence. GNAT now gives very clear warnings
27933 both for the declaration of such a type, and for any assignment to its components.
27934
27935 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
27936 @end itemize
27937
27938 @geindex AI-0009 (Ada 2012 feature)
27939
27940
27941 @itemize *
27942
27943 @item
27944 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
27945
27946 This AI introduces the new pragmas @code{Independent} and
27947 @code{Independent_Components},
27948 which control guaranteeing independence of access to objects and components.
27949 The AI also requires independence not unaffected by confirming rep clauses.
27950
27951 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
27952 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
27953 @end itemize
27954
27955 @geindex AI-0072 (Ada 2012 feature)
27956
27957
27958 @itemize *
27959
27960 @item
27961 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
27962
27963 This AI clarifies that task signalling for reading @code{'Terminated} only
27964 occurs if the result is True. GNAT semantics has always been consistent with
27965 this notion of task signalling.
27966
27967 RM References: 9.10 (6.1/1)
27968 @end itemize
27969
27970 @geindex AI-0108 (Ada 2012 feature)
27971
27972
27973 @itemize *
27974
27975 @item
27976 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
27977
27978 This AI confirms that an incomplete type from a limited view does not have
27979 discriminants. This has always been the case in GNAT.
27980
27981 RM References: 10.01.01 (12.3/2)
27982 @end itemize
27983
27984 @geindex AI-0129 (Ada 2012 feature)
27985
27986
27987 @itemize *
27988
27989 @item
27990 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
27991
27992 This AI clarifies the description of limited views: a limited view of a
27993 package includes only one view of a type that has an incomplete declaration
27994 and a full declaration (there is no possible ambiguity in a client package).
27995 This AI also fixes an omission: a nested package in the private part has no
27996 limited view. GNAT always implemented this correctly.
27997
27998 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
27999 @end itemize
28000
28001 @geindex AI-0077 (Ada 2012 feature)
28002
28003
28004 @itemize *
28005
28006 @item
28007 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
28008
28009 This AI clarifies that a declaration does not include a context clause,
28010 and confirms that it is illegal to have a context in which both a limited
28011 and a nonlimited view of a package are accessible. Such double visibility
28012 was always rejected by GNAT.
28013
28014 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
28015 @end itemize
28016
28017 @geindex AI-0122 (Ada 2012 feature)
28018
28019
28020 @itemize *
28021
28022 @item
28023 @emph{AI-0122 Private with and children of generics (0000-00-00)}
28024
28025 This AI clarifies the visibility of private children of generic units within
28026 instantiations of a parent. GNAT has always handled this correctly.
28027
28028 RM References: 10.01.02 (12/2)
28029 @end itemize
28030
28031 @geindex AI-0040 (Ada 2012 feature)
28032
28033
28034 @itemize *
28035
28036 @item
28037 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
28038
28039 This AI confirms that a limited with clause in a child unit cannot name
28040 an ancestor of the unit. This has always been checked in GNAT.
28041
28042 RM References: 10.01.02 (20/2)
28043 @end itemize
28044
28045 @geindex AI-0132 (Ada 2012 feature)
28046
28047
28048 @itemize *
28049
28050 @item
28051 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
28052
28053 This AI fills a gap in the description of library unit pragmas. The pragma
28054 clearly must apply to a library unit, even if it does not carry the name
28055 of the enclosing unit. GNAT has always enforced the required check.
28056
28057 RM References: 10.01.05 (7)
28058 @end itemize
28059
28060 @geindex AI-0034 (Ada 2012 feature)
28061
28062
28063 @itemize *
28064
28065 @item
28066 @emph{AI-0034 Categorization of limited views (0000-00-00)}
28067
28068 The RM makes certain limited with clauses illegal because of categorization
28069 considerations, when the corresponding normal with would be legal. This is
28070 not intended, and GNAT has always implemented the recommended behavior.
28071
28072 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
28073 @end itemize
28074
28075 @geindex AI-0035 (Ada 2012 feature)
28076
28077
28078 @itemize *
28079
28080 @item
28081 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
28082
28083 This AI remedies some inconsistencies in the legality rules for Pure units.
28084 Derived access types are legal in a pure unit (on the assumption that the
28085 rule for a zero storage pool size has been enforced on the ancestor type).
28086 The rules are enforced in generic instances and in subunits. GNAT has always
28087 implemented the recommended behavior.
28088
28089 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)
28090 @end itemize
28091
28092 @geindex AI-0219 (Ada 2012 feature)
28093
28094
28095 @itemize *
28096
28097 @item
28098 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
28099
28100 This AI refines the rules for the cases with limited parameters which do not
28101 allow the implementations to omit 'redundant'. GNAT now properly conforms
28102 to the requirements of this binding interpretation.
28103
28104 RM References: 10.02.01 (18/2)
28105 @end itemize
28106
28107 @geindex AI-0043 (Ada 2012 feature)
28108
28109
28110 @itemize *
28111
28112 @item
28113 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
28114
28115 This AI covers various omissions in the RM regarding the raising of
28116 exceptions. GNAT has always implemented the intended semantics.
28117
28118 RM References: 11.04.01 (10.1/2) 11 (2)
28119 @end itemize
28120
28121 @geindex AI-0200 (Ada 2012 feature)
28122
28123
28124 @itemize *
28125
28126 @item
28127 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
28128
28129 This AI plugs a gap in the RM which appeared to allow some obviously intended
28130 illegal instantiations. GNAT has never allowed these instantiations.
28131
28132 RM References: 12.07 (16)
28133 @end itemize
28134
28135 @geindex AI-0112 (Ada 2012 feature)
28136
28137
28138 @itemize *
28139
28140 @item
28141 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
28142
28143 This AI concerns giving names to various representation aspects, but the
28144 practical effect is simply to make the use of duplicate
28145 @code{Atomic[_Components]},
28146 @code{Volatile[_Components]}, and
28147 @code{Independent[_Components]} pragmas illegal, and GNAT
28148 now performs this required check.
28149
28150 RM References: 13.01 (8)
28151 @end itemize
28152
28153 @geindex AI-0106 (Ada 2012 feature)
28154
28155
28156 @itemize *
28157
28158 @item
28159 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
28160
28161 The RM appeared to allow representation pragmas on generic formal parameters,
28162 but this was not intended, and GNAT has never permitted this usage.
28163
28164 RM References: 13.01 (9.1/1)
28165 @end itemize
28166
28167 @geindex AI-0012 (Ada 2012 feature)
28168
28169
28170 @itemize *
28171
28172 @item
28173 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
28174
28175 It is now illegal to give an inappropriate component size or a pragma
28176 @code{Pack} that attempts to change the component size in the case of atomic
28177 or aliased components. Previously GNAT ignored such an attempt with a
28178 warning.
28179
28180 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
28181 @end itemize
28182
28183 @geindex AI-0039 (Ada 2012 feature)
28184
28185
28186 @itemize *
28187
28188 @item
28189 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
28190
28191 The RM permitted the use of dynamic expressions (such as @code{ptr.all})`
28192 for stream attributes, but these were never useful and are now illegal. GNAT
28193 has always regarded such expressions as illegal.
28194
28195 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
28196 @end itemize
28197
28198 @geindex AI-0095 (Ada 2012 feature)
28199
28200
28201 @itemize *
28202
28203 @item
28204 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
28205
28206 The prefix of @code{'Address} cannot statically denote a subprogram with
28207 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
28208 @code{Program_Error} if the prefix denotes a subprogram with convention
28209 @code{Intrinsic}.
28210
28211 RM References: 13.03 (11/1)
28212 @end itemize
28213
28214 @geindex AI-0116 (Ada 2012 feature)
28215
28216
28217 @itemize *
28218
28219 @item
28220 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
28221
28222 This AI requires that the alignment of a class-wide object be no greater
28223 than the alignment of any type in the class. GNAT has always followed this
28224 recommendation.
28225
28226 RM References: 13.03 (29) 13.11 (16)
28227 @end itemize
28228
28229 @geindex AI-0146 (Ada 2012 feature)
28230
28231
28232 @itemize *
28233
28234 @item
28235 @emph{AI-0146 Type invariants (2009-09-21)}
28236
28237 Type invariants may be specified for private types using the aspect notation.
28238 Aspect @code{Type_Invariant} may be specified for any private type,
28239 @code{Type_Invariant'Class} can
28240 only be specified for tagged types, and is inherited by any descendent of the
28241 tagged types. The invariant is a boolean expression that is tested for being
28242 true in the following situations: conversions to the private type, object
28243 declarations for the private type that are default initialized, and
28244 [@strong{in}] @strong{out}
28245 parameters and returned result on return from any primitive operation for
28246 the type that is visible to a client.
28247 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
28248 @code{Invariant'Class} for @code{Type_Invariant'Class}.
28249
28250 RM References: 13.03.03 (00)
28251 @end itemize
28252
28253 @geindex AI-0078 (Ada 2012 feature)
28254
28255
28256 @itemize *
28257
28258 @item
28259 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
28260
28261 In Ada 2012, compilers are required to support unchecked conversion where the
28262 target alignment is a multiple of the source alignment. GNAT always supported
28263 this case (and indeed all cases of differing alignments, doing copies where
28264 required if the alignment was reduced).
28265
28266 RM References: 13.09 (7)
28267 @end itemize
28268
28269 @geindex AI-0195 (Ada 2012 feature)
28270
28271
28272 @itemize *
28273
28274 @item
28275 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
28276
28277 The handling of invalid values is now designated to be implementation
28278 defined. This is a documentation change only, requiring Annex M in the GNAT
28279 Reference Manual to document this handling.
28280 In GNAT, checks for invalid values are made
28281 only when necessary to avoid erroneous behavior. Operations like assignments
28282 which cannot cause erroneous behavior ignore the possibility of invalid
28283 values and do not do a check. The date given above applies only to the
28284 documentation change, this behavior has always been implemented by GNAT.
28285
28286 RM References: 13.09.01 (10)
28287 @end itemize
28288
28289 @geindex AI-0193 (Ada 2012 feature)
28290
28291
28292 @itemize *
28293
28294 @item
28295 @emph{AI-0193 Alignment of allocators (2010-09-16)}
28296
28297 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
28298 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
28299 of size.
28300
28301 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
28302 13.11.01 (2) 13.11.01 (3)
28303 @end itemize
28304
28305 @geindex AI-0177 (Ada 2012 feature)
28306
28307
28308 @itemize *
28309
28310 @item
28311 @emph{AI-0177 Parameterized expressions (2010-07-10)}
28312
28313 The new Ada 2012 notion of parameterized expressions is implemented. The form
28314 is:
28315
28316 @example
28317 function-specification is (expression)
28318 @end example
28319
28320 This is exactly equivalent to the
28321 corresponding function body that returns the expression, but it can appear
28322 in a package spec. Note that the expression must be parenthesized.
28323
28324 RM References: 13.11.01 (3/2)
28325 @end itemize
28326
28327 @geindex AI-0033 (Ada 2012 feature)
28328
28329
28330 @itemize *
28331
28332 @item
28333 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
28334
28335 Neither of these two pragmas may appear within a generic template, because
28336 the generic might be instantiated at other than the library level.
28337
28338 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
28339 @end itemize
28340
28341 @geindex AI-0161 (Ada 2012 feature)
28342
28343
28344 @itemize *
28345
28346 @item
28347 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
28348
28349 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
28350 of the default stream attributes for elementary types. If this restriction is
28351 in force, then it is necessary to provide explicit subprograms for any
28352 stream attributes used.
28353
28354 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
28355 @end itemize
28356
28357 @geindex AI-0194 (Ada 2012 feature)
28358
28359
28360 @itemize *
28361
28362 @item
28363 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
28364
28365 The @code{Stream_Size} attribute returns the default number of bits in the
28366 stream representation of the given type.
28367 This value is not affected by the presence
28368 of stream subprogram attributes for the type. GNAT has always implemented
28369 this interpretation.
28370
28371 RM References: 13.13.02 (1.2/2)
28372 @end itemize
28373
28374 @geindex AI-0109 (Ada 2012 feature)
28375
28376
28377 @itemize *
28378
28379 @item
28380 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
28381
28382 This AI is an editorial change only. It removes the need for a tag check
28383 that can never fail.
28384
28385 RM References: 13.13.02 (34/2)
28386 @end itemize
28387
28388 @geindex AI-0007 (Ada 2012 feature)
28389
28390
28391 @itemize *
28392
28393 @item
28394 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
28395
28396 The RM as written appeared to limit the possibilities of declaring read
28397 attribute procedures for private scalar types. This limitation was not
28398 intended, and has never been enforced by GNAT.
28399
28400 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
28401 @end itemize
28402
28403 @geindex AI-0065 (Ada 2012 feature)
28404
28405
28406 @itemize *
28407
28408 @item
28409 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
28410
28411 This AI clarifies the fact that all remote access types support external
28412 streaming. This fixes an obvious oversight in the definition of the
28413 language, and GNAT always implemented the intended correct rules.
28414
28415 RM References: 13.13.02 (52/2)
28416 @end itemize
28417
28418 @geindex AI-0019 (Ada 2012 feature)
28419
28420
28421 @itemize *
28422
28423 @item
28424 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
28425
28426 The RM suggests that primitive subprograms of a specific tagged type are
28427 frozen when the tagged type is frozen. This would be an incompatible change
28428 and is not intended. GNAT has never attempted this kind of freezing and its
28429 behavior is consistent with the recommendation of this AI.
28430
28431 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)
28432 @end itemize
28433
28434 @geindex AI-0017 (Ada 2012 feature)
28435
28436
28437 @itemize *
28438
28439 @item
28440 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
28441
28442 So-called 'Taft-amendment types' (i.e., types that are completed in package
28443 bodies) are not frozen by the occurrence of bodies in the
28444 enclosing declarative part. GNAT always implemented this properly.
28445
28446 RM References: 13.14 (3/1)
28447 @end itemize
28448
28449 @geindex AI-0060 (Ada 2012 feature)
28450
28451
28452 @itemize *
28453
28454 @item
28455 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
28456
28457 This AI extends the definition of remote access types to include access
28458 to limited, synchronized, protected or task class-wide interface types.
28459 GNAT already implemented this extension.
28460
28461 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
28462 @end itemize
28463
28464 @geindex AI-0114 (Ada 2012 feature)
28465
28466
28467 @itemize *
28468
28469 @item
28470 @emph{AI-0114 Classification of letters (0000-00-00)}
28471
28472 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
28473 181 (@code{MICRO SIGN}), and
28474 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
28475 lower case letters by Unicode.
28476 However, they are not allowed in identifiers, and they
28477 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
28478 This behavior is consistent with that defined in Ada 95.
28479
28480 RM References: A.03.02 (59) A.04.06 (7)
28481 @end itemize
28482
28483 @geindex AI-0185 (Ada 2012 feature)
28484
28485
28486 @itemize *
28487
28488 @item
28489 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
28490
28491 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
28492 classification functions for @code{Wide_Character} and
28493 @code{Wide_Wide_Character}, as well as providing
28494 case folding routines for @code{Wide_[Wide_]Character} and
28495 @code{Wide_[Wide_]String}.
28496
28497 RM References: A.03.05 (0) A.03.06 (0)
28498 @end itemize
28499
28500 @geindex AI-0031 (Ada 2012 feature)
28501
28502
28503 @itemize *
28504
28505 @item
28506 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
28507
28508 A new version of @code{Find_Token} is added to all relevant string packages,
28509 with an extra parameter @code{From}. Instead of starting at the first
28510 character of the string, the search for a matching Token starts at the
28511 character indexed by the value of @code{From}.
28512 These procedures are available in all versions of Ada
28513 but if used in versions earlier than Ada 2012 they will generate a warning
28514 that an Ada 2012 subprogram is being used.
28515
28516 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
28517 A.04.05 (46)
28518 @end itemize
28519
28520 @geindex AI-0056 (Ada 2012 feature)
28521
28522
28523 @itemize *
28524
28525 @item
28526 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
28527
28528 The wording in the Ada 2005 RM implied an incompatible handling of the
28529 @code{Index} functions, resulting in raising an exception instead of
28530 returning zero in some situations.
28531 This was not intended and has been corrected.
28532 GNAT always returned zero, and is thus consistent with this AI.
28533
28534 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
28535 @end itemize
28536
28537 @geindex AI-0137 (Ada 2012 feature)
28538
28539
28540 @itemize *
28541
28542 @item
28543 @emph{AI-0137 String encoding package (2010-03-25)}
28544
28545 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
28546 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
28547 and @code{Wide_Wide_Strings} have been
28548 implemented. These packages (whose documentation can be found in the spec
28549 files @code{a-stuten.ads}, @code{a-suenco.ads}, @code{a-suenst.ads},
28550 @code{a-suewst.ads}, @code{a-suezst.ads}) allow encoding and decoding of
28551 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
28552 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
28553 UTF-16), as well as conversions between the different UTF encodings. With
28554 the exception of @code{Wide_Wide_Strings}, these packages are available in
28555 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
28556 The @code{Wide_Wide_Strings} package
28557 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
28558 mode since it uses @code{Wide_Wide_Character}).
28559
28560 RM References: A.04.11
28561 @end itemize
28562
28563 @geindex AI-0038 (Ada 2012 feature)
28564
28565
28566 @itemize *
28567
28568 @item
28569 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
28570
28571 These are minor errors in the description on three points. The intent on
28572 all these points has always been clear, and GNAT has always implemented the
28573 correct intended semantics.
28574
28575 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)
28576 @end itemize
28577
28578 @geindex AI-0044 (Ada 2012 feature)
28579
28580
28581 @itemize *
28582
28583 @item
28584 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
28585
28586 This AI places restrictions on allowed instantiations of generic containers.
28587 These restrictions are not checked by the compiler, so there is nothing to
28588 change in the implementation. This affects only the RM documentation.
28589
28590 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)
28591 @end itemize
28592
28593 @geindex AI-0127 (Ada 2012 feature)
28594
28595
28596 @itemize *
28597
28598 @item
28599 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
28600
28601 This package provides an interface for identifying the current locale.
28602
28603 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
28604 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
28605 @end itemize
28606
28607 @geindex AI-0002 (Ada 2012 feature)
28608
28609
28610 @itemize *
28611
28612 @item
28613 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
28614
28615 The compiler is not required to support exporting an Ada subprogram with
28616 convention C if there are parameters or a return type of an unconstrained
28617 array type (such as @code{String}). GNAT allows such declarations but
28618 generates warnings. It is possible, but complicated, to write the
28619 corresponding C code and certainly such code would be specific to GNAT and
28620 non-portable.
28621
28622 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
28623 @end itemize
28624
28625 @geindex AI05-0216 (Ada 2012 feature)
28626
28627
28628 @itemize *
28629
28630 @item
28631 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
28632
28633 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
28634 forbid tasks declared locally within subprograms, or functions returning task
28635 objects, and that is the implementation that GNAT has always provided.
28636 However the language in the RM was not sufficiently clear on this point.
28637 Thus this is a documentation change in the RM only.
28638
28639 RM References: D.07 (3/3)
28640 @end itemize
28641
28642 @geindex AI-0211 (Ada 2012 feature)
28643
28644
28645 @itemize *
28646
28647 @item
28648 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
28649
28650 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
28651 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
28652
28653 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
28654 @end itemize
28655
28656 @geindex AI-0190 (Ada 2012 feature)
28657
28658
28659 @itemize *
28660
28661 @item
28662 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
28663
28664 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
28665 used to control storage pools globally.
28666 In particular, you can force every access
28667 type that is used for allocation (@strong{new}) to have an explicit storage pool,
28668 or you can declare a pool globally to be used for all access types that lack
28669 an explicit one.
28670
28671 RM References: D.07 (8)
28672 @end itemize
28673
28674 @geindex AI-0189 (Ada 2012 feature)
28675
28676
28677 @itemize *
28678
28679 @item
28680 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
28681
28682 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
28683 which says that no dynamic allocation will occur once elaboration is
28684 completed.
28685 In general this requires a run-time check, which is not required, and which
28686 GNAT does not attempt. But the static cases of allocators in a task body or
28687 in the body of the main program are detected and flagged at compile or bind
28688 time.
28689
28690 RM References: D.07 (19.1/2) H.04 (23.3/2)
28691 @end itemize
28692
28693 @geindex AI-0171 (Ada 2012 feature)
28694
28695
28696 @itemize *
28697
28698 @item
28699 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
28700
28701 A new package @code{System.Multiprocessors} is added, together with the
28702 definition of pragma @code{CPU} for controlling task affinity. A new no
28703 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
28704 is added to the Ravenscar profile.
28705
28706 RM References: D.13.01 (4/2) D.16
28707 @end itemize
28708
28709 @geindex AI-0210 (Ada 2012 feature)
28710
28711
28712 @itemize *
28713
28714 @item
28715 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
28716
28717 This is a documentation only issue regarding wording of metric requirements,
28718 that does not affect the implementation of the compiler.
28719
28720 RM References: D.15 (24/2)
28721 @end itemize
28722
28723 @geindex AI-0206 (Ada 2012 feature)
28724
28725
28726 @itemize *
28727
28728 @item
28729 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
28730
28731 Remote types packages are now allowed to depend on preelaborated packages.
28732 This was formerly considered illegal.
28733
28734 RM References: E.02.02 (6)
28735 @end itemize
28736
28737 @geindex AI-0152 (Ada 2012 feature)
28738
28739
28740 @itemize *
28741
28742 @item
28743 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
28744
28745 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
28746 where the type of the returned value is an anonymous access type.
28747
28748 RM References: H.04 (8/1)
28749 @end itemize
28750
28751 @node Obsolescent Features,Compatibility and Porting Guide,Implementation of Ada 2012 Features,Top
28752 @anchor{gnat_rm/obsolescent_features id1}@anchor{434}@anchor{gnat_rm/obsolescent_features doc}@anchor{435}@anchor{gnat_rm/obsolescent_features obsolescent-features}@anchor{15}
28753 @chapter Obsolescent Features
28754
28755
28756 This chapter describes features that are provided by GNAT, but are
28757 considered obsolescent since there are preferred ways of achieving
28758 the same effect. These features are provided solely for historical
28759 compatibility purposes.
28760
28761 @menu
28762 * pragma No_Run_Time::
28763 * pragma Ravenscar::
28764 * pragma Restricted_Run_Time::
28765 * pragma Task_Info::
28766 * package System.Task_Info (s-tasinf.ads): package System Task_Info s-tasinf ads.
28767
28768 @end menu
28769
28770 @node pragma No_Run_Time,pragma Ravenscar,,Obsolescent Features
28771 @anchor{gnat_rm/obsolescent_features id2}@anchor{436}@anchor{gnat_rm/obsolescent_features pragma-no-run-time}@anchor{437}
28772 @section pragma No_Run_Time
28773
28774
28775 The pragma @code{No_Run_Time} is used to achieve an affect similar
28776 to the use of the "Zero Foot Print" configurable run time, but without
28777 requiring a specially configured run time. The result of using this
28778 pragma, which must be used for all units in a partition, is to restrict
28779 the use of any language features requiring run-time support code. The
28780 preferred usage is to use an appropriately configured run-time that
28781 includes just those features that are to be made accessible.
28782
28783 @node pragma Ravenscar,pragma Restricted_Run_Time,pragma No_Run_Time,Obsolescent Features
28784 @anchor{gnat_rm/obsolescent_features id3}@anchor{438}@anchor{gnat_rm/obsolescent_features pragma-ravenscar}@anchor{439}
28785 @section pragma Ravenscar
28786
28787
28788 The pragma @code{Ravenscar} has exactly the same effect as pragma
28789 @code{Profile (Ravenscar)}. The latter usage is preferred since it
28790 is part of the new Ada 2005 standard.
28791
28792 @node pragma Restricted_Run_Time,pragma Task_Info,pragma Ravenscar,Obsolescent Features
28793 @anchor{gnat_rm/obsolescent_features pragma-restricted-run-time}@anchor{43a}@anchor{gnat_rm/obsolescent_features id4}@anchor{43b}
28794 @section pragma Restricted_Run_Time
28795
28796
28797 The pragma @code{Restricted_Run_Time} has exactly the same effect as
28798 pragma @code{Profile (Restricted)}. The latter usage is
28799 preferred since the Ada 2005 pragma @code{Profile} is intended for
28800 this kind of implementation dependent addition.
28801
28802 @node pragma Task_Info,package System Task_Info s-tasinf ads,pragma Restricted_Run_Time,Obsolescent Features
28803 @anchor{gnat_rm/obsolescent_features pragma-task-info}@anchor{43c}@anchor{gnat_rm/obsolescent_features id5}@anchor{43d}
28804 @section pragma Task_Info
28805
28806
28807 The functionality provided by pragma @code{Task_Info} is now part of the
28808 Ada language. The @code{CPU} aspect and the package
28809 @code{System.Multiprocessors} offer a less system-dependent way to specify
28810 task affinity or to query the number of processors.
28811
28812 Syntax
28813
28814 @example
28815 pragma Task_Info (EXPRESSION);
28816 @end example
28817
28818 This pragma appears within a task definition (like pragma
28819 @code{Priority}) and applies to the task in which it appears. The
28820 argument must be of type @code{System.Task_Info.Task_Info_Type}.
28821 The @code{Task_Info} pragma provides system dependent control over
28822 aspects of tasking implementation, for example, the ability to map
28823 tasks to specific processors. For details on the facilities available
28824 for the version of GNAT that you are using, see the documentation
28825 in the spec of package System.Task_Info in the runtime
28826 library.
28827
28828 @node package System Task_Info s-tasinf ads,,pragma Task_Info,Obsolescent Features
28829 @anchor{gnat_rm/obsolescent_features package-system-task-info}@anchor{43e}@anchor{gnat_rm/obsolescent_features package-system-task-info-s-tasinf-ads}@anchor{43f}
28830 @section package System.Task_Info (@code{s-tasinf.ads})
28831
28832
28833 This package provides target dependent functionality that is used
28834 to support the @code{Task_Info} pragma. The predefined Ada package
28835 @code{System.Multiprocessors} and the @code{CPU} aspect now provide a
28836 standard replacement for GNAT's @code{Task_Info} functionality.
28837
28838 @node Compatibility and Porting Guide,GNU Free Documentation License,Obsolescent Features,Top
28839 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-and-porting-guide}@anchor{16}@anchor{gnat_rm/compatibility_and_porting_guide doc}@anchor{440}@anchor{gnat_rm/compatibility_and_porting_guide id1}@anchor{441}
28840 @chapter Compatibility and Porting Guide
28841
28842
28843 This chapter presents some guidelines for developing portable Ada code,
28844 describes the compatibility issues that may arise between
28845 GNAT and other Ada compilation systems (including those for Ada 83),
28846 and shows how GNAT can expedite porting
28847 applications developed in other Ada environments.
28848
28849 @menu
28850 * Writing Portable Fixed-Point Declarations::
28851 * Compatibility with Ada 83::
28852 * Compatibility between Ada 95 and Ada 2005::
28853 * Implementation-dependent characteristics::
28854 * Compatibility with Other Ada Systems::
28855 * Representation Clauses::
28856 * Compatibility with HP Ada 83::
28857
28858 @end menu
28859
28860 @node Writing Portable Fixed-Point Declarations,Compatibility with Ada 83,,Compatibility and Porting Guide
28861 @anchor{gnat_rm/compatibility_and_porting_guide id2}@anchor{442}@anchor{gnat_rm/compatibility_and_porting_guide writing-portable-fixed-point-declarations}@anchor{443}
28862 @section Writing Portable Fixed-Point Declarations
28863
28864
28865 The Ada Reference Manual gives an implementation freedom to choose bounds
28866 that are narrower by @code{Small} from the given bounds.
28867 For example, if we write
28868
28869 @example
28870 type F1 is delta 1.0 range -128.0 .. +128.0;
28871 @end example
28872
28873 then the implementation is allowed to choose -128.0 .. +127.0 if it
28874 likes, but is not required to do so.
28875
28876 This leads to possible portability problems, so let's have a closer
28877 look at this, and figure out how to avoid these problems.
28878
28879 First, why does this freedom exist, and why would an implementation
28880 take advantage of it? To answer this, take a closer look at the type
28881 declaration for @code{F1} above. If the compiler uses the given bounds,
28882 it would need 9 bits to hold the largest positive value (and typically
28883 that means 16 bits on all machines). But if the implementation chooses
28884 the +127.0 bound then it can fit values of the type in 8 bits.
28885
28886 Why not make the user write +127.0 if that's what is wanted?
28887 The rationale is that if you are thinking of fixed point
28888 as a kind of 'poor man's floating-point', then you don't want
28889 to be thinking about the scaled integers that are used in its
28890 representation. Let's take another example:
28891
28892 @example
28893 type F2 is delta 2.0**(-15) range -1.0 .. +1.0;
28894 @end example
28895
28896 Looking at this declaration, it seems casually as though
28897 it should fit in 16 bits, but again that extra positive value
28898 +1.0 has the scaled integer equivalent of 2**15 which is one too
28899 big for signed 16 bits. The implementation can treat this as:
28900
28901 @example
28902 type F2 is delta 2.0**(-15) range -1.0 .. +1.0-(2.0**(-15));
28903 @end example
28904
28905 and the Ada language design team felt that this was too annoying
28906 to require. We don't need to debate this decision at this point,
28907 since it is well established (the rule about narrowing the ranges
28908 dates to Ada 83).
28909
28910 But the important point is that an implementation is not required
28911 to do this narrowing, so we have a potential portability problem.
28912 We could imagine three types of implementation:
28913
28914
28915 @enumerate a
28916
28917 @item
28918 those that narrow the range automatically if they can figure
28919 out that the narrower range will allow storage in a smaller machine unit,
28920
28921 @item
28922 those that will narrow only if forced to by a @code{'Size} clause, and
28923
28924 @item
28925 those that will never narrow.
28926 @end enumerate
28927
28928 Now if we are language theoreticians, we can imagine a fourth
28929 approach: to narrow all the time, e.g. to treat
28930
28931 @example
28932 type F3 is delta 1.0 range -10.0 .. +23.0;
28933 @end example
28934
28935 as though it had been written:
28936
28937 @example
28938 type F3 is delta 1.0 range -9.0 .. +22.0;
28939 @end example
28940
28941 But although technically allowed, such a behavior would be hostile and silly,
28942 and no real compiler would do this. All real compilers will fall into one of
28943 the categories (a), (b) or (c) above.
28944
28945 So, how do you get the compiler to do what you want? The answer is give the
28946 actual bounds you want, and then use a @code{'Small} clause and a
28947 @code{'Size} clause to absolutely pin down what the compiler does.
28948 E.g., for @code{F2} above, we will write:
28949
28950 @example
28951 My_Small : constant := 2.0**(-15);
28952 My_First : constant := -1.0;
28953 My_Last : constant := +1.0 - My_Small;
28954
28955 type F2 is delta My_Small range My_First .. My_Last;
28956 @end example
28957
28958 and then add
28959
28960 @example
28961 for F2'Small use my_Small;
28962 for F2'Size use 16;
28963 @end example
28964
28965 In practice all compilers will do the same thing here and will give you
28966 what you want, so the above declarations are fully portable. If you really
28967 want to play language lawyer and guard against ludicrous behavior by the
28968 compiler you could add
28969
28970 @example
28971 Test1 : constant := 1 / Boolean'Pos (F2'First = My_First);
28972 Test2 : constant := 1 / Boolean'Pos (F2'Last = My_Last);
28973 @end example
28974
28975 One or other or both are allowed to be illegal if the compiler is
28976 behaving in a silly manner, but at least the silly compiler will not
28977 get away with silently messing with your (very clear) intentions.
28978
28979 If you follow this scheme you will be guaranteed that your fixed-point
28980 types will be portable.
28981
28982 @node Compatibility with Ada 83,Compatibility between Ada 95 and Ada 2005,Writing Portable Fixed-Point Declarations,Compatibility and Porting Guide
28983 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-ada-83}@anchor{444}@anchor{gnat_rm/compatibility_and_porting_guide id3}@anchor{445}
28984 @section Compatibility with Ada 83
28985
28986
28987 @geindex Compatibility (between Ada 83 and Ada 95 / Ada 2005 / Ada 2012)
28988
28989 Ada 95 and the subsequent revisions Ada 2005 and Ada 2012
28990 are highly upwards compatible with Ada 83. In
28991 particular, the design intention was that the difficulties associated
28992 with moving from Ada 83 to later versions of the standard should be no greater
28993 than those that occur when moving from one Ada 83 system to another.
28994
28995 However, there are a number of points at which there are minor
28996 incompatibilities. The @cite{Ada 95 Annotated Reference Manual} contains
28997 full details of these issues as they relate to Ada 95,
28998 and should be consulted for a complete treatment.
28999 In practice the
29000 following subsections treat the most likely issues to be encountered.
29001
29002 @menu
29003 * Legal Ada 83 programs that are illegal in Ada 95::
29004 * More deterministic semantics::
29005 * Changed semantics::
29006 * Other language compatibility issues::
29007
29008 @end menu
29009
29010 @node Legal Ada 83 programs that are illegal in Ada 95,More deterministic semantics,,Compatibility with Ada 83
29011 @anchor{gnat_rm/compatibility_and_porting_guide id4}@anchor{446}@anchor{gnat_rm/compatibility_and_porting_guide legal-ada-83-programs-that-are-illegal-in-ada-95}@anchor{447}
29012 @subsection Legal Ada 83 programs that are illegal in Ada 95
29013
29014
29015 Some legal Ada 83 programs are illegal (i.e., they will fail to compile) in
29016 Ada 95 and later versions of the standard:
29017
29018
29019 @itemize *
29020
29021 @item
29022 @emph{Character literals}
29023
29024 Some uses of character literals are ambiguous. Since Ada 95 has introduced
29025 @code{Wide_Character} as a new predefined character type, some uses of
29026 character literals that were legal in Ada 83 are illegal in Ada 95.
29027 For example:
29028
29029 @example
29030 for Char in 'A' .. 'Z' loop ... end loop;
29031 @end example
29032
29033 The problem is that 'A' and 'Z' could be from either
29034 @code{Character} or @code{Wide_Character}. The simplest correction
29035 is to make the type explicit; e.g.:
29036
29037 @example
29038 for Char in Character range 'A' .. 'Z' loop ... end loop;
29039 @end example
29040
29041 @item
29042 @emph{New reserved words}
29043
29044 The identifiers @code{abstract}, @code{aliased}, @code{protected},
29045 @code{requeue}, @code{tagged}, and @code{until} are reserved in Ada 95.
29046 Existing Ada 83 code using any of these identifiers must be edited to
29047 use some alternative name.
29048
29049 @item
29050 @emph{Freezing rules}
29051
29052 The rules in Ada 95 are slightly different with regard to the point at
29053 which entities are frozen, and representation pragmas and clauses are
29054 not permitted past the freeze point. This shows up most typically in
29055 the form of an error message complaining that a representation item
29056 appears too late, and the appropriate corrective action is to move
29057 the item nearer to the declaration of the entity to which it refers.
29058
29059 A particular case is that representation pragmas
29060 cannot be applied to a subprogram body. If necessary, a separate subprogram
29061 declaration must be introduced to which the pragma can be applied.
29062
29063 @item
29064 @emph{Optional bodies for library packages}
29065
29066 In Ada 83, a package that did not require a package body was nevertheless
29067 allowed to have one. This lead to certain surprises in compiling large
29068 systems (situations in which the body could be unexpectedly ignored by the
29069 binder). In Ada 95, if a package does not require a body then it is not
29070 permitted to have a body. To fix this problem, simply remove a redundant
29071 body if it is empty, or, if it is non-empty, introduce a dummy declaration
29072 into the spec that makes the body required. One approach is to add a private
29073 part to the package declaration (if necessary), and define a parameterless
29074 procedure called @code{Requires_Body}, which must then be given a dummy
29075 procedure body in the package body, which then becomes required.
29076 Another approach (assuming that this does not introduce elaboration
29077 circularities) is to add an @code{Elaborate_Body} pragma to the package spec,
29078 since one effect of this pragma is to require the presence of a package body.
29079
29080 @item
29081 @emph{Numeric_Error is the same exception as Constraint_Error}
29082
29083 In Ada 95, the exception @code{Numeric_Error} is a renaming of @code{Constraint_Error}.
29084 This means that it is illegal to have separate exception handlers for
29085 the two exceptions. The fix is simply to remove the handler for the
29086 @code{Numeric_Error} case (since even in Ada 83, a compiler was free to raise
29087 @code{Constraint_Error} in place of @code{Numeric_Error} in all cases).
29088
29089 @item
29090 @emph{Indefinite subtypes in generics}
29091
29092 In Ada 83, it was permissible to pass an indefinite type (e.g, @code{String})
29093 as the actual for a generic formal private type, but then the instantiation
29094 would be illegal if there were any instances of declarations of variables
29095 of this type in the generic body. In Ada 95, to avoid this clear violation
29096 of the methodological principle known as the 'contract model',
29097 the generic declaration explicitly indicates whether
29098 or not such instantiations are permitted. If a generic formal parameter
29099 has explicit unknown discriminants, indicated by using @code{(<>)} after the
29100 subtype name, then it can be instantiated with indefinite types, but no
29101 stand-alone variables can be declared of this type. Any attempt to declare
29102 such a variable will result in an illegality at the time the generic is
29103 declared. If the @code{(<>)} notation is not used, then it is illegal
29104 to instantiate the generic with an indefinite type.
29105 This is the potential incompatibility issue when porting Ada 83 code to Ada 95.
29106 It will show up as a compile time error, and
29107 the fix is usually simply to add the @code{(<>)} to the generic declaration.
29108 @end itemize
29109
29110 @node More deterministic semantics,Changed semantics,Legal Ada 83 programs that are illegal in Ada 95,Compatibility with Ada 83
29111 @anchor{gnat_rm/compatibility_and_porting_guide more-deterministic-semantics}@anchor{448}@anchor{gnat_rm/compatibility_and_porting_guide id5}@anchor{449}
29112 @subsection More deterministic semantics
29113
29114
29115
29116 @itemize *
29117
29118 @item
29119 @emph{Conversions}
29120
29121 Conversions from real types to integer types round away from 0. In Ada 83
29122 the conversion Integer(2.5) could deliver either 2 or 3 as its value. This
29123 implementation freedom was intended to support unbiased rounding in
29124 statistical applications, but in practice it interfered with portability.
29125 In Ada 95 the conversion semantics are unambiguous, and rounding away from 0
29126 is required. Numeric code may be affected by this change in semantics.
29127 Note, though, that this issue is no worse than already existed in Ada 83
29128 when porting code from one vendor to another.
29129
29130 @item
29131 @emph{Tasking}
29132
29133 The Real-Time Annex introduces a set of policies that define the behavior of
29134 features that were implementation dependent in Ada 83, such as the order in
29135 which open select branches are executed.
29136 @end itemize
29137
29138 @node Changed semantics,Other language compatibility issues,More deterministic semantics,Compatibility with Ada 83
29139 @anchor{gnat_rm/compatibility_and_porting_guide id6}@anchor{44a}@anchor{gnat_rm/compatibility_and_porting_guide changed-semantics}@anchor{44b}
29140 @subsection Changed semantics
29141
29142
29143 The worst kind of incompatibility is one where a program that is legal in
29144 Ada 83 is also legal in Ada 95 but can have an effect in Ada 95 that was not
29145 possible in Ada 83. Fortunately this is extremely rare, but the one
29146 situation that you should be alert to is the change in the predefined type
29147 @code{Character} from 7-bit ASCII to 8-bit Latin-1.
29148
29149 @quotation
29150
29151 @geindex Latin-1
29152 @end quotation
29153
29154
29155 @itemize *
29156
29157 @item
29158 @emph{Range of type `@w{`}Character`@w{`}}
29159
29160 The range of @code{Standard.Character} is now the full 256 characters
29161 of Latin-1, whereas in most Ada 83 implementations it was restricted
29162 to 128 characters. Although some of the effects of
29163 this change will be manifest in compile-time rejection of legal
29164 Ada 83 programs it is possible for a working Ada 83 program to have
29165 a different effect in Ada 95, one that was not permitted in Ada 83.
29166 As an example, the expression
29167 @code{Character'Pos(Character'Last)} returned @code{127} in Ada 83 and now
29168 delivers @code{255} as its value.
29169 In general, you should look at the logic of any
29170 character-processing Ada 83 program and see whether it needs to be adapted
29171 to work correctly with Latin-1. Note that the predefined Ada 95 API has a
29172 character handling package that may be relevant if code needs to be adapted
29173 to account for the additional Latin-1 elements.
29174 The desirable fix is to
29175 modify the program to accommodate the full character set, but in some cases
29176 it may be convenient to define a subtype or derived type of Character that
29177 covers only the restricted range.
29178 @end itemize
29179
29180 @node Other language compatibility issues,,Changed semantics,Compatibility with Ada 83
29181 @anchor{gnat_rm/compatibility_and_porting_guide other-language-compatibility-issues}@anchor{44c}@anchor{gnat_rm/compatibility_and_porting_guide id7}@anchor{44d}
29182 @subsection Other language compatibility issues
29183
29184
29185
29186 @itemize *
29187
29188 @item
29189 @emph{-gnat83} switch
29190
29191 All implementations of GNAT provide a switch that causes GNAT to operate
29192 in Ada 83 mode. In this mode, some but not all compatibility problems
29193 of the type described above are handled automatically. For example, the
29194 new reserved words introduced in Ada 95 and Ada 2005 are treated simply
29195 as identifiers as in Ada 83. However,
29196 in practice, it is usually advisable to make the necessary modifications
29197 to the program to remove the need for using this switch.
29198 See the @code{Compiling Different Versions of Ada} section in
29199 the @cite{GNAT User's Guide}.
29200
29201 @item
29202 Support for removed Ada 83 pragmas and attributes
29203
29204 A number of pragmas and attributes from Ada 83 were removed from Ada 95,
29205 generally because they were replaced by other mechanisms. Ada 95 and Ada 2005
29206 compilers are allowed, but not required, to implement these missing
29207 elements. In contrast with some other compilers, GNAT implements all
29208 such pragmas and attributes, eliminating this compatibility concern. These
29209 include @code{pragma Interface} and the floating point type attributes
29210 (@code{Emax}, @code{Mantissa}, etc.), among other items.
29211 @end itemize
29212
29213 @node Compatibility between Ada 95 and Ada 2005,Implementation-dependent characteristics,Compatibility with Ada 83,Compatibility and Porting Guide
29214 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-between-ada-95-and-ada-2005}@anchor{44e}@anchor{gnat_rm/compatibility_and_porting_guide id8}@anchor{44f}
29215 @section Compatibility between Ada 95 and Ada 2005
29216
29217
29218 @geindex Compatibility between Ada 95 and Ada 2005
29219
29220 Although Ada 2005 was designed to be upwards compatible with Ada 95, there are
29221 a number of incompatibilities. Several are enumerated below;
29222 for a complete description please see the
29223 @cite{Annotated Ada 2005 Reference Manual}, or section 9.1.1 in
29224 @cite{Rationale for Ada 2005}.
29225
29226
29227 @itemize *
29228
29229 @item
29230 @emph{New reserved words.}
29231
29232 The words @code{interface}, @code{overriding} and @code{synchronized} are
29233 reserved in Ada 2005.
29234 A pre-Ada 2005 program that uses any of these as an identifier will be
29235 illegal.
29236
29237 @item
29238 @emph{New declarations in predefined packages.}
29239
29240 A number of packages in the predefined environment contain new declarations:
29241 @code{Ada.Exceptions}, @code{Ada.Real_Time}, @code{Ada.Strings},
29242 @code{Ada.Strings.Fixed}, @code{Ada.Strings.Bounded},
29243 @code{Ada.Strings.Unbounded}, @code{Ada.Strings.Wide_Fixed},
29244 @code{Ada.Strings.Wide_Bounded}, @code{Ada.Strings.Wide_Unbounded},
29245 @code{Ada.Tags}, @code{Ada.Text_IO}, and @code{Interfaces.C}.
29246 If an Ada 95 program does a @code{with} and @code{use} of any of these
29247 packages, the new declarations may cause name clashes.
29248
29249 @item
29250 @emph{Access parameters.}
29251
29252 A nondispatching subprogram with an access parameter cannot be renamed
29253 as a dispatching operation. This was permitted in Ada 95.
29254
29255 @item
29256 @emph{Access types, discriminants, and constraints.}
29257
29258 Rule changes in this area have led to some incompatibilities; for example,
29259 constrained subtypes of some access types are not permitted in Ada 2005.
29260
29261 @item
29262 @emph{Aggregates for limited types.}
29263
29264 The allowance of aggregates for limited types in Ada 2005 raises the
29265 possibility of ambiguities in legal Ada 95 programs, since additional types
29266 now need to be considered in expression resolution.
29267
29268 @item
29269 @emph{Fixed-point multiplication and division.}
29270
29271 Certain expressions involving '*' or '/' for a fixed-point type, which
29272 were legal in Ada 95 and invoked the predefined versions of these operations,
29273 are now ambiguous.
29274 The ambiguity may be resolved either by applying a type conversion to the
29275 expression, or by explicitly invoking the operation from package
29276 @code{Standard}.
29277
29278 @item
29279 @emph{Return-by-reference types.}
29280
29281 The Ada 95 return-by-reference mechanism has been removed. Instead, the user
29282 can declare a function returning a value from an anonymous access type.
29283 @end itemize
29284
29285 @node Implementation-dependent characteristics,Compatibility with Other Ada Systems,Compatibility between Ada 95 and Ada 2005,Compatibility and Porting Guide
29286 @anchor{gnat_rm/compatibility_and_porting_guide implementation-dependent-characteristics}@anchor{450}@anchor{gnat_rm/compatibility_and_porting_guide id9}@anchor{451}
29287 @section Implementation-dependent characteristics
29288
29289
29290 Although the Ada language defines the semantics of each construct as
29291 precisely as practical, in some situations (for example for reasons of
29292 efficiency, or where the effect is heavily dependent on the host or target
29293 platform) the implementation is allowed some freedom. In porting Ada 83
29294 code to GNAT, you need to be aware of whether / how the existing code
29295 exercised such implementation dependencies. Such characteristics fall into
29296 several categories, and GNAT offers specific support in assisting the
29297 transition from certain Ada 83 compilers.
29298
29299 @menu
29300 * Implementation-defined pragmas::
29301 * Implementation-defined attributes::
29302 * Libraries::
29303 * Elaboration order::
29304 * Target-specific aspects::
29305
29306 @end menu
29307
29308 @node Implementation-defined pragmas,Implementation-defined attributes,,Implementation-dependent characteristics
29309 @anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-pragmas}@anchor{452}@anchor{gnat_rm/compatibility_and_porting_guide id10}@anchor{453}
29310 @subsection Implementation-defined pragmas
29311
29312
29313 Ada compilers are allowed to supplement the language-defined pragmas, and
29314 these are a potential source of non-portability. All GNAT-defined pragmas
29315 are described in @ref{7,,Implementation Defined Pragmas},
29316 and these include several that are specifically
29317 intended to correspond to other vendors' Ada 83 pragmas.
29318 For migrating from VADS, the pragma @code{Use_VADS_Size} may be useful.
29319 For compatibility with HP Ada 83, GNAT supplies the pragmas
29320 @code{Extend_System}, @code{Ident}, @code{Inline_Generic},
29321 @code{Interface_Name}, @code{Passive}, @code{Suppress_All},
29322 and @code{Volatile}.
29323 Other relevant pragmas include @code{External} and @code{Link_With}.
29324 Some vendor-specific
29325 Ada 83 pragmas (@code{Share_Generic}, @code{Subtitle}, and @code{Title}) are
29326 recognized, thus
29327 avoiding compiler rejection of units that contain such pragmas; they are not
29328 relevant in a GNAT context and hence are not otherwise implemented.
29329
29330 @node Implementation-defined attributes,Libraries,Implementation-defined pragmas,Implementation-dependent characteristics
29331 @anchor{gnat_rm/compatibility_and_porting_guide id11}@anchor{454}@anchor{gnat_rm/compatibility_and_porting_guide implementation-defined-attributes}@anchor{455}
29332 @subsection Implementation-defined attributes
29333
29334
29335 Analogous to pragmas, the set of attributes may be extended by an
29336 implementation. All GNAT-defined attributes are described in
29337 @ref{8,,Implementation Defined Attributes},
29338 and these include several that are specifically intended
29339 to correspond to other vendors' Ada 83 attributes. For migrating from VADS,
29340 the attribute @code{VADS_Size} may be useful. For compatibility with HP
29341 Ada 83, GNAT supplies the attributes @code{Bit}, @code{Machine_Size} and
29342 @code{Type_Class}.
29343
29344 @node Libraries,Elaboration order,Implementation-defined attributes,Implementation-dependent characteristics
29345 @anchor{gnat_rm/compatibility_and_porting_guide libraries}@anchor{456}@anchor{gnat_rm/compatibility_and_porting_guide id12}@anchor{457}
29346 @subsection Libraries
29347
29348
29349 Vendors may supply libraries to supplement the standard Ada API. If Ada 83
29350 code uses vendor-specific libraries then there are several ways to manage
29351 this in Ada 95 and later versions of the standard:
29352
29353
29354 @itemize *
29355
29356 @item
29357 If the source code for the libraries (specs and bodies) are
29358 available, then the libraries can be migrated in the same way as the
29359 application.
29360
29361 @item
29362 If the source code for the specs but not the bodies are
29363 available, then you can reimplement the bodies.
29364
29365 @item
29366 Some features introduced by Ada 95 obviate the need for library support. For
29367 example most Ada 83 vendors supplied a package for unsigned integers. The
29368 Ada 95 modular type feature is the preferred way to handle this need, so
29369 instead of migrating or reimplementing the unsigned integer package it may
29370 be preferable to retrofit the application using modular types.
29371 @end itemize
29372
29373 @node Elaboration order,Target-specific aspects,Libraries,Implementation-dependent characteristics
29374 @anchor{gnat_rm/compatibility_and_porting_guide elaboration-order}@anchor{458}@anchor{gnat_rm/compatibility_and_porting_guide id13}@anchor{459}
29375 @subsection Elaboration order
29376
29377
29378 The implementation can choose any elaboration order consistent with the unit
29379 dependency relationship. This freedom means that some orders can result in
29380 Program_Error being raised due to an 'Access Before Elaboration': an attempt
29381 to invoke a subprogram before its body has been elaborated, or to instantiate
29382 a generic before the generic body has been elaborated. By default GNAT
29383 attempts to choose a safe order (one that will not encounter access before
29384 elaboration problems) by implicitly inserting @code{Elaborate} or
29385 @code{Elaborate_All} pragmas where
29386 needed. However, this can lead to the creation of elaboration circularities
29387 and a resulting rejection of the program by gnatbind. This issue is
29388 thoroughly described in the @emph{Elaboration Order Handling in GNAT} appendix
29389 in the @cite{GNAT User's Guide}.
29390 In brief, there are several
29391 ways to deal with this situation:
29392
29393
29394 @itemize *
29395
29396 @item
29397 Modify the program to eliminate the circularities, e.g., by moving
29398 elaboration-time code into explicitly-invoked procedures
29399
29400 @item
29401 Constrain the elaboration order by including explicit @code{Elaborate_Body} or
29402 @code{Elaborate} pragmas, and then inhibit the generation of implicit
29403 @code{Elaborate_All}
29404 pragmas either globally (as an effect of the @emph{-gnatE} switch) or locally
29405 (by selectively suppressing elaboration checks via pragma
29406 @code{Suppress(Elaboration_Check)} when it is safe to do so).
29407 @end itemize
29408
29409 @node Target-specific aspects,,Elaboration order,Implementation-dependent characteristics
29410 @anchor{gnat_rm/compatibility_and_porting_guide target-specific-aspects}@anchor{45a}@anchor{gnat_rm/compatibility_and_porting_guide id14}@anchor{45b}
29411 @subsection Target-specific aspects
29412
29413
29414 Low-level applications need to deal with machine addresses, data
29415 representations, interfacing with assembler code, and similar issues. If
29416 such an Ada 83 application is being ported to different target hardware (for
29417 example where the byte endianness has changed) then you will need to
29418 carefully examine the program logic; the porting effort will heavily depend
29419 on the robustness of the original design. Moreover, Ada 95 (and thus
29420 Ada 2005 and Ada 2012) are sometimes
29421 incompatible with typical Ada 83 compiler practices regarding implicit
29422 packing, the meaning of the Size attribute, and the size of access values.
29423 GNAT's approach to these issues is described in @ref{45c,,Representation Clauses}.
29424
29425 @node Compatibility with Other Ada Systems,Representation Clauses,Implementation-dependent characteristics,Compatibility and Porting Guide
29426 @anchor{gnat_rm/compatibility_and_porting_guide id15}@anchor{45d}@anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-other-ada-systems}@anchor{45e}
29427 @section Compatibility with Other Ada Systems
29428
29429
29430 If programs avoid the use of implementation dependent and
29431 implementation defined features, as documented in the
29432 @cite{Ada Reference Manual}, there should be a high degree of portability between
29433 GNAT and other Ada systems. The following are specific items which
29434 have proved troublesome in moving Ada 95 programs from GNAT to other Ada 95
29435 compilers, but do not affect porting code to GNAT.
29436 (As of January 2007, GNAT is the only compiler available for Ada 2005;
29437 the following issues may or may not arise for Ada 2005 programs
29438 when other compilers appear.)
29439
29440
29441 @itemize *
29442
29443 @item
29444 @emph{Ada 83 Pragmas and Attributes}
29445
29446 Ada 95 compilers are allowed, but not required, to implement the missing
29447 Ada 83 pragmas and attributes that are no longer defined in Ada 95.
29448 GNAT implements all such pragmas and attributes, eliminating this as
29449 a compatibility concern, but some other Ada 95 compilers reject these
29450 pragmas and attributes.
29451
29452 @item
29453 @emph{Specialized Needs Annexes}
29454
29455 GNAT implements the full set of special needs annexes. At the
29456 current time, it is the only Ada 95 compiler to do so. This means that
29457 programs making use of these features may not be portable to other Ada
29458 95 compilation systems.
29459
29460 @item
29461 @emph{Representation Clauses}
29462
29463 Some other Ada 95 compilers implement only the minimal set of
29464 representation clauses required by the Ada 95 reference manual. GNAT goes
29465 far beyond this minimal set, as described in the next section.
29466 @end itemize
29467
29468 @node Representation Clauses,Compatibility with HP Ada 83,Compatibility with Other Ada Systems,Compatibility and Porting Guide
29469 @anchor{gnat_rm/compatibility_and_porting_guide representation-clauses}@anchor{45c}@anchor{gnat_rm/compatibility_and_porting_guide id16}@anchor{45f}
29470 @section Representation Clauses
29471
29472
29473 The Ada 83 reference manual was quite vague in describing both the minimal
29474 required implementation of representation clauses, and also their precise
29475 effects. Ada 95 (and thus also Ada 2005) are much more explicit, but the
29476 minimal set of capabilities required is still quite limited.
29477
29478 GNAT implements the full required set of capabilities in
29479 Ada 95 and Ada 2005, but also goes much further, and in particular
29480 an effort has been made to be compatible with existing Ada 83 usage to the
29481 greatest extent possible.
29482
29483 A few cases exist in which Ada 83 compiler behavior is incompatible with
29484 the requirements in Ada 95 (and thus also Ada 2005). These are instances of
29485 intentional or accidental dependence on specific implementation dependent
29486 characteristics of these Ada 83 compilers. The following is a list of
29487 the cases most likely to arise in existing Ada 83 code.
29488
29489
29490 @itemize *
29491
29492 @item
29493 @emph{Implicit Packing}
29494
29495 Some Ada 83 compilers allowed a Size specification to cause implicit
29496 packing of an array or record. This could cause expensive implicit
29497 conversions for change of representation in the presence of derived
29498 types, and the Ada design intends to avoid this possibility.
29499 Subsequent AI's were issued to make it clear that such implicit
29500 change of representation in response to a Size clause is inadvisable,
29501 and this recommendation is represented explicitly in the Ada 95 (and Ada 2005)
29502 Reference Manuals as implementation advice that is followed by GNAT.
29503 The problem will show up as an error
29504 message rejecting the size clause. The fix is simply to provide
29505 the explicit pragma @code{Pack}, or for more fine tuned control, provide
29506 a Component_Size clause.
29507
29508 @item
29509 @emph{Meaning of Size Attribute}
29510
29511 The Size attribute in Ada 95 (and Ada 2005) for discrete types is defined as
29512 the minimal number of bits required to hold values of the type. For example,
29513 on a 32-bit machine, the size of @code{Natural} will typically be 31 and not
29514 32 (since no sign bit is required). Some Ada 83 compilers gave 31, and
29515 some 32 in this situation. This problem will usually show up as a compile
29516 time error, but not always. It is a good idea to check all uses of the
29517 'Size attribute when porting Ada 83 code. The GNAT specific attribute
29518 Object_Size can provide a useful way of duplicating the behavior of
29519 some Ada 83 compiler systems.
29520
29521 @item
29522 @emph{Size of Access Types}
29523
29524 A common assumption in Ada 83 code is that an access type is in fact a pointer,
29525 and that therefore it will be the same size as a System.Address value. This
29526 assumption is true for GNAT in most cases with one exception. For the case of
29527 a pointer to an unconstrained array type (where the bounds may vary from one
29528 value of the access type to another), the default is to use a 'fat pointer',
29529 which is represented as two separate pointers, one to the bounds, and one to
29530 the array. This representation has a number of advantages, including improved
29531 efficiency. However, it may cause some difficulties in porting existing Ada 83
29532 code which makes the assumption that, for example, pointers fit in 32 bits on
29533 a machine with 32-bit addressing.
29534
29535 To get around this problem, GNAT also permits the use of 'thin pointers' for
29536 access types in this case (where the designated type is an unconstrained array
29537 type). These thin pointers are indeed the same size as a System.Address value.
29538 To specify a thin pointer, use a size clause for the type, for example:
29539
29540 @example
29541 type X is access all String;
29542 for X'Size use Standard'Address_Size;
29543 @end example
29544
29545 which will cause the type X to be represented using a single pointer.
29546 When using this representation, the bounds are right behind the array.
29547 This representation is slightly less efficient, and does not allow quite
29548 such flexibility in the use of foreign pointers or in using the
29549 Unrestricted_Access attribute to create pointers to non-aliased objects.
29550 But for any standard portable use of the access type it will work in
29551 a functionally correct manner and allow porting of existing code.
29552 Note that another way of forcing a thin pointer representation
29553 is to use a component size clause for the element size in an array,
29554 or a record representation clause for an access field in a record.
29555
29556 See the documentation of Unrestricted_Access in the GNAT RM for a
29557 full discussion of possible problems using this attribute in conjunction
29558 with thin pointers.
29559 @end itemize
29560
29561 @node Compatibility with HP Ada 83,,Representation Clauses,Compatibility and Porting Guide
29562 @anchor{gnat_rm/compatibility_and_porting_guide compatibility-with-hp-ada-83}@anchor{460}@anchor{gnat_rm/compatibility_and_porting_guide id17}@anchor{461}
29563 @section Compatibility with HP Ada 83
29564
29565
29566 All the HP Ada 83 pragmas and attributes are recognized, although only a subset
29567 of them can sensibly be implemented. The description of pragmas in
29568 @ref{7,,Implementation Defined Pragmas} indicates whether or not they are
29569 applicable to GNAT.
29570
29571
29572 @itemize *
29573
29574 @item
29575 @emph{Default floating-point representation}
29576
29577 In GNAT, the default floating-point format is IEEE, whereas in HP Ada 83,
29578 it is VMS format.
29579
29580 @item
29581 @emph{System}
29582
29583 the package System in GNAT exactly corresponds to the definition in the
29584 Ada 95 reference manual, which means that it excludes many of the
29585 HP Ada 83 extensions. However, a separate package Aux_DEC is provided
29586 that contains the additional definitions, and a special pragma,
29587 Extend_System allows this package to be treated transparently as an
29588 extension of package System.
29589 @end itemize
29590
29591 @node GNU Free Documentation License,Index,Compatibility and Porting Guide,Top
29592 @anchor{share/gnu_free_documentation_license gnu-fdl}@anchor{1}@anchor{share/gnu_free_documentation_license doc}@anchor{462}@anchor{share/gnu_free_documentation_license gnu-free-documentation-license}@anchor{463}
29593 @chapter GNU Free Documentation License
29594
29595
29596 Version 1.3, 3 November 2008
29597
29598 Copyright 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc
29599 @indicateurl{http://fsf.org/}
29600
29601 Everyone is permitted to copy and distribute verbatim copies of this
29602 license document, but changing it is not allowed.
29603
29604 @strong{Preamble}
29605
29606 The purpose of this License is to make a manual, textbook, or other
29607 functional and useful document "free" in the sense of freedom: to
29608 assure everyone the effective freedom to copy and redistribute it,
29609 with or without modifying it, either commercially or noncommercially.
29610 Secondarily, this License preserves for the author and publisher a way
29611 to get credit for their work, while not being considered responsible
29612 for modifications made by others.
29613
29614 This License is a kind of "copyleft", which means that derivative
29615 works of the document must themselves be free in the same sense. It
29616 complements the GNU General Public License, which is a copyleft
29617 license designed for free software.
29618
29619 We have designed this License in order to use it for manuals for free
29620 software, because free software needs free documentation: a free
29621 program should come with manuals providing the same freedoms that the
29622 software does. But this License is not limited to software manuals;
29623 it can be used for any textual work, regardless of subject matter or
29624 whether it is published as a printed book. We recommend this License
29625 principally for works whose purpose is instruction or reference.
29626
29627 @strong{1. APPLICABILITY AND DEFINITIONS}
29628
29629 This License applies to any manual or other work, in any medium, that
29630 contains a notice placed by the copyright holder saying it can be
29631 distributed under the terms of this License. Such a notice grants a
29632 world-wide, royalty-free license, unlimited in duration, to use that
29633 work under the conditions stated herein. The @strong{Document}, below,
29634 refers to any such manual or work. Any member of the public is a
29635 licensee, and is addressed as "@strong{you}". You accept the license if you
29636 copy, modify or distribute the work in a way requiring permission
29637 under copyright law.
29638
29639 A "@strong{Modified Version}" of the Document means any work containing the
29640 Document or a portion of it, either copied verbatim, or with
29641 modifications and/or translated into another language.
29642
29643 A "@strong{Secondary Section}" is a named appendix or a front-matter section of
29644 the Document that deals exclusively with the relationship of the
29645 publishers or authors of the Document to the Document's overall subject
29646 (or to related matters) and contains nothing that could fall directly
29647 within that overall subject. (Thus, if the Document is in part a
29648 textbook of mathematics, a Secondary Section may not explain any
29649 mathematics.) The relationship could be a matter of historical
29650 connection with the subject or with related matters, or of legal,
29651 commercial, philosophical, ethical or political position regarding
29652 them.
29653
29654 The "@strong{Invariant Sections}" are certain Secondary Sections whose titles
29655 are designated, as being those of Invariant Sections, in the notice
29656 that says that the Document is released under this License. If a
29657 section does not fit the above definition of Secondary then it is not
29658 allowed to be designated as Invariant. The Document may contain zero
29659 Invariant Sections. If the Document does not identify any Invariant
29660 Sections then there are none.
29661
29662 The "@strong{Cover Texts}" are certain short passages of text that are listed,
29663 as Front-Cover Texts or Back-Cover Texts, in the notice that says that
29664 the Document is released under this License. A Front-Cover Text may
29665 be at most 5 words, and a Back-Cover Text may be at most 25 words.
29666
29667 A "@strong{Transparent}" copy of the Document means a machine-readable copy,
29668 represented in a format whose specification is available to the
29669 general public, that is suitable for revising the document
29670 straightforwardly with generic text editors or (for images composed of
29671 pixels) generic paint programs or (for drawings) some widely available
29672 drawing editor, and that is suitable for input to text formatters or
29673 for automatic translation to a variety of formats suitable for input
29674 to text formatters. A copy made in an otherwise Transparent file
29675 format whose markup, or absence of markup, has been arranged to thwart
29676 or discourage subsequent modification by readers is not Transparent.
29677 An image format is not Transparent if used for any substantial amount
29678 of text. A copy that is not "Transparent" is called @strong{Opaque}.
29679
29680 Examples of suitable formats for Transparent copies include plain
29681 ASCII without markup, Texinfo input format, LaTeX input format, SGML
29682 or XML using a publicly available DTD, and standard-conforming simple
29683 HTML, PostScript or PDF designed for human modification. Examples of
29684 transparent image formats include PNG, XCF and JPG. Opaque formats
29685 include proprietary formats that can be read and edited only by
29686 proprietary word processors, SGML or XML for which the DTD and/or
29687 processing tools are not generally available, and the
29688 machine-generated HTML, PostScript or PDF produced by some word
29689 processors for output purposes only.
29690
29691 The "@strong{Title Page}" means, for a printed book, the title page itself,
29692 plus such following pages as are needed to hold, legibly, the material
29693 this License requires to appear in the title page. For works in
29694 formats which do not have any title page as such, "Title Page" means
29695 the text near the most prominent appearance of the work's title,
29696 preceding the beginning of the body of the text.
29697
29698 The "@strong{publisher}" means any person or entity that distributes
29699 copies of the Document to the public.
29700
29701 A section "@strong{Entitled XYZ}" means a named subunit of the Document whose
29702 title either is precisely XYZ or contains XYZ in parentheses following
29703 text that translates XYZ in another language. (Here XYZ stands for a
29704 specific section name mentioned below, such as "@strong{Acknowledgements}",
29705 "@strong{Dedications}", "@strong{Endorsements}", or "@strong{History}".)
29706 To "@strong{Preserve the Title}"
29707 of such a section when you modify the Document means that it remains a
29708 section "Entitled XYZ" according to this definition.
29709
29710 The Document may include Warranty Disclaimers next to the notice which
29711 states that this License applies to the Document. These Warranty
29712 Disclaimers are considered to be included by reference in this
29713 License, but only as regards disclaiming warranties: any other
29714 implication that these Warranty Disclaimers may have is void and has
29715 no effect on the meaning of this License.
29716
29717 @strong{2. VERBATIM COPYING}
29718
29719 You may copy and distribute the Document in any medium, either
29720 commercially or noncommercially, provided that this License, the
29721 copyright notices, and the license notice saying this License applies
29722 to the Document are reproduced in all copies, and that you add no other
29723 conditions whatsoever to those of this License. You may not use
29724 technical measures to obstruct or control the reading or further
29725 copying of the copies you make or distribute. However, you may accept
29726 compensation in exchange for copies. If you distribute a large enough
29727 number of copies you must also follow the conditions in section 3.
29728
29729 You may also lend copies, under the same conditions stated above, and
29730 you may publicly display copies.
29731
29732 @strong{3. COPYING IN QUANTITY}
29733
29734 If you publish printed copies (or copies in media that commonly have
29735 printed covers) of the Document, numbering more than 100, and the
29736 Document's license notice requires Cover Texts, you must enclose the
29737 copies in covers that carry, clearly and legibly, all these Cover
29738 Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
29739 the back cover. Both covers must also clearly and legibly identify
29740 you as the publisher of these copies. The front cover must present
29741 the full title with all words of the title equally prominent and
29742 visible. You may add other material on the covers in addition.
29743 Copying with changes limited to the covers, as long as they preserve
29744 the title of the Document and satisfy these conditions, can be treated
29745 as verbatim copying in other respects.
29746
29747 If the required texts for either cover are too voluminous to fit
29748 legibly, you should put the first ones listed (as many as fit
29749 reasonably) on the actual cover, and continue the rest onto adjacent
29750 pages.
29751
29752 If you publish or distribute Opaque copies of the Document numbering
29753 more than 100, you must either include a machine-readable Transparent
29754 copy along with each Opaque copy, or state in or with each Opaque copy
29755 a computer-network location from which the general network-using
29756 public has access to download using public-standard network protocols
29757 a complete Transparent copy of the Document, free of added material.
29758 If you use the latter option, you must take reasonably prudent steps,
29759 when you begin distribution of Opaque copies in quantity, to ensure
29760 that this Transparent copy will remain thus accessible at the stated
29761 location until at least one year after the last time you distribute an
29762 Opaque copy (directly or through your agents or retailers) of that
29763 edition to the public.
29764
29765 It is requested, but not required, that you contact the authors of the
29766 Document well before redistributing any large number of copies, to give
29767 them a chance to provide you with an updated version of the Document.
29768
29769 @strong{4. MODIFICATIONS}
29770
29771 You may copy and distribute a Modified Version of the Document under
29772 the conditions of sections 2 and 3 above, provided that you release
29773 the Modified Version under precisely this License, with the Modified
29774 Version filling the role of the Document, thus licensing distribution
29775 and modification of the Modified Version to whoever possesses a copy
29776 of it. In addition, you must do these things in the Modified Version:
29777
29778
29779 @enumerate A
29780
29781 @item
29782 Use in the Title Page (and on the covers, if any) a title distinct
29783 from that of the Document, and from those of previous versions
29784 (which should, if there were any, be listed in the History section
29785 of the Document). You may use the same title as a previous version
29786 if the original publisher of that version gives permission.
29787
29788 @item
29789 List on the Title Page, as authors, one or more persons or entities
29790 responsible for authorship of the modifications in the Modified
29791 Version, together with at least five of the principal authors of the
29792 Document (all of its principal authors, if it has fewer than five),
29793 unless they release you from this requirement.
29794
29795 @item
29796 State on the Title page the name of the publisher of the
29797 Modified Version, as the publisher.
29798
29799 @item
29800 Preserve all the copyright notices of the Document.
29801
29802 @item
29803 Add an appropriate copyright notice for your modifications
29804 adjacent to the other copyright notices.
29805
29806 @item
29807 Include, immediately after the copyright notices, a license notice
29808 giving the public permission to use the Modified Version under the
29809 terms of this License, in the form shown in the Addendum below.
29810
29811 @item
29812 Preserve in that license notice the full lists of Invariant Sections
29813 and required Cover Texts given in the Document's license notice.
29814
29815 @item
29816 Include an unaltered copy of this License.
29817
29818 @item
29819 Preserve the section Entitled "History", Preserve its Title, and add
29820 to it an item stating at least the title, year, new authors, and
29821 publisher of the Modified Version as given on the Title Page. If
29822 there is no section Entitled "History" in the Document, create one
29823 stating the title, year, authors, and publisher of the Document as
29824 given on its Title Page, then add an item describing the Modified
29825 Version as stated in the previous sentence.
29826
29827 @item
29828 Preserve the network location, if any, given in the Document for
29829 public access to a Transparent copy of the Document, and likewise
29830 the network locations given in the Document for previous versions
29831 it was based on. These may be placed in the "History" section.
29832 You may omit a network location for a work that was published at
29833 least four years before the Document itself, or if the original
29834 publisher of the version it refers to gives permission.
29835
29836 @item
29837 For any section Entitled "Acknowledgements" or "Dedications",
29838 Preserve the Title of the section, and preserve in the section all
29839 the substance and tone of each of the contributor acknowledgements
29840 and/or dedications given therein.
29841
29842 @item
29843 Preserve all the Invariant Sections of the Document,
29844 unaltered in their text and in their titles. Section numbers
29845 or the equivalent are not considered part of the section titles.
29846
29847 @item
29848 Delete any section Entitled "Endorsements". Such a section
29849 may not be included in the Modified Version.
29850
29851 @item
29852 Do not retitle any existing section to be Entitled "Endorsements"
29853 or to conflict in title with any Invariant Section.
29854
29855 @item
29856 Preserve any Warranty Disclaimers.
29857 @end enumerate
29858
29859 If the Modified Version includes new front-matter sections or
29860 appendices that qualify as Secondary Sections and contain no material
29861 copied from the Document, you may at your option designate some or all
29862 of these sections as invariant. To do this, add their titles to the
29863 list of Invariant Sections in the Modified Version's license notice.
29864 These titles must be distinct from any other section titles.
29865
29866 You may add a section Entitled "Endorsements", provided it contains
29867 nothing but endorsements of your Modified Version by various
29868 parties---for example, statements of peer review or that the text has
29869 been approved by an organization as the authoritative definition of a
29870 standard.
29871
29872 You may add a passage of up to five words as a Front-Cover Text, and a
29873 passage of up to 25 words as a Back-Cover Text, to the end of the list
29874 of Cover Texts in the Modified Version. Only one passage of
29875 Front-Cover Text and one of Back-Cover Text may be added by (or
29876 through arrangements made by) any one entity. If the Document already
29877 includes a cover text for the same cover, previously added by you or
29878 by arrangement made by the same entity you are acting on behalf of,
29879 you may not add another; but you may replace the old one, on explicit
29880 permission from the previous publisher that added the old one.
29881
29882 The author(s) and publisher(s) of the Document do not by this License
29883 give permission to use their names for publicity for or to assert or
29884 imply endorsement of any Modified Version.
29885
29886 @strong{5. COMBINING DOCUMENTS}
29887
29888 You may combine the Document with other documents released under this
29889 License, under the terms defined in section 4 above for modified
29890 versions, provided that you include in the combination all of the
29891 Invariant Sections of all of the original documents, unmodified, and
29892 list them all as Invariant Sections of your combined work in its
29893 license notice, and that you preserve all their Warranty Disclaimers.
29894
29895 The combined work need only contain one copy of this License, and
29896 multiple identical Invariant Sections may be replaced with a single
29897 copy. If there are multiple Invariant Sections with the same name but
29898 different contents, make the title of each such section unique by
29899 adding at the end of it, in parentheses, the name of the original
29900 author or publisher of that section if known, or else a unique number.
29901 Make the same adjustment to the section titles in the list of
29902 Invariant Sections in the license notice of the combined work.
29903
29904 In the combination, you must combine any sections Entitled "History"
29905 in the various original documents, forming one section Entitled
29906 "History"; likewise combine any sections Entitled "Acknowledgements",
29907 and any sections Entitled "Dedications". You must delete all sections
29908 Entitled "Endorsements".
29909
29910 @strong{6. COLLECTIONS OF DOCUMENTS}
29911
29912 You may make a collection consisting of the Document and other documents
29913 released under this License, and replace the individual copies of this
29914 License in the various documents with a single copy that is included in
29915 the collection, provided that you follow the rules of this License for
29916 verbatim copying of each of the documents in all other respects.
29917
29918 You may extract a single document from such a collection, and distribute
29919 it individually under this License, provided you insert a copy of this
29920 License into the extracted document, and follow this License in all
29921 other respects regarding verbatim copying of that document.
29922
29923 @strong{7. AGGREGATION WITH INDEPENDENT WORKS}
29924
29925 A compilation of the Document or its derivatives with other separate
29926 and independent documents or works, in or on a volume of a storage or
29927 distribution medium, is called an "aggregate" if the copyright
29928 resulting from the compilation is not used to limit the legal rights
29929 of the compilation's users beyond what the individual works permit.
29930 When the Document is included in an aggregate, this License does not
29931 apply to the other works in the aggregate which are not themselves
29932 derivative works of the Document.
29933
29934 If the Cover Text requirement of section 3 is applicable to these
29935 copies of the Document, then if the Document is less than one half of
29936 the entire aggregate, the Document's Cover Texts may be placed on
29937 covers that bracket the Document within the aggregate, or the
29938 electronic equivalent of covers if the Document is in electronic form.
29939 Otherwise they must appear on printed covers that bracket the whole
29940 aggregate.
29941
29942 @strong{8. TRANSLATION}
29943
29944 Translation is considered a kind of modification, so you may
29945 distribute translations of the Document under the terms of section 4.
29946 Replacing Invariant Sections with translations requires special
29947 permission from their copyright holders, but you may include
29948 translations of some or all Invariant Sections in addition to the
29949 original versions of these Invariant Sections. You may include a
29950 translation of this License, and all the license notices in the
29951 Document, and any Warranty Disclaimers, provided that you also include
29952 the original English version of this License and the original versions
29953 of those notices and disclaimers. In case of a disagreement between
29954 the translation and the original version of this License or a notice
29955 or disclaimer, the original version will prevail.
29956
29957 If a section in the Document is Entitled "Acknowledgements",
29958 "Dedications", or "History", the requirement (section 4) to Preserve
29959 its Title (section 1) will typically require changing the actual
29960 title.
29961
29962 @strong{9. TERMINATION}
29963
29964 You may not copy, modify, sublicense, or distribute the Document
29965 except as expressly provided under this License. Any attempt
29966 otherwise to copy, modify, sublicense, or distribute it is void, and
29967 will automatically terminate your rights under this License.
29968
29969 However, if you cease all violation of this License, then your license
29970 from a particular copyright holder is reinstated (a) provisionally,
29971 unless and until the copyright holder explicitly and finally
29972 terminates your license, and (b) permanently, if the copyright holder
29973 fails to notify you of the violation by some reasonable means prior to
29974 60 days after the cessation.
29975
29976 Moreover, your license from a particular copyright holder is
29977 reinstated permanently if the copyright holder notifies you of the
29978 violation by some reasonable means, this is the first time you have
29979 received notice of violation of this License (for any work) from that
29980 copyright holder, and you cure the violation prior to 30 days after
29981 your receipt of the notice.
29982
29983 Termination of your rights under this section does not terminate the
29984 licenses of parties who have received copies or rights from you under
29985 this License. If your rights have been terminated and not permanently
29986 reinstated, receipt of a copy of some or all of the same material does
29987 not give you any rights to use it.
29988
29989 @strong{10. FUTURE REVISIONS OF THIS LICENSE}
29990
29991 The Free Software Foundation may publish new, revised versions
29992 of the GNU Free Documentation License from time to time. Such new
29993 versions will be similar in spirit to the present version, but may
29994 differ in detail to address new problems or concerns. See
29995 @indicateurl{http://www.gnu.org/copyleft/}.
29996
29997 Each version of the License is given a distinguishing version number.
29998 If the Document specifies that a particular numbered version of this
29999 License "or any later version" applies to it, you have the option of
30000 following the terms and conditions either of that specified version or
30001 of any later version that has been published (not as a draft) by the
30002 Free Software Foundation. If the Document does not specify a version
30003 number of this License, you may choose any version ever published (not
30004 as a draft) by the Free Software Foundation. If the Document
30005 specifies that a proxy can decide which future versions of this
30006 License can be used, that proxy's public statement of acceptance of a
30007 version permanently authorizes you to choose that version for the
30008 Document.
30009
30010 @strong{11. RELICENSING}
30011
30012 "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
30013 World Wide Web server that publishes copyrightable works and also
30014 provides prominent facilities for anybody to edit those works. A
30015 public wiki that anybody can edit is an example of such a server. A
30016 "Massive Multiauthor Collaboration" (or "MMC") contained in the
30017 site means any set of copyrightable works thus published on the MMC
30018 site.
30019
30020 "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
30021 license published by Creative Commons Corporation, a not-for-profit
30022 corporation with a principal place of business in San Francisco,
30023 California, as well as future copyleft versions of that license
30024 published by that same organization.
30025
30026 "Incorporate" means to publish or republish a Document, in whole or
30027 in part, as part of another Document.
30028
30029 An MMC is "eligible for relicensing" if it is licensed under this
30030 License, and if all works that were first published under this License
30031 somewhere other than this MMC, and subsequently incorporated in whole
30032 or in part into the MMC, (1) had no cover texts or invariant sections,
30033 and (2) were thus incorporated prior to November 1, 2008.
30034
30035 The operator of an MMC Site may republish an MMC contained in the site
30036 under CC-BY-SA on the same site at any time before August 1, 2009,
30037 provided the MMC is eligible for relicensing.
30038
30039 @strong{ADDENDUM: How to use this License for your documents}
30040
30041 To use this License in a document you have written, include a copy of
30042 the License in the document and put the following copyright and
30043 license notices just after the title page:
30044
30045 @quotation
30046
30047 Copyright © YEAR YOUR NAME.
30048 Permission is granted to copy, distribute and/or modify this document
30049 under the terms of the GNU Free Documentation License, Version 1.3
30050 or any later version published by the Free Software Foundation;
30051 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
30052 A copy of the license is included in the section entitled "GNU
30053 Free Documentation License".
30054 @end quotation
30055
30056 If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
30057 replace the "with ... Texts." line with this:
30058
30059 @quotation
30060
30061 with the Invariant Sections being LIST THEIR TITLES, with the
30062 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
30063 @end quotation
30064
30065 If you have Invariant Sections without Cover Texts, or some other
30066 combination of the three, merge those two alternatives to suit the
30067 situation.
30068
30069 If your document contains nontrivial examples of program code, we
30070 recommend releasing these examples in parallel under your choice of
30071 free software license, such as the GNU General Public License,
30072 to permit their use in free software.
30073
30074 @node Index,,GNU Free Documentation License,Top
30075 @unnumbered Index
30076
30077
30078 @printindex ge
30079
30080
30081 @c %**end of body
30082 @bye