ce5a35d1b639bf386a5feb138e97ac0acfad3e8d
[gcc.git] / gcc / ada / gnat_rm.texi
1 \input texinfo @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c o
7 @c GNAT DOCUMENTATION o
8 @c o
9 @c G N A T _ RM o
10 @c o
11 @c GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). o
12 @c o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2012, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts. A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm). Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Standard and Implementation Defined Restrictions::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
81 * The GNAT Library::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Implementation of Ada 2012 Features::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
88 * Index::
89
90 --- The Detailed Node Listing ---
91
92 About This Guide
93
94 * What This Reference Manual Contains::
95 * Related Information::
96
97 Implementation Defined Pragmas
98
99 * Pragma Abort_Defer::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Ada_12::
105 * Pragma Ada_2012::
106 * Pragma Annotate::
107 * Pragma Assert::
108 * Pragma Assertion_Policy::
109 * Pragma Assume_No_Invalid_Values::
110 * Pragma Attribute_Definition::
111 * Pragma Ast_Entry::
112 * Pragma C_Pass_By_Copy::
113 * Pragma Check::
114 * Pragma Check_Float_Overflow::
115 * Pragma Check_Name::
116 * Pragma Check_Policy::
117 * Pragma Comment::
118 * Pragma Common_Object::
119 * Pragma Compile_Time_Error::
120 * Pragma Compile_Time_Warning::
121 * Pragma Compiler_Unit::
122 * Pragma Complete_Representation::
123 * Pragma Complex_Representation::
124 * Pragma Component_Alignment::
125 * Pragma Contract_Case::
126 * Pragma Convention_Identifier::
127 * Pragma CPP_Class::
128 * Pragma CPP_Constructor::
129 * Pragma CPP_Virtual::
130 * Pragma CPP_Vtable::
131 * Pragma CPU::
132 * Pragma Debug::
133 * Pragma Debug_Policy::
134 * Pragma Default_Storage_Pool::
135 * Pragma Detect_Blocking::
136 * Pragma Dispatching_Domain::
137 * Pragma Elaboration_Checks::
138 * Pragma Eliminate::
139 * Pragma Export_Exception::
140 * Pragma Export_Function::
141 * Pragma Export_Object::
142 * Pragma Export_Procedure::
143 * Pragma Export_Value::
144 * Pragma Export_Valued_Procedure::
145 * Pragma Extend_System::
146 * Pragma Extensions_Allowed::
147 * Pragma External::
148 * Pragma External_Name_Casing::
149 * Pragma Fast_Math::
150 * Pragma Favor_Top_Level::
151 * Pragma Finalize_Storage_Only::
152 * Pragma Float_Representation::
153 * Pragma Ident::
154 * Pragma Implementation_Defined::
155 * Pragma Implemented::
156 * Pragma Implicit_Packing::
157 * Pragma Import_Exception::
158 * Pragma Import_Function::
159 * Pragma Import_Object::
160 * Pragma Import_Procedure::
161 * Pragma Import_Valued_Procedure::
162 * Pragma Independent::
163 * Pragma Independent_Components::
164 * Pragma Initialize_Scalars::
165 * Pragma Inline_Always::
166 * Pragma Inline_Generic::
167 * Pragma Interface::
168 * Pragma Interface_Name::
169 * Pragma Interrupt_Handler::
170 * Pragma Interrupt_State::
171 * Pragma Invariant::
172 * Pragma Keep_Names::
173 * Pragma License::
174 * Pragma Link_With::
175 * Pragma Linker_Alias::
176 * Pragma Linker_Constructor::
177 * Pragma Linker_Destructor::
178 * Pragma Linker_Section::
179 * Pragma Long_Float::
180 * Pragma Loop_Optimize::
181 * Pragma Machine_Attribute::
182 * Pragma Main::
183 * Pragma Main_Storage::
184 * Pragma No_Body::
185 * Pragma No_Inline::
186 * Pragma No_Return::
187 * Pragma No_Strict_Aliasing ::
188 * Pragma Normalize_Scalars::
189 * Pragma Obsolescent::
190 * Pragma Optimize_Alignment::
191 * Pragma Ordered::
192 * Pragma Overflow_Mode::
193 * Pragma Partition_Elaboration_Policy::
194 * Pragma Passive::
195 * Pragma Persistent_BSS::
196 * Pragma Polling::
197 * Pragma Postcondition::
198 * Pragma Precondition::
199 * Pragma Preelaborable_Initialization::
200 * Pragma Priority_Specific_Dispatching::
201 * Pragma Profile (Ravenscar)::
202 * Pragma Profile (Restricted)::
203 * Pragma Profile (Rational)::
204 * Pragma Psect_Object::
205 * Pragma Pure_Function::
206 * Pragma Relative_Deadline::
207 * Pragma Remote_Access_Type::
208 * Pragma Restriction_Warnings::
209 * Pragma Shared::
210 * Pragma Short_Circuit_And_Or::
211 * Pragma Short_Descriptors::
212 * Pragma Simple_Storage_Pool_Type::
213 * Pragma Source_File_Name::
214 * Pragma Source_File_Name_Project::
215 * Pragma Source_Reference::
216 * Pragma Static_Elaboration_Desired::
217 * Pragma Stream_Convert::
218 * Pragma Style_Checks::
219 * Pragma Subtitle::
220 * Pragma Suppress::
221 * Pragma Suppress_All::
222 * Pragma Suppress_Exception_Locations::
223 * Pragma Suppress_Initialization::
224 * Pragma Task_Info::
225 * Pragma Task_Name::
226 * Pragma Task_Storage::
227 * Pragma Test_Case::
228 * Pragma Thread_Local_Storage::
229 * Pragma Time_Slice::
230 * Pragma Title::
231 * Pragma Unchecked_Union::
232 * Pragma Unimplemented_Unit::
233 * Pragma Universal_Aliasing ::
234 * Pragma Universal_Data::
235 * Pragma Unmodified::
236 * Pragma Unreferenced::
237 * Pragma Unreferenced_Objects::
238 * Pragma Unreserve_All_Interrupts::
239 * Pragma Unsuppress::
240 * Pragma Use_VADS_Size::
241 * Pragma Validity_Checks::
242 * Pragma Volatile::
243 * Pragma Warnings::
244 * Pragma Weak_External::
245 * Pragma Wide_Character_Encoding::
246
247 Implementation Defined Attributes
248
249 * Abort_Signal::
250 * Address_Size::
251 * Asm_Input::
252 * Asm_Output::
253 * AST_Entry::
254 * Bit::
255 * Bit_Position::
256 * Compiler_Version::
257 * Code_Address::
258 * Default_Bit_Order::
259 * Descriptor_Size::
260 * Elaborated::
261 * Elab_Body::
262 * Elab_Spec::
263 * Elab_Subp_Body::
264 * Emax::
265 * Enabled::
266 * Enum_Rep::
267 * Enum_Val::
268 * Epsilon::
269 * Fixed_Value::
270 * Has_Access_Values::
271 * Has_Discriminants::
272 * Img::
273 * Integer_Value::
274 * Invalid_Value::
275 * Large::
276 * Machine_Size::
277 * Mantissa::
278 * Max_Interrupt_Priority::
279 * Max_Priority::
280 * Maximum_Alignment::
281 * Mechanism_Code::
282 * Null_Parameter::
283 * Object_Size::
284 * Passed_By_Reference::
285 * Pool_Address::
286 * Range_Length::
287 * Result::
288 * Safe_Emax::
289 * Safe_Large::
290 * Scalar_Storage_Order::
291 * Simple_Storage_Pool::
292 * Small::
293 * Storage_Unit::
294 * Stub_Type::
295 * System_Allocator_Alignment::
296 * Target_Name::
297 * Tick::
298 * To_Address::
299 * Type_Class::
300 * UET_Address::
301 * Unconstrained_Array::
302 * Universal_Literal_String::
303 * Unrestricted_Access::
304 * Valid_Scalars::
305 * VADS_Size::
306 * Value_Size::
307 * Wchar_T_Size::
308 * Word_Size::
309
310 Standard and Implementation Defined Restrictions
311
312 * Partition-Wide Restrictions::
313 * Program Unit Level Restrictions::
314
315 Partition-Wide Restrictions
316
317 * Immediate_Reclamation::
318 * Max_Asynchronous_Select_Nesting::
319 * Max_Entry_Queue_Length::
320 * Max_Protected_Entries::
321 * Max_Select_Alternatives::
322 * Max_Storage_At_Blocking::
323 * Max_Task_Entries::
324 * Max_Tasks::
325 * No_Abort_Statements::
326 * No_Access_Parameter_Allocators::
327 * No_Access_Subprograms::
328 * No_Allocators::
329 * No_Anonymous_Allocators::
330 * No_Calendar::
331 * No_Coextensions::
332 * No_Default_Initialization::
333 * No_Delay::
334 * No_Dependence::
335 * No_Direct_Boolean_Operators::
336 * No_Dispatch::
337 * No_Dispatching_Calls::
338 * No_Dynamic_Attachment::
339 * No_Dynamic_Priorities::
340 * No_Entry_Calls_In_Elaboration_Code::
341 * No_Enumeration_Maps::
342 * No_Exception_Handlers::
343 * No_Exception_Propagation::
344 * No_Exception_Registration::
345 * No_Exceptions::
346 * No_Finalization::
347 * No_Fixed_Point::
348 * No_Floating_Point::
349 * No_Implicit_Conditionals::
350 * No_Implicit_Dynamic_Code::
351 * No_Implicit_Heap_Allocations::
352 * No_Implicit_Loops::
353 * No_Initialize_Scalars::
354 * No_IO::
355 * No_Local_Allocators::
356 * No_Local_Protected_Objects::
357 * No_Local_Timing_Events::
358 * No_Nested_Finalization::
359 * No_Protected_Type_Allocators::
360 * No_Protected_Types::
361 * No_Recursion::
362 * No_Reentrancy::
363 * No_Relative_Delay::
364 * No_Requeue_Statements::
365 * No_Secondary_Stack::
366 * No_Select_Statements::
367 * No_Specific_Termination_Handlers::
368 * No_Specification_of_Aspect::
369 * No_Standard_Allocators_After_Elaboration::
370 * No_Standard_Storage_Pools::
371 * No_Stream_Optimizations::
372 * No_Streams::
373 * No_Task_Allocators::
374 * No_Task_Attributes_Package::
375 * No_Task_Hierarchy::
376 * No_Task_Termination::
377 * No_Tasking::
378 * No_Terminate_Alternatives::
379 * No_Unchecked_Access::
380 * Simple_Barriers::
381 * Static_Priorities::
382 * Static_Storage_Size::
383
384 Program Unit Level Restrictions
385
386 * No_Elaboration_Code::
387 * No_Entry_Queue::
388 * No_Implementation_Aspect_Specifications::
389 * No_Implementation_Attributes::
390 * No_Implementation_Identifiers::
391 * No_Implementation_Pragmas::
392 * No_Implementation_Restrictions::
393 * No_Implementation_Units::
394 * No_Implicit_Aliasing::
395 * No_Obsolescent_Features::
396 * No_Wide_Characters::
397 * SPARK::
398
399 The Implementation of Standard I/O
400
401 * Standard I/O Packages::
402 * FORM Strings::
403 * Direct_IO::
404 * Sequential_IO::
405 * Text_IO::
406 * Wide_Text_IO::
407 * Wide_Wide_Text_IO::
408 * Stream_IO::
409 * Text Translation::
410 * Shared Files::
411 * Filenames encoding::
412 * Open Modes::
413 * Operations on C Streams::
414 * Interfacing to C Streams::
415
416 The GNAT Library
417
418 * Ada.Characters.Latin_9 (a-chlat9.ads)::
419 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
420 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
421 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
422 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
423 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
424 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
425 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
426 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
427 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
428 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
429 * Ada.Command_Line.Environment (a-colien.ads)::
430 * Ada.Command_Line.Remove (a-colire.ads)::
431 * Ada.Command_Line.Response_File (a-clrefi.ads)::
432 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
433 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
434 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
435 * Ada.Exceptions.Traceback (a-exctra.ads)::
436 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
437 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
438 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
439 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
440 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
441 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
442 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
443 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
444 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
445 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
446 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
447 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
448 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
449 * GNAT.Altivec (g-altive.ads)::
450 * GNAT.Altivec.Conversions (g-altcon.ads)::
451 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
452 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
453 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
454 * GNAT.Array_Split (g-arrspl.ads)::
455 * GNAT.AWK (g-awk.ads)::
456 * GNAT.Bounded_Buffers (g-boubuf.ads)::
457 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
458 * GNAT.Bubble_Sort (g-bubsor.ads)::
459 * GNAT.Bubble_Sort_A (g-busora.ads)::
460 * GNAT.Bubble_Sort_G (g-busorg.ads)::
461 * GNAT.Byte_Order_Mark (g-byorma.ads)::
462 * GNAT.Byte_Swapping (g-bytswa.ads)::
463 * GNAT.Calendar (g-calend.ads)::
464 * GNAT.Calendar.Time_IO (g-catiio.ads)::
465 * GNAT.Case_Util (g-casuti.ads)::
466 * GNAT.CGI (g-cgi.ads)::
467 * GNAT.CGI.Cookie (g-cgicoo.ads)::
468 * GNAT.CGI.Debug (g-cgideb.ads)::
469 * GNAT.Command_Line (g-comlin.ads)::
470 * GNAT.Compiler_Version (g-comver.ads)::
471 * GNAT.Ctrl_C (g-ctrl_c.ads)::
472 * GNAT.CRC32 (g-crc32.ads)::
473 * GNAT.Current_Exception (g-curexc.ads)::
474 * GNAT.Debug_Pools (g-debpoo.ads)::
475 * GNAT.Debug_Utilities (g-debuti.ads)::
476 * GNAT.Decode_String (g-decstr.ads)::
477 * GNAT.Decode_UTF8_String (g-deutst.ads)::
478 * GNAT.Directory_Operations (g-dirope.ads)::
479 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
480 * GNAT.Dynamic_HTables (g-dynhta.ads)::
481 * GNAT.Dynamic_Tables (g-dyntab.ads)::
482 * GNAT.Encode_String (g-encstr.ads)::
483 * GNAT.Encode_UTF8_String (g-enutst.ads)::
484 * GNAT.Exception_Actions (g-excact.ads)::
485 * GNAT.Exception_Traces (g-exctra.ads)::
486 * GNAT.Exceptions (g-except.ads)::
487 * GNAT.Expect (g-expect.ads)::
488 * GNAT.Expect.TTY (g-exptty.ads)::
489 * GNAT.Float_Control (g-flocon.ads)::
490 * GNAT.Heap_Sort (g-heasor.ads)::
491 * GNAT.Heap_Sort_A (g-hesora.ads)::
492 * GNAT.Heap_Sort_G (g-hesorg.ads)::
493 * GNAT.HTable (g-htable.ads)::
494 * GNAT.IO (g-io.ads)::
495 * GNAT.IO_Aux (g-io_aux.ads)::
496 * GNAT.Lock_Files (g-locfil.ads)::
497 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
498 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
499 * GNAT.MD5 (g-md5.ads)::
500 * GNAT.Memory_Dump (g-memdum.ads)::
501 * GNAT.Most_Recent_Exception (g-moreex.ads)::
502 * GNAT.OS_Lib (g-os_lib.ads)::
503 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
504 * GNAT.Random_Numbers (g-rannum.ads)::
505 * GNAT.Regexp (g-regexp.ads)::
506 * GNAT.Registry (g-regist.ads)::
507 * GNAT.Regpat (g-regpat.ads)::
508 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
509 * GNAT.Semaphores (g-semaph.ads)::
510 * GNAT.Serial_Communications (g-sercom.ads)::
511 * GNAT.SHA1 (g-sha1.ads)::
512 * GNAT.SHA224 (g-sha224.ads)::
513 * GNAT.SHA256 (g-sha256.ads)::
514 * GNAT.SHA384 (g-sha384.ads)::
515 * GNAT.SHA512 (g-sha512.ads)::
516 * GNAT.Signals (g-signal.ads)::
517 * GNAT.Sockets (g-socket.ads)::
518 * GNAT.Source_Info (g-souinf.ads)::
519 * GNAT.Spelling_Checker (g-speche.ads)::
520 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
521 * GNAT.Spitbol.Patterns (g-spipat.ads)::
522 * GNAT.Spitbol (g-spitbo.ads)::
523 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
524 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
525 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
526 * GNAT.SSE (g-sse.ads)::
527 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
528 * GNAT.Strings (g-string.ads)::
529 * GNAT.String_Split (g-strspl.ads)::
530 * GNAT.Table (g-table.ads)::
531 * GNAT.Task_Lock (g-tasloc.ads)::
532 * GNAT.Threads (g-thread.ads)::
533 * GNAT.Time_Stamp (g-timsta.ads)::
534 * GNAT.Traceback (g-traceb.ads)::
535 * GNAT.Traceback.Symbolic (g-trasym.ads)::
536 * GNAT.UTF_32 (g-utf_32.ads)::
537 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
538 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
539 * GNAT.Wide_String_Split (g-wistsp.ads)::
540 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
541 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
542 * Interfaces.C.Extensions (i-cexten.ads)::
543 * Interfaces.C.Streams (i-cstrea.ads)::
544 * Interfaces.CPP (i-cpp.ads)::
545 * Interfaces.Packed_Decimal (i-pacdec.ads)::
546 * Interfaces.VxWorks (i-vxwork.ads)::
547 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
548 * System.Address_Image (s-addima.ads)::
549 * System.Assertions (s-assert.ads)::
550 * System.Memory (s-memory.ads)::
551 * System.Multiprocessors (s-multip.ads)::
552 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
553 * System.Partition_Interface (s-parint.ads)::
554 * System.Pool_Global (s-pooglo.ads)::
555 * System.Pool_Local (s-pooloc.ads)::
556 * System.Restrictions (s-restri.ads)::
557 * System.Rident (s-rident.ads)::
558 * System.Strings.Stream_Ops (s-ststop.ads)::
559 * System.Task_Info (s-tasinf.ads)::
560 * System.Wch_Cnv (s-wchcnv.ads)::
561 * System.Wch_Con (s-wchcon.ads)::
562
563 Text_IO
564
565 * Text_IO Stream Pointer Positioning::
566 * Text_IO Reading and Writing Non-Regular Files::
567 * Get_Immediate::
568 * Treating Text_IO Files as Streams::
569 * Text_IO Extensions::
570 * Text_IO Facilities for Unbounded Strings::
571
572 Wide_Text_IO
573
574 * Wide_Text_IO Stream Pointer Positioning::
575 * Wide_Text_IO Reading and Writing Non-Regular Files::
576
577 Wide_Wide_Text_IO
578
579 * Wide_Wide_Text_IO Stream Pointer Positioning::
580 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
581
582 Interfacing to Other Languages
583
584 * Interfacing to C::
585 * Interfacing to C++::
586 * Interfacing to COBOL::
587 * Interfacing to Fortran::
588 * Interfacing to non-GNAT Ada code::
589
590 Specialized Needs Annexes
591
592 Implementation of Specific Ada Features
593 * Machine Code Insertions::
594 * GNAT Implementation of Tasking::
595 * GNAT Implementation of Shared Passive Packages::
596 * Code Generation for Array Aggregates::
597 * The Size of Discriminated Records with Default Discriminants::
598 * Strict Conformance to the Ada Reference Manual::
599
600 Implementation of Ada 2012 Features
601
602 Obsolescent Features
603
604 GNU Free Documentation License
605
606 Index
607 @end menu
608
609 @end ifnottex
610
611 @node About This Guide
612 @unnumbered About This Guide
613
614 @noindent
615 This manual contains useful information in writing programs using the
616 @value{EDITION} compiler. It includes information on implementation dependent
617 characteristics of @value{EDITION}, including all the information required by
618 Annex M of the Ada language standard.
619
620 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
621 Ada 83 compatibility mode.
622 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
623 but you can override with a compiler switch
624 to explicitly specify the language version.
625 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
626 @value{EDITION} User's Guide}, for details on these switches.)
627 Throughout this manual, references to ``Ada'' without a year suffix
628 apply to both the Ada 95 and Ada 2005 versions of the language.
629
630 Ada is designed to be highly portable.
631 In general, a program will have the same effect even when compiled by
632 different compilers on different platforms.
633 However, since Ada is designed to be used in a
634 wide variety of applications, it also contains a number of system
635 dependent features to be used in interfacing to the external world.
636 @cindex Implementation-dependent features
637 @cindex Portability
638
639 Note: Any program that makes use of implementation-dependent features
640 may be non-portable. You should follow good programming practice and
641 isolate and clearly document any sections of your program that make use
642 of these features in a non-portable manner.
643
644 @ifset PROEDITION
645 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
646 ``GNAT'' in the remainder of this document.
647 @end ifset
648
649 @menu
650 * What This Reference Manual Contains::
651 * Conventions::
652 * Related Information::
653 @end menu
654
655 @node What This Reference Manual Contains
656 @unnumberedsec What This Reference Manual Contains
657
658 @noindent
659 This reference manual contains the following chapters:
660
661 @itemize @bullet
662 @item
663 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
664 pragmas, which can be used to extend and enhance the functionality of the
665 compiler.
666
667 @item
668 @ref{Implementation Defined Attributes}, lists GNAT
669 implementation-dependent attributes, which can be used to extend and
670 enhance the functionality of the compiler.
671
672 @item
673 @ref{Standard and Implementation Defined Restrictions}, lists GNAT
674 implementation-dependent restrictions, which can be used to extend and
675 enhance the functionality of the compiler.
676
677 @item
678 @ref{Implementation Advice}, provides information on generally
679 desirable behavior which are not requirements that all compilers must
680 follow since it cannot be provided on all systems, or which may be
681 undesirable on some systems.
682
683 @item
684 @ref{Implementation Defined Characteristics}, provides a guide to
685 minimizing implementation dependent features.
686
687 @item
688 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
689 implemented by GNAT, and how they can be imported into user
690 application programs.
691
692 @item
693 @ref{Representation Clauses and Pragmas}, describes in detail the
694 way that GNAT represents data, and in particular the exact set
695 of representation clauses and pragmas that is accepted.
696
697 @item
698 @ref{Standard Library Routines}, provides a listing of packages and a
699 brief description of the functionality that is provided by Ada's
700 extensive set of standard library routines as implemented by GNAT@.
701
702 @item
703 @ref{The Implementation of Standard I/O}, details how the GNAT
704 implementation of the input-output facilities.
705
706 @item
707 @ref{The GNAT Library}, is a catalog of packages that complement
708 the Ada predefined library.
709
710 @item
711 @ref{Interfacing to Other Languages}, describes how programs
712 written in Ada using GNAT can be interfaced to other programming
713 languages.
714
715 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
716 of the specialized needs annexes.
717
718 @item
719 @ref{Implementation of Specific Ada Features}, discusses issues related
720 to GNAT's implementation of machine code insertions, tasking, and several
721 other features.
722
723 @item
724 @ref{Implementation of Ada 2012 Features}, describes the status of the
725 GNAT implementation of the Ada 2012 language standard.
726
727 @item
728 @ref{Obsolescent Features} documents implementation dependent features,
729 including pragmas and attributes, which are considered obsolescent, since
730 there are other preferred ways of achieving the same results. These
731 obsolescent forms are retained for backwards compatibility.
732
733 @end itemize
734
735 @cindex Ada 95 Language Reference Manual
736 @cindex Ada 2005 Language Reference Manual
737 @noindent
738 This reference manual assumes a basic familiarity with the Ada 95 language, as
739 described in the International Standard ANSI/ISO/IEC-8652:1995,
740 January 1995.
741 It does not require knowledge of the new features introduced by Ada 2005,
742 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
743 and Amendment 1).
744 Both reference manuals are included in the GNAT documentation
745 package.
746
747 @node Conventions
748 @unnumberedsec Conventions
749 @cindex Conventions, typographical
750 @cindex Typographical conventions
751
752 @noindent
753 Following are examples of the typographical and graphic conventions used
754 in this guide:
755
756 @itemize @bullet
757 @item
758 @code{Functions}, @code{utility program names}, @code{standard names},
759 and @code{classes}.
760
761 @item
762 @code{Option flags}
763
764 @item
765 @file{File names}, @samp{button names}, and @samp{field names}.
766
767 @item
768 @code{Variables}, @env{environment variables}, and @var{metasyntactic
769 variables}.
770
771 @item
772 @emph{Emphasis}.
773
774 @item
775 [optional information or parameters]
776
777 @item
778 Examples are described by text
779 @smallexample
780 and then shown this way.
781 @end smallexample
782 @end itemize
783
784 @noindent
785 Commands that are entered by the user are preceded in this manual by the
786 characters @samp{$ } (dollar sign followed by space). If your system uses this
787 sequence as a prompt, then the commands will appear exactly as you see them
788 in the manual. If your system uses some other prompt, then the command will
789 appear with the @samp{$} replaced by whatever prompt character you are using.
790
791 @node Related Information
792 @unnumberedsec Related Information
793 @noindent
794 See the following documents for further information on GNAT:
795
796 @itemize @bullet
797 @item
798 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
799 @value{EDITION} User's Guide}, which provides information on how to use the
800 GNAT compiler system.
801
802 @item
803 @cite{Ada 95 Reference Manual}, which contains all reference
804 material for the Ada 95 programming language.
805
806 @item
807 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
808 of the Ada 95 standard. The annotations describe
809 detailed aspects of the design decision, and in particular contain useful
810 sections on Ada 83 compatibility.
811
812 @item
813 @cite{Ada 2005 Reference Manual}, which contains all reference
814 material for the Ada 2005 programming language.
815
816 @item
817 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
818 of the Ada 2005 standard. The annotations describe
819 detailed aspects of the design decision, and in particular contain useful
820 sections on Ada 83 and Ada 95 compatibility.
821
822 @item
823 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
824 which contains specific information on compatibility between GNAT and
825 DEC Ada 83 systems.
826
827 @item
828 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
829 describes in detail the pragmas and attributes provided by the DEC Ada 83
830 compiler system.
831
832 @end itemize
833
834 @node Implementation Defined Pragmas
835 @chapter Implementation Defined Pragmas
836
837 @noindent
838 Ada defines a set of pragmas that can be used to supply additional
839 information to the compiler. These language defined pragmas are
840 implemented in GNAT and work as described in the Ada Reference Manual.
841
842 In addition, Ada allows implementations to define additional pragmas
843 whose meaning is defined by the implementation. GNAT provides a number
844 of these implementation-defined pragmas, which can be used to extend
845 and enhance the functionality of the compiler. This section of the GNAT
846 Reference Manual describes these additional pragmas.
847
848 Note that any program using these pragmas might not be portable to other
849 compilers (although GNAT implements this set of pragmas on all
850 platforms). Therefore if portability to other compilers is an important
851 consideration, the use of these pragmas should be minimized.
852
853 @menu
854 * Pragma Abort_Defer::
855 * Pragma Ada_83::
856 * Pragma Ada_95::
857 * Pragma Ada_05::
858 * Pragma Ada_2005::
859 * Pragma Ada_12::
860 * Pragma Ada_2012::
861 * Pragma Annotate::
862 * Pragma Assert::
863 * Pragma Assertion_Policy::
864 * Pragma Assume_No_Invalid_Values::
865 * Pragma Attribute_Definition::
866 * Pragma Ast_Entry::
867 * Pragma C_Pass_By_Copy::
868 * Pragma Check::
869 * Pragma Check_Float_Overflow::
870 * Pragma Check_Name::
871 * Pragma Check_Policy::
872 * Pragma Comment::
873 * Pragma Common_Object::
874 * Pragma Compile_Time_Error::
875 * Pragma Compile_Time_Warning::
876 * Pragma Compiler_Unit::
877 * Pragma Complete_Representation::
878 * Pragma Complex_Representation::
879 * Pragma Component_Alignment::
880 * Pragma Contract_Case::
881 * Pragma Convention_Identifier::
882 * Pragma CPP_Class::
883 * Pragma CPP_Constructor::
884 * Pragma CPP_Virtual::
885 * Pragma CPP_Vtable::
886 * Pragma CPU::
887 * Pragma Debug::
888 * Pragma Debug_Policy::
889 * Pragma Default_Storage_Pool::
890 * Pragma Detect_Blocking::
891 * Pragma Dispatching_Domain::
892 * Pragma Elaboration_Checks::
893 * Pragma Eliminate::
894 * Pragma Export_Exception::
895 * Pragma Export_Function::
896 * Pragma Export_Object::
897 * Pragma Export_Procedure::
898 * Pragma Export_Value::
899 * Pragma Export_Valued_Procedure::
900 * Pragma Extend_System::
901 * Pragma Extensions_Allowed::
902 * Pragma External::
903 * Pragma External_Name_Casing::
904 * Pragma Fast_Math::
905 * Pragma Favor_Top_Level::
906 * Pragma Finalize_Storage_Only::
907 * Pragma Float_Representation::
908 * Pragma Ident::
909 * Pragma Implementation_Defined::
910 * Pragma Implemented::
911 * Pragma Implicit_Packing::
912 * Pragma Import_Exception::
913 * Pragma Import_Function::
914 * Pragma Import_Object::
915 * Pragma Import_Procedure::
916 * Pragma Import_Valued_Procedure::
917 * Pragma Independent::
918 * Pragma Independent_Components::
919 * Pragma Initialize_Scalars::
920 * Pragma Inline_Always::
921 * Pragma Inline_Generic::
922 * Pragma Interface::
923 * Pragma Interface_Name::
924 * Pragma Interrupt_Handler::
925 * Pragma Interrupt_State::
926 * Pragma Invariant::
927 * Pragma Keep_Names::
928 * Pragma License::
929 * Pragma Link_With::
930 * Pragma Linker_Alias::
931 * Pragma Linker_Constructor::
932 * Pragma Linker_Destructor::
933 * Pragma Linker_Section::
934 * Pragma Long_Float::
935 * Pragma Loop_Optimize::
936 * Pragma Machine_Attribute::
937 * Pragma Main::
938 * Pragma Main_Storage::
939 * Pragma No_Body::
940 * Pragma No_Inline::
941 * Pragma No_Return::
942 * Pragma No_Strict_Aliasing::
943 * Pragma Normalize_Scalars::
944 * Pragma Obsolescent::
945 * Pragma Optimize_Alignment::
946 * Pragma Ordered::
947 * Pragma Overflow_Mode::
948 * Pragma Partition_Elaboration_Policy::
949 * Pragma Passive::
950 * Pragma Persistent_BSS::
951 * Pragma Polling::
952 * Pragma Postcondition::
953 * Pragma Precondition::
954 * Pragma Preelaborable_Initialization::
955 * Pragma Priority_Specific_Dispatching::
956 * Pragma Profile (Ravenscar)::
957 * Pragma Profile (Restricted)::
958 * Pragma Profile (Rational)::
959 * Pragma Psect_Object::
960 * Pragma Pure_Function::
961 * Pragma Relative_Deadline::
962 * Pragma Remote_Access_Type::
963 * Pragma Restriction_Warnings::
964 * Pragma Shared::
965 * Pragma Short_Circuit_And_Or::
966 * Pragma Short_Descriptors::
967 * Pragma Simple_Storage_Pool_Type::
968 * Pragma Source_File_Name::
969 * Pragma Source_File_Name_Project::
970 * Pragma Source_Reference::
971 * Pragma Static_Elaboration_Desired::
972 * Pragma Stream_Convert::
973 * Pragma Style_Checks::
974 * Pragma Subtitle::
975 * Pragma Suppress::
976 * Pragma Suppress_All::
977 * Pragma Suppress_Exception_Locations::
978 * Pragma Suppress_Initialization::
979 * Pragma Task_Info::
980 * Pragma Task_Name::
981 * Pragma Task_Storage::
982 * Pragma Test_Case::
983 * Pragma Thread_Local_Storage::
984 * Pragma Time_Slice::
985 * Pragma Title::
986 * Pragma Unchecked_Union::
987 * Pragma Unimplemented_Unit::
988 * Pragma Universal_Aliasing ::
989 * Pragma Universal_Data::
990 * Pragma Unmodified::
991 * Pragma Unreferenced::
992 * Pragma Unreferenced_Objects::
993 * Pragma Unreserve_All_Interrupts::
994 * Pragma Unsuppress::
995 * Pragma Use_VADS_Size::
996 * Pragma Validity_Checks::
997 * Pragma Volatile::
998 * Pragma Warnings::
999 * Pragma Weak_External::
1000 * Pragma Wide_Character_Encoding::
1001 @end menu
1002
1003 @node Pragma Abort_Defer
1004 @unnumberedsec Pragma Abort_Defer
1005 @findex Abort_Defer
1006 @cindex Deferring aborts
1007 @noindent
1008 Syntax:
1009 @smallexample
1010 pragma Abort_Defer;
1011 @end smallexample
1012
1013 @noindent
1014 This pragma must appear at the start of the statement sequence of a
1015 handled sequence of statements (right after the @code{begin}). It has
1016 the effect of deferring aborts for the sequence of statements (but not
1017 for the declarations or handlers, if any, associated with this statement
1018 sequence).
1019
1020 @node Pragma Ada_83
1021 @unnumberedsec Pragma Ada_83
1022 @findex Ada_83
1023 @noindent
1024 Syntax:
1025 @smallexample @c ada
1026 pragma Ada_83;
1027 @end smallexample
1028
1029 @noindent
1030 A configuration pragma that establishes Ada 83 mode for the unit to
1031 which it applies, regardless of the mode set by the command line
1032 switches. In Ada 83 mode, GNAT attempts to be as compatible with
1033 the syntax and semantics of Ada 83, as defined in the original Ada
1034 83 Reference Manual as possible. In particular, the keywords added by Ada 95
1035 and Ada 2005 are not recognized, optional package bodies are allowed,
1036 and generics may name types with unknown discriminants without using
1037 the @code{(<>)} notation. In addition, some but not all of the additional
1038 restrictions of Ada 83 are enforced.
1039
1040 Ada 83 mode is intended for two purposes. Firstly, it allows existing
1041 Ada 83 code to be compiled and adapted to GNAT with less effort.
1042 Secondly, it aids in keeping code backwards compatible with Ada 83.
1043 However, there is no guarantee that code that is processed correctly
1044 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
1045 83 compiler, since GNAT does not enforce all the additional checks
1046 required by Ada 83.
1047
1048 @node Pragma Ada_95
1049 @unnumberedsec Pragma Ada_95
1050 @findex Ada_95
1051 @noindent
1052 Syntax:
1053 @smallexample @c ada
1054 pragma Ada_95;
1055 @end smallexample
1056
1057 @noindent
1058 A configuration pragma that establishes Ada 95 mode for the unit to which
1059 it applies, regardless of the mode set by the command line switches.
1060 This mode is set automatically for the @code{Ada} and @code{System}
1061 packages and their children, so you need not specify it in these
1062 contexts. This pragma is useful when writing a reusable component that
1063 itself uses Ada 95 features, but which is intended to be usable from
1064 either Ada 83 or Ada 95 programs.
1065
1066 @node Pragma Ada_05
1067 @unnumberedsec Pragma Ada_05
1068 @findex Ada_05
1069 @noindent
1070 Syntax:
1071 @smallexample @c ada
1072 pragma Ada_05;
1073 @end smallexample
1074
1075 @noindent
1076 A configuration pragma that establishes Ada 2005 mode for the unit to which
1077 it applies, regardless of the mode set by the command line switches.
1078 This pragma is useful when writing a reusable component that
1079 itself uses Ada 2005 features, but which is intended to be usable from
1080 either Ada 83 or Ada 95 programs.
1081
1082 @node Pragma Ada_2005
1083 @unnumberedsec Pragma Ada_2005
1084 @findex Ada_2005
1085 @noindent
1086 Syntax:
1087 @smallexample @c ada
1088 pragma Ada_2005;
1089 @end smallexample
1090
1091 @noindent
1092 This configuration pragma is a synonym for pragma Ada_05 and has the
1093 same syntax and effect.
1094
1095 @node Pragma Ada_12
1096 @unnumberedsec Pragma Ada_12
1097 @findex Ada_12
1098 @noindent
1099 Syntax:
1100 @smallexample @c ada
1101 pragma Ada_12;
1102 @end smallexample
1103
1104 @noindent
1105 A configuration pragma that establishes Ada 2012 mode for the unit to which
1106 it applies, regardless of the mode set by the command line switches.
1107 This mode is set automatically for the @code{Ada} and @code{System}
1108 packages and their children, so you need not specify it in these
1109 contexts. This pragma is useful when writing a reusable component that
1110 itself uses Ada 2012 features, but which is intended to be usable from
1111 Ada 83, Ada 95, or Ada 2005 programs.
1112
1113 @node Pragma Ada_2012
1114 @unnumberedsec Pragma Ada_2012
1115 @findex Ada_2005
1116 @noindent
1117 Syntax:
1118 @smallexample @c ada
1119 pragma Ada_2012;
1120 @end smallexample
1121
1122 @noindent
1123 This configuration pragma is a synonym for pragma Ada_12 and has the
1124 same syntax and effect.
1125
1126 @node Pragma Annotate
1127 @unnumberedsec Pragma Annotate
1128 @findex Annotate
1129 @noindent
1130 Syntax:
1131 @smallexample @c ada
1132 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
1133
1134 ARG ::= NAME | EXPRESSION
1135 @end smallexample
1136
1137 @noindent
1138 This pragma is used to annotate programs. @var{identifier} identifies
1139 the type of annotation. GNAT verifies that it is an identifier, but does
1140 not otherwise analyze it. The second optional identifier is also left
1141 unanalyzed, and by convention is used to control the action of the tool to
1142 which the annotation is addressed. The remaining @var{arg} arguments
1143 can be either string literals or more generally expressions.
1144 String literals are assumed to be either of type
1145 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1146 depending on the character literals they contain.
1147 All other kinds of arguments are analyzed as expressions, and must be
1148 unambiguous.
1149
1150 The analyzed pragma is retained in the tree, but not otherwise processed
1151 by any part of the GNAT compiler, except to generate corresponding note
1152 lines in the generated ALI file. For the format of these note lines, see
1153 the compiler source file lib-writ.ads. This pragma is intended for use by
1154 external tools, including ASIS@. The use of pragma Annotate does not
1155 affect the compilation process in any way. This pragma may be used as
1156 a configuration pragma.
1157
1158 @node Pragma Assert
1159 @unnumberedsec Pragma Assert
1160 @findex Assert
1161 @noindent
1162 Syntax:
1163 @smallexample @c ada
1164 pragma Assert (
1165 boolean_EXPRESSION
1166 [, string_EXPRESSION]);
1167 @end smallexample
1168
1169 @noindent
1170 The effect of this pragma depends on whether the corresponding command
1171 line switch is set to activate assertions. The pragma expands into code
1172 equivalent to the following:
1173
1174 @smallexample @c ada
1175 if assertions-enabled then
1176 if not boolean_EXPRESSION then
1177 System.Assertions.Raise_Assert_Failure
1178 (string_EXPRESSION);
1179 end if;
1180 end if;
1181 @end smallexample
1182
1183 @noindent
1184 The string argument, if given, is the message that will be associated
1185 with the exception occurrence if the exception is raised. If no second
1186 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1187 where @var{file} is the name of the source file containing the assert,
1188 and @var{nnn} is the line number of the assert. A pragma is not a
1189 statement, so if a statement sequence contains nothing but a pragma
1190 assert, then a null statement is required in addition, as in:
1191
1192 @smallexample @c ada
1193 @dots{}
1194 if J > 3 then
1195 pragma Assert (K > 3, "Bad value for K");
1196 null;
1197 end if;
1198 @end smallexample
1199
1200 @noindent
1201 Note that, as with the @code{if} statement to which it is equivalent, the
1202 type of the expression is either @code{Standard.Boolean}, or any type derived
1203 from this standard type.
1204
1205 If assertions are disabled (switch @option{-gnata} not used), then there
1206 is no run-time effect (and in particular, any side effects from the
1207 expression will not occur at run time). (The expression is still
1208 analyzed at compile time, and may cause types to be frozen if they are
1209 mentioned here for the first time).
1210
1211 If assertions are enabled, then the given expression is tested, and if
1212 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1213 which results in the raising of @code{Assert_Failure} with the given message.
1214
1215 You should generally avoid side effects in the expression arguments of
1216 this pragma, because these side effects will turn on and off with the
1217 setting of the assertions mode, resulting in assertions that have an
1218 effect on the program. However, the expressions are analyzed for
1219 semantic correctness whether or not assertions are enabled, so turning
1220 assertions on and off cannot affect the legality of a program.
1221
1222 Note that the implementation defined policy @code{DISABLE}, given in a
1223 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1224
1225 Note: this is a standard language-defined pragma in versions
1226 of Ada from 2005 on. In GNAT, it is implemented in all versions
1227 of Ada, and the DISABLE policy is an implementation-defined
1228 addition.
1229
1230 @node Pragma Assertion_Policy
1231 @unnumberedsec Pragma Assertion_Policy
1232 @findex Assertion_Policy
1233 @noindent
1234 Syntax:
1235 @smallexample @c ada
1236 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1237
1238 Pragma Assertion_Policy (
1239 ASSERTION_KIND => POLICY_IDENTIFIER
1240 @{, ASSERTION_KIND => POLICY_IDENTIFIER@});
1241
1242 ASSERTION_KIND ::= RM_ASSERTION_KIND | ID_ASSERTION_KIND
1243
1244 RM_ASSERTION_KIND ::= Assert |
1245 Static_Predicate |
1246 Dynamic_Predicate |
1247 Pre |
1248 Pre'Class |
1249 Post |
1250 Post'Class |
1251 Type_Invariant |
1252 Type_Invariant'Class
1253
1254 ID_ASSERTION_KIND ::= Assert_And_Cut |
1255 Assume |
1256 Contract_Cases |
1257 Debug |
1258 Invariant |
1259 Invariant'Class |
1260 Loop_Invariant |
1261 Loop_Variant |
1262 Postcondition |
1263 Precondition |
1264 Predicate
1265
1266 POLICY_IDENTIFIER ::= Check | Disable | Ignore
1267 @end smallexample
1268
1269 @noindent
1270 This is a standard Ada 2012 pragma that is available as an
1271 implementation-defined pragma in earlier versions of Ada.
1272 The assertion kinds @code{RM_ASSERTION_KIND} are those defined in
1273 the Ada standard. The assertion kinds @code{ID_ASSERTION_KIND}
1274 are implementation defined additions recognized by the GNAT compiler.
1275
1276 The pragma applies in both cases to pragmas and aspects with matching
1277 names, e.g. @code{Pre} applies to the Pre aspect, and @code{Precondition}
1278 applies to both the @code{Precondition} pragma
1279 and the aspect @code{Precondition}.
1280
1281 If the policy is @code{CHECK}, then assertions are enabled, i.e.
1282 the corresponding pragma or aspect is activated.
1283 If the policy is @code{IGNORE}, then assertions are ignored, i.e.
1284 the corresponding pragma or aspect is deactivated.
1285 This pragma overrides the effect of the @option{-gnata} switch on the
1286 command line.
1287
1288 The implementation defined policy @code{DISABLE} is like
1289 @code{IGNORE} except that it completely disables semantic
1290 checking of the corresponding pragma or aspect. This is
1291 useful when the pragma or aspect argument references subprograms
1292 in a with'ed package which is replaced by a dummy package
1293 for the final build.
1294
1295 @node Pragma Assume_No_Invalid_Values
1296 @unnumberedsec Pragma Assume_No_Invalid_Values
1297 @findex Assume_No_Invalid_Values
1298 @cindex Invalid representations
1299 @cindex Invalid values
1300 @noindent
1301 Syntax:
1302 @smallexample @c ada
1303 pragma Assume_No_Invalid_Values (On | Off);
1304 @end smallexample
1305
1306 @noindent
1307 This is a configuration pragma that controls the assumptions made by the
1308 compiler about the occurrence of invalid representations (invalid values)
1309 in the code.
1310
1311 The default behavior (corresponding to an Off argument for this pragma), is
1312 to assume that values may in general be invalid unless the compiler can
1313 prove they are valid. Consider the following example:
1314
1315 @smallexample @c ada
1316 V1 : Integer range 1 .. 10;
1317 V2 : Integer range 11 .. 20;
1318 ...
1319 for J in V2 .. V1 loop
1320 ...
1321 end loop;
1322 @end smallexample
1323
1324 @noindent
1325 if V1 and V2 have valid values, then the loop is known at compile
1326 time not to execute since the lower bound must be greater than the
1327 upper bound. However in default mode, no such assumption is made,
1328 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1329 is given, the compiler will assume that any occurrence of a variable
1330 other than in an explicit @code{'Valid} test always has a valid
1331 value, and the loop above will be optimized away.
1332
1333 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1334 you know your code is free of uninitialized variables and other
1335 possible sources of invalid representations, and may result in
1336 more efficient code. A program that accesses an invalid representation
1337 with this pragma in effect is erroneous, so no guarantees can be made
1338 about its behavior.
1339
1340 It is peculiar though permissible to use this pragma in conjunction
1341 with validity checking (-gnatVa). In such cases, accessing invalid
1342 values will generally give an exception, though formally the program
1343 is erroneous so there are no guarantees that this will always be the
1344 case, and it is recommended that these two options not be used together.
1345
1346 @node Pragma Ast_Entry
1347 @unnumberedsec Pragma Ast_Entry
1348 @cindex OpenVMS
1349 @findex Ast_Entry
1350 @noindent
1351 Syntax:
1352 @smallexample @c ada
1353 pragma AST_Entry (entry_IDENTIFIER);
1354 @end smallexample
1355
1356 @noindent
1357 This pragma is implemented only in the OpenVMS implementation of GNAT@. The
1358 argument is the simple name of a single entry; at most one @code{AST_Entry}
1359 pragma is allowed for any given entry. This pragma must be used in
1360 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1361 the entry declaration and in the same task type specification or single task
1362 as the entry to which it applies. This pragma specifies that the given entry
1363 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1364 resulting from an OpenVMS system service call. The pragma does not affect
1365 normal use of the entry. For further details on this pragma, see the
1366 DEC Ada Language Reference Manual, section 9.12a.
1367
1368 @node Pragma Attribute_Definition
1369 @unnumberedsec Pragma Attribute_Definition
1370 @findex Attribute_Definition
1371 @noindent
1372 Syntax:
1373 @smallexample @c ada
1374 pragma Attribute_Definition
1375 ([Attribute =>] ATTRIBUTE_DESIGNATOR,
1376 [Entity =>] LOCAL_NAME,
1377 [Expression =>] EXPRESSION | NAME);
1378 @end smallexample
1379
1380 @noindent
1381 If @code{Attribute} is a known attribute name, this pragma is equivalent to
1382 the attribute definition clause:
1383
1384 @smallexample @c ada
1385 for Entity'Attribute use Expression;
1386 @end smallexample
1387
1388 If @code{Attribute} is not a recognized attribute name, the pragma is
1389 ignored, and a warning is emitted. This allows source
1390 code to be written that takes advantage of some new attribute, while remaining
1391 compilable with earlier compilers.
1392
1393 @node Pragma C_Pass_By_Copy
1394 @unnumberedsec Pragma C_Pass_By_Copy
1395 @cindex Passing by copy
1396 @findex C_Pass_By_Copy
1397 @noindent
1398 Syntax:
1399 @smallexample @c ada
1400 pragma C_Pass_By_Copy
1401 ([Max_Size =>] static_integer_EXPRESSION);
1402 @end smallexample
1403
1404 @noindent
1405 Normally the default mechanism for passing C convention records to C
1406 convention subprograms is to pass them by reference, as suggested by RM
1407 B.3(69). Use the configuration pragma @code{C_Pass_By_Copy} to change
1408 this default, by requiring that record formal parameters be passed by
1409 copy if all of the following conditions are met:
1410
1411 @itemize @bullet
1412 @item
1413 The size of the record type does not exceed the value specified for
1414 @code{Max_Size}.
1415 @item
1416 The record type has @code{Convention C}.
1417 @item
1418 The formal parameter has this record type, and the subprogram has a
1419 foreign (non-Ada) convention.
1420 @end itemize
1421
1422 @noindent
1423 If these conditions are met the argument is passed by copy, i.e.@: in a
1424 manner consistent with what C expects if the corresponding formal in the
1425 C prototype is a struct (rather than a pointer to a struct).
1426
1427 You can also pass records by copy by specifying the convention
1428 @code{C_Pass_By_Copy} for the record type, or by using the extended
1429 @code{Import} and @code{Export} pragmas, which allow specification of
1430 passing mechanisms on a parameter by parameter basis.
1431
1432 @node Pragma Check
1433 @unnumberedsec Pragma Check
1434 @cindex Assertions
1435 @cindex Named assertions
1436 @findex Check
1437 @noindent
1438 Syntax:
1439 @smallexample @c ada
1440 pragma Check (
1441 [Name =>] CHECK_KIND,
1442 [Check =>] Boolean_EXPRESSION
1443 [, [Message =>] string_EXPRESSION] );
1444
1445 CHECK_KIND ::= IDENTIFIER |
1446 Pre'Class | Post'Class | Type_Invariant'Class
1447 @end smallexample
1448
1449 @noindent
1450 This pragma is similar to the predefined pragma @code{Assert} except that an
1451 extra identifier argument is present. In conjunction with pragma
1452 @code{Check_Policy}, this can be used to define groups of assertions that can
1453 be independently controlled. The identifier @code{Assertion} is special, it
1454 refers to the normal set of pragma @code{Assert} statements.
1455
1456 Checks introduced by this pragma are normally deactivated by default. They can
1457 be activated either by the command line option @option{-gnata}, which turns on
1458 all checks, or individually controlled using pragma @code{Check_Policy}.
1459
1460 @node Pragma Check_Float_Overflow
1461 @unnumberedsec Pragma Check_Float_Overflow
1462 @cindex Floating-point overflow
1463 @findex Check_Float_Overflow
1464 @noindent
1465 Syntax:
1466 @smallexample @c ada
1467 pragma Check_Float_Overflow;
1468 @end smallexample
1469
1470 @noindent
1471 In Ada, the predefined floating-point types (@code{Short_Float},
1472 @code{Float}, @code{Long_Float}, @code{Long_Long_Float}) are
1473 defined to be @emph{unconstrained}. This means that even though each
1474 has a well-defined base range, an operation that delivers a result
1475 outside this base range is not required to raise an exception.
1476 This implementation permission accommodates the notion
1477 of infinities in IEEE floating-point, and corresponds to the
1478 efficient execution mode on most machines. GNAT will not raise
1479 overflow exceptions on these machines; instead it will generate
1480 infinities and NaN's as defined in the IEEE standard.
1481
1482 Generating infinities, although efficient, is not always desirable.
1483 Often the preferable approach is to check for overflow, even at the
1484 (perhaps considerable) expense of run-time performance.
1485 This can be accomplished by defining your own constrained floating-point subtypes -- i.e., by supplying explicit
1486 range constraints -- and indeed such a subtype
1487 can have the same base range as its base type. For example:
1488
1489 @smallexample @c ada
1490 subtype My_Float is Float range Float'Range;
1491 @end smallexample
1492
1493 @noindent
1494 Here @code{My_Float} has the same range as
1495 @code{Float} but is constrained, so operations on
1496 @code{My_Float} values will be checked for overflow
1497 against this range.
1498
1499 This style will achieve the desired goal, but
1500 it is often more convenient to be able to simply use
1501 the standard predefined floating-point types as long
1502 as overflow checking could be guaranteed.
1503 The @code{Check_Float_Overflow}
1504 configuration pragma achieves this effect. If a unit is compiled
1505 subject to this configuration pragma, then all operations
1506 on predefined floating-point types will be treated as
1507 though those types were constrained, and overflow checks
1508 will be generated. The @code{Constraint_Error}
1509 exception is raised if the result is out of range.
1510
1511 This mode can also be set by use of the compiler
1512 switch @option{-gnateF}.
1513
1514 @node Pragma Check_Name
1515 @unnumberedsec Pragma Check_Name
1516 @cindex Defining check names
1517 @cindex Check names, defining
1518 @findex Check_Name
1519 @noindent
1520 Syntax:
1521 @smallexample @c ada
1522 pragma Check_Name (check_name_IDENTIFIER);
1523 @end smallexample
1524
1525 @noindent
1526 This is a configuration pragma that defines a new implementation
1527 defined check name (unless IDENTIFIER matches one of the predefined
1528 check names, in which case the pragma has no effect). Check names
1529 are global to a partition, so if two or more configuration pragmas
1530 are present in a partition mentioning the same name, only one new
1531 check name is introduced.
1532
1533 An implementation defined check name introduced with this pragma may
1534 be used in only three contexts: @code{pragma Suppress},
1535 @code{pragma Unsuppress},
1536 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1537 any of these three cases, the check name must be visible. A check
1538 name is visible if it is in the configuration pragmas applying to
1539 the current unit, or if it appears at the start of any unit that
1540 is part of the dependency set of the current unit (e.g., units that
1541 are mentioned in @code{with} clauses).
1542
1543 Check names introduced by this pragma are subject to control by compiler
1544 switches (in particular -gnatp) in the usual manner.
1545
1546 @node Pragma Check_Policy
1547 @unnumberedsec Pragma Check_Policy
1548 @cindex Controlling assertions
1549 @cindex Assertions, control
1550 @cindex Check pragma control
1551 @cindex Named assertions
1552 @findex Check
1553 @noindent
1554 Syntax:
1555 @smallexample @c ada
1556 pragma Check_Policy
1557 ([Name =>] CHECK_KIND,
1558 [Policy =>] POLICY_IDENTIFIER);
1559
1560 CHECK_KIND ::= IDENTIFIER |
1561 Pre'Class | Post'Class | Type_Invariant'Class
1562
1563 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1564 @end smallexample
1565
1566 @noindent
1567 This pragma is used to set the checking policy for assertions (specified
1568 by aspects of pragmas), the @code{Debug} pragma, or additional checks
1569 to be checked using the @code{Check} pragma. It may appear either as
1570 a configuration pragma, or within a declarative part of package. In the
1571 latter case, it applies from the point where it appears to the end of
1572 the declarative region (like pragma @code{Suppress}).
1573
1574 The @code{Check_Policy} pragma is similar to the
1575 predefined @code{Assertion_Policy} pragma,
1576 and if the first argument corresponds to one of the assertion kinds that
1577 are allowed by @code{Assertion_Policy}, then the effect is identical.
1578 The identifiers @code{Precondition} and @code{Postcondition} are allowed
1579 synonyms for @code{Pre} and @code{Post}.
1580
1581 If the first argument is Debug, then the policy applies to Debug pragmas,
1582 disabling their effect if the policy is @code{Off}, @code{Disable}, or
1583 @code{Ignore}, and allowing them to execute with normal semantics if
1584 the policy is @code{On} or @code{Check}. In addition if the policy is
1585 @code{Disable}, then the procedure call in @code{Debug} pragmas will
1586 be totally ignored and not analyzed semanticslly.
1587
1588 Finally the first argument may be some other identifier than the above
1589 posibilities, in which case it controls a set of named assertions
1590 that can be checked using pragma @code{Check}. For example, if the pragma:
1591
1592 @smallexample @c ada
1593 pragma Check_Policy (Critical_Error, OFF);
1594 @end smallexample
1595
1596 @noindent
1597 is given, then subsequent @code{Check} pragmas whose first argument is also
1598 @code{Critical_Error} will be disabled.
1599
1600 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1601 to turn on corresponding checks. The default for a set of checks for which no
1602 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1603 @option{-gnata} is given, which turns on all checks by default.
1604
1605 The check policy settings @code{CHECK} and @code{IGNORE} are recognized
1606 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1607 compatibility with the standard @code{Assertion_Policy} pragma. The check
1608 policy setting @code{DISABLE} is also synonymous with @code{OFF} in this
1609 context, but does not have any other significance for check
1610 names other than assertion kinds.
1611
1612 @node Pragma Comment
1613 @unnumberedsec Pragma Comment
1614 @findex Comment
1615 @noindent
1616 Syntax:
1617
1618 @smallexample @c ada
1619 pragma Comment (static_string_EXPRESSION);
1620 @end smallexample
1621
1622 @noindent
1623 This is almost identical in effect to pragma @code{Ident}. It allows the
1624 placement of a comment into the object file and hence into the
1625 executable file if the operating system permits such usage. The
1626 difference is that @code{Comment}, unlike @code{Ident}, has
1627 no limitations on placement of the pragma (it can be placed
1628 anywhere in the main source unit), and if more than one pragma
1629 is used, all comments are retained.
1630
1631 @node Pragma Common_Object
1632 @unnumberedsec Pragma Common_Object
1633 @findex Common_Object
1634 @noindent
1635 Syntax:
1636
1637 @smallexample @c ada
1638 pragma Common_Object (
1639 [Internal =>] LOCAL_NAME
1640 [, [External =>] EXTERNAL_SYMBOL]
1641 [, [Size =>] EXTERNAL_SYMBOL] );
1642
1643 EXTERNAL_SYMBOL ::=
1644 IDENTIFIER
1645 | static_string_EXPRESSION
1646 @end smallexample
1647
1648 @noindent
1649 This pragma enables the shared use of variables stored in overlaid
1650 linker areas corresponding to the use of @code{COMMON}
1651 in Fortran. The single
1652 object @var{LOCAL_NAME} is assigned to the area designated by
1653 the @var{External} argument.
1654 You may define a record to correspond to a series
1655 of fields. The @var{Size} argument
1656 is syntax checked in GNAT, but otherwise ignored.
1657
1658 @code{Common_Object} is not supported on all platforms. If no
1659 support is available, then the code generator will issue a message
1660 indicating that the necessary attribute for implementation of this
1661 pragma is not available.
1662
1663 @node Pragma Compile_Time_Error
1664 @unnumberedsec Pragma Compile_Time_Error
1665 @findex Compile_Time_Error
1666 @noindent
1667 Syntax:
1668
1669 @smallexample @c ada
1670 pragma Compile_Time_Error
1671 (boolean_EXPRESSION, static_string_EXPRESSION);
1672 @end smallexample
1673
1674 @noindent
1675 This pragma can be used to generate additional compile time
1676 error messages. It
1677 is particularly useful in generics, where errors can be issued for
1678 specific problematic instantiations. The first parameter is a boolean
1679 expression. The pragma is effective only if the value of this expression
1680 is known at compile time, and has the value True. The set of expressions
1681 whose values are known at compile time includes all static boolean
1682 expressions, and also other values which the compiler can determine
1683 at compile time (e.g., the size of a record type set by an explicit
1684 size representation clause, or the value of a variable which was
1685 initialized to a constant and is known not to have been modified).
1686 If these conditions are met, an error message is generated using
1687 the value given as the second argument. This string value may contain
1688 embedded ASCII.LF characters to break the message into multiple lines.
1689
1690 @node Pragma Compile_Time_Warning
1691 @unnumberedsec Pragma Compile_Time_Warning
1692 @findex Compile_Time_Warning
1693 @noindent
1694 Syntax:
1695
1696 @smallexample @c ada
1697 pragma Compile_Time_Warning
1698 (boolean_EXPRESSION, static_string_EXPRESSION);
1699 @end smallexample
1700
1701 @noindent
1702 Same as pragma Compile_Time_Error, except a warning is issued instead
1703 of an error message. Note that if this pragma is used in a package that
1704 is with'ed by a client, the client will get the warning even though it
1705 is issued by a with'ed package (normally warnings in with'ed units are
1706 suppressed, but this is a special exception to that rule).
1707
1708 One typical use is within a generic where compile time known characteristics
1709 of formal parameters are tested, and warnings given appropriately. Another use
1710 with a first parameter of True is to warn a client about use of a package,
1711 for example that it is not fully implemented.
1712
1713 @node Pragma Compiler_Unit
1714 @unnumberedsec Pragma Compiler_Unit
1715 @findex Compiler_Unit
1716 @noindent
1717 Syntax:
1718
1719 @smallexample @c ada
1720 pragma Compiler_Unit;
1721 @end smallexample
1722
1723 @noindent
1724 This pragma is intended only for internal use in the GNAT run-time library.
1725 It indicates that the unit is used as part of the compiler build. The effect
1726 is to disallow constructs (raise with message, conditional expressions etc)
1727 that would cause trouble when bootstrapping using an older version of GNAT.
1728 For the exact list of restrictions, see the compiler sources and references
1729 to Is_Compiler_Unit.
1730
1731 @node Pragma Complete_Representation
1732 @unnumberedsec Pragma Complete_Representation
1733 @findex Complete_Representation
1734 @noindent
1735 Syntax:
1736
1737 @smallexample @c ada
1738 pragma Complete_Representation;
1739 @end smallexample
1740
1741 @noindent
1742 This pragma must appear immediately within a record representation
1743 clause. Typical placements are before the first component clause
1744 or after the last component clause. The effect is to give an error
1745 message if any component is missing a component clause. This pragma
1746 may be used to ensure that a record representation clause is
1747 complete, and that this invariant is maintained if fields are
1748 added to the record in the future.
1749
1750 @node Pragma Complex_Representation
1751 @unnumberedsec Pragma Complex_Representation
1752 @findex Complex_Representation
1753 @noindent
1754 Syntax:
1755
1756 @smallexample @c ada
1757 pragma Complex_Representation
1758 ([Entity =>] LOCAL_NAME);
1759 @end smallexample
1760
1761 @noindent
1762 The @var{Entity} argument must be the name of a record type which has
1763 two fields of the same floating-point type. The effect of this pragma is
1764 to force gcc to use the special internal complex representation form for
1765 this record, which may be more efficient. Note that this may result in
1766 the code for this type not conforming to standard ABI (application
1767 binary interface) requirements for the handling of record types. For
1768 example, in some environments, there is a requirement for passing
1769 records by pointer, and the use of this pragma may result in passing
1770 this type in floating-point registers.
1771
1772 @node Pragma Component_Alignment
1773 @unnumberedsec Pragma Component_Alignment
1774 @cindex Alignments of components
1775 @findex Component_Alignment
1776 @noindent
1777 Syntax:
1778
1779 @smallexample @c ada
1780 pragma Component_Alignment (
1781 [Form =>] ALIGNMENT_CHOICE
1782 [, [Name =>] type_LOCAL_NAME]);
1783
1784 ALIGNMENT_CHOICE ::=
1785 Component_Size
1786 | Component_Size_4
1787 | Storage_Unit
1788 | Default
1789 @end smallexample
1790
1791 @noindent
1792 Specifies the alignment of components in array or record types.
1793 The meaning of the @var{Form} argument is as follows:
1794
1795 @table @code
1796 @findex Component_Size
1797 @item Component_Size
1798 Aligns scalar components and subcomponents of the array or record type
1799 on boundaries appropriate to their inherent size (naturally
1800 aligned). For example, 1-byte components are aligned on byte boundaries,
1801 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1802 integer components are aligned on 4-byte boundaries and so on. These
1803 alignment rules correspond to the normal rules for C compilers on all
1804 machines except the VAX@.
1805
1806 @findex Component_Size_4
1807 @item Component_Size_4
1808 Naturally aligns components with a size of four or fewer
1809 bytes. Components that are larger than 4 bytes are placed on the next
1810 4-byte boundary.
1811
1812 @findex Storage_Unit
1813 @item Storage_Unit
1814 Specifies that array or record components are byte aligned, i.e.@:
1815 aligned on boundaries determined by the value of the constant
1816 @code{System.Storage_Unit}.
1817
1818 @cindex OpenVMS
1819 @item Default
1820 Specifies that array or record components are aligned on default
1821 boundaries, appropriate to the underlying hardware or operating system or
1822 both. For OpenVMS VAX systems, the @code{Default} choice is the same as
1823 the @code{Storage_Unit} choice (byte alignment). For all other systems,
1824 the @code{Default} choice is the same as @code{Component_Size} (natural
1825 alignment).
1826 @end table
1827
1828 @noindent
1829 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1830 refer to a local record or array type, and the specified alignment
1831 choice applies to the specified type. The use of
1832 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1833 @code{Component_Alignment} pragma to be ignored. The use of
1834 @code{Component_Alignment} together with a record representation clause
1835 is only effective for fields not specified by the representation clause.
1836
1837 If the @code{Name} parameter is absent, the pragma can be used as either
1838 a configuration pragma, in which case it applies to one or more units in
1839 accordance with the normal rules for configuration pragmas, or it can be
1840 used within a declarative part, in which case it applies to types that
1841 are declared within this declarative part, or within any nested scope
1842 within this declarative part. In either case it specifies the alignment
1843 to be applied to any record or array type which has otherwise standard
1844 representation.
1845
1846 If the alignment for a record or array type is not specified (using
1847 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1848 clause), the GNAT uses the default alignment as described previously.
1849
1850 @node Pragma Contract_Case
1851 @unnumberedsec Pragma Contract_Case
1852 @cindex Contract cases
1853 @findex Contract_Case
1854 @noindent
1855 Syntax:
1856
1857 @smallexample @c ada
1858 pragma Contract_Case (
1859 [Name =>] static_string_Expression
1860 ,[Mode =>] (Nominal | Robustness)
1861 [, Requires => Boolean_Expression]
1862 [, Ensures => Boolean_Expression]);
1863 @end smallexample
1864
1865 @noindent
1866 The @code{Contract_Case} pragma allows defining fine-grain specifications
1867 that can complement or replace the contract given by a precondition and a
1868 postcondition. Additionally, the @code{Contract_Case} pragma can be used
1869 by testing and formal verification tools. The compiler checks its validity and,
1870 depending on the assertion policy at the point of declaration of the pragma,
1871 it may insert a check in the executable. For code generation, the contract
1872 case
1873
1874 @smallexample @c ada
1875 pragma Contract_Case (
1876 Name => ...
1877 Mode => ...
1878 Requires => R,
1879 Ensures => E);
1880 @end smallexample
1881
1882 @noindent
1883 is equivalent to
1884
1885 @smallexample @c ada
1886 pragma Postcondition (not R'Old or else E);
1887 @end smallexample
1888
1889 @noindent
1890 which is also equivalent to (in Ada 2012)
1891
1892 @smallexample @c ada
1893 pragma Postcondition (if R'Old then E);
1894 @end smallexample
1895
1896 @noindent
1897 expressing that, whenever condition @code{R} is satisfied on entry to the
1898 subprogram, condition @code{E} should be fulfilled on exit to the subprogram.
1899
1900 A precondition @code{P} and postcondition @code{Q} can also be
1901 expressed as contract cases:
1902
1903 @smallexample @c ada
1904 pragma Contract_Case (
1905 Name => "Replace precondition",
1906 Mode => Nominal,
1907 Requires => not P,
1908 Ensures => False);
1909 pragma Contract_Case (
1910 Name => "Replace postcondition",
1911 Mode => Nominal,
1912 Requires => P,
1913 Ensures => Q);
1914 @end smallexample
1915
1916 @code{Contract_Case} pragmas may only appear immediately following the
1917 (separate) declaration of a subprogram in a package declaration, inside
1918 a package spec unit. Only other pragmas may intervene (that is appear
1919 between the subprogram declaration and a contract case).
1920
1921 The compiler checks that boolean expressions given in @code{Requires} and
1922 @code{Ensures} are valid, where the rules for @code{Requires} are the
1923 same as the rule for an expression in @code{Precondition} and the rules
1924 for @code{Ensures} are the same as the rule for an expression in
1925 @code{Postcondition}. In particular, attributes @code{'Old} and
1926 @code{'Result} can only be used within the @code{Ensures}
1927 expression. The following is an example of use within a package spec:
1928
1929 @smallexample @c ada
1930 package Math_Functions is
1931 ...
1932 function Sqrt (Arg : Float) return Float;
1933 pragma Contract_Case (Name => "Small argument",
1934 Mode => Nominal,
1935 Requires => Arg < 100,
1936 Ensures => Sqrt'Result < 10);
1937 ...
1938 end Math_Functions;
1939 @end smallexample
1940
1941 @noindent
1942 The meaning of a contract case is that, whenever the associated subprogram is
1943 executed in a context where @code{Requires} holds, then @code{Ensures}
1944 should hold when the subprogram returns. Mode @code{Nominal} indicates
1945 that the input context should also satisfy the precondition of the
1946 subprogram, and the output context should also satisfy its
1947 postcondition. More @code{Robustness} indicates that the precondition and
1948 postcondition of the subprogram should be ignored for this contract case,
1949 which is mostly useful when testing such a contract using a testing tool
1950 that understands contract cases.
1951
1952 @node Pragma Convention_Identifier
1953 @unnumberedsec Pragma Convention_Identifier
1954 @findex Convention_Identifier
1955 @cindex Conventions, synonyms
1956 @noindent
1957 Syntax:
1958
1959 @smallexample @c ada
1960 pragma Convention_Identifier (
1961 [Name =>] IDENTIFIER,
1962 [Convention =>] convention_IDENTIFIER);
1963 @end smallexample
1964
1965 @noindent
1966 This pragma provides a mechanism for supplying synonyms for existing
1967 convention identifiers. The @code{Name} identifier can subsequently
1968 be used as a synonym for the given convention in other pragmas (including
1969 for example pragma @code{Import} or another @code{Convention_Identifier}
1970 pragma). As an example of the use of this, suppose you had legacy code
1971 which used Fortran77 as the identifier for Fortran. Then the pragma:
1972
1973 @smallexample @c ada
1974 pragma Convention_Identifier (Fortran77, Fortran);
1975 @end smallexample
1976
1977 @noindent
1978 would allow the use of the convention identifier @code{Fortran77} in
1979 subsequent code, avoiding the need to modify the sources. As another
1980 example, you could use this to parameterize convention requirements
1981 according to systems. Suppose you needed to use @code{Stdcall} on
1982 windows systems, and @code{C} on some other system, then you could
1983 define a convention identifier @code{Library} and use a single
1984 @code{Convention_Identifier} pragma to specify which convention
1985 would be used system-wide.
1986
1987 @node Pragma CPP_Class
1988 @unnumberedsec Pragma CPP_Class
1989 @findex CPP_Class
1990 @cindex Interfacing with C++
1991 @noindent
1992 Syntax:
1993
1994 @smallexample @c ada
1995 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1996 @end smallexample
1997
1998 @noindent
1999 The argument denotes an entity in the current declarative region that is
2000 declared as a record type. It indicates that the type corresponds to an
2001 externally declared C++ class type, and is to be laid out the same way
2002 that C++ would lay out the type. If the C++ class has virtual primitives
2003 then the record must be declared as a tagged record type.
2004
2005 Types for which @code{CPP_Class} is specified do not have assignment or
2006 equality operators defined (such operations can be imported or declared
2007 as subprograms as required). Initialization is allowed only by constructor
2008 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
2009 limited if not explicitly declared as limited or derived from a limited
2010 type, and an error is issued in that case.
2011
2012 See @ref{Interfacing to C++} for related information.
2013
2014 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
2015 for backward compatibility but its functionality is available
2016 using pragma @code{Import} with @code{Convention} = @code{CPP}.
2017
2018 @node Pragma CPP_Constructor
2019 @unnumberedsec Pragma CPP_Constructor
2020 @cindex Interfacing with C++
2021 @findex CPP_Constructor
2022 @noindent
2023 Syntax:
2024
2025 @smallexample @c ada
2026 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
2027 [, [External_Name =>] static_string_EXPRESSION ]
2028 [, [Link_Name =>] static_string_EXPRESSION ]);
2029 @end smallexample
2030
2031 @noindent
2032 This pragma identifies an imported function (imported in the usual way
2033 with pragma @code{Import}) as corresponding to a C++ constructor. If
2034 @code{External_Name} and @code{Link_Name} are not specified then the
2035 @code{Entity} argument is a name that must have been previously mentioned
2036 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
2037 must be of one of the following forms:
2038
2039 @itemize @bullet
2040 @item
2041 @code{function @var{Fname} return @var{T}}
2042
2043 @itemize @bullet
2044 @item
2045 @code{function @var{Fname} return @var{T}'Class}
2046
2047 @item
2048 @code{function @var{Fname} (@dots{}) return @var{T}}
2049 @end itemize
2050
2051 @item
2052 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
2053 @end itemize
2054
2055 @noindent
2056 where @var{T} is a limited record type imported from C++ with pragma
2057 @code{Import} and @code{Convention} = @code{CPP}.
2058
2059 The first two forms import the default constructor, used when an object
2060 of type @var{T} is created on the Ada side with no explicit constructor.
2061 The latter two forms cover all the non-default constructors of the type.
2062 See the @value{EDITION} User's Guide for details.
2063
2064 If no constructors are imported, it is impossible to create any objects
2065 on the Ada side and the type is implicitly declared abstract.
2066
2067 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
2068 using an automatic binding generator tool (such as the @code{-fdump-ada-spec}
2069 GCC switch).
2070 See @ref{Interfacing to C++} for more related information.
2071
2072 Note: The use of functions returning class-wide types for constructors is
2073 currently obsolete. They are supported for backward compatibility. The
2074 use of functions returning the type T leave the Ada sources more clear
2075 because the imported C++ constructors always return an object of type T;
2076 that is, they never return an object whose type is a descendant of type T.
2077
2078 @node Pragma CPP_Virtual
2079 @unnumberedsec Pragma CPP_Virtual
2080 @cindex Interfacing to C++
2081 @findex CPP_Virtual
2082 @noindent
2083 This pragma is now obsolete has has no effect because GNAT generates
2084 the same object layout than the G++ compiler.
2085
2086 See @ref{Interfacing to C++} for related information.
2087
2088 @node Pragma CPP_Vtable
2089 @unnumberedsec Pragma CPP_Vtable
2090 @cindex Interfacing with C++
2091 @findex CPP_Vtable
2092 @noindent
2093 This pragma is now obsolete has has no effect because GNAT generates
2094 the same object layout than the G++ compiler.
2095
2096 See @ref{Interfacing to C++} for related information.
2097
2098 @node Pragma CPU
2099 @unnumberedsec Pragma CPU
2100 @findex CPU
2101 @noindent
2102 Syntax:
2103
2104 @smallexample @c ada
2105 pragma CPU (EXPRESSSION);
2106 @end smallexample
2107
2108 @noindent
2109 This pragma is standard in Ada 2012, but is available in all earlier
2110 versions of Ada as an implementation-defined pragma.
2111 See Ada 2012 Reference Manual for details.
2112
2113 @node Pragma Debug
2114 @unnumberedsec Pragma Debug
2115 @findex Debug
2116 @noindent
2117 Syntax:
2118
2119 @smallexample @c ada
2120 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
2121
2122 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
2123 PROCEDURE_NAME
2124 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
2125 @end smallexample
2126
2127 @noindent
2128 The procedure call argument has the syntactic form of an expression, meeting
2129 the syntactic requirements for pragmas.
2130
2131 If debug pragmas are not enabled or if the condition is present and evaluates
2132 to False, this pragma has no effect. If debug pragmas are enabled, the
2133 semantics of the pragma is exactly equivalent to the procedure call statement
2134 corresponding to the argument with a terminating semicolon. Pragmas are
2135 permitted in sequences of declarations, so you can use pragma @code{Debug} to
2136 intersperse calls to debug procedures in the middle of declarations. Debug
2137 pragmas can be enabled either by use of the command line switch @option{-gnata}
2138 or by use of the pragma @code{Check_Policy} with a first argument of
2139 @code{Debug}.
2140
2141 @node Pragma Debug_Policy
2142 @unnumberedsec Pragma Debug_Policy
2143 @findex Debug_Policy
2144 @noindent
2145 Syntax:
2146
2147 @smallexample @c ada
2148 pragma Debug_Policy (CHECK | DISABLE | IGNORE | ON | OFF);
2149 @end smallexample
2150
2151 @noindent
2152 This pragma is equivalent to a corresponding @code{Check_Policy} pragma
2153 with a first argument of @code{Debug}. It is retained for historical
2154 compatibility reasons.
2155
2156 @node Pragma Default_Storage_Pool
2157 @unnumberedsec Pragma Default_Storage_Pool
2158 @findex Default_Storage_Pool
2159 @noindent
2160 Syntax:
2161
2162 @smallexample @c ada
2163 pragma Default_Storage_Pool (storage_pool_NAME | null);
2164 @end smallexample
2165
2166 @noindent
2167 This pragma is standard in Ada 2012, but is available in all earlier
2168 versions of Ada as an implementation-defined pragma.
2169 See Ada 2012 Reference Manual for details.
2170
2171 @node Pragma Detect_Blocking
2172 @unnumberedsec Pragma Detect_Blocking
2173 @findex Detect_Blocking
2174 @noindent
2175 Syntax:
2176
2177 @smallexample @c ada
2178 pragma Detect_Blocking;
2179 @end smallexample
2180
2181 @noindent
2182 This is a standard pragma in Ada 2005, that is available in all earlier
2183 versions of Ada as an implementation-defined pragma.
2184
2185 This is a configuration pragma that forces the detection of potentially
2186 blocking operations within a protected operation, and to raise Program_Error
2187 if that happens.
2188
2189 @node Pragma Dispatching_Domain
2190 @unnumberedsec Pragma Dispatching_Domain
2191 @findex Dispatching_Domain
2192 @noindent
2193 Syntax:
2194
2195 @smallexample @c ada
2196 pragma Dispatching_Domain (EXPRESSION);
2197 @end smallexample
2198
2199 @noindent
2200 This pragma is standard in Ada 2012, but is available in all earlier
2201 versions of Ada as an implementation-defined pragma.
2202 See Ada 2012 Reference Manual for details.
2203
2204 @node Pragma Elaboration_Checks
2205 @unnumberedsec Pragma Elaboration_Checks
2206 @cindex Elaboration control
2207 @findex Elaboration_Checks
2208 @noindent
2209 Syntax:
2210
2211 @smallexample @c ada
2212 pragma Elaboration_Checks (Dynamic | Static);
2213 @end smallexample
2214
2215 @noindent
2216 This is a configuration pragma that provides control over the
2217 elaboration model used by the compilation affected by the
2218 pragma. If the parameter is @code{Dynamic},
2219 then the dynamic elaboration
2220 model described in the Ada Reference Manual is used, as though
2221 the @option{-gnatE} switch had been specified on the command
2222 line. If the parameter is @code{Static}, then the default GNAT static
2223 model is used. This configuration pragma overrides the setting
2224 of the command line. For full details on the elaboration models
2225 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
2226 gnat_ugn, @value{EDITION} User's Guide}.
2227
2228 @node Pragma Eliminate
2229 @unnumberedsec Pragma Eliminate
2230 @cindex Elimination of unused subprograms
2231 @findex Eliminate
2232 @noindent
2233 Syntax:
2234
2235 @smallexample @c ada
2236 pragma Eliminate ([Entity =>] DEFINING_DESIGNATOR,
2237 [Source_Location =>] STRING_LITERAL);
2238 @end smallexample
2239
2240 @noindent
2241 The string literal given for the source location is a string which
2242 specifies the line number of the occurrence of the entity, using
2243 the syntax for SOURCE_TRACE given below:
2244
2245 @smallexample @c ada
2246 SOURCE_TRACE ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
2247
2248 LBRACKET ::= [
2249 RBRACKET ::= ]
2250
2251 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
2252
2253 LINE_NUMBER ::= DIGIT @{DIGIT@}
2254 @end smallexample
2255
2256 @noindent
2257 Spaces around the colon in a @code{Source_Reference} are optional.
2258
2259 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
2260 explicit subprogram declaration, where the @code{entity} name in this
2261 designator appears on the source line specified by the source location.
2262
2263 The source trace that is given as the @code{Source_Location} shall obey the
2264 following rules. The @code{FILE_NAME} is the short name (with no directory
2265 information) of an Ada source file, given using exactly the required syntax
2266 for the underlying file system (e.g. case is important if the underlying
2267 operating system is case sensitive). @code{LINE_NUMBER} gives the line
2268 number of the occurrence of the @code{entity}
2269 as a decimal literal without an exponent or point. If an @code{entity} is not
2270 declared in a generic instantiation (this includes generic subprogram
2271 instances), the source trace includes only one source reference. If an entity
2272 is declared inside a generic instantiation, its source trace (when parsing
2273 from left to right) starts with the source location of the declaration of the
2274 entity in the generic unit and ends with the source location of the
2275 instantiation (it is given in square brackets). This approach is recursively
2276 used in case of nested instantiations: the rightmost (nested most deeply in
2277 square brackets) element of the source trace is the location of the outermost
2278 instantiation, the next to left element is the location of the next (first
2279 nested) instantiation in the code of the corresponding generic unit, and so
2280 on, and the leftmost element (that is out of any square brackets) is the
2281 location of the declaration of the entity to eliminate in a generic unit.
2282
2283 Note that the @code{Source_Location} argument specifies which of a set of
2284 similarly named entities is being eliminated, dealing both with overloading,
2285 and also appearence of the same entity name in different scopes.
2286
2287 This pragma indicates that the given entity is not used in the program to be
2288 compiled and built. The effect of the pragma is to allow the compiler to
2289 eliminate the code or data associated with the named entity. Any reference to
2290 an eliminated entity causes a compile-time or link-time error.
2291
2292 The intention of pragma @code{Eliminate} is to allow a program to be compiled
2293 in a system-independent manner, with unused entities eliminated, without
2294 needing to modify the source text. Normally the required set of
2295 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
2296
2297 Any source file change that removes, splits, or
2298 adds lines may make the set of Eliminate pragmas invalid because their
2299 @code{Source_Location} argument values may get out of date.
2300
2301 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
2302 operation. In this case all the subprograms to which the given operation can
2303 dispatch are considered to be unused (are never called as a result of a direct
2304 or a dispatching call).
2305
2306 @node Pragma Export_Exception
2307 @unnumberedsec Pragma Export_Exception
2308 @cindex OpenVMS
2309 @findex Export_Exception
2310 @noindent
2311 Syntax:
2312
2313 @smallexample @c ada
2314 pragma Export_Exception (
2315 [Internal =>] LOCAL_NAME
2316 [, [External =>] EXTERNAL_SYMBOL]
2317 [, [Form =>] Ada | VMS]
2318 [, [Code =>] static_integer_EXPRESSION]);
2319
2320 EXTERNAL_SYMBOL ::=
2321 IDENTIFIER
2322 | static_string_EXPRESSION
2323 @end smallexample
2324
2325 @noindent
2326 This pragma is implemented only in the OpenVMS implementation of GNAT@. It
2327 causes the specified exception to be propagated outside of the Ada program,
2328 so that it can be handled by programs written in other OpenVMS languages.
2329 This pragma establishes an external name for an Ada exception and makes the
2330 name available to the OpenVMS Linker as a global symbol. For further details
2331 on this pragma, see the
2332 DEC Ada Language Reference Manual, section 13.9a3.2.
2333
2334 @node Pragma Export_Function
2335 @unnumberedsec Pragma Export_Function
2336 @cindex Argument passing mechanisms
2337 @findex Export_Function
2338
2339 @noindent
2340 Syntax:
2341
2342 @smallexample @c ada
2343 pragma Export_Function (
2344 [Internal =>] LOCAL_NAME
2345 [, [External =>] EXTERNAL_SYMBOL]
2346 [, [Parameter_Types =>] PARAMETER_TYPES]
2347 [, [Result_Type =>] result_SUBTYPE_MARK]
2348 [, [Mechanism =>] MECHANISM]
2349 [, [Result_Mechanism =>] MECHANISM_NAME]);
2350
2351 EXTERNAL_SYMBOL ::=
2352 IDENTIFIER
2353 | static_string_EXPRESSION
2354 | ""
2355
2356 PARAMETER_TYPES ::=
2357 null
2358 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2359
2360 TYPE_DESIGNATOR ::=
2361 subtype_NAME
2362 | subtype_Name ' Access
2363
2364 MECHANISM ::=
2365 MECHANISM_NAME
2366 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2367
2368 MECHANISM_ASSOCIATION ::=
2369 [formal_parameter_NAME =>] MECHANISM_NAME
2370
2371 MECHANISM_NAME ::=
2372 Value
2373 | Reference
2374 | Descriptor [([Class =>] CLASS_NAME)]
2375 | Short_Descriptor [([Class =>] CLASS_NAME)]
2376
2377 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2378 @end smallexample
2379
2380 @noindent
2381 Use this pragma to make a function externally callable and optionally
2382 provide information on mechanisms to be used for passing parameter and
2383 result values. We recommend, for the purposes of improving portability,
2384 this pragma always be used in conjunction with a separate pragma
2385 @code{Export}, which must precede the pragma @code{Export_Function}.
2386 GNAT does not require a separate pragma @code{Export}, but if none is
2387 present, @code{Convention Ada} is assumed, which is usually
2388 not what is wanted, so it is usually appropriate to use this
2389 pragma in conjunction with a @code{Export} or @code{Convention}
2390 pragma that specifies the desired foreign convention.
2391 Pragma @code{Export_Function}
2392 (and @code{Export}, if present) must appear in the same declarative
2393 region as the function to which they apply.
2394
2395 @var{internal_name} must uniquely designate the function to which the
2396 pragma applies. If more than one function name exists of this name in
2397 the declarative part you must use the @code{Parameter_Types} and
2398 @code{Result_Type} parameters is mandatory to achieve the required
2399 unique designation. @var{subtype_mark}s in these parameters must
2400 exactly match the subtypes in the corresponding function specification,
2401 using positional notation to match parameters with subtype marks.
2402 The form with an @code{'Access} attribute can be used to match an
2403 anonymous access parameter.
2404
2405 @cindex OpenVMS
2406 @cindex Passing by descriptor
2407 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2408 The default behavior for Export_Function is to accept either 64bit or
2409 32bit descriptors unless short_descriptor is specified, then only 32bit
2410 descriptors are accepted.
2411
2412 @cindex Suppressing external name
2413 Special treatment is given if the EXTERNAL is an explicit null
2414 string or a static string expressions that evaluates to the null
2415 string. In this case, no external name is generated. This form
2416 still allows the specification of parameter mechanisms.
2417
2418 @node Pragma Export_Object
2419 @unnumberedsec Pragma Export_Object
2420 @findex Export_Object
2421 @noindent
2422 Syntax:
2423
2424 @smallexample @c ada
2425 pragma Export_Object
2426 [Internal =>] LOCAL_NAME
2427 [, [External =>] EXTERNAL_SYMBOL]
2428 [, [Size =>] EXTERNAL_SYMBOL]
2429
2430 EXTERNAL_SYMBOL ::=
2431 IDENTIFIER
2432 | static_string_EXPRESSION
2433 @end smallexample
2434
2435 @noindent
2436 This pragma designates an object as exported, and apart from the
2437 extended rules for external symbols, is identical in effect to the use of
2438 the normal @code{Export} pragma applied to an object. You may use a
2439 separate Export pragma (and you probably should from the point of view
2440 of portability), but it is not required. @var{Size} is syntax checked,
2441 but otherwise ignored by GNAT@.
2442
2443 @node Pragma Export_Procedure
2444 @unnumberedsec Pragma Export_Procedure
2445 @findex Export_Procedure
2446 @noindent
2447 Syntax:
2448
2449 @smallexample @c ada
2450 pragma Export_Procedure (
2451 [Internal =>] LOCAL_NAME
2452 [, [External =>] EXTERNAL_SYMBOL]
2453 [, [Parameter_Types =>] PARAMETER_TYPES]
2454 [, [Mechanism =>] MECHANISM]);
2455
2456 EXTERNAL_SYMBOL ::=
2457 IDENTIFIER
2458 | static_string_EXPRESSION
2459 | ""
2460
2461 PARAMETER_TYPES ::=
2462 null
2463 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2464
2465 TYPE_DESIGNATOR ::=
2466 subtype_NAME
2467 | subtype_Name ' Access
2468
2469 MECHANISM ::=
2470 MECHANISM_NAME
2471 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2472
2473 MECHANISM_ASSOCIATION ::=
2474 [formal_parameter_NAME =>] MECHANISM_NAME
2475
2476 MECHANISM_NAME ::=
2477 Value
2478 | Reference
2479 | Descriptor [([Class =>] CLASS_NAME)]
2480 | Short_Descriptor [([Class =>] CLASS_NAME)]
2481
2482 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2483 @end smallexample
2484
2485 @noindent
2486 This pragma is identical to @code{Export_Function} except that it
2487 applies to a procedure rather than a function and the parameters
2488 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2489 GNAT does not require a separate pragma @code{Export}, but if none is
2490 present, @code{Convention Ada} is assumed, which is usually
2491 not what is wanted, so it is usually appropriate to use this
2492 pragma in conjunction with a @code{Export} or @code{Convention}
2493 pragma that specifies the desired foreign convention.
2494
2495 @cindex OpenVMS
2496 @cindex Passing by descriptor
2497 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2498 The default behavior for Export_Procedure is to accept either 64bit or
2499 32bit descriptors unless short_descriptor is specified, then only 32bit
2500 descriptors are accepted.
2501
2502 @cindex Suppressing external name
2503 Special treatment is given if the EXTERNAL is an explicit null
2504 string or a static string expressions that evaluates to the null
2505 string. In this case, no external name is generated. This form
2506 still allows the specification of parameter mechanisms.
2507
2508 @node Pragma Export_Value
2509 @unnumberedsec Pragma Export_Value
2510 @findex Export_Value
2511 @noindent
2512 Syntax:
2513
2514 @smallexample @c ada
2515 pragma Export_Value (
2516 [Value =>] static_integer_EXPRESSION,
2517 [Link_Name =>] static_string_EXPRESSION);
2518 @end smallexample
2519
2520 @noindent
2521 This pragma serves to export a static integer value for external use.
2522 The first argument specifies the value to be exported. The Link_Name
2523 argument specifies the symbolic name to be associated with the integer
2524 value. This pragma is useful for defining a named static value in Ada
2525 that can be referenced in assembly language units to be linked with
2526 the application. This pragma is currently supported only for the
2527 AAMP target and is ignored for other targets.
2528
2529 @node Pragma Export_Valued_Procedure
2530 @unnumberedsec Pragma Export_Valued_Procedure
2531 @findex Export_Valued_Procedure
2532 @noindent
2533 Syntax:
2534
2535 @smallexample @c ada
2536 pragma Export_Valued_Procedure (
2537 [Internal =>] LOCAL_NAME
2538 [, [External =>] EXTERNAL_SYMBOL]
2539 [, [Parameter_Types =>] PARAMETER_TYPES]
2540 [, [Mechanism =>] MECHANISM]);
2541
2542 EXTERNAL_SYMBOL ::=
2543 IDENTIFIER
2544 | static_string_EXPRESSION
2545 | ""
2546
2547 PARAMETER_TYPES ::=
2548 null
2549 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2550
2551 TYPE_DESIGNATOR ::=
2552 subtype_NAME
2553 | subtype_Name ' Access
2554
2555 MECHANISM ::=
2556 MECHANISM_NAME
2557 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2558
2559 MECHANISM_ASSOCIATION ::=
2560 [formal_parameter_NAME =>] MECHANISM_NAME
2561
2562 MECHANISM_NAME ::=
2563 Value
2564 | Reference
2565 | Descriptor [([Class =>] CLASS_NAME)]
2566 | Short_Descriptor [([Class =>] CLASS_NAME)]
2567
2568 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2569 @end smallexample
2570
2571 @noindent
2572 This pragma is identical to @code{Export_Procedure} except that the
2573 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2574 mode @code{OUT}, and externally the subprogram is treated as a function
2575 with this parameter as the result of the function. GNAT provides for
2576 this capability to allow the use of @code{OUT} and @code{IN OUT}
2577 parameters in interfacing to external functions (which are not permitted
2578 in Ada functions).
2579 GNAT does not require a separate pragma @code{Export}, but if none is
2580 present, @code{Convention Ada} is assumed, which is almost certainly
2581 not what is wanted since the whole point of this pragma is to interface
2582 with foreign language functions, so it is usually appropriate to use this
2583 pragma in conjunction with a @code{Export} or @code{Convention}
2584 pragma that specifies the desired foreign convention.
2585
2586 @cindex OpenVMS
2587 @cindex Passing by descriptor
2588 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2589 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2590 32bit descriptors unless short_descriptor is specified, then only 32bit
2591 descriptors are accepted.
2592
2593 @cindex Suppressing external name
2594 Special treatment is given if the EXTERNAL is an explicit null
2595 string or a static string expressions that evaluates to the null
2596 string. In this case, no external name is generated. This form
2597 still allows the specification of parameter mechanisms.
2598
2599 @node Pragma Extend_System
2600 @unnumberedsec Pragma Extend_System
2601 @cindex @code{system}, extending
2602 @cindex Dec Ada 83
2603 @findex Extend_System
2604 @noindent
2605 Syntax:
2606
2607 @smallexample @c ada
2608 pragma Extend_System ([Name =>] IDENTIFIER);
2609 @end smallexample
2610
2611 @noindent
2612 This pragma is used to provide backwards compatibility with other
2613 implementations that extend the facilities of package @code{System}. In
2614 GNAT, @code{System} contains only the definitions that are present in
2615 the Ada RM@. However, other implementations, notably the DEC Ada 83
2616 implementation, provide many extensions to package @code{System}.
2617
2618 For each such implementation accommodated by this pragma, GNAT provides a
2619 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2620 implementation, which provides the required additional definitions. You
2621 can use this package in two ways. You can @code{with} it in the normal
2622 way and access entities either by selection or using a @code{use}
2623 clause. In this case no special processing is required.
2624
2625 However, if existing code contains references such as
2626 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2627 definitions provided in package @code{System}, you may use this pragma
2628 to extend visibility in @code{System} in a non-standard way that
2629 provides greater compatibility with the existing code. Pragma
2630 @code{Extend_System} is a configuration pragma whose single argument is
2631 the name of the package containing the extended definition
2632 (e.g.@: @code{Aux_DEC} for the DEC Ada case). A unit compiled under
2633 control of this pragma will be processed using special visibility
2634 processing that looks in package @code{System.Aux_@var{xxx}} where
2635 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2636 package @code{System}, but not found in package @code{System}.
2637
2638 You can use this pragma either to access a predefined @code{System}
2639 extension supplied with the compiler, for example @code{Aux_DEC} or
2640 you can construct your own extension unit following the above
2641 definition. Note that such a package is a child of @code{System}
2642 and thus is considered part of the implementation. To compile
2643 it you will have to use the appropriate switch for compiling
2644 system units.
2645 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2646 for details.
2647
2648 @node Pragma Extensions_Allowed
2649 @unnumberedsec Pragma Extensions_Allowed
2650 @cindex Ada Extensions
2651 @cindex GNAT Extensions
2652 @findex Extensions_Allowed
2653 @noindent
2654 Syntax:
2655
2656 @smallexample @c ada
2657 pragma Extensions_Allowed (On | Off);
2658 @end smallexample
2659
2660 @noindent
2661 This configuration pragma enables or disables the implementation
2662 extension mode (the use of Off as a parameter cancels the effect
2663 of the @option{-gnatX} command switch).
2664
2665 In extension mode, the latest version of the Ada language is
2666 implemented (currently Ada 2012), and in addition a small number
2667 of GNAT specific extensions are recognized as follows:
2668
2669 @table @asis
2670 @item Constrained attribute for generic objects
2671 The @code{Constrained} attribute is permitted for objects of
2672 generic types. The result indicates if the corresponding actual
2673 is constrained.
2674
2675 @end table
2676
2677 @node Pragma External
2678 @unnumberedsec Pragma External
2679 @findex External
2680 @noindent
2681 Syntax:
2682
2683 @smallexample @c ada
2684 pragma External (
2685 [ Convention =>] convention_IDENTIFIER,
2686 [ Entity =>] LOCAL_NAME
2687 [, [External_Name =>] static_string_EXPRESSION ]
2688 [, [Link_Name =>] static_string_EXPRESSION ]);
2689 @end smallexample
2690
2691 @noindent
2692 This pragma is identical in syntax and semantics to pragma
2693 @code{Export} as defined in the Ada Reference Manual. It is
2694 provided for compatibility with some Ada 83 compilers that
2695 used this pragma for exactly the same purposes as pragma
2696 @code{Export} before the latter was standardized.
2697
2698 @node Pragma External_Name_Casing
2699 @unnumberedsec Pragma External_Name_Casing
2700 @cindex Dec Ada 83 casing compatibility
2701 @cindex External Names, casing
2702 @cindex Casing of External names
2703 @findex External_Name_Casing
2704 @noindent
2705 Syntax:
2706
2707 @smallexample @c ada
2708 pragma External_Name_Casing (
2709 Uppercase | Lowercase
2710 [, Uppercase | Lowercase | As_Is]);
2711 @end smallexample
2712
2713 @noindent
2714 This pragma provides control over the casing of external names associated
2715 with Import and Export pragmas. There are two cases to consider:
2716
2717 @table @asis
2718 @item Implicit external names
2719 Implicit external names are derived from identifiers. The most common case
2720 arises when a standard Ada Import or Export pragma is used with only two
2721 arguments, as in:
2722
2723 @smallexample @c ada
2724 pragma Import (C, C_Routine);
2725 @end smallexample
2726
2727 @noindent
2728 Since Ada is a case-insensitive language, the spelling of the identifier in
2729 the Ada source program does not provide any information on the desired
2730 casing of the external name, and so a convention is needed. In GNAT the
2731 default treatment is that such names are converted to all lower case
2732 letters. This corresponds to the normal C style in many environments.
2733 The first argument of pragma @code{External_Name_Casing} can be used to
2734 control this treatment. If @code{Uppercase} is specified, then the name
2735 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2736 then the normal default of all lower case letters will be used.
2737
2738 This same implicit treatment is also used in the case of extended DEC Ada 83
2739 compatible Import and Export pragmas where an external name is explicitly
2740 specified using an identifier rather than a string.
2741
2742 @item Explicit external names
2743 Explicit external names are given as string literals. The most common case
2744 arises when a standard Ada Import or Export pragma is used with three
2745 arguments, as in:
2746
2747 @smallexample @c ada
2748 pragma Import (C, C_Routine, "C_routine");
2749 @end smallexample
2750
2751 @noindent
2752 In this case, the string literal normally provides the exact casing required
2753 for the external name. The second argument of pragma
2754 @code{External_Name_Casing} may be used to modify this behavior.
2755 If @code{Uppercase} is specified, then the name
2756 will be forced to all uppercase letters. If @code{Lowercase} is specified,
2757 then the name will be forced to all lowercase letters. A specification of
2758 @code{As_Is} provides the normal default behavior in which the casing is
2759 taken from the string provided.
2760 @end table
2761
2762 @noindent
2763 This pragma may appear anywhere that a pragma is valid. In particular, it
2764 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2765 case it applies to all subsequent compilations, or it can be used as a program
2766 unit pragma, in which case it only applies to the current unit, or it can
2767 be used more locally to control individual Import/Export pragmas.
2768
2769 It is primarily intended for use with OpenVMS systems, where many
2770 compilers convert all symbols to upper case by default. For interfacing to
2771 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2772 the pragma:
2773
2774 @smallexample @c ada
2775 pragma External_Name_Casing (Uppercase, Uppercase);
2776 @end smallexample
2777
2778 @noindent
2779 to enforce the upper casing of all external symbols.
2780
2781 @node Pragma Fast_Math
2782 @unnumberedsec Pragma Fast_Math
2783 @findex Fast_Math
2784 @noindent
2785 Syntax:
2786
2787 @smallexample @c ada
2788 pragma Fast_Math;
2789 @end smallexample
2790
2791 @noindent
2792 This is a configuration pragma which activates a mode in which speed is
2793 considered more important for floating-point operations than absolutely
2794 accurate adherence to the requirements of the standard. Currently the
2795 following operations are affected:
2796
2797 @table @asis
2798 @item Complex Multiplication
2799 The normal simple formula for complex multiplication can result in intermediate
2800 overflows for numbers near the end of the range. The Ada standard requires that
2801 this situation be detected and corrected by scaling, but in Fast_Math mode such
2802 cases will simply result in overflow. Note that to take advantage of this you
2803 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2804 under control of the pragma, rather than use the preinstantiated versions.
2805 @end table
2806
2807 @node Pragma Favor_Top_Level
2808 @unnumberedsec Pragma Favor_Top_Level
2809 @findex Favor_Top_Level
2810 @noindent
2811 Syntax:
2812
2813 @smallexample @c ada
2814 pragma Favor_Top_Level (type_NAME);
2815 @end smallexample
2816
2817 @noindent
2818 The named type must be an access-to-subprogram type. This pragma is an
2819 efficiency hint to the compiler, regarding the use of 'Access or
2820 'Unrestricted_Access on nested (non-library-level) subprograms. The
2821 pragma means that nested subprograms are not used with this type, or
2822 are rare, so that the generated code should be efficient in the
2823 top-level case. When this pragma is used, dynamically generated
2824 trampolines may be used on some targets for nested subprograms.
2825 See also the No_Implicit_Dynamic_Code restriction.
2826
2827 @node Pragma Finalize_Storage_Only
2828 @unnumberedsec Pragma Finalize_Storage_Only
2829 @findex Finalize_Storage_Only
2830 @noindent
2831 Syntax:
2832
2833 @smallexample @c ada
2834 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2835 @end smallexample
2836
2837 @noindent
2838 This pragma allows the compiler not to emit a Finalize call for objects
2839 defined at the library level. This is mostly useful for types where
2840 finalization is only used to deal with storage reclamation since in most
2841 environments it is not necessary to reclaim memory just before terminating
2842 execution, hence the name.
2843
2844 @node Pragma Float_Representation
2845 @unnumberedsec Pragma Float_Representation
2846 @cindex OpenVMS
2847 @findex Float_Representation
2848 @noindent
2849 Syntax:
2850
2851 @smallexample @c ada
2852 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2853
2854 FLOAT_REP ::= VAX_Float | IEEE_Float
2855 @end smallexample
2856
2857 @noindent
2858 In the one argument form, this pragma is a configuration pragma which
2859 allows control over the internal representation chosen for the predefined
2860 floating point types declared in the packages @code{Standard} and
2861 @code{System}. On all systems other than OpenVMS, the argument must
2862 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2863 argument may be @code{VAX_Float} to specify the use of the VAX float
2864 format for the floating-point types in Standard. This requires that
2865 the standard runtime libraries be recompiled.
2866
2867 The two argument form specifies the representation to be used for
2868 the specified floating-point type. On all systems other than OpenVMS,
2869 the argument must
2870 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2871 argument may be @code{VAX_Float} to specify the use of the VAX float
2872 format, as follows:
2873
2874 @itemize @bullet
2875 @item
2876 For digits values up to 6, F float format will be used.
2877 @item
2878 For digits values from 7 to 9, D float format will be used.
2879 @item
2880 For digits values from 10 to 15, G float format will be used.
2881 @item
2882 Digits values above 15 are not allowed.
2883 @end itemize
2884
2885 @node Pragma Ident
2886 @unnumberedsec Pragma Ident
2887 @findex Ident
2888 @noindent
2889 Syntax:
2890
2891 @smallexample @c ada
2892 pragma Ident (static_string_EXPRESSION);
2893 @end smallexample
2894
2895 @noindent
2896 This pragma provides a string identification in the generated object file,
2897 if the system supports the concept of this kind of identification string.
2898 This pragma is allowed only in the outermost declarative part or
2899 declarative items of a compilation unit. If more than one @code{Ident}
2900 pragma is given, only the last one processed is effective.
2901 @cindex OpenVMS
2902 On OpenVMS systems, the effect of the pragma is identical to the effect of
2903 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2904 maximum allowed length is 31 characters, so if it is important to
2905 maintain compatibility with this compiler, you should obey this length
2906 limit.
2907
2908 @node Pragma Implementation_Defined
2909 @unnumberedsec Pragma Implementation_Defined
2910 @findex Implementation_Defined
2911 @noindent
2912 Syntax:
2913
2914 @smallexample @c ada
2915 pragma Implementation_Defined (local_NAME);
2916 @end smallexample
2917
2918 @noindent
2919 This pragma marks a previously declared entioty as implementation-defined.
2920 For an overloaded entity, applies to the most recent homonym.
2921
2922 @smallexample @c ada
2923 pragma Implementation_Defined;
2924 @end smallexample
2925
2926 @noindent
2927 The form with no arguments appears anywhere within a scope, most
2928 typically a package spec, and indicates that all entities that are
2929 defined within the package spec are Implementation_Defined.
2930
2931 This pragma is used within the GNAT runtime library to identify
2932 implementation-defined entities introduced in language-defined units,
2933 for the purpose of implementing the No_Implementation_Identifiers
2934 restriction.
2935
2936 @node Pragma Implemented
2937 @unnumberedsec Pragma Implemented
2938 @findex Implemented
2939 @noindent
2940 Syntax:
2941
2942 @smallexample @c ada
2943 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2944
2945 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2946 @end smallexample
2947
2948 @noindent
2949 This is an Ada 2012 representation pragma which applies to protected, task
2950 and synchronized interface primitives. The use of pragma Implemented provides
2951 a way to impose a static requirement on the overriding operation by adhering
2952 to one of the three implementation kinds: entry, protected procedure or any of
2953 the above. This pragma is available in all earlier versions of Ada as an
2954 implementation-defined pragma.
2955
2956 @smallexample @c ada
2957 type Synch_Iface is synchronized interface;
2958 procedure Prim_Op (Obj : in out Iface) is abstract;
2959 pragma Implemented (Prim_Op, By_Protected_Procedure);
2960
2961 protected type Prot_1 is new Synch_Iface with
2962 procedure Prim_Op; -- Legal
2963 end Prot_1;
2964
2965 protected type Prot_2 is new Synch_Iface with
2966 entry Prim_Op; -- Illegal
2967 end Prot_2;
2968
2969 task type Task_Typ is new Synch_Iface with
2970 entry Prim_Op; -- Illegal
2971 end Task_Typ;
2972 @end smallexample
2973
2974 @noindent
2975 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2976 Implemented determines the runtime behavior of the requeue. Implementation kind
2977 By_Entry guarantees that the action of requeueing will proceed from an entry to
2978 another entry. Implementation kind By_Protected_Procedure transforms the
2979 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2980 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2981 the target's overriding subprogram kind.
2982
2983 @node Pragma Implicit_Packing
2984 @unnumberedsec Pragma Implicit_Packing
2985 @findex Implicit_Packing
2986 @cindex Rational Profile
2987 @noindent
2988 Syntax:
2989
2990 @smallexample @c ada
2991 pragma Implicit_Packing;
2992 @end smallexample
2993
2994 @noindent
2995 This is a configuration pragma that requests implicit packing for packed
2996 arrays for which a size clause is given but no explicit pragma Pack or
2997 specification of Component_Size is present. It also applies to records
2998 where no record representation clause is present. Consider this example:
2999
3000 @smallexample @c ada
3001 type R is array (0 .. 7) of Boolean;
3002 for R'Size use 8;
3003 @end smallexample
3004
3005 @noindent
3006 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
3007 does not change the layout of a composite object. So the Size clause in the
3008 above example is normally rejected, since the default layout of the array uses
3009 8-bit components, and thus the array requires a minimum of 64 bits.
3010
3011 If this declaration is compiled in a region of code covered by an occurrence
3012 of the configuration pragma Implicit_Packing, then the Size clause in this
3013 and similar examples will cause implicit packing and thus be accepted. For
3014 this implicit packing to occur, the type in question must be an array of small
3015 components whose size is known at compile time, and the Size clause must
3016 specify the exact size that corresponds to the length of the array multiplied
3017 by the size in bits of the component type.
3018 @cindex Array packing
3019
3020 Similarly, the following example shows the use in the record case
3021
3022 @smallexample @c ada
3023 type r is record
3024 a, b, c, d, e, f, g, h : boolean;
3025 chr : character;
3026 end record;
3027 for r'size use 16;
3028 @end smallexample
3029
3030 @noindent
3031 Without a pragma Pack, each Boolean field requires 8 bits, so the
3032 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
3033 sufficient. The use of pragma Implicit_Packing allows this record
3034 declaration to compile without an explicit pragma Pack.
3035 @node Pragma Import_Exception
3036 @unnumberedsec Pragma Import_Exception
3037 @cindex OpenVMS
3038 @findex Import_Exception
3039 @noindent
3040 Syntax:
3041
3042 @smallexample @c ada
3043 pragma Import_Exception (
3044 [Internal =>] LOCAL_NAME
3045 [, [External =>] EXTERNAL_SYMBOL]
3046 [, [Form =>] Ada | VMS]
3047 [, [Code =>] static_integer_EXPRESSION]);
3048
3049 EXTERNAL_SYMBOL ::=
3050 IDENTIFIER
3051 | static_string_EXPRESSION
3052 @end smallexample
3053
3054 @noindent
3055 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3056 It allows OpenVMS conditions (for example, from OpenVMS system services or
3057 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
3058 The pragma specifies that the exception associated with an exception
3059 declaration in an Ada program be defined externally (in non-Ada code).
3060 For further details on this pragma, see the
3061 DEC Ada Language Reference Manual, section 13.9a.3.1.
3062
3063 @node Pragma Import_Function
3064 @unnumberedsec Pragma Import_Function
3065 @findex Import_Function
3066 @noindent
3067 Syntax:
3068
3069 @smallexample @c ada
3070 pragma Import_Function (
3071 [Internal =>] LOCAL_NAME,
3072 [, [External =>] EXTERNAL_SYMBOL]
3073 [, [Parameter_Types =>] PARAMETER_TYPES]
3074 [, [Result_Type =>] SUBTYPE_MARK]
3075 [, [Mechanism =>] MECHANISM]
3076 [, [Result_Mechanism =>] MECHANISM_NAME]
3077 [, [First_Optional_Parameter =>] IDENTIFIER]);
3078
3079 EXTERNAL_SYMBOL ::=
3080 IDENTIFIER
3081 | static_string_EXPRESSION
3082
3083 PARAMETER_TYPES ::=
3084 null
3085 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3086
3087 TYPE_DESIGNATOR ::=
3088 subtype_NAME
3089 | subtype_Name ' Access
3090
3091 MECHANISM ::=
3092 MECHANISM_NAME
3093 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3094
3095 MECHANISM_ASSOCIATION ::=
3096 [formal_parameter_NAME =>] MECHANISM_NAME
3097
3098 MECHANISM_NAME ::=
3099 Value
3100 | Reference
3101 | Descriptor [([Class =>] CLASS_NAME)]
3102 | Short_Descriptor [([Class =>] CLASS_NAME)]
3103
3104 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3105 @end smallexample
3106
3107 @noindent
3108 This pragma is used in conjunction with a pragma @code{Import} to
3109 specify additional information for an imported function. The pragma
3110 @code{Import} (or equivalent pragma @code{Interface}) must precede the
3111 @code{Import_Function} pragma and both must appear in the same
3112 declarative part as the function specification.
3113
3114 The @var{Internal} argument must uniquely designate
3115 the function to which the
3116 pragma applies. If more than one function name exists of this name in
3117 the declarative part you must use the @code{Parameter_Types} and
3118 @var{Result_Type} parameters to achieve the required unique
3119 designation. Subtype marks in these parameters must exactly match the
3120 subtypes in the corresponding function specification, using positional
3121 notation to match parameters with subtype marks.
3122 The form with an @code{'Access} attribute can be used to match an
3123 anonymous access parameter.
3124
3125 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
3126 parameters to specify passing mechanisms for the
3127 parameters and result. If you specify a single mechanism name, it
3128 applies to all parameters. Otherwise you may specify a mechanism on a
3129 parameter by parameter basis using either positional or named
3130 notation. If the mechanism is not specified, the default mechanism
3131 is used.
3132
3133 @cindex OpenVMS
3134 @cindex Passing by descriptor
3135 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
3136 The default behavior for Import_Function is to pass a 64bit descriptor
3137 unless short_descriptor is specified, then a 32bit descriptor is passed.
3138
3139 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
3140 It specifies that the designated parameter and all following parameters
3141 are optional, meaning that they are not passed at the generated code
3142 level (this is distinct from the notion of optional parameters in Ada
3143 where the parameters are passed anyway with the designated optional
3144 parameters). All optional parameters must be of mode @code{IN} and have
3145 default parameter values that are either known at compile time
3146 expressions, or uses of the @code{'Null_Parameter} attribute.
3147
3148 @node Pragma Import_Object
3149 @unnumberedsec Pragma Import_Object
3150 @findex Import_Object
3151 @noindent
3152 Syntax:
3153
3154 @smallexample @c ada
3155 pragma Import_Object
3156 [Internal =>] LOCAL_NAME
3157 [, [External =>] EXTERNAL_SYMBOL]
3158 [, [Size =>] EXTERNAL_SYMBOL]);
3159
3160 EXTERNAL_SYMBOL ::=
3161 IDENTIFIER
3162 | static_string_EXPRESSION
3163 @end smallexample
3164
3165 @noindent
3166 This pragma designates an object as imported, and apart from the
3167 extended rules for external symbols, is identical in effect to the use of
3168 the normal @code{Import} pragma applied to an object. Unlike the
3169 subprogram case, you need not use a separate @code{Import} pragma,
3170 although you may do so (and probably should do so from a portability
3171 point of view). @var{size} is syntax checked, but otherwise ignored by
3172 GNAT@.
3173
3174 @node Pragma Import_Procedure
3175 @unnumberedsec Pragma Import_Procedure
3176 @findex Import_Procedure
3177 @noindent
3178 Syntax:
3179
3180 @smallexample @c ada
3181 pragma Import_Procedure (
3182 [Internal =>] LOCAL_NAME
3183 [, [External =>] EXTERNAL_SYMBOL]
3184 [, [Parameter_Types =>] PARAMETER_TYPES]
3185 [, [Mechanism =>] MECHANISM]
3186 [, [First_Optional_Parameter =>] IDENTIFIER]);
3187
3188 EXTERNAL_SYMBOL ::=
3189 IDENTIFIER
3190 | static_string_EXPRESSION
3191
3192 PARAMETER_TYPES ::=
3193 null
3194 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3195
3196 TYPE_DESIGNATOR ::=
3197 subtype_NAME
3198 | subtype_Name ' Access
3199
3200 MECHANISM ::=
3201 MECHANISM_NAME
3202 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3203
3204 MECHANISM_ASSOCIATION ::=
3205 [formal_parameter_NAME =>] MECHANISM_NAME
3206
3207 MECHANISM_NAME ::=
3208 Value
3209 | Reference
3210 | Descriptor [([Class =>] CLASS_NAME)]
3211 | Short_Descriptor [([Class =>] CLASS_NAME)]
3212
3213 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3214 @end smallexample
3215
3216 @noindent
3217 This pragma is identical to @code{Import_Function} except that it
3218 applies to a procedure rather than a function and the parameters
3219 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
3220
3221 @node Pragma Import_Valued_Procedure
3222 @unnumberedsec Pragma Import_Valued_Procedure
3223 @findex Import_Valued_Procedure
3224 @noindent
3225 Syntax:
3226
3227 @smallexample @c ada
3228 pragma Import_Valued_Procedure (
3229 [Internal =>] LOCAL_NAME
3230 [, [External =>] EXTERNAL_SYMBOL]
3231 [, [Parameter_Types =>] PARAMETER_TYPES]
3232 [, [Mechanism =>] MECHANISM]
3233 [, [First_Optional_Parameter =>] IDENTIFIER]);
3234
3235 EXTERNAL_SYMBOL ::=
3236 IDENTIFIER
3237 | static_string_EXPRESSION
3238
3239 PARAMETER_TYPES ::=
3240 null
3241 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
3242
3243 TYPE_DESIGNATOR ::=
3244 subtype_NAME
3245 | subtype_Name ' Access
3246
3247 MECHANISM ::=
3248 MECHANISM_NAME
3249 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
3250
3251 MECHANISM_ASSOCIATION ::=
3252 [formal_parameter_NAME =>] MECHANISM_NAME
3253
3254 MECHANISM_NAME ::=
3255 Value
3256 | Reference
3257 | Descriptor [([Class =>] CLASS_NAME)]
3258 | Short_Descriptor [([Class =>] CLASS_NAME)]
3259
3260 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
3261 @end smallexample
3262
3263 @noindent
3264 This pragma is identical to @code{Import_Procedure} except that the
3265 first parameter of @var{LOCAL_NAME}, which must be present, must be of
3266 mode @code{OUT}, and externally the subprogram is treated as a function
3267 with this parameter as the result of the function. The purpose of this
3268 capability is to allow the use of @code{OUT} and @code{IN OUT}
3269 parameters in interfacing to external functions (which are not permitted
3270 in Ada functions). You may optionally use the @code{Mechanism}
3271 parameters to specify passing mechanisms for the parameters.
3272 If you specify a single mechanism name, it applies to all parameters.
3273 Otherwise you may specify a mechanism on a parameter by parameter
3274 basis using either positional or named notation. If the mechanism is not
3275 specified, the default mechanism is used.
3276
3277 Note that it is important to use this pragma in conjunction with a separate
3278 pragma Import that specifies the desired convention, since otherwise the
3279 default convention is Ada, which is almost certainly not what is required.
3280
3281 @node Pragma Independent
3282 @unnumberedsec Pragma Independent
3283 @findex Independent
3284 @noindent
3285 Syntax:
3286
3287 @smallexample @c ada
3288 pragma Independent (Local_NAME);
3289 @end smallexample
3290
3291 @noindent
3292 This pragma is standard in Ada 2012 mode (which also provides an aspect
3293 of the same name). It is also available as an implementation-defined
3294 pragma in all earlier versions. It specifies that the
3295 designated object or all objects of the designated type must be
3296 independently addressable. This means that separate tasks can safely
3297 manipulate such objects. For example, if two components of a record are
3298 independent, then two separate tasks may access these two components.
3299 This may place
3300 constraints on the representation of the object (for instance prohibiting
3301 tight packing).
3302
3303 @node Pragma Independent_Components
3304 @unnumberedsec Pragma Independent_Components
3305 @findex Independent_Components
3306 @noindent
3307 Syntax:
3308
3309 @smallexample @c ada
3310 pragma Independent_Components (Local_NAME);
3311 @end smallexample
3312
3313 @noindent
3314 This pragma is standard in Ada 2012 mode (which also provides an aspect
3315 of the same name). It is also available as an implementation-defined
3316 pragma in all earlier versions. It specifies that the components of the
3317 designated object, or the components of each object of the designated
3318 type, must be
3319 independently addressable. This means that separate tasks can safely
3320 manipulate separate components in the composite object. This may place
3321 constraints on the representation of the object (for instance prohibiting
3322 tight packing).
3323
3324 @node Pragma Initialize_Scalars
3325 @unnumberedsec Pragma Initialize_Scalars
3326 @findex Initialize_Scalars
3327 @cindex debugging with Initialize_Scalars
3328 @noindent
3329 Syntax:
3330
3331 @smallexample @c ada
3332 pragma Initialize_Scalars;
3333 @end smallexample
3334
3335 @noindent
3336 This pragma is similar to @code{Normalize_Scalars} conceptually but has
3337 two important differences. First, there is no requirement for the pragma
3338 to be used uniformly in all units of a partition, in particular, it is fine
3339 to use this just for some or all of the application units of a partition,
3340 without needing to recompile the run-time library.
3341
3342 In the case where some units are compiled with the pragma, and some without,
3343 then a declaration of a variable where the type is defined in package
3344 Standard or is locally declared will always be subject to initialization,
3345 as will any declaration of a scalar variable. For composite variables,
3346 whether the variable is initialized may also depend on whether the package
3347 in which the type of the variable is declared is compiled with the pragma.
3348
3349 The other important difference is that you can control the value used
3350 for initializing scalar objects. At bind time, you can select several
3351 options for initialization. You can
3352 initialize with invalid values (similar to Normalize_Scalars, though for
3353 Initialize_Scalars it is not always possible to determine the invalid
3354 values in complex cases like signed component fields with non-standard
3355 sizes). You can also initialize with high or
3356 low values, or with a specified bit pattern. See the @value{EDITION}
3357 User's Guide for binder options for specifying these cases.
3358
3359 This means that you can compile a program, and then without having to
3360 recompile the program, you can run it with different values being used
3361 for initializing otherwise uninitialized values, to test if your program
3362 behavior depends on the choice. Of course the behavior should not change,
3363 and if it does, then most likely you have an erroneous reference to an
3364 uninitialized value.
3365
3366 It is even possible to change the value at execution time eliminating even
3367 the need to rebind with a different switch using an environment variable.
3368 See the @value{EDITION} User's Guide for details.
3369
3370 Note that pragma @code{Initialize_Scalars} is particularly useful in
3371 conjunction with the enhanced validity checking that is now provided
3372 in GNAT, which checks for invalid values under more conditions.
3373 Using this feature (see description of the @option{-gnatV} flag in the
3374 @value{EDITION} User's Guide) in conjunction with
3375 pragma @code{Initialize_Scalars}
3376 provides a powerful new tool to assist in the detection of problems
3377 caused by uninitialized variables.
3378
3379 Note: the use of @code{Initialize_Scalars} has a fairly extensive
3380 effect on the generated code. This may cause your code to be
3381 substantially larger. It may also cause an increase in the amount
3382 of stack required, so it is probably a good idea to turn on stack
3383 checking (see description of stack checking in the @value{EDITION}
3384 User's Guide) when using this pragma.
3385
3386 @node Pragma Inline_Always
3387 @unnumberedsec Pragma Inline_Always
3388 @findex Inline_Always
3389 @noindent
3390 Syntax:
3391
3392 @smallexample @c ada
3393 pragma Inline_Always (NAME [, NAME]);
3394 @end smallexample
3395
3396 @noindent
3397 Similar to pragma @code{Inline} except that inlining is not subject to
3398 the use of option @option{-gnatn} or @option{-gnatN} and the inlining
3399 happens regardless of whether these options are used.
3400
3401 @node Pragma Inline_Generic
3402 @unnumberedsec Pragma Inline_Generic
3403 @findex Inline_Generic
3404 @noindent
3405 Syntax:
3406
3407 @smallexample @c ada
3408 pragma Inline_Generic (generic_package_NAME);
3409 @end smallexample
3410
3411 @noindent
3412 This is implemented for compatibility with DEC Ada 83 and is recognized,
3413 but otherwise ignored, by GNAT@. All generic instantiations are inlined
3414 by default when using GNAT@.
3415
3416 @node Pragma Interface
3417 @unnumberedsec Pragma Interface
3418 @findex Interface
3419 @noindent
3420 Syntax:
3421
3422 @smallexample @c ada
3423 pragma Interface (
3424 [Convention =>] convention_identifier,
3425 [Entity =>] local_NAME
3426 [, [External_Name =>] static_string_expression]
3427 [, [Link_Name =>] static_string_expression]);
3428 @end smallexample
3429
3430 @noindent
3431 This pragma is identical in syntax and semantics to
3432 the standard Ada pragma @code{Import}. It is provided for compatibility
3433 with Ada 83. The definition is upwards compatible both with pragma
3434 @code{Interface} as defined in the Ada 83 Reference Manual, and also
3435 with some extended implementations of this pragma in certain Ada 83
3436 implementations. The only difference between pragma @code{Interface}
3437 and pragma @code{Import} is that there is special circuitry to allow
3438 both pragmas to appear for the same subprogram entity (normally it
3439 is illegal to have multiple @code{Import} pragmas. This is useful in
3440 maintaining Ada 83/Ada 95 compatibility and is compatible with other
3441 Ada 83 compilers.
3442
3443 @node Pragma Interface_Name
3444 @unnumberedsec Pragma Interface_Name
3445 @findex Interface_Name
3446 @noindent
3447 Syntax:
3448
3449 @smallexample @c ada
3450 pragma Interface_Name (
3451 [Entity =>] LOCAL_NAME
3452 [, [External_Name =>] static_string_EXPRESSION]
3453 [, [Link_Name =>] static_string_EXPRESSION]);
3454 @end smallexample
3455
3456 @noindent
3457 This pragma provides an alternative way of specifying the interface name
3458 for an interfaced subprogram, and is provided for compatibility with Ada
3459 83 compilers that use the pragma for this purpose. You must provide at
3460 least one of @var{External_Name} or @var{Link_Name}.
3461
3462 @node Pragma Interrupt_Handler
3463 @unnumberedsec Pragma Interrupt_Handler
3464 @findex Interrupt_Handler
3465 @noindent
3466 Syntax:
3467
3468 @smallexample @c ada
3469 pragma Interrupt_Handler (procedure_LOCAL_NAME);
3470 @end smallexample
3471
3472 @noindent
3473 This program unit pragma is supported for parameterless protected procedures
3474 as described in Annex C of the Ada Reference Manual. On the AAMP target
3475 the pragma can also be specified for nonprotected parameterless procedures
3476 that are declared at the library level (which includes procedures
3477 declared at the top level of a library package). In the case of AAMP,
3478 when this pragma is applied to a nonprotected procedure, the instruction
3479 @code{IERET} is generated for returns from the procedure, enabling
3480 maskable interrupts, in place of the normal return instruction.
3481
3482 @node Pragma Interrupt_State
3483 @unnumberedsec Pragma Interrupt_State
3484 @findex Interrupt_State
3485 @noindent
3486 Syntax:
3487
3488 @smallexample @c ada
3489 pragma Interrupt_State
3490 ([Name =>] value,
3491 [State =>] SYSTEM | RUNTIME | USER);
3492 @end smallexample
3493
3494 @noindent
3495 Normally certain interrupts are reserved to the implementation. Any attempt
3496 to attach an interrupt causes Program_Error to be raised, as described in
3497 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
3498 many systems for an @kbd{Ctrl-C} interrupt. Normally this interrupt is
3499 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3500 interrupt execution. Additionally, signals such as @code{SIGSEGV},
3501 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3502 Ada exceptions, or used to implement run-time functions such as the
3503 @code{abort} statement and stack overflow checking.
3504
3505 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3506 such uses of interrupts. It subsumes the functionality of pragma
3507 @code{Unreserve_All_Interrupts}. Pragma @code{Interrupt_State} is not
3508 available on Windows or VMS. On all other platforms than VxWorks,
3509 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3510 and may be used to mark interrupts required by the board support package
3511 as reserved.
3512
3513 Interrupts can be in one of three states:
3514 @itemize @bullet
3515 @item System
3516
3517 The interrupt is reserved (no Ada handler can be installed), and the
3518 Ada run-time may not install a handler. As a result you are guaranteed
3519 standard system default action if this interrupt is raised.
3520
3521 @item Runtime
3522
3523 The interrupt is reserved (no Ada handler can be installed). The run time
3524 is allowed to install a handler for internal control purposes, but is
3525 not required to do so.
3526
3527 @item User
3528
3529 The interrupt is unreserved. The user may install a handler to provide
3530 some other action.
3531 @end itemize
3532
3533 @noindent
3534 These states are the allowed values of the @code{State} parameter of the
3535 pragma. The @code{Name} parameter is a value of the type
3536 @code{Ada.Interrupts.Interrupt_ID}. Typically, it is a name declared in
3537 @code{Ada.Interrupts.Names}.
3538
3539 This is a configuration pragma, and the binder will check that there
3540 are no inconsistencies between different units in a partition in how a
3541 given interrupt is specified. It may appear anywhere a pragma is legal.
3542
3543 The effect is to move the interrupt to the specified state.
3544
3545 By declaring interrupts to be SYSTEM, you guarantee the standard system
3546 action, such as a core dump.
3547
3548 By declaring interrupts to be USER, you guarantee that you can install
3549 a handler.
3550
3551 Note that certain signals on many operating systems cannot be caught and
3552 handled by applications. In such cases, the pragma is ignored. See the
3553 operating system documentation, or the value of the array @code{Reserved}
3554 declared in the spec of package @code{System.OS_Interface}.
3555
3556 Overriding the default state of signals used by the Ada runtime may interfere
3557 with an application's runtime behavior in the cases of the synchronous signals,
3558 and in the case of the signal used to implement the @code{abort} statement.
3559
3560 @node Pragma Invariant
3561 @unnumberedsec Pragma Invariant
3562 @findex Invariant
3563 @noindent
3564 Syntax:
3565
3566 @smallexample @c ada
3567 pragma Invariant
3568 ([Entity =>] private_type_LOCAL_NAME,
3569 [Check =>] EXPRESSION
3570 [,[Message =>] String_Expression]);
3571 @end smallexample
3572
3573 @noindent
3574 This pragma provides exactly the same capabilities as the Type_Invariant aspect
3575 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The
3576 Type_Invariant aspect is fully implemented in Ada 2012 mode, but since it
3577 requires the use of the aspect syntax, which is not available except in 2012
3578 mode, it is not possible to use the Type_Invariant aspect in earlier versions
3579 of Ada. However the Invariant pragma may be used in any version of Ada. Also
3580 note that the aspect Invariant is a synonym in GNAT for the aspect
3581 Type_Invariant, but there is no pragma Type_Invariant.
3582
3583 The pragma must appear within the visible part of the package specification,
3584 after the type to which its Entity argument appears. As with the Invariant
3585 aspect, the Check expression is not analyzed until the end of the visible
3586 part of the package, so it may contain forward references. The Message
3587 argument, if present, provides the exception message used if the invariant
3588 is violated. If no Message parameter is provided, a default message that
3589 identifies the line on which the pragma appears is used.
3590
3591 It is permissible to have multiple Invariants for the same type entity, in
3592 which case they are and'ed together. It is permissible to use this pragma
3593 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3594 invariant pragma for the same entity.
3595
3596 For further details on the use of this pragma, see the Ada 2012 documentation
3597 of the Type_Invariant aspect.
3598
3599 @node Pragma Keep_Names
3600 @unnumberedsec Pragma Keep_Names
3601 @findex Keep_Names
3602 @noindent
3603 Syntax:
3604
3605 @smallexample @c ada
3606 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3607 @end smallexample
3608
3609 @noindent
3610 The @var{LOCAL_NAME} argument
3611 must refer to an enumeration first subtype
3612 in the current declarative part. The effect is to retain the enumeration
3613 literal names for use by @code{Image} and @code{Value} even if a global
3614 @code{Discard_Names} pragma applies. This is useful when you want to
3615 generally suppress enumeration literal names and for example you therefore
3616 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3617 want to retain the names for specific enumeration types.
3618
3619 @node Pragma License
3620 @unnumberedsec Pragma License
3621 @findex License
3622 @cindex License checking
3623 @noindent
3624 Syntax:
3625
3626 @smallexample @c ada
3627 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3628 @end smallexample
3629
3630 @noindent
3631 This pragma is provided to allow automated checking for appropriate license
3632 conditions with respect to the standard and modified GPL@. A pragma
3633 @code{License}, which is a configuration pragma that typically appears at
3634 the start of a source file or in a separate @file{gnat.adc} file, specifies
3635 the licensing conditions of a unit as follows:
3636
3637 @itemize @bullet
3638 @item Unrestricted
3639 This is used for a unit that can be freely used with no license restrictions.
3640 Examples of such units are public domain units, and units from the Ada
3641 Reference Manual.
3642
3643 @item GPL
3644 This is used for a unit that is licensed under the unmodified GPL, and which
3645 therefore cannot be @code{with}'ed by a restricted unit.
3646
3647 @item Modified_GPL
3648 This is used for a unit licensed under the GNAT modified GPL that includes
3649 a special exception paragraph that specifically permits the inclusion of
3650 the unit in programs without requiring the entire program to be released
3651 under the GPL@.
3652
3653 @item Restricted
3654 This is used for a unit that is restricted in that it is not permitted to
3655 depend on units that are licensed under the GPL@. Typical examples are
3656 proprietary code that is to be released under more restrictive license
3657 conditions. Note that restricted units are permitted to @code{with} units
3658 which are licensed under the modified GPL (this is the whole point of the
3659 modified GPL).
3660
3661 @end itemize
3662
3663 @noindent
3664 Normally a unit with no @code{License} pragma is considered to have an
3665 unknown license, and no checking is done. However, standard GNAT headers
3666 are recognized, and license information is derived from them as follows.
3667
3668 @itemize @bullet
3669
3670 A GNAT license header starts with a line containing 78 hyphens. The following
3671 comment text is searched for the appearance of any of the following strings.
3672
3673 If the string ``GNU General Public License'' is found, then the unit is assumed
3674 to have GPL license, unless the string ``As a special exception'' follows, in
3675 which case the license is assumed to be modified GPL@.
3676
3677 If one of the strings
3678 ``This specification is adapted from the Ada Semantic Interface'' or
3679 ``This specification is derived from the Ada Reference Manual'' is found
3680 then the unit is assumed to be unrestricted.
3681 @end itemize
3682
3683 @noindent
3684 These default actions means that a program with a restricted license pragma
3685 will automatically get warnings if a GPL unit is inappropriately
3686 @code{with}'ed. For example, the program:
3687
3688 @smallexample @c ada
3689 with Sem_Ch3;
3690 with GNAT.Sockets;
3691 procedure Secret_Stuff is
3692 @dots{}
3693 end Secret_Stuff
3694 @end smallexample
3695
3696 @noindent
3697 if compiled with pragma @code{License} (@code{Restricted}) in a
3698 @file{gnat.adc} file will generate the warning:
3699
3700 @smallexample
3701 1. with Sem_Ch3;
3702 |
3703 >>> license of withed unit "Sem_Ch3" is incompatible
3704
3705 2. with GNAT.Sockets;
3706 3. procedure Secret_Stuff is
3707 @end smallexample
3708
3709 @noindent
3710 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3711 compiler and is licensed under the
3712 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3713 run time, and is therefore licensed under the modified GPL@.
3714
3715 @node Pragma Link_With
3716 @unnumberedsec Pragma Link_With
3717 @findex Link_With
3718 @noindent
3719 Syntax:
3720
3721 @smallexample @c ada
3722 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3723 @end smallexample
3724
3725 @noindent
3726 This pragma is provided for compatibility with certain Ada 83 compilers.
3727 It has exactly the same effect as pragma @code{Linker_Options} except
3728 that spaces occurring within one of the string expressions are treated
3729 as separators. For example, in the following case:
3730
3731 @smallexample @c ada
3732 pragma Link_With ("-labc -ldef");
3733 @end smallexample
3734
3735 @noindent
3736 results in passing the strings @code{-labc} and @code{-ldef} as two
3737 separate arguments to the linker. In addition pragma Link_With allows
3738 multiple arguments, with the same effect as successive pragmas.
3739
3740 @node Pragma Linker_Alias
3741 @unnumberedsec Pragma Linker_Alias
3742 @findex Linker_Alias
3743 @noindent
3744 Syntax:
3745
3746 @smallexample @c ada
3747 pragma Linker_Alias (
3748 [Entity =>] LOCAL_NAME,
3749 [Target =>] static_string_EXPRESSION);
3750 @end smallexample
3751
3752 @noindent
3753 @var{LOCAL_NAME} must refer to an object that is declared at the library
3754 level. This pragma establishes the given entity as a linker alias for the
3755 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3756 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3757 @var{static_string_EXPRESSION} in the object file, that is to say no space
3758 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3759 to the same address as @var{static_string_EXPRESSION} by the linker.
3760
3761 The actual linker name for the target must be used (e.g.@: the fully
3762 encoded name with qualification in Ada, or the mangled name in C++),
3763 or it must be declared using the C convention with @code{pragma Import}
3764 or @code{pragma Export}.
3765
3766 Not all target machines support this pragma. On some of them it is accepted
3767 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3768
3769 @smallexample @c ada
3770 -- Example of the use of pragma Linker_Alias
3771
3772 package p is
3773 i : Integer := 1;
3774 pragma Export (C, i);
3775
3776 new_name_for_i : Integer;
3777 pragma Linker_Alias (new_name_for_i, "i");
3778 end p;
3779 @end smallexample
3780
3781 @node Pragma Linker_Constructor
3782 @unnumberedsec Pragma Linker_Constructor
3783 @findex Linker_Constructor
3784 @noindent
3785 Syntax:
3786
3787 @smallexample @c ada
3788 pragma Linker_Constructor (procedure_LOCAL_NAME);
3789 @end smallexample
3790
3791 @noindent
3792 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3793 is declared at the library level. A procedure to which this pragma is
3794 applied will be treated as an initialization routine by the linker.
3795 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3796 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3797 of the executable is called (or immediately after the shared library is
3798 loaded if the procedure is linked in a shared library), in particular
3799 before the Ada run-time environment is set up.
3800
3801 Because of these specific contexts, the set of operations such a procedure
3802 can perform is very limited and the type of objects it can manipulate is
3803 essentially restricted to the elementary types. In particular, it must only
3804 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3805
3806 This pragma is used by GNAT to implement auto-initialization of shared Stand
3807 Alone Libraries, which provides a related capability without the restrictions
3808 listed above. Where possible, the use of Stand Alone Libraries is preferable
3809 to the use of this pragma.
3810
3811 @node Pragma Linker_Destructor
3812 @unnumberedsec Pragma Linker_Destructor
3813 @findex Linker_Destructor
3814 @noindent
3815 Syntax:
3816
3817 @smallexample @c ada
3818 pragma Linker_Destructor (procedure_LOCAL_NAME);
3819 @end smallexample
3820
3821 @noindent
3822 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3823 is declared at the library level. A procedure to which this pragma is
3824 applied will be treated as a finalization routine by the linker.
3825 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3826 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3827 of the executable has exited (or immediately before the shared library
3828 is unloaded if the procedure is linked in a shared library), in particular
3829 after the Ada run-time environment is shut down.
3830
3831 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3832 because of these specific contexts.
3833
3834 @node Pragma Linker_Section
3835 @unnumberedsec Pragma Linker_Section
3836 @findex Linker_Section
3837 @noindent
3838 Syntax:
3839
3840 @smallexample @c ada
3841 pragma Linker_Section (
3842 [Entity =>] LOCAL_NAME,
3843 [Section =>] static_string_EXPRESSION);
3844 @end smallexample
3845
3846 @noindent
3847 @var{LOCAL_NAME} must refer to an object that is declared at the library
3848 level. This pragma specifies the name of the linker section for the given
3849 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3850 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3851 section of the executable (assuming the linker doesn't rename the section).
3852
3853 The compiler normally places library-level objects in standard sections
3854 depending on their type: procedures and functions generally go in the
3855 @code{.text} section, initialized variables in the @code{.data} section
3856 and uninitialized variables in the @code{.bss} section.
3857
3858 Other, special sections may exist on given target machines to map special
3859 hardware, for example I/O ports or flash memory. This pragma is a means to
3860 defer the final layout of the executable to the linker, thus fully working
3861 at the symbolic level with the compiler.
3862
3863 Some file formats do not support arbitrary sections so not all target
3864 machines support this pragma. The use of this pragma may cause a program
3865 execution to be erroneous if it is used to place an entity into an
3866 inappropriate section (e.g.@: a modified variable into the @code{.text}
3867 section). See also @code{pragma Persistent_BSS}.
3868
3869 @smallexample @c ada
3870 -- Example of the use of pragma Linker_Section
3871
3872 package IO_Card is
3873 Port_A : Integer;
3874 pragma Volatile (Port_A);
3875 pragma Linker_Section (Port_A, ".bss.port_a");
3876
3877 Port_B : Integer;
3878 pragma Volatile (Port_B);
3879 pragma Linker_Section (Port_B, ".bss.port_b");
3880 end IO_Card;
3881 @end smallexample
3882
3883 @node Pragma Long_Float
3884 @unnumberedsec Pragma Long_Float
3885 @cindex OpenVMS
3886 @findex Long_Float
3887 @noindent
3888 Syntax:
3889
3890 @smallexample @c ada
3891 pragma Long_Float (FLOAT_FORMAT);
3892
3893 FLOAT_FORMAT ::= D_Float | G_Float
3894 @end smallexample
3895
3896 @noindent
3897 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3898 It allows control over the internal representation chosen for the predefined
3899 type @code{Long_Float} and for floating point type representations with
3900 @code{digits} specified in the range 7 through 15.
3901 For further details on this pragma, see the
3902 @cite{DEC Ada Language Reference Manual}, section 3.5.7b. Note that to use
3903 this pragma, the standard runtime libraries must be recompiled.
3904
3905 @node Pragma Loop_Optimize
3906 @unnumberedsec Pragma Loop_Optimize
3907 @findex Loop_Optimize
3908 @noindent
3909 Syntax:
3910
3911 @smallexample @c ada
3912 pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
3913
3914 OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
3915 @end smallexample
3916
3917 @noindent
3918 This pragma must appear immediately within a loop statement. It allows the
3919 programmer to specify optimization hints for the enclosing loop. The hints
3920 are not mutually exclusive and can be freely mixed, but not all combinations
3921 will yield a sensible outcome.
3922
3923 There are four supported optimization hints for a loop:
3924 @itemize @bullet
3925 @item No_Unroll
3926
3927 The loop must not be unrolled. This is a strong hint: the compiler will not
3928 unroll a loop marked with this hint.
3929
3930 @item Unroll
3931
3932 The loop should be unrolled. This is a weak hint: the compiler will try to
3933 apply unrolling to this loop preferably to other optimizations, notably
3934 vectorization, but there is no guarantee that the loop will be unrolled.
3935
3936 @item No_Vector
3937
3938 The loop must not be vectorized. This is a strong hint: the compiler will not
3939 vectorize a loop marked with this hint.
3940
3941 @item Vector
3942
3943 The loop should be vectorized. This is a weak hint: the compiler will try to
3944 apply vectorization to this loop preferably to other optimizations, notably
3945 unrolling, but there is no guarantee that the loop will be vectorized.
3946
3947 @end itemize
3948
3949 These hints do not void the need to pass the appropriate switches to the
3950 compiler in order to enable the relevant optimizations, that is to say
3951 @option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
3952 vectorization.
3953
3954 @node Pragma Machine_Attribute
3955 @unnumberedsec Pragma Machine_Attribute
3956 @findex Machine_Attribute
3957 @noindent
3958 Syntax:
3959
3960 @smallexample @c ada
3961 pragma Machine_Attribute (
3962 [Entity =>] LOCAL_NAME,
3963 [Attribute_Name =>] static_string_EXPRESSION
3964 [, [Info =>] static_EXPRESSION] );
3965 @end smallexample
3966
3967 @noindent
3968 Machine-dependent attributes can be specified for types and/or
3969 declarations. This pragma is semantically equivalent to
3970 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3971 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3972 in GNU C, where @code{@var{attribute_name}} is recognized by the
3973 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3974 specific macro. A string literal for the optional parameter @var{info}
3975 is transformed into an identifier, which may make this pragma unusable
3976 for some attributes. @xref{Target Attributes,, Defining target-specific
3977 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3978 Internals}, further information.
3979
3980 @node Pragma Main
3981 @unnumberedsec Pragma Main
3982 @cindex OpenVMS
3983 @findex Main
3984 @noindent
3985 Syntax:
3986
3987 @smallexample @c ada
3988 pragma Main
3989 (MAIN_OPTION [, MAIN_OPTION]);
3990
3991 MAIN_OPTION ::=
3992 [Stack_Size =>] static_integer_EXPRESSION
3993 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3994 | [Time_Slicing_Enabled =>] static_boolean_EXPRESSION
3995 @end smallexample
3996
3997 @noindent
3998 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
3999 no effect in GNAT, other than being syntax checked.
4000
4001 @node Pragma Main_Storage
4002 @unnumberedsec Pragma Main_Storage
4003 @cindex OpenVMS
4004 @findex Main_Storage
4005 @noindent
4006 Syntax:
4007
4008 @smallexample @c ada
4009 pragma Main_Storage
4010 (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
4011
4012 MAIN_STORAGE_OPTION ::=
4013 [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
4014 | [TOP_GUARD =>] static_SIMPLE_EXPRESSION
4015 @end smallexample
4016
4017 @noindent
4018 This pragma is provided for compatibility with OpenVMS VAX Systems. It has
4019 no effect in GNAT, other than being syntax checked. Note that the pragma
4020 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
4021
4022 @node Pragma No_Body
4023 @unnumberedsec Pragma No_Body
4024 @findex No_Body
4025 @noindent
4026 Syntax:
4027
4028 @smallexample @c ada
4029 pragma No_Body;
4030 @end smallexample
4031
4032 @noindent
4033 There are a number of cases in which a package spec does not require a body,
4034 and in fact a body is not permitted. GNAT will not permit the spec to be
4035 compiled if there is a body around. The pragma No_Body allows you to provide
4036 a body file, even in a case where no body is allowed. The body file must
4037 contain only comments and a single No_Body pragma. This is recognized by
4038 the compiler as indicating that no body is logically present.
4039
4040 This is particularly useful during maintenance when a package is modified in
4041 such a way that a body needed before is no longer needed. The provision of a
4042 dummy body with a No_Body pragma ensures that there is no interference from
4043 earlier versions of the package body.
4044
4045 @node Pragma No_Inline
4046 @unnumberedsec Pragma No_Inline
4047 @findex No_Inline
4048 @noindent
4049 Syntax:
4050
4051 @smallexample @c ada
4052 pragma No_Inline (NAME @{, NAME@});
4053 @end smallexample
4054
4055 @noindent
4056 This pragma suppresses inlining for the callable entity or the instances of
4057 the generic subprogram designated by @var{NAME}, including inlining that
4058 results from the use of pragma @code{Inline}. This pragma is always active,
4059 in particular it is not subject to the use of option @option{-gnatn} or
4060 @option{-gnatN}. It is illegal to specify both pragma @code{No_Inline} and
4061 pragma @code{Inline_Always} for the same @var{NAME}.
4062
4063 @node Pragma No_Return
4064 @unnumberedsec Pragma No_Return
4065 @findex No_Return
4066 @noindent
4067 Syntax:
4068
4069 @smallexample @c ada
4070 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
4071 @end smallexample
4072
4073 @noindent
4074 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
4075 declarations in the current declarative part. A procedure to which this
4076 pragma is applied may not contain any explicit @code{return} statements.
4077 In addition, if the procedure contains any implicit returns from falling
4078 off the end of a statement sequence, then execution of that implicit
4079 return will cause Program_Error to be raised.
4080
4081 One use of this pragma is to identify procedures whose only purpose is to raise
4082 an exception. Another use of this pragma is to suppress incorrect warnings
4083 about missing returns in functions, where the last statement of a function
4084 statement sequence is a call to such a procedure.
4085
4086 Note that in Ada 2005 mode, this pragma is part of the language. It is
4087 available in all earlier versions of Ada as an implementation-defined
4088 pragma.
4089
4090 @node Pragma No_Strict_Aliasing
4091 @unnumberedsec Pragma No_Strict_Aliasing
4092 @findex No_Strict_Aliasing
4093 @noindent
4094 Syntax:
4095
4096 @smallexample @c ada
4097 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
4098 @end smallexample
4099
4100 @noindent
4101 @var{type_LOCAL_NAME} must refer to an access type
4102 declaration in the current declarative part. The effect is to inhibit
4103 strict aliasing optimization for the given type. The form with no
4104 arguments is a configuration pragma which applies to all access types
4105 declared in units to which the pragma applies. For a detailed
4106 description of the strict aliasing optimization, and the situations
4107 in which it must be suppressed, see @ref{Optimization and Strict
4108 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4109
4110 This pragma currently has no effects on access to unconstrained array types.
4111
4112 @node Pragma Normalize_Scalars
4113 @unnumberedsec Pragma Normalize_Scalars
4114 @findex Normalize_Scalars
4115 @noindent
4116 Syntax:
4117
4118 @smallexample @c ada
4119 pragma Normalize_Scalars;
4120 @end smallexample
4121
4122 @noindent
4123 This is a language defined pragma which is fully implemented in GNAT@. The
4124 effect is to cause all scalar objects that are not otherwise initialized
4125 to be initialized. The initial values are implementation dependent and
4126 are as follows:
4127
4128 @table @code
4129 @item Standard.Character
4130 @noindent
4131 Objects whose root type is Standard.Character are initialized to
4132 Character'Last unless the subtype range excludes NUL (in which case
4133 NUL is used). This choice will always generate an invalid value if
4134 one exists.
4135
4136 @item Standard.Wide_Character
4137 @noindent
4138 Objects whose root type is Standard.Wide_Character are initialized to
4139 Wide_Character'Last unless the subtype range excludes NUL (in which case
4140 NUL is used). This choice will always generate an invalid value if
4141 one exists.
4142
4143 @item Standard.Wide_Wide_Character
4144 @noindent
4145 Objects whose root type is Standard.Wide_Wide_Character are initialized to
4146 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
4147 which case NUL is used). This choice will always generate an invalid value if
4148 one exists.
4149
4150 @item Integer types
4151 @noindent
4152 Objects of an integer type are treated differently depending on whether
4153 negative values are present in the subtype. If no negative values are
4154 present, then all one bits is used as the initial value except in the
4155 special case where zero is excluded from the subtype, in which case
4156 all zero bits are used. This choice will always generate an invalid
4157 value if one exists.
4158
4159 For subtypes with negative values present, the largest negative number
4160 is used, except in the unusual case where this largest negative number
4161 is in the subtype, and the largest positive number is not, in which case
4162 the largest positive value is used. This choice will always generate
4163 an invalid value if one exists.
4164
4165 @item Floating-Point Types
4166 Objects of all floating-point types are initialized to all 1-bits. For
4167 standard IEEE format, this corresponds to a NaN (not a number) which is
4168 indeed an invalid value.
4169
4170 @item Fixed-Point Types
4171 Objects of all fixed-point types are treated as described above for integers,
4172 with the rules applying to the underlying integer value used to represent
4173 the fixed-point value.
4174
4175 @item Modular types
4176 Objects of a modular type are initialized to all one bits, except in
4177 the special case where zero is excluded from the subtype, in which
4178 case all zero bits are used. This choice will always generate an
4179 invalid value if one exists.
4180
4181 @item Enumeration types
4182 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
4183 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
4184 whose Pos value is zero, in which case a code of zero is used. This choice
4185 will always generate an invalid value if one exists.
4186
4187 @end table
4188
4189 @node Pragma Obsolescent
4190 @unnumberedsec Pragma Obsolescent
4191 @findex Obsolescent
4192 @noindent
4193 Syntax:
4194
4195 @smallexample @c ada
4196 pragma Obsolescent;
4197
4198 pragma Obsolescent (
4199 [Message =>] static_string_EXPRESSION
4200 [,[Version =>] Ada_05]]);
4201
4202 pragma Obsolescent (
4203 [Entity =>] NAME
4204 [,[Message =>] static_string_EXPRESSION
4205 [,[Version =>] Ada_05]] );
4206 @end smallexample
4207
4208 @noindent
4209 This pragma can occur immediately following a declaration of an entity,
4210 including the case of a record component. If no Entity argument is present,
4211 then this declaration is the one to which the pragma applies. If an Entity
4212 parameter is present, it must either match the name of the entity in this
4213 declaration, or alternatively, the pragma can immediately follow an enumeration
4214 type declaration, where the Entity argument names one of the enumeration
4215 literals.
4216
4217 This pragma is used to indicate that the named entity
4218 is considered obsolescent and should not be used. Typically this is
4219 used when an API must be modified by eventually removing or modifying
4220 existing subprograms or other entities. The pragma can be used at an
4221 intermediate stage when the entity is still present, but will be
4222 removed later.
4223
4224 The effect of this pragma is to output a warning message on a reference to
4225 an entity thus marked that the subprogram is obsolescent if the appropriate
4226 warning option in the compiler is activated. If the Message parameter is
4227 present, then a second warning message is given containing this text. In
4228 addition, a reference to the entity is considered to be a violation of pragma
4229 Restrictions (No_Obsolescent_Features).
4230
4231 This pragma can also be used as a program unit pragma for a package,
4232 in which case the entity name is the name of the package, and the
4233 pragma indicates that the entire package is considered
4234 obsolescent. In this case a client @code{with}'ing such a package
4235 violates the restriction, and the @code{with} statement is
4236 flagged with warnings if the warning option is set.
4237
4238 If the Version parameter is present (which must be exactly
4239 the identifier Ada_05, no other argument is allowed), then the
4240 indication of obsolescence applies only when compiling in Ada 2005
4241 mode. This is primarily intended for dealing with the situations
4242 in the predefined library where subprograms or packages
4243 have become defined as obsolescent in Ada 2005
4244 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
4245
4246 The following examples show typical uses of this pragma:
4247
4248 @smallexample @c ada
4249 package p is
4250 pragma Obsolescent (p, Message => "use pp instead of p");
4251 end p;
4252
4253 package q is
4254 procedure q2;
4255 pragma Obsolescent ("use q2new instead");
4256
4257 type R is new integer;
4258 pragma Obsolescent
4259 (Entity => R,
4260 Message => "use RR in Ada 2005",
4261 Version => Ada_05);
4262
4263 type M is record
4264 F1 : Integer;
4265 F2 : Integer;
4266 pragma Obsolescent;
4267 F3 : Integer;
4268 end record;
4269
4270 type E is (a, bc, 'd', quack);
4271 pragma Obsolescent (Entity => bc)
4272 pragma Obsolescent (Entity => 'd')
4273
4274 function "+"
4275 (a, b : character) return character;
4276 pragma Obsolescent (Entity => "+");
4277 end;
4278 @end smallexample
4279
4280 @noindent
4281 Note that, as for all pragmas, if you use a pragma argument identifier,
4282 then all subsequent parameters must also use a pragma argument identifier.
4283 So if you specify "Entity =>" for the Entity argument, and a Message
4284 argument is present, it must be preceded by "Message =>".
4285
4286 @node Pragma Optimize_Alignment
4287 @unnumberedsec Pragma Optimize_Alignment
4288 @findex Optimize_Alignment
4289 @cindex Alignment, default settings
4290 @noindent
4291 Syntax:
4292
4293 @smallexample @c ada
4294 pragma Optimize_Alignment (TIME | SPACE | OFF);
4295 @end smallexample
4296
4297 @noindent
4298 This is a configuration pragma which affects the choice of default alignments
4299 for types where no alignment is explicitly specified. There is a time/space
4300 trade-off in the selection of these values. Large alignments result in more
4301 efficient code, at the expense of larger data space, since sizes have to be
4302 increased to match these alignments. Smaller alignments save space, but the
4303 access code is slower. The normal choice of default alignments (which is what
4304 you get if you do not use this pragma, or if you use an argument of OFF),
4305 tries to balance these two requirements.
4306
4307 Specifying SPACE causes smaller default alignments to be chosen in two cases.
4308 First any packed record is given an alignment of 1. Second, if a size is given
4309 for the type, then the alignment is chosen to avoid increasing this size. For
4310 example, consider:
4311
4312 @smallexample @c ada
4313 type R is record
4314 X : Integer;
4315 Y : Character;
4316 end record;
4317
4318 for R'Size use 5*8;
4319 @end smallexample
4320
4321 @noindent
4322 In the default mode, this type gets an alignment of 4, so that access to the
4323 Integer field X are efficient. But this means that objects of the type end up
4324 with a size of 8 bytes. This is a valid choice, since sizes of objects are
4325 allowed to be bigger than the size of the type, but it can waste space if for
4326 example fields of type R appear in an enclosing record. If the above type is
4327 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
4328
4329 However, there is one case in which SPACE is ignored. If a variable length
4330 record (that is a discriminated record with a component which is an array
4331 whose length depends on a discriminant), has a pragma Pack, then it is not
4332 in general possible to set the alignment of such a record to one, so the
4333 pragma is ignored in this case (with a warning).
4334
4335 Specifying TIME causes larger default alignments to be chosen in the case of
4336 small types with sizes that are not a power of 2. For example, consider:
4337
4338 @smallexample @c ada
4339 type R is record
4340 A : Character;
4341 B : Character;
4342 C : Boolean;
4343 end record;
4344
4345 pragma Pack (R);
4346 for R'Size use 17;
4347 @end smallexample
4348
4349 @noindent
4350 The default alignment for this record is normally 1, but if this type is
4351 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
4352 to 4, which wastes space for objects of the type, since they are now 4 bytes
4353 long, but results in more efficient access when the whole record is referenced.
4354
4355 As noted above, this is a configuration pragma, and there is a requirement
4356 that all units in a partition be compiled with a consistent setting of the
4357 optimization setting. This would normally be achieved by use of a configuration
4358 pragma file containing the appropriate setting. The exception to this rule is
4359 that units with an explicit configuration pragma in the same file as the source
4360 unit are excluded from the consistency check, as are all predefined units. The
4361 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
4362 pragma appears at the start of the file.
4363
4364 @node Pragma Ordered
4365 @unnumberedsec Pragma Ordered
4366 @findex Ordered
4367 @findex pragma @code{Ordered}
4368 @noindent
4369 Syntax:
4370
4371 @smallexample @c ada
4372 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
4373 @end smallexample
4374
4375 @noindent
4376 Most enumeration types are from a conceptual point of view unordered.
4377 For example, consider:
4378
4379 @smallexample @c ada
4380 type Color is (Red, Blue, Green, Yellow);
4381 @end smallexample
4382
4383 @noindent
4384 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
4385 but really these relations make no sense; the enumeration type merely
4386 specifies a set of possible colors, and the order is unimportant.
4387
4388 For unordered enumeration types, it is generally a good idea if
4389 clients avoid comparisons (other than equality or inequality) and
4390 explicit ranges. (A @emph{client} is a unit where the type is referenced,
4391 other than the unit where the type is declared, its body, and its subunits.)
4392 For example, if code buried in some client says:
4393
4394 @smallexample @c ada
4395 if Current_Color < Yellow then ...
4396 if Current_Color in Blue .. Green then ...
4397 @end smallexample
4398
4399 @noindent
4400 then the client code is relying on the order, which is undesirable.
4401 It makes the code hard to read and creates maintenance difficulties if
4402 entries have to be added to the enumeration type. Instead,
4403 the code in the client should list the possibilities, or an
4404 appropriate subtype should be declared in the unit that declares
4405 the original enumeration type. E.g., the following subtype could
4406 be declared along with the type @code{Color}:
4407
4408 @smallexample @c ada
4409 subtype RBG is Color range Red .. Green;
4410 @end smallexample
4411
4412 @noindent
4413 and then the client could write:
4414
4415 @smallexample @c ada
4416 if Current_Color in RBG then ...
4417 if Current_Color = Blue or Current_Color = Green then ...
4418 @end smallexample
4419
4420 @noindent
4421 However, some enumeration types are legitimately ordered from a conceptual
4422 point of view. For example, if you declare:
4423
4424 @smallexample @c ada
4425 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
4426 @end smallexample
4427
4428 @noindent
4429 then the ordering imposed by the language is reasonable, and
4430 clients can depend on it, writing for example:
4431
4432 @smallexample @c ada
4433 if D in Mon .. Fri then ...
4434 if D < Wed then ...
4435 @end smallexample
4436
4437 @noindent
4438 The pragma @option{Ordered} is provided to mark enumeration types that
4439 are conceptually ordered, alerting the reader that clients may depend
4440 on the ordering. GNAT provides a pragma to mark enumerations as ordered
4441 rather than one to mark them as unordered, since in our experience,
4442 the great majority of enumeration types are conceptually unordered.
4443
4444 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
4445 and @code{Wide_Wide_Character}
4446 are considered to be ordered types, so each is declared with a
4447 pragma @code{Ordered} in package @code{Standard}.
4448
4449 Normally pragma @code{Ordered} serves only as documentation and a guide for
4450 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
4451 requests warnings for inappropriate uses (comparisons and explicit
4452 subranges) for unordered types. If this switch is used, then any
4453 enumeration type not marked with pragma @code{Ordered} will be considered
4454 as unordered, and will generate warnings for inappropriate uses.
4455
4456 For additional information please refer to the description of the
4457 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
4458
4459 @node Pragma Overflow_Mode
4460 @unnumberedsec Pragma Overflow_Mode
4461 @findex Overflow checks
4462 @findex Overflow mode
4463 @findex pragma @code{Overflow_Mode}
4464 @noindent
4465 Syntax:
4466
4467 @smallexample @c ada
4468 pragma Overflow_Mode
4469 ( [General =>] MODE
4470 [,[Assertions =>] MODE]);
4471
4472 MODE ::= STRICT | MINIMIZED | ELIMINATED
4473 @end smallexample
4474
4475 @noindent
4476 This pragma sets the current overflow mode to the given setting. For details
4477 of the meaning of these modes, please refer to the
4478 ``Overflow Check Handling in GNAT'' appendix in the
4479 @value{EDITION} User's Guide. If only the @code{General} parameter is present,
4480 the given mode applies to all expressions. If both parameters are present,
4481 the @code{General} mode applies to expressions outside assertions, and
4482 the @code{Eliminated} mode applies to expressions within assertions.
4483
4484 The case of the @code{MODE} parameter is ignored,
4485 so @code{MINIMIZED}, @code{Minimized} and
4486 @code{minimized} all have the same effect.
4487
4488 The @code{Overflow_Mode} pragma has the same scoping and placement
4489 rules as pragma @code{Suppress}, so it can occur either as a
4490 configuration pragma, specifying a default for the whole
4491 program, or in a declarative scope, where it applies to the
4492 remaining declarations and statements in that scope.
4493
4494 The pragma @code{Suppress (Overflow_Check)} suppresses
4495 overflow checking, but does not affect the overflow mode.
4496
4497 The pragma @code{Unsuppress (Overflow_Check)} unsuppresses (enables)
4498 overflow checking, but does not affect the overflow mode.
4499
4500 @node Pragma Partition_Elaboration_Policy
4501 @unnumberedsec Pragma Partition_Elaboration_Policy
4502 @findex Partition_Elaboration_Policy
4503 @noindent
4504 Syntax:
4505
4506 @smallexample @c ada
4507 pragma Partition_Elaboration_Policy (POLICY_IDENTIFIER);
4508
4509 POLICY_IDENTIFIER ::= Concurrent | Sequential
4510 @end smallexample
4511
4512 @noindent
4513 This pragma is standard in Ada 2005, but is available in all earlier
4514 versions of Ada as an implementation-defined pragma.
4515 See Ada 2012 Reference Manual for details.
4516
4517 @node Pragma Passive
4518 @unnumberedsec Pragma Passive
4519 @findex Passive
4520 @noindent
4521 Syntax:
4522
4523 @smallexample @c ada
4524 pragma Passive [(Semaphore | No)];
4525 @end smallexample
4526
4527 @noindent
4528 Syntax checked, but otherwise ignored by GNAT@. This is recognized for
4529 compatibility with DEC Ada 83 implementations, where it is used within a
4530 task definition to request that a task be made passive. If the argument
4531 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
4532 treats the pragma as an assertion that the containing task is passive
4533 and that optimization of context switch with this task is permitted and
4534 desired. If the argument @code{No} is present, the task must not be
4535 optimized. GNAT does not attempt to optimize any tasks in this manner
4536 (since protected objects are available in place of passive tasks).
4537
4538 @node Pragma Persistent_BSS
4539 @unnumberedsec Pragma Persistent_BSS
4540 @findex Persistent_BSS
4541 @noindent
4542 Syntax:
4543
4544 @smallexample @c ada
4545 pragma Persistent_BSS [(LOCAL_NAME)]
4546 @end smallexample
4547
4548 @noindent
4549 This pragma allows selected objects to be placed in the @code{.persistent_bss}
4550 section. On some targets the linker and loader provide for special
4551 treatment of this section, allowing a program to be reloaded without
4552 affecting the contents of this data (hence the name persistent).
4553
4554 There are two forms of usage. If an argument is given, it must be the
4555 local name of a library level object, with no explicit initialization
4556 and whose type is potentially persistent. If no argument is given, then
4557 the pragma is a configuration pragma, and applies to all library level
4558 objects with no explicit initialization of potentially persistent types.
4559
4560 A potentially persistent type is a scalar type, or a non-tagged,
4561 non-discriminated record, all of whose components have no explicit
4562 initialization and are themselves of a potentially persistent type,
4563 or an array, all of whose constraints are static, and whose component
4564 type is potentially persistent.
4565
4566 If this pragma is used on a target where this feature is not supported,
4567 then the pragma will be ignored. See also @code{pragma Linker_Section}.
4568
4569 @node Pragma Polling
4570 @unnumberedsec Pragma Polling
4571 @findex Polling
4572 @noindent
4573 Syntax:
4574
4575 @smallexample @c ada
4576 pragma Polling (ON | OFF);
4577 @end smallexample
4578
4579 @noindent
4580 This pragma controls the generation of polling code. This is normally off.
4581 If @code{pragma Polling (ON)} is used then periodic calls are generated to
4582 the routine @code{Ada.Exceptions.Poll}. This routine is a separate unit in the
4583 runtime library, and can be found in file @file{a-excpol.adb}.
4584
4585 Pragma @code{Polling} can appear as a configuration pragma (for example it
4586 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
4587 can be used in the statement or declaration sequence to control polling
4588 more locally.
4589
4590 A call to the polling routine is generated at the start of every loop and
4591 at the start of every subprogram call. This guarantees that the @code{Poll}
4592 routine is called frequently, and places an upper bound (determined by
4593 the complexity of the code) on the period between two @code{Poll} calls.
4594
4595 The primary purpose of the polling interface is to enable asynchronous
4596 aborts on targets that cannot otherwise support it (for example Windows
4597 NT), but it may be used for any other purpose requiring periodic polling.
4598 The standard version is null, and can be replaced by a user program. This
4599 will require re-compilation of the @code{Ada.Exceptions} package that can
4600 be found in files @file{a-except.ads} and @file{a-except.adb}.
4601
4602 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
4603 distribution) is used to enable the asynchronous abort capability on
4604 targets that do not normally support the capability. The version of
4605 @code{Poll} in this file makes a call to the appropriate runtime routine
4606 to test for an abort condition.
4607
4608 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4609 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4610 details.
4611
4612 @node Pragma Postcondition
4613 @unnumberedsec Pragma Postcondition
4614 @cindex Postconditions
4615 @cindex Checks, postconditions
4616 @findex Postconditions
4617 @noindent
4618 Syntax:
4619
4620 @smallexample @c ada
4621 pragma Postcondition (
4622 [Check =>] Boolean_Expression
4623 [,[Message =>] String_Expression]);
4624 @end smallexample
4625
4626 @noindent
4627 The @code{Postcondition} pragma allows specification of automatic
4628 postcondition checks for subprograms. These checks are similar to
4629 assertions, but are automatically inserted just prior to the return
4630 statements of the subprogram with which they are associated (including
4631 implicit returns at the end of procedure bodies and associated
4632 exception handlers).
4633
4634 In addition, the boolean expression which is the condition which
4635 must be true may contain references to function'Result in the case
4636 of a function to refer to the returned value.
4637
4638 @code{Postcondition} pragmas may appear either immediately following the
4639 (separate) declaration of a subprogram, or at the start of the
4640 declarations of a subprogram body. Only other pragmas may intervene
4641 (that is appear between the subprogram declaration and its
4642 postconditions, or appear before the postcondition in the
4643 declaration sequence in a subprogram body). In the case of a
4644 postcondition appearing after a subprogram declaration, the
4645 formal arguments of the subprogram are visible, and can be
4646 referenced in the postcondition expressions.
4647
4648 The postconditions are collected and automatically tested just
4649 before any return (implicit or explicit) in the subprogram body.
4650 A postcondition is only recognized if postconditions are active
4651 at the time the pragma is encountered. The compiler switch @option{gnata}
4652 turns on all postconditions by default, and pragma @code{Check_Policy}
4653 with an identifier of @code{Postcondition} can also be used to
4654 control whether postconditions are active.
4655
4656 The general approach is that postconditions are placed in the spec
4657 if they represent functional aspects which make sense to the client.
4658 For example we might have:
4659
4660 @smallexample @c ada
4661 function Direction return Integer;
4662 pragma Postcondition
4663 (Direction'Result = +1
4664 or else
4665 Direction'Result = -1);
4666 @end smallexample
4667
4668 @noindent
4669 which serves to document that the result must be +1 or -1, and
4670 will test that this is the case at run time if postcondition
4671 checking is active.
4672
4673 Postconditions within the subprogram body can be used to
4674 check that some internal aspect of the implementation,
4675 not visible to the client, is operating as expected.
4676 For instance if a square root routine keeps an internal
4677 counter of the number of times it is called, then we
4678 might have the following postcondition:
4679
4680 @smallexample @c ada
4681 Sqrt_Calls : Natural := 0;
4682
4683 function Sqrt (Arg : Float) return Float is
4684 pragma Postcondition
4685 (Sqrt_Calls = Sqrt_Calls'Old + 1);
4686 ...
4687 end Sqrt
4688 @end smallexample
4689
4690 @noindent
4691 As this example, shows, the use of the @code{Old} attribute
4692 is often useful in postconditions to refer to the state on
4693 entry to the subprogram.
4694
4695 Note that postconditions are only checked on normal returns
4696 from the subprogram. If an abnormal return results from
4697 raising an exception, then the postconditions are not checked.
4698
4699 If a postcondition fails, then the exception
4700 @code{System.Assertions.Assert_Failure} is raised. If
4701 a message argument was supplied, then the given string
4702 will be used as the exception message. If no message
4703 argument was supplied, then the default message has
4704 the form "Postcondition failed at file:line". The
4705 exception is raised in the context of the subprogram
4706 body, so it is possible to catch postcondition failures
4707 within the subprogram body itself.
4708
4709 Within a package spec, normal visibility rules
4710 in Ada would prevent forward references within a
4711 postcondition pragma to functions defined later in
4712 the same package. This would introduce undesirable
4713 ordering constraints. To avoid this problem, all
4714 postcondition pragmas are analyzed at the end of
4715 the package spec, allowing forward references.
4716
4717 The following example shows that this even allows
4718 mutually recursive postconditions as in:
4719
4720 @smallexample @c ada
4721 package Parity_Functions is
4722 function Odd (X : Natural) return Boolean;
4723 pragma Postcondition
4724 (Odd'Result =
4725 (x = 1
4726 or else
4727 (x /= 0 and then Even (X - 1))));
4728
4729 function Even (X : Natural) return Boolean;
4730 pragma Postcondition
4731 (Even'Result =
4732 (x = 0
4733 or else
4734 (x /= 1 and then Odd (X - 1))));
4735
4736 end Parity_Functions;
4737 @end smallexample
4738
4739 @noindent
4740 There are no restrictions on the complexity or form of
4741 conditions used within @code{Postcondition} pragmas.
4742 The following example shows that it is even possible
4743 to verify performance behavior.
4744
4745 @smallexample @c ada
4746 package Sort is
4747
4748 Performance : constant Float;
4749 -- Performance constant set by implementation
4750 -- to match target architecture behavior.
4751
4752 procedure Treesort (Arg : String);
4753 -- Sorts characters of argument using N*logN sort
4754 pragma Postcondition
4755 (Float (Clock - Clock'Old) <=
4756 Float (Arg'Length) *
4757 log (Float (Arg'Length)) *
4758 Performance);
4759 end Sort;
4760 @end smallexample
4761
4762 @noindent
4763 Note: postcondition pragmas associated with subprograms that are
4764 marked as Inline_Always, or those marked as Inline with front-end
4765 inlining (-gnatN option set) are accepted and legality-checked
4766 by the compiler, but are ignored at run-time even if postcondition
4767 checking is enabled.
4768
4769 @node Pragma Preelaborable_Initialization
4770 @unnumberedsec Pragma Preelaborable_Initialization
4771 @findex Preelaborable_Initialization
4772 @noindent
4773 Syntax:
4774
4775 @smallexample @c ada
4776 pragma Preelaborable_Initialization (DIRECT_NAME);
4777 @end smallexample
4778
4779 @noindent
4780 This pragma is standard in Ada 2005, but is available in all earlier
4781 versions of Ada as an implementation-defined pragma.
4782 See Ada 2012 Reference Manual for details.
4783
4784 @node Pragma Priority_Specific_Dispatching
4785 @unnumberedsec Pragma Priority_Specific_Dispatching
4786 @findex Priority_Specific_Dispatching
4787 @noindent
4788 Syntax:
4789
4790 @smallexample @c ada
4791 pragma Priority_Specific_Dispatching (
4792 POLICY_IDENTIFIER,
4793 first_priority_EXPRESSION,
4794 last_priority_EXPRESSION)
4795
4796 POLICY_IDENTIFIER ::=
4797 EDF_Across_Priorities |
4798 FIFO_Within_Priorities |
4799 Non_Preemptive_Within_Priorities |
4800 Round_Robin_Within_Priorities
4801 @end smallexample
4802
4803 @noindent
4804 This pragma is standard in Ada 2005, but is available in all earlier
4805 versions of Ada as an implementation-defined pragma.
4806 See Ada 2012 Reference Manual for details.
4807
4808 @node Pragma Precondition
4809 @unnumberedsec Pragma Precondition
4810 @cindex Preconditions
4811 @cindex Checks, preconditions
4812 @findex Preconditions
4813 @noindent
4814 Syntax:
4815
4816 @smallexample @c ada
4817 pragma Precondition (
4818 [Check =>] Boolean_Expression
4819 [,[Message =>] String_Expression]);
4820 @end smallexample
4821
4822 @noindent
4823 The @code{Precondition} pragma is similar to @code{Postcondition}
4824 except that the corresponding checks take place immediately upon
4825 entry to the subprogram, and if a precondition fails, the exception
4826 is raised in the context of the caller, and the attribute 'Result
4827 cannot be used within the precondition expression.
4828
4829 Otherwise, the placement and visibility rules are identical to those
4830 described for postconditions. The following is an example of use
4831 within a package spec:
4832
4833 @smallexample @c ada
4834 package Math_Functions is
4835 ...
4836 function Sqrt (Arg : Float) return Float;
4837 pragma Precondition (Arg >= 0.0)
4838 ...
4839 end Math_Functions;
4840 @end smallexample
4841
4842 @noindent
4843 @code{Precondition} pragmas may appear either immediately following the
4844 (separate) declaration of a subprogram, or at the start of the
4845 declarations of a subprogram body. Only other pragmas may intervene
4846 (that is appear between the subprogram declaration and its
4847 postconditions, or appear before the postcondition in the
4848 declaration sequence in a subprogram body).
4849
4850 Note: postcondition pragmas associated with subprograms that are
4851 marked as Inline_Always, or those marked as Inline with front-end
4852 inlining (-gnatN option set) are accepted and legality-checked
4853 by the compiler, but are ignored at run-time even if postcondition
4854 checking is enabled.
4855
4856 @node Pragma Profile (Ravenscar)
4857 @unnumberedsec Pragma Profile (Ravenscar)
4858 @findex Ravenscar
4859 @noindent
4860 Syntax:
4861
4862 @smallexample @c ada
4863 pragma Profile (Ravenscar | Restricted);
4864 @end smallexample
4865
4866 @noindent
4867 This pragma is standard in Ada 2005, but is available in all earlier
4868 versions of Ada as an implementation-defined pragma. This is a
4869 configuration pragma that establishes the following set of configuration
4870 pragmas:
4871
4872 @table @code
4873 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4874 [RM D.2.2] Tasks are dispatched following a preemptive
4875 priority-ordered scheduling policy.
4876
4877 @item Locking_Policy (Ceiling_Locking)
4878 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4879 the ceiling priority of the corresponding protected object.
4880
4881 @item Detect_Blocking
4882 This pragma forces the detection of potentially blocking operations within a
4883 protected operation, and to raise Program_Error if that happens.
4884 @end table
4885 @noindent
4886
4887 plus the following set of restrictions:
4888
4889 @table @code
4890 @item Max_Entry_Queue_Length => 1
4891 No task can be queued on a protected entry.
4892 @item Max_Protected_Entries => 1
4893 @item Max_Task_Entries => 0
4894 No rendezvous statements are allowed.
4895 @item No_Abort_Statements
4896 @item No_Dynamic_Attachment
4897 @item No_Dynamic_Priorities
4898 @item No_Implicit_Heap_Allocations
4899 @item No_Local_Protected_Objects
4900 @item No_Local_Timing_Events
4901 @item No_Protected_Type_Allocators
4902 @item No_Relative_Delay
4903 @item No_Requeue_Statements
4904 @item No_Select_Statements
4905 @item No_Specific_Termination_Handlers
4906 @item No_Task_Allocators
4907 @item No_Task_Hierarchy
4908 @item No_Task_Termination
4909 @item Simple_Barriers
4910 @end table
4911 @noindent
4912
4913 The Ravenscar profile also includes the following restrictions that specify
4914 that there are no semantic dependences on the corresponding predefined
4915 packages:
4916
4917 @table @code
4918 @item No_Dependence => Ada.Asynchronous_Task_Control
4919 @item No_Dependence => Ada.Calendar
4920 @item No_Dependence => Ada.Execution_Time.Group_Budget
4921 @item No_Dependence => Ada.Execution_Time.Timers
4922 @item No_Dependence => Ada.Task_Attributes
4923 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4924 @end table
4925
4926 @noindent
4927
4928 This set of configuration pragmas and restrictions correspond to the
4929 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4930 published by the @cite{International Real-Time Ada Workshop}, 1997,
4931 and whose most recent description is available at
4932 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4933
4934 The original definition of the profile was revised at subsequent IRTAW
4935 meetings. It has been included in the ISO
4936 @cite{Guide for the Use of the Ada Programming Language in High
4937 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4938 the next revision of the standard. The formal definition given by
4939 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4940 AI-305) available at
4941 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4942 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4943
4944 The above set is a superset of the restrictions provided by pragma
4945 @code{Profile (Restricted)}, it includes six additional restrictions
4946 (@code{Simple_Barriers}, @code{No_Select_Statements},
4947 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4948 @code{No_Relative_Delay} and @code{No_Task_Termination}). This means
4949 that pragma @code{Profile (Ravenscar)}, like the pragma
4950 @code{Profile (Restricted)},
4951 automatically causes the use of a simplified,
4952 more efficient version of the tasking run-time system.
4953
4954 @node Pragma Profile (Restricted)
4955 @unnumberedsec Pragma Profile (Restricted)
4956 @findex Restricted Run Time
4957 @noindent
4958 Syntax:
4959
4960 @smallexample @c ada
4961 pragma Profile (Restricted);
4962 @end smallexample
4963
4964 @noindent
4965 This is an implementation-defined version of the standard pragma defined
4966 in Ada 2005. It is available in all versions of Ada. It is a
4967 configuration pragma that establishes the following set of restrictions:
4968
4969 @itemize @bullet
4970 @item No_Abort_Statements
4971 @item No_Entry_Queue
4972 @item No_Task_Hierarchy
4973 @item No_Task_Allocators
4974 @item No_Dynamic_Priorities
4975 @item No_Terminate_Alternatives
4976 @item No_Dynamic_Attachment
4977 @item No_Protected_Type_Allocators
4978 @item No_Local_Protected_Objects
4979 @item No_Requeue_Statements
4980 @item No_Task_Attributes_Package
4981 @item Max_Asynchronous_Select_Nesting = 0
4982 @item Max_Task_Entries = 0
4983 @item Max_Protected_Entries = 1
4984 @item Max_Select_Alternatives = 0
4985 @end itemize
4986
4987 @noindent
4988 This set of restrictions causes the automatic selection of a simplified
4989 version of the run time that provides improved performance for the
4990 limited set of tasking functionality permitted by this set of restrictions.
4991
4992 @node Pragma Profile (Rational)
4993 @unnumberedsec Pragma Profile (Rational)
4994 @findex Rational compatibility mode
4995 @noindent
4996 Syntax:
4997
4998 @smallexample @c ada
4999 pragma Profile (Rational);
5000 @end smallexample
5001
5002 @noindent
5003 The Rational profile is intended to facilitate porting legacy code that
5004 compiles with the Rational APEX compiler, even when the code includes non-
5005 conforming Ada constructs. The profile enables the following three pragmas:
5006
5007 @itemize @bullet
5008 pragma Implicit_Packing;
5009 pragma Overriding_Renamings;
5010 pragma Use_VADS_Size;
5011 @end itemize
5012
5013 @noindent
5014 @node Pragma Psect_Object
5015 @unnumberedsec Pragma Psect_Object
5016 @findex Psect_Object
5017 @noindent
5018 Syntax:
5019
5020 @smallexample @c ada
5021 pragma Psect_Object (
5022 [Internal =>] LOCAL_NAME,
5023 [, [External =>] EXTERNAL_SYMBOL]
5024 [, [Size =>] EXTERNAL_SYMBOL]);
5025
5026 EXTERNAL_SYMBOL ::=
5027 IDENTIFIER
5028 | static_string_EXPRESSION
5029 @end smallexample
5030
5031 @noindent
5032 This pragma is identical in effect to pragma @code{Common_Object}.
5033
5034 @node Pragma Pure_Function
5035 @unnumberedsec Pragma Pure_Function
5036 @findex Pure_Function
5037 @noindent
5038 Syntax:
5039
5040 @smallexample @c ada
5041 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
5042 @end smallexample
5043
5044 @noindent
5045 This pragma appears in the same declarative part as a function
5046 declaration (or a set of function declarations if more than one
5047 overloaded declaration exists, in which case the pragma applies
5048 to all entities). It specifies that the function @code{Entity} is
5049 to be considered pure for the purposes of code generation. This means
5050 that the compiler can assume that there are no side effects, and
5051 in particular that two calls with identical arguments produce the
5052 same result. It also means that the function can be used in an
5053 address clause.
5054
5055 Note that, quite deliberately, there are no static checks to try
5056 to ensure that this promise is met, so @code{Pure_Function} can be used
5057 with functions that are conceptually pure, even if they do modify
5058 global variables. For example, a square root function that is
5059 instrumented to count the number of times it is called is still
5060 conceptually pure, and can still be optimized, even though it
5061 modifies a global variable (the count). Memo functions are another
5062 example (where a table of previous calls is kept and consulted to
5063 avoid re-computation).
5064
5065 Note also that the normal rules excluding optimization of subprograms
5066 in pure units (when parameter types are descended from System.Address,
5067 or when the full view of a parameter type is limited), do not apply
5068 for the Pure_Function case. If you explicitly specify Pure_Function,
5069 the compiler may optimize away calls with identical arguments, and
5070 if that results in unexpected behavior, the proper action is not to
5071 use the pragma for subprograms that are not (conceptually) pure.
5072
5073 @findex Pure
5074 Note: Most functions in a @code{Pure} package are automatically pure, and
5075 there is no need to use pragma @code{Pure_Function} for such functions. One
5076 exception is any function that has at least one formal of type
5077 @code{System.Address} or a type derived from it. Such functions are not
5078 considered pure by default, since the compiler assumes that the
5079 @code{Address} parameter may be functioning as a pointer and that the
5080 referenced data may change even if the address value does not.
5081 Similarly, imported functions are not considered to be pure by default,
5082 since there is no way of checking that they are in fact pure. The use
5083 of pragma @code{Pure_Function} for such a function will override these default
5084 assumption, and cause the compiler to treat a designated subprogram as pure
5085 in these cases.
5086
5087 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
5088 applies to the underlying renamed function. This can be used to
5089 disambiguate cases of overloading where some but not all functions
5090 in a set of overloaded functions are to be designated as pure.
5091
5092 If pragma @code{Pure_Function} is applied to a library level function, the
5093 function is also considered pure from an optimization point of view, but the
5094 unit is not a Pure unit in the categorization sense. So for example, a function
5095 thus marked is free to @code{with} non-pure units.
5096
5097 @node Pragma Relative_Deadline
5098 @unnumberedsec Pragma Relative_Deadline
5099 @findex Relative_Deadline
5100 @noindent
5101 Syntax:
5102
5103 @smallexample @c ada
5104 pragma Relative_Deadline (time_span_EXPRESSSION);
5105 @end smallexample
5106
5107 @noindent
5108 This pragma is standard in Ada 2005, but is available in all earlier
5109 versions of Ada as an implementation-defined pragma.
5110 See Ada 2012 Reference Manual for details.
5111
5112 @node Pragma Remote_Access_Type
5113 @unnumberedsec Pragma Remote_Access_Type
5114 @findex Remote_Access_Type
5115 @noindent
5116 Syntax:
5117
5118 @smallexample @c ada
5119 pragma Remote_Access_Type ([Entity =>] formal_access_type_LOCAL_NAME);
5120 @end smallexample
5121
5122 @noindent
5123 This pragma appears in the formal part of a generic declaration.
5124 It specifies an exception to the RM rule from E.2.2(17/2), which forbids
5125 the use of a remote access to class-wide type as actual for a formal
5126 access type.
5127
5128 When this pragma applies to a formal access type @code{Entity}, that
5129 type is treated as a remote access to class-wide type in the generic.
5130 It must be a formal general access type, and its designated type must
5131 be the class-wide type of a formal tagged limited private type from the
5132 same generic declaration.
5133
5134 In the generic unit, the formal type is subject to all restrictions
5135 pertaining to remote access to class-wide types. At instantiation, the
5136 actual type must be a remote access to class-wide type.
5137
5138 @node Pragma Restriction_Warnings
5139 @unnumberedsec Pragma Restriction_Warnings
5140 @findex Restriction_Warnings
5141 @noindent
5142 Syntax:
5143
5144 @smallexample @c ada
5145 pragma Restriction_Warnings
5146 (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
5147 @end smallexample
5148
5149 @noindent
5150 This pragma allows a series of restriction identifiers to be
5151 specified (the list of allowed identifiers is the same as for
5152 pragma @code{Restrictions}). For each of these identifiers
5153 the compiler checks for violations of the restriction, but
5154 generates a warning message rather than an error message
5155 if the restriction is violated.
5156
5157 @node Pragma Shared
5158 @unnumberedsec Pragma Shared
5159 @findex Shared
5160
5161 @noindent
5162 This pragma is provided for compatibility with Ada 83. The syntax and
5163 semantics are identical to pragma Atomic.
5164
5165 @node Pragma Short_Circuit_And_Or
5166 @unnumberedsec Pragma Short_Circuit_And_Or
5167 @findex Short_Circuit_And_Or
5168
5169 @noindent
5170 This configuration pragma causes any occurrence of the AND operator applied to
5171 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
5172 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
5173 may be useful in the context of certification protocols requiring the use of
5174 short-circuited logical operators. If this configuration pragma occurs locally
5175 within the file being compiled, it applies only to the file being compiled.
5176 There is no requirement that all units in a partition use this option.
5177
5178 @node Pragma Short_Descriptors
5179 @unnumberedsec Pragma Short_Descriptors
5180 @findex Short_Descriptors
5181 @noindent
5182 Syntax:
5183
5184 @smallexample @c ada
5185 pragma Short_Descriptors
5186 @end smallexample
5187
5188 @noindent
5189 In VMS versions of the compiler, this configuration pragma causes all
5190 occurrences of the mechanism types Descriptor[_xxx] to be treated as
5191 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
5192 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
5193 versions.
5194
5195 @node Pragma Simple_Storage_Pool_Type
5196 @unnumberedsec Pragma Simple_Storage_Pool_Type
5197 @findex Simple_Storage_Pool_Type
5198 @cindex Storage pool, simple
5199 @cindex Simple storage pool
5200 @noindent
5201 Syntax:
5202
5203 @smallexample @c ada
5204 pragma Simple_Storage_Pool_Type (type_LOCAL_NAME);
5205 @end smallexample
5206
5207 @noindent
5208 A type can be established as a ``simple storage pool type'' by applying
5209 the representation pragma @code{Simple_Storage_Pool_Type} to the type.
5210 A type named in the pragma must be a library-level immutably limited record
5211 type or limited tagged type declared immediately within a package declaration.
5212 The type can also be a limited private type whose full type is allowed as
5213 a simple storage pool type.
5214
5215 For a simple storage pool type @var{SSP}, nonabstract primitive subprograms
5216 @code{Allocate}, @code{Deallocate}, and @code{Storage_Size} can be declared that
5217 are subtype conformant with the following subprogram declarations:
5218
5219 @smallexample @c ada
5220 procedure Allocate
5221 (Pool : in out SSP;
5222 Storage_Address : out System.Address;
5223 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5224 Alignment : System.Storage_Elements.Storage_Count);
5225
5226 procedure Deallocate
5227 (Pool : in out SSP;
5228 Storage_Address : System.Address;
5229 Size_In_Storage_Elements : System.Storage_Elements.Storage_Count;
5230 Alignment : System.Storage_Elements.Storage_Count);
5231
5232 function Storage_Size (Pool : SSP)
5233 return System.Storage_Elements.Storage_Count;
5234 @end smallexample
5235
5236 @noindent
5237 Procedure @code{Allocate} must be declared, whereas @code{Deallocate} and
5238 @code{Storage_Size} are optional. If @code{Deallocate} is not declared, then
5239 applying an unchecked deallocation has no effect other than to set its actual
5240 parameter to null. If @code{Storage_Size} is not declared, then the
5241 @code{Storage_Size} attribute applied to an access type associated with
5242 a pool object of type SSP returns zero. Additional operations can be declared
5243 for a simple storage pool type (such as for supporting a mark/release
5244 storage-management discipline).
5245
5246 An object of a simple storage pool type can be associated with an access
5247 type by specifying the attribute @code{Simple_Storage_Pool}. For example:
5248
5249 @smallexample @c ada
5250
5251 My_Pool : My_Simple_Storage_Pool_Type;
5252
5253 type Acc is access My_Data_Type;
5254
5255 for Acc'Simple_Storage_Pool use My_Pool;
5256
5257 @end smallexample
5258
5259 @noindent
5260 See attribute @code{Simple_Storage_Pool} for further details.
5261
5262 @node Pragma Source_File_Name
5263 @unnumberedsec Pragma Source_File_Name
5264 @findex Source_File_Name
5265 @noindent
5266 Syntax:
5267
5268 @smallexample @c ada
5269 pragma Source_File_Name (
5270 [Unit_Name =>] unit_NAME,
5271 Spec_File_Name => STRING_LITERAL,
5272 [Index => INTEGER_LITERAL]);
5273
5274 pragma Source_File_Name (
5275 [Unit_Name =>] unit_NAME,
5276 Body_File_Name => STRING_LITERAL,
5277 [Index => INTEGER_LITERAL]);
5278 @end smallexample
5279
5280 @noindent
5281 Use this to override the normal naming convention. It is a configuration
5282 pragma, and so has the usual applicability of configuration pragmas
5283 (i.e.@: it applies to either an entire partition, or to all units in a
5284 compilation, or to a single unit, depending on how it is used.
5285 @var{unit_name} is mapped to @var{file_name_literal}. The identifier for
5286 the second argument is required, and indicates whether this is the file
5287 name for the spec or for the body.
5288
5289 The optional Index argument should be used when a file contains multiple
5290 units, and when you do not want to use @code{gnatchop} to separate then
5291 into multiple files (which is the recommended procedure to limit the
5292 number of recompilations that are needed when some sources change).
5293 For instance, if the source file @file{source.ada} contains
5294
5295 @smallexample @c ada
5296 package B is
5297 ...
5298 end B;
5299
5300 with B;
5301 procedure A is
5302 begin
5303 ..
5304 end A;
5305 @end smallexample
5306
5307 you could use the following configuration pragmas:
5308
5309 @smallexample @c ada
5310 pragma Source_File_Name
5311 (B, Spec_File_Name => "source.ada", Index => 1);
5312 pragma Source_File_Name
5313 (A, Body_File_Name => "source.ada", Index => 2);
5314 @end smallexample
5315
5316 Note that the @code{gnatname} utility can also be used to generate those
5317 configuration pragmas.
5318
5319 Another form of the @code{Source_File_Name} pragma allows
5320 the specification of patterns defining alternative file naming schemes
5321 to apply to all files.
5322
5323 @smallexample @c ada
5324 pragma Source_File_Name
5325 ( [Spec_File_Name =>] STRING_LITERAL
5326 [,[Casing =>] CASING_SPEC]
5327 [,[Dot_Replacement =>] STRING_LITERAL]);
5328
5329 pragma Source_File_Name
5330 ( [Body_File_Name =>] STRING_LITERAL
5331 [,[Casing =>] CASING_SPEC]
5332 [,[Dot_Replacement =>] STRING_LITERAL]);
5333
5334 pragma Source_File_Name
5335 ( [Subunit_File_Name =>] STRING_LITERAL
5336 [,[Casing =>] CASING_SPEC]
5337 [,[Dot_Replacement =>] STRING_LITERAL]);
5338
5339 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
5340 @end smallexample
5341
5342 @noindent
5343 The first argument is a pattern that contains a single asterisk indicating
5344 the point at which the unit name is to be inserted in the pattern string
5345 to form the file name. The second argument is optional. If present it
5346 specifies the casing of the unit name in the resulting file name string.
5347 The default is lower case. Finally the third argument allows for systematic
5348 replacement of any dots in the unit name by the specified string literal.
5349
5350 Note that Source_File_Name pragmas should not be used if you are using
5351 project files. The reason for this rule is that the project manager is not
5352 aware of these pragmas, and so other tools that use the projet file would not
5353 be aware of the intended naming conventions. If you are using project files,
5354 file naming is controlled by Source_File_Name_Project pragmas, which are
5355 usually supplied automatically by the project manager. A pragma
5356 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
5357
5358 For more details on the use of the @code{Source_File_Name} pragma,
5359 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
5360 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
5361 User's Guide}.
5362
5363 @node Pragma Source_File_Name_Project
5364 @unnumberedsec Pragma Source_File_Name_Project
5365 @findex Source_File_Name_Project
5366 @noindent
5367
5368 This pragma has the same syntax and semantics as pragma Source_File_Name.
5369 It is only allowed as a stand alone configuration pragma.
5370 It cannot appear after a @ref{Pragma Source_File_Name}, and
5371 most importantly, once pragma Source_File_Name_Project appears,
5372 no further Source_File_Name pragmas are allowed.
5373
5374 The intention is that Source_File_Name_Project pragmas are always
5375 generated by the Project Manager in a manner consistent with the naming
5376 specified in a project file, and when naming is controlled in this manner,
5377 it is not permissible to attempt to modify this naming scheme using
5378 Source_File_Name or Source_File_Name_Project pragmas (which would not be
5379 known to the project manager).
5380
5381 @node Pragma Source_Reference
5382 @unnumberedsec Pragma Source_Reference
5383 @findex Source_Reference
5384 @noindent
5385 Syntax:
5386
5387 @smallexample @c ada
5388 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
5389 @end smallexample
5390
5391 @noindent
5392 This pragma must appear as the first line of a source file.
5393 @var{integer_literal} is the logical line number of the line following
5394 the pragma line (for use in error messages and debugging
5395 information). @var{string_literal} is a static string constant that
5396 specifies the file name to be used in error messages and debugging
5397 information. This is most notably used for the output of @code{gnatchop}
5398 with the @option{-r} switch, to make sure that the original unchopped
5399 source file is the one referred to.
5400
5401 The second argument must be a string literal, it cannot be a static
5402 string expression other than a string literal. This is because its value
5403 is needed for error messages issued by all phases of the compiler.
5404
5405 @node Pragma Static_Elaboration_Desired
5406 @unnumberedsec Pragma Static_Elaboration_Desired
5407 @findex Static_Elaboration_Desired
5408 @noindent
5409 Syntax:
5410
5411 @smallexample @c ada
5412 pragma Static_Elaboration_Desired;
5413 @end smallexample
5414
5415 @noindent
5416 This pragma is used to indicate that the compiler should attempt to initialize
5417 statically the objects declared in the library unit to which the pragma applies,
5418 when these objects are initialized (explicitly or implicitly) by an aggregate.
5419 In the absence of this pragma, aggregates in object declarations are expanded
5420 into assignments and loops, even when the aggregate components are static
5421 constants. When the aggregate is present the compiler builds a static expression
5422 that requires no run-time code, so that the initialized object can be placed in
5423 read-only data space. If the components are not static, or the aggregate has
5424 more that 100 components, the compiler emits a warning that the pragma cannot
5425 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
5426 construction of larger aggregates with static components that include an others
5427 choice.)
5428
5429 @node Pragma Stream_Convert
5430 @unnumberedsec Pragma Stream_Convert
5431 @findex Stream_Convert
5432 @noindent
5433 Syntax:
5434
5435 @smallexample @c ada
5436 pragma Stream_Convert (
5437 [Entity =>] type_LOCAL_NAME,
5438 [Read =>] function_NAME,
5439 [Write =>] function_NAME);
5440 @end smallexample
5441
5442 @noindent
5443 This pragma provides an efficient way of providing stream functions for
5444 types defined in packages. Not only is it simpler to use than declaring
5445 the necessary functions with attribute representation clauses, but more
5446 significantly, it allows the declaration to made in such a way that the
5447 stream packages are not loaded unless they are needed. The use of
5448 the Stream_Convert pragma adds no overhead at all, unless the stream
5449 attributes are actually used on the designated type.
5450
5451 The first argument specifies the type for which stream functions are
5452 provided. The second parameter provides a function used to read values
5453 of this type. It must name a function whose argument type may be any
5454 subtype, and whose returned type must be the type given as the first
5455 argument to the pragma.
5456
5457 The meaning of the @var{Read}
5458 parameter is that if a stream attribute directly
5459 or indirectly specifies reading of the type given as the first parameter,
5460 then a value of the type given as the argument to the Read function is
5461 read from the stream, and then the Read function is used to convert this
5462 to the required target type.
5463
5464 Similarly the @var{Write} parameter specifies how to treat write attributes
5465 that directly or indirectly apply to the type given as the first parameter.
5466 It must have an input parameter of the type specified by the first parameter,
5467 and the return type must be the same as the input type of the Read function.
5468 The effect is to first call the Write function to convert to the given stream
5469 type, and then write the result type to the stream.
5470
5471 The Read and Write functions must not be overloaded subprograms. If necessary
5472 renamings can be supplied to meet this requirement.
5473 The usage of this attribute is best illustrated by a simple example, taken
5474 from the GNAT implementation of package Ada.Strings.Unbounded:
5475
5476 @smallexample @c ada
5477 function To_Unbounded (S : String)
5478 return Unbounded_String
5479 renames To_Unbounded_String;
5480
5481 pragma Stream_Convert
5482 (Unbounded_String, To_Unbounded, To_String);
5483 @end smallexample
5484
5485 @noindent
5486 The specifications of the referenced functions, as given in the Ada
5487 Reference Manual are:
5488
5489 @smallexample @c ada
5490 function To_Unbounded_String (Source : String)
5491 return Unbounded_String;
5492
5493 function To_String (Source : Unbounded_String)
5494 return String;
5495 @end smallexample
5496
5497 @noindent
5498 The effect is that if the value of an unbounded string is written to a stream,
5499 then the representation of the item in the stream is in the same format that
5500 would be used for @code{Standard.String'Output}, and this same representation
5501 is expected when a value of this type is read from the stream. Note that the
5502 value written always includes the bounds, even for Unbounded_String'Write,
5503 since Unbounded_String is not an array type.
5504
5505 @node Pragma Style_Checks
5506 @unnumberedsec Pragma Style_Checks
5507 @findex Style_Checks
5508 @noindent
5509 Syntax:
5510
5511 @smallexample @c ada
5512 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
5513 On | Off [, LOCAL_NAME]);
5514 @end smallexample
5515
5516 @noindent
5517 This pragma is used in conjunction with compiler switches to control the
5518 built in style checking provided by GNAT@. The compiler switches, if set,
5519 provide an initial setting for the switches, and this pragma may be used
5520 to modify these settings, or the settings may be provided entirely by
5521 the use of the pragma. This pragma can be used anywhere that a pragma
5522 is legal, including use as a configuration pragma (including use in
5523 the @file{gnat.adc} file).
5524
5525 The form with a string literal specifies which style options are to be
5526 activated. These are additive, so they apply in addition to any previously
5527 set style check options. The codes for the options are the same as those
5528 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
5529 For example the following two methods can be used to enable
5530 layout checking:
5531
5532 @itemize @bullet
5533 @item
5534 @smallexample @c ada
5535 pragma Style_Checks ("l");
5536 @end smallexample
5537
5538 @item
5539 @smallexample
5540 gcc -c -gnatyl @dots{}
5541 @end smallexample
5542 @end itemize
5543
5544 @noindent
5545 The form ALL_CHECKS activates all standard checks (its use is equivalent
5546 to the use of the @code{gnaty} switch with no options. @xref{Top,
5547 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
5548 @value{EDITION} User's Guide}, for details.)
5549
5550 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
5551 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
5552 options (i.e. equivalent to -gnatyg).
5553
5554 The forms with @code{Off} and @code{On}
5555 can be used to temporarily disable style checks
5556 as shown in the following example:
5557
5558 @smallexample @c ada
5559 @iftex
5560 @leftskip=0cm
5561 @end iftex
5562 pragma Style_Checks ("k"); -- requires keywords in lower case
5563 pragma Style_Checks (Off); -- turn off style checks
5564 NULL; -- this will not generate an error message
5565 pragma Style_Checks (On); -- turn style checks back on
5566 NULL; -- this will generate an error message
5567 @end smallexample
5568
5569 @noindent
5570 Finally the two argument form is allowed only if the first argument is
5571 @code{On} or @code{Off}. The effect is to turn of semantic style checks
5572 for the specified entity, as shown in the following example:
5573
5574 @smallexample @c ada
5575 @iftex
5576 @leftskip=0cm
5577 @end iftex
5578 pragma Style_Checks ("r"); -- require consistency of identifier casing
5579 Arg : Integer;
5580 Rf1 : Integer := ARG; -- incorrect, wrong case
5581 pragma Style_Checks (Off, Arg);
5582 Rf2 : Integer := ARG; -- OK, no error
5583 @end smallexample
5584
5585 @node Pragma Subtitle
5586 @unnumberedsec Pragma Subtitle
5587 @findex Subtitle
5588 @noindent
5589 Syntax:
5590
5591 @smallexample @c ada
5592 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
5593 @end smallexample
5594
5595 @noindent
5596 This pragma is recognized for compatibility with other Ada compilers
5597 but is ignored by GNAT@.
5598
5599 @node Pragma Suppress
5600 @unnumberedsec Pragma Suppress
5601 @findex Suppress
5602 @noindent
5603 Syntax:
5604
5605 @smallexample @c ada
5606 pragma Suppress (Identifier [, [On =>] Name]);
5607 @end smallexample
5608
5609 @noindent
5610 This is a standard pragma, and supports all the check names required in
5611 the RM. It is included here because GNAT recognizes one additional check
5612 name: @code{Alignment_Check} which can be used to suppress alignment checks
5613 on addresses used in address clauses. Such checks can also be suppressed
5614 by suppressing range checks, but the specific use of @code{Alignment_Check}
5615 allows suppression of alignment checks without suppressing other range checks.
5616
5617 Note that pragma Suppress gives the compiler permission to omit
5618 checks, but does not require the compiler to omit checks. The compiler
5619 will generate checks if they are essentially free, even when they are
5620 suppressed. In particular, if the compiler can prove that a certain
5621 check will necessarily fail, it will generate code to do an
5622 unconditional ``raise'', even if checks are suppressed. The compiler
5623 warns in this case.
5624
5625 Of course, run-time checks are omitted whenever the compiler can prove
5626 that they will not fail, whether or not checks are suppressed.
5627
5628 @node Pragma Suppress_All
5629 @unnumberedsec Pragma Suppress_All
5630 @findex Suppress_All
5631 @noindent
5632 Syntax:
5633
5634 @smallexample @c ada
5635 pragma Suppress_All;
5636 @end smallexample
5637
5638 @noindent
5639 This pragma can appear anywhere within a unit.
5640 The effect is to apply @code{Suppress (All_Checks)} to the unit
5641 in which it appears. This pragma is implemented for compatibility with DEC
5642 Ada 83 usage where it appears at the end of a unit, and for compatibility
5643 with Rational Ada, where it appears as a program unit pragma.
5644 The use of the standard Ada pragma @code{Suppress (All_Checks)}
5645 as a normal configuration pragma is the preferred usage in GNAT@.
5646
5647 @node Pragma Suppress_Exception_Locations
5648 @unnumberedsec Pragma Suppress_Exception_Locations
5649 @findex Suppress_Exception_Locations
5650 @noindent
5651 Syntax:
5652
5653 @smallexample @c ada
5654 pragma Suppress_Exception_Locations;
5655 @end smallexample
5656
5657 @noindent
5658 In normal mode, a raise statement for an exception by default generates
5659 an exception message giving the file name and line number for the location
5660 of the raise. This is useful for debugging and logging purposes, but this
5661 entails extra space for the strings for the messages. The configuration
5662 pragma @code{Suppress_Exception_Locations} can be used to suppress the
5663 generation of these strings, with the result that space is saved, but the
5664 exception message for such raises is null. This configuration pragma may
5665 appear in a global configuration pragma file, or in a specific unit as
5666 usual. It is not required that this pragma be used consistently within
5667 a partition, so it is fine to have some units within a partition compiled
5668 with this pragma and others compiled in normal mode without it.
5669
5670 @node Pragma Suppress_Initialization
5671 @unnumberedsec Pragma Suppress_Initialization
5672 @findex Suppress_Initialization
5673 @cindex Suppressing initialization
5674 @cindex Initialization, suppression of
5675 @noindent
5676 Syntax:
5677
5678 @smallexample @c ada
5679 pragma Suppress_Initialization ([Entity =>] subtype_Name);
5680 @end smallexample
5681
5682 @noindent
5683 Here subtype_Name is the name introduced by a type declaration
5684 or subtype declaration.
5685 This pragma suppresses any implicit or explicit initialization
5686 for all variables of the given type or subtype,
5687 including initialization resulting from the use of pragmas
5688 Normalize_Scalars or Initialize_Scalars.
5689
5690 This is considered a representation item, so it cannot be given after
5691 the type is frozen. It applies to all subsequent object declarations,
5692 and also any allocator that creates objects of the type.
5693
5694 If the pragma is given for the first subtype, then it is considered
5695 to apply to the base type and all its subtypes. If the pragma is given
5696 for other than a first subtype, then it applies only to the given subtype.
5697 The pragma may not be given after the type is frozen.
5698
5699 @node Pragma Task_Info
5700 @unnumberedsec Pragma Task_Info
5701 @findex Task_Info
5702 @noindent
5703 Syntax
5704
5705 @smallexample @c ada
5706 pragma Task_Info (EXPRESSION);
5707 @end smallexample
5708
5709 @noindent
5710 This pragma appears within a task definition (like pragma
5711 @code{Priority}) and applies to the task in which it appears. The
5712 argument must be of type @code{System.Task_Info.Task_Info_Type}.
5713 The @code{Task_Info} pragma provides system dependent control over
5714 aspects of tasking implementation, for example, the ability to map
5715 tasks to specific processors. For details on the facilities available
5716 for the version of GNAT that you are using, see the documentation
5717 in the spec of package System.Task_Info in the runtime
5718 library.
5719
5720 @node Pragma Task_Name
5721 @unnumberedsec Pragma Task_Name
5722 @findex Task_Name
5723 @noindent
5724 Syntax
5725
5726 @smallexample @c ada
5727 pragma Task_Name (string_EXPRESSION);
5728 @end smallexample
5729
5730 @noindent
5731 This pragma appears within a task definition (like pragma
5732 @code{Priority}) and applies to the task in which it appears. The
5733 argument must be of type String, and provides a name to be used for
5734 the task instance when the task is created. Note that this expression
5735 is not required to be static, and in particular, it can contain
5736 references to task discriminants. This facility can be used to
5737 provide different names for different tasks as they are created,
5738 as illustrated in the example below.
5739
5740 The task name is recorded internally in the run-time structures
5741 and is accessible to tools like the debugger. In addition the
5742 routine @code{Ada.Task_Identification.Image} will return this
5743 string, with a unique task address appended.
5744
5745 @smallexample @c ada
5746 -- Example of the use of pragma Task_Name
5747
5748 with Ada.Task_Identification;
5749 use Ada.Task_Identification;
5750 with Text_IO; use Text_IO;
5751 procedure t3 is
5752
5753 type Astring is access String;
5754
5755 task type Task_Typ (Name : access String) is
5756 pragma Task_Name (Name.all);
5757 end Task_Typ;
5758
5759 task body Task_Typ is
5760 Nam : constant String := Image (Current_Task);
5761 begin
5762 Put_Line ("-->" & Nam (1 .. 14) & "<--");
5763 end Task_Typ;
5764
5765 type Ptr_Task is access Task_Typ;
5766 Task_Var : Ptr_Task;
5767
5768 begin
5769 Task_Var :=
5770 new Task_Typ (new String'("This is task 1"));
5771 Task_Var :=
5772 new Task_Typ (new String'("This is task 2"));
5773 end;
5774 @end smallexample
5775
5776 @node Pragma Task_Storage
5777 @unnumberedsec Pragma Task_Storage
5778 @findex Task_Storage
5779 Syntax:
5780
5781 @smallexample @c ada
5782 pragma Task_Storage (
5783 [Task_Type =>] LOCAL_NAME,
5784 [Top_Guard =>] static_integer_EXPRESSION);
5785 @end smallexample
5786
5787 @noindent
5788 This pragma specifies the length of the guard area for tasks. The guard
5789 area is an additional storage area allocated to a task. A value of zero
5790 means that either no guard area is created or a minimal guard area is
5791 created, depending on the target. This pragma can appear anywhere a
5792 @code{Storage_Size} attribute definition clause is allowed for a task
5793 type.
5794
5795 @node Pragma Test_Case
5796 @unnumberedsec Pragma Test_Case
5797 @cindex Test cases
5798 @findex Test_Case
5799 @noindent
5800 Syntax:
5801
5802 @smallexample @c ada
5803 pragma Test_Case (
5804 [Name =>] static_string_Expression
5805 ,[Mode =>] (Nominal | Robustness)
5806 [, Requires => Boolean_Expression]
5807 [, Ensures => Boolean_Expression]);
5808 @end smallexample
5809
5810 @noindent
5811 The @code{Test_Case} pragma allows defining fine-grain specifications
5812 for use by testing tools. Its syntax is similar to the syntax of the
5813 @code{Contract_Case} pragma, which is used for both testing and
5814 formal verification.
5815 The compiler checks the validity of the @code{Test_Case} pragma, but its
5816 presence does not lead to any modification of the code generated by the
5817 compiler, contrary to the treatment of the @code{Contract_Case} pragma.
5818
5819 @code{Test_Case} pragmas may only appear immediately following the
5820 (separate) declaration of a subprogram in a package declaration, inside
5821 a package spec unit. Only other pragmas may intervene (that is appear
5822 between the subprogram declaration and a test case).
5823
5824 The compiler checks that boolean expressions given in @code{Requires} and
5825 @code{Ensures} are valid, where the rules for @code{Requires} are the
5826 same as the rule for an expression in @code{Precondition} and the rules
5827 for @code{Ensures} are the same as the rule for an expression in
5828 @code{Postcondition}. In particular, attributes @code{'Old} and
5829 @code{'Result} can only be used within the @code{Ensures}
5830 expression. The following is an example of use within a package spec:
5831
5832 @smallexample @c ada
5833 package Math_Functions is
5834 ...
5835 function Sqrt (Arg : Float) return Float;
5836 pragma Test_Case (Name => "Test 1",
5837 Mode => Nominal,
5838 Requires => Arg < 10000,
5839 Ensures => Sqrt'Result < 10);
5840 ...
5841 end Math_Functions;
5842 @end smallexample
5843
5844 @noindent
5845 The meaning of a test case is that there is at least one context where
5846 @code{Requires} holds such that, if the associated subprogram is executed in
5847 that context, then @code{Ensures} holds when the subprogram returns.
5848 Mode @code{Nominal} indicates that the input context should also satisfy the
5849 precondition of the subprogram, and the output context should also satisfy its
5850 postcondition. More @code{Robustness} indicates that the precondition and
5851 postcondition of the subprogram should be ignored for this test case.
5852
5853 @node Pragma Thread_Local_Storage
5854 @unnumberedsec Pragma Thread_Local_Storage
5855 @findex Thread_Local_Storage
5856 @cindex Task specific storage
5857 @cindex TLS (Thread Local Storage)
5858 Syntax:
5859
5860 @smallexample @c ada
5861 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5862 @end smallexample
5863
5864 @noindent
5865 This pragma specifies that the specified entity, which must be
5866 a variable declared in a library level package, is to be marked as
5867 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5868 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5869 (and hence each Ada task) to see a distinct copy of the variable.
5870
5871 The variable may not have default initialization, and if there is
5872 an explicit initialization, it must be either @code{null} for an
5873 access variable, or a static expression for a scalar variable.
5874 This provides a low level mechanism similar to that provided by
5875 the @code{Ada.Task_Attributes} package, but much more efficient
5876 and is also useful in writing interface code that will interact
5877 with foreign threads.
5878
5879 If this pragma is used on a system where @code{TLS} is not supported,
5880 then an error message will be generated and the program will be rejected.
5881
5882 @node Pragma Time_Slice
5883 @unnumberedsec Pragma Time_Slice
5884 @findex Time_Slice
5885 @noindent
5886 Syntax:
5887
5888 @smallexample @c ada
5889 pragma Time_Slice (static_duration_EXPRESSION);
5890 @end smallexample
5891
5892 @noindent
5893 For implementations of GNAT on operating systems where it is possible
5894 to supply a time slice value, this pragma may be used for this purpose.
5895 It is ignored if it is used in a system that does not allow this control,
5896 or if it appears in other than the main program unit.
5897 @cindex OpenVMS
5898 Note that the effect of this pragma is identical to the effect of the
5899 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5900
5901 @node Pragma Title
5902 @unnumberedsec Pragma Title
5903 @findex Title
5904 @noindent
5905 Syntax:
5906
5907 @smallexample @c ada
5908 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5909
5910 TITLING_OPTION ::=
5911 [Title =>] STRING_LITERAL,
5912 | [Subtitle =>] STRING_LITERAL
5913 @end smallexample
5914
5915 @noindent
5916 Syntax checked but otherwise ignored by GNAT@. This is a listing control
5917 pragma used in DEC Ada 83 implementations to provide a title and/or
5918 subtitle for the program listing. The program listing generated by GNAT
5919 does not have titles or subtitles.
5920
5921 Unlike other pragmas, the full flexibility of named notation is allowed
5922 for this pragma, i.e.@: the parameters may be given in any order if named
5923 notation is used, and named and positional notation can be mixed
5924 following the normal rules for procedure calls in Ada.
5925
5926 @node Pragma Unchecked_Union
5927 @unnumberedsec Pragma Unchecked_Union
5928 @cindex Unions in C
5929 @findex Unchecked_Union
5930 @noindent
5931 Syntax:
5932
5933 @smallexample @c ada
5934 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5935 @end smallexample
5936
5937 @noindent
5938 This pragma is used to specify a representation of a record type that is
5939 equivalent to a C union. It was introduced as a GNAT implementation defined
5940 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5941 pragma, making it language defined, and GNAT fully implements this extended
5942 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5943 details, consult the Ada 2012 Reference Manual, section B.3.3.
5944
5945 @node Pragma Unimplemented_Unit
5946 @unnumberedsec Pragma Unimplemented_Unit
5947 @findex Unimplemented_Unit
5948 @noindent
5949 Syntax:
5950
5951 @smallexample @c ada
5952 pragma Unimplemented_Unit;
5953 @end smallexample
5954
5955 @noindent
5956 If this pragma occurs in a unit that is processed by the compiler, GNAT
5957 aborts with the message @samp{@var{xxx} not implemented}, where
5958 @var{xxx} is the name of the current compilation unit. This pragma is
5959 intended to allow the compiler to handle unimplemented library units in
5960 a clean manner.
5961
5962 The abort only happens if code is being generated. Thus you can use
5963 specs of unimplemented packages in syntax or semantic checking mode.
5964
5965 @node Pragma Universal_Aliasing
5966 @unnumberedsec Pragma Universal_Aliasing
5967 @findex Universal_Aliasing
5968 @noindent
5969 Syntax:
5970
5971 @smallexample @c ada
5972 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5973 @end smallexample
5974
5975 @noindent
5976 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5977 declarative part. The effect is to inhibit strict type-based aliasing
5978 optimization for the given type. In other words, the effect is as though
5979 access types designating this type were subject to pragma No_Strict_Aliasing.
5980 For a detailed description of the strict aliasing optimization, and the
5981 situations in which it must be suppressed, @xref{Optimization and Strict
5982 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5983
5984 @node Pragma Universal_Data
5985 @unnumberedsec Pragma Universal_Data
5986 @findex Universal_Data
5987 @noindent
5988 Syntax:
5989
5990 @smallexample @c ada
5991 pragma Universal_Data [(library_unit_Name)];
5992 @end smallexample
5993
5994 @noindent
5995 This pragma is supported only for the AAMP target and is ignored for
5996 other targets. The pragma specifies that all library-level objects
5997 (Counter 0 data) associated with the library unit are to be accessed
5998 and updated using universal addressing (24-bit addresses for AAMP5)
5999 rather than the default of 16-bit Data Environment (DENV) addressing.
6000 Use of this pragma will generally result in less efficient code for
6001 references to global data associated with the library unit, but
6002 allows such data to be located anywhere in memory. This pragma is
6003 a library unit pragma, but can also be used as a configuration pragma
6004 (including use in the @file{gnat.adc} file). The functionality
6005 of this pragma is also available by applying the -univ switch on the
6006 compilations of units where universal addressing of the data is desired.
6007
6008 @node Pragma Unmodified
6009 @unnumberedsec Pragma Unmodified
6010 @findex Unmodified
6011 @cindex Warnings, unmodified
6012 @noindent
6013 Syntax:
6014
6015 @smallexample @c ada
6016 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
6017 @end smallexample
6018
6019 @noindent
6020 This pragma signals that the assignable entities (variables,
6021 @code{out} parameters, @code{in out} parameters) whose names are listed are
6022 deliberately not assigned in the current source unit. This
6023 suppresses warnings about the
6024 entities being referenced but not assigned, and in addition a warning will be
6025 generated if one of these entities is in fact assigned in the
6026 same unit as the pragma (or in the corresponding body, or one
6027 of its subunits).
6028
6029 This is particularly useful for clearly signaling that a particular
6030 parameter is not modified, even though the spec suggests that it might
6031 be.
6032
6033 @node Pragma Unreferenced
6034 @unnumberedsec Pragma Unreferenced
6035 @findex Unreferenced
6036 @cindex Warnings, unreferenced
6037 @noindent
6038 Syntax:
6039
6040 @smallexample @c ada
6041 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
6042 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
6043 @end smallexample
6044
6045 @noindent
6046 This pragma signals that the entities whose names are listed are
6047 deliberately not referenced in the current source unit. This
6048 suppresses warnings about the
6049 entities being unreferenced, and in addition a warning will be
6050 generated if one of these entities is in fact subsequently referenced in the
6051 same unit as the pragma (or in the corresponding body, or one
6052 of its subunits).
6053
6054 This is particularly useful for clearly signaling that a particular
6055 parameter is not referenced in some particular subprogram implementation
6056 and that this is deliberate. It can also be useful in the case of
6057 objects declared only for their initialization or finalization side
6058 effects.
6059
6060 If @code{LOCAL_NAME} identifies more than one matching homonym in the
6061 current scope, then the entity most recently declared is the one to which
6062 the pragma applies. Note that in the case of accept formals, the pragma
6063 Unreferenced may appear immediately after the keyword @code{do} which
6064 allows the indication of whether or not accept formals are referenced
6065 or not to be given individually for each accept statement.
6066
6067 The left hand side of an assignment does not count as a reference for the
6068 purpose of this pragma. Thus it is fine to assign to an entity for which
6069 pragma Unreferenced is given.
6070
6071 Note that if a warning is desired for all calls to a given subprogram,
6072 regardless of whether they occur in the same unit as the subprogram
6073 declaration, then this pragma should not be used (calls from another
6074 unit would not be flagged); pragma Obsolescent can be used instead
6075 for this purpose, see @xref{Pragma Obsolescent}.
6076
6077 The second form of pragma @code{Unreferenced} is used within a context
6078 clause. In this case the arguments must be unit names of units previously
6079 mentioned in @code{with} clauses (similar to the usage of pragma
6080 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
6081 units and unreferenced entities within these units.
6082
6083 @node Pragma Unreferenced_Objects
6084 @unnumberedsec Pragma Unreferenced_Objects
6085 @findex Unreferenced_Objects
6086 @cindex Warnings, unreferenced
6087 @noindent
6088 Syntax:
6089
6090 @smallexample @c ada
6091 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
6092 @end smallexample
6093
6094 @noindent
6095 This pragma signals that for the types or subtypes whose names are
6096 listed, objects which are declared with one of these types or subtypes may
6097 not be referenced, and if no references appear, no warnings are given.
6098
6099 This is particularly useful for objects which are declared solely for their
6100 initialization and finalization effect. Such variables are sometimes referred
6101 to as RAII variables (Resource Acquisition Is Initialization). Using this
6102 pragma on the relevant type (most typically a limited controlled type), the
6103 compiler will automatically suppress unwanted warnings about these variables
6104 not being referenced.
6105
6106 @node Pragma Unreserve_All_Interrupts
6107 @unnumberedsec Pragma Unreserve_All_Interrupts
6108 @findex Unreserve_All_Interrupts
6109 @noindent
6110 Syntax:
6111
6112 @smallexample @c ada
6113 pragma Unreserve_All_Interrupts;
6114 @end smallexample
6115
6116 @noindent
6117 Normally certain interrupts are reserved to the implementation. Any attempt
6118 to attach an interrupt causes Program_Error to be raised, as described in
6119 RM C.3.2(22). A typical example is the @code{SIGINT} interrupt used in
6120 many systems for a @kbd{Ctrl-C} interrupt. Normally this interrupt is
6121 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
6122 interrupt execution.
6123
6124 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
6125 a program, then all such interrupts are unreserved. This allows the
6126 program to handle these interrupts, but disables their standard
6127 functions. For example, if this pragma is used, then pressing
6128 @kbd{Ctrl-C} will not automatically interrupt execution. However,
6129 a program can then handle the @code{SIGINT} interrupt as it chooses.
6130
6131 For a full list of the interrupts handled in a specific implementation,
6132 see the source code for the spec of @code{Ada.Interrupts.Names} in
6133 file @file{a-intnam.ads}. This is a target dependent file that contains the
6134 list of interrupts recognized for a given target. The documentation in
6135 this file also specifies what interrupts are affected by the use of
6136 the @code{Unreserve_All_Interrupts} pragma.
6137
6138 For a more general facility for controlling what interrupts can be
6139 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
6140 of the @code{Unreserve_All_Interrupts} pragma.
6141
6142 @node Pragma Unsuppress
6143 @unnumberedsec Pragma Unsuppress
6144 @findex Unsuppress
6145 @noindent
6146 Syntax:
6147
6148 @smallexample @c ada
6149 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
6150 @end smallexample
6151
6152 @noindent
6153 This pragma undoes the effect of a previous pragma @code{Suppress}. If
6154 there is no corresponding pragma @code{Suppress} in effect, it has no
6155 effect. The range of the effect is the same as for pragma
6156 @code{Suppress}. The meaning of the arguments is identical to that used
6157 in pragma @code{Suppress}.
6158
6159 One important application is to ensure that checks are on in cases where
6160 code depends on the checks for its correct functioning, so that the code
6161 will compile correctly even if the compiler switches are set to suppress
6162 checks.
6163
6164 This pragma is standard in Ada 2005. It is available in all earlier versions
6165 of Ada as an implementation-defined pragma.
6166
6167 @node Pragma Use_VADS_Size
6168 @unnumberedsec Pragma Use_VADS_Size
6169 @cindex @code{Size}, VADS compatibility
6170 @cindex Rational profile
6171 @findex Use_VADS_Size
6172 @noindent
6173 Syntax:
6174
6175 @smallexample @c ada
6176 pragma Use_VADS_Size;
6177 @end smallexample
6178
6179 @noindent
6180 This is a configuration pragma. In a unit to which it applies, any use
6181 of the 'Size attribute is automatically interpreted as a use of the
6182 'VADS_Size attribute. Note that this may result in incorrect semantic
6183 processing of valid Ada 95 or Ada 2005 programs. This is intended to aid in
6184 the handling of existing code which depends on the interpretation of Size
6185 as implemented in the VADS compiler. See description of the VADS_Size
6186 attribute for further details.
6187
6188 @node Pragma Validity_Checks
6189 @unnumberedsec Pragma Validity_Checks
6190 @findex Validity_Checks
6191 @noindent
6192 Syntax:
6193
6194 @smallexample @c ada
6195 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
6196 @end smallexample
6197
6198 @noindent
6199 This pragma is used in conjunction with compiler switches to control the
6200 built-in validity checking provided by GNAT@. The compiler switches, if set
6201 provide an initial setting for the switches, and this pragma may be used
6202 to modify these settings, or the settings may be provided entirely by
6203 the use of the pragma. This pragma can be used anywhere that a pragma
6204 is legal, including use as a configuration pragma (including use in
6205 the @file{gnat.adc} file).
6206
6207 The form with a string literal specifies which validity options are to be
6208 activated. The validity checks are first set to include only the default
6209 reference manual settings, and then a string of letters in the string
6210 specifies the exact set of options required. The form of this string
6211 is exactly as described for the @option{-gnatVx} compiler switch (see the
6212 @value{EDITION} User's Guide for details). For example the following two
6213 methods can be used to enable validity checking for mode @code{in} and
6214 @code{in out} subprogram parameters:
6215
6216 @itemize @bullet
6217 @item
6218 @smallexample @c ada
6219 pragma Validity_Checks ("im");
6220 @end smallexample
6221
6222 @item
6223 @smallexample
6224 gcc -c -gnatVim @dots{}
6225 @end smallexample
6226 @end itemize
6227
6228 @noindent
6229 The form ALL_CHECKS activates all standard checks (its use is equivalent
6230 to the use of the @code{gnatva} switch.
6231
6232 The forms with @code{Off} and @code{On}
6233 can be used to temporarily disable validity checks
6234 as shown in the following example:
6235
6236 @smallexample @c ada
6237 @iftex
6238 @leftskip=0cm
6239 @end iftex
6240 pragma Validity_Checks ("c"); -- validity checks for copies
6241 pragma Validity_Checks (Off); -- turn off validity checks
6242 A := B; -- B will not be validity checked
6243 pragma Validity_Checks (On); -- turn validity checks back on
6244 A := C; -- C will be validity checked
6245 @end smallexample
6246
6247 @node Pragma Volatile
6248 @unnumberedsec Pragma Volatile
6249 @findex Volatile
6250 @noindent
6251 Syntax:
6252
6253 @smallexample @c ada
6254 pragma Volatile (LOCAL_NAME);
6255 @end smallexample
6256
6257 @noindent
6258 This pragma is defined by the Ada Reference Manual, and the GNAT
6259 implementation is fully conformant with this definition. The reason it
6260 is mentioned in this section is that a pragma of the same name was supplied
6261 in some Ada 83 compilers, including DEC Ada 83. The Ada 95 / Ada 2005
6262 implementation of pragma Volatile is upwards compatible with the
6263 implementation in DEC Ada 83.
6264
6265 @node Pragma Warnings
6266 @unnumberedsec Pragma Warnings
6267 @findex Warnings
6268 @noindent
6269 Syntax:
6270
6271 @smallexample @c ada
6272 pragma Warnings (On | Off);
6273 pragma Warnings (On | Off, LOCAL_NAME);
6274 pragma Warnings (static_string_EXPRESSION);
6275 pragma Warnings (On | Off, static_string_EXPRESSION);
6276 @end smallexample
6277
6278 @noindent
6279 Normally warnings are enabled, with the output being controlled by
6280 the command line switch. Warnings (@code{Off}) turns off generation of
6281 warnings until a Warnings (@code{On}) is encountered or the end of the
6282 current unit. If generation of warnings is turned off using this
6283 pragma, then no warning messages are output, regardless of the
6284 setting of the command line switches.
6285
6286 The form with a single argument may be used as a configuration pragma.
6287
6288 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
6289 the specified entity. This suppression is effective from the point where
6290 it occurs till the end of the extended scope of the variable (similar to
6291 the scope of @code{Suppress}).
6292
6293 The form with a single static_string_EXPRESSION argument provides more precise
6294 control over which warnings are active. The string is a list of letters
6295 specifying which warnings are to be activated and which deactivated. The
6296 code for these letters is the same as the string used in the command
6297 line switch controlling warnings. For a brief summary, use the gnatmake
6298 command with no arguments, which will generate usage information containing
6299 the list of warnings switches supported. For
6300 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
6301 User's Guide}.
6302
6303 @noindent
6304 The warnings controlled by the `-gnatw' switch are generated by the front end
6305 of the compiler. The `GCC' back end can provide additional warnings and they
6306 are controlled by the `-W' switch.
6307 The form with a single static_string_EXPRESSION argument also works for the
6308 latters, but the string must be a single full `-W' switch in this case.
6309 The above reference lists a few examples of these additional warnings.
6310
6311 @noindent
6312 The specified warnings will be in effect until the end of the program
6313 or another pragma Warnings is encountered. The effect of the pragma is
6314 cumulative. Initially the set of warnings is the standard default set
6315 as possibly modified by compiler switches. Then each pragma Warning
6316 modifies this set of warnings as specified. This form of the pragma may
6317 also be used as a configuration pragma.
6318
6319 The fourth form, with an @code{On|Off} parameter and a string, is used to
6320 control individual messages, based on their text. The string argument
6321 is a pattern that is used to match against the text of individual
6322 warning messages (not including the initial "warning: " tag).
6323
6324 The pattern may contain asterisks, which match zero or more characters in
6325 the message. For example, you can use
6326 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
6327 message @code{warning: 960 bits of "a" unused}. No other regular
6328 expression notations are permitted. All characters other than asterisk in
6329 these three specific cases are treated as literal characters in the match.
6330
6331 The above use of patterns to match the message applies only to warning
6332 messages generated by the front end. This form of the pragma with a
6333 string argument can also be used to control back end warnings controlled
6334 by a "-Wxxx" switch. Such warnings can be identified by the appearence
6335 of a string of the form "[-Wxxx]" in the message which identifies the
6336 "-W" switch that controls the message. By using the text of the
6337 "-W" switch in the pragma, such back end warnings can be turned on and off.
6338
6339 There are two ways to use the pragma in this form. The OFF form can be used as a
6340 configuration pragma. The effect is to suppress all warnings (if any)
6341 that match the pattern string throughout the compilation (or match the
6342 -W switch in the back end case).
6343
6344 The second usage is to suppress a warning locally, and in this case, two
6345 pragmas must appear in sequence:
6346
6347 @smallexample @c ada
6348 pragma Warnings (Off, Pattern);
6349 @dots{} code where given warning is to be suppressed
6350 pragma Warnings (On, Pattern);
6351 @end smallexample
6352
6353 @noindent
6354 In this usage, the pattern string must match in the Off and On pragmas,
6355 and at least one matching warning must be suppressed.
6356
6357 Note: to write a string that will match any warning, use the string
6358 @code{"***"}. It will not work to use a single asterisk or two asterisks
6359 since this looks like an operator name. This form with three asterisks
6360 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
6361 matching @code{pragma Warnings (On, "***")} will be required. This can be
6362 helpful in avoiding forgetting to turn warnings back on.
6363
6364 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
6365 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
6366 be useful in checking whether obsolete pragmas in existing programs are hiding
6367 real problems.
6368
6369 Note: pragma Warnings does not affect the processing of style messages. See
6370 separate entry for pragma Style_Checks for control of style messages.
6371
6372 @node Pragma Weak_External
6373 @unnumberedsec Pragma Weak_External
6374 @findex Weak_External
6375 @noindent
6376 Syntax:
6377
6378 @smallexample @c ada
6379 pragma Weak_External ([Entity =>] LOCAL_NAME);
6380 @end smallexample
6381
6382 @noindent
6383 @var{LOCAL_NAME} must refer to an object that is declared at the library
6384 level. This pragma specifies that the given entity should be marked as a
6385 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
6386 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
6387 of a regular symbol, that is to say a symbol that does not have to be
6388 resolved by the linker if used in conjunction with a pragma Import.
6389
6390 When a weak symbol is not resolved by the linker, its address is set to
6391 zero. This is useful in writing interfaces to external modules that may
6392 or may not be linked in the final executable, for example depending on
6393 configuration settings.
6394
6395 If a program references at run time an entity to which this pragma has been
6396 applied, and the corresponding symbol was not resolved at link time, then
6397 the execution of the program is erroneous. It is not erroneous to take the
6398 Address of such an entity, for example to guard potential references,
6399 as shown in the example below.
6400
6401 Some file formats do not support weak symbols so not all target machines
6402 support this pragma.
6403
6404 @smallexample @c ada
6405 -- Example of the use of pragma Weak_External
6406
6407 package External_Module is
6408 key : Integer;
6409 pragma Import (C, key);
6410 pragma Weak_External (key);
6411 function Present return boolean;
6412 end External_Module;
6413
6414 with System; use System;
6415 package body External_Module is
6416 function Present return boolean is
6417 begin
6418 return key'Address /= System.Null_Address;
6419 end Present;
6420 end External_Module;
6421 @end smallexample
6422
6423 @node Pragma Wide_Character_Encoding
6424 @unnumberedsec Pragma Wide_Character_Encoding
6425 @findex Wide_Character_Encoding
6426 @noindent
6427 Syntax:
6428
6429 @smallexample @c ada
6430 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
6431 @end smallexample
6432
6433 @noindent
6434 This pragma specifies the wide character encoding to be used in program
6435 source text appearing subsequently. It is a configuration pragma, but may
6436 also be used at any point that a pragma is allowed, and it is permissible
6437 to have more than one such pragma in a file, allowing multiple encodings
6438 to appear within the same file.
6439
6440 The argument can be an identifier or a character literal. In the identifier
6441 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
6442 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
6443 case it is correspondingly one of the characters @samp{h}, @samp{u},
6444 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
6445
6446 Note that when the pragma is used within a file, it affects only the
6447 encoding within that file, and does not affect withed units, specs,
6448 or subunits.
6449
6450 @node Implementation Defined Attributes
6451 @chapter Implementation Defined Attributes
6452 Ada defines (throughout the Ada reference manual,
6453 summarized in Annex K),
6454 a set of attributes that provide useful additional functionality in all
6455 areas of the language. These language defined attributes are implemented
6456 in GNAT and work as described in the Ada Reference Manual.
6457
6458 In addition, Ada allows implementations to define additional
6459 attributes whose meaning is defined by the implementation. GNAT provides
6460 a number of these implementation-dependent attributes which can be used
6461 to extend and enhance the functionality of the compiler. This section of
6462 the GNAT reference manual describes these additional attributes.
6463
6464 Note that any program using these attributes may not be portable to
6465 other compilers (although GNAT implements this set of attributes on all
6466 platforms). Therefore if portability to other compilers is an important
6467 consideration, you should minimize the use of these attributes.
6468
6469 @menu
6470 * Abort_Signal::
6471 * Address_Size::
6472 * Asm_Input::
6473 * Asm_Output::
6474 * AST_Entry::
6475 * Bit::
6476 * Bit_Position::
6477 * Compiler_Version::
6478 * Code_Address::
6479 * Default_Bit_Order::
6480 * Descriptor_Size::
6481 * Elaborated::
6482 * Elab_Body::
6483 * Elab_Spec::
6484 * Elab_Subp_Body::
6485 * Emax::
6486 * Enabled::
6487 * Enum_Rep::
6488 * Enum_Val::
6489 * Epsilon::
6490 * Fixed_Value::
6491 * Has_Access_Values::
6492 * Has_Discriminants::
6493 * Img::
6494 * Integer_Value::
6495 * Invalid_Value::
6496 * Large::
6497 * Machine_Size::
6498 * Mantissa::
6499 * Max_Interrupt_Priority::
6500 * Max_Priority::
6501 * Maximum_Alignment::
6502 * Mechanism_Code::
6503 * Null_Parameter::
6504 * Object_Size::
6505 * Passed_By_Reference::
6506 * Pool_Address::
6507 * Range_Length::
6508 * Ref::
6509 * Result::
6510 * Safe_Emax::
6511 * Safe_Large::
6512 * Scalar_Storage_Order::
6513 * Simple_Storage_Pool::
6514 * Small::
6515 * Storage_Unit::
6516 * Stub_Type::
6517 * System_Allocator_Alignment::
6518 * Target_Name::
6519 * Tick::
6520 * To_Address::
6521 * Type_Class::
6522 * UET_Address::
6523 * Unconstrained_Array::
6524 * Universal_Literal_String::
6525 * Unrestricted_Access::
6526 * Valid_Scalars::
6527 * VADS_Size::
6528 * Value_Size::
6529 * Wchar_T_Size::
6530 * Word_Size::
6531 @end menu
6532
6533 @node Abort_Signal
6534 @unnumberedsec Abort_Signal
6535 @findex Abort_Signal
6536 @noindent
6537 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
6538 prefix) provides the entity for the special exception used to signal
6539 task abort or asynchronous transfer of control. Normally this attribute
6540 should only be used in the tasking runtime (it is highly peculiar, and
6541 completely outside the normal semantics of Ada, for a user program to
6542 intercept the abort exception).
6543
6544 @node Address_Size
6545 @unnumberedsec Address_Size
6546 @cindex Size of @code{Address}
6547 @findex Address_Size
6548 @noindent
6549 @code{Standard'Address_Size} (@code{Standard} is the only allowed
6550 prefix) is a static constant giving the number of bits in an
6551 @code{Address}. It is the same value as System.Address'Size,
6552 but has the advantage of being static, while a direct
6553 reference to System.Address'Size is non-static because Address
6554 is a private type.
6555
6556 @node Asm_Input
6557 @unnumberedsec Asm_Input
6558 @findex Asm_Input
6559 @noindent
6560 The @code{Asm_Input} attribute denotes a function that takes two
6561 parameters. The first is a string, the second is an expression of the
6562 type designated by the prefix. The first (string) argument is required
6563 to be a static expression, and is the constraint for the parameter,
6564 (e.g.@: what kind of register is required). The second argument is the
6565 value to be used as the input argument. The possible values for the
6566 constant are the same as those used in the RTL, and are dependent on
6567 the configuration file used to built the GCC back end.
6568 @ref{Machine Code Insertions}
6569
6570 @node Asm_Output
6571 @unnumberedsec Asm_Output
6572 @findex Asm_Output
6573 @noindent
6574 The @code{Asm_Output} attribute denotes a function that takes two
6575 parameters. The first is a string, the second is the name of a variable
6576 of the type designated by the attribute prefix. The first (string)
6577 argument is required to be a static expression and designates the
6578 constraint for the parameter (e.g.@: what kind of register is
6579 required). The second argument is the variable to be updated with the
6580 result. The possible values for constraint are the same as those used in
6581 the RTL, and are dependent on the configuration file used to build the
6582 GCC back end. If there are no output operands, then this argument may
6583 either be omitted, or explicitly given as @code{No_Output_Operands}.
6584 @ref{Machine Code Insertions}
6585
6586 @node AST_Entry
6587 @unnumberedsec AST_Entry
6588 @cindex OpenVMS
6589 @findex AST_Entry
6590 @noindent
6591 This attribute is implemented only in OpenVMS versions of GNAT@. Applied to
6592 the name of an entry, it yields a value of the predefined type AST_Handler
6593 (declared in the predefined package System, as extended by the use of
6594 pragma @code{Extend_System (Aux_DEC)}). This value enables the given entry to
6595 be called when an AST occurs. For further details, refer to the @cite{DEC Ada
6596 Language Reference Manual}, section 9.12a.
6597
6598 @node Bit
6599 @unnumberedsec Bit
6600 @findex Bit
6601 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
6602 offset within the storage unit (byte) that contains the first bit of
6603 storage allocated for the object. The value of this attribute is of the
6604 type @code{Universal_Integer}, and is always a non-negative number not
6605 exceeding the value of @code{System.Storage_Unit}.
6606
6607 For an object that is a variable or a constant allocated in a register,
6608 the value is zero. (The use of this attribute does not force the
6609 allocation of a variable to memory).
6610
6611 For an object that is a formal parameter, this attribute applies
6612 to either the matching actual parameter or to a copy of the
6613 matching actual parameter.
6614
6615 For an access object the value is zero. Note that
6616 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
6617 designated object. Similarly for a record component
6618 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
6619 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
6620 are subject to index checks.
6621
6622 This attribute is designed to be compatible with the DEC Ada 83 definition
6623 and implementation of the @code{Bit} attribute.
6624
6625 @node Bit_Position
6626 @unnumberedsec Bit_Position
6627 @findex Bit_Position
6628 @noindent
6629 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
6630 of the fields of the record type, yields the bit
6631 offset within the record contains the first bit of
6632 storage allocated for the object. The value of this attribute is of the
6633 type @code{Universal_Integer}. The value depends only on the field
6634 @var{C} and is independent of the alignment of
6635 the containing record @var{R}.
6636
6637 @node Compiler_Version
6638 @unnumberedsec Compiler_Version
6639 @findex Compiler_Version
6640 @noindent
6641 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
6642 prefix) yields a static string identifying the version of the compiler
6643 being used to compile the unit containing the attribute reference. A
6644 typical result would be something like "@value{EDITION} @i{version} (20090221)".
6645
6646 @node Code_Address
6647 @unnumberedsec Code_Address
6648 @findex Code_Address
6649 @cindex Subprogram address
6650 @cindex Address of subprogram code
6651 @noindent
6652 The @code{'Address}
6653 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
6654 intended effect seems to be to provide
6655 an address value which can be used to call the subprogram by means of
6656 an address clause as in the following example:
6657
6658 @smallexample @c ada
6659 procedure K is @dots{}
6660
6661 procedure L;
6662 for L'Address use K'Address;
6663 pragma Import (Ada, L);
6664 @end smallexample
6665
6666 @noindent
6667 A call to @code{L} is then expected to result in a call to @code{K}@.
6668 In Ada 83, where there were no access-to-subprogram values, this was
6669 a common work-around for getting the effect of an indirect call.
6670 GNAT implements the above use of @code{Address} and the technique
6671 illustrated by the example code works correctly.
6672
6673 However, for some purposes, it is useful to have the address of the start
6674 of the generated code for the subprogram. On some architectures, this is
6675 not necessarily the same as the @code{Address} value described above.
6676 For example, the @code{Address} value may reference a subprogram
6677 descriptor rather than the subprogram itself.
6678
6679 The @code{'Code_Address} attribute, which can only be applied to
6680 subprogram entities, always returns the address of the start of the
6681 generated code of the specified subprogram, which may or may not be
6682 the same value as is returned by the corresponding @code{'Address}
6683 attribute.
6684
6685 @node Default_Bit_Order
6686 @unnumberedsec Default_Bit_Order
6687 @cindex Big endian
6688 @cindex Little endian
6689 @findex Default_Bit_Order
6690 @noindent
6691 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
6692 permissible prefix), provides the value @code{System.Default_Bit_Order}
6693 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
6694 @code{Low_Order_First}). This is used to construct the definition of
6695 @code{Default_Bit_Order} in package @code{System}.
6696
6697 @node Descriptor_Size
6698 @unnumberedsec Descriptor_Size
6699 @cindex Descriptor
6700 @cindex Dope vector
6701 @findex Descriptor_Size
6702 @noindent
6703 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
6704 descriptor allocated for a type. The result is non-zero only for unconstrained
6705 array types and the returned value is of type universal integer. In GNAT, an
6706 array descriptor contains bounds information and is located immediately before
6707 the first element of the array.
6708
6709 @smallexample @c ada
6710 type Unconstr_Array is array (Positive range <>) of Boolean;
6711 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
6712 @end smallexample
6713
6714 @noindent
6715 The attribute takes into account any additional padding due to type alignment.
6716 In the example above, the descriptor contains two values of type
6717 @code{Positive} representing the low and high bound. Since @code{Positive} has
6718 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
6719 Positive'Size + 2} or 64 bits.
6720
6721 @node Elaborated
6722 @unnumberedsec Elaborated
6723 @findex Elaborated
6724 @noindent
6725 The prefix of the @code{'Elaborated} attribute must be a unit name. The
6726 value is a Boolean which indicates whether or not the given unit has been
6727 elaborated. This attribute is primarily intended for internal use by the
6728 generated code for dynamic elaboration checking, but it can also be used
6729 in user programs. The value will always be True once elaboration of all
6730 units has been completed. An exception is for units which need no
6731 elaboration, the value is always False for such units.
6732
6733 @node Elab_Body
6734 @unnumberedsec Elab_Body
6735 @findex Elab_Body
6736 @noindent
6737 This attribute can only be applied to a program unit name. It returns
6738 the entity for the corresponding elaboration procedure for elaborating
6739 the body of the referenced unit. This is used in the main generated
6740 elaboration procedure by the binder and is not normally used in any
6741 other context. However, there may be specialized situations in which it
6742 is useful to be able to call this elaboration procedure from Ada code,
6743 e.g.@: if it is necessary to do selective re-elaboration to fix some
6744 error.
6745
6746 @node Elab_Spec
6747 @unnumberedsec Elab_Spec
6748 @findex Elab_Spec
6749 @noindent
6750 This attribute can only be applied to a program unit name. It returns
6751 the entity for the corresponding elaboration procedure for elaborating
6752 the spec of the referenced unit. This is used in the main
6753 generated elaboration procedure by the binder and is not normally used
6754 in any other context. However, there may be specialized situations in
6755 which it is useful to be able to call this elaboration procedure from
6756 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6757 some error.
6758
6759 @node Elab_Subp_Body
6760 @unnumberedsec Elab_Subp_Body
6761 @findex Elab_Subp_Body
6762 @noindent
6763 This attribute can only be applied to a library level subprogram
6764 name and is only allowed in CodePeer mode. It returns the entity
6765 for the corresponding elaboration procedure for elaborating the body
6766 of the referenced subprogram unit. This is used in the main generated
6767 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6768 otherwise.
6769
6770 @node Emax
6771 @unnumberedsec Emax
6772 @cindex Ada 83 attributes
6773 @findex Emax
6774 @noindent
6775 The @code{Emax} attribute is provided for compatibility with Ada 83. See
6776 the Ada 83 reference manual for an exact description of the semantics of
6777 this attribute.
6778
6779 @node Enabled
6780 @unnumberedsec Enabled
6781 @findex Enabled
6782 @noindent
6783 The @code{Enabled} attribute allows an application program to check at compile
6784 time to see if the designated check is currently enabled. The prefix is a
6785 simple identifier, referencing any predefined check name (other than
6786 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6787 no argument is given for the attribute, the check is for the general state
6788 of the check, if an argument is given, then it is an entity name, and the
6789 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6790 given naming the entity (if not, then the argument is ignored).
6791
6792 Note that instantiations inherit the check status at the point of the
6793 instantiation, so a useful idiom is to have a library package that
6794 introduces a check name with @code{pragma Check_Name}, and then contains
6795 generic packages or subprograms which use the @code{Enabled} attribute
6796 to see if the check is enabled. A user of this package can then issue
6797 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6798 the package or subprogram, controlling whether the check will be present.
6799
6800 @node Enum_Rep
6801 @unnumberedsec Enum_Rep
6802 @cindex Representation of enums
6803 @findex Enum_Rep
6804 @noindent
6805 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6806 function with the following spec:
6807
6808 @smallexample @c ada
6809 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6810 return @i{Universal_Integer};
6811 @end smallexample
6812
6813 @noindent
6814 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6815 enumeration type or to a non-overloaded enumeration
6816 literal. In this case @code{@var{S}'Enum_Rep} is equivalent to
6817 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6818 enumeration literal or object.
6819
6820 The function returns the representation value for the given enumeration
6821 value. This will be equal to value of the @code{Pos} attribute in the
6822 absence of an enumeration representation clause. This is a static
6823 attribute (i.e.@: the result is static if the argument is static).
6824
6825 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6826 in which case it simply returns the integer value. The reason for this
6827 is to allow it to be used for @code{(<>)} discrete formal arguments in
6828 a generic unit that can be instantiated with either enumeration types
6829 or integer types. Note that if @code{Enum_Rep} is used on a modular
6830 type whose upper bound exceeds the upper bound of the largest signed
6831 integer type, and the argument is a variable, so that the universal
6832 integer calculation is done at run time, then the call to @code{Enum_Rep}
6833 may raise @code{Constraint_Error}.
6834
6835 @node Enum_Val
6836 @unnumberedsec Enum_Val
6837 @cindex Representation of enums
6838 @findex Enum_Val
6839 @noindent
6840 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6841 function with the following spec:
6842
6843 @smallexample @c ada
6844 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6845 return @var{S}'Base};
6846 @end smallexample
6847
6848 @noindent
6849 The function returns the enumeration value whose representation matches the
6850 argument, or raises Constraint_Error if no enumeration literal of the type
6851 has the matching value.
6852 This will be equal to value of the @code{Val} attribute in the
6853 absence of an enumeration representation clause. This is a static
6854 attribute (i.e.@: the result is static if the argument is static).
6855
6856 @node Epsilon
6857 @unnumberedsec Epsilon
6858 @cindex Ada 83 attributes
6859 @findex Epsilon
6860 @noindent
6861 The @code{Epsilon} attribute is provided for compatibility with Ada 83. See
6862 the Ada 83 reference manual for an exact description of the semantics of
6863 this attribute.
6864
6865 @node Fixed_Value
6866 @unnumberedsec Fixed_Value
6867 @findex Fixed_Value
6868 @noindent
6869 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6870 function with the following specification:
6871
6872 @smallexample @c ada
6873 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6874 return @var{S};
6875 @end smallexample
6876
6877 @noindent
6878 The value returned is the fixed-point value @var{V} such that
6879
6880 @smallexample @c ada
6881 @var{V} = Arg * @var{S}'Small
6882 @end smallexample
6883
6884 @noindent
6885 The effect is thus similar to first converting the argument to the
6886 integer type used to represent @var{S}, and then doing an unchecked
6887 conversion to the fixed-point type. The difference is
6888 that there are full range checks, to ensure that the result is in range.
6889 This attribute is primarily intended for use in implementation of the
6890 input-output functions for fixed-point values.
6891
6892 @node Has_Access_Values
6893 @unnumberedsec Has_Access_Values
6894 @cindex Access values, testing for
6895 @findex Has_Access_Values
6896 @noindent
6897 The prefix of the @code{Has_Access_Values} attribute is a type. The result
6898 is a Boolean value which is True if the is an access type, or is a composite
6899 type with a component (at any nesting depth) that is an access type, and is
6900 False otherwise.
6901 The intended use of this attribute is in conjunction with generic
6902 definitions. If the attribute is applied to a generic private type, it
6903 indicates whether or not the corresponding actual type has access values.
6904
6905 @node Has_Discriminants
6906 @unnumberedsec Has_Discriminants
6907 @cindex Discriminants, testing for
6908 @findex Has_Discriminants
6909 @noindent
6910 The prefix of the @code{Has_Discriminants} attribute is a type. The result
6911 is a Boolean value which is True if the type has discriminants, and False
6912 otherwise. The intended use of this attribute is in conjunction with generic
6913 definitions. If the attribute is applied to a generic private type, it
6914 indicates whether or not the corresponding actual type has discriminants.
6915
6916 @node Img
6917 @unnumberedsec Img
6918 @findex Img
6919 @noindent
6920 The @code{Img} attribute differs from @code{Image} in that it may be
6921 applied to objects as well as types, in which case it gives the
6922 @code{Image} for the subtype of the object. This is convenient for
6923 debugging:
6924
6925 @smallexample @c ada
6926 Put_Line ("X = " & X'Img);
6927 @end smallexample
6928
6929 @noindent
6930 has the same meaning as the more verbose:
6931
6932 @smallexample @c ada
6933 Put_Line ("X = " & @var{T}'Image (X));
6934 @end smallexample
6935
6936 @noindent
6937 where @var{T} is the (sub)type of the object @code{X}.
6938
6939 @node Integer_Value
6940 @unnumberedsec Integer_Value
6941 @findex Integer_Value
6942 @noindent
6943 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6944 function with the following spec:
6945
6946 @smallexample @c ada
6947 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6948 return @var{S};
6949 @end smallexample
6950
6951 @noindent
6952 The value returned is the integer value @var{V}, such that
6953
6954 @smallexample @c ada
6955 Arg = @var{V} * @var{T}'Small
6956 @end smallexample
6957
6958 @noindent
6959 where @var{T} is the type of @code{Arg}.
6960 The effect is thus similar to first doing an unchecked conversion from
6961 the fixed-point type to its corresponding implementation type, and then
6962 converting the result to the target integer type. The difference is
6963 that there are full range checks, to ensure that the result is in range.
6964 This attribute is primarily intended for use in implementation of the
6965 standard input-output functions for fixed-point values.
6966
6967 @node Invalid_Value
6968 @unnumberedsec Invalid_Value
6969 @findex Invalid_Value
6970 @noindent
6971 For every scalar type S, S'Invalid_Value returns an undefined value of the
6972 type. If possible this value is an invalid representation for the type. The
6973 value returned is identical to the value used to initialize an otherwise
6974 uninitialized value of the type if pragma Initialize_Scalars is used,
6975 including the ability to modify the value with the binder -Sxx flag and
6976 relevant environment variables at run time.
6977
6978 @node Large
6979 @unnumberedsec Large
6980 @cindex Ada 83 attributes
6981 @findex Large
6982 @noindent
6983 The @code{Large} attribute is provided for compatibility with Ada 83. See
6984 the Ada 83 reference manual for an exact description of the semantics of
6985 this attribute.
6986
6987 @node Machine_Size
6988 @unnumberedsec Machine_Size
6989 @findex Machine_Size
6990 @noindent
6991 This attribute is identical to the @code{Object_Size} attribute. It is
6992 provided for compatibility with the DEC Ada 83 attribute of this name.
6993
6994 @node Mantissa
6995 @unnumberedsec Mantissa
6996 @cindex Ada 83 attributes
6997 @findex Mantissa
6998 @noindent
6999 The @code{Mantissa} attribute is provided for compatibility with Ada 83. See
7000 the Ada 83 reference manual for an exact description of the semantics of
7001 this attribute.
7002
7003 @node Max_Interrupt_Priority
7004 @unnumberedsec Max_Interrupt_Priority
7005 @cindex Interrupt priority, maximum
7006 @findex Max_Interrupt_Priority
7007 @noindent
7008 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
7009 permissible prefix), provides the same value as
7010 @code{System.Max_Interrupt_Priority}.
7011
7012 @node Max_Priority
7013 @unnumberedsec Max_Priority
7014 @cindex Priority, maximum
7015 @findex Max_Priority
7016 @noindent
7017 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
7018 prefix) provides the same value as @code{System.Max_Priority}.
7019
7020 @node Maximum_Alignment
7021 @unnumberedsec Maximum_Alignment
7022 @cindex Alignment, maximum
7023 @findex Maximum_Alignment
7024 @noindent
7025 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
7026 permissible prefix) provides the maximum useful alignment value for the
7027 target. This is a static value that can be used to specify the alignment
7028 for an object, guaranteeing that it is properly aligned in all
7029 cases.
7030
7031 @node Mechanism_Code
7032 @unnumberedsec Mechanism_Code
7033 @cindex Return values, passing mechanism
7034 @cindex Parameters, passing mechanism
7035 @findex Mechanism_Code
7036 @noindent
7037 @code{@var{function}'Mechanism_Code} yields an integer code for the
7038 mechanism used for the result of function, and
7039 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
7040 used for formal parameter number @var{n} (a static integer value with 1
7041 meaning the first parameter) of @var{subprogram}. The code returned is:
7042
7043 @table @asis
7044 @item 1
7045 by copy (value)
7046 @item 2
7047 by reference
7048 @item 3
7049 by descriptor (default descriptor class)
7050 @item 4
7051 by descriptor (UBS: unaligned bit string)
7052 @item 5
7053 by descriptor (UBSB: aligned bit string with arbitrary bounds)
7054 @item 6
7055 by descriptor (UBA: unaligned bit array)
7056 @item 7
7057 by descriptor (S: string, also scalar access type parameter)
7058 @item 8
7059 by descriptor (SB: string with arbitrary bounds)
7060 @item 9
7061 by descriptor (A: contiguous array)
7062 @item 10
7063 by descriptor (NCA: non-contiguous array)
7064 @end table
7065
7066 @noindent
7067 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
7068 @cindex OpenVMS
7069
7070 @node Null_Parameter
7071 @unnumberedsec Null_Parameter
7072 @cindex Zero address, passing
7073 @findex Null_Parameter
7074 @noindent
7075 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
7076 type or subtype @var{T} allocated at machine address zero. The attribute
7077 is allowed only as the default expression of a formal parameter, or as
7078 an actual expression of a subprogram call. In either case, the
7079 subprogram must be imported.
7080
7081 The identity of the object is represented by the address zero in the
7082 argument list, independent of the passing mechanism (explicit or
7083 default).
7084
7085 This capability is needed to specify that a zero address should be
7086 passed for a record or other composite object passed by reference.
7087 There is no way of indicating this without the @code{Null_Parameter}
7088 attribute.
7089
7090 @node Object_Size
7091 @unnumberedsec Object_Size
7092 @cindex Size, used for objects
7093 @findex Object_Size
7094 @noindent
7095 The size of an object is not necessarily the same as the size of the type
7096 of an object. This is because by default object sizes are increased to be
7097 a multiple of the alignment of the object. For example,
7098 @code{Natural'Size} is
7099 31, but by default objects of type @code{Natural} will have a size of 32 bits.
7100 Similarly, a record containing an integer and a character:
7101
7102 @smallexample @c ada
7103 type Rec is record
7104 I : Integer;
7105 C : Character;
7106 end record;
7107 @end smallexample
7108
7109 @noindent
7110 will have a size of 40 (that is @code{Rec'Size} will be 40). The
7111 alignment will be 4, because of the
7112 integer field, and so the default size of record objects for this type
7113 will be 64 (8 bytes).
7114
7115 @node Passed_By_Reference
7116 @unnumberedsec Passed_By_Reference
7117 @cindex Parameters, when passed by reference
7118 @findex Passed_By_Reference
7119 @noindent
7120 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
7121 a value of type @code{Boolean} value that is @code{True} if the type is
7122 normally passed by reference and @code{False} if the type is normally
7123 passed by copy in calls. For scalar types, the result is always @code{False}
7124 and is static. For non-scalar types, the result is non-static.
7125
7126 @node Pool_Address
7127 @unnumberedsec Pool_Address
7128 @cindex Parameters, when passed by reference
7129 @findex Pool_Address
7130 @noindent
7131 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
7132 of X within its storage pool. This is the same as
7133 @code{@var{X}'Address}, except that for an unconstrained array whose
7134 bounds are allocated just before the first component,
7135 @code{@var{X}'Pool_Address} returns the address of those bounds,
7136 whereas @code{@var{X}'Address} returns the address of the first
7137 component.
7138
7139 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
7140 the object is allocated'', which could be a user-defined storage pool,
7141 the global heap, on the stack, or in a static memory area. For an
7142 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
7143 what is passed to @code{Allocate} and returned from @code{Deallocate}.
7144
7145 @node Range_Length
7146 @unnumberedsec Range_Length
7147 @findex Range_Length
7148 @noindent
7149 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
7150 the number of values represented by the subtype (zero for a null
7151 range). The result is static for static subtypes. @code{Range_Length}
7152 applied to the index subtype of a one dimensional array always gives the
7153 same result as @code{Length} applied to the array itself.
7154
7155 @node Ref
7156 @unnumberedsec Ref
7157 @findex Ref
7158 @noindent
7159 The @code{System.Address'Ref}
7160 (@code{System.Address} is the only permissible prefix)
7161 denotes a function identical to
7162 @code{System.Storage_Elements.To_Address} except that
7163 it is a static attribute. See @ref{To_Address} for more details.
7164
7165 @node Result
7166 @unnumberedsec Result
7167 @findex Result
7168 @noindent
7169 @code{@var{function}'Result} can only be used with in a Postcondition pragma
7170 for a function. The prefix must be the name of the corresponding function. This
7171 is used to refer to the result of the function in the postcondition expression.
7172 For a further discussion of the use of this attribute and examples of its use,
7173 see the description of pragma Postcondition.
7174
7175 @node Safe_Emax
7176 @unnumberedsec Safe_Emax
7177 @cindex Ada 83 attributes
7178 @findex Safe_Emax
7179 @noindent
7180 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83. See
7181 the Ada 83 reference manual for an exact description of the semantics of
7182 this attribute.
7183
7184 @node Safe_Large
7185 @unnumberedsec Safe_Large
7186 @cindex Ada 83 attributes
7187 @findex Safe_Large
7188 @noindent
7189 The @code{Safe_Large} attribute is provided for compatibility with Ada 83. See
7190 the Ada 83 reference manual for an exact description of the semantics of
7191 this attribute.
7192
7193 @node Scalar_Storage_Order
7194 @unnumberedsec Scalar_Storage_Order
7195 @cindex Endianness
7196 @cindex Scalar storage order
7197 @findex Scalar_Storage_Order
7198 @noindent
7199 For every array or record type @var{S}, the representation attribute
7200 @code{Scalar_Storage_Order} denotes the order in which storage elements
7201 that make up scalar components are ordered within S:
7202
7203 @smallexample @c ada
7204 -- Component type definitions
7205
7206 subtype Yr_Type is Natural range 0 .. 127;
7207 subtype Mo_Type is Natural range 1 .. 12;
7208 subtype Da_Type is Natural range 1 .. 31;
7209
7210 -- Record declaration
7211
7212 type Date is record
7213 Years_Since_1980 : Yr_Type;
7214 Month : Mo_Type;
7215 Day_Of_Month : Da_Type;
7216 end record;
7217
7218 -- Record representation clause
7219
7220 for Date use record
7221 Years_Since_1980 at 0 range 0 .. 6;
7222 Month at 0 range 7 .. 10;
7223 Day_Of_Month at 0 range 11 .. 15;
7224 end record;
7225
7226 -- Attribute definition clauses
7227
7228 for Date'Bit_Order use System.High_Order_First;
7229 for Date'Scalar_Storage_Order use System.High_Order_First;
7230 -- If Scalar_Storage_Order is specified, it must be consistent with
7231 -- Bit_Order, so it's best to always define the latter explicitly if
7232 -- the former is used.
7233 @end smallexample
7234
7235 Other properties are
7236 as for standard representation attribute @code{Bit_Order}, as defined by
7237 Ada RM 13.5.3(4). The default is @code{System.Default_Bit_Order}.
7238
7239 For a record type @var{S}, if @code{@var{S}'Scalar_Storage_Order} is
7240 specified explicitly, it shall be equal to @code{@var{S}'Bit_Order}. Note:
7241 this means that if a @code{Scalar_Storage_Order} attribute definition
7242 clause is not confirming, then the type's @code{Bit_Order} shall be
7243 specified explicitly and set to the same value.
7244
7245 For a record extension, the derived type shall have the same scalar storage
7246 order as the parent type.
7247
7248 If a component of @var{S} has itself a record or array type, then it shall also
7249 have a @code{Scalar_Storage_Order} attribute definition clause. In addition,
7250 if the component does not start on a byte boundary, then the scalar storage
7251 order specified for S and for the nested component type shall be identical.
7252
7253 No component of a type that has a @code{Scalar_Storage_Order} attribute
7254 definition may be aliased.
7255
7256 A confirming @code{Scalar_Storage_Order} attribute definition clause (i.e.
7257 with a value equal to @code{System.Default_Bit_Order}) has no effect.
7258
7259 If the opposite storage order is specified, then whenever the value of
7260 a scalar component of an object of type @var{S} is read, the storage
7261 elements of the enclosing machine scalar are first reversed (before
7262 retrieving the component value, possibly applying some shift and mask
7263 operatings on the enclosing machine scalar), and the opposite operation
7264 is done for writes.
7265
7266 In that case, the restrictions set forth in 13.5.1(10.3/2) for scalar components
7267 are relaxed. Instead, the following rules apply:
7268
7269 @itemize @bullet
7270 @item the underlying storage elements are those at positions
7271 @code{(position + first_bit / storage_element_size) ..
7272 (position + (last_bit + storage_element_size - 1) /
7273 storage_element_size)}
7274 @item the sequence of underlying storage elements shall have
7275 a size no greater than the largest machine scalar
7276 @item the enclosing machine scalar is defined as the smallest machine
7277 scalar starting at a position no greater than
7278 @code{position + first_bit / storage_element_size} and covering
7279 storage elements at least up to @code{position + (last_bit +
7280 storage_element_size - 1) / storage_element_size}
7281 @item the position of the component is interpreted relative to that machine
7282 scalar.
7283
7284 @end itemize
7285
7286 @node Simple_Storage_Pool
7287 @unnumberedsec Simple_Storage_Pool
7288 @cindex Storage pool, simple
7289 @cindex Simple storage pool
7290 @findex Simple_Storage_Pool
7291 @noindent
7292 For every nonformal, nonderived access-to-object type @var{Acc}, the
7293 representation attribute @code{Simple_Storage_Pool} may be specified
7294 via an attribute_definition_clause (or by specifying the equivalent aspect):
7295
7296 @smallexample @c ada
7297
7298 My_Pool : My_Simple_Storage_Pool_Type;
7299
7300 type Acc is access My_Data_Type;
7301
7302 for Acc'Simple_Storage_Pool use My_Pool;
7303
7304 @end smallexample
7305
7306 @noindent
7307 The name given in an attribute_definition_clause for the
7308 @code{Simple_Storage_Pool} attribute shall denote a variable of
7309 a ``simple storage pool type'' (see pragma @code{Simple_Storage_Pool_Type}).
7310
7311 The use of this attribute is only allowed for a prefix denoting a type
7312 for which it has been specified. The type of the attribute is the type
7313 of the variable specified as the simple storage pool of the access type,
7314 and the attribute denotes that variable.
7315
7316 It is illegal to specify both @code{Storage_Pool} and @code{Simple_Storage_Pool}
7317 for the same access type.
7318
7319 If the @code{Simple_Storage_Pool} attribute has been specified for an access
7320 type, then applying the @code{Storage_Pool} attribute to the type is flagged
7321 with a warning and its evaluation raises the exception @code{Program_Error}.
7322
7323 If the Simple_Storage_Pool attribute has been specified for an access
7324 type @var{S}, then the evaluation of the attribute @code{@var{S}'Storage_Size}
7325 returns the result of calling @code{Storage_Size (@var{S}'Simple_Storage_Pool)},
7326 which is intended to indicate the number of storage elements reserved for
7327 the simple storage pool. If the Storage_Size function has not been defined
7328 for the simple storage pool type, then this attribute returns zero.
7329
7330 If an access type @var{S} has a specified simple storage pool of type
7331 @var{SSP}, then the evaluation of an allocator for that access type calls
7332 the primitive @code{Allocate} procedure for type @var{SSP}, passing
7333 @code{@var{S}'Simple_Storage_Pool} as the pool parameter. The detailed
7334 semantics of such allocators is the same as those defined for allocators
7335 in section 13.11 of the Ada Reference Manual, with the term
7336 ``simple storage pool'' substituted for ``storage pool''.
7337
7338 If an access type @var{S} has a specified simple storage pool of type
7339 @var{SSP}, then a call to an instance of the @code{Ada.Unchecked_Deallocation}
7340 for that access type invokes the primitive @code{Deallocate} procedure
7341 for type @var{SSP}, passing @code{@var{S}'Simple_Storage_Pool} as the pool
7342 parameter. The detailed semantics of such unchecked deallocations is the same
7343 as defined in section 13.11.2 of the Ada Reference Manual, except that the
7344 term ``simple storage pool'' is substituted for ``storage pool''.
7345
7346 @node Small
7347 @unnumberedsec Small
7348 @cindex Ada 83 attributes
7349 @findex Small
7350 @noindent
7351 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
7352 fixed-point types.
7353 GNAT also allows this attribute to be applied to floating-point types
7354 for compatibility with Ada 83. See
7355 the Ada 83 reference manual for an exact description of the semantics of
7356 this attribute when applied to floating-point types.
7357
7358 @node Storage_Unit
7359 @unnumberedsec Storage_Unit
7360 @findex Storage_Unit
7361 @noindent
7362 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
7363 prefix) provides the same value as @code{System.Storage_Unit}.
7364
7365 @node Stub_Type
7366 @unnumberedsec Stub_Type
7367 @findex Stub_Type
7368 @noindent
7369 The GNAT implementation of remote access-to-classwide types is
7370 organized as described in AARM section E.4 (20.t): a value of an RACW type
7371 (designating a remote object) is represented as a normal access
7372 value, pointing to a "stub" object which in turn contains the
7373 necessary information to contact the designated remote object. A
7374 call on any dispatching operation of such a stub object does the
7375 remote call, if necessary, using the information in the stub object
7376 to locate the target partition, etc.
7377
7378 For a prefix @code{T} that denotes a remote access-to-classwide type,
7379 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
7380
7381 By construction, the layout of @code{T'Stub_Type} is identical to that of
7382 type @code{RACW_Stub_Type} declared in the internal implementation-defined
7383 unit @code{System.Partition_Interface}. Use of this attribute will create
7384 an implicit dependency on this unit.
7385
7386 @node System_Allocator_Alignment
7387 @unnumberedsec System_Allocator_Alignment
7388 @cindex Alignment, allocator
7389 @findex System_Allocator_Alignment
7390 @noindent
7391 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
7392 permissible prefix) provides the observable guaranted to be honored by
7393 the system allocator (malloc). This is a static value that can be used
7394 in user storage pools based on malloc either to reject allocation
7395 with alignment too large or to enable a realignment circuitry if the
7396 alignment request is larger than this value.
7397
7398 @node Target_Name
7399 @unnumberedsec Target_Name
7400 @findex Target_Name
7401 @noindent
7402 @code{Standard'Target_Name} (@code{Standard} is the only permissible
7403 prefix) provides a static string value that identifies the target
7404 for the current compilation. For GCC implementations, this is the
7405 standard gcc target name without the terminating slash (for
7406 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
7407
7408 @node Tick
7409 @unnumberedsec Tick
7410 @findex Tick
7411 @noindent
7412 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
7413 provides the same value as @code{System.Tick},
7414
7415 @node To_Address
7416 @unnumberedsec To_Address
7417 @findex To_Address
7418 @noindent
7419 The @code{System'To_Address}
7420 (@code{System} is the only permissible prefix)
7421 denotes a function identical to
7422 @code{System.Storage_Elements.To_Address} except that
7423 it is a static attribute. This means that if its argument is
7424 a static expression, then the result of the attribute is a
7425 static expression. The result is that such an expression can be
7426 used in contexts (e.g.@: preelaborable packages) which require a
7427 static expression and where the function call could not be used
7428 (since the function call is always non-static, even if its
7429 argument is static).
7430
7431 @node Type_Class
7432 @unnumberedsec Type_Class
7433 @findex Type_Class
7434 @noindent
7435 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
7436 the value of the type class for the full type of @var{type}. If
7437 @var{type} is a generic formal type, the value is the value for the
7438 corresponding actual subtype. The value of this attribute is of type
7439 @code{System.Aux_DEC.Type_Class}, which has the following definition:
7440
7441 @smallexample @c ada
7442 type Type_Class is
7443 (Type_Class_Enumeration,
7444 Type_Class_Integer,
7445 Type_Class_Fixed_Point,
7446 Type_Class_Floating_Point,
7447 Type_Class_Array,
7448 Type_Class_Record,
7449 Type_Class_Access,
7450 Type_Class_Task,
7451 Type_Class_Address);
7452 @end smallexample
7453
7454 @noindent
7455 Protected types yield the value @code{Type_Class_Task}, which thus
7456 applies to all concurrent types. This attribute is designed to
7457 be compatible with the DEC Ada 83 attribute of the same name.
7458
7459 @node UET_Address
7460 @unnumberedsec UET_Address
7461 @findex UET_Address
7462 @noindent
7463 The @code{UET_Address} attribute can only be used for a prefix which
7464 denotes a library package. It yields the address of the unit exception
7465 table when zero cost exception handling is used. This attribute is
7466 intended only for use within the GNAT implementation. See the unit
7467 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
7468 for details on how this attribute is used in the implementation.
7469
7470 @node Unconstrained_Array
7471 @unnumberedsec Unconstrained_Array
7472 @findex Unconstrained_Array
7473 @noindent
7474 The @code{Unconstrained_Array} attribute can be used with a prefix that
7475 denotes any type or subtype. It is a static attribute that yields
7476 @code{True} if the prefix designates an unconstrained array,
7477 and @code{False} otherwise. In a generic instance, the result is
7478 still static, and yields the result of applying this test to the
7479 generic actual.
7480
7481 @node Universal_Literal_String
7482 @unnumberedsec Universal_Literal_String
7483 @cindex Named numbers, representation of
7484 @findex Universal_Literal_String
7485 @noindent
7486 The prefix of @code{Universal_Literal_String} must be a named
7487 number. The static result is the string consisting of the characters of
7488 the number as defined in the original source. This allows the user
7489 program to access the actual text of named numbers without intermediate
7490 conversions and without the need to enclose the strings in quotes (which
7491 would preclude their use as numbers).
7492
7493 For example, the following program prints the first 50 digits of pi:
7494
7495 @smallexample @c ada
7496 with Text_IO; use Text_IO;
7497 with Ada.Numerics;
7498 procedure Pi is
7499 begin
7500 Put (Ada.Numerics.Pi'Universal_Literal_String);
7501 end;
7502 @end smallexample
7503
7504 @node Unrestricted_Access
7505 @unnumberedsec Unrestricted_Access
7506 @cindex @code{Access}, unrestricted
7507 @findex Unrestricted_Access
7508 @noindent
7509 The @code{Unrestricted_Access} attribute is similar to @code{Access}
7510 except that all accessibility and aliased view checks are omitted. This
7511 is a user-beware attribute. It is similar to
7512 @code{Address}, for which it is a desirable replacement where the value
7513 desired is an access type. In other words, its effect is identical to
7514 first applying the @code{Address} attribute and then doing an unchecked
7515 conversion to a desired access type. In GNAT, but not necessarily in
7516 other implementations, the use of static chains for inner level
7517 subprograms means that @code{Unrestricted_Access} applied to a
7518 subprogram yields a value that can be called as long as the subprogram
7519 is in scope (normal Ada accessibility rules restrict this usage).
7520
7521 It is possible to use @code{Unrestricted_Access} for any type, but care
7522 must be exercised if it is used to create pointers to unconstrained
7523 objects. In this case, the resulting pointer has the same scope as the
7524 context of the attribute, and may not be returned to some enclosing
7525 scope. For instance, a function cannot use @code{Unrestricted_Access}
7526 to create a unconstrained pointer and then return that value to the
7527 caller.
7528
7529 @node Valid_Scalars
7530 @unnumberedsec Valid_Scalars
7531 @findex Valid_Scalars
7532 @noindent
7533 The @code{'Valid_Scalars} attribute is intended to make it easier to
7534 check the validity of scalar subcomponents of composite objects. It
7535 is defined for any prefix @code{X} that denotes an object.
7536 The value of this attribute is of the predefined type Boolean.
7537 @code{X'Valid_Scalars} yields True if and only if evaluation of
7538 @code{P'Valid} yields True for every scalar part P of X or if X has
7539 no scalar parts. It is not specified in what order the scalar parts
7540 are checked, nor whether any more are checked after any one of them
7541 is determined to be invalid. If the prefix @code{X} is of a class-wide
7542 type @code{T'Class} (where @code{T} is the associated specific type),
7543 or if the prefix @code{X} is of a specific tagged type @code{T}, then
7544 only the scalar parts of components of @code{T} are traversed; in other
7545 words, components of extensions of @code{T} are not traversed even if
7546 @code{T'Class (X)'Tag /= T'Tag} . The compiler will issue a warning if it can
7547 be determined at compile time that the prefix of the attribute has no
7548 scalar parts (e.g., if the prefix is of an access type, an interface type,
7549 an undiscriminated task type, or an undiscriminated protected type).
7550
7551 @node VADS_Size
7552 @unnumberedsec VADS_Size
7553 @cindex @code{Size}, VADS compatibility
7554 @findex VADS_Size
7555 @noindent
7556 The @code{'VADS_Size} attribute is intended to make it easier to port
7557 legacy code which relies on the semantics of @code{'Size} as implemented
7558 by the VADS Ada 83 compiler. GNAT makes a best effort at duplicating the
7559 same semantic interpretation. In particular, @code{'VADS_Size} applied
7560 to a predefined or other primitive type with no Size clause yields the
7561 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
7562 typical machines). In addition @code{'VADS_Size} applied to an object
7563 gives the result that would be obtained by applying the attribute to
7564 the corresponding type.
7565
7566 @node Value_Size
7567 @unnumberedsec Value_Size
7568 @cindex @code{Size}, setting for not-first subtype
7569 @findex Value_Size
7570 @code{@var{type}'Value_Size} is the number of bits required to represent
7571 a value of the given subtype. It is the same as @code{@var{type}'Size},
7572 but, unlike @code{Size}, may be set for non-first subtypes.
7573
7574 @node Wchar_T_Size
7575 @unnumberedsec Wchar_T_Size
7576 @findex Wchar_T_Size
7577 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
7578 prefix) provides the size in bits of the C @code{wchar_t} type
7579 primarily for constructing the definition of this type in
7580 package @code{Interfaces.C}.
7581
7582 @node Word_Size
7583 @unnumberedsec Word_Size
7584 @findex Word_Size
7585 @code{Standard'Word_Size} (@code{Standard} is the only permissible
7586 prefix) provides the value @code{System.Word_Size}.
7587
7588 @node Standard and Implementation Defined Restrictions
7589 @chapter Standard and Implementation Defined Restrictions
7590
7591 @noindent
7592 All RM defined Restriction identifiers are implemented:
7593
7594 @itemize @bullet
7595 @item language-defined restrictions (see 13.12.1)
7596 @item tasking restrictions (see D.7)
7597 @item high integrity restrictions (see H.4)
7598 @end itemize
7599
7600 @noindent
7601 GNAT implements additional restriction identifiers. All restrictions, whether
7602 language defined or GNAT-specific, are listed in the following.
7603
7604 @menu
7605 * Partition-Wide Restrictions::
7606 * Program Unit Level Restrictions::
7607 @end menu
7608
7609 @node Partition-Wide Restrictions
7610 @section Partition-Wide Restrictions
7611
7612 There are two separate lists of restriction identifiers. The first
7613 set requires consistency throughout a partition (in other words, if the
7614 restriction identifier is used for any compilation unit in the partition,
7615 then all compilation units in the partition must obey the restriction).
7616
7617 @menu
7618 * Immediate_Reclamation::
7619 * Max_Asynchronous_Select_Nesting::
7620 * Max_Entry_Queue_Length::
7621 * Max_Protected_Entries::
7622 * Max_Select_Alternatives::
7623 * Max_Storage_At_Blocking::
7624 * Max_Task_Entries::
7625 * Max_Tasks::
7626 * No_Abort_Statements::
7627 * No_Access_Parameter_Allocators::
7628 * No_Access_Subprograms::
7629 * No_Allocators::
7630 * No_Anonymous_Allocators::
7631 * No_Calendar::
7632 * No_Coextensions::
7633 * No_Default_Initialization::
7634 * No_Delay::
7635 * No_Dependence::
7636 * No_Direct_Boolean_Operators::
7637 * No_Dispatch::
7638 * No_Dispatching_Calls::
7639 * No_Dynamic_Attachment::
7640 * No_Dynamic_Priorities::
7641 * No_Entry_Calls_In_Elaboration_Code::
7642 * No_Enumeration_Maps::
7643 * No_Exception_Handlers::
7644 * No_Exception_Propagation::
7645 * No_Exception_Registration::
7646 * No_Exceptions::
7647 * No_Finalization::
7648 * No_Fixed_Point::
7649 * No_Floating_Point::
7650 * No_Implicit_Conditionals::
7651 * No_Implicit_Dynamic_Code::
7652 * No_Implicit_Heap_Allocations::
7653 * No_Implicit_Loops::
7654 * No_Initialize_Scalars::
7655 * No_IO::
7656 * No_Local_Allocators::
7657 * No_Local_Protected_Objects::
7658 * No_Local_Timing_Events::
7659 * No_Nested_Finalization::
7660 * No_Protected_Type_Allocators::
7661 * No_Protected_Types::
7662 * No_Recursion::
7663 * No_Reentrancy::
7664 * No_Relative_Delay::
7665 * No_Requeue_Statements::
7666 * No_Secondary_Stack::
7667 * No_Select_Statements::
7668 * No_Specific_Termination_Handlers::
7669 * No_Specification_of_Aspect::
7670 * No_Standard_Allocators_After_Elaboration::
7671 * No_Standard_Storage_Pools::
7672 * No_Stream_Optimizations::
7673 * No_Streams::
7674 * No_Task_Allocators::
7675 * No_Task_Attributes_Package::
7676 * No_Task_Hierarchy::
7677 * No_Task_Termination::
7678 * No_Tasking::
7679 * No_Terminate_Alternatives::
7680 * No_Unchecked_Access::
7681 * Simple_Barriers::
7682 * Static_Priorities::
7683 * Static_Storage_Size::
7684 @end menu
7685
7686 @node Immediate_Reclamation
7687 @unnumberedsubsec Immediate_Reclamation
7688 @findex Immediate_Reclamation
7689 [RM H.4] This restriction ensures that, except for storage occupied by
7690 objects created by allocators and not deallocated via unchecked
7691 deallocation, any storage reserved at run time for an object is
7692 immediately reclaimed when the object no longer exists.
7693
7694 @node Max_Asynchronous_Select_Nesting
7695 @unnumberedsubsec Max_Asynchronous_Select_Nesting
7696 @findex Max_Asynchronous_Select_Nesting
7697 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous
7698 selects. Violations of this restriction with a value of zero are
7699 detected at compile time. Violations of this restriction with values
7700 other than zero cause Storage_Error to be raised.
7701
7702 @node Max_Entry_Queue_Length
7703 @unnumberedsubsec Max_Entry_Queue_Length
7704 @findex Max_Entry_Queue_Length
7705 [RM D.7] This restriction is a declaration that any protected entry compiled in
7706 the scope of the restriction has at most the specified number of
7707 tasks waiting on the entry at any one time, and so no queue is required.
7708 Note that this restriction is checked at run time. Violation of this
7709 restriction results in the raising of Program_Error exception at the point of
7710 the call.
7711
7712 @node Max_Protected_Entries
7713 @unnumberedsubsec Max_Protected_Entries
7714 @findex Max_Protected_Entries
7715 [RM D.7] Specifies the maximum number of entries per protected type. The
7716 bounds of every entry family of a protected unit shall be static, or shall be
7717 defined by a discriminant of a subtype whose corresponding bound is static.
7718
7719 @node Max_Select_Alternatives
7720 @unnumberedsubsec Max_Select_Alternatives
7721 @findex Max_Select_Alternatives
7722 [RM D.7] Specifies the maximum number of alternatives in a selective accept.
7723
7724 @node Max_Storage_At_Blocking
7725 @unnumberedsubsec Max_Storage_At_Blocking
7726 @findex Max_Storage_At_Blocking
7727 [RM D.7] Specifies the maximum portion (in storage elements) of a task's
7728 Storage_Size that can be retained by a blocked task. A violation of this
7729 restriction causes Storage_Error to be raised.
7730
7731 @node Max_Task_Entries
7732 @unnumberedsubsec Max_Task_Entries
7733 @findex Max_Task_Entries
7734 [RM D.7] Specifies the maximum number of entries
7735 per task. The bounds of every entry family
7736 of a task unit shall be static, or shall be
7737 defined by a discriminant of a subtype whose
7738 corresponding bound is static.
7739
7740 @node Max_Tasks
7741 @unnumberedsubsec Max_Tasks
7742 @findex Max_Tasks
7743 [RM D.7] Specifies the maximum number of task that may be created, not
7744 counting the creation of the environment task. Violations of this
7745 restriction with a value of zero are detected at compile
7746 time. Violations of this restriction with values other than zero cause
7747 Storage_Error to be raised.
7748
7749 @node No_Abort_Statements
7750 @unnumberedsubsec No_Abort_Statements
7751 @findex No_Abort_Statements
7752 [RM D.7] There are no abort_statements, and there are
7753 no calls to Task_Identification.Abort_Task.
7754
7755 @node No_Access_Parameter_Allocators
7756 @unnumberedsubsec No_Access_Parameter_Allocators
7757 @findex No_Access_Parameter_Allocators
7758 [RM H.4] This restriction ensures at compile time that there are no
7759 occurrences of an allocator as the actual parameter to an access
7760 parameter.
7761
7762 @node No_Access_Subprograms
7763 @unnumberedsubsec No_Access_Subprograms
7764 @findex No_Access_Subprograms
7765 [RM H.4] This restriction ensures at compile time that there are no
7766 declarations of access-to-subprogram types.
7767
7768 @node No_Allocators
7769 @unnumberedsubsec No_Allocators
7770 @findex No_Allocators
7771 [RM H.4] This restriction ensures at compile time that there are no
7772 occurrences of an allocator.
7773
7774 @node No_Anonymous_Allocators
7775 @unnumberedsubsec No_Anonymous_Allocators
7776 @findex No_Anonymous_Allocators
7777 [RM H.4] This restriction ensures at compile time that there are no
7778 occurrences of an allocator of anonymous access type.
7779
7780 @node No_Calendar
7781 @unnumberedsubsec No_Calendar
7782 @findex No_Calendar
7783 [GNAT] This restriction ensures at compile time that there is no implicit or
7784 explicit dependence on the package @code{Ada.Calendar}.
7785
7786 @node No_Coextensions
7787 @unnumberedsubsec No_Coextensions
7788 @findex No_Coextensions
7789 [RM H.4] This restriction ensures at compile time that there are no
7790 coextensions. See 3.10.2.
7791
7792 @node No_Default_Initialization
7793 @unnumberedsubsec No_Default_Initialization
7794 @findex No_Default_Initialization
7795
7796 [GNAT] This restriction prohibits any instance of default initialization
7797 of variables. The binder implements a consistency rule which prevents
7798 any unit compiled without the restriction from with'ing a unit with the
7799 restriction (this allows the generation of initialization procedures to
7800 be skipped, since you can be sure that no call is ever generated to an
7801 initialization procedure in a unit with the restriction active). If used
7802 in conjunction with Initialize_Scalars or Normalize_Scalars, the effect
7803 is to prohibit all cases of variables declared without a specific
7804 initializer (including the case of OUT scalar parameters).
7805
7806 @node No_Delay
7807 @unnumberedsubsec No_Delay
7808 @findex No_Delay
7809 [RM H.4] This restriction ensures at compile time that there are no
7810 delay statements and no dependences on package Calendar.
7811
7812 @node No_Dependence
7813 @unnumberedsubsec No_Dependence
7814 @findex No_Dependence
7815 [RM 13.12.1] This restriction checks at compile time that there are no
7816 dependence on a library unit.
7817
7818 @node No_Direct_Boolean_Operators
7819 @unnumberedsubsec No_Direct_Boolean_Operators
7820 @findex No_Direct_Boolean_Operators
7821 [GNAT] This restriction ensures that no logical (and/or/xor) are used on
7822 operands of type Boolean (or any type derived
7823 from Boolean). This is intended for use in safety critical programs
7824 where the certification protocol requires the use of short-circuit
7825 (and then, or else) forms for all composite boolean operations.
7826
7827 @node No_Dispatch
7828 @unnumberedsubsec No_Dispatch
7829 @findex No_Dispatch
7830 [RM H.4] This restriction ensures at compile time that there are no
7831 occurrences of @code{T'Class}, for any (tagged) subtype @code{T}.
7832
7833 @node No_Dispatching_Calls
7834 @unnumberedsubsec No_Dispatching_Calls
7835 @findex No_Dispatching_Calls
7836 [GNAT] This restriction ensures at compile time that the code generated by the
7837 compiler involves no dispatching calls. The use of this restriction allows the
7838 safe use of record extensions, classwide membership tests and other classwide
7839 features not involving implicit dispatching. This restriction ensures that
7840 the code contains no indirect calls through a dispatching mechanism. Note that
7841 this includes internally-generated calls created by the compiler, for example
7842 in the implementation of class-wide objects assignments. The
7843 membership test is allowed in the presence of this restriction, because its
7844 implementation requires no dispatching.
7845 This restriction is comparable to the official Ada restriction
7846 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7847 all classwide constructs that do not imply dispatching.
7848 The following example indicates constructs that violate this restriction.
7849
7850 @smallexample
7851 package Pkg is
7852 type T is tagged record
7853 Data : Natural;
7854 end record;
7855 procedure P (X : T);
7856
7857 type DT is new T with record
7858 More_Data : Natural;
7859 end record;
7860 procedure Q (X : DT);
7861 end Pkg;
7862
7863 with Pkg; use Pkg;
7864 procedure Example is
7865 procedure Test (O : T'Class) is
7866 N : Natural := O'Size;-- Error: Dispatching call
7867 C : T'Class := O; -- Error: implicit Dispatching Call
7868 begin
7869 if O in DT'Class then -- OK : Membership test
7870 Q (DT (O)); -- OK : Type conversion plus direct call
7871 else
7872 P (O); -- Error: Dispatching call
7873 end if;
7874 end Test;
7875
7876 Obj : DT;
7877 begin
7878 P (Obj); -- OK : Direct call
7879 P (T (Obj)); -- OK : Type conversion plus direct call
7880 P (T'Class (Obj)); -- Error: Dispatching call
7881
7882 Test (Obj); -- OK : Type conversion
7883
7884 if Obj in T'Class then -- OK : Membership test
7885 null;
7886 end if;
7887 end Example;
7888 @end smallexample
7889
7890 @node No_Dynamic_Attachment
7891 @unnumberedsubsec No_Dynamic_Attachment
7892 @findex No_Dynamic_Attachment
7893 [RM D.7] This restriction ensures that there is no call to any of the
7894 operations defined in package Ada.Interrupts
7895 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
7896 Detach_Handler, and Reference).
7897
7898 @node No_Dynamic_Priorities
7899 @unnumberedsubsec No_Dynamic_Priorities
7900 @findex No_Dynamic_Priorities
7901 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
7902
7903 @node No_Entry_Calls_In_Elaboration_Code
7904 @unnumberedsubsec No_Entry_Calls_In_Elaboration_Code
7905 @findex No_Entry_Calls_In_Elaboration_Code
7906 [GNAT] This restriction ensures at compile time that no task or protected entry
7907 calls are made during elaboration code. As a result of the use of this
7908 restriction, the compiler can assume that no code past an accept statement
7909 in a task can be executed at elaboration time.
7910
7911 @node No_Enumeration_Maps
7912 @unnumberedsubsec No_Enumeration_Maps
7913 @findex No_Enumeration_Maps
7914 [GNAT] This restriction ensures at compile time that no operations requiring
7915 enumeration maps are used (that is Image and Value attributes applied
7916 to enumeration types).
7917
7918 @node No_Exception_Handlers
7919 @unnumberedsubsec No_Exception_Handlers
7920 @findex No_Exception_Handlers
7921 [GNAT] This restriction ensures at compile time that there are no explicit
7922 exception handlers. It also indicates that no exception propagation will
7923 be provided. In this mode, exceptions may be raised but will result in
7924 an immediate call to the last chance handler, a routine that the user
7925 must define with the following profile:
7926
7927 @smallexample @c ada
7928 procedure Last_Chance_Handler
7929 (Source_Location : System.Address; Line : Integer);
7930 pragma Export (C, Last_Chance_Handler,
7931 "__gnat_last_chance_handler");
7932 @end smallexample
7933
7934 The parameter is a C null-terminated string representing a message to be
7935 associated with the exception (typically the source location of the raise
7936 statement generated by the compiler). The Line parameter when nonzero
7937 represents the line number in the source program where the raise occurs.
7938
7939 @node No_Exception_Propagation
7940 @unnumberedsubsec No_Exception_Propagation
7941 @findex No_Exception_Propagation
7942 [GNAT] This restriction guarantees that exceptions are never propagated
7943 to an outer subprogram scope. The only case in which an exception may
7944 be raised is when the handler is statically in the same subprogram, so
7945 that the effect of a raise is essentially like a goto statement. Any
7946 other raise statement (implicit or explicit) will be considered
7947 unhandled. Exception handlers are allowed, but may not contain an
7948 exception occurrence identifier (exception choice). In addition, use of
7949 the package GNAT.Current_Exception is not permitted, and reraise
7950 statements (raise with no operand) are not permitted.
7951
7952 @node No_Exception_Registration
7953 @unnumberedsubsec No_Exception_Registration
7954 @findex No_Exception_Registration
7955 [GNAT] This restriction ensures at compile time that no stream operations for
7956 types Exception_Id or Exception_Occurrence are used. This also makes it
7957 impossible to pass exceptions to or from a partition with this restriction
7958 in a distributed environment. If this exception is active, then the generated
7959 code is simplified by omitting the otherwise-required global registration
7960 of exceptions when they are declared.
7961
7962 @node No_Exceptions
7963 @unnumberedsubsec No_Exceptions
7964 @findex No_Exceptions
7965 [RM H.4] This restriction ensures at compile time that there are no
7966 raise statements and no exception handlers.
7967
7968 @node No_Finalization
7969 @unnumberedsubsec No_Finalization
7970 @findex No_Finalization
7971 [GNAT] This restriction disables the language features described in
7972 chapter 7.6 of the Ada 2005 RM as well as all form of code generation
7973 performed by the compiler to support these features. The following types
7974 are no longer considered controlled when this restriction is in effect:
7975 @itemize @bullet
7976 @item
7977 @code{Ada.Finalization.Controlled}
7978 @item
7979 @code{Ada.Finalization.Limited_Controlled}
7980 @item
7981 Derivations from @code{Controlled} or @code{Limited_Controlled}
7982 @item
7983 Class-wide types
7984 @item
7985 Protected types
7986 @item
7987 Task types
7988 @item
7989 Array and record types with controlled components
7990 @end itemize
7991 The compiler no longer generates code to initialize, finalize or adjust an
7992 object or a nested component, either declared on the stack or on the heap. The
7993 deallocation of a controlled object no longer finalizes its contents.
7994
7995 @node No_Fixed_Point
7996 @unnumberedsubsec No_Fixed_Point
7997 @findex No_Fixed_Point
7998 [RM H.4] This restriction ensures at compile time that there are no
7999 occurrences of fixed point types and operations.
8000
8001 @node No_Floating_Point
8002 @unnumberedsubsec No_Floating_Point
8003 @findex No_Floating_Point
8004 [RM H.4] This restriction ensures at compile time that there are no
8005 occurrences of floating point types and operations.
8006
8007 @node No_Implicit_Conditionals
8008 @unnumberedsubsec No_Implicit_Conditionals
8009 @findex No_Implicit_Conditionals
8010 [GNAT] This restriction ensures that the generated code does not contain any
8011 implicit conditionals, either by modifying the generated code where possible,
8012 or by rejecting any construct that would otherwise generate an implicit
8013 conditional. Note that this check does not include run time constraint
8014 checks, which on some targets may generate implicit conditionals as
8015 well. To control the latter, constraint checks can be suppressed in the
8016 normal manner. Constructs generating implicit conditionals include comparisons
8017 of composite objects and the Max/Min attributes.
8018
8019 @node No_Implicit_Dynamic_Code
8020 @unnumberedsubsec No_Implicit_Dynamic_Code
8021 @findex No_Implicit_Dynamic_Code
8022 @cindex trampoline
8023 [GNAT] This restriction prevents the compiler from building ``trampolines''.
8024 This is a structure that is built on the stack and contains dynamic
8025 code to be executed at run time. On some targets, a trampoline is
8026 built for the following features: @code{Access},
8027 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8028 nested task bodies; primitive operations of nested tagged types.
8029 Trampolines do not work on machines that prevent execution of stack
8030 data. For example, on windows systems, enabling DEP (data execution
8031 protection) will cause trampolines to raise an exception.
8032 Trampolines are also quite slow at run time.
8033
8034 On many targets, trampolines have been largely eliminated. Look at the
8035 version of system.ads for your target --- if it has
8036 Always_Compatible_Rep equal to False, then trampolines are largely
8037 eliminated. In particular, a trampoline is built for the following
8038 features: @code{Address} of a nested subprogram;
8039 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8040 but only if pragma Favor_Top_Level applies, or the access type has a
8041 foreign-language convention; primitive operations of nested tagged
8042 types.
8043
8044 @node No_Implicit_Heap_Allocations
8045 @unnumberedsubsec No_Implicit_Heap_Allocations
8046 @findex No_Implicit_Heap_Allocations
8047 [RM D.7] No constructs are allowed to cause implicit heap allocation.
8048
8049 @node No_Implicit_Loops
8050 @unnumberedsubsec No_Implicit_Loops
8051 @findex No_Implicit_Loops
8052 [GNAT] This restriction ensures that the generated code does not contain any
8053 implicit @code{for} loops, either by modifying
8054 the generated code where possible,
8055 or by rejecting any construct that would otherwise generate an implicit
8056 @code{for} loop. If this restriction is active, it is possible to build
8057 large array aggregates with all static components without generating an
8058 intermediate temporary, and without generating a loop to initialize individual
8059 components. Otherwise, a loop is created for arrays larger than about 5000
8060 scalar components.
8061
8062 @node No_Initialize_Scalars
8063 @unnumberedsubsec No_Initialize_Scalars
8064 @findex No_Initialize_Scalars
8065 [GNAT] This restriction ensures that no unit in the partition is compiled with
8066 pragma Initialize_Scalars. This allows the generation of more efficient
8067 code, and in particular eliminates dummy null initialization routines that
8068 are otherwise generated for some record and array types.
8069
8070 @node No_IO
8071 @unnumberedsubsec No_IO
8072 @findex No_IO
8073 [RM H.4] This restriction ensures at compile time that there are no
8074 dependences on any of the library units Sequential_IO, Direct_IO,
8075 Text_IO, Wide_Text_IO, Wide_Wide_Text_IO, or Stream_IO.
8076
8077 @node No_Local_Allocators
8078 @unnumberedsubsec No_Local_Allocators
8079 @findex No_Local_Allocators
8080 [RM H.4] This restriction ensures at compile time that there are no
8081 occurrences of an allocator in subprograms, generic subprograms, tasks,
8082 and entry bodies.
8083
8084 @node No_Local_Protected_Objects
8085 @unnumberedsubsec No_Local_Protected_Objects
8086 @findex No_Local_Protected_Objects
8087 [RM D.7] This restriction ensures at compile time that protected objects are
8088 only declared at the library level.
8089
8090 @node No_Local_Timing_Events
8091 @unnumberedsubsec No_Local_Timing_Events
8092 @findex No_Local_Timing_Events
8093 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
8094 declared at the library level.
8095
8096 @node No_Nested_Finalization
8097 @unnumberedsubsec No_Nested_Finalization
8098 @findex No_Nested_Finalization
8099 [RM D.7] All objects requiring finalization are declared at the library level.
8100
8101 @node No_Protected_Type_Allocators
8102 @unnumberedsubsec No_Protected_Type_Allocators
8103 @findex No_Protected_Type_Allocators
8104 [RM D.7] This restriction ensures at compile time that there are no allocator
8105 expressions that attempt to allocate protected objects.
8106
8107 @node No_Protected_Types
8108 @unnumberedsubsec No_Protected_Types
8109 @findex No_Protected_Types
8110 [RM H.4] This restriction ensures at compile time that there are no
8111 declarations of protected types or protected objects.
8112
8113 @node No_Recursion
8114 @unnumberedsubsec No_Recursion
8115 @findex No_Recursion
8116 [RM H.4] A program execution is erroneous if a subprogram is invoked as
8117 part of its execution.
8118
8119 @node No_Reentrancy
8120 @unnumberedsubsec No_Reentrancy
8121 @findex No_Reentrancy
8122 [RM H.4] A program execution is erroneous if a subprogram is executed by
8123 two tasks at the same time.
8124
8125 @node No_Relative_Delay
8126 @unnumberedsubsec No_Relative_Delay
8127 @findex No_Relative_Delay
8128 [RM D.7] This restriction ensures at compile time that there are no delay
8129 relative statements and prevents expressions such as @code{delay 1.23;} from
8130 appearing in source code.
8131
8132 @node No_Requeue_Statements
8133 @unnumberedsubsec No_Requeue_Statements
8134 @findex No_Requeue_Statements
8135 [RM D.7] This restriction ensures at compile time that no requeue statements
8136 are permitted and prevents keyword @code{requeue} from being used in source
8137 code.
8138
8139 @node No_Secondary_Stack
8140 @unnumberedsubsec No_Secondary_Stack
8141 @findex No_Secondary_Stack
8142 [GNAT] This restriction ensures at compile time that the generated code
8143 does not contain any reference to the secondary stack. The secondary
8144 stack is used to implement functions returning unconstrained objects
8145 (arrays or records) on some targets.
8146
8147 @node No_Select_Statements
8148 @unnumberedsubsec No_Select_Statements
8149 @findex No_Select_Statements
8150 [RM D.7] This restriction ensures at compile time no select statements of any
8151 kind are permitted, that is the keyword @code{select} may not appear.
8152
8153 @node No_Specific_Termination_Handlers
8154 @unnumberedsubsec No_Specific_Termination_Handlers
8155 @findex No_Specific_Termination_Handlers
8156 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
8157 or to Ada.Task_Termination.Specific_Handler.
8158
8159 @node No_Specification_of_Aspect
8160 @unnumberedsubsec No_Specification_of_Aspect
8161 @findex No_Specification_of_Aspect
8162 [RM 13.12.1] This restriction checks at compile time that no aspect
8163 specification, attribute definition clause, or pragma is given for a
8164 given aspect.
8165
8166 @node No_Standard_Allocators_After_Elaboration
8167 @unnumberedsubsec No_Standard_Allocators_After_Elaboration
8168 @findex No_Standard_Allocators_After_Elaboration
8169 [RM D.7] Specifies that an allocator using a standard storage pool
8170 should never be evaluated at run time after the elaboration of the
8171 library items of the partition has completed. Otherwise, Storage_Error
8172 is raised.
8173
8174 @node No_Standard_Storage_Pools
8175 @unnumberedsubsec No_Standard_Storage_Pools
8176 @findex No_Standard_Storage_Pools
8177 [GNAT] This restriction ensures at compile time that no access types
8178 use the standard default storage pool. Any access type declared must
8179 have an explicit Storage_Pool attribute defined specifying a
8180 user-defined storage pool.
8181
8182 @node No_Stream_Optimizations
8183 @unnumberedsubsec No_Stream_Optimizations
8184 @findex No_Stream_Optimizations
8185 [GNAT] This restriction affects the performance of stream operations on types
8186 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
8187 compiler uses block reads and writes when manipulating @code{String} objects
8188 due to their supperior performance. When this restriction is in effect, the
8189 compiler performs all IO operations on a per-character basis.
8190
8191 @node No_Streams
8192 @unnumberedsubsec No_Streams
8193 @findex No_Streams
8194 [GNAT] This restriction ensures at compile/bind time that there are no
8195 stream objects created and no use of stream attributes.
8196 This restriction does not forbid dependences on the package
8197 @code{Ada.Streams}. So it is permissible to with
8198 @code{Ada.Streams} (or another package that does so itself)
8199 as long as no actual stream objects are created and no
8200 stream attributes are used.
8201
8202 Note that the use of restriction allows optimization of tagged types,
8203 since they do not need to worry about dispatching stream operations.
8204 To take maximum advantage of this space-saving optimization, any
8205 unit declaring a tagged type should be compiled with the restriction,
8206 though this is not required.
8207
8208 @node No_Task_Allocators
8209 @unnumberedsubsec No_Task_Allocators
8210 @findex No_Task_Allocators
8211 [RM D.7] There are no allocators for task types
8212 or types containing task subcomponents.
8213
8214 @node No_Task_Attributes_Package
8215 @unnumberedsubsec No_Task_Attributes_Package
8216 @findex No_Task_Attributes_Package
8217 [GNAT] This restriction ensures at compile time that there are no implicit or
8218 explicit dependencies on the package @code{Ada.Task_Attributes}.
8219
8220 @node No_Task_Hierarchy
8221 @unnumberedsubsec No_Task_Hierarchy
8222 @findex No_Task_Hierarchy
8223 [RM D.7] All (non-environment) tasks depend
8224 directly on the environment task of the partition.
8225
8226 @node No_Task_Termination
8227 @unnumberedsubsec No_Task_Termination
8228 @findex No_Task_Termination
8229 [RM D.7] Tasks which terminate are erroneous.
8230
8231 @node No_Tasking
8232 @unnumberedsubsec No_Tasking
8233 @findex No_Tasking
8234 [GNAT] This restriction prevents the declaration of tasks or task types
8235 throughout the partition. It is similar in effect to the use of
8236 @code{Max_Tasks => 0} except that violations are caught at compile time
8237 and cause an error message to be output either by the compiler or
8238 binder.
8239
8240 @node No_Terminate_Alternatives
8241 @unnumberedsubsec No_Terminate_Alternatives
8242 @findex No_Terminate_Alternatives
8243 [RM D.7] There are no selective accepts with terminate alternatives.
8244
8245 @node No_Unchecked_Access
8246 @unnumberedsubsec No_Unchecked_Access
8247 @findex No_Unchecked_Access
8248 [RM H.4] This restriction ensures at compile time that there are no
8249 occurrences of the Unchecked_Access attribute.
8250
8251 @node Simple_Barriers
8252 @unnumberedsubsec Simple_Barriers
8253 @findex Simple_Barriers
8254 [RM D.7] This restriction ensures at compile time that barriers in entry
8255 declarations for protected types are restricted to either static boolean
8256 expressions or references to simple boolean variables defined in the private
8257 part of the protected type. No other form of entry barriers is permitted.
8258
8259 @node Static_Priorities
8260 @unnumberedsubsec Static_Priorities
8261 @findex Static_Priorities
8262 [GNAT] This restriction ensures at compile time that all priority expressions
8263 are static, and that there are no dependences on the package
8264 @code{Ada.Dynamic_Priorities}.
8265
8266 @node Static_Storage_Size
8267 @unnumberedsubsec Static_Storage_Size
8268 @findex Static_Storage_Size
8269 [GNAT] This restriction ensures at compile time that any expression appearing
8270 in a Storage_Size pragma or attribute definition clause is static.
8271
8272 @node Program Unit Level Restrictions
8273 @section Program Unit Level Restrictions
8274
8275 @noindent
8276 The second set of restriction identifiers
8277 does not require partition-wide consistency.
8278 The restriction may be enforced for a single
8279 compilation unit without any effect on any of the
8280 other compilation units in the partition.
8281
8282 @menu
8283 * No_Elaboration_Code::
8284 * No_Entry_Queue::
8285 * No_Implementation_Aspect_Specifications::
8286 * No_Implementation_Attributes::
8287 * No_Implementation_Identifiers::
8288 * No_Implementation_Pragmas::
8289 * No_Implementation_Restrictions::
8290 * No_Implementation_Units::
8291 * No_Implicit_Aliasing::
8292 * No_Obsolescent_Features::
8293 * No_Wide_Characters::
8294 * SPARK::
8295 @end menu
8296
8297 @node No_Elaboration_Code
8298 @unnumberedsubsec No_Elaboration_Code
8299 @findex No_Elaboration_Code
8300 [GNAT] This restriction ensures at compile time that no elaboration code is
8301 generated. Note that this is not the same condition as is enforced
8302 by pragma @code{Preelaborate}. There are cases in which pragma
8303 @code{Preelaborate} still permits code to be generated (e.g.@: code
8304 to initialize a large array to all zeroes), and there are cases of units
8305 which do not meet the requirements for pragma @code{Preelaborate},
8306 but for which no elaboration code is generated. Generally, it is
8307 the case that preelaborable units will meet the restrictions, with
8308 the exception of large aggregates initialized with an others_clause,
8309 and exception declarations (which generate calls to a run-time
8310 registry procedure). This restriction is enforced on
8311 a unit by unit basis, it need not be obeyed consistently
8312 throughout a partition.
8313
8314 In the case of aggregates with others, if the aggregate has a dynamic
8315 size, there is no way to eliminate the elaboration code (such dynamic
8316 bounds would be incompatible with @code{Preelaborate} in any case). If
8317 the bounds are static, then use of this restriction actually modifies
8318 the code choice of the compiler to avoid generating a loop, and instead
8319 generate the aggregate statically if possible, no matter how many times
8320 the data for the others clause must be repeatedly generated.
8321
8322 It is not possible to precisely document
8323 the constructs which are compatible with this restriction, since,
8324 unlike most other restrictions, this is not a restriction on the
8325 source code, but a restriction on the generated object code. For
8326 example, if the source contains a declaration:
8327
8328 @smallexample
8329 Val : constant Integer := X;
8330 @end smallexample
8331
8332 @noindent
8333 where X is not a static constant, it may be possible, depending
8334 on complex optimization circuitry, for the compiler to figure
8335 out the value of X at compile time, in which case this initialization
8336 can be done by the loader, and requires no initialization code. It
8337 is not possible to document the precise conditions under which the
8338 optimizer can figure this out.
8339
8340 Note that this the implementation of this restriction requires full
8341 code generation. If it is used in conjunction with "semantics only"
8342 checking, then some cases of violations may be missed.
8343
8344 @node No_Entry_Queue
8345 @unnumberedsubsec No_Entry_Queue
8346 @findex No_Entry_Queue
8347 [GNAT] This restriction is a declaration that any protected entry compiled in
8348 the scope of the restriction has at most one task waiting on the entry
8349 at any one time, and so no queue is required. This restriction is not
8350 checked at compile time. A program execution is erroneous if an attempt
8351 is made to queue a second task on such an entry.
8352
8353 @node No_Implementation_Aspect_Specifications
8354 @unnumberedsubsec No_Implementation_Aspect_Specifications
8355 @findex No_Implementation_Aspect_Specifications
8356 [RM 13.12.1] This restriction checks at compile time that no
8357 GNAT-defined aspects are present. With this restriction, the only
8358 aspects that can be used are those defined in the Ada Reference Manual.
8359
8360 @node No_Implementation_Attributes
8361 @unnumberedsubsec No_Implementation_Attributes
8362 @findex No_Implementation_Attributes
8363 [RM 13.12.1] This restriction checks at compile time that no
8364 GNAT-defined attributes are present. With this restriction, the only
8365 attributes that can be used are those defined in the Ada Reference
8366 Manual.
8367
8368 @node No_Implementation_Identifiers
8369 @unnumberedsubsec No_Implementation_Identifiers
8370 @findex No_Implementation_Identifiers
8371 [RM 13.12.1] This restriction checks at compile time that no
8372 implementation-defined identifiers (marked with pragma Implementation_Defined)
8373 occur within language-defined packages.
8374
8375 @node No_Implementation_Pragmas
8376 @unnumberedsubsec No_Implementation_Pragmas
8377 @findex No_Implementation_Pragmas
8378 [RM 13.12.1] This restriction checks at compile time that no
8379 GNAT-defined pragmas are present. With this restriction, the only
8380 pragmas that can be used are those defined in the Ada Reference Manual.
8381
8382 @node No_Implementation_Restrictions
8383 @unnumberedsubsec No_Implementation_Restrictions
8384 @findex No_Implementation_Restrictions
8385 [GNAT] This restriction checks at compile time that no GNAT-defined restriction
8386 identifiers (other than @code{No_Implementation_Restrictions} itself)
8387 are present. With this restriction, the only other restriction identifiers
8388 that can be used are those defined in the Ada Reference Manual.
8389
8390 @node No_Implementation_Units
8391 @unnumberedsubsec No_Implementation_Units
8392 @findex No_Implementation_Units
8393 [RM 13.12.1] This restriction checks at compile time that there is no
8394 mention in the context clause of any implementation-defined descendants
8395 of packages Ada, Interfaces, or System.
8396
8397 @node No_Implicit_Aliasing
8398 @unnumberedsubsec No_Implicit_Aliasing
8399 @findex No_Implicit_Aliasing
8400 [GNAT] This restriction, which is not required to be partition-wide consistent,
8401 requires an explicit aliased keyword for an object to which 'Access,
8402 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
8403 the 'Unrestricted_Access attribute for objects. Note: the reason that
8404 Unrestricted_Access is forbidden is that it would require the prefix
8405 to be aliased, and in such cases, it can always be replaced by
8406 the standard attribute Unchecked_Access which is preferable.
8407
8408 @node No_Obsolescent_Features
8409 @unnumberedsubsec No_Obsolescent_Features
8410 @findex No_Obsolescent_Features
8411 [RM 13.12.1] This restriction checks at compile time that no obsolescent
8412 features are used, as defined in Annex J of the Ada Reference Manual.
8413
8414 @node No_Wide_Characters
8415 @unnumberedsubsec No_Wide_Characters
8416 @findex No_Wide_Characters
8417 [GNAT] This restriction ensures at compile time that no uses of the types
8418 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8419 wide types
8420 appear, and that no wide or wide wide string or character literals
8421 appear in the program (that is literals representing characters not in
8422 type @code{Character}).
8423
8424 @node SPARK
8425 @unnumberedsubsec SPARK
8426 @findex SPARK
8427 [GNAT] This restriction checks at compile time that some constructs
8428 forbidden in SPARK are not present. The SPARK version used as a
8429 reference is the same as the Ada mode for the unit, so a unit compiled
8430 in Ada 95 mode with SPARK restrictions will be checked for constructs
8431 forbidden in SPARK 95. Error messages related to SPARK restriction have
8432 the form:
8433
8434 @smallexample
8435 violation of restriction "SPARK" at <file>
8436 <error message>
8437 @end smallexample
8438
8439 This is not a replacement for the semantic checks performed by the
8440 SPARK Examiner tool, as the compiler only deals currently with code,
8441 not at all with SPARK annotations and does not guarantee catching all
8442 cases of constructs forbidden by SPARK.
8443
8444 Thus it may well be the case that code which
8445 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
8446 e.g. due to the different visibility rules of the Examiner based on
8447 SPARK @code{inherit} annotations.
8448
8449 This restriction can be useful in providing an initial filter for
8450 code developed using SPARK, or in examining legacy code to see how far
8451 it is from meeting SPARK restrictions.
8452
8453 @c ------------------------
8454 @node Implementation Advice
8455 @chapter Implementation Advice
8456 @noindent
8457 The main text of the Ada Reference Manual describes the required
8458 behavior of all Ada compilers, and the GNAT compiler conforms to
8459 these requirements.
8460
8461 In addition, there are sections throughout the Ada Reference Manual headed
8462 by the phrase ``Implementation advice''. These sections are not normative,
8463 i.e., they do not specify requirements that all compilers must
8464 follow. Rather they provide advice on generally desirable behavior. You
8465 may wonder why they are not requirements. The most typical answer is
8466 that they describe behavior that seems generally desirable, but cannot
8467 be provided on all systems, or which may be undesirable on some systems.
8468
8469 As far as practical, GNAT follows the implementation advice sections in
8470 the Ada Reference Manual. This chapter contains a table giving the
8471 reference manual section number, paragraph number and several keywords
8472 for each advice. Each entry consists of the text of the advice followed
8473 by the GNAT interpretation of this advice. Most often, this simply says
8474 ``followed'', which means that GNAT follows the advice. However, in a
8475 number of cases, GNAT deliberately deviates from this advice, in which
8476 case the text describes what GNAT does and why.
8477
8478 @cindex Error detection
8479 @unnumberedsec 1.1.3(20): Error Detection
8480 @sp 1
8481 @cartouche
8482 If an implementation detects the use of an unsupported Specialized Needs
8483 Annex feature at run time, it should raise @code{Program_Error} if
8484 feasible.
8485 @end cartouche
8486 Not relevant. All specialized needs annex features are either supported,
8487 or diagnosed at compile time.
8488
8489 @cindex Child Units
8490 @unnumberedsec 1.1.3(31): Child Units
8491 @sp 1
8492 @cartouche
8493 If an implementation wishes to provide implementation-defined
8494 extensions to the functionality of a language-defined library unit, it
8495 should normally do so by adding children to the library unit.
8496 @end cartouche
8497 Followed.
8498
8499 @cindex Bounded errors
8500 @unnumberedsec 1.1.5(12): Bounded Errors
8501 @sp 1
8502 @cartouche
8503 If an implementation detects a bounded error or erroneous
8504 execution, it should raise @code{Program_Error}.
8505 @end cartouche
8506 Followed in all cases in which the implementation detects a bounded
8507 error or erroneous execution. Not all such situations are detected at
8508 runtime.
8509
8510 @cindex Pragmas
8511 @unnumberedsec 2.8(16): Pragmas
8512 @sp 1
8513 @cartouche
8514 Normally, implementation-defined pragmas should have no semantic effect
8515 for error-free programs; that is, if the implementation-defined pragmas
8516 are removed from a working program, the program should still be legal,
8517 and should still have the same semantics.
8518 @end cartouche
8519 The following implementation defined pragmas are exceptions to this
8520 rule:
8521
8522 @table @code
8523 @item Abort_Defer
8524 Affects semantics
8525 @item Ada_83
8526 Affects legality
8527 @item Assert
8528 Affects semantics
8529 @item CPP_Class
8530 Affects semantics
8531 @item CPP_Constructor
8532 Affects semantics
8533 @item Debug
8534 Affects semantics
8535 @item Interface_Name
8536 Affects semantics
8537 @item Machine_Attribute
8538 Affects semantics
8539 @item Unimplemented_Unit
8540 Affects legality
8541 @item Unchecked_Union
8542 Affects semantics
8543 @end table
8544
8545 @noindent
8546 In each of the above cases, it is essential to the purpose of the pragma
8547 that this advice not be followed. For details see the separate section
8548 on implementation defined pragmas.
8549
8550 @unnumberedsec 2.8(17-19): Pragmas
8551 @sp 1
8552 @cartouche
8553 Normally, an implementation should not define pragmas that can
8554 make an illegal program legal, except as follows:
8555 @end cartouche
8556 @sp 1
8557 @cartouche
8558 A pragma used to complete a declaration, such as a pragma @code{Import};
8559 @end cartouche
8560 @sp 1
8561 @cartouche
8562 A pragma used to configure the environment by adding, removing, or
8563 replacing @code{library_items}.
8564 @end cartouche
8565 See response to paragraph 16 of this same section.
8566
8567 @cindex Character Sets
8568 @cindex Alternative Character Sets
8569 @unnumberedsec 3.5.2(5): Alternative Character Sets
8570 @sp 1
8571 @cartouche
8572 If an implementation supports a mode with alternative interpretations
8573 for @code{Character} and @code{Wide_Character}, the set of graphic
8574 characters of @code{Character} should nevertheless remain a proper
8575 subset of the set of graphic characters of @code{Wide_Character}. Any
8576 character set ``localizations'' should be reflected in the results of
8577 the subprograms defined in the language-defined package
8578 @code{Characters.Handling} (see A.3) available in such a mode. In a mode with
8579 an alternative interpretation of @code{Character}, the implementation should
8580 also support a corresponding change in what is a legal
8581 @code{identifier_letter}.
8582 @end cartouche
8583 Not all wide character modes follow this advice, in particular the JIS
8584 and IEC modes reflect standard usage in Japan, and in these encoding,
8585 the upper half of the Latin-1 set is not part of the wide-character
8586 subset, since the most significant bit is used for wide character
8587 encoding. However, this only applies to the external forms. Internally
8588 there is no such restriction.
8589
8590 @cindex Integer types
8591 @unnumberedsec 3.5.4(28): Integer Types
8592
8593 @sp 1
8594 @cartouche
8595 An implementation should support @code{Long_Integer} in addition to
8596 @code{Integer} if the target machine supports 32-bit (or longer)
8597 arithmetic. No other named integer subtypes are recommended for package
8598 @code{Standard}. Instead, appropriate named integer subtypes should be
8599 provided in the library package @code{Interfaces} (see B.2).
8600 @end cartouche
8601 @code{Long_Integer} is supported. Other standard integer types are supported
8602 so this advice is not fully followed. These types
8603 are supported for convenient interface to C, and so that all hardware
8604 types of the machine are easily available.
8605 @unnumberedsec 3.5.4(29): Integer Types
8606
8607 @sp 1
8608 @cartouche
8609 An implementation for a two's complement machine should support
8610 modular types with a binary modulus up to @code{System.Max_Int*2+2}. An
8611 implementation should support a non-binary modules up to @code{Integer'Last}.
8612 @end cartouche
8613 Followed.
8614
8615 @cindex Enumeration values
8616 @unnumberedsec 3.5.5(8): Enumeration Values
8617 @sp 1
8618 @cartouche
8619 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
8620 subtype, if the value of the operand does not correspond to the internal
8621 code for any enumeration literal of its type (perhaps due to an
8622 un-initialized variable), then the implementation should raise
8623 @code{Program_Error}. This is particularly important for enumeration
8624 types with noncontiguous internal codes specified by an
8625 enumeration_representation_clause.
8626 @end cartouche
8627 Followed.
8628
8629 @cindex Float types
8630 @unnumberedsec 3.5.7(17): Float Types
8631 @sp 1
8632 @cartouche
8633 An implementation should support @code{Long_Float} in addition to
8634 @code{Float} if the target machine supports 11 or more digits of
8635 precision. No other named floating point subtypes are recommended for
8636 package @code{Standard}. Instead, appropriate named floating point subtypes
8637 should be provided in the library package @code{Interfaces} (see B.2).
8638 @end cartouche
8639 @code{Short_Float} and @code{Long_Long_Float} are also provided. The
8640 former provides improved compatibility with other implementations
8641 supporting this type. The latter corresponds to the highest precision
8642 floating-point type supported by the hardware. On most machines, this
8643 will be the same as @code{Long_Float}, but on some machines, it will
8644 correspond to the IEEE extended form. The notable case is all ia32
8645 (x86) implementations, where @code{Long_Long_Float} corresponds to
8646 the 80-bit extended precision format supported in hardware on this
8647 processor. Note that the 128-bit format on SPARC is not supported,
8648 since this is a software rather than a hardware format.
8649
8650 @cindex Multidimensional arrays
8651 @cindex Arrays, multidimensional
8652 @unnumberedsec 3.6.2(11): Multidimensional Arrays
8653 @sp 1
8654 @cartouche
8655 An implementation should normally represent multidimensional arrays in
8656 row-major order, consistent with the notation used for multidimensional
8657 array aggregates (see 4.3.3). However, if a pragma @code{Convention}
8658 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
8659 column-major order should be used instead (see B.5, ``Interfacing with
8660 Fortran'').
8661 @end cartouche
8662 Followed.
8663
8664 @findex Duration'Small
8665 @unnumberedsec 9.6(30-31): Duration'Small
8666 @sp 1
8667 @cartouche
8668 Whenever possible in an implementation, the value of @code{Duration'Small}
8669 should be no greater than 100 microseconds.
8670 @end cartouche
8671 Followed. (@code{Duration'Small} = 10**(@minus{}9)).
8672
8673 @sp 1
8674 @cartouche
8675 The time base for @code{delay_relative_statements} should be monotonic;
8676 it need not be the same time base as used for @code{Calendar.Clock}.
8677 @end cartouche
8678 Followed.
8679
8680 @unnumberedsec 10.2.1(12): Consistent Representation
8681 @sp 1
8682 @cartouche
8683 In an implementation, a type declared in a pre-elaborated package should
8684 have the same representation in every elaboration of a given version of
8685 the package, whether the elaborations occur in distinct executions of
8686 the same program, or in executions of distinct programs or partitions
8687 that include the given version.
8688 @end cartouche
8689 Followed, except in the case of tagged types. Tagged types involve
8690 implicit pointers to a local copy of a dispatch table, and these pointers
8691 have representations which thus depend on a particular elaboration of the
8692 package. It is not easy to see how it would be possible to follow this
8693 advice without severely impacting efficiency of execution.
8694
8695 @cindex Exception information
8696 @unnumberedsec 11.4.1(19): Exception Information
8697 @sp 1
8698 @cartouche
8699 @code{Exception_Message} by default and @code{Exception_Information}
8700 should produce information useful for
8701 debugging. @code{Exception_Message} should be short, about one
8702 line. @code{Exception_Information} can be long. @code{Exception_Message}
8703 should not include the
8704 @code{Exception_Name}. @code{Exception_Information} should include both
8705 the @code{Exception_Name} and the @code{Exception_Message}.
8706 @end cartouche
8707 Followed. For each exception that doesn't have a specified
8708 @code{Exception_Message}, the compiler generates one containing the location
8709 of the raise statement. This location has the form ``file:line'', where
8710 file is the short file name (without path information) and line is the line
8711 number in the file. Note that in the case of the Zero Cost Exception
8712 mechanism, these messages become redundant with the Exception_Information that
8713 contains a full backtrace of the calling sequence, so they are disabled.
8714 To disable explicitly the generation of the source location message, use the
8715 Pragma @code{Discard_Names}.
8716
8717 @cindex Suppression of checks
8718 @cindex Checks, suppression of
8719 @unnumberedsec 11.5(28): Suppression of Checks
8720 @sp 1
8721 @cartouche
8722 The implementation should minimize the code executed for checks that
8723 have been suppressed.
8724 @end cartouche
8725 Followed.
8726
8727 @cindex Representation clauses
8728 @unnumberedsec 13.1 (21-24): Representation Clauses
8729 @sp 1
8730 @cartouche
8731 The recommended level of support for all representation items is
8732 qualified as follows:
8733 @end cartouche
8734 @sp 1
8735 @cartouche
8736 An implementation need not support representation items containing
8737 non-static expressions, except that an implementation should support a
8738 representation item for a given entity if each non-static expression in
8739 the representation item is a name that statically denotes a constant
8740 declared before the entity.
8741 @end cartouche
8742 Followed. In fact, GNAT goes beyond the recommended level of support
8743 by allowing nonstatic expressions in some representation clauses even
8744 without the need to declare constants initialized with the values of
8745 such expressions.
8746 For example:
8747
8748 @smallexample @c ada
8749 X : Integer;
8750 Y : Float;
8751 for Y'Address use X'Address;>>
8752 @end smallexample
8753
8754 @sp 1
8755 @cartouche
8756 An implementation need not support a specification for the @code{Size}
8757 for a given composite subtype, nor the size or storage place for an
8758 object (including a component) of a given composite subtype, unless the
8759 constraints on the subtype and its composite subcomponents (if any) are
8760 all static constraints.
8761 @end cartouche
8762 Followed. Size Clauses are not permitted on non-static components, as
8763 described above.
8764
8765 @sp 1
8766 @cartouche
8767 An aliased component, or a component whose type is by-reference, should
8768 always be allocated at an addressable location.
8769 @end cartouche
8770 Followed.
8771
8772 @cindex Packed types
8773 @unnumberedsec 13.2(6-8): Packed Types
8774 @sp 1
8775 @cartouche
8776 If a type is packed, then the implementation should try to minimize
8777 storage allocated to objects of the type, possibly at the expense of
8778 speed of accessing components, subject to reasonable complexity in
8779 addressing calculations.
8780 @end cartouche
8781 @sp 1
8782 @cartouche
8783 The recommended level of support pragma @code{Pack} is:
8784
8785 For a packed record type, the components should be packed as tightly as
8786 possible subject to the Sizes of the component subtypes, and subject to
8787 any @code{record_representation_clause} that applies to the type; the
8788 implementation may, but need not, reorder components or cross aligned
8789 word boundaries to improve the packing. A component whose @code{Size} is
8790 greater than the word size may be allocated an integral number of words.
8791 @end cartouche
8792 Followed. Tight packing of arrays is supported for all component sizes
8793 up to 64-bits. If the array component size is 1 (that is to say, if
8794 the component is a boolean type or an enumeration type with two values)
8795 then values of the type are implicitly initialized to zero. This
8796 happens both for objects of the packed type, and for objects that have a
8797 subcomponent of the packed type.
8798
8799 @sp 1
8800 @cartouche
8801 An implementation should support Address clauses for imported
8802 subprograms.
8803 @end cartouche
8804 Followed.
8805 @cindex @code{Address} clauses
8806 @unnumberedsec 13.3(14-19): Address Clauses
8807
8808 @sp 1
8809 @cartouche
8810 For an array @var{X}, @code{@var{X}'Address} should point at the first
8811 component of the array, and not at the array bounds.
8812 @end cartouche
8813 Followed.
8814
8815 @sp 1
8816 @cartouche
8817 The recommended level of support for the @code{Address} attribute is:
8818
8819 @code{@var{X}'Address} should produce a useful result if @var{X} is an
8820 object that is aliased or of a by-reference type, or is an entity whose
8821 @code{Address} has been specified.
8822 @end cartouche
8823 Followed. A valid address will be produced even if none of those
8824 conditions have been met. If necessary, the object is forced into
8825 memory to ensure the address is valid.
8826
8827 @sp 1
8828 @cartouche
8829 An implementation should support @code{Address} clauses for imported
8830 subprograms.
8831 @end cartouche
8832 Followed.
8833
8834 @sp 1
8835 @cartouche
8836 Objects (including subcomponents) that are aliased or of a by-reference
8837 type should be allocated on storage element boundaries.
8838 @end cartouche
8839 Followed.
8840
8841 @sp 1
8842 @cartouche
8843 If the @code{Address} of an object is specified, or it is imported or exported,
8844 then the implementation should not perform optimizations based on
8845 assumptions of no aliases.
8846 @end cartouche
8847 Followed.
8848
8849 @cindex @code{Alignment} clauses
8850 @unnumberedsec 13.3(29-35): Alignment Clauses
8851 @sp 1
8852 @cartouche
8853 The recommended level of support for the @code{Alignment} attribute for
8854 subtypes is:
8855
8856 An implementation should support specified Alignments that are factors
8857 and multiples of the number of storage elements per word, subject to the
8858 following:
8859 @end cartouche
8860 Followed.
8861
8862 @sp 1
8863 @cartouche
8864 An implementation need not support specified @code{Alignment}s for
8865 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
8866 loaded and stored by available machine instructions.
8867 @end cartouche
8868 Followed.
8869
8870 @sp 1
8871 @cartouche
8872 An implementation need not support specified @code{Alignment}s that are
8873 greater than the maximum @code{Alignment} the implementation ever returns by
8874 default.
8875 @end cartouche
8876 Followed.
8877
8878 @sp 1
8879 @cartouche
8880 The recommended level of support for the @code{Alignment} attribute for
8881 objects is:
8882
8883 Same as above, for subtypes, but in addition:
8884 @end cartouche
8885 Followed.
8886
8887 @sp 1
8888 @cartouche
8889 For stand-alone library-level objects of statically constrained
8890 subtypes, the implementation should support all @code{Alignment}s
8891 supported by the target linker. For example, page alignment is likely to
8892 be supported for such objects, but not for subtypes.
8893 @end cartouche
8894 Followed.
8895
8896 @cindex @code{Size} clauses
8897 @unnumberedsec 13.3(42-43): Size Clauses
8898 @sp 1
8899 @cartouche
8900 The recommended level of support for the @code{Size} attribute of
8901 objects is:
8902
8903 A @code{Size} clause should be supported for an object if the specified
8904 @code{Size} is at least as large as its subtype's @code{Size}, and
8905 corresponds to a size in storage elements that is a multiple of the
8906 object's @code{Alignment} (if the @code{Alignment} is nonzero).
8907 @end cartouche
8908 Followed.
8909
8910 @unnumberedsec 13.3(50-56): Size Clauses
8911 @sp 1
8912 @cartouche
8913 If the @code{Size} of a subtype is specified, and allows for efficient
8914 independent addressability (see 9.10) on the target architecture, then
8915 the @code{Size} of the following objects of the subtype should equal the
8916 @code{Size} of the subtype:
8917
8918 Aliased objects (including components).
8919 @end cartouche
8920 Followed.
8921
8922 @sp 1
8923 @cartouche
8924 @code{Size} clause on a composite subtype should not affect the
8925 internal layout of components.
8926 @end cartouche
8927 Followed. But note that this can be overridden by use of the implementation
8928 pragma Implicit_Packing in the case of packed arrays.
8929
8930 @sp 1
8931 @cartouche
8932 The recommended level of support for the @code{Size} attribute of subtypes is:
8933 @end cartouche
8934 @sp 1
8935 @cartouche
8936 The @code{Size} (if not specified) of a static discrete or fixed point
8937 subtype should be the number of bits needed to represent each value
8938 belonging to the subtype using an unbiased representation, leaving space
8939 for a sign bit only if the subtype contains negative values. If such a
8940 subtype is a first subtype, then an implementation should support a
8941 specified @code{Size} for it that reflects this representation.
8942 @end cartouche
8943 Followed.
8944
8945 @sp 1
8946 @cartouche
8947 For a subtype implemented with levels of indirection, the @code{Size}
8948 should include the size of the pointers, but not the size of what they
8949 point at.
8950 @end cartouche
8951 Followed.
8952
8953 @cindex @code{Component_Size} clauses
8954 @unnumberedsec 13.3(71-73): Component Size Clauses
8955 @sp 1
8956 @cartouche
8957 The recommended level of support for the @code{Component_Size}
8958 attribute is:
8959 @end cartouche
8960 @sp 1
8961 @cartouche
8962 An implementation need not support specified @code{Component_Sizes} that are
8963 less than the @code{Size} of the component subtype.
8964 @end cartouche
8965 Followed.
8966
8967 @sp 1
8968 @cartouche
8969 An implementation should support specified @code{Component_Size}s that
8970 are factors and multiples of the word size. For such
8971 @code{Component_Size}s, the array should contain no gaps between
8972 components. For other @code{Component_Size}s (if supported), the array
8973 should contain no gaps between components when packing is also
8974 specified; the implementation should forbid this combination in cases
8975 where it cannot support a no-gaps representation.
8976 @end cartouche
8977 Followed.
8978
8979 @cindex Enumeration representation clauses
8980 @cindex Representation clauses, enumeration
8981 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
8982 @sp 1
8983 @cartouche
8984 The recommended level of support for enumeration representation clauses
8985 is:
8986
8987 An implementation need not support enumeration representation clauses
8988 for boolean types, but should at minimum support the internal codes in
8989 the range @code{System.Min_Int.System.Max_Int}.
8990 @end cartouche
8991 Followed.
8992
8993 @cindex Record representation clauses
8994 @cindex Representation clauses, records
8995 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
8996 @sp 1
8997 @cartouche
8998 The recommended level of support for
8999 @*@code{record_representation_clauses} is:
9000
9001 An implementation should support storage places that can be extracted
9002 with a load, mask, shift sequence of machine code, and set with a load,
9003 shift, mask, store sequence, given the available machine instructions
9004 and run-time model.
9005 @end cartouche
9006 Followed.
9007
9008 @sp 1
9009 @cartouche
9010 A storage place should be supported if its size is equal to the
9011 @code{Size} of the component subtype, and it starts and ends on a
9012 boundary that obeys the @code{Alignment} of the component subtype.
9013 @end cartouche
9014 Followed.
9015
9016 @sp 1
9017 @cartouche
9018 If the default bit ordering applies to the declaration of a given type,
9019 then for a component whose subtype's @code{Size} is less than the word
9020 size, any storage place that does not cross an aligned word boundary
9021 should be supported.
9022 @end cartouche
9023 Followed.
9024
9025 @sp 1
9026 @cartouche
9027 An implementation may reserve a storage place for the tag field of a
9028 tagged type, and disallow other components from overlapping that place.
9029 @end cartouche
9030 Followed. The storage place for the tag field is the beginning of the tagged
9031 record, and its size is Address'Size. GNAT will reject an explicit component
9032 clause for the tag field.
9033
9034 @sp 1
9035 @cartouche
9036 An implementation need not support a @code{component_clause} for a
9037 component of an extension part if the storage place is not after the
9038 storage places of all components of the parent type, whether or not
9039 those storage places had been specified.
9040 @end cartouche
9041 Followed. The above advice on record representation clauses is followed,
9042 and all mentioned features are implemented.
9043
9044 @cindex Storage place attributes
9045 @unnumberedsec 13.5.2(5): Storage Place Attributes
9046 @sp 1
9047 @cartouche
9048 If a component is represented using some form of pointer (such as an
9049 offset) to the actual data of the component, and this data is contiguous
9050 with the rest of the object, then the storage place attributes should
9051 reflect the place of the actual data, not the pointer. If a component is
9052 allocated discontinuously from the rest of the object, then a warning
9053 should be generated upon reference to one of its storage place
9054 attributes.
9055 @end cartouche
9056 Followed. There are no such components in GNAT@.
9057
9058 @cindex Bit ordering
9059 @unnumberedsec 13.5.3(7-8): Bit Ordering
9060 @sp 1
9061 @cartouche
9062 The recommended level of support for the non-default bit ordering is:
9063 @end cartouche
9064 @sp 1
9065 @cartouche
9066 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
9067 should support the non-default bit ordering in addition to the default
9068 bit ordering.
9069 @end cartouche
9070 Followed. Word size does not equal storage size in this implementation.
9071 Thus non-default bit ordering is not supported.
9072
9073 @cindex @code{Address}, as private type
9074 @unnumberedsec 13.7(37): Address as Private
9075 @sp 1
9076 @cartouche
9077 @code{Address} should be of a private type.
9078 @end cartouche
9079 Followed.
9080
9081 @cindex Operations, on @code{Address}
9082 @cindex @code{Address}, operations of
9083 @unnumberedsec 13.7.1(16): Address Operations
9084 @sp 1
9085 @cartouche
9086 Operations in @code{System} and its children should reflect the target
9087 environment semantics as closely as is reasonable. For example, on most
9088 machines, it makes sense for address arithmetic to ``wrap around''.
9089 Operations that do not make sense should raise @code{Program_Error}.
9090 @end cartouche
9091 Followed. Address arithmetic is modular arithmetic that wraps around. No
9092 operation raises @code{Program_Error}, since all operations make sense.
9093
9094 @cindex Unchecked conversion
9095 @unnumberedsec 13.9(14-17): Unchecked Conversion
9096 @sp 1
9097 @cartouche
9098 The @code{Size} of an array object should not include its bounds; hence,
9099 the bounds should not be part of the converted data.
9100 @end cartouche
9101 Followed.
9102
9103 @sp 1
9104 @cartouche
9105 The implementation should not generate unnecessary run-time checks to
9106 ensure that the representation of @var{S} is a representation of the
9107 target type. It should take advantage of the permission to return by
9108 reference when possible. Restrictions on unchecked conversions should be
9109 avoided unless required by the target environment.
9110 @end cartouche
9111 Followed. There are no restrictions on unchecked conversion. A warning is
9112 generated if the source and target types do not have the same size since
9113 the semantics in this case may be target dependent.
9114
9115 @sp 1
9116 @cartouche
9117 The recommended level of support for unchecked conversions is:
9118 @end cartouche
9119 @sp 1
9120 @cartouche
9121 Unchecked conversions should be supported and should be reversible in
9122 the cases where this clause defines the result. To enable meaningful use
9123 of unchecked conversion, a contiguous representation should be used for
9124 elementary subtypes, for statically constrained array subtypes whose
9125 component subtype is one of the subtypes described in this paragraph,
9126 and for record subtypes without discriminants whose component subtypes
9127 are described in this paragraph.
9128 @end cartouche
9129 Followed.
9130
9131 @cindex Heap usage, implicit
9132 @unnumberedsec 13.11(23-25): Implicit Heap Usage
9133 @sp 1
9134 @cartouche
9135 An implementation should document any cases in which it dynamically
9136 allocates heap storage for a purpose other than the evaluation of an
9137 allocator.
9138 @end cartouche
9139 Followed, the only other points at which heap storage is dynamically
9140 allocated are as follows:
9141
9142 @itemize @bullet
9143 @item
9144 At initial elaboration time, to allocate dynamically sized global
9145 objects.
9146
9147 @item
9148 To allocate space for a task when a task is created.
9149
9150 @item
9151 To extend the secondary stack dynamically when needed. The secondary
9152 stack is used for returning variable length results.
9153 @end itemize
9154
9155 @sp 1
9156 @cartouche
9157 A default (implementation-provided) storage pool for an
9158 access-to-constant type should not have overhead to support deallocation of
9159 individual objects.
9160 @end cartouche
9161 Followed.
9162
9163 @sp 1
9164 @cartouche
9165 A storage pool for an anonymous access type should be created at the
9166 point of an allocator for the type, and be reclaimed when the designated
9167 object becomes inaccessible.
9168 @end cartouche
9169 Followed.
9170
9171 @cindex Unchecked deallocation
9172 @unnumberedsec 13.11.2(17): Unchecked De-allocation
9173 @sp 1
9174 @cartouche
9175 For a standard storage pool, @code{Free} should actually reclaim the
9176 storage.
9177 @end cartouche
9178 Followed.
9179
9180 @cindex Stream oriented attributes
9181 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
9182 @sp 1
9183 @cartouche
9184 If a stream element is the same size as a storage element, then the
9185 normal in-memory representation should be used by @code{Read} and
9186 @code{Write} for scalar objects. Otherwise, @code{Read} and @code{Write}
9187 should use the smallest number of stream elements needed to represent
9188 all values in the base range of the scalar type.
9189 @end cartouche
9190
9191 Followed. By default, GNAT uses the interpretation suggested by AI-195,
9192 which specifies using the size of the first subtype.
9193 However, such an implementation is based on direct binary
9194 representations and is therefore target- and endianness-dependent.
9195 To address this issue, GNAT also supplies an alternate implementation
9196 of the stream attributes @code{Read} and @code{Write},
9197 which uses the target-independent XDR standard representation
9198 for scalar types.
9199 @cindex XDR representation
9200 @cindex @code{Read} attribute
9201 @cindex @code{Write} attribute
9202 @cindex Stream oriented attributes
9203 The XDR implementation is provided as an alternative body of the
9204 @code{System.Stream_Attributes} package, in the file
9205 @file{s-stratt-xdr.adb} in the GNAT library.
9206 There is no @file{s-stratt-xdr.ads} file.
9207 In order to install the XDR implementation, do the following:
9208 @enumerate
9209 @item Replace the default implementation of the
9210 @code{System.Stream_Attributes} package with the XDR implementation.
9211 For example on a Unix platform issue the commands:
9212 @smallexample
9213 $ mv s-stratt.adb s-stratt-default.adb
9214 $ mv s-stratt-xdr.adb s-stratt.adb
9215 @end smallexample
9216
9217 @item
9218 Rebuild the GNAT run-time library as documented in
9219 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
9220 @end enumerate
9221
9222 @unnumberedsec A.1(52): Names of Predefined Numeric Types
9223 @sp 1
9224 @cartouche
9225 If an implementation provides additional named predefined integer types,
9226 then the names should end with @samp{Integer} as in
9227 @samp{Long_Integer}. If an implementation provides additional named
9228 predefined floating point types, then the names should end with
9229 @samp{Float} as in @samp{Long_Float}.
9230 @end cartouche
9231 Followed.
9232
9233 @findex Ada.Characters.Handling
9234 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
9235 @sp 1
9236 @cartouche
9237 If an implementation provides a localized definition of @code{Character}
9238 or @code{Wide_Character}, then the effects of the subprograms in
9239 @code{Characters.Handling} should reflect the localizations. See also
9240 3.5.2.
9241 @end cartouche
9242 Followed. GNAT provides no such localized definitions.
9243
9244 @cindex Bounded-length strings
9245 @unnumberedsec A.4.4(106): Bounded-Length String Handling
9246 @sp 1
9247 @cartouche
9248 Bounded string objects should not be implemented by implicit pointers
9249 and dynamic allocation.
9250 @end cartouche
9251 Followed. No implicit pointers or dynamic allocation are used.
9252
9253 @cindex Random number generation
9254 @unnumberedsec A.5.2(46-47): Random Number Generation
9255 @sp 1
9256 @cartouche
9257 Any storage associated with an object of type @code{Generator} should be
9258 reclaimed on exit from the scope of the object.
9259 @end cartouche
9260 Followed.
9261
9262 @sp 1
9263 @cartouche
9264 If the generator period is sufficiently long in relation to the number
9265 of distinct initiator values, then each possible value of
9266 @code{Initiator} passed to @code{Reset} should initiate a sequence of
9267 random numbers that does not, in a practical sense, overlap the sequence
9268 initiated by any other value. If this is not possible, then the mapping
9269 between initiator values and generator states should be a rapidly
9270 varying function of the initiator value.
9271 @end cartouche
9272 Followed. The generator period is sufficiently long for the first
9273 condition here to hold true.
9274
9275 @findex Get_Immediate
9276 @unnumberedsec A.10.7(23): @code{Get_Immediate}
9277 @sp 1
9278 @cartouche
9279 The @code{Get_Immediate} procedures should be implemented with
9280 unbuffered input. For a device such as a keyboard, input should be
9281 @dfn{available} if a key has already been typed, whereas for a disk
9282 file, input should always be available except at end of file. For a file
9283 associated with a keyboard-like device, any line-editing features of the
9284 underlying operating system should be disabled during the execution of
9285 @code{Get_Immediate}.
9286 @end cartouche
9287 Followed on all targets except VxWorks. For VxWorks, there is no way to
9288 provide this functionality that does not result in the input buffer being
9289 flushed before the @code{Get_Immediate} call. A special unit
9290 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
9291 this functionality.
9292
9293 @findex Export
9294 @unnumberedsec B.1(39-41): Pragma @code{Export}
9295 @sp 1
9296 @cartouche
9297 If an implementation supports pragma @code{Export} to a given language,
9298 then it should also allow the main subprogram to be written in that
9299 language. It should support some mechanism for invoking the elaboration
9300 of the Ada library units included in the system, and for invoking the
9301 finalization of the environment task. On typical systems, the
9302 recommended mechanism is to provide two subprograms whose link names are
9303 @code{adainit} and @code{adafinal}. @code{adainit} should contain the
9304 elaboration code for library units. @code{adafinal} should contain the
9305 finalization code. These subprograms should have no effect the second
9306 and subsequent time they are called.
9307 @end cartouche
9308 Followed.
9309
9310 @sp 1
9311 @cartouche
9312 Automatic elaboration of pre-elaborated packages should be
9313 provided when pragma @code{Export} is supported.
9314 @end cartouche
9315 Followed when the main program is in Ada. If the main program is in a
9316 foreign language, then
9317 @code{adainit} must be called to elaborate pre-elaborated
9318 packages.
9319
9320 @sp 1
9321 @cartouche
9322 For each supported convention @var{L} other than @code{Intrinsic}, an
9323 implementation should support @code{Import} and @code{Export} pragmas
9324 for objects of @var{L}-compatible types and for subprograms, and pragma
9325 @code{Convention} for @var{L}-eligible types and for subprograms,
9326 presuming the other language has corresponding features. Pragma
9327 @code{Convention} need not be supported for scalar types.
9328 @end cartouche
9329 Followed.
9330
9331 @cindex Package @code{Interfaces}
9332 @findex Interfaces
9333 @unnumberedsec B.2(12-13): Package @code{Interfaces}
9334 @sp 1
9335 @cartouche
9336 For each implementation-defined convention identifier, there should be a
9337 child package of package Interfaces with the corresponding name. This
9338 package should contain any declarations that would be useful for
9339 interfacing to the language (implementation) represented by the
9340 convention. Any declarations useful for interfacing to any language on
9341 the given hardware architecture should be provided directly in
9342 @code{Interfaces}.
9343 @end cartouche
9344 Followed. An additional package not defined
9345 in the Ada Reference Manual is @code{Interfaces.CPP}, used
9346 for interfacing to C++.
9347
9348 @sp 1
9349 @cartouche
9350 An implementation supporting an interface to C, COBOL, or Fortran should
9351 provide the corresponding package or packages described in the following
9352 clauses.
9353 @end cartouche
9354 Followed. GNAT provides all the packages described in this section.
9355
9356 @cindex C, interfacing with
9357 @unnumberedsec B.3(63-71): Interfacing with C
9358 @sp 1
9359 @cartouche
9360 An implementation should support the following interface correspondences
9361 between Ada and C@.
9362 @end cartouche
9363 Followed.
9364
9365 @sp 1
9366 @cartouche
9367 An Ada procedure corresponds to a void-returning C function.
9368 @end cartouche
9369 Followed.
9370
9371 @sp 1
9372 @cartouche
9373 An Ada function corresponds to a non-void C function.
9374 @end cartouche
9375 Followed.
9376
9377 @sp 1
9378 @cartouche
9379 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
9380 function.
9381 @end cartouche
9382 Followed.
9383
9384 @sp 1
9385 @cartouche
9386 An Ada @code{in} parameter of an access-to-object type with designated
9387 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
9388 where @var{t} is the C type corresponding to the Ada type @var{T}.
9389 @end cartouche
9390 Followed.
9391
9392 @sp 1
9393 @cartouche
9394 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
9395 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
9396 argument to a C function, where @var{t} is the C type corresponding to
9397 the Ada type @var{T}. In the case of an elementary @code{out} or
9398 @code{in out} parameter, a pointer to a temporary copy is used to
9399 preserve by-copy semantics.
9400 @end cartouche
9401 Followed.
9402
9403 @sp 1
9404 @cartouche
9405 An Ada parameter of a record type @var{T}, of any mode, is passed as a
9406 @code{@var{t}*} argument to a C function, where @var{t} is the C
9407 structure corresponding to the Ada type @var{T}.
9408 @end cartouche
9409 Followed. This convention may be overridden by the use of the C_Pass_By_Copy
9410 pragma, or Convention, or by explicitly specifying the mechanism for a given
9411 call using an extended import or export pragma.
9412
9413 @sp 1
9414 @cartouche
9415 An Ada parameter of an array type with component type @var{T}, of any
9416 mode, is passed as a @code{@var{t}*} argument to a C function, where
9417 @var{t} is the C type corresponding to the Ada type @var{T}.
9418 @end cartouche
9419 Followed.
9420
9421 @sp 1
9422 @cartouche
9423 An Ada parameter of an access-to-subprogram type is passed as a pointer
9424 to a C function whose prototype corresponds to the designated
9425 subprogram's specification.
9426 @end cartouche
9427 Followed.
9428
9429 @cindex COBOL, interfacing with
9430 @unnumberedsec B.4(95-98): Interfacing with COBOL
9431 @sp 1
9432 @cartouche
9433 An Ada implementation should support the following interface
9434 correspondences between Ada and COBOL@.
9435 @end cartouche
9436 Followed.
9437
9438 @sp 1
9439 @cartouche
9440 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
9441 the COBOL type corresponding to @var{T}.
9442 @end cartouche
9443 Followed.
9444
9445 @sp 1
9446 @cartouche
9447 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
9448 the corresponding COBOL type.
9449 @end cartouche
9450 Followed.
9451
9452 @sp 1
9453 @cartouche
9454 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
9455 COBOL type corresponding to the Ada parameter type; for scalars, a local
9456 copy is used if necessary to ensure by-copy semantics.
9457 @end cartouche
9458 Followed.
9459
9460 @cindex Fortran, interfacing with
9461 @unnumberedsec B.5(22-26): Interfacing with Fortran
9462 @sp 1
9463 @cartouche
9464 An Ada implementation should support the following interface
9465 correspondences between Ada and Fortran:
9466 @end cartouche
9467 Followed.
9468
9469 @sp 1
9470 @cartouche
9471 An Ada procedure corresponds to a Fortran subroutine.
9472 @end cartouche
9473 Followed.
9474
9475 @sp 1
9476 @cartouche
9477 An Ada function corresponds to a Fortran function.
9478 @end cartouche
9479 Followed.
9480
9481 @sp 1
9482 @cartouche
9483 An Ada parameter of an elementary, array, or record type @var{T} is
9484 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
9485 the Fortran type corresponding to the Ada type @var{T}, and where the
9486 INTENT attribute of the corresponding dummy argument matches the Ada
9487 formal parameter mode; the Fortran implementation's parameter passing
9488 conventions are used. For elementary types, a local copy is used if
9489 necessary to ensure by-copy semantics.
9490 @end cartouche
9491 Followed.
9492
9493 @sp 1
9494 @cartouche
9495 An Ada parameter of an access-to-subprogram type is passed as a
9496 reference to a Fortran procedure whose interface corresponds to the
9497 designated subprogram's specification.
9498 @end cartouche
9499 Followed.
9500
9501 @cindex Machine operations
9502 @unnumberedsec C.1(3-5): Access to Machine Operations
9503 @sp 1
9504 @cartouche
9505 The machine code or intrinsic support should allow access to all
9506 operations normally available to assembly language programmers for the
9507 target environment, including privileged instructions, if any.
9508 @end cartouche
9509 Followed.
9510
9511 @sp 1
9512 @cartouche
9513 The interfacing pragmas (see Annex B) should support interface to
9514 assembler; the default assembler should be associated with the
9515 convention identifier @code{Assembler}.
9516 @end cartouche
9517 Followed.
9518
9519 @sp 1
9520 @cartouche
9521 If an entity is exported to assembly language, then the implementation
9522 should allocate it at an addressable location, and should ensure that it
9523 is retained by the linking process, even if not otherwise referenced
9524 from the Ada code. The implementation should assume that any call to a
9525 machine code or assembler subprogram is allowed to read or update every
9526 object that is specified as exported.
9527 @end cartouche
9528 Followed.
9529
9530 @unnumberedsec C.1(10-16): Access to Machine Operations
9531 @sp 1
9532 @cartouche
9533 The implementation should ensure that little or no overhead is
9534 associated with calling intrinsic and machine-code subprograms.
9535 @end cartouche
9536 Followed for both intrinsics and machine-code subprograms.
9537
9538 @sp 1
9539 @cartouche
9540 It is recommended that intrinsic subprograms be provided for convenient
9541 access to any machine operations that provide special capabilities or
9542 efficiency and that are not otherwise available through the language
9543 constructs.
9544 @end cartouche
9545 Followed. A full set of machine operation intrinsic subprograms is provided.
9546
9547 @sp 1
9548 @cartouche
9549 Atomic read-modify-write operations---e.g.@:, test and set, compare and
9550 swap, decrement and test, enqueue/dequeue.
9551 @end cartouche
9552 Followed on any target supporting such operations.
9553
9554 @sp 1
9555 @cartouche
9556 Standard numeric functions---e.g.@:, sin, log.
9557 @end cartouche
9558 Followed on any target supporting such operations.
9559
9560 @sp 1
9561 @cartouche
9562 String manipulation operations---e.g.@:, translate and test.
9563 @end cartouche
9564 Followed on any target supporting such operations.
9565
9566 @sp 1
9567 @cartouche
9568 Vector operations---e.g.@:, compare vector against thresholds.
9569 @end cartouche
9570 Followed on any target supporting such operations.
9571
9572 @sp 1
9573 @cartouche
9574 Direct operations on I/O ports.
9575 @end cartouche
9576 Followed on any target supporting such operations.
9577
9578 @cindex Interrupt support
9579 @unnumberedsec C.3(28): Interrupt Support
9580 @sp 1
9581 @cartouche
9582 If the @code{Ceiling_Locking} policy is not in effect, the
9583 implementation should provide means for the application to specify which
9584 interrupts are to be blocked during protected actions, if the underlying
9585 system allows for a finer-grain control of interrupt blocking.
9586 @end cartouche
9587 Followed. The underlying system does not allow for finer-grain control
9588 of interrupt blocking.
9589
9590 @cindex Protected procedure handlers
9591 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
9592 @sp 1
9593 @cartouche
9594 Whenever possible, the implementation should allow interrupt handlers to
9595 be called directly by the hardware.
9596 @end cartouche
9597 Followed on any target where the underlying operating system permits
9598 such direct calls.
9599
9600 @sp 1
9601 @cartouche
9602 Whenever practical, violations of any
9603 implementation-defined restrictions should be detected before run time.
9604 @end cartouche
9605 Followed. Compile time warnings are given when possible.
9606
9607 @cindex Package @code{Interrupts}
9608 @findex Interrupts
9609 @unnumberedsec C.3.2(25): Package @code{Interrupts}
9610
9611 @sp 1
9612 @cartouche
9613 If implementation-defined forms of interrupt handler procedures are
9614 supported, such as protected procedures with parameters, then for each
9615 such form of a handler, a type analogous to @code{Parameterless_Handler}
9616 should be specified in a child package of @code{Interrupts}, with the
9617 same operations as in the predefined package Interrupts.
9618 @end cartouche
9619 Followed.
9620
9621 @cindex Pre-elaboration requirements
9622 @unnumberedsec C.4(14): Pre-elaboration Requirements
9623 @sp 1
9624 @cartouche
9625 It is recommended that pre-elaborated packages be implemented in such a
9626 way that there should be little or no code executed at run time for the
9627 elaboration of entities not already covered by the Implementation
9628 Requirements.
9629 @end cartouche
9630 Followed. Executable code is generated in some cases, e.g.@: loops
9631 to initialize large arrays.
9632
9633 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
9634 @sp 1
9635 @cartouche
9636 If the pragma applies to an entity, then the implementation should
9637 reduce the amount of storage used for storing names associated with that
9638 entity.
9639 @end cartouche
9640 Followed.
9641
9642 @cindex Package @code{Task_Attributes}
9643 @findex Task_Attributes
9644 @unnumberedsec C.7.2(30): The Package Task_Attributes
9645 @sp 1
9646 @cartouche
9647 Some implementations are targeted to domains in which memory use at run
9648 time must be completely deterministic. For such implementations, it is
9649 recommended that the storage for task attributes will be pre-allocated
9650 statically and not from the heap. This can be accomplished by either
9651 placing restrictions on the number and the size of the task's
9652 attributes, or by using the pre-allocated storage for the first @var{N}
9653 attribute objects, and the heap for the others. In the latter case,
9654 @var{N} should be documented.
9655 @end cartouche
9656 Not followed. This implementation is not targeted to such a domain.
9657
9658 @cindex Locking Policies
9659 @unnumberedsec D.3(17): Locking Policies
9660
9661 @sp 1
9662 @cartouche
9663 The implementation should use names that end with @samp{_Locking} for
9664 locking policies defined by the implementation.
9665 @end cartouche
9666 Followed. Two implementation-defined locking policies are defined,
9667 whose names (@code{Inheritance_Locking} and
9668 @code{Concurrent_Readers_Locking}) follow this suggestion.
9669
9670 @cindex Entry queuing policies
9671 @unnumberedsec D.4(16): Entry Queuing Policies
9672 @sp 1
9673 @cartouche
9674 Names that end with @samp{_Queuing} should be used
9675 for all implementation-defined queuing policies.
9676 @end cartouche
9677 Followed. No such implementation-defined queuing policies exist.
9678
9679 @cindex Preemptive abort
9680 @unnumberedsec D.6(9-10): Preemptive Abort
9681 @sp 1
9682 @cartouche
9683 Even though the @code{abort_statement} is included in the list of
9684 potentially blocking operations (see 9.5.1), it is recommended that this
9685 statement be implemented in a way that never requires the task executing
9686 the @code{abort_statement} to block.
9687 @end cartouche
9688 Followed.
9689
9690 @sp 1
9691 @cartouche
9692 On a multi-processor, the delay associated with aborting a task on
9693 another processor should be bounded; the implementation should use
9694 periodic polling, if necessary, to achieve this.
9695 @end cartouche
9696 Followed.
9697
9698 @cindex Tasking restrictions
9699 @unnumberedsec D.7(21): Tasking Restrictions
9700 @sp 1
9701 @cartouche
9702 When feasible, the implementation should take advantage of the specified
9703 restrictions to produce a more efficient implementation.
9704 @end cartouche
9705 GNAT currently takes advantage of these restrictions by providing an optimized
9706 run time when the Ravenscar profile and the GNAT restricted run time set
9707 of restrictions are specified. See pragma @code{Profile (Ravenscar)} and
9708 pragma @code{Profile (Restricted)} for more details.
9709
9710 @cindex Time, monotonic
9711 @unnumberedsec D.8(47-49): Monotonic Time
9712 @sp 1
9713 @cartouche
9714 When appropriate, implementations should provide configuration
9715 mechanisms to change the value of @code{Tick}.
9716 @end cartouche
9717 Such configuration mechanisms are not appropriate to this implementation
9718 and are thus not supported.
9719
9720 @sp 1
9721 @cartouche
9722 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
9723 be implemented as transformations of the same time base.
9724 @end cartouche
9725 Followed.
9726
9727 @sp 1
9728 @cartouche
9729 It is recommended that the @dfn{best} time base which exists in
9730 the underlying system be available to the application through
9731 @code{Clock}. @dfn{Best} may mean highest accuracy or largest range.
9732 @end cartouche
9733 Followed.
9734
9735 @cindex Partition communication subsystem
9736 @cindex PCS
9737 @unnumberedsec E.5(28-29): Partition Communication Subsystem
9738 @sp 1
9739 @cartouche
9740 Whenever possible, the PCS on the called partition should allow for
9741 multiple tasks to call the RPC-receiver with different messages and
9742 should allow them to block until the corresponding subprogram body
9743 returns.
9744 @end cartouche
9745 Followed by GLADE, a separately supplied PCS that can be used with
9746 GNAT.
9747
9748 @sp 1
9749 @cartouche
9750 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
9751 should raise @code{Storage_Error} if it runs out of space trying to
9752 write the @code{Item} into the stream.
9753 @end cartouche
9754 Followed by GLADE, a separately supplied PCS that can be used with
9755 GNAT@.
9756
9757 @cindex COBOL support
9758 @unnumberedsec F(7): COBOL Support
9759 @sp 1
9760 @cartouche
9761 If COBOL (respectively, C) is widely supported in the target
9762 environment, implementations supporting the Information Systems Annex
9763 should provide the child package @code{Interfaces.COBOL} (respectively,
9764 @code{Interfaces.C}) specified in Annex B and should support a
9765 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
9766 pragmas (see Annex B), thus allowing Ada programs to interface with
9767 programs written in that language.
9768 @end cartouche
9769 Followed.
9770
9771 @cindex Decimal radix support
9772 @unnumberedsec F.1(2): Decimal Radix Support
9773 @sp 1
9774 @cartouche
9775 Packed decimal should be used as the internal representation for objects
9776 of subtype @var{S} when @var{S}'Machine_Radix = 10.
9777 @end cartouche
9778 Not followed. GNAT ignores @var{S}'Machine_Radix and always uses binary
9779 representations.
9780
9781 @cindex Numerics
9782 @unnumberedsec G: Numerics
9783 @sp 2
9784 @cartouche
9785 If Fortran (respectively, C) is widely supported in the target
9786 environment, implementations supporting the Numerics Annex
9787 should provide the child package @code{Interfaces.Fortran} (respectively,
9788 @code{Interfaces.C}) specified in Annex B and should support a
9789 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
9790 pragmas (see Annex B), thus allowing Ada programs to interface with
9791 programs written in that language.
9792 @end cartouche
9793 Followed.
9794
9795 @cindex Complex types
9796 @unnumberedsec G.1.1(56-58): Complex Types
9797 @sp 2
9798 @cartouche
9799 Because the usual mathematical meaning of multiplication of a complex
9800 operand and a real operand is that of the scaling of both components of
9801 the former by the latter, an implementation should not perform this
9802 operation by first promoting the real operand to complex type and then
9803 performing a full complex multiplication. In systems that, in the
9804 future, support an Ada binding to IEC 559:1989, the latter technique
9805 will not generate the required result when one of the components of the
9806 complex operand is infinite. (Explicit multiplication of the infinite
9807 component by the zero component obtained during promotion yields a NaN
9808 that propagates into the final result.) Analogous advice applies in the
9809 case of multiplication of a complex operand and a pure-imaginary
9810 operand, and in the case of division of a complex operand by a real or
9811 pure-imaginary operand.
9812 @end cartouche
9813 Not followed.
9814
9815 @sp 1
9816 @cartouche
9817 Similarly, because the usual mathematical meaning of addition of a
9818 complex operand and a real operand is that the imaginary operand remains
9819 unchanged, an implementation should not perform this operation by first
9820 promoting the real operand to complex type and then performing a full
9821 complex addition. In implementations in which the @code{Signed_Zeros}
9822 attribute of the component type is @code{True} (and which therefore
9823 conform to IEC 559:1989 in regard to the handling of the sign of zero in
9824 predefined arithmetic operations), the latter technique will not
9825 generate the required result when the imaginary component of the complex
9826 operand is a negatively signed zero. (Explicit addition of the negative
9827 zero to the zero obtained during promotion yields a positive zero.)
9828 Analogous advice applies in the case of addition of a complex operand
9829 and a pure-imaginary operand, and in the case of subtraction of a
9830 complex operand and a real or pure-imaginary operand.
9831 @end cartouche
9832 Not followed.
9833
9834 @sp 1
9835 @cartouche
9836 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
9837 attempt to provide a rational treatment of the signs of zero results and
9838 result components. As one example, the result of the @code{Argument}
9839 function should have the sign of the imaginary component of the
9840 parameter @code{X} when the point represented by that parameter lies on
9841 the positive real axis; as another, the sign of the imaginary component
9842 of the @code{Compose_From_Polar} function should be the same as
9843 (respectively, the opposite of) that of the @code{Argument} parameter when that
9844 parameter has a value of zero and the @code{Modulus} parameter has a
9845 nonnegative (respectively, negative) value.
9846 @end cartouche
9847 Followed.
9848
9849 @cindex Complex elementary functions
9850 @unnumberedsec G.1.2(49): Complex Elementary Functions
9851 @sp 1
9852 @cartouche
9853 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
9854 @code{True} should attempt to provide a rational treatment of the signs
9855 of zero results and result components. For example, many of the complex
9856 elementary functions have components that are odd functions of one of
9857 the parameter components; in these cases, the result component should
9858 have the sign of the parameter component at the origin. Other complex
9859 elementary functions have zero components whose sign is opposite that of
9860 a parameter component at the origin, or is always positive or always
9861 negative.
9862 @end cartouche
9863 Followed.
9864
9865 @cindex Accuracy requirements
9866 @unnumberedsec G.2.4(19): Accuracy Requirements
9867 @sp 1
9868 @cartouche
9869 The versions of the forward trigonometric functions without a
9870 @code{Cycle} parameter should not be implemented by calling the
9871 corresponding version with a @code{Cycle} parameter of
9872 @code{2.0*Numerics.Pi}, since this will not provide the required
9873 accuracy in some portions of the domain. For the same reason, the
9874 version of @code{Log} without a @code{Base} parameter should not be
9875 implemented by calling the corresponding version with a @code{Base}
9876 parameter of @code{Numerics.e}.
9877 @end cartouche
9878 Followed.
9879
9880 @cindex Complex arithmetic accuracy
9881 @cindex Accuracy, complex arithmetic
9882 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
9883
9884 @sp 1
9885 @cartouche
9886 The version of the @code{Compose_From_Polar} function without a
9887 @code{Cycle} parameter should not be implemented by calling the
9888 corresponding version with a @code{Cycle} parameter of
9889 @code{2.0*Numerics.Pi}, since this will not provide the required
9890 accuracy in some portions of the domain.
9891 @end cartouche
9892 Followed.
9893
9894 @cindex Sequential elaboration policy
9895 @unnumberedsec H.6(15/2): Pragma Partition_Elaboration_Policy
9896
9897 @sp 1
9898 @cartouche
9899 If the partition elaboration policy is @code{Sequential} and the
9900 Environment task becomes permanently blocked during elaboration then the
9901 partition is deadlocked and it is recommended that the partition be
9902 immediately terminated.
9903 @end cartouche
9904 Not followed.
9905
9906 @c -----------------------------------------
9907 @node Implementation Defined Characteristics
9908 @chapter Implementation Defined Characteristics
9909
9910 @noindent
9911 In addition to the implementation dependent pragmas and attributes, and the
9912 implementation advice, there are a number of other Ada features that are
9913 potentially implementation dependent and are designated as
9914 implementation-defined. These are mentioned throughout the Ada Reference
9915 Manual, and are summarized in Annex M@.
9916
9917 A requirement for conforming Ada compilers is that they provide
9918 documentation describing how the implementation deals with each of these
9919 issues. In this chapter, you will find each point in Annex M listed
9920 followed by a description in italic font of how GNAT
9921 handles the implementation dependence.
9922
9923 You can use this chapter as a guide to minimizing implementation
9924 dependent features in your programs if portability to other compilers
9925 and other operating systems is an important consideration. The numbers
9926 in each section below correspond to the paragraph number in the Ada
9927 Reference Manual.
9928
9929 @sp 1
9930 @cartouche
9931 @noindent
9932 @strong{2}. Whether or not each recommendation given in Implementation
9933 Advice is followed. See 1.1.2(37).
9934 @end cartouche
9935 @noindent
9936 @xref{Implementation Advice}.
9937
9938 @sp 1
9939 @cartouche
9940 @noindent
9941 @strong{3}. Capacity limitations of the implementation. See 1.1.3(3).
9942 @end cartouche
9943 @noindent
9944 The complexity of programs that can be processed is limited only by the
9945 total amount of available virtual memory, and disk space for the
9946 generated object files.
9947
9948 @sp 1
9949 @cartouche
9950 @noindent
9951 @strong{4}. Variations from the standard that are impractical to avoid
9952 given the implementation's execution environment. See 1.1.3(6).
9953 @end cartouche
9954 @noindent
9955 There are no variations from the standard.
9956
9957 @sp 1
9958 @cartouche
9959 @noindent
9960 @strong{5}. Which @code{code_statement}s cause external
9961 interactions. See 1.1.3(10).
9962 @end cartouche
9963 @noindent
9964 Any @code{code_statement} can potentially cause external interactions.
9965
9966 @sp 1
9967 @cartouche
9968 @noindent
9969 @strong{6}. The coded representation for the text of an Ada
9970 program. See 2.1(4).
9971 @end cartouche
9972 @noindent
9973 See separate section on source representation.
9974
9975 @sp 1
9976 @cartouche
9977 @noindent
9978 @strong{7}. The control functions allowed in comments. See 2.1(14).
9979 @end cartouche
9980 @noindent
9981 See separate section on source representation.
9982
9983 @sp 1
9984 @cartouche
9985 @noindent
9986 @strong{8}. The representation for an end of line. See 2.2(2).
9987 @end cartouche
9988 @noindent
9989 See separate section on source representation.
9990
9991 @sp 1
9992 @cartouche
9993 @noindent
9994 @strong{9}. Maximum supported line length and lexical element
9995 length. See 2.2(15).
9996 @end cartouche
9997 @noindent
9998 The maximum line length is 255 characters and the maximum length of
9999 a lexical element is also 255 characters. This is the default setting
10000 if not overridden by the use of compiler switch @option{-gnaty} (which
10001 sets the maximum to 79) or @option{-gnatyMnn} which allows the maximum
10002 line length to be specified to be any value up to 32767. The maximum
10003 length of a lexical element is the same as the maximum line length.
10004
10005 @sp 1
10006 @cartouche
10007 @noindent
10008 @strong{10}. Implementation defined pragmas. See 2.8(14).
10009 @end cartouche
10010 @noindent
10011
10012 @xref{Implementation Defined Pragmas}.
10013
10014 @sp 1
10015 @cartouche
10016 @noindent
10017 @strong{11}. Effect of pragma @code{Optimize}. See 2.8(27).
10018 @end cartouche
10019 @noindent
10020 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
10021 parameter, checks that the optimization flag is set, and aborts if it is
10022 not.
10023
10024 @sp 1
10025 @cartouche
10026 @noindent
10027 @strong{12}. The sequence of characters of the value returned by
10028 @code{@var{S}'Image} when some of the graphic characters of
10029 @code{@var{S}'Wide_Image} are not defined in @code{Character}. See
10030 3.5(37).
10031 @end cartouche
10032 @noindent
10033 The sequence of characters is as defined by the wide character encoding
10034 method used for the source. See section on source representation for
10035 further details.
10036
10037 @sp 1
10038 @cartouche
10039 @noindent
10040 @strong{13}. The predefined integer types declared in
10041 @code{Standard}. See 3.5.4(25).
10042 @end cartouche
10043 @noindent
10044 @table @code
10045 @item Short_Short_Integer
10046 8 bit signed
10047 @item Short_Integer
10048 (Short) 16 bit signed
10049 @item Integer
10050 32 bit signed
10051 @item Long_Integer
10052 64 bit signed (on most 64 bit targets, depending on the C definition of long).
10053 32 bit signed (all other targets)
10054 @item Long_Long_Integer
10055 64 bit signed
10056 @end table
10057
10058 @sp 1
10059 @cartouche
10060 @noindent
10061 @strong{14}. Any nonstandard integer types and the operators defined
10062 for them. See 3.5.4(26).
10063 @end cartouche
10064 @noindent
10065 There are no nonstandard integer types.
10066
10067 @sp 1
10068 @cartouche
10069 @noindent
10070 @strong{15}. Any nonstandard real types and the operators defined for
10071 them. See 3.5.6(8).
10072 @end cartouche
10073 @noindent
10074 There are no nonstandard real types.
10075
10076 @sp 1
10077 @cartouche
10078 @noindent
10079 @strong{16}. What combinations of requested decimal precision and range
10080 are supported for floating point types. See 3.5.7(7).
10081 @end cartouche
10082 @noindent
10083 The precision and range is as defined by the IEEE standard.
10084
10085 @sp 1
10086 @cartouche
10087 @noindent
10088 @strong{17}. The predefined floating point types declared in
10089 @code{Standard}. See 3.5.7(16).
10090 @end cartouche
10091 @noindent
10092 @table @code
10093 @item Short_Float
10094 32 bit IEEE short
10095 @item Float
10096 (Short) 32 bit IEEE short
10097 @item Long_Float
10098 64 bit IEEE long
10099 @item Long_Long_Float
10100 64 bit IEEE long (80 bit IEEE long on x86 processors)
10101 @end table
10102
10103 @sp 1
10104 @cartouche
10105 @noindent
10106 @strong{18}. The small of an ordinary fixed point type. See 3.5.9(8).
10107 @end cartouche
10108 @noindent
10109 @code{Fine_Delta} is 2**(@minus{}63)
10110
10111 @sp 1
10112 @cartouche
10113 @noindent
10114 @strong{19}. What combinations of small, range, and digits are
10115 supported for fixed point types. See 3.5.9(10).
10116 @end cartouche
10117 @noindent
10118 Any combinations are permitted that do not result in a small less than
10119 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
10120 If the mantissa is larger than 53 bits on machines where Long_Long_Float
10121 is 64 bits (true of all architectures except ia32), then the output from
10122 Text_IO is accurate to only 53 bits, rather than the full mantissa. This
10123 is because floating-point conversions are used to convert fixed point.
10124
10125 @sp 1
10126 @cartouche
10127 @noindent
10128 @strong{20}. The result of @code{Tags.Expanded_Name} for types declared
10129 within an unnamed @code{block_statement}. See 3.9(10).
10130 @end cartouche
10131 @noindent
10132 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
10133 decimal integer are allocated.
10134
10135 @sp 1
10136 @cartouche
10137 @noindent
10138 @strong{21}. Implementation-defined attributes. See 4.1.4(12).
10139 @end cartouche
10140 @noindent
10141 @xref{Implementation Defined Attributes}.
10142
10143 @sp 1
10144 @cartouche
10145 @noindent
10146 @strong{22}. Any implementation-defined time types. See 9.6(6).
10147 @end cartouche
10148 @noindent
10149 There are no implementation-defined time types.
10150
10151 @sp 1
10152 @cartouche
10153 @noindent
10154 @strong{23}. The time base associated with relative delays.
10155 @end cartouche
10156 @noindent
10157 See 9.6(20). The time base used is that provided by the C library
10158 function @code{gettimeofday}.
10159
10160 @sp 1
10161 @cartouche
10162 @noindent
10163 @strong{24}. The time base of the type @code{Calendar.Time}. See
10164 9.6(23).
10165 @end cartouche
10166 @noindent
10167 The time base used is that provided by the C library function
10168 @code{gettimeofday}.
10169
10170 @sp 1
10171 @cartouche
10172 @noindent
10173 @strong{25}. The time zone used for package @code{Calendar}
10174 operations. See 9.6(24).
10175 @end cartouche
10176 @noindent
10177 The time zone used by package @code{Calendar} is the current system time zone
10178 setting for local time, as accessed by the C library function
10179 @code{localtime}.
10180
10181 @sp 1
10182 @cartouche
10183 @noindent
10184 @strong{26}. Any limit on @code{delay_until_statements} of
10185 @code{select_statements}. See 9.6(29).
10186 @end cartouche
10187 @noindent
10188 There are no such limits.
10189
10190 @sp 1
10191 @cartouche
10192 @noindent
10193 @strong{27}. Whether or not two non-overlapping parts of a composite
10194 object are independently addressable, in the case where packing, record
10195 layout, or @code{Component_Size} is specified for the object. See
10196 9.10(1).
10197 @end cartouche
10198 @noindent
10199 Separate components are independently addressable if they do not share
10200 overlapping storage units.
10201
10202 @sp 1
10203 @cartouche
10204 @noindent
10205 @strong{28}. The representation for a compilation. See 10.1(2).
10206 @end cartouche
10207 @noindent
10208 A compilation is represented by a sequence of files presented to the
10209 compiler in a single invocation of the @command{gcc} command.
10210
10211 @sp 1
10212 @cartouche
10213 @noindent
10214 @strong{29}. Any restrictions on compilations that contain multiple
10215 compilation_units. See 10.1(4).
10216 @end cartouche
10217 @noindent
10218 No single file can contain more than one compilation unit, but any
10219 sequence of files can be presented to the compiler as a single
10220 compilation.
10221
10222 @sp 1
10223 @cartouche
10224 @noindent
10225 @strong{30}. The mechanisms for creating an environment and for adding
10226 and replacing compilation units. See 10.1.4(3).
10227 @end cartouche
10228 @noindent
10229 See separate section on compilation model.
10230
10231 @sp 1
10232 @cartouche
10233 @noindent
10234 @strong{31}. The manner of explicitly assigning library units to a
10235 partition. See 10.2(2).
10236 @end cartouche
10237 @noindent
10238 If a unit contains an Ada main program, then the Ada units for the partition
10239 are determined by recursive application of the rules in the Ada Reference
10240 Manual section 10.2(2-6). In other words, the Ada units will be those that
10241 are needed by the main program, and then this definition of need is applied
10242 recursively to those units, and the partition contains the transitive
10243 closure determined by this relationship. In short, all the necessary units
10244 are included, with no need to explicitly specify the list. If additional
10245 units are required, e.g.@: by foreign language units, then all units must be
10246 mentioned in the context clause of one of the needed Ada units.
10247
10248 If the partition contains no main program, or if the main program is in
10249 a language other than Ada, then GNAT
10250 provides the binder options @option{-z} and @option{-n} respectively, and in
10251 this case a list of units can be explicitly supplied to the binder for
10252 inclusion in the partition (all units needed by these units will also
10253 be included automatically). For full details on the use of these
10254 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
10255 @value{EDITION} User's Guide}.
10256
10257 @sp 1
10258 @cartouche
10259 @noindent
10260 @strong{32}. The implementation-defined means, if any, of specifying
10261 which compilation units are needed by a given compilation unit. See
10262 10.2(2).
10263 @end cartouche
10264 @noindent
10265 The units needed by a given compilation unit are as defined in
10266 the Ada Reference Manual section 10.2(2-6). There are no
10267 implementation-defined pragmas or other implementation-defined
10268 means for specifying needed units.
10269
10270 @sp 1
10271 @cartouche
10272 @noindent
10273 @strong{33}. The manner of designating the main subprogram of a
10274 partition. See 10.2(7).
10275 @end cartouche
10276 @noindent
10277 The main program is designated by providing the name of the
10278 corresponding @file{ALI} file as the input parameter to the binder.
10279
10280 @sp 1
10281 @cartouche
10282 @noindent
10283 @strong{34}. The order of elaboration of @code{library_items}. See
10284 10.2(18).
10285 @end cartouche
10286 @noindent
10287 The first constraint on ordering is that it meets the requirements of
10288 Chapter 10 of the Ada Reference Manual. This still leaves some
10289 implementation dependent choices, which are resolved by first
10290 elaborating bodies as early as possible (i.e., in preference to specs
10291 where there is a choice), and second by evaluating the immediate with
10292 clauses of a unit to determine the probably best choice, and
10293 third by elaborating in alphabetical order of unit names
10294 where a choice still remains.
10295
10296 @sp 1
10297 @cartouche
10298 @noindent
10299 @strong{35}. Parameter passing and function return for the main
10300 subprogram. See 10.2(21).
10301 @end cartouche
10302 @noindent
10303 The main program has no parameters. It may be a procedure, or a function
10304 returning an integer type. In the latter case, the returned integer
10305 value is the return code of the program (overriding any value that
10306 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
10307
10308 @sp 1
10309 @cartouche
10310 @noindent
10311 @strong{36}. The mechanisms for building and running partitions. See
10312 10.2(24).
10313 @end cartouche
10314 @noindent
10315 GNAT itself supports programs with only a single partition. The GNATDIST
10316 tool provided with the GLADE package (which also includes an implementation
10317 of the PCS) provides a completely flexible method for building and running
10318 programs consisting of multiple partitions. See the separate GLADE manual
10319 for details.
10320
10321 @sp 1
10322 @cartouche
10323 @noindent
10324 @strong{37}. The details of program execution, including program
10325 termination. See 10.2(25).
10326 @end cartouche
10327 @noindent
10328 See separate section on compilation model.
10329
10330 @sp 1
10331 @cartouche
10332 @noindent
10333 @strong{38}. The semantics of any non-active partitions supported by the
10334 implementation. See 10.2(28).
10335 @end cartouche
10336 @noindent
10337 Passive partitions are supported on targets where shared memory is
10338 provided by the operating system. See the GLADE reference manual for
10339 further details.
10340
10341 @sp 1
10342 @cartouche
10343 @noindent
10344 @strong{39}. The information returned by @code{Exception_Message}. See
10345 11.4.1(10).
10346 @end cartouche
10347 @noindent
10348 Exception message returns the null string unless a specific message has
10349 been passed by the program.
10350
10351 @sp 1
10352 @cartouche
10353 @noindent
10354 @strong{40}. The result of @code{Exceptions.Exception_Name} for types
10355 declared within an unnamed @code{block_statement}. See 11.4.1(12).
10356 @end cartouche
10357 @noindent
10358 Blocks have implementation defined names of the form @code{B@var{nnn}}
10359 where @var{nnn} is an integer.
10360
10361 @sp 1
10362 @cartouche
10363 @noindent
10364 @strong{41}. The information returned by
10365 @code{Exception_Information}. See 11.4.1(13).
10366 @end cartouche
10367 @noindent
10368 @code{Exception_Information} returns a string in the following format:
10369
10370 @smallexample
10371 @emph{Exception_Name:} nnnnn
10372 @emph{Message:} mmmmm
10373 @emph{PID:} ppp
10374 @emph{Call stack traceback locations:}
10375 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
10376 @end smallexample
10377
10378 @noindent
10379 where
10380
10381 @itemize @bullet
10382 @item
10383 @code{nnnn} is the fully qualified name of the exception in all upper
10384 case letters. This line is always present.
10385
10386 @item
10387 @code{mmmm} is the message (this line present only if message is non-null)
10388
10389 @item
10390 @code{ppp} is the Process Id value as a decimal integer (this line is
10391 present only if the Process Id is nonzero). Currently we are
10392 not making use of this field.
10393
10394 @item
10395 The Call stack traceback locations line and the following values
10396 are present only if at least one traceback location was recorded.
10397 The values are given in C style format, with lower case letters
10398 for a-f, and only as many digits present as are necessary.
10399 @end itemize
10400
10401 @noindent
10402 The line terminator sequence at the end of each line, including
10403 the last line is a single @code{LF} character (@code{16#0A#}).
10404
10405 @sp 1
10406 @cartouche
10407 @noindent
10408 @strong{42}. Implementation-defined check names. See 11.5(27).
10409 @end cartouche
10410 @noindent
10411 The implementation defined check name Alignment_Check controls checking of
10412 address clause values for proper alignment (that is, the address supplied
10413 must be consistent with the alignment of the type).
10414
10415 In addition, a user program can add implementation-defined check names
10416 by means of the pragma Check_Name.
10417
10418 @sp 1
10419 @cartouche
10420 @noindent
10421 @strong{43}. The interpretation of each aspect of representation. See
10422 13.1(20).
10423 @end cartouche
10424 @noindent
10425 See separate section on data representations.
10426
10427 @sp 1
10428 @cartouche
10429 @noindent
10430 @strong{44}. Any restrictions placed upon representation items. See
10431 13.1(20).
10432 @end cartouche
10433 @noindent
10434 See separate section on data representations.
10435
10436 @sp 1
10437 @cartouche
10438 @noindent
10439 @strong{45}. The meaning of @code{Size} for indefinite subtypes. See
10440 13.3(48).
10441 @end cartouche
10442 @noindent
10443 Size for an indefinite subtype is the maximum possible size, except that
10444 for the case of a subprogram parameter, the size of the parameter object
10445 is the actual size.
10446
10447 @sp 1
10448 @cartouche
10449 @noindent
10450 @strong{46}. The default external representation for a type tag. See
10451 13.3(75).
10452 @end cartouche
10453 @noindent
10454 The default external representation for a type tag is the fully expanded
10455 name of the type in upper case letters.
10456
10457 @sp 1
10458 @cartouche
10459 @noindent
10460 @strong{47}. What determines whether a compilation unit is the same in
10461 two different partitions. See 13.3(76).
10462 @end cartouche
10463 @noindent
10464 A compilation unit is the same in two different partitions if and only
10465 if it derives from the same source file.
10466
10467 @sp 1
10468 @cartouche
10469 @noindent
10470 @strong{48}. Implementation-defined components. See 13.5.1(15).
10471 @end cartouche
10472 @noindent
10473 The only implementation defined component is the tag for a tagged type,
10474 which contains a pointer to the dispatching table.
10475
10476 @sp 1
10477 @cartouche
10478 @noindent
10479 @strong{49}. If @code{Word_Size} = @code{Storage_Unit}, the default bit
10480 ordering. See 13.5.3(5).
10481 @end cartouche
10482 @noindent
10483 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
10484 implementation, so no non-default bit ordering is supported. The default
10485 bit ordering corresponds to the natural endianness of the target architecture.
10486
10487 @sp 1
10488 @cartouche
10489 @noindent
10490 @strong{50}. The contents of the visible part of package @code{System}
10491 and its language-defined children. See 13.7(2).
10492 @end cartouche
10493 @noindent
10494 See the definition of these packages in files @file{system.ads} and
10495 @file{s-stoele.ads}.
10496
10497 @sp 1
10498 @cartouche
10499 @noindent
10500 @strong{51}. The contents of the visible part of package
10501 @code{System.Machine_Code}, and the meaning of
10502 @code{code_statements}. See 13.8(7).
10503 @end cartouche
10504 @noindent
10505 See the definition and documentation in file @file{s-maccod.ads}.
10506
10507 @sp 1
10508 @cartouche
10509 @noindent
10510 @strong{52}. The effect of unchecked conversion. See 13.9(11).
10511 @end cartouche
10512 @noindent
10513 Unchecked conversion between types of the same size
10514 results in an uninterpreted transmission of the bits from one type
10515 to the other. If the types are of unequal sizes, then in the case of
10516 discrete types, a shorter source is first zero or sign extended as
10517 necessary, and a shorter target is simply truncated on the left.
10518 For all non-discrete types, the source is first copied if necessary
10519 to ensure that the alignment requirements of the target are met, then
10520 a pointer is constructed to the source value, and the result is obtained
10521 by dereferencing this pointer after converting it to be a pointer to the
10522 target type. Unchecked conversions where the target subtype is an
10523 unconstrained array are not permitted. If the target alignment is
10524 greater than the source alignment, then a copy of the result is
10525 made with appropriate alignment
10526
10527 @sp 1
10528 @cartouche
10529 @noindent
10530 @strong{53}. The semantics of operations on invalid representations.
10531 See 13.9.2(10-11).
10532 @end cartouche
10533 @noindent
10534 For assignments and other operations where the use of invalid values cannot
10535 result in erroneous behavior, the compiler ignores the possibility of invalid
10536 values. An exception is raised at the point where an invalid value would
10537 result in erroneous behavior. For example executing:
10538
10539 @smallexample @c ada
10540 procedure invalidvals is
10541 X : Integer := -1;
10542 Y : Natural range 1 .. 10;
10543 for Y'Address use X'Address;
10544 Z : Natural range 1 .. 10;
10545 A : array (Natural range 1 .. 10) of Integer;
10546 begin
10547 Z := Y; -- no exception
10548 A (Z) := 3; -- exception raised;
10549 end;
10550 @end smallexample
10551
10552 @noindent
10553 As indicated, an exception is raised on the array assignment, but not
10554 on the simple assignment of the invalid negative value from Y to Z.
10555
10556 @sp 1
10557 @cartouche
10558 @noindent
10559 @strong{53}. The manner of choosing a storage pool for an access type
10560 when @code{Storage_Pool} is not specified for the type. See 13.11(17).
10561 @end cartouche
10562 @noindent
10563 There are 3 different standard pools used by the compiler when
10564 @code{Storage_Pool} is not specified depending whether the type is local
10565 to a subprogram or defined at the library level and whether
10566 @code{Storage_Size}is specified or not. See documentation in the runtime
10567 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
10568 @code{System.Pool_Local} in files @file{s-poosiz.ads},
10569 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
10570 default pools used.
10571
10572 @sp 1
10573 @cartouche
10574 @noindent
10575 @strong{54}. Whether or not the implementation provides user-accessible
10576 names for the standard pool type(s). See 13.11(17).
10577 @end cartouche
10578 @noindent
10579
10580 See documentation in the sources of the run time mentioned in paragraph
10581 @strong{53} . All these pools are accessible by means of @code{with}'ing
10582 these units.
10583
10584 @sp 1
10585 @cartouche
10586 @noindent
10587 @strong{55}. The meaning of @code{Storage_Size}. See 13.11(18).
10588 @end cartouche
10589 @noindent
10590 @code{Storage_Size} is measured in storage units, and refers to the
10591 total space available for an access type collection, or to the primary
10592 stack space for a task.
10593
10594 @sp 1
10595 @cartouche
10596 @noindent
10597 @strong{56}. Implementation-defined aspects of storage pools. See
10598 13.11(22).
10599 @end cartouche
10600 @noindent
10601 See documentation in the sources of the run time mentioned in paragraph
10602 @strong{53} for details on GNAT-defined aspects of storage pools.
10603
10604 @sp 1
10605 @cartouche
10606 @noindent
10607 @strong{57}. The set of restrictions allowed in a pragma
10608 @code{Restrictions}. See 13.12(7).
10609 @end cartouche
10610 @noindent
10611 @xref{Standard and Implementation Defined Restrictions}.
10612
10613 @sp 1
10614 @cartouche
10615 @noindent
10616 @strong{58}. The consequences of violating limitations on
10617 @code{Restrictions} pragmas. See 13.12(9).
10618 @end cartouche
10619 @noindent
10620 Restrictions that can be checked at compile time result in illegalities
10621 if violated. Currently there are no other consequences of violating
10622 restrictions.
10623
10624 @sp 1
10625 @cartouche
10626 @noindent
10627 @strong{59}. The representation used by the @code{Read} and
10628 @code{Write} attributes of elementary types in terms of stream
10629 elements. See 13.13.2(9).
10630 @end cartouche
10631 @noindent
10632 The representation is the in-memory representation of the base type of
10633 the type, using the number of bits corresponding to the
10634 @code{@var{type}'Size} value, and the natural ordering of the machine.
10635
10636 @sp 1
10637 @cartouche
10638 @noindent
10639 @strong{60}. The names and characteristics of the numeric subtypes
10640 declared in the visible part of package @code{Standard}. See A.1(3).
10641 @end cartouche
10642 @noindent
10643 See items describing the integer and floating-point types supported.
10644
10645 @sp 1
10646 @cartouche
10647 @noindent
10648 @strong{61}. The accuracy actually achieved by the elementary
10649 functions. See A.5.1(1).
10650 @end cartouche
10651 @noindent
10652 The elementary functions correspond to the functions available in the C
10653 library. Only fast math mode is implemented.
10654
10655 @sp 1
10656 @cartouche
10657 @noindent
10658 @strong{62}. The sign of a zero result from some of the operators or
10659 functions in @code{Numerics.Generic_Elementary_Functions}, when
10660 @code{Float_Type'Signed_Zeros} is @code{True}. See A.5.1(46).
10661 @end cartouche
10662 @noindent
10663 The sign of zeroes follows the requirements of the IEEE 754 standard on
10664 floating-point.
10665
10666 @sp 1
10667 @cartouche
10668 @noindent
10669 @strong{63}. The value of
10670 @code{Numerics.Float_Random.Max_Image_Width}. See A.5.2(27).
10671 @end cartouche
10672 @noindent
10673 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10674
10675 @sp 1
10676 @cartouche
10677 @noindent
10678 @strong{64}. The value of
10679 @code{Numerics.Discrete_Random.Max_Image_Width}. See A.5.2(27).
10680 @end cartouche
10681 @noindent
10682 Maximum image width is 6864, see library file @file{s-rannum.ads}.
10683
10684 @sp 1
10685 @cartouche
10686 @noindent
10687 @strong{65}. The algorithms for random number generation. See
10688 A.5.2(32).
10689 @end cartouche
10690 @noindent
10691 The algorithm is the Mersenne Twister, as documented in the source file
10692 @file{s-rannum.adb}. This version of the algorithm has a period of
10693 2**19937-1.
10694
10695 @sp 1
10696 @cartouche
10697 @noindent
10698 @strong{66}. The string representation of a random number generator's
10699 state. See A.5.2(38).
10700 @end cartouche
10701 @noindent
10702 The value returned by the Image function is the concatenation of
10703 the fixed-width decimal representations of the 624 32-bit integers
10704 of the state vector.
10705
10706 @sp 1
10707 @cartouche
10708 @noindent
10709 @strong{67}. The minimum time interval between calls to the
10710 time-dependent Reset procedure that are guaranteed to initiate different
10711 random number sequences. See A.5.2(45).
10712 @end cartouche
10713 @noindent
10714 The minimum period between reset calls to guarantee distinct series of
10715 random numbers is one microsecond.
10716
10717 @sp 1
10718 @cartouche
10719 @noindent
10720 @strong{68}. The values of the @code{Model_Mantissa},
10721 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
10722 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
10723 Annex is not supported. See A.5.3(72).
10724 @end cartouche
10725 @noindent
10726 Run the compiler with @option{-gnatS} to produce a listing of package
10727 @code{Standard}, has the values of all numeric attributes.
10728
10729 @sp 1
10730 @cartouche
10731 @noindent
10732 @strong{69}. Any implementation-defined characteristics of the
10733 input-output packages. See A.7(14).
10734 @end cartouche
10735 @noindent
10736 There are no special implementation defined characteristics for these
10737 packages.
10738
10739 @sp 1
10740 @cartouche
10741 @noindent
10742 @strong{70}. The value of @code{Buffer_Size} in @code{Storage_IO}. See
10743 A.9(10).
10744 @end cartouche
10745 @noindent
10746 All type representations are contiguous, and the @code{Buffer_Size} is
10747 the value of @code{@var{type}'Size} rounded up to the next storage unit
10748 boundary.
10749
10750 @sp 1
10751 @cartouche
10752 @noindent
10753 @strong{71}. External files for standard input, standard output, and
10754 standard error See A.10(5).
10755 @end cartouche
10756 @noindent
10757 These files are mapped onto the files provided by the C streams
10758 libraries. See source file @file{i-cstrea.ads} for further details.
10759
10760 @sp 1
10761 @cartouche
10762 @noindent
10763 @strong{72}. The accuracy of the value produced by @code{Put}. See
10764 A.10.9(36).
10765 @end cartouche
10766 @noindent
10767 If more digits are requested in the output than are represented by the
10768 precision of the value, zeroes are output in the corresponding least
10769 significant digit positions.
10770
10771 @sp 1
10772 @cartouche
10773 @noindent
10774 @strong{73}. The meaning of @code{Argument_Count}, @code{Argument}, and
10775 @code{Command_Name}. See A.15(1).
10776 @end cartouche
10777 @noindent
10778 These are mapped onto the @code{argv} and @code{argc} parameters of the
10779 main program in the natural manner.
10780
10781 @sp 1
10782 @cartouche
10783 @noindent
10784 @strong{74}. The interpretation of the @code{Form} parameter in procedure
10785 @code{Create_Directory}. See A.16(56).
10786 @end cartouche
10787 @noindent
10788 The @code{Form} parameter is not used.
10789
10790 @sp 1
10791 @cartouche
10792 @noindent
10793 @strong{75}. The interpretation of the @code{Form} parameter in procedure
10794 @code{Create_Path}. See A.16(60).
10795 @end cartouche
10796 @noindent
10797 The @code{Form} parameter is not used.
10798
10799 @sp 1
10800 @cartouche
10801 @noindent
10802 @strong{76}. The interpretation of the @code{Form} parameter in procedure
10803 @code{Copy_File}. See A.16(68).
10804 @end cartouche
10805 @noindent
10806 The @code{Form} parameter is case-insensitive.
10807
10808 Two fields are recognized in the @code{Form} parameter:
10809
10810 @table @code
10811
10812 @item preserve=<value>
10813
10814 @item mode=<value>
10815
10816 @end table
10817
10818 @noindent
10819 <value> starts immediately after the character '=' and ends with the
10820 character immediately preceding the next comma (',') or with the last
10821 character of the parameter.
10822
10823 The only possible values for preserve= are:
10824
10825 @table @code
10826
10827 @item no_attributes
10828 Do not try to preserve any file attributes. This is the default if no
10829 preserve= is found in Form.
10830
10831 @item all_attributes
10832 Try to preserve all file attributes (timestamps, access rights).
10833
10834 @item timestamps
10835 Preserve the timestamp of the copied file, but not the other file attributes.
10836
10837 @end table
10838
10839 @noindent
10840 The only possible values for mode= are:
10841
10842 @table @code
10843
10844 @item copy
10845 Only do the copy if the destination file does not already exist. If it already
10846 exists, Copy_File fails.
10847
10848 @item overwrite
10849 Copy the file in all cases. Overwrite an already existing destination file.
10850
10851 @item append
10852 Append the original file to the destination file. If the destination file does
10853 not exist, the destination file is a copy of the source file. When mode=append,
10854 the field preserve=, if it exists, is not taken into account.
10855
10856 @end table
10857
10858 @noindent
10859 If the Form parameter includes one or both of the fields and the value or
10860 values are incorrect, Copy_file fails with Use_Error.
10861
10862 Examples of correct Forms:
10863
10864 @smallexample
10865 Form => "preserve=no_attributes,mode=overwrite" (the default)
10866 Form => "mode=append"
10867 Form => "mode=copy, preserve=all_attributes"
10868 @end smallexample
10869
10870 @noindent
10871 Examples of incorrect Forms
10872
10873 @smallexample
10874 Form => "preserve=junk"
10875 Form => "mode=internal, preserve=timestamps"
10876 @end smallexample
10877
10878 @sp 1
10879 @cartouche
10880 @noindent
10881 @strong{77}. Implementation-defined convention names. See B.1(11).
10882 @end cartouche
10883 @noindent
10884 The following convention names are supported
10885
10886 @table @code
10887 @item Ada
10888 Ada
10889 @item Ada_Pass_By_Copy
10890 Allowed for any types except by-reference types such as limited
10891 records. Compatible with convention Ada, but causes any parameters
10892 with this convention to be passed by copy.
10893 @item Ada_Pass_By_Reference
10894 Allowed for any types except by-copy types such as scalars.
10895 Compatible with convention Ada, but causes any parameters
10896 with this convention to be passed by reference.
10897 @item Assembler
10898 Assembly language
10899 @item Asm
10900 Synonym for Assembler
10901 @item Assembly
10902 Synonym for Assembler
10903 @item C
10904 C
10905 @item C_Pass_By_Copy
10906 Allowed only for record types, like C, but also notes that record
10907 is to be passed by copy rather than reference.
10908 @item COBOL
10909 COBOL
10910 @item C_Plus_Plus (or CPP)
10911 C++
10912 @item Default
10913 Treated the same as C
10914 @item External
10915 Treated the same as C
10916 @item Fortran
10917 Fortran
10918 @item Intrinsic
10919 For support of pragma @code{Import} with convention Intrinsic, see
10920 separate section on Intrinsic Subprograms.
10921 @item Stdcall
10922 Stdcall (used for Windows implementations only). This convention correspond
10923 to the WINAPI (previously called Pascal convention) C/C++ convention under
10924 Windows. A routine with this convention cleans the stack before
10925 exit. This pragma cannot be applied to a dispatching call.
10926 @item DLL
10927 Synonym for Stdcall
10928 @item Win32
10929 Synonym for Stdcall
10930 @item Stubbed
10931 Stubbed is a special convention used to indicate that the body of the
10932 subprogram will be entirely ignored. Any call to the subprogram
10933 is converted into a raise of the @code{Program_Error} exception. If a
10934 pragma @code{Import} specifies convention @code{stubbed} then no body need
10935 be present at all. This convention is useful during development for the
10936 inclusion of subprograms whose body has not yet been written.
10937
10938 @end table
10939 @noindent
10940 In addition, all otherwise unrecognized convention names are also
10941 treated as being synonymous with convention C@. In all implementations
10942 except for VMS, use of such other names results in a warning. In VMS
10943 implementations, these names are accepted silently.
10944
10945 @sp 1
10946 @cartouche
10947 @noindent
10948 @strong{78}. The meaning of link names. See B.1(36).
10949 @end cartouche
10950 @noindent
10951 Link names are the actual names used by the linker.
10952
10953 @sp 1
10954 @cartouche
10955 @noindent
10956 @strong{79}. The manner of choosing link names when neither the link
10957 name nor the address of an imported or exported entity is specified. See
10958 B.1(36).
10959 @end cartouche
10960 @noindent
10961 The default linker name is that which would be assigned by the relevant
10962 external language, interpreting the Ada name as being in all lower case
10963 letters.
10964
10965 @sp 1
10966 @cartouche
10967 @noindent
10968 @strong{80}. The effect of pragma @code{Linker_Options}. See B.1(37).
10969 @end cartouche
10970 @noindent
10971 The string passed to @code{Linker_Options} is presented uninterpreted as
10972 an argument to the link command, unless it contains ASCII.NUL characters.
10973 NUL characters if they appear act as argument separators, so for example
10974
10975 @smallexample @c ada
10976 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
10977 @end smallexample
10978
10979 @noindent
10980 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
10981 linker. The order of linker options is preserved for a given unit. The final
10982 list of options passed to the linker is in reverse order of the elaboration
10983 order. For example, linker options for a body always appear before the options
10984 from the corresponding package spec.
10985
10986 @sp 1
10987 @cartouche
10988 @noindent
10989 @strong{81}. The contents of the visible part of package
10990 @code{Interfaces} and its language-defined descendants. See B.2(1).
10991 @end cartouche
10992 @noindent
10993 See files with prefix @file{i-} in the distributed library.
10994
10995 @sp 1
10996 @cartouche
10997 @noindent
10998 @strong{82}. Implementation-defined children of package
10999 @code{Interfaces}. The contents of the visible part of package
11000 @code{Interfaces}. See B.2(11).
11001 @end cartouche
11002 @noindent
11003 See files with prefix @file{i-} in the distributed library.
11004
11005 @sp 1
11006 @cartouche
11007 @noindent
11008 @strong{83}. The types @code{Floating}, @code{Long_Floating},
11009 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
11010 @code{COBOL_Character}; and the initialization of the variables
11011 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
11012 @code{Interfaces.COBOL}. See B.4(50).
11013 @end cartouche
11014 @noindent
11015 @table @code
11016 @item Floating
11017 Float
11018 @item Long_Floating
11019 (Floating) Long_Float
11020 @item Binary
11021 Integer
11022 @item Long_Binary
11023 Long_Long_Integer
11024 @item Decimal_Element
11025 Character
11026 @item COBOL_Character
11027 Character
11028 @end table
11029
11030 @noindent
11031 For initialization, see the file @file{i-cobol.ads} in the distributed library.
11032
11033 @sp 1
11034 @cartouche
11035 @noindent
11036 @strong{84}. Support for access to machine instructions. See C.1(1).
11037 @end cartouche
11038 @noindent
11039 See documentation in file @file{s-maccod.ads} in the distributed library.
11040
11041 @sp 1
11042 @cartouche
11043 @noindent
11044 @strong{85}. Implementation-defined aspects of access to machine
11045 operations. See C.1(9).
11046 @end cartouche
11047 @noindent
11048 See documentation in file @file{s-maccod.ads} in the distributed library.
11049
11050 @sp 1
11051 @cartouche
11052 @noindent
11053 @strong{86}. Implementation-defined aspects of interrupts. See C.3(2).
11054 @end cartouche
11055 @noindent
11056 Interrupts are mapped to signals or conditions as appropriate. See
11057 definition of unit
11058 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
11059 on the interrupts supported on a particular target.
11060
11061 @sp 1
11062 @cartouche
11063 @noindent
11064 @strong{87}. Implementation-defined aspects of pre-elaboration. See
11065 C.4(13).
11066 @end cartouche
11067 @noindent
11068 GNAT does not permit a partition to be restarted without reloading,
11069 except under control of the debugger.
11070
11071 @sp 1
11072 @cartouche
11073 @noindent
11074 @strong{88}. The semantics of pragma @code{Discard_Names}. See C.5(7).
11075 @end cartouche
11076 @noindent
11077 Pragma @code{Discard_Names} causes names of enumeration literals to
11078 be suppressed. In the presence of this pragma, the Image attribute
11079 provides the image of the Pos of the literal, and Value accepts
11080 Pos values.
11081
11082 @sp 1
11083 @cartouche
11084 @noindent
11085 @strong{89}. The result of the @code{Task_Identification.Image}
11086 attribute. See C.7.1(7).
11087 @end cartouche
11088 @noindent
11089 The result of this attribute is a string that identifies
11090 the object or component that denotes a given task. If a variable @code{Var}
11091 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
11092 where the suffix
11093 is the hexadecimal representation of the virtual address of the corresponding
11094 task control block. If the variable is an array of tasks, the image of each
11095 task will have the form of an indexed component indicating the position of a
11096 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
11097 component of a record, the image of the task will have the form of a selected
11098 component. These rules are fully recursive, so that the image of a task that
11099 is a subcomponent of a composite object corresponds to the expression that
11100 designates this task.
11101 @noindent
11102 If a task is created by an allocator, its image depends on the context. If the
11103 allocator is part of an object declaration, the rules described above are used
11104 to construct its image, and this image is not affected by subsequent
11105 assignments. If the allocator appears within an expression, the image
11106 includes only the name of the task type.
11107 @noindent
11108 If the configuration pragma Discard_Names is present, or if the restriction
11109 No_Implicit_Heap_Allocation is in effect, the image reduces to
11110 the numeric suffix, that is to say the hexadecimal representation of the
11111 virtual address of the control block of the task.
11112 @sp 1
11113 @cartouche
11114 @noindent
11115 @strong{90}. The value of @code{Current_Task} when in a protected entry
11116 or interrupt handler. See C.7.1(17).
11117 @end cartouche
11118 @noindent
11119 Protected entries or interrupt handlers can be executed by any
11120 convenient thread, so the value of @code{Current_Task} is undefined.
11121
11122 @sp 1
11123 @cartouche
11124 @noindent
11125 @strong{91}. The effect of calling @code{Current_Task} from an entry
11126 body or interrupt handler. See C.7.1(19).
11127 @end cartouche
11128 @noindent
11129 The effect of calling @code{Current_Task} from an entry body or
11130 interrupt handler is to return the identification of the task currently
11131 executing the code.
11132
11133 @sp 1
11134 @cartouche
11135 @noindent
11136 @strong{92}. Implementation-defined aspects of
11137 @code{Task_Attributes}. See C.7.2(19).
11138 @end cartouche
11139 @noindent
11140 There are no implementation-defined aspects of @code{Task_Attributes}.
11141
11142 @sp 1
11143 @cartouche
11144 @noindent
11145 @strong{93}. Values of all @code{Metrics}. See D(2).
11146 @end cartouche
11147 @noindent
11148 The metrics information for GNAT depends on the performance of the
11149 underlying operating system. The sources of the run-time for tasking
11150 implementation, together with the output from @option{-gnatG} can be
11151 used to determine the exact sequence of operating systems calls made
11152 to implement various tasking constructs. Together with appropriate
11153 information on the performance of the underlying operating system,
11154 on the exact target in use, this information can be used to determine
11155 the required metrics.
11156
11157 @sp 1
11158 @cartouche
11159 @noindent
11160 @strong{94}. The declarations of @code{Any_Priority} and
11161 @code{Priority}. See D.1(11).
11162 @end cartouche
11163 @noindent
11164 See declarations in file @file{system.ads}.
11165
11166 @sp 1
11167 @cartouche
11168 @noindent
11169 @strong{95}. Implementation-defined execution resources. See D.1(15).
11170 @end cartouche
11171 @noindent
11172 There are no implementation-defined execution resources.
11173
11174 @sp 1
11175 @cartouche
11176 @noindent
11177 @strong{96}. Whether, on a multiprocessor, a task that is waiting for
11178 access to a protected object keeps its processor busy. See D.2.1(3).
11179 @end cartouche
11180 @noindent
11181 On a multi-processor, a task that is waiting for access to a protected
11182 object does not keep its processor busy.
11183
11184 @sp 1
11185 @cartouche
11186 @noindent
11187 @strong{97}. The affect of implementation defined execution resources
11188 on task dispatching. See D.2.1(9).
11189 @end cartouche
11190 @noindent
11191 Tasks map to threads in the threads package used by GNAT@. Where possible
11192 and appropriate, these threads correspond to native threads of the
11193 underlying operating system.
11194
11195 @sp 1
11196 @cartouche
11197 @noindent
11198 @strong{98}. Implementation-defined @code{policy_identifiers} allowed
11199 in a pragma @code{Task_Dispatching_Policy}. See D.2.2(3).
11200 @end cartouche
11201 @noindent
11202 There are no implementation-defined policy-identifiers allowed in this
11203 pragma.
11204
11205 @sp 1
11206 @cartouche
11207 @noindent
11208 @strong{99}. Implementation-defined aspects of priority inversion. See
11209 D.2.2(16).
11210 @end cartouche
11211 @noindent
11212 Execution of a task cannot be preempted by the implementation processing
11213 of delay expirations for lower priority tasks.
11214
11215 @sp 1
11216 @cartouche
11217 @noindent
11218 @strong{100}. Implementation-defined task dispatching. See D.2.2(18).
11219 @end cartouche
11220 @noindent
11221 The policy is the same as that of the underlying threads implementation.
11222
11223 @sp 1
11224 @cartouche
11225 @noindent
11226 @strong{101}. Implementation-defined @code{policy_identifiers} allowed
11227 in a pragma @code{Locking_Policy}. See D.3(4).
11228 @end cartouche
11229 @noindent
11230 The two implementation defined policies permitted in GNAT are
11231 @code{Inheritance_Locking} and @code{Conccurent_Readers_Locking}. On
11232 targets that support the @code{Inheritance_Locking} policy, locking is
11233 implemented by inheritance, i.e.@: the task owning the lock operates
11234 at a priority equal to the highest priority of any task currently
11235 requesting the lock. On targets that support the
11236 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
11237 read/write lock allowing multiple propected object functions to enter
11238 concurrently.
11239
11240 @sp 1
11241 @cartouche
11242 @noindent
11243 @strong{102}. Default ceiling priorities. See D.3(10).
11244 @end cartouche
11245 @noindent
11246 The ceiling priority of protected objects of the type
11247 @code{System.Interrupt_Priority'Last} as described in the Ada
11248 Reference Manual D.3(10),
11249
11250 @sp 1
11251 @cartouche
11252 @noindent
11253 @strong{103}. The ceiling of any protected object used internally by
11254 the implementation. See D.3(16).
11255 @end cartouche
11256 @noindent
11257 The ceiling priority of internal protected objects is
11258 @code{System.Priority'Last}.
11259
11260 @sp 1
11261 @cartouche
11262 @noindent
11263 @strong{104}. Implementation-defined queuing policies. See D.4(1).
11264 @end cartouche
11265 @noindent
11266 There are no implementation-defined queuing policies.
11267
11268 @sp 1
11269 @cartouche
11270 @noindent
11271 @strong{105}. On a multiprocessor, any conditions that cause the
11272 completion of an aborted construct to be delayed later than what is
11273 specified for a single processor. See D.6(3).
11274 @end cartouche
11275 @noindent
11276 The semantics for abort on a multi-processor is the same as on a single
11277 processor, there are no further delays.
11278
11279 @sp 1
11280 @cartouche
11281 @noindent
11282 @strong{106}. Any operations that implicitly require heap storage
11283 allocation. See D.7(8).
11284 @end cartouche
11285 @noindent
11286 The only operation that implicitly requires heap storage allocation is
11287 task creation.
11288
11289 @sp 1
11290 @cartouche
11291 @noindent
11292 @strong{107}. Implementation-defined aspects of pragma
11293 @code{Restrictions}. See D.7(20).
11294 @end cartouche
11295 @noindent
11296 There are no such implementation-defined aspects.
11297
11298 @sp 1
11299 @cartouche
11300 @noindent
11301 @strong{108}. Implementation-defined aspects of package
11302 @code{Real_Time}. See D.8(17).
11303 @end cartouche
11304 @noindent
11305 There are no implementation defined aspects of package @code{Real_Time}.
11306
11307 @sp 1
11308 @cartouche
11309 @noindent
11310 @strong{109}. Implementation-defined aspects of
11311 @code{delay_statements}. See D.9(8).
11312 @end cartouche
11313 @noindent
11314 Any difference greater than one microsecond will cause the task to be
11315 delayed (see D.9(7)).
11316
11317 @sp 1
11318 @cartouche
11319 @noindent
11320 @strong{110}. The upper bound on the duration of interrupt blocking
11321 caused by the implementation. See D.12(5).
11322 @end cartouche
11323 @noindent
11324 The upper bound is determined by the underlying operating system. In
11325 no cases is it more than 10 milliseconds.
11326
11327 @sp 1
11328 @cartouche
11329 @noindent
11330 @strong{111}. The means for creating and executing distributed
11331 programs. See E(5).
11332 @end cartouche
11333 @noindent
11334 The GLADE package provides a utility GNATDIST for creating and executing
11335 distributed programs. See the GLADE reference manual for further details.
11336
11337 @sp 1
11338 @cartouche
11339 @noindent
11340 @strong{112}. Any events that can result in a partition becoming
11341 inaccessible. See E.1(7).
11342 @end cartouche
11343 @noindent
11344 See the GLADE reference manual for full details on such events.
11345
11346 @sp 1
11347 @cartouche
11348 @noindent
11349 @strong{113}. The scheduling policies, treatment of priorities, and
11350 management of shared resources between partitions in certain cases. See
11351 E.1(11).
11352 @end cartouche
11353 @noindent
11354 See the GLADE reference manual for full details on these aspects of
11355 multi-partition execution.
11356
11357 @sp 1
11358 @cartouche
11359 @noindent
11360 @strong{114}. Events that cause the version of a compilation unit to
11361 change. See E.3(5).
11362 @end cartouche
11363 @noindent
11364 Editing the source file of a compilation unit, or the source files of
11365 any units on which it is dependent in a significant way cause the version
11366 to change. No other actions cause the version number to change. All changes
11367 are significant except those which affect only layout, capitalization or
11368 comments.
11369
11370 @sp 1
11371 @cartouche
11372 @noindent
11373 @strong{115}. Whether the execution of the remote subprogram is
11374 immediately aborted as a result of cancellation. See E.4(13).
11375 @end cartouche
11376 @noindent
11377 See the GLADE reference manual for details on the effect of abort in
11378 a distributed application.
11379
11380 @sp 1
11381 @cartouche
11382 @noindent
11383 @strong{116}. Implementation-defined aspects of the PCS@. See E.5(25).
11384 @end cartouche
11385 @noindent
11386 See the GLADE reference manual for a full description of all implementation
11387 defined aspects of the PCS@.
11388
11389 @sp 1
11390 @cartouche
11391 @noindent
11392 @strong{117}. Implementation-defined interfaces in the PCS@. See
11393 E.5(26).
11394 @end cartouche
11395 @noindent
11396 See the GLADE reference manual for a full description of all
11397 implementation defined interfaces.
11398
11399 @sp 1
11400 @cartouche
11401 @noindent
11402 @strong{118}. The values of named numbers in the package
11403 @code{Decimal}. See F.2(7).
11404 @end cartouche
11405 @noindent
11406 @table @code
11407 @item Max_Scale
11408 +18
11409 @item Min_Scale
11410 -18
11411 @item Min_Delta
11412 1.0E-18
11413 @item Max_Delta
11414 1.0E+18
11415 @item Max_Decimal_Digits
11416 18
11417 @end table
11418
11419 @sp 1
11420 @cartouche
11421 @noindent
11422 @strong{119}. The value of @code{Max_Picture_Length} in the package
11423 @code{Text_IO.Editing}. See F.3.3(16).
11424 @end cartouche
11425 @noindent
11426 64
11427
11428 @sp 1
11429 @cartouche
11430 @noindent
11431 @strong{120}. The value of @code{Max_Picture_Length} in the package
11432 @code{Wide_Text_IO.Editing}. See F.3.4(5).
11433 @end cartouche
11434 @noindent
11435 64
11436
11437 @sp 1
11438 @cartouche
11439 @noindent
11440 @strong{121}. The accuracy actually achieved by the complex elementary
11441 functions and by other complex arithmetic operations. See G.1(1).
11442 @end cartouche
11443 @noindent
11444 Standard library functions are used for the complex arithmetic
11445 operations. Only fast math mode is currently supported.
11446
11447 @sp 1
11448 @cartouche
11449 @noindent
11450 @strong{122}. The sign of a zero result (or a component thereof) from
11451 any operator or function in @code{Numerics.Generic_Complex_Types}, when
11452 @code{Real'Signed_Zeros} is True. See G.1.1(53).
11453 @end cartouche
11454 @noindent
11455 The signs of zero values are as recommended by the relevant
11456 implementation advice.
11457
11458 @sp 1
11459 @cartouche
11460 @noindent
11461 @strong{123}. The sign of a zero result (or a component thereof) from
11462 any operator or function in
11463 @code{Numerics.Generic_Complex_Elementary_Functions}, when
11464 @code{Real'Signed_Zeros} is @code{True}. See G.1.2(45).
11465 @end cartouche
11466 @noindent
11467 The signs of zero values are as recommended by the relevant
11468 implementation advice.
11469
11470 @sp 1
11471 @cartouche
11472 @noindent
11473 @strong{124}. Whether the strict mode or the relaxed mode is the
11474 default. See G.2(2).
11475 @end cartouche
11476 @noindent
11477 The strict mode is the default. There is no separate relaxed mode. GNAT
11478 provides a highly efficient implementation of strict mode.
11479
11480 @sp 1
11481 @cartouche
11482 @noindent
11483 @strong{125}. The result interval in certain cases of fixed-to-float
11484 conversion. See G.2.1(10).
11485 @end cartouche
11486 @noindent
11487 For cases where the result interval is implementation dependent, the
11488 accuracy is that provided by performing all operations in 64-bit IEEE
11489 floating-point format.
11490
11491 @sp 1
11492 @cartouche
11493 @noindent
11494 @strong{126}. The result of a floating point arithmetic operation in
11495 overflow situations, when the @code{Machine_Overflows} attribute of the
11496 result type is @code{False}. See G.2.1(13).
11497 @end cartouche
11498 @noindent
11499 Infinite and NaN values are produced as dictated by the IEEE
11500 floating-point standard.
11501
11502 Note that on machines that are not fully compliant with the IEEE
11503 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
11504 must be used for achieving IEEE conforming behavior (although at the cost
11505 of a significant performance penalty), so infinite and NaN values are
11506 properly generated.
11507
11508 @sp 1
11509 @cartouche
11510 @noindent
11511 @strong{127}. The result interval for division (or exponentiation by a
11512 negative exponent), when the floating point hardware implements division
11513 as multiplication by a reciprocal. See G.2.1(16).
11514 @end cartouche
11515 @noindent
11516 Not relevant, division is IEEE exact.
11517
11518 @sp 1
11519 @cartouche
11520 @noindent
11521 @strong{128}. The definition of close result set, which determines the
11522 accuracy of certain fixed point multiplications and divisions. See
11523 G.2.3(5).
11524 @end cartouche
11525 @noindent
11526 Operations in the close result set are performed using IEEE long format
11527 floating-point arithmetic. The input operands are converted to
11528 floating-point, the operation is done in floating-point, and the result
11529 is converted to the target type.
11530
11531 @sp 1
11532 @cartouche
11533 @noindent
11534 @strong{129}. Conditions on a @code{universal_real} operand of a fixed
11535 point multiplication or division for which the result shall be in the
11536 perfect result set. See G.2.3(22).
11537 @end cartouche
11538 @noindent
11539 The result is only defined to be in the perfect result set if the result
11540 can be computed by a single scaling operation involving a scale factor
11541 representable in 64-bits.
11542
11543 @sp 1
11544 @cartouche
11545 @noindent
11546 @strong{130}. The result of a fixed point arithmetic operation in
11547 overflow situations, when the @code{Machine_Overflows} attribute of the
11548 result type is @code{False}. See G.2.3(27).
11549 @end cartouche
11550 @noindent
11551 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
11552 types.
11553
11554 @sp 1
11555 @cartouche
11556 @noindent
11557 @strong{131}. The result of an elementary function reference in
11558 overflow situations, when the @code{Machine_Overflows} attribute of the
11559 result type is @code{False}. See G.2.4(4).
11560 @end cartouche
11561 @noindent
11562 IEEE infinite and Nan values are produced as appropriate.
11563
11564 @sp 1
11565 @cartouche
11566 @noindent
11567 @strong{132}. The value of the angle threshold, within which certain
11568 elementary functions, complex arithmetic operations, and complex
11569 elementary functions yield results conforming to a maximum relative
11570 error bound. See G.2.4(10).
11571 @end cartouche
11572 @noindent
11573 Information on this subject is not yet available.
11574
11575 @sp 1
11576 @cartouche
11577 @noindent
11578 @strong{133}. The accuracy of certain elementary functions for
11579 parameters beyond the angle threshold. See G.2.4(10).
11580 @end cartouche
11581 @noindent
11582 Information on this subject is not yet available.
11583
11584 @sp 1
11585 @cartouche
11586 @noindent
11587 @strong{134}. The result of a complex arithmetic operation or complex
11588 elementary function reference in overflow situations, when the
11589 @code{Machine_Overflows} attribute of the corresponding real type is
11590 @code{False}. See G.2.6(5).
11591 @end cartouche
11592 @noindent
11593 IEEE infinite and Nan values are produced as appropriate.
11594
11595 @sp 1
11596 @cartouche
11597 @noindent
11598 @strong{135}. The accuracy of certain complex arithmetic operations and
11599 certain complex elementary functions for parameters (or components
11600 thereof) beyond the angle threshold. See G.2.6(8).
11601 @end cartouche
11602 @noindent
11603 Information on those subjects is not yet available.
11604
11605 @sp 1
11606 @cartouche
11607 @noindent
11608 @strong{136}. Information regarding bounded errors and erroneous
11609 execution. See H.2(1).
11610 @end cartouche
11611 @noindent
11612 Information on this subject is not yet available.
11613
11614 @sp 1
11615 @cartouche
11616 @noindent
11617 @strong{137}. Implementation-defined aspects of pragma
11618 @code{Inspection_Point}. See H.3.2(8).
11619 @end cartouche
11620 @noindent
11621 Pragma @code{Inspection_Point} ensures that the variable is live and can
11622 be examined by the debugger at the inspection point.
11623
11624 @sp 1
11625 @cartouche
11626 @noindent
11627 @strong{138}. Implementation-defined aspects of pragma
11628 @code{Restrictions}. See H.4(25).
11629 @end cartouche
11630 @noindent
11631 There are no implementation-defined aspects of pragma @code{Restrictions}. The
11632 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
11633 generated code. Checks must suppressed by use of pragma @code{Suppress}.
11634
11635 @sp 1
11636 @cartouche
11637 @noindent
11638 @strong{139}. Any restrictions on pragma @code{Restrictions}. See
11639 H.4(27).
11640 @end cartouche
11641 @noindent
11642 There are no restrictions on pragma @code{Restrictions}.
11643
11644 @node Intrinsic Subprograms
11645 @chapter Intrinsic Subprograms
11646 @cindex Intrinsic Subprograms
11647
11648 @menu
11649 * Intrinsic Operators::
11650 * Enclosing_Entity::
11651 * Exception_Information::
11652 * Exception_Message::
11653 * Exception_Name::
11654 * File::
11655 * Line::
11656 * Shifts and Rotates::
11657 * Source_Location::
11658 @end menu
11659
11660 @noindent
11661 GNAT allows a user application program to write the declaration:
11662
11663 @smallexample @c ada
11664 pragma Import (Intrinsic, name);
11665 @end smallexample
11666
11667 @noindent
11668 providing that the name corresponds to one of the implemented intrinsic
11669 subprograms in GNAT, and that the parameter profile of the referenced
11670 subprogram meets the requirements. This chapter describes the set of
11671 implemented intrinsic subprograms, and the requirements on parameter profiles.
11672 Note that no body is supplied; as with other uses of pragma Import, the
11673 body is supplied elsewhere (in this case by the compiler itself). Note
11674 that any use of this feature is potentially non-portable, since the
11675 Ada standard does not require Ada compilers to implement this feature.
11676
11677 @node Intrinsic Operators
11678 @section Intrinsic Operators
11679 @cindex Intrinsic operator
11680
11681 @noindent
11682 All the predefined numeric operators in package Standard
11683 in @code{pragma Import (Intrinsic,..)}
11684 declarations. In the binary operator case, the operands must have the same
11685 size. The operand or operands must also be appropriate for
11686 the operator. For example, for addition, the operands must
11687 both be floating-point or both be fixed-point, and the
11688 right operand for @code{"**"} must have a root type of
11689 @code{Standard.Integer'Base}.
11690 You can use an intrinsic operator declaration as in the following example:
11691
11692 @smallexample @c ada
11693 type Int1 is new Integer;
11694 type Int2 is new Integer;
11695
11696 function "+" (X1 : Int1; X2 : Int2) return Int1;
11697 function "+" (X1 : Int1; X2 : Int2) return Int2;
11698 pragma Import (Intrinsic, "+");
11699 @end smallexample
11700
11701 @noindent
11702 This declaration would permit ``mixed mode'' arithmetic on items
11703 of the differing types @code{Int1} and @code{Int2}.
11704 It is also possible to specify such operators for private types, if the
11705 full views are appropriate arithmetic types.
11706
11707 @node Enclosing_Entity
11708 @section Enclosing_Entity
11709 @cindex Enclosing_Entity
11710 @noindent
11711 This intrinsic subprogram is used in the implementation of the
11712 library routine @code{GNAT.Source_Info}. The only useful use of the
11713 intrinsic import in this case is the one in this unit, so an
11714 application program should simply call the function
11715 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
11716 the current subprogram, package, task, entry, or protected subprogram.
11717
11718 @node Exception_Information
11719 @section Exception_Information
11720 @cindex Exception_Information'
11721 @noindent
11722 This intrinsic subprogram is used in the implementation of the
11723 library routine @code{GNAT.Current_Exception}. The only useful
11724 use of the intrinsic import in this case is the one in this unit,
11725 so an application program should simply call the function
11726 @code{GNAT.Current_Exception.Exception_Information} to obtain
11727 the exception information associated with the current exception.
11728
11729 @node Exception_Message
11730 @section Exception_Message
11731 @cindex Exception_Message
11732 @noindent
11733 This intrinsic subprogram is used in the implementation of the
11734 library routine @code{GNAT.Current_Exception}. The only useful
11735 use of the intrinsic import in this case is the one in this unit,
11736 so an application program should simply call the function
11737 @code{GNAT.Current_Exception.Exception_Message} to obtain
11738 the message associated with the current exception.
11739
11740 @node Exception_Name
11741 @section Exception_Name
11742 @cindex Exception_Name
11743 @noindent
11744 This intrinsic subprogram is used in the implementation of the
11745 library routine @code{GNAT.Current_Exception}. The only useful
11746 use of the intrinsic import in this case is the one in this unit,
11747 so an application program should simply call the function
11748 @code{GNAT.Current_Exception.Exception_Name} to obtain
11749 the name of the current exception.
11750
11751 @node File
11752 @section File
11753 @cindex File
11754 @noindent
11755 This intrinsic subprogram is used in the implementation of the
11756 library routine @code{GNAT.Source_Info}. The only useful use of the
11757 intrinsic import in this case is the one in this unit, so an
11758 application program should simply call the function
11759 @code{GNAT.Source_Info.File} to obtain the name of the current
11760 file.
11761
11762 @node Line
11763 @section Line
11764 @cindex Line
11765 @noindent
11766 This intrinsic subprogram is used in the implementation of the
11767 library routine @code{GNAT.Source_Info}. The only useful use of the
11768 intrinsic import in this case is the one in this unit, so an
11769 application program should simply call the function
11770 @code{GNAT.Source_Info.Line} to obtain the number of the current
11771 source line.
11772
11773 @node Shifts and Rotates
11774 @section Shifts and Rotates
11775 @cindex Shift_Left
11776 @cindex Shift_Right
11777 @cindex Shift_Right_Arithmetic
11778 @cindex Rotate_Left
11779 @cindex Rotate_Right
11780 @noindent
11781 In standard Ada, the shift and rotate functions are available only
11782 for the predefined modular types in package @code{Interfaces}. However, in
11783 GNAT it is possible to define these functions for any integer
11784 type (signed or modular), as in this example:
11785
11786 @smallexample @c ada
11787 function Shift_Left
11788 (Value : T;
11789 Amount : Natural)
11790 return T;
11791 @end smallexample
11792
11793 @noindent
11794 The function name must be one of
11795 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
11796 Rotate_Right. T must be an integer type. T'Size must be
11797 8, 16, 32 or 64 bits; if T is modular, the modulus
11798 must be 2**8, 2**16, 2**32 or 2**64.
11799 The result type must be the same as the type of @code{Value}.
11800 The shift amount must be Natural.
11801 The formal parameter names can be anything.
11802
11803 @node Source_Location
11804 @section Source_Location
11805 @cindex Source_Location
11806 @noindent
11807 This intrinsic subprogram is used in the implementation of the
11808 library routine @code{GNAT.Source_Info}. The only useful use of the
11809 intrinsic import in this case is the one in this unit, so an
11810 application program should simply call the function
11811 @code{GNAT.Source_Info.Source_Location} to obtain the current
11812 source file location.
11813
11814 @node Representation Clauses and Pragmas
11815 @chapter Representation Clauses and Pragmas
11816 @cindex Representation Clauses
11817
11818 @menu
11819 * Alignment Clauses::
11820 * Size Clauses::
11821 * Storage_Size Clauses::
11822 * Size of Variant Record Objects::
11823 * Biased Representation ::
11824 * Value_Size and Object_Size Clauses::
11825 * Component_Size Clauses::
11826 * Bit_Order Clauses::
11827 * Effect of Bit_Order on Byte Ordering::
11828 * Pragma Pack for Arrays::
11829 * Pragma Pack for Records::
11830 * Record Representation Clauses::
11831 * Enumeration Clauses::
11832 * Address Clauses::
11833 * Effect of Convention on Representation::
11834 * Determining the Representations chosen by GNAT::
11835 @end menu
11836
11837 @noindent
11838 @cindex Representation Clause
11839 @cindex Representation Pragma
11840 @cindex Pragma, representation
11841 This section describes the representation clauses accepted by GNAT, and
11842 their effect on the representation of corresponding data objects.
11843
11844 GNAT fully implements Annex C (Systems Programming). This means that all
11845 the implementation advice sections in chapter 13 are fully implemented.
11846 However, these sections only require a minimal level of support for
11847 representation clauses. GNAT provides much more extensive capabilities,
11848 and this section describes the additional capabilities provided.
11849
11850 @node Alignment Clauses
11851 @section Alignment Clauses
11852 @cindex Alignment Clause
11853
11854 @noindent
11855 GNAT requires that all alignment clauses specify a power of 2, and all
11856 default alignments are always a power of 2. The default alignment
11857 values are as follows:
11858
11859 @itemize @bullet
11860 @item @emph{Primitive Types}.
11861 For primitive types, the alignment is the minimum of the actual size of
11862 objects of the type divided by @code{Storage_Unit},
11863 and the maximum alignment supported by the target.
11864 (This maximum alignment is given by the GNAT-specific attribute
11865 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
11866 @cindex @code{Maximum_Alignment} attribute
11867 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
11868 default alignment will be 8 on any target that supports alignments
11869 this large, but on some targets, the maximum alignment may be smaller
11870 than 8, in which case objects of type @code{Long_Float} will be maximally
11871 aligned.
11872
11873 @item @emph{Arrays}.
11874 For arrays, the alignment is equal to the alignment of the component type
11875 for the normal case where no packing or component size is given. If the
11876 array is packed, and the packing is effective (see separate section on
11877 packed arrays), then the alignment will be one for long packed arrays,
11878 or arrays whose length is not known at compile time. For short packed
11879 arrays, which are handled internally as modular types, the alignment
11880 will be as described for primitive types, e.g.@: a packed array of length
11881 31 bits will have an object size of four bytes, and an alignment of 4.
11882
11883 @item @emph{Records}.
11884 For the normal non-packed case, the alignment of a record is equal to
11885 the maximum alignment of any of its components. For tagged records, this
11886 includes the implicit access type used for the tag. If a pragma @code{Pack}
11887 is used and all components are packable (see separate section on pragma
11888 @code{Pack}), then the resulting alignment is 1, unless the layout of the
11889 record makes it profitable to increase it.
11890
11891 A special case is when:
11892 @itemize @bullet
11893 @item
11894 the size of the record is given explicitly, or a
11895 full record representation clause is given, and
11896 @item
11897 the size of the record is 2, 4, or 8 bytes.
11898 @end itemize
11899 @noindent
11900 In this case, an alignment is chosen to match the
11901 size of the record. For example, if we have:
11902
11903 @smallexample @c ada
11904 type Small is record
11905 A, B : Character;
11906 end record;
11907 for Small'Size use 16;
11908 @end smallexample
11909
11910 @noindent
11911 then the default alignment of the record type @code{Small} is 2, not 1. This
11912 leads to more efficient code when the record is treated as a unit, and also
11913 allows the type to specified as @code{Atomic} on architectures requiring
11914 strict alignment.
11915
11916 @end itemize
11917
11918 @noindent
11919 An alignment clause may specify a larger alignment than the default value
11920 up to some maximum value dependent on the target (obtainable by using the
11921 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
11922 a smaller alignment than the default value for enumeration, integer and
11923 fixed point types, as well as for record types, for example
11924
11925 @smallexample @c ada
11926 type V is record
11927 A : Integer;
11928 end record;
11929
11930 for V'alignment use 1;
11931 @end smallexample
11932
11933 @noindent
11934 @cindex Alignment, default
11935 The default alignment for the type @code{V} is 4, as a result of the
11936 Integer field in the record, but it is permissible, as shown, to
11937 override the default alignment of the record with a smaller value.
11938
11939 @cindex Alignment, subtypes
11940 Note that according to the Ada standard, an alignment clause applies only
11941 to the first named subtype. If additional subtypes are declared, then the
11942 compiler is allowed to choose any alignment it likes, and there is no way
11943 to control this choice. Consider:
11944
11945 @smallexample @c ada
11946 type R is range 1 .. 10_000;
11947 for R'Alignment use 1;
11948 subtype RS is R range 1 .. 1000;
11949 @end smallexample
11950
11951 @noindent
11952 The alignment clause specifies an alignment of 1 for the first named subtype
11953 @code{R} but this does not necessarily apply to @code{RS}. When writing
11954 portable Ada code, you should avoid writing code that explicitly or
11955 implicitly relies on the alignment of such subtypes.
11956
11957 For the GNAT compiler, if an explicit alignment clause is given, this
11958 value is also used for any subsequent subtypes. So for GNAT, in the
11959 above example, you can count on the alignment of @code{RS} being 1. But this
11960 assumption is non-portable, and other compilers may choose different
11961 alignments for the subtype @code{RS}.
11962
11963 @node Size Clauses
11964 @section Size Clauses
11965 @cindex Size Clause
11966
11967 @noindent
11968 The default size for a type @code{T} is obtainable through the
11969 language-defined attribute @code{T'Size} and also through the
11970 equivalent GNAT-defined attribute @code{T'Value_Size}.
11971 For objects of type @code{T}, GNAT will generally increase the type size
11972 so that the object size (obtainable through the GNAT-defined attribute
11973 @code{T'Object_Size})
11974 is a multiple of @code{T'Alignment * Storage_Unit}.
11975 For example
11976
11977 @smallexample @c ada
11978 type Smallint is range 1 .. 6;
11979
11980 type Rec is record
11981 Y1 : integer;
11982 Y2 : boolean;
11983 end record;
11984 @end smallexample
11985
11986 @noindent
11987 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
11988 as specified by the RM rules,
11989 but objects of this type will have a size of 8
11990 (@code{Smallint'Object_Size} = 8),
11991 since objects by default occupy an integral number
11992 of storage units. On some targets, notably older
11993 versions of the Digital Alpha, the size of stand
11994 alone objects of this type may be 32, reflecting
11995 the inability of the hardware to do byte load/stores.
11996
11997 Similarly, the size of type @code{Rec} is 40 bits
11998 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
11999 the alignment is 4, so objects of this type will have
12000 their size increased to 64 bits so that it is a multiple
12001 of the alignment (in bits). This decision is
12002 in accordance with the specific Implementation Advice in RM 13.3(43):
12003
12004 @quotation
12005 A @code{Size} clause should be supported for an object if the specified
12006 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
12007 to a size in storage elements that is a multiple of the object's
12008 @code{Alignment} (if the @code{Alignment} is nonzero).
12009 @end quotation
12010
12011 @noindent
12012 An explicit size clause may be used to override the default size by
12013 increasing it. For example, if we have:
12014
12015 @smallexample @c ada
12016 type My_Boolean is new Boolean;
12017 for My_Boolean'Size use 32;
12018 @end smallexample
12019
12020 @noindent
12021 then values of this type will always be 32 bits long. In the case of
12022 discrete types, the size can be increased up to 64 bits, with the effect
12023 that the entire specified field is used to hold the value, sign- or
12024 zero-extended as appropriate. If more than 64 bits is specified, then
12025 padding space is allocated after the value, and a warning is issued that
12026 there are unused bits.
12027
12028 Similarly the size of records and arrays may be increased, and the effect
12029 is to add padding bits after the value. This also causes a warning message
12030 to be generated.
12031
12032 The largest Size value permitted in GNAT is 2**31@minus{}1. Since this is a
12033 Size in bits, this corresponds to an object of size 256 megabytes (minus
12034 one). This limitation is true on all targets. The reason for this
12035 limitation is that it improves the quality of the code in many cases
12036 if it is known that a Size value can be accommodated in an object of
12037 type Integer.
12038
12039 @node Storage_Size Clauses
12040 @section Storage_Size Clauses
12041 @cindex Storage_Size Clause
12042
12043 @noindent
12044 For tasks, the @code{Storage_Size} clause specifies the amount of space
12045 to be allocated for the task stack. This cannot be extended, and if the
12046 stack is exhausted, then @code{Storage_Error} will be raised (if stack
12047 checking is enabled). Use a @code{Storage_Size} attribute definition clause,
12048 or a @code{Storage_Size} pragma in the task definition to set the
12049 appropriate required size. A useful technique is to include in every
12050 task definition a pragma of the form:
12051
12052 @smallexample @c ada
12053 pragma Storage_Size (Default_Stack_Size);
12054 @end smallexample
12055
12056 @noindent
12057 Then @code{Default_Stack_Size} can be defined in a global package, and
12058 modified as required. Any tasks requiring stack sizes different from the
12059 default can have an appropriate alternative reference in the pragma.
12060
12061 You can also use the @option{-d} binder switch to modify the default stack
12062 size.
12063
12064 For access types, the @code{Storage_Size} clause specifies the maximum
12065 space available for allocation of objects of the type. If this space is
12066 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
12067 In the case where the access type is declared local to a subprogram, the
12068 use of a @code{Storage_Size} clause triggers automatic use of a special
12069 predefined storage pool (@code{System.Pool_Size}) that ensures that all
12070 space for the pool is automatically reclaimed on exit from the scope in
12071 which the type is declared.
12072
12073 A special case recognized by the compiler is the specification of a
12074 @code{Storage_Size} of zero for an access type. This means that no
12075 items can be allocated from the pool, and this is recognized at compile
12076 time, and all the overhead normally associated with maintaining a fixed
12077 size storage pool is eliminated. Consider the following example:
12078
12079 @smallexample @c ada
12080 procedure p is
12081 type R is array (Natural) of Character;
12082 type P is access all R;
12083 for P'Storage_Size use 0;
12084 -- Above access type intended only for interfacing purposes
12085
12086 y : P;
12087
12088 procedure g (m : P);
12089 pragma Import (C, g);
12090
12091 -- @dots{}
12092
12093 begin
12094 -- @dots{}
12095 y := new R;
12096 end;
12097 @end smallexample
12098
12099 @noindent
12100 As indicated in this example, these dummy storage pools are often useful in
12101 connection with interfacing where no object will ever be allocated. If you
12102 compile the above example, you get the warning:
12103
12104 @smallexample
12105 p.adb:16:09: warning: allocation from empty storage pool
12106 p.adb:16:09: warning: Storage_Error will be raised at run time
12107 @end smallexample
12108
12109 @noindent
12110 Of course in practice, there will not be any explicit allocators in the
12111 case of such an access declaration.
12112
12113 @node Size of Variant Record Objects
12114 @section Size of Variant Record Objects
12115 @cindex Size, variant record objects
12116 @cindex Variant record objects, size
12117
12118 @noindent
12119 In the case of variant record objects, there is a question whether Size gives
12120 information about a particular variant, or the maximum size required
12121 for any variant. Consider the following program
12122
12123 @smallexample @c ada
12124 with Text_IO; use Text_IO;
12125 procedure q is
12126 type R1 (A : Boolean := False) is record
12127 case A is
12128 when True => X : Character;
12129 when False => null;
12130 end case;
12131 end record;
12132
12133 V1 : R1 (False);
12134 V2 : R1;
12135
12136 begin
12137 Put_Line (Integer'Image (V1'Size));
12138 Put_Line (Integer'Image (V2'Size));
12139 end q;
12140 @end smallexample
12141
12142 @noindent
12143 Here we are dealing with a variant record, where the True variant
12144 requires 16 bits, and the False variant requires 8 bits.
12145 In the above example, both V1 and V2 contain the False variant,
12146 which is only 8 bits long. However, the result of running the
12147 program is:
12148
12149 @smallexample
12150 8
12151 16
12152 @end smallexample
12153
12154 @noindent
12155 The reason for the difference here is that the discriminant value of
12156 V1 is fixed, and will always be False. It is not possible to assign
12157 a True variant value to V1, therefore 8 bits is sufficient. On the
12158 other hand, in the case of V2, the initial discriminant value is
12159 False (from the default), but it is possible to assign a True
12160 variant value to V2, therefore 16 bits must be allocated for V2
12161 in the general case, even fewer bits may be needed at any particular
12162 point during the program execution.
12163
12164 As can be seen from the output of this program, the @code{'Size}
12165 attribute applied to such an object in GNAT gives the actual allocated
12166 size of the variable, which is the largest size of any of the variants.
12167 The Ada Reference Manual is not completely clear on what choice should
12168 be made here, but the GNAT behavior seems most consistent with the
12169 language in the RM@.
12170
12171 In some cases, it may be desirable to obtain the size of the current
12172 variant, rather than the size of the largest variant. This can be
12173 achieved in GNAT by making use of the fact that in the case of a
12174 subprogram parameter, GNAT does indeed return the size of the current
12175 variant (because a subprogram has no way of knowing how much space
12176 is actually allocated for the actual).
12177
12178 Consider the following modified version of the above program:
12179
12180 @smallexample @c ada
12181 with Text_IO; use Text_IO;
12182 procedure q is
12183 type R1 (A : Boolean := False) is record
12184 case A is
12185 when True => X : Character;
12186 when False => null;
12187 end case;
12188 end record;
12189
12190 V2 : R1;
12191
12192 function Size (V : R1) return Integer is
12193 begin
12194 return V'Size;
12195 end Size;
12196
12197 begin
12198 Put_Line (Integer'Image (V2'Size));
12199 Put_Line (Integer'IMage (Size (V2)));
12200 V2 := (True, 'x');
12201 Put_Line (Integer'Image (V2'Size));
12202 Put_Line (Integer'IMage (Size (V2)));
12203 end q;
12204 @end smallexample
12205
12206 @noindent
12207 The output from this program is
12208
12209 @smallexample
12210 16
12211 8
12212 16
12213 16
12214 @end smallexample
12215
12216 @noindent
12217 Here we see that while the @code{'Size} attribute always returns
12218 the maximum size, regardless of the current variant value, the
12219 @code{Size} function does indeed return the size of the current
12220 variant value.
12221
12222 @node Biased Representation
12223 @section Biased Representation
12224 @cindex Size for biased representation
12225 @cindex Biased representation
12226
12227 @noindent
12228 In the case of scalars with a range starting at other than zero, it is
12229 possible in some cases to specify a size smaller than the default minimum
12230 value, and in such cases, GNAT uses an unsigned biased representation,
12231 in which zero is used to represent the lower bound, and successive values
12232 represent successive values of the type.
12233
12234 For example, suppose we have the declaration:
12235
12236 @smallexample @c ada
12237 type Small is range -7 .. -4;
12238 for Small'Size use 2;
12239 @end smallexample
12240
12241 @noindent
12242 Although the default size of type @code{Small} is 4, the @code{Size}
12243 clause is accepted by GNAT and results in the following representation
12244 scheme:
12245
12246 @smallexample
12247 -7 is represented as 2#00#
12248 -6 is represented as 2#01#
12249 -5 is represented as 2#10#
12250 -4 is represented as 2#11#
12251 @end smallexample
12252
12253 @noindent
12254 Biased representation is only used if the specified @code{Size} clause
12255 cannot be accepted in any other manner. These reduced sizes that force
12256 biased representation can be used for all discrete types except for
12257 enumeration types for which a representation clause is given.
12258
12259 @node Value_Size and Object_Size Clauses
12260 @section Value_Size and Object_Size Clauses
12261 @findex Value_Size
12262 @findex Object_Size
12263 @cindex Size, of objects
12264
12265 @noindent
12266 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
12267 number of bits required to hold values of type @code{T}.
12268 Although this interpretation was allowed in Ada 83, it was not required,
12269 and this requirement in practice can cause some significant difficulties.
12270 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
12271 However, in Ada 95 and Ada 2005,
12272 @code{Natural'Size} is
12273 typically 31. This means that code may change in behavior when moving
12274 from Ada 83 to Ada 95 or Ada 2005. For example, consider:
12275
12276 @smallexample @c ada
12277 type Rec is record;
12278 A : Natural;
12279 B : Natural;
12280 end record;
12281
12282 for Rec use record
12283 at 0 range 0 .. Natural'Size - 1;
12284 at 0 range Natural'Size .. 2 * Natural'Size - 1;
12285 end record;
12286 @end smallexample
12287
12288 @noindent
12289 In the above code, since the typical size of @code{Natural} objects
12290 is 32 bits and @code{Natural'Size} is 31, the above code can cause
12291 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
12292 there are cases where the fact that the object size can exceed the
12293 size of the type causes surprises.
12294
12295 To help get around this problem GNAT provides two implementation
12296 defined attributes, @code{Value_Size} and @code{Object_Size}. When
12297 applied to a type, these attributes yield the size of the type
12298 (corresponding to the RM defined size attribute), and the size of
12299 objects of the type respectively.
12300
12301 The @code{Object_Size} is used for determining the default size of
12302 objects and components. This size value can be referred to using the
12303 @code{Object_Size} attribute. The phrase ``is used'' here means that it is
12304 the basis of the determination of the size. The backend is free to
12305 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
12306 character might be stored in 32 bits on a machine with no efficient
12307 byte access instructions such as the Alpha.
12308
12309 The default rules for the value of @code{Object_Size} for
12310 discrete types are as follows:
12311
12312 @itemize @bullet
12313 @item
12314 The @code{Object_Size} for base subtypes reflect the natural hardware
12315 size in bits (run the compiler with @option{-gnatS} to find those values
12316 for numeric types). Enumeration types and fixed-point base subtypes have
12317 8, 16, 32 or 64 bits for this size, depending on the range of values
12318 to be stored.
12319
12320 @item
12321 The @code{Object_Size} of a subtype is the same as the
12322 @code{Object_Size} of
12323 the type from which it is obtained.
12324
12325 @item
12326 The @code{Object_Size} of a derived base type is copied from the parent
12327 base type, and the @code{Object_Size} of a derived first subtype is copied
12328 from the parent first subtype.
12329 @end itemize
12330
12331 @noindent
12332 The @code{Value_Size} attribute
12333 is the (minimum) number of bits required to store a value
12334 of the type.
12335 This value is used to determine how tightly to pack
12336 records or arrays with components of this type, and also affects
12337 the semantics of unchecked conversion (unchecked conversions where
12338 the @code{Value_Size} values differ generate a warning, and are potentially
12339 target dependent).
12340
12341 The default rules for the value of @code{Value_Size} are as follows:
12342
12343 @itemize @bullet
12344 @item
12345 The @code{Value_Size} for a base subtype is the minimum number of bits
12346 required to store all values of the type (including the sign bit
12347 only if negative values are possible).
12348
12349 @item
12350 If a subtype statically matches the first subtype of a given type, then it has
12351 by default the same @code{Value_Size} as the first subtype. This is a
12352 consequence of RM 13.1(14) (``if two subtypes statically match,
12353 then their subtype-specific aspects are the same''.)
12354
12355 @item
12356 All other subtypes have a @code{Value_Size} corresponding to the minimum
12357 number of bits required to store all values of the subtype. For
12358 dynamic bounds, it is assumed that the value can range down or up
12359 to the corresponding bound of the ancestor
12360 @end itemize
12361
12362 @noindent
12363 The RM defined attribute @code{Size} corresponds to the
12364 @code{Value_Size} attribute.
12365
12366 The @code{Size} attribute may be defined for a first-named subtype. This sets
12367 the @code{Value_Size} of
12368 the first-named subtype to the given value, and the
12369 @code{Object_Size} of this first-named subtype to the given value padded up
12370 to an appropriate boundary. It is a consequence of the default rules
12371 above that this @code{Object_Size} will apply to all further subtypes. On the
12372 other hand, @code{Value_Size} is affected only for the first subtype, any
12373 dynamic subtypes obtained from it directly, and any statically matching
12374 subtypes. The @code{Value_Size} of any other static subtypes is not affected.
12375
12376 @code{Value_Size} and
12377 @code{Object_Size} may be explicitly set for any subtype using
12378 an attribute definition clause. Note that the use of these attributes
12379 can cause the RM 13.1(14) rule to be violated. If two access types
12380 reference aliased objects whose subtypes have differing @code{Object_Size}
12381 values as a result of explicit attribute definition clauses, then it
12382 is erroneous to convert from one access subtype to the other.
12383
12384 At the implementation level, Esize stores the Object_Size and the
12385 RM_Size field stores the @code{Value_Size} (and hence the value of the
12386 @code{Size} attribute,
12387 which, as noted above, is equivalent to @code{Value_Size}).
12388
12389 To get a feel for the difference, consider the following examples (note
12390 that in each case the base is @code{Short_Short_Integer} with a size of 8):
12391
12392 @smallexample
12393 Object_Size Value_Size
12394
12395 type x1 is range 0 .. 5; 8 3
12396
12397 type x2 is range 0 .. 5;
12398 for x2'size use 12; 16 12
12399
12400 subtype x3 is x2 range 0 .. 3; 16 2
12401
12402 subtype x4 is x2'base range 0 .. 10; 8 4
12403
12404 subtype x5 is x2 range 0 .. dynamic; 16 3*
12405
12406 subtype x6 is x2'base range 0 .. dynamic; 8 3*
12407
12408 @end smallexample
12409
12410 @noindent
12411 Note: the entries marked ``3*'' are not actually specified by the Ada
12412 Reference Manual, but it seems in the spirit of the RM rules to allocate
12413 the minimum number of bits (here 3, given the range for @code{x2})
12414 known to be large enough to hold the given range of values.
12415
12416 So far, so good, but GNAT has to obey the RM rules, so the question is
12417 under what conditions must the RM @code{Size} be used.
12418 The following is a list
12419 of the occasions on which the RM @code{Size} must be used:
12420
12421 @itemize @bullet
12422 @item
12423 Component size for packed arrays or records
12424
12425 @item
12426 Value of the attribute @code{Size} for a type
12427
12428 @item
12429 Warning about sizes not matching for unchecked conversion
12430 @end itemize
12431
12432 @noindent
12433 For record types, the @code{Object_Size} is always a multiple of the
12434 alignment of the type (this is true for all types). In some cases the
12435 @code{Value_Size} can be smaller. Consider:
12436
12437 @smallexample
12438 type R is record
12439 X : Integer;
12440 Y : Character;
12441 end record;
12442 @end smallexample
12443
12444 @noindent
12445 On a typical 32-bit architecture, the X component will be four bytes, and
12446 require four-byte alignment, and the Y component will be one byte. In this
12447 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
12448 required to store a value of this type, and for example, it is permissible
12449 to have a component of type R in an outer array whose component size is
12450 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
12451 since it must be rounded up so that this value is a multiple of the
12452 alignment (4 bytes = 32 bits).
12453
12454 @noindent
12455 For all other types, the @code{Object_Size}
12456 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
12457 Only @code{Size} may be specified for such types.
12458
12459 @node Component_Size Clauses
12460 @section Component_Size Clauses
12461 @cindex Component_Size Clause
12462
12463 @noindent
12464 Normally, the value specified in a component size clause must be consistent
12465 with the subtype of the array component with regard to size and alignment.
12466 In other words, the value specified must be at least equal to the size
12467 of this subtype, and must be a multiple of the alignment value.
12468
12469 In addition, component size clauses are allowed which cause the array
12470 to be packed, by specifying a smaller value. A first case is for
12471 component size values in the range 1 through 63. The value specified
12472 must not be smaller than the Size of the subtype. GNAT will accurately
12473 honor all packing requests in this range. For example, if we have:
12474
12475 @smallexample @c ada
12476 type r is array (1 .. 8) of Natural;
12477 for r'Component_Size use 31;
12478 @end smallexample
12479
12480 @noindent
12481 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
12482 Of course access to the components of such an array is considerably
12483 less efficient than if the natural component size of 32 is used.
12484 A second case is when the subtype of the component is a record type
12485 padded because of its default alignment. For example, if we have:
12486
12487 @smallexample @c ada
12488 type r is record
12489 i : Integer;
12490 j : Integer;
12491 b : Boolean;
12492 end record;
12493
12494 type a is array (1 .. 8) of r;
12495 for a'Component_Size use 72;
12496 @end smallexample
12497
12498 @noindent
12499 then the resulting array has a length of 72 bytes, instead of 96 bytes
12500 if the alignment of the record (4) was obeyed.
12501
12502 Note that there is no point in giving both a component size clause
12503 and a pragma Pack for the same array type. if such duplicate
12504 clauses are given, the pragma Pack will be ignored.
12505
12506 @node Bit_Order Clauses
12507 @section Bit_Order Clauses
12508 @cindex Bit_Order Clause
12509 @cindex bit ordering
12510 @cindex ordering, of bits
12511
12512 @noindent
12513 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
12514 attribute. The specification may either correspond to the default bit
12515 order for the target, in which case the specification has no effect and
12516 places no additional restrictions, or it may be for the non-standard
12517 setting (that is the opposite of the default).
12518
12519 In the case where the non-standard value is specified, the effect is
12520 to renumber bits within each byte, but the ordering of bytes is not
12521 affected. There are certain
12522 restrictions placed on component clauses as follows:
12523
12524 @itemize @bullet
12525
12526 @item Components fitting within a single storage unit.
12527 @noindent
12528 These are unrestricted, and the effect is merely to renumber bits. For
12529 example if we are on a little-endian machine with @code{Low_Order_First}
12530 being the default, then the following two declarations have exactly
12531 the same effect:
12532
12533 @smallexample @c ada
12534 type R1 is record
12535 A : Boolean;
12536 B : Integer range 1 .. 120;
12537 end record;
12538
12539 for R1 use record
12540 A at 0 range 0 .. 0;
12541 B at 0 range 1 .. 7;
12542 end record;
12543
12544 type R2 is record
12545 A : Boolean;
12546 B : Integer range 1 .. 120;
12547 end record;
12548
12549 for R2'Bit_Order use High_Order_First;
12550
12551 for R2 use record
12552 A at 0 range 7 .. 7;
12553 B at 0 range 0 .. 6;
12554 end record;
12555 @end smallexample
12556
12557 @noindent
12558 The useful application here is to write the second declaration with the
12559 @code{Bit_Order} attribute definition clause, and know that it will be treated
12560 the same, regardless of whether the target is little-endian or big-endian.
12561
12562 @item Components occupying an integral number of bytes.
12563 @noindent
12564 These are components that exactly fit in two or more bytes. Such component
12565 declarations are allowed, but have no effect, since it is important to realize
12566 that the @code{Bit_Order} specification does not affect the ordering of bytes.
12567 In particular, the following attempt at getting an endian-independent integer
12568 does not work:
12569
12570 @smallexample @c ada
12571 type R2 is record
12572 A : Integer;
12573 end record;
12574
12575 for R2'Bit_Order use High_Order_First;
12576
12577 for R2 use record
12578 A at 0 range 0 .. 31;
12579 end record;
12580 @end smallexample
12581
12582 @noindent
12583 This declaration will result in a little-endian integer on a
12584 little-endian machine, and a big-endian integer on a big-endian machine.
12585 If byte flipping is required for interoperability between big- and
12586 little-endian machines, this must be explicitly programmed. This capability
12587 is not provided by @code{Bit_Order}.
12588
12589 @item Components that are positioned across byte boundaries
12590 @noindent
12591 but do not occupy an integral number of bytes. Given that bytes are not
12592 reordered, such fields would occupy a non-contiguous sequence of bits
12593 in memory, requiring non-trivial code to reassemble. They are for this
12594 reason not permitted, and any component clause specifying such a layout
12595 will be flagged as illegal by GNAT@.
12596
12597 @end itemize
12598
12599 @noindent
12600 Since the misconception that Bit_Order automatically deals with all
12601 endian-related incompatibilities is a common one, the specification of
12602 a component field that is an integral number of bytes will always
12603 generate a warning. This warning may be suppressed using @code{pragma
12604 Warnings (Off)} if desired. The following section contains additional
12605 details regarding the issue of byte ordering.
12606
12607 @node Effect of Bit_Order on Byte Ordering
12608 @section Effect of Bit_Order on Byte Ordering
12609 @cindex byte ordering
12610 @cindex ordering, of bytes
12611
12612 @noindent
12613 In this section we will review the effect of the @code{Bit_Order} attribute
12614 definition clause on byte ordering. Briefly, it has no effect at all, but
12615 a detailed example will be helpful. Before giving this
12616 example, let us review the precise
12617 definition of the effect of defining @code{Bit_Order}. The effect of a
12618 non-standard bit order is described in section 15.5.3 of the Ada
12619 Reference Manual:
12620
12621 @quotation
12622 2 A bit ordering is a method of interpreting the meaning of
12623 the storage place attributes.
12624 @end quotation
12625
12626 @noindent
12627 To understand the precise definition of storage place attributes in
12628 this context, we visit section 13.5.1 of the manual:
12629
12630 @quotation
12631 13 A record_representation_clause (without the mod_clause)
12632 specifies the layout. The storage place attributes (see 13.5.2)
12633 are taken from the values of the position, first_bit, and last_bit
12634 expressions after normalizing those values so that first_bit is
12635 less than Storage_Unit.
12636 @end quotation
12637
12638 @noindent
12639 The critical point here is that storage places are taken from
12640 the values after normalization, not before. So the @code{Bit_Order}
12641 interpretation applies to normalized values. The interpretation
12642 is described in the later part of the 15.5.3 paragraph:
12643
12644 @quotation
12645 2 A bit ordering is a method of interpreting the meaning of
12646 the storage place attributes. High_Order_First (known in the
12647 vernacular as ``big endian'') means that the first bit of a
12648 storage element (bit 0) is the most significant bit (interpreting
12649 the sequence of bits that represent a component as an unsigned
12650 integer value). Low_Order_First (known in the vernacular as
12651 ``little endian'') means the opposite: the first bit is the
12652 least significant.
12653 @end quotation
12654
12655 @noindent
12656 Note that the numbering is with respect to the bits of a storage
12657 unit. In other words, the specification affects only the numbering
12658 of bits within a single storage unit.
12659
12660 We can make the effect clearer by giving an example.
12661
12662 Suppose that we have an external device which presents two bytes, the first
12663 byte presented, which is the first (low addressed byte) of the two byte
12664 record is called Master, and the second byte is called Slave.
12665
12666 The left most (most significant bit is called Control for each byte, and
12667 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
12668 (least significant) bit.
12669
12670 On a big-endian machine, we can write the following representation clause
12671
12672 @smallexample @c ada
12673 type Data is record
12674 Master_Control : Bit;
12675 Master_V1 : Bit;
12676 Master_V2 : Bit;
12677 Master_V3 : Bit;
12678 Master_V4 : Bit;
12679 Master_V5 : Bit;
12680 Master_V6 : Bit;
12681 Master_V7 : Bit;
12682 Slave_Control : Bit;
12683 Slave_V1 : Bit;
12684 Slave_V2 : Bit;
12685 Slave_V3 : Bit;
12686 Slave_V4 : Bit;
12687 Slave_V5 : Bit;
12688 Slave_V6 : Bit;
12689 Slave_V7 : Bit;
12690 end record;
12691
12692 for Data use record
12693 Master_Control at 0 range 0 .. 0;
12694 Master_V1 at 0 range 1 .. 1;
12695 Master_V2 at 0 range 2 .. 2;
12696 Master_V3 at 0 range 3 .. 3;
12697 Master_V4 at 0 range 4 .. 4;
12698 Master_V5 at 0 range 5 .. 5;
12699 Master_V6 at 0 range 6 .. 6;
12700 Master_V7 at 0 range 7 .. 7;
12701 Slave_Control at 1 range 0 .. 0;
12702 Slave_V1 at 1 range 1 .. 1;
12703 Slave_V2 at 1 range 2 .. 2;
12704 Slave_V3 at 1 range 3 .. 3;
12705 Slave_V4 at 1 range 4 .. 4;
12706 Slave_V5 at 1 range 5 .. 5;
12707 Slave_V6 at 1 range 6 .. 6;
12708 Slave_V7 at 1 range 7 .. 7;
12709 end record;
12710 @end smallexample
12711
12712 @noindent
12713 Now if we move this to a little endian machine, then the bit ordering within
12714 the byte is backwards, so we have to rewrite the record rep clause as:
12715
12716 @smallexample @c ada
12717 for Data use record
12718 Master_Control at 0 range 7 .. 7;
12719 Master_V1 at 0 range 6 .. 6;
12720 Master_V2 at 0 range 5 .. 5;
12721 Master_V3 at 0 range 4 .. 4;
12722 Master_V4 at 0 range 3 .. 3;
12723 Master_V5 at 0 range 2 .. 2;
12724 Master_V6 at 0 range 1 .. 1;
12725 Master_V7 at 0 range 0 .. 0;
12726 Slave_Control at 1 range 7 .. 7;
12727 Slave_V1 at 1 range 6 .. 6;
12728 Slave_V2 at 1 range 5 .. 5;
12729 Slave_V3 at 1 range 4 .. 4;
12730 Slave_V4 at 1 range 3 .. 3;
12731 Slave_V5 at 1 range 2 .. 2;
12732 Slave_V6 at 1 range 1 .. 1;
12733 Slave_V7 at 1 range 0 .. 0;
12734 end record;
12735 @end smallexample
12736
12737 @noindent
12738 It is a nuisance to have to rewrite the clause, especially if
12739 the code has to be maintained on both machines. However,
12740 this is a case that we can handle with the
12741 @code{Bit_Order} attribute if it is implemented.
12742 Note that the implementation is not required on byte addressed
12743 machines, but it is indeed implemented in GNAT.
12744 This means that we can simply use the
12745 first record clause, together with the declaration
12746
12747 @smallexample @c ada
12748 for Data'Bit_Order use High_Order_First;
12749 @end smallexample
12750
12751 @noindent
12752 and the effect is what is desired, namely the layout is exactly the same,
12753 independent of whether the code is compiled on a big-endian or little-endian
12754 machine.
12755
12756 The important point to understand is that byte ordering is not affected.
12757 A @code{Bit_Order} attribute definition never affects which byte a field
12758 ends up in, only where it ends up in that byte.
12759 To make this clear, let us rewrite the record rep clause of the previous
12760 example as:
12761
12762 @smallexample @c ada
12763 for Data'Bit_Order use High_Order_First;
12764 for Data use record
12765 Master_Control at 0 range 0 .. 0;
12766 Master_V1 at 0 range 1 .. 1;
12767 Master_V2 at 0 range 2 .. 2;
12768 Master_V3 at 0 range 3 .. 3;
12769 Master_V4 at 0 range 4 .. 4;
12770 Master_V5 at 0 range 5 .. 5;
12771 Master_V6 at 0 range 6 .. 6;
12772 Master_V7 at 0 range 7 .. 7;
12773 Slave_Control at 0 range 8 .. 8;
12774 Slave_V1 at 0 range 9 .. 9;
12775 Slave_V2 at 0 range 10 .. 10;
12776 Slave_V3 at 0 range 11 .. 11;
12777 Slave_V4 at 0 range 12 .. 12;
12778 Slave_V5 at 0 range 13 .. 13;
12779 Slave_V6 at 0 range 14 .. 14;
12780 Slave_V7 at 0 range 15 .. 15;
12781 end record;
12782 @end smallexample
12783
12784 @noindent
12785 This is exactly equivalent to saying (a repeat of the first example):
12786
12787 @smallexample @c ada
12788 for Data'Bit_Order use High_Order_First;
12789 for Data use record
12790 Master_Control at 0 range 0 .. 0;
12791 Master_V1 at 0 range 1 .. 1;
12792 Master_V2 at 0 range 2 .. 2;
12793 Master_V3 at 0 range 3 .. 3;
12794 Master_V4 at 0 range 4 .. 4;
12795 Master_V5 at 0 range 5 .. 5;
12796 Master_V6 at 0 range 6 .. 6;
12797 Master_V7 at 0 range 7 .. 7;
12798 Slave_Control at 1 range 0 .. 0;
12799 Slave_V1 at 1 range 1 .. 1;
12800 Slave_V2 at 1 range 2 .. 2;
12801 Slave_V3 at 1 range 3 .. 3;
12802 Slave_V4 at 1 range 4 .. 4;
12803 Slave_V5 at 1 range 5 .. 5;
12804 Slave_V6 at 1 range 6 .. 6;
12805 Slave_V7 at 1 range 7 .. 7;
12806 end record;
12807 @end smallexample
12808
12809 @noindent
12810 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
12811 field. The storage place attributes are obtained by normalizing the
12812 values given so that the @code{First_Bit} value is less than 8. After
12813 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
12814 we specified in the other case.
12815
12816 Now one might expect that the @code{Bit_Order} attribute might affect
12817 bit numbering within the entire record component (two bytes in this
12818 case, thus affecting which byte fields end up in), but that is not
12819 the way this feature is defined, it only affects numbering of bits,
12820 not which byte they end up in.
12821
12822 Consequently it never makes sense to specify a starting bit number
12823 greater than 7 (for a byte addressable field) if an attribute
12824 definition for @code{Bit_Order} has been given, and indeed it
12825 may be actively confusing to specify such a value, so the compiler
12826 generates a warning for such usage.
12827
12828 If you do need to control byte ordering then appropriate conditional
12829 values must be used. If in our example, the slave byte came first on
12830 some machines we might write:
12831
12832 @smallexample @c ada
12833 Master_Byte_First constant Boolean := @dots{};
12834
12835 Master_Byte : constant Natural :=
12836 1 - Boolean'Pos (Master_Byte_First);
12837 Slave_Byte : constant Natural :=
12838 Boolean'Pos (Master_Byte_First);
12839
12840 for Data'Bit_Order use High_Order_First;
12841 for Data use record
12842 Master_Control at Master_Byte range 0 .. 0;
12843 Master_V1 at Master_Byte range 1 .. 1;
12844 Master_V2 at Master_Byte range 2 .. 2;
12845 Master_V3 at Master_Byte range 3 .. 3;
12846 Master_V4 at Master_Byte range 4 .. 4;
12847 Master_V5 at Master_Byte range 5 .. 5;
12848 Master_V6 at Master_Byte range 6 .. 6;
12849 Master_V7 at Master_Byte range 7 .. 7;
12850 Slave_Control at Slave_Byte range 0 .. 0;
12851 Slave_V1 at Slave_Byte range 1 .. 1;
12852 Slave_V2 at Slave_Byte range 2 .. 2;
12853 Slave_V3 at Slave_Byte range 3 .. 3;
12854 Slave_V4 at Slave_Byte range 4 .. 4;
12855 Slave_V5 at Slave_Byte range 5 .. 5;
12856 Slave_V6 at Slave_Byte range 6 .. 6;
12857 Slave_V7 at Slave_Byte range 7 .. 7;
12858 end record;
12859 @end smallexample
12860
12861 @noindent
12862 Now to switch between machines, all that is necessary is
12863 to set the boolean constant @code{Master_Byte_First} in
12864 an appropriate manner.
12865
12866 @node Pragma Pack for Arrays
12867 @section Pragma Pack for Arrays
12868 @cindex Pragma Pack (for arrays)
12869
12870 @noindent
12871 Pragma @code{Pack} applied to an array has no effect unless the component type
12872 is packable. For a component type to be packable, it must be one of the
12873 following cases:
12874
12875 @itemize @bullet
12876 @item
12877 Any scalar type
12878 @item
12879 Any type whose size is specified with a size clause
12880 @item
12881 Any packed array type with a static size
12882 @item
12883 Any record type padded because of its default alignment
12884 @end itemize
12885
12886 @noindent
12887 For all these cases, if the component subtype size is in the range
12888 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
12889 component size were specified giving the component subtype size.
12890 For example if we have:
12891
12892 @smallexample @c ada
12893 type r is range 0 .. 17;
12894
12895 type ar is array (1 .. 8) of r;
12896 pragma Pack (ar);
12897 @end smallexample
12898
12899 @noindent
12900 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
12901 and the size of the array @code{ar} will be exactly 40 bits.
12902
12903 Note that in some cases this rather fierce approach to packing can produce
12904 unexpected effects. For example, in Ada 95 and Ada 2005,
12905 subtype @code{Natural} typically has a size of 31, meaning that if you
12906 pack an array of @code{Natural}, you get 31-bit
12907 close packing, which saves a few bits, but results in far less efficient
12908 access. Since many other Ada compilers will ignore such a packing request,
12909 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
12910 might not be what is intended. You can easily remove this warning by
12911 using an explicit @code{Component_Size} setting instead, which never generates
12912 a warning, since the intention of the programmer is clear in this case.
12913
12914 GNAT treats packed arrays in one of two ways. If the size of the array is
12915 known at compile time and is less than 64 bits, then internally the array
12916 is represented as a single modular type, of exactly the appropriate number
12917 of bits. If the length is greater than 63 bits, or is not known at compile
12918 time, then the packed array is represented as an array of bytes, and the
12919 length is always a multiple of 8 bits.
12920
12921 Note that to represent a packed array as a modular type, the alignment must
12922 be suitable for the modular type involved. For example, on typical machines
12923 a 32-bit packed array will be represented by a 32-bit modular integer with
12924 an alignment of four bytes. If you explicitly override the default alignment
12925 with an alignment clause that is too small, the modular representation
12926 cannot be used. For example, consider the following set of declarations:
12927
12928 @smallexample @c ada
12929 type R is range 1 .. 3;
12930 type S is array (1 .. 31) of R;
12931 for S'Component_Size use 2;
12932 for S'Size use 62;
12933 for S'Alignment use 1;
12934 @end smallexample
12935
12936 @noindent
12937 If the alignment clause were not present, then a 62-bit modular
12938 representation would be chosen (typically with an alignment of 4 or 8
12939 bytes depending on the target). But the default alignment is overridden
12940 with the explicit alignment clause. This means that the modular
12941 representation cannot be used, and instead the array of bytes
12942 representation must be used, meaning that the length must be a multiple
12943 of 8. Thus the above set of declarations will result in a diagnostic
12944 rejecting the size clause and noting that the minimum size allowed is 64.
12945
12946 @cindex Pragma Pack (for type Natural)
12947 @cindex Pragma Pack warning
12948
12949 One special case that is worth noting occurs when the base type of the
12950 component size is 8/16/32 and the subtype is one bit less. Notably this
12951 occurs with subtype @code{Natural}. Consider:
12952
12953 @smallexample @c ada
12954 type Arr is array (1 .. 32) of Natural;
12955 pragma Pack (Arr);
12956 @end smallexample
12957
12958 @noindent
12959 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
12960 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
12961 Ada 83 compilers did not attempt 31 bit packing.
12962
12963 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
12964 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
12965 substantial unintended performance penalty when porting legacy Ada 83 code.
12966 To help prevent this, GNAT generates a warning in such cases. If you really
12967 want 31 bit packing in a case like this, you can set the component size
12968 explicitly:
12969
12970 @smallexample @c ada
12971 type Arr is array (1 .. 32) of Natural;
12972 for Arr'Component_Size use 31;
12973 @end smallexample
12974
12975 @noindent
12976 Here 31-bit packing is achieved as required, and no warning is generated,
12977 since in this case the programmer intention is clear.
12978
12979 @node Pragma Pack for Records
12980 @section Pragma Pack for Records
12981 @cindex Pragma Pack (for records)
12982
12983 @noindent
12984 Pragma @code{Pack} applied to a record will pack the components to reduce
12985 wasted space from alignment gaps and by reducing the amount of space
12986 taken by components. We distinguish between @emph{packable} components and
12987 @emph{non-packable} components.
12988 Components of the following types are considered packable:
12989 @itemize @bullet
12990 @item
12991 All primitive types are packable.
12992
12993 @item
12994 Small packed arrays, whose size does not exceed 64 bits, and where the
12995 size is statically known at compile time, are represented internally
12996 as modular integers, and so they are also packable.
12997
12998 @end itemize
12999
13000 @noindent
13001 All packable components occupy the exact number of bits corresponding to
13002 their @code{Size} value, and are packed with no padding bits, i.e.@: they
13003 can start on an arbitrary bit boundary.
13004
13005 All other types are non-packable, they occupy an integral number of
13006 storage units, and
13007 are placed at a boundary corresponding to their alignment requirements.
13008
13009 For example, consider the record
13010
13011 @smallexample @c ada
13012 type Rb1 is array (1 .. 13) of Boolean;
13013 pragma Pack (rb1);
13014
13015 type Rb2 is array (1 .. 65) of Boolean;
13016 pragma Pack (rb2);
13017
13018 type x2 is record
13019 l1 : Boolean;
13020 l2 : Duration;
13021 l3 : Float;
13022 l4 : Boolean;
13023 l5 : Rb1;
13024 l6 : Rb2;
13025 end record;
13026 pragma Pack (x2);
13027 @end smallexample
13028
13029 @noindent
13030 The representation for the record x2 is as follows:
13031
13032 @smallexample @c ada
13033 for x2'Size use 224;
13034 for x2 use record
13035 l1 at 0 range 0 .. 0;
13036 l2 at 0 range 1 .. 64;
13037 l3 at 12 range 0 .. 31;
13038 l4 at 16 range 0 .. 0;
13039 l5 at 16 range 1 .. 13;
13040 l6 at 18 range 0 .. 71;
13041 end record;
13042 @end smallexample
13043
13044 @noindent
13045 Studying this example, we see that the packable fields @code{l1}
13046 and @code{l2} are
13047 of length equal to their sizes, and placed at specific bit boundaries (and
13048 not byte boundaries) to
13049 eliminate padding. But @code{l3} is of a non-packable float type, so
13050 it is on the next appropriate alignment boundary.
13051
13052 The next two fields are fully packable, so @code{l4} and @code{l5} are
13053 minimally packed with no gaps. However, type @code{Rb2} is a packed
13054 array that is longer than 64 bits, so it is itself non-packable. Thus
13055 the @code{l6} field is aligned to the next byte boundary, and takes an
13056 integral number of bytes, i.e.@: 72 bits.
13057
13058 @node Record Representation Clauses
13059 @section Record Representation Clauses
13060 @cindex Record Representation Clause
13061
13062 @noindent
13063 Record representation clauses may be given for all record types, including
13064 types obtained by record extension. Component clauses are allowed for any
13065 static component. The restrictions on component clauses depend on the type
13066 of the component.
13067
13068 @cindex Component Clause
13069 For all components of an elementary type, the only restriction on component
13070 clauses is that the size must be at least the 'Size value of the type
13071 (actually the Value_Size). There are no restrictions due to alignment,
13072 and such components may freely cross storage boundaries.
13073
13074 Packed arrays with a size up to and including 64 bits are represented
13075 internally using a modular type with the appropriate number of bits, and
13076 thus the same lack of restriction applies. For example, if you declare:
13077
13078 @smallexample @c ada
13079 type R is array (1 .. 49) of Boolean;
13080 pragma Pack (R);
13081 for R'Size use 49;
13082 @end smallexample
13083
13084 @noindent
13085 then a component clause for a component of type R may start on any
13086 specified bit boundary, and may specify a value of 49 bits or greater.
13087
13088 For packed bit arrays that are longer than 64 bits, there are two
13089 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
13090 including the important case of single bits or boolean values, then
13091 there are no limitations on placement of such components, and they
13092 may start and end at arbitrary bit boundaries.
13093
13094 If the component size is not a power of 2 (e.g.@: 3 or 5), then
13095 an array of this type longer than 64 bits must always be placed on
13096 on a storage unit (byte) boundary and occupy an integral number
13097 of storage units (bytes). Any component clause that does not
13098 meet this requirement will be rejected.
13099
13100 Any aliased component, or component of an aliased type, must
13101 have its normal alignment and size. A component clause that
13102 does not meet this requirement will be rejected.
13103
13104 The tag field of a tagged type always occupies an address sized field at
13105 the start of the record. No component clause may attempt to overlay this
13106 tag. When a tagged type appears as a component, the tag field must have
13107 proper alignment
13108
13109 In the case of a record extension T1, of a type T, no component clause applied
13110 to the type T1 can specify a storage location that would overlap the first
13111 T'Size bytes of the record.
13112
13113 For all other component types, including non-bit-packed arrays,
13114 the component can be placed at an arbitrary bit boundary,
13115 so for example, the following is permitted:
13116
13117 @smallexample @c ada
13118 type R is array (1 .. 10) of Boolean;
13119 for R'Size use 80;
13120
13121 type Q is record
13122 G, H : Boolean;
13123 L, M : R;
13124 end record;
13125
13126 for Q use record
13127 G at 0 range 0 .. 0;
13128 H at 0 range 1 .. 1;
13129 L at 0 range 2 .. 81;
13130 R at 0 range 82 .. 161;
13131 end record;
13132 @end smallexample
13133
13134 @noindent
13135 Note: the above rules apply to recent releases of GNAT 5.
13136 In GNAT 3, there are more severe restrictions on larger components.
13137 For non-primitive types, including packed arrays with a size greater than
13138 64 bits, component clauses must respect the alignment requirement of the
13139 type, in particular, always starting on a byte boundary, and the length
13140 must be a multiple of the storage unit.
13141
13142 @node Enumeration Clauses
13143 @section Enumeration Clauses
13144
13145 The only restriction on enumeration clauses is that the range of values
13146 must be representable. For the signed case, if one or more of the
13147 representation values are negative, all values must be in the range:
13148
13149 @smallexample @c ada
13150 System.Min_Int .. System.Max_Int
13151 @end smallexample
13152
13153 @noindent
13154 For the unsigned case, where all values are nonnegative, the values must
13155 be in the range:
13156
13157 @smallexample @c ada
13158 0 .. System.Max_Binary_Modulus;
13159 @end smallexample
13160
13161 @noindent
13162 A @emph{confirming} representation clause is one in which the values range
13163 from 0 in sequence, i.e.@: a clause that confirms the default representation
13164 for an enumeration type.
13165 Such a confirming representation
13166 is permitted by these rules, and is specially recognized by the compiler so
13167 that no extra overhead results from the use of such a clause.
13168
13169 If an array has an index type which is an enumeration type to which an
13170 enumeration clause has been applied, then the array is stored in a compact
13171 manner. Consider the declarations:
13172
13173 @smallexample @c ada
13174 type r is (A, B, C);
13175 for r use (A => 1, B => 5, C => 10);
13176 type t is array (r) of Character;
13177 @end smallexample
13178
13179 @noindent
13180 The array type t corresponds to a vector with exactly three elements and
13181 has a default size equal to @code{3*Character'Size}. This ensures efficient
13182 use of space, but means that accesses to elements of the array will incur
13183 the overhead of converting representation values to the corresponding
13184 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
13185
13186 @node Address Clauses
13187 @section Address Clauses
13188 @cindex Address Clause
13189
13190 The reference manual allows a general restriction on representation clauses,
13191 as found in RM 13.1(22):
13192
13193 @quotation
13194 An implementation need not support representation
13195 items containing nonstatic expressions, except that
13196 an implementation should support a representation item
13197 for a given entity if each nonstatic expression in the
13198 representation item is a name that statically denotes
13199 a constant declared before the entity.
13200 @end quotation
13201
13202 @noindent
13203 In practice this is applicable only to address clauses, since this is the
13204 only case in which a non-static expression is permitted by the syntax. As
13205 the AARM notes in sections 13.1 (22.a-22.h):
13206
13207 @display
13208 22.a Reason: This is to avoid the following sort of thing:
13209
13210 22.b X : Integer := F(@dots{});
13211 Y : Address := G(@dots{});
13212 for X'Address use Y;
13213
13214 22.c In the above, we have to evaluate the
13215 initialization expression for X before we
13216 know where to put the result. This seems
13217 like an unreasonable implementation burden.
13218
13219 22.d The above code should instead be written
13220 like this:
13221
13222 22.e Y : constant Address := G(@dots{});
13223 X : Integer := F(@dots{});
13224 for X'Address use Y;
13225
13226 22.f This allows the expression ``Y'' to be safely
13227 evaluated before X is created.
13228
13229 22.g The constant could be a formal parameter of mode in.
13230
13231 22.h An implementation can support other nonstatic
13232 expressions if it wants to. Expressions of type
13233 Address are hardly ever static, but their value
13234 might be known at compile time anyway in many
13235 cases.
13236 @end display
13237
13238 @noindent
13239 GNAT does indeed permit many additional cases of non-static expressions. In
13240 particular, if the type involved is elementary there are no restrictions
13241 (since in this case, holding a temporary copy of the initialization value,
13242 if one is present, is inexpensive). In addition, if there is no implicit or
13243 explicit initialization, then there are no restrictions. GNAT will reject
13244 only the case where all three of these conditions hold:
13245
13246 @itemize @bullet
13247
13248 @item
13249 The type of the item is non-elementary (e.g.@: a record or array).
13250
13251 @item
13252 There is explicit or implicit initialization required for the object.
13253 Note that access values are always implicitly initialized.
13254
13255 @item
13256 The address value is non-static. Here GNAT is more permissive than the
13257 RM, and allows the address value to be the address of a previously declared
13258 stand-alone variable, as long as it does not itself have an address clause.
13259
13260 @smallexample @c ada
13261 Anchor : Some_Initialized_Type;
13262 Overlay : Some_Initialized_Type;
13263 for Overlay'Address use Anchor'Address;
13264 @end smallexample
13265
13266 @noindent
13267 However, the prefix of the address clause cannot be an array component, or
13268 a component of a discriminated record.
13269
13270 @end itemize
13271
13272 @noindent
13273 As noted above in section 22.h, address values are typically non-static. In
13274 particular the To_Address function, even if applied to a literal value, is
13275 a non-static function call. To avoid this minor annoyance, GNAT provides
13276 the implementation defined attribute 'To_Address. The following two
13277 expressions have identical values:
13278
13279 @findex Attribute
13280 @findex To_Address
13281 @smallexample @c ada
13282 To_Address (16#1234_0000#)
13283 System'To_Address (16#1234_0000#);
13284 @end smallexample
13285
13286 @noindent
13287 except that the second form is considered to be a static expression, and
13288 thus when used as an address clause value is always permitted.
13289
13290 @noindent
13291 Additionally, GNAT treats as static an address clause that is an
13292 unchecked_conversion of a static integer value. This simplifies the porting
13293 of legacy code, and provides a portable equivalent to the GNAT attribute
13294 @code{To_Address}.
13295
13296 Another issue with address clauses is the interaction with alignment
13297 requirements. When an address clause is given for an object, the address
13298 value must be consistent with the alignment of the object (which is usually
13299 the same as the alignment of the type of the object). If an address clause
13300 is given that specifies an inappropriately aligned address value, then the
13301 program execution is erroneous.
13302
13303 Since this source of erroneous behavior can have unfortunate effects, GNAT
13304 checks (at compile time if possible, generating a warning, or at execution
13305 time with a run-time check) that the alignment is appropriate. If the
13306 run-time check fails, then @code{Program_Error} is raised. This run-time
13307 check is suppressed if range checks are suppressed, or if the special GNAT
13308 check Alignment_Check is suppressed, or if
13309 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
13310
13311 Finally, GNAT does not permit overlaying of objects of controlled types or
13312 composite types containing a controlled component. In most cases, the compiler
13313 can detect an attempt at such overlays and will generate a warning at compile
13314 time and a Program_Error exception at run time.
13315
13316 @findex Export
13317 An address clause cannot be given for an exported object. More
13318 understandably the real restriction is that objects with an address
13319 clause cannot be exported. This is because such variables are not
13320 defined by the Ada program, so there is no external object to export.
13321
13322 @findex Import
13323 It is permissible to give an address clause and a pragma Import for the
13324 same object. In this case, the variable is not really defined by the
13325 Ada program, so there is no external symbol to be linked. The link name
13326 and the external name are ignored in this case. The reason that we allow this
13327 combination is that it provides a useful idiom to avoid unwanted
13328 initializations on objects with address clauses.
13329
13330 When an address clause is given for an object that has implicit or
13331 explicit initialization, then by default initialization takes place. This
13332 means that the effect of the object declaration is to overwrite the
13333 memory at the specified address. This is almost always not what the
13334 programmer wants, so GNAT will output a warning:
13335
13336 @smallexample
13337 with System;
13338 package G is
13339 type R is record
13340 M : Integer := 0;
13341 end record;
13342
13343 Ext : R;
13344 for Ext'Address use System'To_Address (16#1234_1234#);
13345 |
13346 >>> warning: implicit initialization of "Ext" may
13347 modify overlaid storage
13348 >>> warning: use pragma Import for "Ext" to suppress
13349 initialization (RM B(24))
13350
13351 end G;
13352 @end smallexample
13353
13354 @noindent
13355 As indicated by the warning message, the solution is to use a (dummy) pragma
13356 Import to suppress this initialization. The pragma tell the compiler that the
13357 object is declared and initialized elsewhere. The following package compiles
13358 without warnings (and the initialization is suppressed):
13359
13360 @smallexample @c ada
13361 with System;
13362 package G is
13363 type R is record
13364 M : Integer := 0;
13365 end record;
13366
13367 Ext : R;
13368 for Ext'Address use System'To_Address (16#1234_1234#);
13369 pragma Import (Ada, Ext);
13370 end G;
13371 @end smallexample
13372
13373 @noindent
13374 A final issue with address clauses involves their use for overlaying
13375 variables, as in the following example:
13376 @cindex Overlaying of objects
13377
13378 @smallexample @c ada
13379 A : Integer;
13380 B : Integer;
13381 for B'Address use A'Address;
13382 @end smallexample
13383
13384 @noindent
13385 or alternatively, using the form recommended by the RM:
13386
13387 @smallexample @c ada
13388 A : Integer;
13389 Addr : constant Address := A'Address;
13390 B : Integer;
13391 for B'Address use Addr;
13392 @end smallexample
13393
13394 @noindent
13395 In both of these cases, @code{A}
13396 and @code{B} become aliased to one another via the
13397 address clause. This use of address clauses to overlay
13398 variables, achieving an effect similar to unchecked
13399 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
13400 the effect is implementation defined. Furthermore, the
13401 Ada RM specifically recommends that in a situation
13402 like this, @code{B} should be subject to the following
13403 implementation advice (RM 13.3(19)):
13404
13405 @quotation
13406 19 If the Address of an object is specified, or it is imported
13407 or exported, then the implementation should not perform
13408 optimizations based on assumptions of no aliases.
13409 @end quotation
13410
13411 @noindent
13412 GNAT follows this recommendation, and goes further by also applying
13413 this recommendation to the overlaid variable (@code{A}
13414 in the above example) in this case. This means that the overlay
13415 works "as expected", in that a modification to one of the variables
13416 will affect the value of the other.
13417
13418 @node Effect of Convention on Representation
13419 @section Effect of Convention on Representation
13420 @cindex Convention, effect on representation
13421
13422 @noindent
13423 Normally the specification of a foreign language convention for a type or
13424 an object has no effect on the chosen representation. In particular, the
13425 representation chosen for data in GNAT generally meets the standard system
13426 conventions, and for example records are laid out in a manner that is
13427 consistent with C@. This means that specifying convention C (for example)
13428 has no effect.
13429
13430 There are four exceptions to this general rule:
13431
13432 @itemize @bullet
13433
13434 @item Convention Fortran and array subtypes
13435 If pragma Convention Fortran is specified for an array subtype, then in
13436 accordance with the implementation advice in section 3.6.2(11) of the
13437 Ada Reference Manual, the array will be stored in a Fortran-compatible
13438 column-major manner, instead of the normal default row-major order.
13439
13440 @item Convention C and enumeration types
13441 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
13442 to accommodate all values of the type. For example, for the enumeration
13443 type declared by:
13444
13445 @smallexample @c ada
13446 type Color is (Red, Green, Blue);
13447 @end smallexample
13448
13449 @noindent
13450 8 bits is sufficient to store all values of the type, so by default, objects
13451 of type @code{Color} will be represented using 8 bits. However, normal C
13452 convention is to use 32 bits for all enum values in C, since enum values
13453 are essentially of type int. If pragma @code{Convention C} is specified for an
13454 Ada enumeration type, then the size is modified as necessary (usually to
13455 32 bits) to be consistent with the C convention for enum values.
13456
13457 Note that this treatment applies only to types. If Convention C is given for
13458 an enumeration object, where the enumeration type is not Convention C, then
13459 Object_Size bits are allocated. For example, for a normal enumeration type,
13460 with less than 256 elements, only 8 bits will be allocated for the object.
13461 Since this may be a surprise in terms of what C expects, GNAT will issue a
13462 warning in this situation. The warning can be suppressed by giving an explicit
13463 size clause specifying the desired size.
13464
13465 @item Convention C/Fortran and Boolean types
13466 In C, the usual convention for boolean values, that is values used for
13467 conditions, is that zero represents false, and nonzero values represent
13468 true. In Ada, the normal convention is that two specific values, typically
13469 0/1, are used to represent false/true respectively.
13470
13471 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
13472 value represents true).
13473
13474 To accommodate the Fortran and C conventions, if a pragma Convention specifies
13475 C or Fortran convention for a derived Boolean, as in the following example:
13476
13477 @smallexample @c ada
13478 type C_Switch is new Boolean;
13479 pragma Convention (C, C_Switch);
13480 @end smallexample
13481
13482 @noindent
13483 then the GNAT generated code will treat any nonzero value as true. For truth
13484 values generated by GNAT, the conventional value 1 will be used for True, but
13485 when one of these values is read, any nonzero value is treated as True.
13486
13487 @item Access types on OpenVMS
13488 For 64-bit OpenVMS systems, access types (other than those for unconstrained
13489 arrays) are 64-bits long. An exception to this rule is for the case of
13490 C-convention access types where there is no explicit size clause present (or
13491 inherited for derived types). In this case, GNAT chooses to make these
13492 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
13493 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
13494
13495 @end itemize
13496
13497 @node Determining the Representations chosen by GNAT
13498 @section Determining the Representations chosen by GNAT
13499 @cindex Representation, determination of
13500 @cindex @option{-gnatR} switch
13501
13502 @noindent
13503 Although the descriptions in this section are intended to be complete, it is
13504 often easier to simply experiment to see what GNAT accepts and what the
13505 effect is on the layout of types and objects.
13506
13507 As required by the Ada RM, if a representation clause is not accepted, then
13508 it must be rejected as illegal by the compiler. However, when a
13509 representation clause or pragma is accepted, there can still be questions
13510 of what the compiler actually does. For example, if a partial record
13511 representation clause specifies the location of some components and not
13512 others, then where are the non-specified components placed? Or if pragma
13513 @code{Pack} is used on a record, then exactly where are the resulting
13514 fields placed? The section on pragma @code{Pack} in this chapter can be
13515 used to answer the second question, but it is often easier to just see
13516 what the compiler does.
13517
13518 For this purpose, GNAT provides the option @option{-gnatR}. If you compile
13519 with this option, then the compiler will output information on the actual
13520 representations chosen, in a format similar to source representation
13521 clauses. For example, if we compile the package:
13522
13523 @smallexample @c ada
13524 package q is
13525 type r (x : boolean) is tagged record
13526 case x is
13527 when True => S : String (1 .. 100);
13528 when False => null;
13529 end case;
13530 end record;
13531
13532 type r2 is new r (false) with record
13533 y2 : integer;
13534 end record;
13535
13536 for r2 use record
13537 y2 at 16 range 0 .. 31;
13538 end record;
13539
13540 type x is record
13541 y : character;
13542 end record;
13543
13544 type x1 is array (1 .. 10) of x;
13545 for x1'component_size use 11;
13546
13547 type ia is access integer;
13548
13549 type Rb1 is array (1 .. 13) of Boolean;
13550 pragma Pack (rb1);
13551
13552 type Rb2 is array (1 .. 65) of Boolean;
13553 pragma Pack (rb2);
13554
13555 type x2 is record
13556 l1 : Boolean;
13557 l2 : Duration;
13558 l3 : Float;
13559 l4 : Boolean;
13560 l5 : Rb1;
13561 l6 : Rb2;
13562 end record;
13563 pragma Pack (x2);
13564 end q;
13565 @end smallexample
13566
13567 @noindent
13568 using the switch @option{-gnatR} we obtain the following output:
13569
13570 @smallexample
13571 Representation information for unit q
13572 -------------------------------------
13573
13574 for r'Size use ??;
13575 for r'Alignment use 4;
13576 for r use record
13577 x at 4 range 0 .. 7;
13578 _tag at 0 range 0 .. 31;
13579 s at 5 range 0 .. 799;
13580 end record;
13581
13582 for r2'Size use 160;
13583 for r2'Alignment use 4;
13584 for r2 use record
13585 x at 4 range 0 .. 7;
13586 _tag at 0 range 0 .. 31;
13587 _parent at 0 range 0 .. 63;
13588 y2 at 16 range 0 .. 31;
13589 end record;
13590
13591 for x'Size use 8;
13592 for x'Alignment use 1;
13593 for x use record
13594 y at 0 range 0 .. 7;
13595 end record;
13596
13597 for x1'Size use 112;
13598 for x1'Alignment use 1;
13599 for x1'Component_Size use 11;
13600
13601 for rb1'Size use 13;
13602 for rb1'Alignment use 2;
13603 for rb1'Component_Size use 1;
13604
13605 for rb2'Size use 72;
13606 for rb2'Alignment use 1;
13607 for rb2'Component_Size use 1;
13608
13609 for x2'Size use 224;
13610 for x2'Alignment use 4;
13611 for x2 use record
13612 l1 at 0 range 0 .. 0;
13613 l2 at 0 range 1 .. 64;
13614 l3 at 12 range 0 .. 31;
13615 l4 at 16 range 0 .. 0;
13616 l5 at 16 range 1 .. 13;
13617 l6 at 18 range 0 .. 71;
13618 end record;
13619 @end smallexample
13620
13621 @noindent
13622 The Size values are actually the Object_Size, i.e.@: the default size that
13623 will be allocated for objects of the type.
13624 The ?? size for type r indicates that we have a variant record, and the
13625 actual size of objects will depend on the discriminant value.
13626
13627 The Alignment values show the actual alignment chosen by the compiler
13628 for each record or array type.
13629
13630 The record representation clause for type r shows where all fields
13631 are placed, including the compiler generated tag field (whose location
13632 cannot be controlled by the programmer).
13633
13634 The record representation clause for the type extension r2 shows all the
13635 fields present, including the parent field, which is a copy of the fields
13636 of the parent type of r2, i.e.@: r1.
13637
13638 The component size and size clauses for types rb1 and rb2 show
13639 the exact effect of pragma @code{Pack} on these arrays, and the record
13640 representation clause for type x2 shows how pragma @code{Pack} affects
13641 this record type.
13642
13643 In some cases, it may be useful to cut and paste the representation clauses
13644 generated by the compiler into the original source to fix and guarantee
13645 the actual representation to be used.
13646
13647 @node Standard Library Routines
13648 @chapter Standard Library Routines
13649
13650 @noindent
13651 The Ada Reference Manual contains in Annex A a full description of an
13652 extensive set of standard library routines that can be used in any Ada
13653 program, and which must be provided by all Ada compilers. They are
13654 analogous to the standard C library used by C programs.
13655
13656 GNAT implements all of the facilities described in annex A, and for most
13657 purposes the description in the Ada Reference Manual, or appropriate Ada
13658 text book, will be sufficient for making use of these facilities.
13659
13660 In the case of the input-output facilities,
13661 @xref{The Implementation of Standard I/O},
13662 gives details on exactly how GNAT interfaces to the
13663 file system. For the remaining packages, the Ada Reference Manual
13664 should be sufficient. The following is a list of the packages included,
13665 together with a brief description of the functionality that is provided.
13666
13667 For completeness, references are included to other predefined library
13668 routines defined in other sections of the Ada Reference Manual (these are
13669 cross-indexed from Annex A).
13670
13671 @table @code
13672 @item Ada (A.2)
13673 This is a parent package for all the standard library packages. It is
13674 usually included implicitly in your program, and itself contains no
13675 useful data or routines.
13676
13677 @item Ada.Calendar (9.6)
13678 @code{Calendar} provides time of day access, and routines for
13679 manipulating times and durations.
13680
13681 @item Ada.Characters (A.3.1)
13682 This is a dummy parent package that contains no useful entities
13683
13684 @item Ada.Characters.Handling (A.3.2)
13685 This package provides some basic character handling capabilities,
13686 including classification functions for classes of characters (e.g.@: test
13687 for letters, or digits).
13688
13689 @item Ada.Characters.Latin_1 (A.3.3)
13690 This package includes a complete set of definitions of the characters
13691 that appear in type CHARACTER@. It is useful for writing programs that
13692 will run in international environments. For example, if you want an
13693 upper case E with an acute accent in a string, it is often better to use
13694 the definition of @code{UC_E_Acute} in this package. Then your program
13695 will print in an understandable manner even if your environment does not
13696 support these extended characters.
13697
13698 @item Ada.Command_Line (A.15)
13699 This package provides access to the command line parameters and the name
13700 of the current program (analogous to the use of @code{argc} and @code{argv}
13701 in C), and also allows the exit status for the program to be set in a
13702 system-independent manner.
13703
13704 @item Ada.Decimal (F.2)
13705 This package provides constants describing the range of decimal numbers
13706 implemented, and also a decimal divide routine (analogous to the COBOL
13707 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
13708
13709 @item Ada.Direct_IO (A.8.4)
13710 This package provides input-output using a model of a set of records of
13711 fixed-length, containing an arbitrary definite Ada type, indexed by an
13712 integer record number.
13713
13714 @item Ada.Dynamic_Priorities (D.5)
13715 This package allows the priorities of a task to be adjusted dynamically
13716 as the task is running.
13717
13718 @item Ada.Exceptions (11.4.1)
13719 This package provides additional information on exceptions, and also
13720 contains facilities for treating exceptions as data objects, and raising
13721 exceptions with associated messages.
13722
13723 @item Ada.Finalization (7.6)
13724 This package contains the declarations and subprograms to support the
13725 use of controlled types, providing for automatic initialization and
13726 finalization (analogous to the constructors and destructors of C++)
13727
13728 @item Ada.Interrupts (C.3.2)
13729 This package provides facilities for interfacing to interrupts, which
13730 includes the set of signals or conditions that can be raised and
13731 recognized as interrupts.
13732
13733 @item Ada.Interrupts.Names (C.3.2)
13734 This package provides the set of interrupt names (actually signal
13735 or condition names) that can be handled by GNAT@.
13736
13737 @item Ada.IO_Exceptions (A.13)
13738 This package defines the set of exceptions that can be raised by use of
13739 the standard IO packages.
13740
13741 @item Ada.Numerics
13742 This package contains some standard constants and exceptions used
13743 throughout the numerics packages. Note that the constants pi and e are
13744 defined here, and it is better to use these definitions than rolling
13745 your own.
13746
13747 @item Ada.Numerics.Complex_Elementary_Functions
13748 Provides the implementation of standard elementary functions (such as
13749 log and trigonometric functions) operating on complex numbers using the
13750 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
13751 created by the package @code{Numerics.Complex_Types}.
13752
13753 @item Ada.Numerics.Complex_Types
13754 This is a predefined instantiation of
13755 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
13756 build the type @code{Complex} and @code{Imaginary}.
13757
13758 @item Ada.Numerics.Discrete_Random
13759 This generic package provides a random number generator suitable for generating
13760 uniformly distributed values of a specified discrete subtype.
13761
13762 @item Ada.Numerics.Float_Random
13763 This package provides a random number generator suitable for generating
13764 uniformly distributed floating point values in the unit interval.
13765
13766 @item Ada.Numerics.Generic_Complex_Elementary_Functions
13767 This is a generic version of the package that provides the
13768 implementation of standard elementary functions (such as log and
13769 trigonometric functions) for an arbitrary complex type.
13770
13771 The following predefined instantiations of this package are provided:
13772
13773 @table @code
13774 @item Short_Float
13775 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
13776 @item Float
13777 @code{Ada.Numerics.Complex_Elementary_Functions}
13778 @item Long_Float
13779 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
13780 @end table
13781
13782 @item Ada.Numerics.Generic_Complex_Types
13783 This is a generic package that allows the creation of complex types,
13784 with associated complex arithmetic operations.
13785
13786 The following predefined instantiations of this package exist
13787 @table @code
13788 @item Short_Float
13789 @code{Ada.Numerics.Short_Complex_Complex_Types}
13790 @item Float
13791 @code{Ada.Numerics.Complex_Complex_Types}
13792 @item Long_Float
13793 @code{Ada.Numerics.Long_Complex_Complex_Types}
13794 @end table
13795
13796 @item Ada.Numerics.Generic_Elementary_Functions
13797 This is a generic package that provides the implementation of standard
13798 elementary functions (such as log an trigonometric functions) for an
13799 arbitrary float type.
13800
13801 The following predefined instantiations of this package exist
13802
13803 @table @code
13804 @item Short_Float
13805 @code{Ada.Numerics.Short_Elementary_Functions}
13806 @item Float
13807 @code{Ada.Numerics.Elementary_Functions}
13808 @item Long_Float
13809 @code{Ada.Numerics.Long_Elementary_Functions}
13810 @end table
13811
13812 @item Ada.Real_Time (D.8)
13813 This package provides facilities similar to those of @code{Calendar}, but
13814 operating with a finer clock suitable for real time control. Note that
13815 annex D requires that there be no backward clock jumps, and GNAT generally
13816 guarantees this behavior, but of course if the external clock on which
13817 the GNAT runtime depends is deliberately reset by some external event,
13818 then such a backward jump may occur.
13819
13820 @item Ada.Sequential_IO (A.8.1)
13821 This package provides input-output facilities for sequential files,
13822 which can contain a sequence of values of a single type, which can be
13823 any Ada type, including indefinite (unconstrained) types.
13824
13825 @item Ada.Storage_IO (A.9)
13826 This package provides a facility for mapping arbitrary Ada types to and
13827 from a storage buffer. It is primarily intended for the creation of new
13828 IO packages.
13829
13830 @item Ada.Streams (13.13.1)
13831 This is a generic package that provides the basic support for the
13832 concept of streams as used by the stream attributes (@code{Input},
13833 @code{Output}, @code{Read} and @code{Write}).
13834
13835 @item Ada.Streams.Stream_IO (A.12.1)
13836 This package is a specialization of the type @code{Streams} defined in
13837 package @code{Streams} together with a set of operations providing
13838 Stream_IO capability. The Stream_IO model permits both random and
13839 sequential access to a file which can contain an arbitrary set of values
13840 of one or more Ada types.
13841
13842 @item Ada.Strings (A.4.1)
13843 This package provides some basic constants used by the string handling
13844 packages.
13845
13846 @item Ada.Strings.Bounded (A.4.4)
13847 This package provides facilities for handling variable length
13848 strings. The bounded model requires a maximum length. It is thus
13849 somewhat more limited than the unbounded model, but avoids the use of
13850 dynamic allocation or finalization.
13851
13852 @item Ada.Strings.Fixed (A.4.3)
13853 This package provides facilities for handling fixed length strings.
13854
13855 @item Ada.Strings.Maps (A.4.2)
13856 This package provides facilities for handling character mappings and
13857 arbitrarily defined subsets of characters. For instance it is useful in
13858 defining specialized translation tables.
13859
13860 @item Ada.Strings.Maps.Constants (A.4.6)
13861 This package provides a standard set of predefined mappings and
13862 predefined character sets. For example, the standard upper to lower case
13863 conversion table is found in this package. Note that upper to lower case
13864 conversion is non-trivial if you want to take the entire set of
13865 characters, including extended characters like E with an acute accent,
13866 into account. You should use the mappings in this package (rather than
13867 adding 32 yourself) to do case mappings.
13868
13869 @item Ada.Strings.Unbounded (A.4.5)
13870 This package provides facilities for handling variable length
13871 strings. The unbounded model allows arbitrary length strings, but
13872 requires the use of dynamic allocation and finalization.
13873
13874 @item Ada.Strings.Wide_Bounded (A.4.7)
13875 @itemx Ada.Strings.Wide_Fixed (A.4.7)
13876 @itemx Ada.Strings.Wide_Maps (A.4.7)
13877 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
13878 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
13879 These packages provide analogous capabilities to the corresponding
13880 packages without @samp{Wide_} in the name, but operate with the types
13881 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
13882 and @code{Character}.
13883
13884 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
13885 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
13886 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
13887 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
13888 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
13889 These packages provide analogous capabilities to the corresponding
13890 packages without @samp{Wide_} in the name, but operate with the types
13891 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
13892 of @code{String} and @code{Character}.
13893
13894 @item Ada.Synchronous_Task_Control (D.10)
13895 This package provides some standard facilities for controlling task
13896 communication in a synchronous manner.
13897
13898 @item Ada.Tags
13899 This package contains definitions for manipulation of the tags of tagged
13900 values.
13901
13902 @item Ada.Task_Attributes
13903 This package provides the capability of associating arbitrary
13904 task-specific data with separate tasks.
13905
13906 @item Ada.Text_IO
13907 This package provides basic text input-output capabilities for
13908 character, string and numeric data. The subpackages of this
13909 package are listed next.
13910
13911 @item Ada.Text_IO.Decimal_IO
13912 Provides input-output facilities for decimal fixed-point types
13913
13914 @item Ada.Text_IO.Enumeration_IO
13915 Provides input-output facilities for enumeration types.
13916
13917 @item Ada.Text_IO.Fixed_IO
13918 Provides input-output facilities for ordinary fixed-point types.
13919
13920 @item Ada.Text_IO.Float_IO
13921 Provides input-output facilities for float types. The following
13922 predefined instantiations of this generic package are available:
13923
13924 @table @code
13925 @item Short_Float
13926 @code{Short_Float_Text_IO}
13927 @item Float
13928 @code{Float_Text_IO}
13929 @item Long_Float
13930 @code{Long_Float_Text_IO}
13931 @end table
13932
13933 @item Ada.Text_IO.Integer_IO
13934 Provides input-output facilities for integer types. The following
13935 predefined instantiations of this generic package are available:
13936
13937 @table @code
13938 @item Short_Short_Integer
13939 @code{Ada.Short_Short_Integer_Text_IO}
13940 @item Short_Integer
13941 @code{Ada.Short_Integer_Text_IO}
13942 @item Integer
13943 @code{Ada.Integer_Text_IO}
13944 @item Long_Integer
13945 @code{Ada.Long_Integer_Text_IO}
13946 @item Long_Long_Integer
13947 @code{Ada.Long_Long_Integer_Text_IO}
13948 @end table
13949
13950 @item Ada.Text_IO.Modular_IO
13951 Provides input-output facilities for modular (unsigned) types
13952
13953 @item Ada.Text_IO.Complex_IO (G.1.3)
13954 This package provides basic text input-output capabilities for complex
13955 data.
13956
13957 @item Ada.Text_IO.Editing (F.3.3)
13958 This package contains routines for edited output, analogous to the use
13959 of pictures in COBOL@. The picture formats used by this package are a
13960 close copy of the facility in COBOL@.
13961
13962 @item Ada.Text_IO.Text_Streams (A.12.2)
13963 This package provides a facility that allows Text_IO files to be treated
13964 as streams, so that the stream attributes can be used for writing
13965 arbitrary data, including binary data, to Text_IO files.
13966
13967 @item Ada.Unchecked_Conversion (13.9)
13968 This generic package allows arbitrary conversion from one type to
13969 another of the same size, providing for breaking the type safety in
13970 special circumstances.
13971
13972 If the types have the same Size (more accurately the same Value_Size),
13973 then the effect is simply to transfer the bits from the source to the
13974 target type without any modification. This usage is well defined, and
13975 for simple types whose representation is typically the same across
13976 all implementations, gives a portable method of performing such
13977 conversions.
13978
13979 If the types do not have the same size, then the result is implementation
13980 defined, and thus may be non-portable. The following describes how GNAT
13981 handles such unchecked conversion cases.
13982
13983 If the types are of different sizes, and are both discrete types, then
13984 the effect is of a normal type conversion without any constraint checking.
13985 In particular if the result type has a larger size, the result will be
13986 zero or sign extended. If the result type has a smaller size, the result
13987 will be truncated by ignoring high order bits.
13988
13989 If the types are of different sizes, and are not both discrete types,
13990 then the conversion works as though pointers were created to the source
13991 and target, and the pointer value is converted. The effect is that bits
13992 are copied from successive low order storage units and bits of the source
13993 up to the length of the target type.
13994
13995 A warning is issued if the lengths differ, since the effect in this
13996 case is implementation dependent, and the above behavior may not match
13997 that of some other compiler.
13998
13999 A pointer to one type may be converted to a pointer to another type using
14000 unchecked conversion. The only case in which the effect is undefined is
14001 when one or both pointers are pointers to unconstrained array types. In
14002 this case, the bounds information may get incorrectly transferred, and in
14003 particular, GNAT uses double size pointers for such types, and it is
14004 meaningless to convert between such pointer types. GNAT will issue a
14005 warning if the alignment of the target designated type is more strict
14006 than the alignment of the source designated type (since the result may
14007 be unaligned in this case).
14008
14009 A pointer other than a pointer to an unconstrained array type may be
14010 converted to and from System.Address. Such usage is common in Ada 83
14011 programs, but note that Ada.Address_To_Access_Conversions is the
14012 preferred method of performing such conversions in Ada 95 and Ada 2005.
14013 Neither
14014 unchecked conversion nor Ada.Address_To_Access_Conversions should be
14015 used in conjunction with pointers to unconstrained objects, since
14016 the bounds information cannot be handled correctly in this case.
14017
14018 @item Ada.Unchecked_Deallocation (13.11.2)
14019 This generic package allows explicit freeing of storage previously
14020 allocated by use of an allocator.
14021
14022 @item Ada.Wide_Text_IO (A.11)
14023 This package is similar to @code{Ada.Text_IO}, except that the external
14024 file supports wide character representations, and the internal types are
14025 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14026 and @code{String}. It contains generic subpackages listed next.
14027
14028 @item Ada.Wide_Text_IO.Decimal_IO
14029 Provides input-output facilities for decimal fixed-point types
14030
14031 @item Ada.Wide_Text_IO.Enumeration_IO
14032 Provides input-output facilities for enumeration types.
14033
14034 @item Ada.Wide_Text_IO.Fixed_IO
14035 Provides input-output facilities for ordinary fixed-point types.
14036
14037 @item Ada.Wide_Text_IO.Float_IO
14038 Provides input-output facilities for float types. The following
14039 predefined instantiations of this generic package are available:
14040
14041 @table @code
14042 @item Short_Float
14043 @code{Short_Float_Wide_Text_IO}
14044 @item Float
14045 @code{Float_Wide_Text_IO}
14046 @item Long_Float
14047 @code{Long_Float_Wide_Text_IO}
14048 @end table
14049
14050 @item Ada.Wide_Text_IO.Integer_IO
14051 Provides input-output facilities for integer types. The following
14052 predefined instantiations of this generic package are available:
14053
14054 @table @code
14055 @item Short_Short_Integer
14056 @code{Ada.Short_Short_Integer_Wide_Text_IO}
14057 @item Short_Integer
14058 @code{Ada.Short_Integer_Wide_Text_IO}
14059 @item Integer
14060 @code{Ada.Integer_Wide_Text_IO}
14061 @item Long_Integer
14062 @code{Ada.Long_Integer_Wide_Text_IO}
14063 @item Long_Long_Integer
14064 @code{Ada.Long_Long_Integer_Wide_Text_IO}
14065 @end table
14066
14067 @item Ada.Wide_Text_IO.Modular_IO
14068 Provides input-output facilities for modular (unsigned) types
14069
14070 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
14071 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14072 external file supports wide character representations.
14073
14074 @item Ada.Wide_Text_IO.Editing (F.3.4)
14075 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14076 types are @code{Wide_Character} and @code{Wide_String} instead of
14077 @code{Character} and @code{String}.
14078
14079 @item Ada.Wide_Text_IO.Streams (A.12.3)
14080 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14081 types are @code{Wide_Character} and @code{Wide_String} instead of
14082 @code{Character} and @code{String}.
14083
14084 @item Ada.Wide_Wide_Text_IO (A.11)
14085 This package is similar to @code{Ada.Text_IO}, except that the external
14086 file supports wide character representations, and the internal types are
14087 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
14088 and @code{String}. It contains generic subpackages listed next.
14089
14090 @item Ada.Wide_Wide_Text_IO.Decimal_IO
14091 Provides input-output facilities for decimal fixed-point types
14092
14093 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
14094 Provides input-output facilities for enumeration types.
14095
14096 @item Ada.Wide_Wide_Text_IO.Fixed_IO
14097 Provides input-output facilities for ordinary fixed-point types.
14098
14099 @item Ada.Wide_Wide_Text_IO.Float_IO
14100 Provides input-output facilities for float types. The following
14101 predefined instantiations of this generic package are available:
14102
14103 @table @code
14104 @item Short_Float
14105 @code{Short_Float_Wide_Wide_Text_IO}
14106 @item Float
14107 @code{Float_Wide_Wide_Text_IO}
14108 @item Long_Float
14109 @code{Long_Float_Wide_Wide_Text_IO}
14110 @end table
14111
14112 @item Ada.Wide_Wide_Text_IO.Integer_IO
14113 Provides input-output facilities for integer types. The following
14114 predefined instantiations of this generic package are available:
14115
14116 @table @code
14117 @item Short_Short_Integer
14118 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
14119 @item Short_Integer
14120 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
14121 @item Integer
14122 @code{Ada.Integer_Wide_Wide_Text_IO}
14123 @item Long_Integer
14124 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
14125 @item Long_Long_Integer
14126 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
14127 @end table
14128
14129 @item Ada.Wide_Wide_Text_IO.Modular_IO
14130 Provides input-output facilities for modular (unsigned) types
14131
14132 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
14133 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
14134 external file supports wide character representations.
14135
14136 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
14137 This package is similar to @code{Ada.Text_IO.Editing}, except that the
14138 types are @code{Wide_Character} and @code{Wide_String} instead of
14139 @code{Character} and @code{String}.
14140
14141 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
14142 This package is similar to @code{Ada.Text_IO.Streams}, except that the
14143 types are @code{Wide_Character} and @code{Wide_String} instead of
14144 @code{Character} and @code{String}.
14145 @end table
14146
14147 @node The Implementation of Standard I/O
14148 @chapter The Implementation of Standard I/O
14149
14150 @noindent
14151 GNAT implements all the required input-output facilities described in
14152 A.6 through A.14. These sections of the Ada Reference Manual describe the
14153 required behavior of these packages from the Ada point of view, and if
14154 you are writing a portable Ada program that does not need to know the
14155 exact manner in which Ada maps to the outside world when it comes to
14156 reading or writing external files, then you do not need to read this
14157 chapter. As long as your files are all regular files (not pipes or
14158 devices), and as long as you write and read the files only from Ada, the
14159 description in the Ada Reference Manual is sufficient.
14160
14161 However, if you want to do input-output to pipes or other devices, such
14162 as the keyboard or screen, or if the files you are dealing with are
14163 either generated by some other language, or to be read by some other
14164 language, then you need to know more about the details of how the GNAT
14165 implementation of these input-output facilities behaves.
14166
14167 In this chapter we give a detailed description of exactly how GNAT
14168 interfaces to the file system. As always, the sources of the system are
14169 available to you for answering questions at an even more detailed level,
14170 but for most purposes the information in this chapter will suffice.
14171
14172 Another reason that you may need to know more about how input-output is
14173 implemented arises when you have a program written in mixed languages
14174 where, for example, files are shared between the C and Ada sections of
14175 the same program. GNAT provides some additional facilities, in the form
14176 of additional child library packages, that facilitate this sharing, and
14177 these additional facilities are also described in this chapter.
14178
14179 @menu
14180 * Standard I/O Packages::
14181 * FORM Strings::
14182 * Direct_IO::
14183 * Sequential_IO::
14184 * Text_IO::
14185 * Wide_Text_IO::
14186 * Wide_Wide_Text_IO::
14187 * Stream_IO::
14188 * Text Translation::
14189 * Shared Files::
14190 * Filenames encoding::
14191 * Open Modes::
14192 * Operations on C Streams::
14193 * Interfacing to C Streams::
14194 @end menu
14195
14196 @node Standard I/O Packages
14197 @section Standard I/O Packages
14198
14199 @noindent
14200 The Standard I/O packages described in Annex A for
14201
14202 @itemize @bullet
14203 @item
14204 Ada.Text_IO
14205 @item
14206 Ada.Text_IO.Complex_IO
14207 @item
14208 Ada.Text_IO.Text_Streams
14209 @item
14210 Ada.Wide_Text_IO
14211 @item
14212 Ada.Wide_Text_IO.Complex_IO
14213 @item
14214 Ada.Wide_Text_IO.Text_Streams
14215 @item
14216 Ada.Wide_Wide_Text_IO
14217 @item
14218 Ada.Wide_Wide_Text_IO.Complex_IO
14219 @item
14220 Ada.Wide_Wide_Text_IO.Text_Streams
14221 @item
14222 Ada.Stream_IO
14223 @item
14224 Ada.Sequential_IO
14225 @item
14226 Ada.Direct_IO
14227 @end itemize
14228
14229 @noindent
14230 are implemented using the C
14231 library streams facility; where
14232
14233 @itemize @bullet
14234 @item
14235 All files are opened using @code{fopen}.
14236 @item
14237 All input/output operations use @code{fread}/@code{fwrite}.
14238 @end itemize
14239
14240 @noindent
14241 There is no internal buffering of any kind at the Ada library level. The only
14242 buffering is that provided at the system level in the implementation of the
14243 library routines that support streams. This facilitates shared use of these
14244 streams by mixed language programs. Note though that system level buffering is
14245 explicitly enabled at elaboration of the standard I/O packages and that can
14246 have an impact on mixed language programs, in particular those using I/O before
14247 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
14248 the Ada elaboration routine before performing any I/O or when impractical,
14249 flush the common I/O streams and in particular Standard_Output before
14250 elaborating the Ada code.
14251
14252 @node FORM Strings
14253 @section FORM Strings
14254
14255 @noindent
14256 The format of a FORM string in GNAT is:
14257
14258 @smallexample
14259 "keyword=value,keyword=value,@dots{},keyword=value"
14260 @end smallexample
14261
14262 @noindent
14263 where letters may be in upper or lower case, and there are no spaces
14264 between values. The order of the entries is not important. Currently
14265 the following keywords defined.
14266
14267 @smallexample
14268 TEXT_TRANSLATION=[YES|NO]
14269 SHARED=[YES|NO]
14270 WCEM=[n|h|u|s|e|8|b]
14271 ENCODING=[UTF8|8BITS]
14272 @end smallexample
14273
14274 @noindent
14275 The use of these parameters is described later in this section. If an
14276 unrecognized keyword appears in a form string, it is silently ignored
14277 and not considered invalid.
14278
14279 @noindent
14280 For OpenVMS additional FORM string keywords are available for use with
14281 RMS services. The syntax is:
14282
14283 @smallexample
14284 VMS_RMS_Keys=(keyword=value,@dots{},keyword=value)
14285 @end smallexample
14286
14287 @noindent
14288 The following RMS keywords and values are currently defined:
14289
14290 @smallexample
14291 Context=Force_Stream_Mode|Force_Record_Mode
14292 @end smallexample
14293
14294 @noindent
14295 VMS RMS keys are silently ignored on non-VMS systems. On OpenVMS
14296 unimplented RMS keywords, values, or invalid syntax will raise Use_Error.
14297
14298 @node Direct_IO
14299 @section Direct_IO
14300
14301 @noindent
14302 Direct_IO can only be instantiated for definite types. This is a
14303 restriction of the Ada language, which means that the records are fixed
14304 length (the length being determined by @code{@var{type}'Size}, rounded
14305 up to the next storage unit boundary if necessary).
14306
14307 The records of a Direct_IO file are simply written to the file in index
14308 sequence, with the first record starting at offset zero, and subsequent
14309 records following. There is no control information of any kind. For
14310 example, if 32-bit integers are being written, each record takes
14311 4-bytes, so the record at index @var{K} starts at offset
14312 (@var{K}@minus{}1)*4.
14313
14314 There is no limit on the size of Direct_IO files, they are expanded as
14315 necessary to accommodate whatever records are written to the file.
14316
14317 @node Sequential_IO
14318 @section Sequential_IO
14319
14320 @noindent
14321 Sequential_IO may be instantiated with either a definite (constrained)
14322 or indefinite (unconstrained) type.
14323
14324 For the definite type case, the elements written to the file are simply
14325 the memory images of the data values with no control information of any
14326 kind. The resulting file should be read using the same type, no validity
14327 checking is performed on input.
14328
14329 For the indefinite type case, the elements written consist of two
14330 parts. First is the size of the data item, written as the memory image
14331 of a @code{Interfaces.C.size_t} value, followed by the memory image of
14332 the data value. The resulting file can only be read using the same
14333 (unconstrained) type. Normal assignment checks are performed on these
14334 read operations, and if these checks fail, @code{Data_Error} is
14335 raised. In particular, in the array case, the lengths must match, and in
14336 the variant record case, if the variable for a particular read operation
14337 is constrained, the discriminants must match.
14338
14339 Note that it is not possible to use Sequential_IO to write variable
14340 length array items, and then read the data back into different length
14341 arrays. For example, the following will raise @code{Data_Error}:
14342
14343 @smallexample @c ada
14344 package IO is new Sequential_IO (String);
14345 F : IO.File_Type;
14346 S : String (1..4);
14347 @dots{}
14348 IO.Create (F)
14349 IO.Write (F, "hello!")
14350 IO.Reset (F, Mode=>In_File);
14351 IO.Read (F, S);
14352 Put_Line (S);
14353
14354 @end smallexample
14355
14356 @noindent
14357 On some Ada implementations, this will print @code{hell}, but the program is
14358 clearly incorrect, since there is only one element in the file, and that
14359 element is the string @code{hello!}.
14360
14361 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
14362 using Stream_IO, and this is the preferred mechanism. In particular, the
14363 above program fragment rewritten to use Stream_IO will work correctly.
14364
14365 @node Text_IO
14366 @section Text_IO
14367
14368 @noindent
14369 Text_IO files consist of a stream of characters containing the following
14370 special control characters:
14371
14372 @smallexample
14373 LF (line feed, 16#0A#) Line Mark
14374 FF (form feed, 16#0C#) Page Mark
14375 @end smallexample
14376
14377 @noindent
14378 A canonical Text_IO file is defined as one in which the following
14379 conditions are met:
14380
14381 @itemize @bullet
14382 @item
14383 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
14384 of the line.
14385
14386 @item
14387 The character @code{FF} is used only as a page mark, i.e.@: to mark the
14388 end of a page and consequently can appear only immediately following a
14389 @code{LF} (line mark) character.
14390
14391 @item
14392 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
14393 (line mark, page mark). In the former case, the page mark is implicitly
14394 assumed to be present.
14395 @end itemize
14396
14397 @noindent
14398 A file written using Text_IO will be in canonical form provided that no
14399 explicit @code{LF} or @code{FF} characters are written using @code{Put}
14400 or @code{Put_Line}. There will be no @code{FF} character at the end of
14401 the file unless an explicit @code{New_Page} operation was performed
14402 before closing the file.
14403
14404 A canonical Text_IO file that is a regular file (i.e., not a device or a
14405 pipe) can be read using any of the routines in Text_IO@. The
14406 semantics in this case will be exactly as defined in the Ada Reference
14407 Manual, and all the routines in Text_IO are fully implemented.
14408
14409 A text file that does not meet the requirements for a canonical Text_IO
14410 file has one of the following:
14411
14412 @itemize @bullet
14413 @item
14414 The file contains @code{FF} characters not immediately following a
14415 @code{LF} character.
14416
14417 @item
14418 The file contains @code{LF} or @code{FF} characters written by
14419 @code{Put} or @code{Put_Line}, which are not logically considered to be
14420 line marks or page marks.
14421
14422 @item
14423 The file ends in a character other than @code{LF} or @code{FF},
14424 i.e.@: there is no explicit line mark or page mark at the end of the file.
14425 @end itemize
14426
14427 @noindent
14428 Text_IO can be used to read such non-standard text files but subprograms
14429 to do with line or page numbers do not have defined meanings. In
14430 particular, a @code{FF} character that does not follow a @code{LF}
14431 character may or may not be treated as a page mark from the point of
14432 view of page and line numbering. Every @code{LF} character is considered
14433 to end a line, and there is an implied @code{LF} character at the end of
14434 the file.
14435
14436 @menu
14437 * Text_IO Stream Pointer Positioning::
14438 * Text_IO Reading and Writing Non-Regular Files::
14439 * Get_Immediate::
14440 * Treating Text_IO Files as Streams::
14441 * Text_IO Extensions::
14442 * Text_IO Facilities for Unbounded Strings::
14443 @end menu
14444
14445 @node Text_IO Stream Pointer Positioning
14446 @subsection Stream Pointer Positioning
14447
14448 @noindent
14449 @code{Ada.Text_IO} has a definition of current position for a file that
14450 is being read. No internal buffering occurs in Text_IO, and usually the
14451 physical position in the stream used to implement the file corresponds
14452 to this logical position defined by Text_IO@. There are two exceptions:
14453
14454 @itemize @bullet
14455 @item
14456 After a call to @code{End_Of_Page} that returns @code{True}, the stream
14457 is positioned past the @code{LF} (line mark) that precedes the page
14458 mark. Text_IO maintains an internal flag so that subsequent read
14459 operations properly handle the logical position which is unchanged by
14460 the @code{End_Of_Page} call.
14461
14462 @item
14463 After a call to @code{End_Of_File} that returns @code{True}, if the
14464 Text_IO file was positioned before the line mark at the end of file
14465 before the call, then the logical position is unchanged, but the stream
14466 is physically positioned right at the end of file (past the line mark,
14467 and past a possible page mark following the line mark. Again Text_IO
14468 maintains internal flags so that subsequent read operations properly
14469 handle the logical position.
14470 @end itemize
14471
14472 @noindent
14473 These discrepancies have no effect on the observable behavior of
14474 Text_IO, but if a single Ada stream is shared between a C program and
14475 Ada program, or shared (using @samp{shared=yes} in the form string)
14476 between two Ada files, then the difference may be observable in some
14477 situations.
14478
14479 @node Text_IO Reading and Writing Non-Regular Files
14480 @subsection Reading and Writing Non-Regular Files
14481
14482 @noindent
14483 A non-regular file is a device (such as a keyboard), or a pipe. Text_IO
14484 can be used for reading and writing. Writing is not affected and the
14485 sequence of characters output is identical to the normal file case, but
14486 for reading, the behavior of Text_IO is modified to avoid undesirable
14487 look-ahead as follows:
14488
14489 An input file that is not a regular file is considered to have no page
14490 marks. Any @code{Ascii.FF} characters (the character normally used for a
14491 page mark) appearing in the file are considered to be data
14492 characters. In particular:
14493
14494 @itemize @bullet
14495 @item
14496 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
14497 following a line mark. If a page mark appears, it will be treated as a
14498 data character.
14499
14500 @item
14501 This avoids the need to wait for an extra character to be typed or
14502 entered from the pipe to complete one of these operations.
14503
14504 @item
14505 @code{End_Of_Page} always returns @code{False}
14506
14507 @item
14508 @code{End_Of_File} will return @code{False} if there is a page mark at
14509 the end of the file.
14510 @end itemize
14511
14512 @noindent
14513 Output to non-regular files is the same as for regular files. Page marks
14514 may be written to non-regular files using @code{New_Page}, but as noted
14515 above they will not be treated as page marks on input if the output is
14516 piped to another Ada program.
14517
14518 Another important discrepancy when reading non-regular files is that the end
14519 of file indication is not ``sticky''. If an end of file is entered, e.g.@: by
14520 pressing the @key{EOT} key,
14521 then end of file
14522 is signaled once (i.e.@: the test @code{End_Of_File}
14523 will yield @code{True}, or a read will
14524 raise @code{End_Error}), but then reading can resume
14525 to read data past that end of
14526 file indication, until another end of file indication is entered.
14527
14528 @node Get_Immediate
14529 @subsection Get_Immediate
14530 @cindex Get_Immediate
14531
14532 @noindent
14533 Get_Immediate returns the next character (including control characters)
14534 from the input file. In particular, Get_Immediate will return LF or FF
14535 characters used as line marks or page marks. Such operations leave the
14536 file positioned past the control character, and it is thus not treated
14537 as having its normal function. This means that page, line and column
14538 counts after this kind of Get_Immediate call are set as though the mark
14539 did not occur. In the case where a Get_Immediate leaves the file
14540 positioned between the line mark and page mark (which is not normally
14541 possible), it is undefined whether the FF character will be treated as a
14542 page mark.
14543
14544 @node Treating Text_IO Files as Streams
14545 @subsection Treating Text_IO Files as Streams
14546 @cindex Stream files
14547
14548 @noindent
14549 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
14550 as a stream. Data written to a Text_IO file in this stream mode is
14551 binary data. If this binary data contains bytes 16#0A# (@code{LF}) or
14552 16#0C# (@code{FF}), the resulting file may have non-standard
14553 format. Similarly if read operations are used to read from a Text_IO
14554 file treated as a stream, then @code{LF} and @code{FF} characters may be
14555 skipped and the effect is similar to that described above for
14556 @code{Get_Immediate}.
14557
14558 @node Text_IO Extensions
14559 @subsection Text_IO Extensions
14560 @cindex Text_IO extensions
14561
14562 @noindent
14563 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
14564 to the standard @code{Text_IO} package:
14565
14566 @itemize @bullet
14567 @item function File_Exists (Name : String) return Boolean;
14568 Determines if a file of the given name exists.
14569
14570 @item function Get_Line return String;
14571 Reads a string from the standard input file. The value returned is exactly
14572 the length of the line that was read.
14573
14574 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
14575 Similar, except that the parameter File specifies the file from which
14576 the string is to be read.
14577
14578 @end itemize
14579
14580 @node Text_IO Facilities for Unbounded Strings
14581 @subsection Text_IO Facilities for Unbounded Strings
14582 @cindex Text_IO for unbounded strings
14583 @cindex Unbounded_String, Text_IO operations
14584
14585 @noindent
14586 The package @code{Ada.Strings.Unbounded.Text_IO}
14587 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
14588 subprograms useful for Text_IO operations on unbounded strings:
14589
14590 @itemize @bullet
14591
14592 @item function Get_Line (File : File_Type) return Unbounded_String;
14593 Reads a line from the specified file
14594 and returns the result as an unbounded string.
14595
14596 @item procedure Put (File : File_Type; U : Unbounded_String);
14597 Writes the value of the given unbounded string to the specified file
14598 Similar to the effect of
14599 @code{Put (To_String (U))} except that an extra copy is avoided.
14600
14601 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
14602 Writes the value of the given unbounded string to the specified file,
14603 followed by a @code{New_Line}.
14604 Similar to the effect of @code{Put_Line (To_String (U))} except
14605 that an extra copy is avoided.
14606 @end itemize
14607
14608 @noindent
14609 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
14610 and is optional. If the parameter is omitted, then the standard input or
14611 output file is referenced as appropriate.
14612
14613 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
14614 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
14615 @code{Wide_Text_IO} functionality for unbounded wide strings.
14616
14617 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
14618 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
14619 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
14620
14621 @node Wide_Text_IO
14622 @section Wide_Text_IO
14623
14624 @noindent
14625 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
14626 both input and output files may contain special sequences that represent
14627 wide character values. The encoding scheme for a given file may be
14628 specified using a FORM parameter:
14629
14630 @smallexample
14631 WCEM=@var{x}
14632 @end smallexample
14633
14634 @noindent
14635 as part of the FORM string (WCEM = wide character encoding method),
14636 where @var{x} is one of the following characters
14637
14638 @table @samp
14639 @item h
14640 Hex ESC encoding
14641 @item u
14642 Upper half encoding
14643 @item s
14644 Shift-JIS encoding
14645 @item e
14646 EUC Encoding
14647 @item 8
14648 UTF-8 encoding
14649 @item b
14650 Brackets encoding
14651 @end table
14652
14653 @noindent
14654 The encoding methods match those that
14655 can be used in a source
14656 program, but there is no requirement that the encoding method used for
14657 the source program be the same as the encoding method used for files,
14658 and different files may use different encoding methods.
14659
14660 The default encoding method for the standard files, and for opened files
14661 for which no WCEM parameter is given in the FORM string matches the
14662 wide character encoding specified for the main program (the default
14663 being brackets encoding if no coding method was specified with -gnatW).
14664
14665 @table @asis
14666 @item Hex Coding
14667 In this encoding, a wide character is represented by a five character
14668 sequence:
14669
14670 @smallexample
14671 ESC a b c d
14672 @end smallexample
14673
14674 @noindent
14675 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
14676 characters (using upper case letters) of the wide character code. For
14677 example, ESC A345 is used to represent the wide character with code
14678 16#A345#. This scheme is compatible with use of the full
14679 @code{Wide_Character} set.
14680
14681 @item Upper Half Coding
14682 The wide character with encoding 16#abcd#, where the upper bit is on
14683 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
14684 16#cd#. The second byte may never be a format control character, but is
14685 not required to be in the upper half. This method can be also used for
14686 shift-JIS or EUC where the internal coding matches the external coding.
14687
14688 @item Shift JIS Coding
14689 A wide character is represented by a two character sequence 16#ab# and
14690 16#cd#, with the restrictions described for upper half encoding as
14691 described above. The internal character code is the corresponding JIS
14692 character according to the standard algorithm for Shift-JIS
14693 conversion. Only characters defined in the JIS code set table can be
14694 used with this encoding method.
14695
14696 @item EUC Coding
14697 A wide character is represented by a two character sequence 16#ab# and
14698 16#cd#, with both characters being in the upper half. The internal
14699 character code is the corresponding JIS character according to the EUC
14700 encoding algorithm. Only characters defined in the JIS code set table
14701 can be used with this encoding method.
14702
14703 @item UTF-8 Coding
14704 A wide character is represented using
14705 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14706 10646-1/Am.2. Depending on the character value, the representation
14707 is a one, two, or three byte sequence:
14708
14709 @smallexample
14710 16#0000#-16#007f#: 2#0xxxxxxx#
14711 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
14712 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14713 @end smallexample
14714
14715 @noindent
14716 where the @var{xxx} bits correspond to the left-padded bits of the
14717 16-bit character value. Note that all lower half ASCII characters
14718 are represented as ASCII bytes and all upper half characters and
14719 other wide characters are represented as sequences of upper-half
14720 (The full UTF-8 scheme allows for encoding 31-bit characters as
14721 6-byte sequences, but in this implementation, all UTF-8 sequences
14722 of four or more bytes length will raise a Constraint_Error, as
14723 will all invalid UTF-8 sequences.)
14724
14725 @item Brackets Coding
14726 In this encoding, a wide character is represented by the following eight
14727 character sequence:
14728
14729 @smallexample
14730 [ " a b c d " ]
14731 @end smallexample
14732
14733 @noindent
14734 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
14735 characters (using uppercase letters) of the wide character code. For
14736 example, @code{["A345"]} is used to represent the wide character with code
14737 @code{16#A345#}.
14738 This scheme is compatible with use of the full Wide_Character set.
14739 On input, brackets coding can also be used for upper half characters,
14740 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14741 is only used for wide characters with a code greater than @code{16#FF#}.
14742
14743 Note that brackets coding is not normally used in the context of
14744 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
14745 a portable way of encoding source files. In the context of Wide_Text_IO
14746 or Wide_Wide_Text_IO, it can only be used if the file does not contain
14747 any instance of the left bracket character other than to encode wide
14748 character values using the brackets encoding method. In practice it is
14749 expected that some standard wide character encoding method such
14750 as UTF-8 will be used for text input output.
14751
14752 If brackets notation is used, then any occurrence of a left bracket
14753 in the input file which is not the start of a valid wide character
14754 sequence will cause Constraint_Error to be raised. It is possible to
14755 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
14756 input will interpret this as a left bracket.
14757
14758 However, when a left bracket is output, it will be output as a left bracket
14759 and not as ["5B"]. We make this decision because for normal use of
14760 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
14761 brackets. For example, if we write:
14762
14763 @smallexample
14764 Put_Line ("Start of output [first run]");
14765 @end smallexample
14766
14767 @noindent
14768 we really do not want to have the left bracket in this message clobbered so
14769 that the output reads:
14770
14771 @smallexample
14772 Start of output ["5B"]first run]
14773 @end smallexample
14774
14775 @noindent
14776 In practice brackets encoding is reasonably useful for normal Put_Line use
14777 since we won't get confused between left brackets and wide character
14778 sequences in the output. But for input, or when files are written out
14779 and read back in, it really makes better sense to use one of the standard
14780 encoding methods such as UTF-8.
14781
14782 @end table
14783
14784 @noindent
14785 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
14786 not all wide character
14787 values can be represented. An attempt to output a character that cannot
14788 be represented using the encoding scheme for the file causes
14789 Constraint_Error to be raised. An invalid wide character sequence on
14790 input also causes Constraint_Error to be raised.
14791
14792 @menu
14793 * Wide_Text_IO Stream Pointer Positioning::
14794 * Wide_Text_IO Reading and Writing Non-Regular Files::
14795 @end menu
14796
14797 @node Wide_Text_IO Stream Pointer Positioning
14798 @subsection Stream Pointer Positioning
14799
14800 @noindent
14801 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14802 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14803 case:
14804
14805 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
14806 normal lower ASCII set (i.e.@: a character in the range:
14807
14808 @smallexample @c ada
14809 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
14810 @end smallexample
14811
14812 @noindent
14813 then although the logical position of the file pointer is unchanged by
14814 the @code{Look_Ahead} call, the stream is physically positioned past the
14815 wide character sequence. Again this is to avoid the need for buffering
14816 or backup, and all @code{Wide_Text_IO} routines check the internal
14817 indication that this situation has occurred so that this is not visible
14818 to a normal program using @code{Wide_Text_IO}. However, this discrepancy
14819 can be observed if the wide text file shares a stream with another file.
14820
14821 @node Wide_Text_IO Reading and Writing Non-Regular Files
14822 @subsection Reading and Writing Non-Regular Files
14823
14824 @noindent
14825 As in the case of Text_IO, when a non-regular file is read, it is
14826 assumed that the file contains no page marks (any form characters are
14827 treated as data characters), and @code{End_Of_Page} always returns
14828 @code{False}. Similarly, the end of file indication is not sticky, so
14829 it is possible to read beyond an end of file.
14830
14831 @node Wide_Wide_Text_IO
14832 @section Wide_Wide_Text_IO
14833
14834 @noindent
14835 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
14836 both input and output files may contain special sequences that represent
14837 wide wide character values. The encoding scheme for a given file may be
14838 specified using a FORM parameter:
14839
14840 @smallexample
14841 WCEM=@var{x}
14842 @end smallexample
14843
14844 @noindent
14845 as part of the FORM string (WCEM = wide character encoding method),
14846 where @var{x} is one of the following characters
14847
14848 @table @samp
14849 @item h
14850 Hex ESC encoding
14851 @item u
14852 Upper half encoding
14853 @item s
14854 Shift-JIS encoding
14855 @item e
14856 EUC Encoding
14857 @item 8
14858 UTF-8 encoding
14859 @item b
14860 Brackets encoding
14861 @end table
14862
14863 @noindent
14864 The encoding methods match those that
14865 can be used in a source
14866 program, but there is no requirement that the encoding method used for
14867 the source program be the same as the encoding method used for files,
14868 and different files may use different encoding methods.
14869
14870 The default encoding method for the standard files, and for opened files
14871 for which no WCEM parameter is given in the FORM string matches the
14872 wide character encoding specified for the main program (the default
14873 being brackets encoding if no coding method was specified with -gnatW).
14874
14875 @table @asis
14876
14877 @item UTF-8 Coding
14878 A wide character is represented using
14879 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
14880 10646-1/Am.2. Depending on the character value, the representation
14881 is a one, two, three, or four byte sequence:
14882
14883 @smallexample
14884 16#000000#-16#00007f#: 2#0xxxxxxx#
14885 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
14886 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
14887 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
14888 @end smallexample
14889
14890 @noindent
14891 where the @var{xxx} bits correspond to the left-padded bits of the
14892 21-bit character value. Note that all lower half ASCII characters
14893 are represented as ASCII bytes and all upper half characters and
14894 other wide characters are represented as sequences of upper-half
14895 characters.
14896
14897 @item Brackets Coding
14898 In this encoding, a wide wide character is represented by the following eight
14899 character sequence if is in wide character range
14900
14901 @smallexample
14902 [ " a b c d " ]
14903 @end smallexample
14904
14905 and by the following ten character sequence if not
14906
14907 @smallexample
14908 [ " a b c d e f " ]
14909 @end smallexample
14910
14911 @noindent
14912 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
14913 are the four or six hexadecimal
14914 characters (using uppercase letters) of the wide wide character code. For
14915 example, @code{["01A345"]} is used to represent the wide wide character
14916 with code @code{16#01A345#}.
14917
14918 This scheme is compatible with use of the full Wide_Wide_Character set.
14919 On input, brackets coding can also be used for upper half characters,
14920 e.g.@: @code{["C1"]} for lower case a. However, on output, brackets notation
14921 is only used for wide characters with a code greater than @code{16#FF#}.
14922
14923 @end table
14924
14925 @noindent
14926 If is also possible to use the other Wide_Character encoding methods,
14927 such as Shift-JIS, but the other schemes cannot support the full range
14928 of wide wide characters.
14929 An attempt to output a character that cannot
14930 be represented using the encoding scheme for the file causes
14931 Constraint_Error to be raised. An invalid wide character sequence on
14932 input also causes Constraint_Error to be raised.
14933
14934 @menu
14935 * Wide_Wide_Text_IO Stream Pointer Positioning::
14936 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
14937 @end menu
14938
14939 @node Wide_Wide_Text_IO Stream Pointer Positioning
14940 @subsection Stream Pointer Positioning
14941
14942 @noindent
14943 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
14944 of stream pointer positioning (@pxref{Text_IO}). There is one additional
14945 case:
14946
14947 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
14948 normal lower ASCII set (i.e.@: a character in the range:
14949
14950 @smallexample @c ada
14951 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
14952 @end smallexample
14953
14954 @noindent
14955 then although the logical position of the file pointer is unchanged by
14956 the @code{Look_Ahead} call, the stream is physically positioned past the
14957 wide character sequence. Again this is to avoid the need for buffering
14958 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
14959 indication that this situation has occurred so that this is not visible
14960 to a normal program using @code{Wide_Wide_Text_IO}. However, this discrepancy
14961 can be observed if the wide text file shares a stream with another file.
14962
14963 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
14964 @subsection Reading and Writing Non-Regular Files
14965
14966 @noindent
14967 As in the case of Text_IO, when a non-regular file is read, it is
14968 assumed that the file contains no page marks (any form characters are
14969 treated as data characters), and @code{End_Of_Page} always returns
14970 @code{False}. Similarly, the end of file indication is not sticky, so
14971 it is possible to read beyond an end of file.
14972
14973 @node Stream_IO
14974 @section Stream_IO
14975
14976 @noindent
14977 A stream file is a sequence of bytes, where individual elements are
14978 written to the file as described in the Ada Reference Manual. The type
14979 @code{Stream_Element} is simply a byte. There are two ways to read or
14980 write a stream file.
14981
14982 @itemize @bullet
14983 @item
14984 The operations @code{Read} and @code{Write} directly read or write a
14985 sequence of stream elements with no control information.
14986
14987 @item
14988 The stream attributes applied to a stream file transfer data in the
14989 manner described for stream attributes.
14990 @end itemize
14991
14992 @node Text Translation
14993 @section Text Translation
14994
14995 @noindent
14996 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
14997 passed to Text_IO.Create and Text_IO.Open:
14998 @samp{Text_Translation=@var{Yes}} is the default, which means to
14999 translate LF to/from CR/LF on Windows systems.
15000 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
15001 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
15002 may be used to create Unix-style files on
15003 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
15004 systems.
15005
15006 @node Shared Files
15007 @section Shared Files
15008
15009 @noindent
15010 Section A.14 of the Ada Reference Manual allows implementations to
15011 provide a wide variety of behavior if an attempt is made to access the
15012 same external file with two or more internal files.
15013
15014 To provide a full range of functionality, while at the same time
15015 minimizing the problems of portability caused by this implementation
15016 dependence, GNAT handles file sharing as follows:
15017
15018 @itemize @bullet
15019 @item
15020 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
15021 to open two or more files with the same full name is considered an error
15022 and is not supported. The exception @code{Use_Error} will be
15023 raised. Note that a file that is not explicitly closed by the program
15024 remains open until the program terminates.
15025
15026 @item
15027 If the form parameter @samp{shared=no} appears in the form string, the
15028 file can be opened or created with its own separate stream identifier,
15029 regardless of whether other files sharing the same external file are
15030 opened. The exact effect depends on how the C stream routines handle
15031 multiple accesses to the same external files using separate streams.
15032
15033 @item
15034 If the form parameter @samp{shared=yes} appears in the form string for
15035 each of two or more files opened using the same full name, the same
15036 stream is shared between these files, and the semantics are as described
15037 in Ada Reference Manual, Section A.14.
15038 @end itemize
15039
15040 @noindent
15041 When a program that opens multiple files with the same name is ported
15042 from another Ada compiler to GNAT, the effect will be that
15043 @code{Use_Error} is raised.
15044
15045 The documentation of the original compiler and the documentation of the
15046 program should then be examined to determine if file sharing was
15047 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
15048 and @code{Create} calls as required.
15049
15050 When a program is ported from GNAT to some other Ada compiler, no
15051 special attention is required unless the @samp{shared=@var{xxx}} form
15052 parameter is used in the program. In this case, you must examine the
15053 documentation of the new compiler to see if it supports the required
15054 file sharing semantics, and form strings modified appropriately. Of
15055 course it may be the case that the program cannot be ported if the
15056 target compiler does not support the required functionality. The best
15057 approach in writing portable code is to avoid file sharing (and hence
15058 the use of the @samp{shared=@var{xxx}} parameter in the form string)
15059 completely.
15060
15061 One common use of file sharing in Ada 83 is the use of instantiations of
15062 Sequential_IO on the same file with different types, to achieve
15063 heterogeneous input-output. Although this approach will work in GNAT if
15064 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
15065 for this purpose (using the stream attributes)
15066
15067 @node Filenames encoding
15068 @section Filenames encoding
15069
15070 @noindent
15071 An encoding form parameter can be used to specify the filename
15072 encoding @samp{encoding=@var{xxx}}.
15073
15074 @itemize @bullet
15075 @item
15076 If the form parameter @samp{encoding=utf8} appears in the form string, the
15077 filename must be encoded in UTF-8.
15078
15079 @item
15080 If the form parameter @samp{encoding=8bits} appears in the form
15081 string, the filename must be a standard 8bits string.
15082 @end itemize
15083
15084 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
15085 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
15086 variable. And if not set @samp{utf8} is assumed.
15087
15088 @table @samp
15089 @item CP_ACP
15090 The current system Windows ANSI code page.
15091 @item CP_UTF8
15092 UTF-8 encoding
15093 @end table
15094
15095 This encoding form parameter is only supported on the Windows
15096 platform. On the other Operating Systems the run-time is supporting
15097 UTF-8 natively.
15098
15099 @node Open Modes
15100 @section Open Modes
15101
15102 @noindent
15103 @code{Open} and @code{Create} calls result in a call to @code{fopen}
15104 using the mode shown in the following table:
15105
15106 @sp 2
15107 @center @code{Open} and @code{Create} Call Modes
15108 @smallexample
15109 @b{OPEN } @b{CREATE}
15110 Append_File "r+" "w+"
15111 In_File "r" "w+"
15112 Out_File (Direct_IO) "r+" "w"
15113 Out_File (all other cases) "w" "w"
15114 Inout_File "r+" "w+"
15115 @end smallexample
15116
15117 @noindent
15118 If text file translation is required, then either @samp{b} or @samp{t}
15119 is added to the mode, depending on the setting of Text. Text file
15120 translation refers to the mapping of CR/LF sequences in an external file
15121 to LF characters internally. This mapping only occurs in DOS and
15122 DOS-like systems, and is not relevant to other systems.
15123
15124 A special case occurs with Stream_IO@. As shown in the above table, the
15125 file is initially opened in @samp{r} or @samp{w} mode for the
15126 @code{In_File} and @code{Out_File} cases. If a @code{Set_Mode} operation
15127 subsequently requires switching from reading to writing or vice-versa,
15128 then the file is reopened in @samp{r+} mode to permit the required operation.
15129
15130 @node Operations on C Streams
15131 @section Operations on C Streams
15132 The package @code{Interfaces.C_Streams} provides an Ada program with direct
15133 access to the C library functions for operations on C streams:
15134
15135 @smallexample @c adanocomment
15136 package Interfaces.C_Streams is
15137 -- Note: the reason we do not use the types that are in
15138 -- Interfaces.C is that we want to avoid dragging in the
15139 -- code in this unit if possible.
15140 subtype chars is System.Address;
15141 -- Pointer to null-terminated array of characters
15142 subtype FILEs is System.Address;
15143 -- Corresponds to the C type FILE*
15144 subtype voids is System.Address;
15145 -- Corresponds to the C type void*
15146 subtype int is Integer;
15147 subtype long is Long_Integer;
15148 -- Note: the above types are subtypes deliberately, and it
15149 -- is part of this spec that the above correspondences are
15150 -- guaranteed. This means that it is legitimate to, for
15151 -- example, use Integer instead of int. We provide these
15152 -- synonyms for clarity, but in some cases it may be
15153 -- convenient to use the underlying types (for example to
15154 -- avoid an unnecessary dependency of a spec on the spec
15155 -- of this unit).
15156 type size_t is mod 2 ** Standard'Address_Size;
15157 NULL_Stream : constant FILEs;
15158 -- Value returned (NULL in C) to indicate an
15159 -- fdopen/fopen/tmpfile error
15160 ----------------------------------
15161 -- Constants Defined in stdio.h --
15162 ----------------------------------
15163 EOF : constant int;
15164 -- Used by a number of routines to indicate error or
15165 -- end of file
15166 IOFBF : constant int;
15167 IOLBF : constant int;
15168 IONBF : constant int;
15169 -- Used to indicate buffering mode for setvbuf call
15170 SEEK_CUR : constant int;
15171 SEEK_END : constant int;
15172 SEEK_SET : constant int;
15173 -- Used to indicate origin for fseek call
15174 function stdin return FILEs;
15175 function stdout return FILEs;
15176 function stderr return FILEs;
15177 -- Streams associated with standard files
15178 --------------------------
15179 -- Standard C functions --
15180 --------------------------
15181 -- The functions selected below are ones that are
15182 -- available in UNIX (but not necessarily in ANSI C).
15183 -- These are very thin interfaces
15184 -- which copy exactly the C headers. For more
15185 -- documentation on these functions, see the Microsoft C
15186 -- "Run-Time Library Reference" (Microsoft Press, 1990,
15187 -- ISBN 1-55615-225-6), which includes useful information
15188 -- on system compatibility.
15189 procedure clearerr (stream : FILEs);
15190 function fclose (stream : FILEs) return int;
15191 function fdopen (handle : int; mode : chars) return FILEs;
15192 function feof (stream : FILEs) return int;
15193 function ferror (stream : FILEs) return int;
15194 function fflush (stream : FILEs) return int;
15195 function fgetc (stream : FILEs) return int;
15196 function fgets (strng : chars; n : int; stream : FILEs)
15197 return chars;
15198 function fileno (stream : FILEs) return int;
15199 function fopen (filename : chars; Mode : chars)
15200 return FILEs;
15201 -- Note: to maintain target independence, use
15202 -- text_translation_required, a boolean variable defined in
15203 -- a-sysdep.c to deal with the target dependent text
15204 -- translation requirement. If this variable is set,
15205 -- then b/t should be appended to the standard mode
15206 -- argument to set the text translation mode off or on
15207 -- as required.
15208 function fputc (C : int; stream : FILEs) return int;
15209 function fputs (Strng : chars; Stream : FILEs) return int;
15210 function fread
15211 (buffer : voids;
15212 size : size_t;
15213 count : size_t;
15214 stream : FILEs)
15215 return size_t;
15216 function freopen
15217 (filename : chars;
15218 mode : chars;
15219 stream : FILEs)
15220 return FILEs;
15221 function fseek
15222 (stream : FILEs;
15223 offset : long;
15224 origin : int)
15225 return int;
15226 function ftell (stream : FILEs) return long;
15227 function fwrite
15228 (buffer : voids;
15229 size : size_t;
15230 count : size_t;
15231 stream : FILEs)
15232 return size_t;
15233 function isatty (handle : int) return int;
15234 procedure mktemp (template : chars);
15235 -- The return value (which is just a pointer to template)
15236 -- is discarded
15237 procedure rewind (stream : FILEs);
15238 function rmtmp return int;
15239 function setvbuf
15240 (stream : FILEs;
15241 buffer : chars;
15242 mode : int;
15243 size : size_t)
15244 return int;
15245
15246 function tmpfile return FILEs;
15247 function ungetc (c : int; stream : FILEs) return int;
15248 function unlink (filename : chars) return int;
15249 ---------------------
15250 -- Extra functions --
15251 ---------------------
15252 -- These functions supply slightly thicker bindings than
15253 -- those above. They are derived from functions in the
15254 -- C Run-Time Library, but may do a bit more work than
15255 -- just directly calling one of the Library functions.
15256 function is_regular_file (handle : int) return int;
15257 -- Tests if given handle is for a regular file (result 1)
15258 -- or for a non-regular file (pipe or device, result 0).
15259 ---------------------------------
15260 -- Control of Text/Binary Mode --
15261 ---------------------------------
15262 -- If text_translation_required is true, then the following
15263 -- functions may be used to dynamically switch a file from
15264 -- binary to text mode or vice versa. These functions have
15265 -- no effect if text_translation_required is false (i.e.@: in
15266 -- normal UNIX mode). Use fileno to get a stream handle.
15267 procedure set_binary_mode (handle : int);
15268 procedure set_text_mode (handle : int);
15269 ----------------------------
15270 -- Full Path Name support --
15271 ----------------------------
15272 procedure full_name (nam : chars; buffer : chars);
15273 -- Given a NUL terminated string representing a file
15274 -- name, returns in buffer a NUL terminated string
15275 -- representing the full path name for the file name.
15276 -- On systems where it is relevant the drive is also
15277 -- part of the full path name. It is the responsibility
15278 -- of the caller to pass an actual parameter for buffer
15279 -- that is big enough for any full path name. Use
15280 -- max_path_len given below as the size of buffer.
15281 max_path_len : integer;
15282 -- Maximum length of an allowable full path name on the
15283 -- system, including a terminating NUL character.
15284 end Interfaces.C_Streams;
15285 @end smallexample
15286
15287 @node Interfacing to C Streams
15288 @section Interfacing to C Streams
15289
15290 @noindent
15291 The packages in this section permit interfacing Ada files to C Stream
15292 operations.
15293
15294 @smallexample @c ada
15295 with Interfaces.C_Streams;
15296 package Ada.Sequential_IO.C_Streams is
15297 function C_Stream (F : File_Type)
15298 return Interfaces.C_Streams.FILEs;
15299 procedure Open
15300 (File : in out File_Type;
15301 Mode : in File_Mode;
15302 C_Stream : in Interfaces.C_Streams.FILEs;
15303 Form : in String := "");
15304 end Ada.Sequential_IO.C_Streams;
15305
15306 with Interfaces.C_Streams;
15307 package Ada.Direct_IO.C_Streams is
15308 function C_Stream (F : File_Type)
15309 return Interfaces.C_Streams.FILEs;
15310 procedure Open
15311 (File : in out File_Type;
15312 Mode : in File_Mode;
15313 C_Stream : in Interfaces.C_Streams.FILEs;
15314 Form : in String := "");
15315 end Ada.Direct_IO.C_Streams;
15316
15317 with Interfaces.C_Streams;
15318 package Ada.Text_IO.C_Streams is
15319 function C_Stream (F : File_Type)
15320 return Interfaces.C_Streams.FILEs;
15321 procedure Open
15322 (File : in out File_Type;
15323 Mode : in File_Mode;
15324 C_Stream : in Interfaces.C_Streams.FILEs;
15325 Form : in String := "");
15326 end Ada.Text_IO.C_Streams;
15327
15328 with Interfaces.C_Streams;
15329 package Ada.Wide_Text_IO.C_Streams is
15330 function C_Stream (F : File_Type)
15331 return Interfaces.C_Streams.FILEs;
15332 procedure Open
15333 (File : in out File_Type;
15334 Mode : in File_Mode;
15335 C_Stream : in Interfaces.C_Streams.FILEs;
15336 Form : in String := "");
15337 end Ada.Wide_Text_IO.C_Streams;
15338
15339 with Interfaces.C_Streams;
15340 package Ada.Wide_Wide_Text_IO.C_Streams is
15341 function C_Stream (F : File_Type)
15342 return Interfaces.C_Streams.FILEs;
15343 procedure Open
15344 (File : in out File_Type;
15345 Mode : in File_Mode;
15346 C_Stream : in Interfaces.C_Streams.FILEs;
15347 Form : in String := "");
15348 end Ada.Wide_Wide_Text_IO.C_Streams;
15349
15350 with Interfaces.C_Streams;
15351 package Ada.Stream_IO.C_Streams is
15352 function C_Stream (F : File_Type)
15353 return Interfaces.C_Streams.FILEs;
15354 procedure Open
15355 (File : in out File_Type;
15356 Mode : in File_Mode;
15357 C_Stream : in Interfaces.C_Streams.FILEs;
15358 Form : in String := "");
15359 end Ada.Stream_IO.C_Streams;
15360 @end smallexample
15361
15362 @noindent
15363 In each of these six packages, the @code{C_Stream} function obtains the
15364 @code{FILE} pointer from a currently opened Ada file. It is then
15365 possible to use the @code{Interfaces.C_Streams} package to operate on
15366 this stream, or the stream can be passed to a C program which can
15367 operate on it directly. Of course the program is responsible for
15368 ensuring that only appropriate sequences of operations are executed.
15369
15370 One particular use of relevance to an Ada program is that the
15371 @code{setvbuf} function can be used to control the buffering of the
15372 stream used by an Ada file. In the absence of such a call the standard
15373 default buffering is used.
15374
15375 The @code{Open} procedures in these packages open a file giving an
15376 existing C Stream instead of a file name. Typically this stream is
15377 imported from a C program, allowing an Ada file to operate on an
15378 existing C file.
15379
15380 @node The GNAT Library
15381 @chapter The GNAT Library
15382
15383 @noindent
15384 The GNAT library contains a number of general and special purpose packages.
15385 It represents functionality that the GNAT developers have found useful, and
15386 which is made available to GNAT users. The packages described here are fully
15387 supported, and upwards compatibility will be maintained in future releases,
15388 so you can use these facilities with the confidence that the same functionality
15389 will be available in future releases.
15390
15391 The chapter here simply gives a brief summary of the facilities available.
15392 The full documentation is found in the spec file for the package. The full
15393 sources of these library packages, including both spec and body, are provided
15394 with all GNAT releases. For example, to find out the full specifications of
15395 the SPITBOL pattern matching capability, including a full tutorial and
15396 extensive examples, look in the @file{g-spipat.ads} file in the library.
15397
15398 For each entry here, the package name (as it would appear in a @code{with}
15399 clause) is given, followed by the name of the corresponding spec file in
15400 parentheses. The packages are children in four hierarchies, @code{Ada},
15401 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
15402 GNAT-specific hierarchy.
15403
15404 Note that an application program should only use packages in one of these
15405 four hierarchies if the package is defined in the Ada Reference Manual,
15406 or is listed in this section of the GNAT Programmers Reference Manual.
15407 All other units should be considered internal implementation units and
15408 should not be directly @code{with}'ed by application code. The use of
15409 a @code{with} statement that references one of these internal implementation
15410 units makes an application potentially dependent on changes in versions
15411 of GNAT, and will generate a warning message.
15412
15413 @menu
15414 * Ada.Characters.Latin_9 (a-chlat9.ads)::
15415 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
15416 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
15417 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
15418 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
15419 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
15420 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
15421 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
15422 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
15423 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
15424 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
15425 * Ada.Command_Line.Environment (a-colien.ads)::
15426 * Ada.Command_Line.Remove (a-colire.ads)::
15427 * Ada.Command_Line.Response_File (a-clrefi.ads)::
15428 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
15429 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
15430 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
15431 * Ada.Exceptions.Traceback (a-exctra.ads)::
15432 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
15433 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
15434 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
15435 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
15436 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
15437 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
15438 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
15439 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
15440 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
15441 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
15442 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
15443 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
15444 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
15445 * GNAT.Altivec (g-altive.ads)::
15446 * GNAT.Altivec.Conversions (g-altcon.ads)::
15447 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
15448 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
15449 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
15450 * GNAT.Array_Split (g-arrspl.ads)::
15451 * GNAT.AWK (g-awk.ads)::
15452 * GNAT.Bounded_Buffers (g-boubuf.ads)::
15453 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
15454 * GNAT.Bubble_Sort (g-bubsor.ads)::
15455 * GNAT.Bubble_Sort_A (g-busora.ads)::
15456 * GNAT.Bubble_Sort_G (g-busorg.ads)::
15457 * GNAT.Byte_Order_Mark (g-byorma.ads)::
15458 * GNAT.Byte_Swapping (g-bytswa.ads)::
15459 * GNAT.Calendar (g-calend.ads)::
15460 * GNAT.Calendar.Time_IO (g-catiio.ads)::
15461 * GNAT.Case_Util (g-casuti.ads)::
15462 * GNAT.CGI (g-cgi.ads)::
15463 * GNAT.CGI.Cookie (g-cgicoo.ads)::
15464 * GNAT.CGI.Debug (g-cgideb.ads)::
15465 * GNAT.Command_Line (g-comlin.ads)::
15466 * GNAT.Compiler_Version (g-comver.ads)::
15467 * GNAT.Ctrl_C (g-ctrl_c.ads)::
15468 * GNAT.CRC32 (g-crc32.ads)::
15469 * GNAT.Current_Exception (g-curexc.ads)::
15470 * GNAT.Debug_Pools (g-debpoo.ads)::
15471 * GNAT.Debug_Utilities (g-debuti.ads)::
15472 * GNAT.Decode_String (g-decstr.ads)::
15473 * GNAT.Decode_UTF8_String (g-deutst.ads)::
15474 * GNAT.Directory_Operations (g-dirope.ads)::
15475 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
15476 * GNAT.Dynamic_HTables (g-dynhta.ads)::
15477 * GNAT.Dynamic_Tables (g-dyntab.ads)::
15478 * GNAT.Encode_String (g-encstr.ads)::
15479 * GNAT.Encode_UTF8_String (g-enutst.ads)::
15480 * GNAT.Exception_Actions (g-excact.ads)::
15481 * GNAT.Exception_Traces (g-exctra.ads)::
15482 * GNAT.Exceptions (g-except.ads)::
15483 * GNAT.Expect (g-expect.ads)::
15484 * GNAT.Expect.TTY (g-exptty.ads)::
15485 * GNAT.Float_Control (g-flocon.ads)::
15486 * GNAT.Heap_Sort (g-heasor.ads)::
15487 * GNAT.Heap_Sort_A (g-hesora.ads)::
15488 * GNAT.Heap_Sort_G (g-hesorg.ads)::
15489 * GNAT.HTable (g-htable.ads)::
15490 * GNAT.IO (g-io.ads)::
15491 * GNAT.IO_Aux (g-io_aux.ads)::
15492 * GNAT.Lock_Files (g-locfil.ads)::
15493 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
15494 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
15495 * GNAT.MD5 (g-md5.ads)::
15496 * GNAT.Memory_Dump (g-memdum.ads)::
15497 * GNAT.Most_Recent_Exception (g-moreex.ads)::
15498 * GNAT.OS_Lib (g-os_lib.ads)::
15499 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
15500 * GNAT.Random_Numbers (g-rannum.ads)::
15501 * GNAT.Regexp (g-regexp.ads)::
15502 * GNAT.Registry (g-regist.ads)::
15503 * GNAT.Regpat (g-regpat.ads)::
15504 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
15505 * GNAT.Semaphores (g-semaph.ads)::
15506 * GNAT.Serial_Communications (g-sercom.ads)::
15507 * GNAT.SHA1 (g-sha1.ads)::
15508 * GNAT.SHA224 (g-sha224.ads)::
15509 * GNAT.SHA256 (g-sha256.ads)::
15510 * GNAT.SHA384 (g-sha384.ads)::
15511 * GNAT.SHA512 (g-sha512.ads)::
15512 * GNAT.Signals (g-signal.ads)::
15513 * GNAT.Sockets (g-socket.ads)::
15514 * GNAT.Source_Info (g-souinf.ads)::
15515 * GNAT.Spelling_Checker (g-speche.ads)::
15516 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
15517 * GNAT.Spitbol.Patterns (g-spipat.ads)::
15518 * GNAT.Spitbol (g-spitbo.ads)::
15519 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
15520 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
15521 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
15522 * GNAT.SSE (g-sse.ads)::
15523 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
15524 * GNAT.Strings (g-string.ads)::
15525 * GNAT.String_Split (g-strspl.ads)::
15526 * GNAT.Table (g-table.ads)::
15527 * GNAT.Task_Lock (g-tasloc.ads)::
15528 * GNAT.Threads (g-thread.ads)::
15529 * GNAT.Time_Stamp (g-timsta.ads)::
15530 * GNAT.Traceback (g-traceb.ads)::
15531 * GNAT.Traceback.Symbolic (g-trasym.ads)::
15532 * GNAT.UTF_32 (g-utf_32.ads)::
15533 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
15534 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
15535 * GNAT.Wide_String_Split (g-wistsp.ads)::
15536 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
15537 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
15538 * Interfaces.C.Extensions (i-cexten.ads)::
15539 * Interfaces.C.Streams (i-cstrea.ads)::
15540 * Interfaces.CPP (i-cpp.ads)::
15541 * Interfaces.Packed_Decimal (i-pacdec.ads)::
15542 * Interfaces.VxWorks (i-vxwork.ads)::
15543 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
15544 * System.Address_Image (s-addima.ads)::
15545 * System.Assertions (s-assert.ads)::
15546 * System.Memory (s-memory.ads)::
15547 * System.Multiprocessors (s-multip.ads)::
15548 * System.Multiprocessors.Dispatching_Domains (s-mudido.ads)::
15549 * System.Partition_Interface (s-parint.ads)::
15550 * System.Pool_Global (s-pooglo.ads)::
15551 * System.Pool_Local (s-pooloc.ads)::
15552 * System.Restrictions (s-restri.ads)::
15553 * System.Rident (s-rident.ads)::
15554 * System.Strings.Stream_Ops (s-ststop.ads)::
15555 * System.Task_Info (s-tasinf.ads)::
15556 * System.Wch_Cnv (s-wchcnv.ads)::
15557 * System.Wch_Con (s-wchcon.ads)::
15558 @end menu
15559
15560 @node Ada.Characters.Latin_9 (a-chlat9.ads)
15561 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15562 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
15563 @cindex Latin_9 constants for Character
15564
15565 @noindent
15566 This child of @code{Ada.Characters}
15567 provides a set of definitions corresponding to those in the
15568 RM-defined package @code{Ada.Characters.Latin_1} but with the
15569 few modifications required for @code{Latin-9}
15570 The provision of such a package
15571 is specifically authorized by the Ada Reference Manual
15572 (RM A.3.3(27)).
15573
15574 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
15575 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15576 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
15577 @cindex Latin_1 constants for Wide_Character
15578
15579 @noindent
15580 This child of @code{Ada.Characters}
15581 provides a set of definitions corresponding to those in the
15582 RM-defined package @code{Ada.Characters.Latin_1} but with the
15583 types of the constants being @code{Wide_Character}
15584 instead of @code{Character}. The provision of such a package
15585 is specifically authorized by the Ada Reference Manual
15586 (RM A.3.3(27)).
15587
15588 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
15589 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15590 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
15591 @cindex Latin_9 constants for Wide_Character
15592
15593 @noindent
15594 This child of @code{Ada.Characters}
15595 provides a set of definitions corresponding to those in the
15596 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15597 types of the constants being @code{Wide_Character}
15598 instead of @code{Character}. The provision of such a package
15599 is specifically authorized by the Ada Reference Manual
15600 (RM A.3.3(27)).
15601
15602 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
15603 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15604 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
15605 @cindex Latin_1 constants for Wide_Wide_Character
15606
15607 @noindent
15608 This child of @code{Ada.Characters}
15609 provides a set of definitions corresponding to those in the
15610 RM-defined package @code{Ada.Characters.Latin_1} but with the
15611 types of the constants being @code{Wide_Wide_Character}
15612 instead of @code{Character}. The provision of such a package
15613 is specifically authorized by the Ada Reference Manual
15614 (RM A.3.3(27)).
15615
15616 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
15617 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15618 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
15619 @cindex Latin_9 constants for Wide_Wide_Character
15620
15621 @noindent
15622 This child of @code{Ada.Characters}
15623 provides a set of definitions corresponding to those in the
15624 GNAT defined package @code{Ada.Characters.Latin_9} but with the
15625 types of the constants being @code{Wide_Wide_Character}
15626 instead of @code{Character}. The provision of such a package
15627 is specifically authorized by the Ada Reference Manual
15628 (RM A.3.3(27)).
15629
15630 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
15631 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15632 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
15633 @cindex Formal container for doubly linked lists
15634
15635 @noindent
15636 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15637 container for doubly linked lists, meant to facilitate formal verification of
15638 code using such containers.
15639
15640 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
15641 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15642 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
15643 @cindex Formal container for hashed maps
15644
15645 @noindent
15646 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15647 container for hashed maps, meant to facilitate formal verification of
15648 code using such containers.
15649
15650 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
15651 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15652 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
15653 @cindex Formal container for hashed sets
15654
15655 @noindent
15656 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15657 container for hashed sets, meant to facilitate formal verification of
15658 code using such containers.
15659
15660 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
15661 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15662 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
15663 @cindex Formal container for ordered maps
15664
15665 @noindent
15666 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15667 container for ordered maps, meant to facilitate formal verification of
15668 code using such containers.
15669
15670 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
15671 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15672 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
15673 @cindex Formal container for ordered sets
15674
15675 @noindent
15676 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15677 container for ordered sets, meant to facilitate formal verification of
15678 code using such containers.
15679
15680 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
15681 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15682 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
15683 @cindex Formal container for vectors
15684
15685 @noindent
15686 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
15687 container for vectors, meant to facilitate formal verification of
15688 code using such containers.
15689
15690 @node Ada.Command_Line.Environment (a-colien.ads)
15691 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15692 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
15693 @cindex Environment entries
15694
15695 @noindent
15696 This child of @code{Ada.Command_Line}
15697 provides a mechanism for obtaining environment values on systems
15698 where this concept makes sense.
15699
15700 @node Ada.Command_Line.Remove (a-colire.ads)
15701 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15702 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
15703 @cindex Removing command line arguments
15704 @cindex Command line, argument removal
15705
15706 @noindent
15707 This child of @code{Ada.Command_Line}
15708 provides a mechanism for logically removing
15709 arguments from the argument list. Once removed, an argument is not visible
15710 to further calls on the subprograms in @code{Ada.Command_Line} will not
15711 see the removed argument.
15712
15713 @node Ada.Command_Line.Response_File (a-clrefi.ads)
15714 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15715 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
15716 @cindex Response file for command line
15717 @cindex Command line, response file
15718 @cindex Command line, handling long command lines
15719
15720 @noindent
15721 This child of @code{Ada.Command_Line} provides a mechanism facilities for
15722 getting command line arguments from a text file, called a "response file".
15723 Using a response file allow passing a set of arguments to an executable longer
15724 than the maximum allowed by the system on the command line.
15725
15726 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
15727 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15728 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
15729 @cindex C Streams, Interfacing with Direct_IO
15730
15731 @noindent
15732 This package provides subprograms that allow interfacing between
15733 C streams and @code{Direct_IO}. The stream identifier can be
15734 extracted from a file opened on the Ada side, and an Ada file
15735 can be constructed from a stream opened on the C side.
15736
15737 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
15738 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15739 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
15740 @cindex Null_Occurrence, testing for
15741
15742 @noindent
15743 This child subprogram provides a way of testing for the null
15744 exception occurrence (@code{Null_Occurrence}) without raising
15745 an exception.
15746
15747 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
15748 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15749 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
15750 @cindex Null_Occurrence, testing for
15751
15752 @noindent
15753 This child subprogram is used for handling otherwise unhandled
15754 exceptions (hence the name last chance), and perform clean ups before
15755 terminating the program. Note that this subprogram never returns.
15756
15757 @node Ada.Exceptions.Traceback (a-exctra.ads)
15758 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15759 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
15760 @cindex Traceback for Exception Occurrence
15761
15762 @noindent
15763 This child package provides the subprogram (@code{Tracebacks}) to
15764 give a traceback array of addresses based on an exception
15765 occurrence.
15766
15767 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
15768 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15769 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
15770 @cindex C Streams, Interfacing with Sequential_IO
15771
15772 @noindent
15773 This package provides subprograms that allow interfacing between
15774 C streams and @code{Sequential_IO}. The stream identifier can be
15775 extracted from a file opened on the Ada side, and an Ada file
15776 can be constructed from a stream opened on the C side.
15777
15778 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
15779 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15780 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
15781 @cindex C Streams, Interfacing with Stream_IO
15782
15783 @noindent
15784 This package provides subprograms that allow interfacing between
15785 C streams and @code{Stream_IO}. The stream identifier can be
15786 extracted from a file opened on the Ada side, and an Ada file
15787 can be constructed from a stream opened on the C side.
15788
15789 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
15790 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15791 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
15792 @cindex @code{Unbounded_String}, IO support
15793 @cindex @code{Text_IO}, extensions for unbounded strings
15794
15795 @noindent
15796 This package provides subprograms for Text_IO for unbounded
15797 strings, avoiding the necessity for an intermediate operation
15798 with ordinary strings.
15799
15800 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
15801 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15802 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
15803 @cindex @code{Unbounded_Wide_String}, IO support
15804 @cindex @code{Text_IO}, extensions for unbounded wide strings
15805
15806 @noindent
15807 This package provides subprograms for Text_IO for unbounded
15808 wide strings, avoiding the necessity for an intermediate operation
15809 with ordinary wide strings.
15810
15811 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
15812 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15813 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
15814 @cindex @code{Unbounded_Wide_Wide_String}, IO support
15815 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
15816
15817 @noindent
15818 This package provides subprograms for Text_IO for unbounded
15819 wide wide strings, avoiding the necessity for an intermediate operation
15820 with ordinary wide wide strings.
15821
15822 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
15823 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15824 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
15825 @cindex C Streams, Interfacing with @code{Text_IO}
15826
15827 @noindent
15828 This package provides subprograms that allow interfacing between
15829 C streams and @code{Text_IO}. The stream identifier can be
15830 extracted from a file opened on the Ada side, and an Ada file
15831 can be constructed from a stream opened on the C side.
15832
15833 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
15834 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15835 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
15836 @cindex @code{Text_IO} resetting standard files
15837
15838 @noindent
15839 This procedure is used to reset the status of the standard files used
15840 by Ada.Text_IO. This is useful in a situation (such as a restart in an
15841 embedded application) where the status of the files may change during
15842 execution (for example a standard input file may be redefined to be
15843 interactive).
15844
15845 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
15846 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15847 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
15848 @cindex Unicode categorization, Wide_Character
15849
15850 @noindent
15851 This package provides subprograms that allow categorization of
15852 Wide_Character values according to Unicode categories.
15853
15854 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
15855 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15856 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
15857 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
15858
15859 @noindent
15860 This package provides subprograms that allow interfacing between
15861 C streams and @code{Wide_Text_IO}. The stream identifier can be
15862 extracted from a file opened on the Ada side, and an Ada file
15863 can be constructed from a stream opened on the C side.
15864
15865 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
15866 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15867 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
15868 @cindex @code{Wide_Text_IO} resetting standard files
15869
15870 @noindent
15871 This procedure is used to reset the status of the standard files used
15872 by Ada.Wide_Text_IO. This is useful in a situation (such as a restart in an
15873 embedded application) where the status of the files may change during
15874 execution (for example a standard input file may be redefined to be
15875 interactive).
15876
15877 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
15878 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15879 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
15880 @cindex Unicode categorization, Wide_Wide_Character
15881
15882 @noindent
15883 This package provides subprograms that allow categorization of
15884 Wide_Wide_Character values according to Unicode categories.
15885
15886 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
15887 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15888 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
15889 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
15890
15891 @noindent
15892 This package provides subprograms that allow interfacing between
15893 C streams and @code{Wide_Wide_Text_IO}. The stream identifier can be
15894 extracted from a file opened on the Ada side, and an Ada file
15895 can be constructed from a stream opened on the C side.
15896
15897 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
15898 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15899 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
15900 @cindex @code{Wide_Wide_Text_IO} resetting standard files
15901
15902 @noindent
15903 This procedure is used to reset the status of the standard files used
15904 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
15905 restart in an embedded application) where the status of the files may
15906 change during execution (for example a standard input file may be
15907 redefined to be interactive).
15908
15909 @node GNAT.Altivec (g-altive.ads)
15910 @section @code{GNAT.Altivec} (@file{g-altive.ads})
15911 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
15912 @cindex AltiVec
15913
15914 @noindent
15915 This is the root package of the GNAT AltiVec binding. It provides
15916 definitions of constants and types common to all the versions of the
15917 binding.
15918
15919 @node GNAT.Altivec.Conversions (g-altcon.ads)
15920 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15921 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
15922 @cindex AltiVec
15923
15924 @noindent
15925 This package provides the Vector/View conversion routines.
15926
15927 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
15928 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15929 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
15930 @cindex AltiVec
15931
15932 @noindent
15933 This package exposes the Ada interface to the AltiVec operations on
15934 vector objects. A soft emulation is included by default in the GNAT
15935 library. The hard binding is provided as a separate package. This unit
15936 is common to both bindings.
15937
15938 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
15939 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15940 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
15941 @cindex AltiVec
15942
15943 @noindent
15944 This package exposes the various vector types part of the Ada binding
15945 to AltiVec facilities.
15946
15947 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
15948 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15949 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
15950 @cindex AltiVec
15951
15952 @noindent
15953 This package provides public 'View' data types from/to which private
15954 vector representations can be converted via
15955 GNAT.Altivec.Conversions. This allows convenient access to individual
15956 vector elements and provides a simple way to initialize vector
15957 objects.
15958
15959 @node GNAT.Array_Split (g-arrspl.ads)
15960 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15961 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
15962 @cindex Array splitter
15963
15964 @noindent
15965 Useful array-manipulation routines: given a set of separators, split
15966 an array wherever the separators appear, and provide direct access
15967 to the resulting slices.
15968
15969 @node GNAT.AWK (g-awk.ads)
15970 @section @code{GNAT.AWK} (@file{g-awk.ads})
15971 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
15972 @cindex Parsing
15973 @cindex AWK
15974
15975 @noindent
15976 Provides AWK-like parsing functions, with an easy interface for parsing one
15977 or more files containing formatted data. The file is viewed as a database
15978 where each record is a line and a field is a data element in this line.
15979
15980 @node GNAT.Bounded_Buffers (g-boubuf.ads)
15981 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15982 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
15983 @cindex Parsing
15984 @cindex Bounded Buffers
15985
15986 @noindent
15987 Provides a concurrent generic bounded buffer abstraction. Instances are
15988 useful directly or as parts of the implementations of other abstractions,
15989 such as mailboxes.
15990
15991 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
15992 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15993 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
15994 @cindex Parsing
15995 @cindex Mailboxes
15996
15997 @noindent
15998 Provides a thread-safe asynchronous intertask mailbox communication facility.
15999
16000 @node GNAT.Bubble_Sort (g-bubsor.ads)
16001 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
16002 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
16003 @cindex Sorting
16004 @cindex Bubble sort
16005
16006 @noindent
16007 Provides a general implementation of bubble sort usable for sorting arbitrary
16008 data items. Exchange and comparison procedures are provided by passing
16009 access-to-procedure values.
16010
16011 @node GNAT.Bubble_Sort_A (g-busora.ads)
16012 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
16013 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
16014 @cindex Sorting
16015 @cindex Bubble sort
16016
16017 @noindent
16018 Provides a general implementation of bubble sort usable for sorting arbitrary
16019 data items. Move and comparison procedures are provided by passing
16020 access-to-procedure values. This is an older version, retained for
16021 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
16022
16023 @node GNAT.Bubble_Sort_G (g-busorg.ads)
16024 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
16025 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
16026 @cindex Sorting
16027 @cindex Bubble sort
16028
16029 @noindent
16030 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
16031 are provided as generic parameters, this improves efficiency, especially
16032 if the procedures can be inlined, at the expense of duplicating code for
16033 multiple instantiations.
16034
16035 @node GNAT.Byte_Order_Mark (g-byorma.ads)
16036 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16037 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
16038 @cindex UTF-8 representation
16039 @cindex Wide characte representations
16040
16041 @noindent
16042 Provides a routine which given a string, reads the start of the string to
16043 see whether it is one of the standard byte order marks (BOM's) which signal
16044 the encoding of the string. The routine includes detection of special XML
16045 sequences for various UCS input formats.
16046
16047 @node GNAT.Byte_Swapping (g-bytswa.ads)
16048 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16049 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
16050 @cindex Byte swapping
16051 @cindex Endianness
16052
16053 @noindent
16054 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
16055 Machine-specific implementations are available in some cases.
16056
16057 @node GNAT.Calendar (g-calend.ads)
16058 @section @code{GNAT.Calendar} (@file{g-calend.ads})
16059 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
16060 @cindex @code{Calendar}
16061
16062 @noindent
16063 Extends the facilities provided by @code{Ada.Calendar} to include handling
16064 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
16065 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
16066 C @code{timeval} format.
16067
16068 @node GNAT.Calendar.Time_IO (g-catiio.ads)
16069 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16070 @cindex @code{Calendar}
16071 @cindex Time
16072 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
16073
16074 @node GNAT.CRC32 (g-crc32.ads)
16075 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
16076 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
16077 @cindex CRC32
16078 @cindex Cyclic Redundancy Check
16079
16080 @noindent
16081 This package implements the CRC-32 algorithm. For a full description
16082 of this algorithm see
16083 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
16084 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
16085 Aug.@: 1988. Sarwate, D.V@.
16086
16087 @node GNAT.Case_Util (g-casuti.ads)
16088 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
16089 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
16090 @cindex Casing utilities
16091 @cindex Character handling (@code{GNAT.Case_Util})
16092
16093 @noindent
16094 A set of simple routines for handling upper and lower casing of strings
16095 without the overhead of the full casing tables
16096 in @code{Ada.Characters.Handling}.
16097
16098 @node GNAT.CGI (g-cgi.ads)
16099 @section @code{GNAT.CGI} (@file{g-cgi.ads})
16100 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
16101 @cindex CGI (Common Gateway Interface)
16102
16103 @noindent
16104 This is a package for interfacing a GNAT program with a Web server via the
16105 Common Gateway Interface (CGI)@. Basically this package parses the CGI
16106 parameters, which are a set of key/value pairs sent by the Web server. It
16107 builds a table whose index is the key and provides some services to deal
16108 with this table.
16109
16110 @node GNAT.CGI.Cookie (g-cgicoo.ads)
16111 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16112 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
16113 @cindex CGI (Common Gateway Interface) cookie support
16114 @cindex Cookie support in CGI
16115
16116 @noindent
16117 This is a package to interface a GNAT program with a Web server via the
16118 Common Gateway Interface (CGI). It exports services to deal with Web
16119 cookies (piece of information kept in the Web client software).
16120
16121 @node GNAT.CGI.Debug (g-cgideb.ads)
16122 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16123 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
16124 @cindex CGI (Common Gateway Interface) debugging
16125
16126 @noindent
16127 This is a package to help debugging CGI (Common Gateway Interface)
16128 programs written in Ada.
16129
16130 @node GNAT.Command_Line (g-comlin.ads)
16131 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
16132 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
16133 @cindex Command line
16134
16135 @noindent
16136 Provides a high level interface to @code{Ada.Command_Line} facilities,
16137 including the ability to scan for named switches with optional parameters
16138 and expand file names using wild card notations.
16139
16140 @node GNAT.Compiler_Version (g-comver.ads)
16141 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16142 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
16143 @cindex Compiler Version
16144 @cindex Version, of compiler
16145
16146 @noindent
16147 Provides a routine for obtaining the version of the compiler used to
16148 compile the program. More accurately this is the version of the binder
16149 used to bind the program (this will normally be the same as the version
16150 of the compiler if a consistent tool set is used to compile all units
16151 of a partition).
16152
16153 @node GNAT.Ctrl_C (g-ctrl_c.ads)
16154 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16155 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
16156 @cindex Interrupt
16157
16158 @noindent
16159 Provides a simple interface to handle Ctrl-C keyboard events.
16160
16161 @node GNAT.Current_Exception (g-curexc.ads)
16162 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16163 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
16164 @cindex Current exception
16165 @cindex Exception retrieval
16166
16167 @noindent
16168 Provides access to information on the current exception that has been raised
16169 without the need for using the Ada 95 / Ada 2005 exception choice parameter
16170 specification syntax.
16171 This is particularly useful in simulating typical facilities for
16172 obtaining information about exceptions provided by Ada 83 compilers.
16173
16174 @node GNAT.Debug_Pools (g-debpoo.ads)
16175 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16176 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
16177 @cindex Debugging
16178 @cindex Debug pools
16179 @cindex Memory corruption debugging
16180
16181 @noindent
16182 Provide a debugging storage pools that helps tracking memory corruption
16183 problems. @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
16184 @value{EDITION} User's Guide}.
16185
16186 @node GNAT.Debug_Utilities (g-debuti.ads)
16187 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16188 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
16189 @cindex Debugging
16190
16191 @noindent
16192 Provides a few useful utilities for debugging purposes, including conversion
16193 to and from string images of address values. Supports both C and Ada formats
16194 for hexadecimal literals.
16195
16196 @node GNAT.Decode_String (g-decstr.ads)
16197 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
16198 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
16199 @cindex Decoding strings
16200 @cindex String decoding
16201 @cindex Wide character encoding
16202 @cindex UTF-8
16203 @cindex Unicode
16204
16205 @noindent
16206 A generic package providing routines for decoding wide character and wide wide
16207 character strings encoded as sequences of 8-bit characters using a specified
16208 encoding method. Includes validation routines, and also routines for stepping
16209 to next or previous encoded character in an encoded string.
16210 Useful in conjunction with Unicode character coding. Note there is a
16211 preinstantiation for UTF-8. See next entry.
16212
16213 @node GNAT.Decode_UTF8_String (g-deutst.ads)
16214 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16215 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
16216 @cindex Decoding strings
16217 @cindex Decoding UTF-8 strings
16218 @cindex UTF-8 string decoding
16219 @cindex Wide character decoding
16220 @cindex UTF-8
16221 @cindex Unicode
16222
16223 @noindent
16224 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
16225
16226 @node GNAT.Directory_Operations (g-dirope.ads)
16227 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16228 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
16229 @cindex Directory operations
16230
16231 @noindent
16232 Provides a set of routines for manipulating directories, including changing
16233 the current directory, making new directories, and scanning the files in a
16234 directory.
16235
16236 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
16237 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16238 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
16239 @cindex Directory operations iteration
16240
16241 @noindent
16242 A child unit of GNAT.Directory_Operations providing additional operations
16243 for iterating through directories.
16244
16245 @node GNAT.Dynamic_HTables (g-dynhta.ads)
16246 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16247 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
16248 @cindex Hash tables
16249
16250 @noindent
16251 A generic implementation of hash tables that can be used to hash arbitrary
16252 data. Provided in two forms, a simple form with built in hash functions,
16253 and a more complex form in which the hash function is supplied.
16254
16255 @noindent
16256 This package provides a facility similar to that of @code{GNAT.HTable},
16257 except that this package declares a type that can be used to define
16258 dynamic instances of the hash table, while an instantiation of
16259 @code{GNAT.HTable} creates a single instance of the hash table.
16260
16261 @node GNAT.Dynamic_Tables (g-dyntab.ads)
16262 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16263 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
16264 @cindex Table implementation
16265 @cindex Arrays, extendable
16266
16267 @noindent
16268 A generic package providing a single dimension array abstraction where the
16269 length of the array can be dynamically modified.
16270
16271 @noindent
16272 This package provides a facility similar to that of @code{GNAT.Table},
16273 except that this package declares a type that can be used to define
16274 dynamic instances of the table, while an instantiation of
16275 @code{GNAT.Table} creates a single instance of the table type.
16276
16277 @node GNAT.Encode_String (g-encstr.ads)
16278 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
16279 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
16280 @cindex Encoding strings
16281 @cindex String encoding
16282 @cindex Wide character encoding
16283 @cindex UTF-8
16284 @cindex Unicode
16285
16286 @noindent
16287 A generic package providing routines for encoding wide character and wide
16288 wide character strings as sequences of 8-bit characters using a specified
16289 encoding method. Useful in conjunction with Unicode character coding.
16290 Note there is a preinstantiation for UTF-8. See next entry.
16291
16292 @node GNAT.Encode_UTF8_String (g-enutst.ads)
16293 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16294 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
16295 @cindex Encoding strings
16296 @cindex Encoding UTF-8 strings
16297 @cindex UTF-8 string encoding
16298 @cindex Wide character encoding
16299 @cindex UTF-8
16300 @cindex Unicode
16301
16302 @noindent
16303 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
16304
16305 @node GNAT.Exception_Actions (g-excact.ads)
16306 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16307 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
16308 @cindex Exception actions
16309
16310 @noindent
16311 Provides callbacks when an exception is raised. Callbacks can be registered
16312 for specific exceptions, or when any exception is raised. This
16313 can be used for instance to force a core dump to ease debugging.
16314
16315 @node GNAT.Exception_Traces (g-exctra.ads)
16316 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16317 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
16318 @cindex Exception traces
16319 @cindex Debugging
16320
16321 @noindent
16322 Provides an interface allowing to control automatic output upon exception
16323 occurrences.
16324
16325 @node GNAT.Exceptions (g-except.ads)
16326 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
16327 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
16328 @cindex Exceptions, Pure
16329 @cindex Pure packages, exceptions
16330
16331 @noindent
16332 Normally it is not possible to raise an exception with
16333 a message from a subprogram in a pure package, since the
16334 necessary types and subprograms are in @code{Ada.Exceptions}
16335 which is not a pure unit. @code{GNAT.Exceptions} provides a
16336 facility for getting around this limitation for a few
16337 predefined exceptions, and for example allow raising
16338 @code{Constraint_Error} with a message from a pure subprogram.
16339
16340 @node GNAT.Expect (g-expect.ads)
16341 @section @code{GNAT.Expect} (@file{g-expect.ads})
16342 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
16343
16344 @noindent
16345 Provides a set of subprograms similar to what is available
16346 with the standard Tcl Expect tool.
16347 It allows you to easily spawn and communicate with an external process.
16348 You can send commands or inputs to the process, and compare the output
16349 with some expected regular expression. Currently @code{GNAT.Expect}
16350 is implemented on all native GNAT ports except for OpenVMS@.
16351 It is not implemented for cross ports, and in particular is not
16352 implemented for VxWorks or LynxOS@.
16353
16354 @node GNAT.Expect.TTY (g-exptty.ads)
16355 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16356 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
16357
16358 @noindent
16359 As GNAT.Expect but using pseudo-terminal.
16360 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
16361 ports except for OpenVMS@. It is not implemented for cross ports, and
16362 in particular is not implemented for VxWorks or LynxOS@.
16363
16364 @node GNAT.Float_Control (g-flocon.ads)
16365 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
16366 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
16367 @cindex Floating-Point Processor
16368
16369 @noindent
16370 Provides an interface for resetting the floating-point processor into the
16371 mode required for correct semantic operation in Ada. Some third party
16372 library calls may cause this mode to be modified, and the Reset procedure
16373 in this package can be used to reestablish the required mode.
16374
16375 @node GNAT.Heap_Sort (g-heasor.ads)
16376 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16377 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
16378 @cindex Sorting
16379
16380 @noindent
16381 Provides a general implementation of heap sort usable for sorting arbitrary
16382 data items. Exchange and comparison procedures are provided by passing
16383 access-to-procedure values. The algorithm used is a modified heap sort
16384 that performs approximately N*log(N) comparisons in the worst case.
16385
16386 @node GNAT.Heap_Sort_A (g-hesora.ads)
16387 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16388 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
16389 @cindex Sorting
16390
16391 @noindent
16392 Provides a general implementation of heap sort usable for sorting arbitrary
16393 data items. Move and comparison procedures are provided by passing
16394 access-to-procedure values. The algorithm used is a modified heap sort
16395 that performs approximately N*log(N) comparisons in the worst case.
16396 This differs from @code{GNAT.Heap_Sort} in having a less convenient
16397 interface, but may be slightly more efficient.
16398
16399 @node GNAT.Heap_Sort_G (g-hesorg.ads)
16400 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16401 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
16402 @cindex Sorting
16403
16404 @noindent
16405 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
16406 are provided as generic parameters, this improves efficiency, especially
16407 if the procedures can be inlined, at the expense of duplicating code for
16408 multiple instantiations.
16409
16410 @node GNAT.HTable (g-htable.ads)
16411 @section @code{GNAT.HTable} (@file{g-htable.ads})
16412 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
16413 @cindex Hash tables
16414
16415 @noindent
16416 A generic implementation of hash tables that can be used to hash arbitrary
16417 data. Provides two approaches, one a simple static approach, and the other
16418 allowing arbitrary dynamic hash tables.
16419
16420 @node GNAT.IO (g-io.ads)
16421 @section @code{GNAT.IO} (@file{g-io.ads})
16422 @cindex @code{GNAT.IO} (@file{g-io.ads})
16423 @cindex Simple I/O
16424 @cindex Input/Output facilities
16425
16426 @noindent
16427 A simple preelaborable input-output package that provides a subset of
16428 simple Text_IO functions for reading characters and strings from
16429 Standard_Input, and writing characters, strings and integers to either
16430 Standard_Output or Standard_Error.
16431
16432 @node GNAT.IO_Aux (g-io_aux.ads)
16433 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16434 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
16435 @cindex Text_IO
16436 @cindex Input/Output facilities
16437
16438 Provides some auxiliary functions for use with Text_IO, including a test
16439 for whether a file exists, and functions for reading a line of text.
16440
16441 @node GNAT.Lock_Files (g-locfil.ads)
16442 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16443 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
16444 @cindex File locking
16445 @cindex Locking using files
16446
16447 @noindent
16448 Provides a general interface for using files as locks. Can be used for
16449 providing program level synchronization.
16450
16451 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
16452 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16453 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
16454 @cindex Random number generation
16455
16456 @noindent
16457 The original implementation of @code{Ada.Numerics.Discrete_Random}. Uses
16458 a modified version of the Blum-Blum-Shub generator.
16459
16460 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
16461 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16462 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
16463 @cindex Random number generation
16464
16465 @noindent
16466 The original implementation of @code{Ada.Numerics.Float_Random}. Uses
16467 a modified version of the Blum-Blum-Shub generator.
16468
16469 @node GNAT.MD5 (g-md5.ads)
16470 @section @code{GNAT.MD5} (@file{g-md5.ads})
16471 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
16472 @cindex Message Digest MD5
16473
16474 @noindent
16475 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
16476
16477 @node GNAT.Memory_Dump (g-memdum.ads)
16478 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16479 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
16480 @cindex Dump Memory
16481
16482 @noindent
16483 Provides a convenient routine for dumping raw memory to either the
16484 standard output or standard error files. Uses GNAT.IO for actual
16485 output.
16486
16487 @node GNAT.Most_Recent_Exception (g-moreex.ads)
16488 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16489 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
16490 @cindex Exception, obtaining most recent
16491
16492 @noindent
16493 Provides access to the most recently raised exception. Can be used for
16494 various logging purposes, including duplicating functionality of some
16495 Ada 83 implementation dependent extensions.
16496
16497 @node GNAT.OS_Lib (g-os_lib.ads)
16498 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16499 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
16500 @cindex Operating System interface
16501 @cindex Spawn capability
16502
16503 @noindent
16504 Provides a range of target independent operating system interface functions,
16505 including time/date management, file operations, subprocess management,
16506 including a portable spawn procedure, and access to environment variables
16507 and error return codes.
16508
16509 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
16510 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16511 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
16512 @cindex Hash functions
16513
16514 @noindent
16515 Provides a generator of static minimal perfect hash functions. No
16516 collisions occur and each item can be retrieved from the table in one
16517 probe (perfect property). The hash table size corresponds to the exact
16518 size of the key set and no larger (minimal property). The key set has to
16519 be know in advance (static property). The hash functions are also order
16520 preserving. If w2 is inserted after w1 in the generator, their
16521 hashcode are in the same order. These hashing functions are very
16522 convenient for use with realtime applications.
16523
16524 @node GNAT.Random_Numbers (g-rannum.ads)
16525 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16526 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
16527 @cindex Random number generation
16528
16529 @noindent
16530 Provides random number capabilities which extend those available in the
16531 standard Ada library and are more convenient to use.
16532
16533 @node GNAT.Regexp (g-regexp.ads)
16534 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
16535 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
16536 @cindex Regular expressions
16537 @cindex Pattern matching
16538
16539 @noindent
16540 A simple implementation of regular expressions, using a subset of regular
16541 expression syntax copied from familiar Unix style utilities. This is the
16542 simples of the three pattern matching packages provided, and is particularly
16543 suitable for ``file globbing'' applications.
16544
16545 @node GNAT.Registry (g-regist.ads)
16546 @section @code{GNAT.Registry} (@file{g-regist.ads})
16547 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
16548 @cindex Windows Registry
16549
16550 @noindent
16551 This is a high level binding to the Windows registry. It is possible to
16552 do simple things like reading a key value, creating a new key. For full
16553 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
16554 package provided with the Win32Ada binding
16555
16556 @node GNAT.Regpat (g-regpat.ads)
16557 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
16558 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
16559 @cindex Regular expressions
16560 @cindex Pattern matching
16561
16562 @noindent
16563 A complete implementation of Unix-style regular expression matching, copied
16564 from the original V7 style regular expression library written in C by
16565 Henry Spencer (and binary compatible with this C library).
16566
16567 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
16568 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16569 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
16570 @cindex Secondary Stack Info
16571
16572 @noindent
16573 Provide the capability to query the high water mark of the current task's
16574 secondary stack.
16575
16576 @node GNAT.Semaphores (g-semaph.ads)
16577 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
16578 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
16579 @cindex Semaphores
16580
16581 @noindent
16582 Provides classic counting and binary semaphores using protected types.
16583
16584 @node GNAT.Serial_Communications (g-sercom.ads)
16585 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16586 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
16587 @cindex Serial_Communications
16588
16589 @noindent
16590 Provides a simple interface to send and receive data over a serial
16591 port. This is only supported on GNU/Linux and Windows.
16592
16593 @node GNAT.SHA1 (g-sha1.ads)
16594 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
16595 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
16596 @cindex Secure Hash Algorithm SHA-1
16597
16598 @noindent
16599 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
16600 and RFC 3174.
16601
16602 @node GNAT.SHA224 (g-sha224.ads)
16603 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
16604 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
16605 @cindex Secure Hash Algorithm SHA-224
16606
16607 @noindent
16608 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
16609
16610 @node GNAT.SHA256 (g-sha256.ads)
16611 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
16612 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
16613 @cindex Secure Hash Algorithm SHA-256
16614
16615 @noindent
16616 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
16617
16618 @node GNAT.SHA384 (g-sha384.ads)
16619 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
16620 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
16621 @cindex Secure Hash Algorithm SHA-384
16622
16623 @noindent
16624 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
16625
16626 @node GNAT.SHA512 (g-sha512.ads)
16627 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
16628 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
16629 @cindex Secure Hash Algorithm SHA-512
16630
16631 @noindent
16632 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
16633
16634 @node GNAT.Signals (g-signal.ads)
16635 @section @code{GNAT.Signals} (@file{g-signal.ads})
16636 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
16637 @cindex Signals
16638
16639 @noindent
16640 Provides the ability to manipulate the blocked status of signals on supported
16641 targets.
16642
16643 @node GNAT.Sockets (g-socket.ads)
16644 @section @code{GNAT.Sockets} (@file{g-socket.ads})
16645 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
16646 @cindex Sockets
16647
16648 @noindent
16649 A high level and portable interface to develop sockets based applications.
16650 This package is based on the sockets thin binding found in
16651 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
16652 on all native GNAT ports except for OpenVMS@. It is not implemented
16653 for the LynxOS@ cross port.
16654
16655 @node GNAT.Source_Info (g-souinf.ads)
16656 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
16657 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
16658 @cindex Source Information
16659
16660 @noindent
16661 Provides subprograms that give access to source code information known at
16662 compile time, such as the current file name and line number.
16663
16664 @node GNAT.Spelling_Checker (g-speche.ads)
16665 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16666 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
16667 @cindex Spell checking
16668
16669 @noindent
16670 Provides a function for determining whether one string is a plausible
16671 near misspelling of another string.
16672
16673 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
16674 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16675 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
16676 @cindex Spell checking
16677
16678 @noindent
16679 Provides a generic function that can be instantiated with a string type for
16680 determining whether one string is a plausible near misspelling of another
16681 string.
16682
16683 @node GNAT.Spitbol.Patterns (g-spipat.ads)
16684 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16685 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
16686 @cindex SPITBOL pattern matching
16687 @cindex Pattern matching
16688
16689 @noindent
16690 A complete implementation of SNOBOL4 style pattern matching. This is the
16691 most elaborate of the pattern matching packages provided. It fully duplicates
16692 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
16693 efficient algorithm developed by Robert Dewar for the SPITBOL system.
16694
16695 @node GNAT.Spitbol (g-spitbo.ads)
16696 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16697 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
16698 @cindex SPITBOL interface
16699
16700 @noindent
16701 The top level package of the collection of SPITBOL-style functionality, this
16702 package provides basic SNOBOL4 string manipulation functions, such as
16703 Pad, Reverse, Trim, Substr capability, as well as a generic table function
16704 useful for constructing arbitrary mappings from strings in the style of
16705 the SNOBOL4 TABLE function.
16706
16707 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
16708 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16709 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
16710 @cindex Sets of strings
16711 @cindex SPITBOL Tables
16712
16713 @noindent
16714 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16715 for type @code{Standard.Boolean}, giving an implementation of sets of
16716 string values.
16717
16718 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
16719 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16720 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
16721 @cindex Integer maps
16722 @cindex Maps
16723 @cindex SPITBOL Tables
16724
16725 @noindent
16726 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
16727 for type @code{Standard.Integer}, giving an implementation of maps
16728 from string to integer values.
16729
16730 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
16731 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16732 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
16733 @cindex String maps
16734 @cindex Maps
16735 @cindex SPITBOL Tables
16736
16737 @noindent
16738 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
16739 a variable length string type, giving an implementation of general
16740 maps from strings to strings.
16741
16742 @node GNAT.SSE (g-sse.ads)
16743 @section @code{GNAT.SSE} (@file{g-sse.ads})
16744 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
16745
16746 @noindent
16747 Root of a set of units aimed at offering Ada bindings to a subset of
16748 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
16749 targets. It exposes vector component types together with a general
16750 introduction to the binding contents and use.
16751
16752 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
16753 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16754 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
16755
16756 @noindent
16757 SSE vector types for use with SSE related intrinsics.
16758
16759 @node GNAT.Strings (g-string.ads)
16760 @section @code{GNAT.Strings} (@file{g-string.ads})
16761 @cindex @code{GNAT.Strings} (@file{g-string.ads})
16762
16763 @noindent
16764 Common String access types and related subprograms. Basically it
16765 defines a string access and an array of string access types.
16766
16767 @node GNAT.String_Split (g-strspl.ads)
16768 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
16769 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
16770 @cindex String splitter
16771
16772 @noindent
16773 Useful string manipulation routines: given a set of separators, split
16774 a string wherever the separators appear, and provide direct access
16775 to the resulting slices. This package is instantiated from
16776 @code{GNAT.Array_Split}.
16777
16778 @node GNAT.Table (g-table.ads)
16779 @section @code{GNAT.Table} (@file{g-table.ads})
16780 @cindex @code{GNAT.Table} (@file{g-table.ads})
16781 @cindex Table implementation
16782 @cindex Arrays, extendable
16783
16784 @noindent
16785 A generic package providing a single dimension array abstraction where the
16786 length of the array can be dynamically modified.
16787
16788 @noindent
16789 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
16790 except that this package declares a single instance of the table type,
16791 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
16792 used to define dynamic instances of the table.
16793
16794 @node GNAT.Task_Lock (g-tasloc.ads)
16795 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16796 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
16797 @cindex Task synchronization
16798 @cindex Task locking
16799 @cindex Locking
16800
16801 @noindent
16802 A very simple facility for locking and unlocking sections of code using a
16803 single global task lock. Appropriate for use in situations where contention
16804 between tasks is very rarely expected.
16805
16806 @node GNAT.Time_Stamp (g-timsta.ads)
16807 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16808 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
16809 @cindex Time stamp
16810 @cindex Current time
16811
16812 @noindent
16813 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
16814 represents the current date and time in ISO 8601 format. This is a very simple
16815 routine with minimal code and there are no dependencies on any other unit.
16816
16817 @node GNAT.Threads (g-thread.ads)
16818 @section @code{GNAT.Threads} (@file{g-thread.ads})
16819 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
16820 @cindex Foreign threads
16821 @cindex Threads, foreign
16822
16823 @noindent
16824 Provides facilities for dealing with foreign threads which need to be known
16825 by the GNAT run-time system. Consult the documentation of this package for
16826 further details if your program has threads that are created by a non-Ada
16827 environment which then accesses Ada code.
16828
16829 @node GNAT.Traceback (g-traceb.ads)
16830 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
16831 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
16832 @cindex Trace back facilities
16833
16834 @noindent
16835 Provides a facility for obtaining non-symbolic traceback information, useful
16836 in various debugging situations.
16837
16838 @node GNAT.Traceback.Symbolic (g-trasym.ads)
16839 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16840 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
16841 @cindex Trace back facilities
16842
16843 @node GNAT.UTF_32 (g-utf_32.ads)
16844 @section @code{GNAT.UTF_32} (@file{g-table.ads})
16845 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
16846 @cindex Wide character codes
16847
16848 @noindent
16849 This is a package intended to be used in conjunction with the
16850 @code{Wide_Character} type in Ada 95 and the
16851 @code{Wide_Wide_Character} type in Ada 2005 (available
16852 in @code{GNAT} in Ada 2005 mode). This package contains
16853 Unicode categorization routines, as well as lexical
16854 categorization routines corresponding to the Ada 2005
16855 lexical rules for identifiers and strings, and also a
16856 lower case to upper case fold routine corresponding to
16857 the Ada 2005 rules for identifier equivalence.
16858
16859 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
16860 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16861 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
16862 @cindex Spell checking
16863
16864 @noindent
16865 Provides a function for determining whether one wide wide string is a plausible
16866 near misspelling of another wide wide string, where the strings are represented
16867 using the UTF_32_String type defined in System.Wch_Cnv.
16868
16869 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
16870 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16871 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
16872 @cindex Spell checking
16873
16874 @noindent
16875 Provides a function for determining whether one wide string is a plausible
16876 near misspelling of another wide string.
16877
16878 @node GNAT.Wide_String_Split (g-wistsp.ads)
16879 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16880 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
16881 @cindex Wide_String splitter
16882
16883 @noindent
16884 Useful wide string manipulation routines: given a set of separators, split
16885 a wide string wherever the separators appear, and provide direct access
16886 to the resulting slices. This package is instantiated from
16887 @code{GNAT.Array_Split}.
16888
16889 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
16890 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16891 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
16892 @cindex Spell checking
16893
16894 @noindent
16895 Provides a function for determining whether one wide wide string is a plausible
16896 near misspelling of another wide wide string.
16897
16898 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
16899 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16900 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
16901 @cindex Wide_Wide_String splitter
16902
16903 @noindent
16904 Useful wide wide string manipulation routines: given a set of separators, split
16905 a wide wide string wherever the separators appear, and provide direct access
16906 to the resulting slices. This package is instantiated from
16907 @code{GNAT.Array_Split}.
16908
16909 @node Interfaces.C.Extensions (i-cexten.ads)
16910 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16911 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
16912
16913 @noindent
16914 This package contains additional C-related definitions, intended
16915 for use with either manually or automatically generated bindings
16916 to C libraries.
16917
16918 @node Interfaces.C.Streams (i-cstrea.ads)
16919 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16920 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
16921 @cindex C streams, interfacing
16922
16923 @noindent
16924 This package is a binding for the most commonly used operations
16925 on C streams.
16926
16927 @node Interfaces.CPP (i-cpp.ads)
16928 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
16929 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
16930 @cindex C++ interfacing
16931 @cindex Interfacing, to C++
16932
16933 @noindent
16934 This package provides facilities for use in interfacing to C++. It
16935 is primarily intended to be used in connection with automated tools
16936 for the generation of C++ interfaces.
16937
16938 @node Interfaces.Packed_Decimal (i-pacdec.ads)
16939 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16940 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
16941 @cindex IBM Packed Format
16942 @cindex Packed Decimal
16943
16944 @noindent
16945 This package provides a set of routines for conversions to and
16946 from a packed decimal format compatible with that used on IBM
16947 mainframes.
16948
16949 @node Interfaces.VxWorks (i-vxwork.ads)
16950 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16951 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
16952 @cindex Interfacing to VxWorks
16953 @cindex VxWorks, interfacing
16954
16955 @noindent
16956 This package provides a limited binding to the VxWorks API.
16957 In particular, it interfaces with the
16958 VxWorks hardware interrupt facilities.
16959
16960 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
16961 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16962 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
16963 @cindex Interfacing to VxWorks' I/O
16964 @cindex VxWorks, I/O interfacing
16965 @cindex VxWorks, Get_Immediate
16966 @cindex Get_Immediate, VxWorks
16967
16968 @noindent
16969 This package provides a binding to the ioctl (IO/Control)
16970 function of VxWorks, defining a set of option values and
16971 function codes. A particular use of this package is
16972 to enable the use of Get_Immediate under VxWorks.
16973
16974 @node System.Address_Image (s-addima.ads)
16975 @section @code{System.Address_Image} (@file{s-addima.ads})
16976 @cindex @code{System.Address_Image} (@file{s-addima.ads})
16977 @cindex Address image
16978 @cindex Image, of an address
16979
16980 @noindent
16981 This function provides a useful debugging
16982 function that gives an (implementation dependent)
16983 string which identifies an address.
16984
16985 @node System.Assertions (s-assert.ads)
16986 @section @code{System.Assertions} (@file{s-assert.ads})
16987 @cindex @code{System.Assertions} (@file{s-assert.ads})
16988 @cindex Assertions
16989 @cindex Assert_Failure, exception
16990
16991 @noindent
16992 This package provides the declaration of the exception raised
16993 by an run-time assertion failure, as well as the routine that
16994 is used internally to raise this assertion.
16995
16996 @node System.Memory (s-memory.ads)
16997 @section @code{System.Memory} (@file{s-memory.ads})
16998 @cindex @code{System.Memory} (@file{s-memory.ads})
16999 @cindex Memory allocation
17000
17001 @noindent
17002 This package provides the interface to the low level routines used
17003 by the generated code for allocation and freeing storage for the
17004 default storage pool (analogous to the C routines malloc and free.
17005 It also provides a reallocation interface analogous to the C routine
17006 realloc. The body of this unit may be modified to provide alternative
17007 allocation mechanisms for the default pool, and in addition, direct
17008 calls to this unit may be made for low level allocation uses (for
17009 example see the body of @code{GNAT.Tables}).
17010
17011 @node System.Multiprocessors (s-multip.ads)
17012 @section @code{System.Multiprocessors} (@file{s-multip.ads})
17013 @cindex @code{System.Multiprocessors} (@file{s-multip.ads})
17014 @cindex Multiprocessor interface
17015 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
17016 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
17017 technically an implementation-defined addition).
17018
17019 @node System.Multiprocessors.Dispatching_Domains (s-mudido.ads)
17020 @section @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
17021 @cindex @code{System.Multiprocessors.Dispatching_Domains} (@file{s-mudido.ads})
17022 @cindex Multiprocessor interface
17023 This is an Ada 2012 unit defined in the Ada 2012 Reference Manual, but
17024 in GNAT we also make it available in Ada 95 and Ada 2005 (where it is
17025 technically an implementation-defined addition).
17026
17027 @node System.Partition_Interface (s-parint.ads)
17028 @section @code{System.Partition_Interface} (@file{s-parint.ads})
17029 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
17030 @cindex Partition interfacing functions
17031
17032 @noindent
17033 This package provides facilities for partition interfacing. It
17034 is used primarily in a distribution context when using Annex E
17035 with @code{GLADE}.
17036
17037 @node System.Pool_Global (s-pooglo.ads)
17038 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
17039 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
17040 @cindex Storage pool, global
17041 @cindex Global storage pool
17042
17043 @noindent
17044 This package provides a storage pool that is equivalent to the default
17045 storage pool used for access types for which no pool is specifically
17046 declared. It uses malloc/free to allocate/free and does not attempt to
17047 do any automatic reclamation.
17048
17049 @node System.Pool_Local (s-pooloc.ads)
17050 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
17051 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
17052 @cindex Storage pool, local
17053 @cindex Local storage pool
17054
17055 @noindent
17056 This package provides a storage pool that is intended for use with locally
17057 defined access types. It uses malloc/free for allocate/free, and maintains
17058 a list of allocated blocks, so that all storage allocated for the pool can
17059 be freed automatically when the pool is finalized.
17060
17061 @node System.Restrictions (s-restri.ads)
17062 @section @code{System.Restrictions} (@file{s-restri.ads})
17063 @cindex @code{System.Restrictions} (@file{s-restri.ads})
17064 @cindex Run-time restrictions access
17065
17066 @noindent
17067 This package provides facilities for accessing at run time
17068 the status of restrictions specified at compile time for
17069 the partition. Information is available both with regard
17070 to actual restrictions specified, and with regard to
17071 compiler determined information on which restrictions
17072 are violated by one or more packages in the partition.
17073
17074 @node System.Rident (s-rident.ads)
17075 @section @code{System.Rident} (@file{s-rident.ads})
17076 @cindex @code{System.Rident} (@file{s-rident.ads})
17077 @cindex Restrictions definitions
17078
17079 @noindent
17080 This package provides definitions of the restrictions
17081 identifiers supported by GNAT, and also the format of
17082 the restrictions provided in package System.Restrictions.
17083 It is not normally necessary to @code{with} this generic package
17084 since the necessary instantiation is included in
17085 package System.Restrictions.
17086
17087 @node System.Strings.Stream_Ops (s-ststop.ads)
17088 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17089 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
17090 @cindex Stream operations
17091 @cindex String stream operations
17092
17093 @noindent
17094 This package provides a set of stream subprograms for standard string types.
17095 It is intended primarily to support implicit use of such subprograms when
17096 stream attributes are applied to string types, but the subprograms in this
17097 package can be used directly by application programs.
17098
17099 @node System.Task_Info (s-tasinf.ads)
17100 @section @code{System.Task_Info} (@file{s-tasinf.ads})
17101 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
17102 @cindex Task_Info pragma
17103
17104 @noindent
17105 This package provides target dependent functionality that is used
17106 to support the @code{Task_Info} pragma
17107
17108 @node System.Wch_Cnv (s-wchcnv.ads)
17109 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17110 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
17111 @cindex Wide Character, Representation
17112 @cindex Wide String, Conversion
17113 @cindex Representation of wide characters
17114
17115 @noindent
17116 This package provides routines for converting between
17117 wide and wide wide characters and a representation as a value of type
17118 @code{Standard.String}, using a specified wide character
17119 encoding method. It uses definitions in
17120 package @code{System.Wch_Con}.
17121
17122 @node System.Wch_Con (s-wchcon.ads)
17123 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
17124 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
17125
17126 @noindent
17127 This package provides definitions and descriptions of
17128 the various methods used for encoding wide characters
17129 in ordinary strings. These definitions are used by
17130 the package @code{System.Wch_Cnv}.
17131
17132 @node Interfacing to Other Languages
17133 @chapter Interfacing to Other Languages
17134 @noindent
17135 The facilities in annex B of the Ada Reference Manual are fully
17136 implemented in GNAT, and in addition, a full interface to C++ is
17137 provided.
17138
17139 @menu
17140 * Interfacing to C::
17141 * Interfacing to C++::
17142 * Interfacing to COBOL::
17143 * Interfacing to Fortran::
17144 * Interfacing to non-GNAT Ada code::
17145 @end menu
17146
17147 @node Interfacing to C
17148 @section Interfacing to C
17149
17150 @noindent
17151 Interfacing to C with GNAT can use one of two approaches:
17152
17153 @itemize @bullet
17154 @item
17155 The types in the package @code{Interfaces.C} may be used.
17156 @item
17157 Standard Ada types may be used directly. This may be less portable to
17158 other compilers, but will work on all GNAT compilers, which guarantee
17159 correspondence between the C and Ada types.
17160 @end itemize
17161
17162 @noindent
17163 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
17164 effect, since this is the default. The following table shows the
17165 correspondence between Ada scalar types and the corresponding C types.
17166
17167 @table @code
17168 @item Integer
17169 @code{int}
17170 @item Short_Integer
17171 @code{short}
17172 @item Short_Short_Integer
17173 @code{signed char}
17174 @item Long_Integer
17175 @code{long}
17176 @item Long_Long_Integer
17177 @code{long long}
17178 @item Short_Float
17179 @code{float}
17180 @item Float
17181 @code{float}
17182 @item Long_Float
17183 @code{double}
17184 @item Long_Long_Float
17185 This is the longest floating-point type supported by the hardware.
17186 @end table
17187
17188 @noindent
17189 Additionally, there are the following general correspondences between Ada
17190 and C types:
17191 @itemize @bullet
17192 @item
17193 Ada enumeration types map to C enumeration types directly if pragma
17194 @code{Convention C} is specified, which causes them to have int
17195 length. Without pragma @code{Convention C}, Ada enumeration types map to
17196 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
17197 @code{int}, respectively) depending on the number of values passed.
17198 This is the only case in which pragma @code{Convention C} affects the
17199 representation of an Ada type.
17200
17201 @item
17202 Ada access types map to C pointers, except for the case of pointers to
17203 unconstrained types in Ada, which have no direct C equivalent.
17204
17205 @item
17206 Ada arrays map directly to C arrays.
17207
17208 @item
17209 Ada records map directly to C structures.
17210
17211 @item
17212 Packed Ada records map to C structures where all members are bit fields
17213 of the length corresponding to the @code{@var{type}'Size} value in Ada.
17214 @end itemize
17215
17216 @node Interfacing to C++
17217 @section Interfacing to C++
17218
17219 @noindent
17220 The interface to C++ makes use of the following pragmas, which are
17221 primarily intended to be constructed automatically using a binding generator
17222 tool, although it is possible to construct them by hand.
17223
17224 Using these pragmas it is possible to achieve complete
17225 inter-operability between Ada tagged types and C++ class definitions.
17226 See @ref{Implementation Defined Pragmas}, for more details.
17227
17228 @table @code
17229 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
17230 The argument denotes an entity in the current declarative region that is
17231 declared as a tagged or untagged record type. It indicates that the type
17232 corresponds to an externally declared C++ class type, and is to be laid
17233 out the same way that C++ would lay out the type.
17234
17235 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
17236 for backward compatibility but its functionality is available
17237 using pragma @code{Import} with @code{Convention} = @code{CPP}.
17238
17239 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
17240 This pragma identifies an imported function (imported in the usual way
17241 with pragma @code{Import}) as corresponding to a C++ constructor.
17242 @end table
17243
17244 A few restrictions are placed on the use of the @code{Access} attribute
17245 in conjunction with subprograms subject to convention @code{CPP}: the
17246 attribute may be used neither on primitive operations of a tagged
17247 record type with convention @code{CPP}, imported or not, nor on
17248 subprograms imported with pragma @code{CPP_Constructor}.
17249
17250 In addition, C++ exceptions are propagated and can be handled in an
17251 @code{others} choice of an exception handler. The corresponding Ada
17252 occurrence has no message, and the simple name of the exception identity
17253 contains @samp{Foreign_Exception}. Finalization and awaiting dependent
17254 tasks works properly when such foreign exceptions are propagated.
17255
17256 @node Interfacing to COBOL
17257 @section Interfacing to COBOL
17258
17259 @noindent
17260 Interfacing to COBOL is achieved as described in section B.4 of
17261 the Ada Reference Manual.
17262
17263 @node Interfacing to Fortran
17264 @section Interfacing to Fortran
17265
17266 @noindent
17267 Interfacing to Fortran is achieved as described in section B.5 of the
17268 Ada Reference Manual. The pragma @code{Convention Fortran}, applied to a
17269 multi-dimensional array causes the array to be stored in column-major
17270 order as required for convenient interface to Fortran.
17271
17272 @node Interfacing to non-GNAT Ada code
17273 @section Interfacing to non-GNAT Ada code
17274
17275 It is possible to specify the convention @code{Ada} in a pragma
17276 @code{Import} or pragma @code{Export}. However this refers to
17277 the calling conventions used by GNAT, which may or may not be
17278 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
17279 compiler to allow interoperation.
17280
17281 If arguments types are kept simple, and if the foreign compiler generally
17282 follows system calling conventions, then it may be possible to integrate
17283 files compiled by other Ada compilers, provided that the elaboration
17284 issues are adequately addressed (for example by eliminating the
17285 need for any load time elaboration).
17286
17287 In particular, GNAT running on VMS is designed to
17288 be highly compatible with the DEC Ada 83 compiler, so this is one
17289 case in which it is possible to import foreign units of this type,
17290 provided that the data items passed are restricted to simple scalar
17291 values or simple record types without variants, or simple array
17292 types with fixed bounds.
17293
17294 @node Specialized Needs Annexes
17295 @chapter Specialized Needs Annexes
17296
17297 @noindent
17298 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
17299 required in all implementations. However, as described in this chapter,
17300 GNAT implements all of these annexes:
17301
17302 @table @asis
17303 @item Systems Programming (Annex C)
17304 The Systems Programming Annex is fully implemented.
17305
17306 @item Real-Time Systems (Annex D)
17307 The Real-Time Systems Annex is fully implemented.
17308
17309 @item Distributed Systems (Annex E)
17310 Stub generation is fully implemented in the GNAT compiler. In addition,
17311 a complete compatible PCS is available as part of the GLADE system,
17312 a separate product. When the two
17313 products are used in conjunction, this annex is fully implemented.
17314
17315 @item Information Systems (Annex F)
17316 The Information Systems annex is fully implemented.
17317
17318 @item Numerics (Annex G)
17319 The Numerics Annex is fully implemented.
17320
17321 @item Safety and Security / High-Integrity Systems (Annex H)
17322 The Safety and Security Annex (termed the High-Integrity Systems Annex
17323 in Ada 2005) is fully implemented.
17324 @end table
17325
17326 @node Implementation of Specific Ada Features
17327 @chapter Implementation of Specific Ada Features
17328
17329 @noindent
17330 This chapter describes the GNAT implementation of several Ada language
17331 facilities.
17332
17333 @menu
17334 * Machine Code Insertions::
17335 * GNAT Implementation of Tasking::
17336 * GNAT Implementation of Shared Passive Packages::
17337 * Code Generation for Array Aggregates::
17338 * The Size of Discriminated Records with Default Discriminants::
17339 * Strict Conformance to the Ada Reference Manual::
17340 @end menu
17341
17342 @node Machine Code Insertions
17343 @section Machine Code Insertions
17344 @cindex Machine Code insertions
17345
17346 @noindent
17347 Package @code{Machine_Code} provides machine code support as described
17348 in the Ada Reference Manual in two separate forms:
17349 @itemize @bullet
17350 @item
17351 Machine code statements, consisting of qualified expressions that
17352 fit the requirements of RM section 13.8.
17353 @item
17354 An intrinsic callable procedure, providing an alternative mechanism of
17355 including machine instructions in a subprogram.
17356 @end itemize
17357
17358 @noindent
17359 The two features are similar, and both are closely related to the mechanism
17360 provided by the asm instruction in the GNU C compiler. Full understanding
17361 and use of the facilities in this package requires understanding the asm
17362 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
17363 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
17364
17365 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
17366 semantic restrictions and effects as described below. Both are provided so
17367 that the procedure call can be used as a statement, and the function call
17368 can be used to form a code_statement.
17369
17370 The first example given in the GCC documentation is the C @code{asm}
17371 instruction:
17372 @smallexample
17373 asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
17374 @end smallexample
17375
17376 @noindent
17377 The equivalent can be written for GNAT as:
17378
17379 @smallexample @c ada
17380 Asm ("fsinx %1 %0",
17381 My_Float'Asm_Output ("=f", result),
17382 My_Float'Asm_Input ("f", angle));
17383 @end smallexample
17384
17385 @noindent
17386 The first argument to @code{Asm} is the assembler template, and is
17387 identical to what is used in GNU C@. This string must be a static
17388 expression. The second argument is the output operand list. It is
17389 either a single @code{Asm_Output} attribute reference, or a list of such
17390 references enclosed in parentheses (technically an array aggregate of
17391 such references).
17392
17393 The @code{Asm_Output} attribute denotes a function that takes two
17394 parameters. The first is a string, the second is the name of a variable
17395 of the type designated by the attribute prefix. The first (string)
17396 argument is required to be a static expression and designates the
17397 constraint for the parameter (e.g.@: what kind of register is
17398 required). The second argument is the variable to be updated with the
17399 result. The possible values for constraint are the same as those used in
17400 the RTL, and are dependent on the configuration file used to build the
17401 GCC back end. If there are no output operands, then this argument may
17402 either be omitted, or explicitly given as @code{No_Output_Operands}.
17403
17404 The second argument of @code{@var{my_float}'Asm_Output} functions as
17405 though it were an @code{out} parameter, which is a little curious, but
17406 all names have the form of expressions, so there is no syntactic
17407 irregularity, even though normally functions would not be permitted
17408 @code{out} parameters. The third argument is the list of input
17409 operands. It is either a single @code{Asm_Input} attribute reference, or
17410 a list of such references enclosed in parentheses (technically an array
17411 aggregate of such references).
17412
17413 The @code{Asm_Input} attribute denotes a function that takes two
17414 parameters. The first is a string, the second is an expression of the
17415 type designated by the prefix. The first (string) argument is required
17416 to be a static expression, and is the constraint for the parameter,
17417 (e.g.@: what kind of register is required). The second argument is the
17418 value to be used as the input argument. The possible values for the
17419 constant are the same as those used in the RTL, and are dependent on
17420 the configuration file used to built the GCC back end.
17421
17422 If there are no input operands, this argument may either be omitted, or
17423 explicitly given as @code{No_Input_Operands}. The fourth argument, not
17424 present in the above example, is a list of register names, called the
17425 @dfn{clobber} argument. This argument, if given, must be a static string
17426 expression, and is a space or comma separated list of names of registers
17427 that must be considered destroyed as a result of the @code{Asm} call. If
17428 this argument is the null string (the default value), then the code
17429 generator assumes that no additional registers are destroyed.
17430
17431 The fifth argument, not present in the above example, called the
17432 @dfn{volatile} argument, is by default @code{False}. It can be set to
17433 the literal value @code{True} to indicate to the code generator that all
17434 optimizations with respect to the instruction specified should be
17435 suppressed, and that in particular, for an instruction that has outputs,
17436 the instruction will still be generated, even if none of the outputs are
17437 used. @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
17438 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
17439 Generally it is strongly advisable to use Volatile for any ASM statement
17440 that is missing either input or output operands, or when two or more ASM
17441 statements appear in sequence, to avoid unwanted optimizations. A warning
17442 is generated if this advice is not followed.
17443
17444 The @code{Asm} subprograms may be used in two ways. First the procedure
17445 forms can be used anywhere a procedure call would be valid, and
17446 correspond to what the RM calls ``intrinsic'' routines. Such calls can
17447 be used to intersperse machine instructions with other Ada statements.
17448 Second, the function forms, which return a dummy value of the limited
17449 private type @code{Asm_Insn}, can be used in code statements, and indeed
17450 this is the only context where such calls are allowed. Code statements
17451 appear as aggregates of the form:
17452
17453 @smallexample @c ada
17454 Asm_Insn'(Asm (@dots{}));
17455 Asm_Insn'(Asm_Volatile (@dots{}));
17456 @end smallexample
17457
17458 @noindent
17459 In accordance with RM rules, such code statements are allowed only
17460 within subprograms whose entire body consists of such statements. It is
17461 not permissible to intermix such statements with other Ada statements.
17462
17463 Typically the form using intrinsic procedure calls is more convenient
17464 and more flexible. The code statement form is provided to meet the RM
17465 suggestion that such a facility should be made available. The following
17466 is the exact syntax of the call to @code{Asm}. As usual, if named notation
17467 is used, the arguments may be given in arbitrary order, following the
17468 normal rules for use of positional and named arguments)
17469
17470 @smallexample
17471 ASM_CALL ::= Asm (
17472 [Template =>] static_string_EXPRESSION
17473 [,[Outputs =>] OUTPUT_OPERAND_LIST ]
17474 [,[Inputs =>] INPUT_OPERAND_LIST ]
17475 [,[Clobber =>] static_string_EXPRESSION ]
17476 [,[Volatile =>] static_boolean_EXPRESSION] )
17477
17478 OUTPUT_OPERAND_LIST ::=
17479 [PREFIX.]No_Output_Operands
17480 | OUTPUT_OPERAND_ATTRIBUTE
17481 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
17482
17483 OUTPUT_OPERAND_ATTRIBUTE ::=
17484 SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
17485
17486 INPUT_OPERAND_LIST ::=
17487 [PREFIX.]No_Input_Operands
17488 | INPUT_OPERAND_ATTRIBUTE
17489 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
17490
17491 INPUT_OPERAND_ATTRIBUTE ::=
17492 SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
17493 @end smallexample
17494
17495 @noindent
17496 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
17497 are declared in the package @code{Machine_Code} and must be referenced
17498 according to normal visibility rules. In particular if there is no
17499 @code{use} clause for this package, then appropriate package name
17500 qualification is required.
17501
17502 @node GNAT Implementation of Tasking
17503 @section GNAT Implementation of Tasking
17504
17505 @noindent
17506 This chapter outlines the basic GNAT approach to tasking (in particular,
17507 a multi-layered library for portability) and discusses issues related
17508 to compliance with the Real-Time Systems Annex.
17509
17510 @menu
17511 * Mapping Ada Tasks onto the Underlying Kernel Threads::
17512 * Ensuring Compliance with the Real-Time Annex::
17513 @end menu
17514
17515 @node Mapping Ada Tasks onto the Underlying Kernel Threads
17516 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
17517
17518 @noindent
17519 GNAT's run-time support comprises two layers:
17520
17521 @itemize @bullet
17522 @item GNARL (GNAT Run-time Layer)
17523 @item GNULL (GNAT Low-level Library)
17524 @end itemize
17525
17526 @noindent
17527 In GNAT, Ada's tasking services rely on a platform and OS independent
17528 layer known as GNARL@. This code is responsible for implementing the
17529 correct semantics of Ada's task creation, rendezvous, protected
17530 operations etc.
17531
17532 GNARL decomposes Ada's tasking semantics into simpler lower level
17533 operations such as create a thread, set the priority of a thread,
17534 yield, create a lock, lock/unlock, etc. The spec for these low-level
17535 operations constitutes GNULLI, the GNULL Interface. This interface is
17536 directly inspired from the POSIX real-time API@.
17537
17538 If the underlying executive or OS implements the POSIX standard
17539 faithfully, the GNULL Interface maps as is to the services offered by
17540 the underlying kernel. Otherwise, some target dependent glue code maps
17541 the services offered by the underlying kernel to the semantics expected
17542 by GNARL@.
17543
17544 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
17545 key point is that each Ada task is mapped on a thread in the underlying
17546 kernel. For example, in the case of VxWorks, one Ada task = one VxWorks task.
17547
17548 In addition Ada task priorities map onto the underlying thread priorities.
17549 Mapping Ada tasks onto the underlying kernel threads has several advantages:
17550
17551 @itemize @bullet
17552 @item
17553 The underlying scheduler is used to schedule the Ada tasks. This
17554 makes Ada tasks as efficient as kernel threads from a scheduling
17555 standpoint.
17556
17557 @item
17558 Interaction with code written in C containing threads is eased
17559 since at the lowest level Ada tasks and C threads map onto the same
17560 underlying kernel concept.
17561
17562 @item
17563 When an Ada task is blocked during I/O the remaining Ada tasks are
17564 able to proceed.
17565
17566 @item
17567 On multiprocessor systems Ada tasks can execute in parallel.
17568 @end itemize
17569
17570 @noindent
17571 Some threads libraries offer a mechanism to fork a new process, with the
17572 child process duplicating the threads from the parent.
17573 GNAT does not
17574 support this functionality when the parent contains more than one task.
17575 @cindex Forking a new process
17576
17577 @node Ensuring Compliance with the Real-Time Annex
17578 @subsection Ensuring Compliance with the Real-Time Annex
17579 @cindex Real-Time Systems Annex compliance
17580
17581 @noindent
17582 Although mapping Ada tasks onto
17583 the underlying threads has significant advantages, it does create some
17584 complications when it comes to respecting the scheduling semantics
17585 specified in the real-time annex (Annex D).
17586
17587 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
17588 scheduling policy states:
17589
17590 @quotation
17591 @emph{When the active priority of a ready task that is not running
17592 changes, or the setting of its base priority takes effect, the
17593 task is removed from the ready queue for its old active priority
17594 and is added at the tail of the ready queue for its new active
17595 priority, except in the case where the active priority is lowered
17596 due to the loss of inherited priority, in which case the task is
17597 added at the head of the ready queue for its new active priority.}
17598 @end quotation
17599
17600 @noindent
17601 While most kernels do put tasks at the end of the priority queue when
17602 a task changes its priority, (which respects the main
17603 FIFO_Within_Priorities requirement), almost none keep a thread at the
17604 beginning of its priority queue when its priority drops from the loss
17605 of inherited priority.
17606
17607 As a result most vendors have provided incomplete Annex D implementations.
17608
17609 The GNAT run-time, has a nice cooperative solution to this problem
17610 which ensures that accurate FIFO_Within_Priorities semantics are
17611 respected.
17612
17613 The principle is as follows. When an Ada task T is about to start
17614 running, it checks whether some other Ada task R with the same
17615 priority as T has been suspended due to the loss of priority
17616 inheritance. If this is the case, T yields and is placed at the end of
17617 its priority queue. When R arrives at the front of the queue it
17618 executes.
17619
17620 Note that this simple scheme preserves the relative order of the tasks
17621 that were ready to execute in the priority queue where R has been
17622 placed at the end.
17623
17624 @node GNAT Implementation of Shared Passive Packages
17625 @section GNAT Implementation of Shared Passive Packages
17626 @cindex Shared passive packages
17627
17628 @noindent
17629 GNAT fully implements the pragma @code{Shared_Passive} for
17630 @cindex pragma @code{Shared_Passive}
17631 the purpose of designating shared passive packages.
17632 This allows the use of passive partitions in the
17633 context described in the Ada Reference Manual; i.e., for communication
17634 between separate partitions of a distributed application using the
17635 features in Annex E.
17636 @cindex Annex E
17637 @cindex Distribution Systems Annex
17638
17639 However, the implementation approach used by GNAT provides for more
17640 extensive usage as follows:
17641
17642 @table @emph
17643 @item Communication between separate programs
17644
17645 This allows separate programs to access the data in passive
17646 partitions, using protected objects for synchronization where
17647 needed. The only requirement is that the two programs have a
17648 common shared file system. It is even possible for programs
17649 running on different machines with different architectures
17650 (e.g.@: different endianness) to communicate via the data in
17651 a passive partition.
17652
17653 @item Persistence between program runs
17654
17655 The data in a passive package can persist from one run of a
17656 program to another, so that a later program sees the final
17657 values stored by a previous run of the same program.
17658
17659 @end table
17660
17661 @noindent
17662 The implementation approach used is to store the data in files. A
17663 separate stream file is created for each object in the package, and
17664 an access to an object causes the corresponding file to be read or
17665 written.
17666
17667 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
17668 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
17669 set to the directory to be used for these files.
17670 The files in this directory
17671 have names that correspond to their fully qualified names. For
17672 example, if we have the package
17673
17674 @smallexample @c ada
17675 package X is
17676 pragma Shared_Passive (X);
17677 Y : Integer;
17678 Z : Float;
17679 end X;
17680 @end smallexample
17681
17682 @noindent
17683 and the environment variable is set to @code{/stemp/}, then the files created
17684 will have the names:
17685
17686 @smallexample
17687 /stemp/x.y
17688 /stemp/x.z
17689 @end smallexample
17690
17691 @noindent
17692 These files are created when a value is initially written to the object, and
17693 the files are retained until manually deleted. This provides the persistence
17694 semantics. If no file exists, it means that no partition has assigned a value
17695 to the variable; in this case the initial value declared in the package
17696 will be used. This model ensures that there are no issues in synchronizing
17697 the elaboration process, since elaboration of passive packages elaborates the
17698 initial values, but does not create the files.
17699
17700 The files are written using normal @code{Stream_IO} access.
17701 If you want to be able
17702 to communicate between programs or partitions running on different
17703 architectures, then you should use the XDR versions of the stream attribute
17704 routines, since these are architecture independent.
17705
17706 If active synchronization is required for access to the variables in the
17707 shared passive package, then as described in the Ada Reference Manual, the
17708 package may contain protected objects used for this purpose. In this case
17709 a lock file (whose name is @file{___lock} (three underscores)
17710 is created in the shared memory directory.
17711 @cindex @file{___lock} file (for shared passive packages)
17712 This is used to provide the required locking
17713 semantics for proper protected object synchronization.
17714
17715 As of January 2003, GNAT supports shared passive packages on all platforms
17716 except for OpenVMS.
17717
17718 @node Code Generation for Array Aggregates
17719 @section Code Generation for Array Aggregates
17720
17721 @menu
17722 * Static constant aggregates with static bounds::
17723 * Constant aggregates with unconstrained nominal types::
17724 * Aggregates with static bounds::
17725 * Aggregates with non-static bounds::
17726 * Aggregates in assignment statements::
17727 @end menu
17728
17729 @noindent
17730 Aggregates have a rich syntax and allow the user to specify the values of
17731 complex data structures by means of a single construct. As a result, the
17732 code generated for aggregates can be quite complex and involve loops, case
17733 statements and multiple assignments. In the simplest cases, however, the
17734 compiler will recognize aggregates whose components and constraints are
17735 fully static, and in those cases the compiler will generate little or no
17736 executable code. The following is an outline of the code that GNAT generates
17737 for various aggregate constructs. For further details, you will find it
17738 useful to examine the output produced by the -gnatG flag to see the expanded
17739 source that is input to the code generator. You may also want to examine
17740 the assembly code generated at various levels of optimization.
17741
17742 The code generated for aggregates depends on the context, the component values,
17743 and the type. In the context of an object declaration the code generated is
17744 generally simpler than in the case of an assignment. As a general rule, static
17745 component values and static subtypes also lead to simpler code.
17746
17747 @node Static constant aggregates with static bounds
17748 @subsection Static constant aggregates with static bounds
17749
17750 @noindent
17751 For the declarations:
17752 @smallexample @c ada
17753 type One_Dim is array (1..10) of integer;
17754 ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
17755 @end smallexample
17756
17757 @noindent
17758 GNAT generates no executable code: the constant ar0 is placed in static memory.
17759 The same is true for constant aggregates with named associations:
17760
17761 @smallexample @c ada
17762 Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
17763 Cr3 : constant One_Dim := (others => 7777);
17764 @end smallexample
17765
17766 @noindent
17767 The same is true for multidimensional constant arrays such as:
17768
17769 @smallexample @c ada
17770 type two_dim is array (1..3, 1..3) of integer;
17771 Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
17772 @end smallexample
17773
17774 @noindent
17775 The same is true for arrays of one-dimensional arrays: the following are
17776 static:
17777
17778 @smallexample @c ada
17779 type ar1b is array (1..3) of boolean;
17780 type ar_ar is array (1..3) of ar1b;
17781 None : constant ar1b := (others => false); -- fully static
17782 None2 : constant ar_ar := (1..3 => None); -- fully static
17783 @end smallexample
17784
17785 @noindent
17786 However, for multidimensional aggregates with named associations, GNAT will
17787 generate assignments and loops, even if all associations are static. The
17788 following two declarations generate a loop for the first dimension, and
17789 individual component assignments for the second dimension:
17790
17791 @smallexample @c ada
17792 Zero1: constant two_dim := (1..3 => (1..3 => 0));
17793 Zero2: constant two_dim := (others => (others => 0));
17794 @end smallexample
17795
17796 @node Constant aggregates with unconstrained nominal types
17797 @subsection Constant aggregates with unconstrained nominal types
17798
17799 @noindent
17800 In such cases the aggregate itself establishes the subtype, so that
17801 associations with @code{others} cannot be used. GNAT determines the
17802 bounds for the actual subtype of the aggregate, and allocates the
17803 aggregate statically as well. No code is generated for the following:
17804
17805 @smallexample @c ada
17806 type One_Unc is array (natural range <>) of integer;
17807 Cr_Unc : constant One_Unc := (12,24,36);
17808 @end smallexample
17809
17810 @node Aggregates with static bounds
17811 @subsection Aggregates with static bounds
17812
17813 @noindent
17814 In all previous examples the aggregate was the initial (and immutable) value
17815 of a constant. If the aggregate initializes a variable, then code is generated
17816 for it as a combination of individual assignments and loops over the target
17817 object. The declarations
17818
17819 @smallexample @c ada
17820 Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
17821 Cr_Var2 : One_Dim := (others > -1);
17822 @end smallexample
17823
17824 @noindent
17825 generate the equivalent of
17826
17827 @smallexample @c ada
17828 Cr_Var1 (1) := 2;
17829 Cr_Var1 (2) := 3;
17830 Cr_Var1 (3) := 5;
17831 Cr_Var1 (4) := 11;
17832
17833 for I in Cr_Var2'range loop
17834 Cr_Var2 (I) := -1;
17835 end loop;
17836 @end smallexample
17837
17838 @node Aggregates with non-static bounds
17839 @subsection Aggregates with non-static bounds
17840
17841 @noindent
17842 If the bounds of the aggregate are not statically compatible with the bounds
17843 of the nominal subtype of the target, then constraint checks have to be
17844 generated on the bounds. For a multidimensional array, constraint checks may
17845 have to be applied to sub-arrays individually, if they do not have statically
17846 compatible subtypes.
17847
17848 @node Aggregates in assignment statements
17849 @subsection Aggregates in assignment statements
17850
17851 @noindent
17852 In general, aggregate assignment requires the construction of a temporary,
17853 and a copy from the temporary to the target of the assignment. This is because
17854 it is not always possible to convert the assignment into a series of individual
17855 component assignments. For example, consider the simple case:
17856
17857 @smallexample @c ada
17858 A := (A(2), A(1));
17859 @end smallexample
17860
17861 @noindent
17862 This cannot be converted into:
17863
17864 @smallexample @c ada
17865 A(1) := A(2);
17866 A(2) := A(1);
17867 @end smallexample
17868
17869 @noindent
17870 So the aggregate has to be built first in a separate location, and then
17871 copied into the target. GNAT recognizes simple cases where this intermediate
17872 step is not required, and the assignments can be performed in place, directly
17873 into the target. The following sufficient criteria are applied:
17874
17875 @itemize @bullet
17876 @item
17877 The bounds of the aggregate are static, and the associations are static.
17878 @item
17879 The components of the aggregate are static constants, names of
17880 simple variables that are not renamings, or expressions not involving
17881 indexed components whose operands obey these rules.
17882 @end itemize
17883
17884 @noindent
17885 If any of these conditions are violated, the aggregate will be built in
17886 a temporary (created either by the front-end or the code generator) and then
17887 that temporary will be copied onto the target.
17888
17889 @node The Size of Discriminated Records with Default Discriminants
17890 @section The Size of Discriminated Records with Default Discriminants
17891
17892 @noindent
17893 If a discriminated type @code{T} has discriminants with default values, it is
17894 possible to declare an object of this type without providing an explicit
17895 constraint:
17896
17897 @smallexample @c ada
17898 @group
17899 type Size is range 1..100;
17900
17901 type Rec (D : Size := 15) is record
17902 Name : String (1..D);
17903 end T;
17904
17905 Word : Rec;
17906 @end group
17907 @end smallexample
17908
17909 @noindent
17910 Such an object is said to be @emph{unconstrained}.
17911 The discriminant of the object
17912 can be modified by a full assignment to the object, as long as it preserves the
17913 relation between the value of the discriminant, and the value of the components
17914 that depend on it:
17915
17916 @smallexample @c ada
17917 @group
17918 Word := (3, "yes");
17919
17920 Word := (5, "maybe");
17921
17922 Word := (5, "no"); -- raises Constraint_Error
17923 @end group
17924 @end smallexample
17925
17926 @noindent
17927 In order to support this behavior efficiently, an unconstrained object is
17928 given the maximum size that any value of the type requires. In the case
17929 above, @code{Word} has storage for the discriminant and for
17930 a @code{String} of length 100.
17931 It is important to note that unconstrained objects do not require dynamic
17932 allocation. It would be an improper implementation to place on the heap those
17933 components whose size depends on discriminants. (This improper implementation
17934 was used by some Ada83 compilers, where the @code{Name} component above
17935 would have
17936 been stored as a pointer to a dynamic string). Following the principle that
17937 dynamic storage management should never be introduced implicitly,
17938 an Ada compiler should reserve the full size for an unconstrained declared
17939 object, and place it on the stack.
17940
17941 This maximum size approach
17942 has been a source of surprise to some users, who expect the default
17943 values of the discriminants to determine the size reserved for an
17944 unconstrained object: ``If the default is 15, why should the object occupy
17945 a larger size?''
17946 The answer, of course, is that the discriminant may be later modified,
17947 and its full range of values must be taken into account. This is why the
17948 declaration:
17949
17950 @smallexample
17951 @group
17952 type Rec (D : Positive := 15) is record
17953 Name : String (1..D);
17954 end record;
17955
17956 Too_Large : Rec;
17957 @end group
17958 @end smallexample
17959
17960 @noindent
17961 is flagged by the compiler with a warning:
17962 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
17963 because the required size includes @code{Positive'Last}
17964 bytes. As the first example indicates, the proper approach is to declare an
17965 index type of ``reasonable'' range so that unconstrained objects are not too
17966 large.
17967
17968 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
17969 created in the heap by means of an allocator, then it is @emph{not}
17970 unconstrained:
17971 it is constrained by the default values of the discriminants, and those values
17972 cannot be modified by full assignment. This is because in the presence of
17973 aliasing all views of the object (which may be manipulated by different tasks,
17974 say) must be consistent, so it is imperative that the object, once created,
17975 remain invariant.
17976
17977 @node Strict Conformance to the Ada Reference Manual
17978 @section Strict Conformance to the Ada Reference Manual
17979
17980 @noindent
17981 The dynamic semantics defined by the Ada Reference Manual impose a set of
17982 run-time checks to be generated. By default, the GNAT compiler will insert many
17983 run-time checks into the compiled code, including most of those required by the
17984 Ada Reference Manual. However, there are three checks that are not enabled
17985 in the default mode for efficiency reasons: arithmetic overflow checking for
17986 integer operations (including division by zero), checks for access before
17987 elaboration on subprogram calls, and stack overflow checking (most operating
17988 systems do not perform this check by default).
17989
17990 Strict conformance to the Ada Reference Manual can be achieved by adding
17991 three compiler options for overflow checking for integer operations
17992 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
17993 calls and generic instantiations (@option{-gnatE}), and stack overflow
17994 checking (@option{-fstack-check}).
17995
17996 Note that the result of a floating point arithmetic operation in overflow and
17997 invalid situations, when the @code{Machine_Overflows} attribute of the result
17998 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
17999 case for machines compliant with the IEEE floating-point standard, but on
18000 machines that are not fully compliant with this standard, such as Alpha, the
18001 @option{-mieee} compiler flag must be used for achieving IEEE confirming
18002 behavior (although at the cost of a significant performance penalty), so
18003 infinite and NaN values are properly generated.
18004
18005
18006 @node Implementation of Ada 2012 Features
18007 @chapter Implementation of Ada 2012 Features
18008 @cindex Ada 2012 implementation status
18009
18010 This chapter contains a complete list of Ada 2012 features that have been
18011 implemented as of GNAT version 6.4. Generally, these features are only
18012 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
18013 @cindex @option{-gnat12} option
18014 or if the configuration pragma @code{Ada_2012} is used.
18015 @cindex pragma @code{Ada_2012}
18016 @cindex configuration pragma @code{Ada_2012}
18017 @cindex @code{Ada_2012} configuration pragma
18018 However, new pragmas, attributes, and restrictions are
18019 unconditionally available, since the Ada 95 standard allows the addition of
18020 new pragmas, attributes, and restrictions (there are exceptions, which are
18021 documented in the individual descriptions), and also certain packages
18022 were made available in earlier versions of Ada.
18023
18024 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
18025 This date shows the implementation date of the feature. Any wavefront
18026 subsequent to this date will contain the indicated feature, as will any
18027 subsequent releases. A date of 0000-00-00 means that GNAT has always
18028 implemented the feature, or implemented it as soon as it appeared as a
18029 binding interpretation.
18030
18031 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
18032 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
18033 The features are ordered based on the relevant sections of the Ada
18034 Reference Manual (``RM''). When a given AI relates to multiple points
18035 in the RM, the earliest is used.
18036
18037 A complete description of the AIs may be found in
18038 @url{www.ada-auth.org/ai05-summary.html}.
18039
18040 @itemize @bullet
18041
18042 @item
18043 @emph{AI-0176 Quantified expressions (2010-09-29)}
18044 @cindex AI-0176 (Ada 2012 feature)
18045
18046 @noindent
18047 Both universally and existentially quantified expressions are implemented.
18048 They use the new syntax for iterators proposed in AI05-139-2, as well as
18049 the standard Ada loop syntax.
18050
18051 @noindent
18052 RM References: 1.01.04 (12) 2.09 (2/2) 4.04 (7) 4.05.09 (0)
18053
18054 @item
18055 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
18056 @cindex AI-0079 (Ada 2012 feature)
18057
18058 @noindent
18059 Wide characters in the unicode category @i{other_format} are now allowed in
18060 source programs between tokens, but not within a token such as an identifier.
18061
18062 @noindent
18063 RM References: 2.01 (4/2) 2.02 (7)
18064
18065 @item
18066 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
18067 @cindex AI-0091 (Ada 2012 feature)
18068
18069 @noindent
18070 Wide characters in the unicode category @i{other_format} are not permitted
18071 within an identifier, since this can be a security problem. The error
18072 message for this case has been improved to be more specific, but GNAT has
18073 never allowed such characters to appear in identifiers.
18074
18075 @noindent
18076 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)
18077
18078 @item
18079 @emph{AI-0100 Placement of pragmas (2010-07-01)}
18080 @cindex AI-0100 (Ada 2012 feature)
18081
18082 @noindent
18083 This AI is an earlier version of AI-163. It simplifies the rules
18084 for legal placement of pragmas. In the case of lists that allow pragmas, if
18085 the list may have no elements, then the list may consist solely of pragmas.
18086
18087 @noindent
18088 RM References: 2.08 (7)
18089
18090 @item
18091 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
18092 @cindex AI-0163 (Ada 2012 feature)
18093
18094 @noindent
18095 A statement sequence may be composed entirely of pragmas. It is no longer
18096 necessary to add a dummy @code{null} statement to make the sequence legal.
18097
18098 @noindent
18099 RM References: 2.08 (7) 2.08 (16)
18100
18101
18102 @item
18103 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
18104 @cindex AI-0080 (Ada 2012 feature)
18105
18106 @noindent
18107 This is an editorial change only, described as non-testable in the AI.
18108
18109 @noindent
18110 RM References: 3.01 (7)
18111
18112
18113 @item
18114 @emph{AI-0183 Aspect specifications (2010-08-16)}
18115 @cindex AI-0183 (Ada 2012 feature)
18116
18117 @noindent
18118 Aspect specifications have been fully implemented except for pre and post-
18119 conditions, and type invariants, which have their own separate AI's. All
18120 forms of declarations listed in the AI are supported. The following is a
18121 list of the aspects supported (with GNAT implementation aspects marked)
18122
18123 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
18124 @item @code{Ada_2005} @tab -- GNAT
18125 @item @code{Ada_2012} @tab -- GNAT
18126 @item @code{Address} @tab
18127 @item @code{Alignment} @tab
18128 @item @code{Atomic} @tab
18129 @item @code{Atomic_Components} @tab
18130 @item @code{Bit_Order} @tab
18131 @item @code{Component_Size} @tab
18132 @item @code{Contract_Case} @tab -- GNAT
18133 @item @code{Discard_Names} @tab
18134 @item @code{External_Tag} @tab
18135 @item @code{Favor_Top_Level} @tab -- GNAT
18136 @item @code{Inline} @tab
18137 @item @code{Inline_Always} @tab -- GNAT
18138 @item @code{Invariant} @tab -- GNAT
18139 @item @code{Machine_Radix} @tab
18140 @item @code{No_Return} @tab
18141 @item @code{Object_Size} @tab -- GNAT
18142 @item @code{Pack} @tab
18143 @item @code{Persistent_BSS} @tab -- GNAT
18144 @item @code{Post} @tab
18145 @item @code{Pre} @tab
18146 @item @code{Predicate} @tab
18147 @item @code{Preelaborable_Initialization} @tab
18148 @item @code{Pure_Function} @tab -- GNAT
18149 @item @code{Remote_Access_Type} @tab -- GNAT
18150 @item @code{Shared} @tab -- GNAT
18151 @item @code{Size} @tab
18152 @item @code{Storage_Pool} @tab
18153 @item @code{Storage_Size} @tab
18154 @item @code{Stream_Size} @tab
18155 @item @code{Suppress} @tab
18156 @item @code{Suppress_Debug_Info} @tab -- GNAT
18157 @item @code{Test_Case} @tab -- GNAT
18158 @item @code{Type_Invariant} @tab
18159 @item @code{Unchecked_Union} @tab
18160 @item @code{Universal_Aliasing} @tab -- GNAT
18161 @item @code{Unmodified} @tab -- GNAT
18162 @item @code{Unreferenced} @tab -- GNAT
18163 @item @code{Unreferenced_Objects} @tab -- GNAT
18164 @item @code{Unsuppress} @tab
18165 @item @code{Value_Size} @tab -- GNAT
18166 @item @code{Volatile} @tab
18167 @item @code{Volatile_Components}
18168 @item @code{Warnings} @tab -- GNAT
18169 @end multitable
18170
18171 @noindent
18172 Note that for aspects with an expression, e.g. @code{Size}, the expression is
18173 treated like a default expression (visibility is analyzed at the point of
18174 occurrence of the aspect, but evaluation of the expression occurs at the
18175 freeze point of the entity involved.
18176
18177 @noindent
18178 RM References: 3.02.01 (3) 3.02.02 (2) 3.03.01 (2/2) 3.08 (6)
18179 3.09.03 (1.1/2) 6.01 (2/2) 6.07 (2/2) 9.05.02 (2/2) 7.01 (3) 7.03
18180 (2) 7.03 (3) 9.01 (2/2) 9.01 (3/2) 9.04 (2/2) 9.04 (3/2)
18181 9.05.02 (2/2) 11.01 (2) 12.01 (3) 12.03 (2/2) 12.04 (2/2) 12.05 (2)
18182 12.06 (2.1/2) 12.06 (2.2/2) 12.07 (2) 13.01 (0.1/2) 13.03 (5/1)
18183 13.03.01 (0)
18184
18185
18186 @item
18187 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
18188 @cindex AI-0128 (Ada 2012 feature)
18189
18190 @noindent
18191 If an equality operator ("=") is declared for a type, then the implicitly
18192 declared inequality operator ("/=") is a primitive operation of the type.
18193 This is the only reasonable interpretation, and is the one always implemented
18194 by GNAT, but the RM was not entirely clear in making this point.
18195
18196 @noindent
18197 RM References: 3.02.03 (6) 6.06 (6)
18198
18199 @item
18200 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
18201 @cindex AI-0003 (Ada 2012 feature)
18202
18203 @noindent
18204 In Ada 2012, a qualified expression is considered to be syntactically a name,
18205 meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
18206 useful in disambiguating some cases of overloading.
18207
18208 @noindent
18209 RM References: 3.03 (11) 3.03 (21) 4.01 (2) 4.04 (7) 4.07 (3)
18210 5.04 (7)
18211
18212 @item
18213 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
18214 @cindex AI-0120 (Ada 2012 feature)
18215
18216 @noindent
18217 This is an RM editorial change only. The section that lists objects that are
18218 constant failed to include the current instance of a protected object
18219 within a protected function. This has always been treated as a constant
18220 in GNAT.
18221
18222 @noindent
18223 RM References: 3.03 (21)
18224
18225 @item
18226 @emph{AI-0008 General access to constrained objects (0000-00-00)}
18227 @cindex AI-0008 (Ada 2012 feature)
18228
18229 @noindent
18230 The wording in the RM implied that if you have a general access to a
18231 constrained object, it could be used to modify the discriminants. This was
18232 obviously not intended. @code{Constraint_Error} should be raised, and GNAT
18233 has always done so in this situation.
18234
18235 @noindent
18236 RM References: 3.03 (23) 3.10.02 (26/2) 4.01 (9) 6.04.01 (17) 8.05.01 (5/2)
18237
18238
18239 @item
18240 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
18241 @cindex AI-0093 (Ada 2012 feature)
18242
18243 @noindent
18244 This is an editorial change only, to make more widespread use of the Ada 2012
18245 ``immutably limited''.
18246
18247 @noindent
18248 RM References: 3.03 (23.4/3)
18249
18250
18251
18252 @item
18253 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
18254 @cindex AI-0096 (Ada 2012 feature)
18255
18256 @noindent
18257 In general it is illegal for a type derived from a formal limited type to be
18258 nonlimited. This AI makes an exception to this rule: derivation is legal
18259 if it appears in the private part of the generic, and the formal type is not
18260 tagged. If the type is tagged, the legality check must be applied to the
18261 private part of the package.
18262
18263 @noindent
18264 RM References: 3.04 (5.1/2) 6.02 (7)
18265
18266
18267 @item
18268 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
18269 @cindex AI-0181 (Ada 2012 feature)
18270
18271 @noindent
18272 From Ada 2005 on, soft hyphen is considered a non-graphic character, which
18273 means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
18274 @code{Image} and @code{Value} attributes for the character types. Strictly
18275 speaking this is an inconsistency with Ada 95, but in practice the use of
18276 these attributes is so obscure that it will not cause problems.
18277
18278 @noindent
18279 RM References: 3.05.02 (2/2) A.01 (35/2) A.03.03 (21)
18280
18281
18282 @item
18283 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
18284 @cindex AI-0182 (Ada 2012 feature)
18285
18286 @noindent
18287 This AI allows @code{Character'Value} to accept the string @code{'?'} where
18288 @code{?} is any character including non-graphic control characters. GNAT has
18289 always accepted such strings. It also allows strings such as
18290 @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
18291 permission and raises @code{Constraint_Error}, as is certainly still
18292 permitted.
18293
18294 @noindent
18295 RM References: 3.05 (56/2)
18296
18297
18298 @item
18299 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
18300 @cindex AI-0214 (Ada 2012 feature)
18301
18302 @noindent
18303 Ada 2012 relaxes the restriction that forbids discriminants of tagged types
18304 to have default expressions by allowing them when the type is limited. It
18305 is often useful to define a default value for a discriminant even though
18306 it can't be changed by assignment.
18307
18308 @noindent
18309 RM References: 3.07 (9.1/2) 3.07.02 (3)
18310
18311
18312 @item
18313 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
18314 @cindex AI-0102 (Ada 2012 feature)
18315
18316 @noindent
18317 It is illegal to assign an anonymous access constant to an anonymous access
18318 variable. The RM did not have a clear rule to prevent this, but GNAT has
18319 always generated an error for this usage.
18320
18321 @noindent
18322 RM References: 3.07 (16) 3.07.01 (9) 6.04.01 (6) 8.06 (27/2)
18323
18324
18325 @item
18326 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
18327 @cindex AI-0158 (Ada 2012 feature)
18328
18329 @noindent
18330 This AI extends the syntax of membership tests to simplify complex conditions
18331 that can be expressed as membership in a subset of values of any type. It
18332 introduces syntax for a list of expressions that may be used in loop contexts
18333 as well.
18334
18335 @noindent
18336 RM References: 3.08.01 (5) 4.04 (3) 4.05.02 (3) 4.05.02 (5) 4.05.02 (27)
18337
18338
18339 @item
18340 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
18341 @cindex AI-0173 (Ada 2012 feature)
18342
18343 @noindent
18344 The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
18345 with the tag of an abstract type, and @code{False} otherwise.
18346
18347 @noindent
18348 RM References: 3.09 (7.4/2) 3.09 (12.4/2)
18349
18350
18351
18352 @item
18353 @emph{AI-0076 function with controlling result (0000-00-00)}
18354 @cindex AI-0076 (Ada 2012 feature)
18355
18356 @noindent
18357 This is an editorial change only. The RM defines calls with controlling
18358 results, but uses the term ``function with controlling result'' without an
18359 explicit definition.
18360
18361 @noindent
18362 RM References: 3.09.02 (2/2)
18363
18364
18365 @item
18366 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
18367 @cindex AI-0126 (Ada 2012 feature)
18368
18369 @noindent
18370 This AI clarifies dispatching rules, and simply confirms that dispatching
18371 executes the operation of the parent type when there is no explicitly or
18372 implicitly declared operation for the descendant type. This has always been
18373 the case in all versions of GNAT.
18374
18375 @noindent
18376 RM References: 3.09.02 (20/2) 3.09.02 (20.1/2) 3.09.02 (20.2/2)
18377
18378
18379 @item
18380 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
18381 @cindex AI-0097 (Ada 2012 feature)
18382
18383 @noindent
18384 The RM as written implied that in some cases it was possible to create an
18385 object of an abstract type, by having an abstract extension inherit a non-
18386 abstract constructor from its parent type. This mistake has been corrected
18387 in GNAT and in the RM, and this construct is now illegal.
18388
18389 @noindent
18390 RM References: 3.09.03 (4/2)
18391
18392
18393 @item
18394 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
18395 @cindex AI-0203 (Ada 2012 feature)
18396
18397 @noindent
18398 A return_subtype_indication cannot denote an abstract subtype. GNAT has never
18399 permitted such usage.
18400
18401 @noindent
18402 RM References: 3.09.03 (8/3)
18403
18404
18405 @item
18406 @emph{AI-0198 Inheriting abstract operators (0000-00-00)}
18407 @cindex AI-0198 (Ada 2012 feature)
18408
18409 @noindent
18410 This AI resolves a conflict between two rules involving inherited abstract
18411 operations and predefined operators. If a derived numeric type inherits
18412 an abstract operator, it overrides the predefined one. This interpretation
18413 was always the one implemented in GNAT.
18414
18415 @noindent
18416 RM References: 3.09.03 (4/3)
18417
18418 @item
18419 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
18420 @cindex AI-0073 (Ada 2012 feature)
18421
18422 @noindent
18423 This AI covers a number of issues regarding returning abstract types. In
18424 particular generic functions cannot have abstract result types or access
18425 result types designated an abstract type. There are some other cases which
18426 are detailed in the AI. Note that this binding interpretation has not been
18427 retrofitted to operate before Ada 2012 mode, since it caused a significant
18428 number of regressions.
18429
18430 @noindent
18431 RM References: 3.09.03 (8) 3.09.03 (10) 6.05 (8/2)
18432
18433
18434 @item
18435 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
18436 @cindex AI-0070 (Ada 2012 feature)
18437
18438 @noindent
18439 This is an editorial change only, there are no testable consequences short of
18440 checking for the absence of generated code for an interface declaration.
18441
18442 @noindent
18443 RM References: 3.09.04 (18/2)
18444
18445
18446 @item
18447 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
18448 @cindex AI-0208 (Ada 2012 feature)
18449
18450 @noindent
18451 The wording in the Ada 2005 RM concerning characteristics of incomplete views
18452 was incorrect and implied that some programs intended to be legal were now
18453 illegal. GNAT had never considered such programs illegal, so it has always
18454 implemented the intent of this AI.
18455
18456 @noindent
18457 RM References: 3.10.01 (2.4/2) 3.10.01 (2.6/2)
18458
18459
18460 @item
18461 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
18462 @cindex AI-0162 (Ada 2012 feature)
18463
18464 @noindent
18465 Incomplete types are made more useful by allowing them to be completed by
18466 private types and private extensions.
18467
18468 @noindent
18469 RM References: 3.10.01 (2.5/2) 3.10.01 (2.6/2) 3.10.01 (3) 3.10.01 (4/2)
18470
18471
18472
18473 @item
18474 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
18475 @cindex AI-0098 (Ada 2012 feature)
18476
18477 @noindent
18478 An unintentional omission in the RM implied some inconsistent restrictions on
18479 the use of anonymous access to subprogram values. These restrictions were not
18480 intentional, and have never been enforced by GNAT.
18481
18482 @noindent
18483 RM References: 3.10.01 (6) 3.10.01 (9.2/2)
18484
18485
18486 @item
18487 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
18488 @cindex AI-0199 (Ada 2012 feature)
18489
18490 @noindent
18491 A choice list in a record aggregate can include several components of
18492 (distinct) anonymous access types as long as they have matching designated
18493 subtypes.
18494
18495 @noindent
18496 RM References: 4.03.01 (16)
18497
18498
18499 @item
18500 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
18501 @cindex AI-0220 (Ada 2012 feature)
18502
18503 @noindent
18504 This AI addresses a wording problem in the RM that appears to permit some
18505 complex cases of aggregates with non-static discriminants. GNAT has always
18506 implemented the intended semantics.
18507
18508 @noindent
18509 RM References: 4.03.01 (17)
18510
18511 @item
18512 @emph{AI-0147 Conditional expressions (2009-03-29)}
18513 @cindex AI-0147 (Ada 2012 feature)
18514
18515 @noindent
18516 Conditional expressions are permitted. The form of such an expression is:
18517
18518 @smallexample
18519 (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
18520 @end smallexample
18521
18522 The parentheses can be omitted in contexts where parentheses are present
18523 anyway, such as subprogram arguments and pragma arguments. If the @b{else}
18524 clause is omitted, @b{else True} is assumed;
18525 thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
18526 @emph{(A implies B)} in standard logic.
18527
18528 @noindent
18529 RM References: 4.03.03 (15) 4.04 (1) 4.04 (7) 4.05.07 (0) 4.07 (2)
18530 4.07 (3) 4.09 (12) 4.09 (33) 5.03 (3) 5.03 (4) 7.05 (2.1/2)
18531
18532
18533 @item
18534 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
18535 @cindex AI-0037 (Ada 2012 feature)
18536
18537 @noindent
18538 This AI confirms that an association of the form @code{Indx => <>} in an
18539 array aggregate must raise @code{Constraint_Error} if @code{Indx}
18540 is out of range. The RM specified a range check on other associations, but
18541 not when the value of the association was defaulted. GNAT has always inserted
18542 a constraint check on the index value.
18543
18544 @noindent
18545 RM References: 4.03.03 (29)
18546
18547
18548 @item
18549 @emph{AI-0123 Composability of equality (2010-04-13)}
18550 @cindex AI-0123 (Ada 2012 feature)
18551
18552 @noindent
18553 Equality of untagged record composes, so that the predefined equality for a
18554 composite type that includes a component of some untagged record type
18555 @code{R} uses the equality operation of @code{R} (which may be user-defined
18556 or predefined). This makes the behavior of untagged records identical to that
18557 of tagged types in this respect.
18558
18559 This change is an incompatibility with previous versions of Ada, but it
18560 corrects a non-uniformity that was often a source of confusion. Analysis of
18561 a large number of industrial programs indicates that in those rare cases
18562 where a composite type had an untagged record component with a user-defined
18563 equality, either there was no use of the composite equality, or else the code
18564 expected the same composability as for tagged types, and thus had a bug that
18565 would be fixed by this change.
18566
18567 @noindent
18568 RM References: 4.05.02 (9.7/2) 4.05.02 (14) 4.05.02 (15) 4.05.02 (24)
18569 8.05.04 (8)
18570
18571
18572 @item
18573 @emph{AI-0088 The value of exponentiation (0000-00-00)}
18574 @cindex AI-0088 (Ada 2012 feature)
18575
18576 @noindent
18577 This AI clarifies the equivalence rule given for the dynamic semantics of
18578 exponentiation: the value of the operation can be obtained by repeated
18579 multiplication, but the operation can be implemented otherwise (for example
18580 using the familiar divide-by-two-and-square algorithm, even if this is less
18581 accurate), and does not imply repeated reads of a volatile base.
18582
18583 @noindent
18584 RM References: 4.05.06 (11)
18585
18586 @item
18587 @emph{AI-0188 Case expressions (2010-01-09)}
18588 @cindex AI-0188 (Ada 2012 feature)
18589
18590 @noindent
18591 Case expressions are permitted. This allows use of constructs such as:
18592 @smallexample
18593 X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
18594 @end smallexample
18595
18596 @noindent
18597 RM References: 4.05.07 (0) 4.05.08 (0) 4.09 (12) 4.09 (33)
18598
18599 @item
18600 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
18601 @cindex AI-0104 (Ada 2012 feature)
18602
18603 @noindent
18604 The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
18605 @code{Constraint_Error} because the default value of the allocated object is
18606 @b{null}. This useless construct is illegal in Ada 2012.
18607
18608 @noindent
18609 RM References: 4.08 (2)
18610
18611 @item
18612 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
18613 @cindex AI-0157 (Ada 2012 feature)
18614
18615 @noindent
18616 Allocation and Deallocation from an empty storage pool (i.e. allocation or
18617 deallocation of a pointer for which a static storage size clause of zero
18618 has been given) is now illegal and is detected as such. GNAT
18619 previously gave a warning but not an error.
18620
18621 @noindent
18622 RM References: 4.08 (5.3/2) 13.11.02 (4) 13.11.02 (17)
18623
18624 @item
18625 @emph{AI-0179 Statement not required after label (2010-04-10)}
18626 @cindex AI-0179 (Ada 2012 feature)
18627
18628 @noindent
18629 It is not necessary to have a statement following a label, so a label
18630 can appear at the end of a statement sequence without the need for putting a
18631 null statement afterwards, but it is not allowable to have only labels and
18632 no real statements in a statement sequence.
18633
18634 @noindent
18635 RM References: 5.01 (2)
18636
18637
18638 @item
18639 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
18640 @cindex AI-139-2 (Ada 2012 feature)
18641
18642 @noindent
18643 The new syntax for iterating over arrays and containers is now implemented.
18644 Iteration over containers is for now limited to read-only iterators. Only
18645 default iterators are supported, with the syntax: @code{@b{for} Elem @b{of} C}.
18646
18647 @noindent
18648 RM References: 5.05
18649
18650 @item
18651 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
18652 @cindex AI-0134 (Ada 2012 feature)
18653
18654 @noindent
18655 For full conformance, the profiles of anonymous-access-to-subprogram
18656 parameters must match. GNAT has always enforced this rule.
18657
18658 @noindent
18659 RM References: 6.03.01 (18)
18660
18661 @item
18662 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
18663 @cindex AI-0207 (Ada 2012 feature)
18664
18665 @noindent
18666 This AI confirms that access_to_constant indication must match for mode
18667 conformance. This was implemented in GNAT when the qualifier was originally
18668 introduced in Ada 2005.
18669
18670 @noindent
18671 RM References: 6.03.01 (16/2)
18672
18673
18674 @item
18675 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
18676 @cindex AI-0046 (Ada 2012 feature)
18677
18678 @noindent
18679 For full conformance, in the case of access parameters, the null exclusion
18680 must match (either both or neither must have @code{@b{not null}}).
18681
18682 @noindent
18683 RM References: 6.03.02 (18)
18684
18685
18686 @item
18687 @emph{AI-0118 The association of parameter associations (0000-00-00)}
18688 @cindex AI-0118 (Ada 2012 feature)
18689
18690 @noindent
18691 This AI clarifies the rules for named associations in subprogram calls and
18692 generic instantiations. The rules have been in place since Ada 83.
18693
18694 @noindent
18695 RM References: 6.04.01 (2) 12.03 (9)
18696
18697
18698 @item
18699 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
18700 @cindex AI-0196 (Ada 2012 feature)
18701
18702 @noindent
18703 Null exclusion checks are not made for @code{@b{out}} parameters when
18704 evaluating the actual parameters. GNAT has never generated these checks.
18705
18706 @noindent
18707 RM References: 6.04.01 (13)
18708
18709 @item
18710 @emph{AI-0015 Constant return objects (0000-00-00)}
18711 @cindex AI-0015 (Ada 2012 feature)
18712
18713 @noindent
18714 The return object declared in an @i{extended_return_statement} may be
18715 declared constant. This was always intended, and GNAT has always allowed it.
18716
18717 @noindent
18718 RM References: 6.05 (2.1/2) 3.03 (10/2) 3.03 (21) 6.05 (5/2)
18719 6.05 (5.7/2)
18720
18721
18722 @item
18723 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
18724 @cindex AI-0032 (Ada 2012 feature)
18725
18726 @noindent
18727 If a function returns a class-wide type, the object of an extended return
18728 statement can be declared with a specific type that is covered by the class-
18729 wide type. This has been implemented in GNAT since the introduction of
18730 extended returns. Note AI-0103 complements this AI by imposing matching
18731 rules for constrained return types.
18732
18733 @noindent
18734 RM References: 6.05 (5.2/2) 6.05 (5.3/2) 6.05 (5.6/2) 6.05 (5.8/2)
18735 6.05 (8/2)
18736
18737 @item
18738 @emph{AI-0103 Static matching for extended return (2010-07-23)}
18739 @cindex AI-0103 (Ada 2012 feature)
18740
18741 @noindent
18742 If the return subtype of a function is an elementary type or a constrained
18743 type, the subtype indication in an extended return statement must match
18744 statically this return subtype.
18745
18746 @noindent
18747 RM References: 6.05 (5.2/2)
18748
18749
18750 @item
18751 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
18752 @cindex AI-0058 (Ada 2012 feature)
18753
18754 @noindent
18755 The RM had some incorrect wording implying wrong treatment of abnormal
18756 completion in an extended return. GNAT has always implemented the intended
18757 correct semantics as described by this AI.
18758
18759 @noindent
18760 RM References: 6.05 (22/2)
18761
18762
18763 @item
18764 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
18765 @cindex AI-0050 (Ada 2012 feature)
18766
18767 @noindent
18768 The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
18769 not take advantage of these incorrect permissions in any case.
18770
18771 @noindent
18772 RM References: 6.05 (24/2)
18773
18774
18775 @item
18776 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
18777 @cindex AI-0125 (Ada 2012 feature)
18778
18779 @noindent
18780 In Ada 2012, the declaration of a primitive operation of a type extension
18781 or private extension can also override an inherited primitive that is not
18782 visible at the point of this declaration.
18783
18784 @noindent
18785 RM References: 7.03.01 (6) 8.03 (23) 8.03.01 (5/2) 8.03.01 (6/2)
18786
18787 @item
18788 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
18789 @cindex AI-0062 (Ada 2012 feature)
18790
18791 @noindent
18792 A full constant may have a null exclusion even if its associated deferred
18793 constant does not. GNAT has always allowed this.
18794
18795 @noindent
18796 RM References: 7.04 (6/2) 7.04 (7.1/2)
18797
18798
18799 @item
18800 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
18801 @cindex AI-0178 (Ada 2012 feature)
18802
18803 @noindent
18804 This AI clarifies the role of incomplete views and plugs an omission in the
18805 RM. GNAT always correctly restricted the use of incomplete views and types.
18806
18807 @noindent
18808 RM References: 7.05 (3/2) 7.05 (6/2)
18809
18810 @item
18811 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
18812 @cindex AI-0087 (Ada 2012 feature)
18813
18814 @noindent
18815 The actual for a formal nonlimited derived type cannot be limited. In
18816 particular, a formal derived type that extends a limited interface but which
18817 is not explicitly limited cannot be instantiated with a limited type.
18818
18819 @noindent
18820 RM References: 7.05 (5/2) 12.05.01 (5.1/2)
18821
18822 @item
18823 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
18824 @cindex AI-0099 (Ada 2012 feature)
18825
18826 @noindent
18827 This AI clarifies that ``needs finalization'' is part of dynamic semantics,
18828 and therefore depends on the run-time characteristics of an object (i.e. its
18829 tag) and not on its nominal type. As the AI indicates: ``we do not expect
18830 this to affect any implementation''.
18831
18832 @noindent
18833 RM References: 7.06.01 (6) 7.06.01 (7) 7.06.01 (8) 7.06.01 (9/2)
18834
18835
18836
18837 @item
18838 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
18839 @cindex AI-0064 (Ada 2012 feature)
18840
18841 @noindent
18842 This is an editorial change only. The intended behavior is already checked
18843 by an existing ACATS test, which GNAT has always executed correctly.
18844
18845 @noindent
18846 RM References: 7.06.01 (17.1/1)
18847
18848 @item
18849 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
18850 @cindex AI-0026 (Ada 2012 feature)
18851
18852 @noindent
18853 Record representation clauses concerning Unchecked_Union types cannot mention
18854 the discriminant of the type. The type of a component declared in the variant
18855 part of an Unchecked_Union cannot be controlled, have controlled components,
18856 nor have protected or task parts. If an Unchecked_Union type is declared
18857 within the body of a generic unit or its descendants, then the type of a
18858 component declared in the variant part cannot be a formal private type or a
18859 formal private extension declared within the same generic unit.
18860
18861 @noindent
18862 RM References: 7.06 (9.4/2) B.03.03 (9/2) B.03.03 (10/2)
18863
18864
18865 @item
18866 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
18867 @cindex AI-0205 (Ada 2012 feature)
18868
18869 @noindent
18870 This AI corrects a simple omission in the RM. Return objects have always
18871 been visible within an extended return statement.
18872
18873 @noindent
18874 RM References: 8.03 (17)
18875
18876
18877 @item
18878 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
18879 @cindex AI-0042 (Ada 2012 feature)
18880
18881 @noindent
18882 This AI fixes a wording gap in the RM. An operation of a synchronized
18883 interface can be implemented by a protected or task entry, but the abstract
18884 operation is not being overridden in the usual sense, and it must be stated
18885 separately that this implementation is legal. This has always been the case
18886 in GNAT.
18887
18888 @noindent
18889 RM References: 9.01 (9.2/2) 9.04 (11.1/2)
18890
18891 @item
18892 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
18893 @cindex AI-0030 (Ada 2012 feature)
18894
18895 @noindent
18896 Requeue is permitted to a protected, synchronized or task interface primitive
18897 providing it is known that the overriding operation is an entry. Otherwise
18898 the requeue statement has the same effect as a procedure call. Use of pragma
18899 @code{Implemented} provides a way to impose a static requirement on the
18900 overriding operation by adhering to one of the implementation kinds: entry,
18901 protected procedure or any of the above.
18902
18903 @noindent
18904 RM References: 9.05 (9) 9.05.04 (2) 9.05.04 (3) 9.05.04 (5)
18905 9.05.04 (6) 9.05.04 (7) 9.05.04 (12)
18906
18907
18908 @item
18909 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
18910 @cindex AI-0201 (Ada 2012 feature)
18911
18912 @noindent
18913 If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
18914 attribute, then individual components may not be addressable by independent
18915 tasks. However, if the representation clause has no effect (is confirming),
18916 then independence is not compromised. Furthermore, in GNAT, specification of
18917 other appropriately addressable component sizes (e.g. 16 for 8-bit
18918 characters) also preserves independence. GNAT now gives very clear warnings
18919 both for the declaration of such a type, and for any assignment to its components.
18920
18921 @noindent
18922 RM References: 9.10 (1/3) C.06 (22/2) C.06 (23/2)
18923
18924 @item
18925 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
18926 @cindex AI-0009 (Ada 2012 feature)
18927
18928 @noindent
18929 This AI introduces the new pragmas @code{Independent} and
18930 @code{Independent_Components},
18931 which control guaranteeing independence of access to objects and components.
18932 The AI also requires independence not unaffected by confirming rep clauses.
18933
18934 @noindent
18935 RM References: 9.10 (1) 13.01 (15/1) 13.02 (9) 13.03 (13) C.06 (2)
18936 C.06 (4) C.06 (6) C.06 (9) C.06 (13) C.06 (14)
18937
18938
18939 @item
18940 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
18941 @cindex AI-0072 (Ada 2012 feature)
18942
18943 @noindent
18944 This AI clarifies that task signalling for reading @code{'Terminated} only
18945 occurs if the result is True. GNAT semantics has always been consistent with
18946 this notion of task signalling.
18947
18948 @noindent
18949 RM References: 9.10 (6.1/1)
18950
18951 @item
18952 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
18953 @cindex AI-0108 (Ada 2012 feature)
18954
18955 @noindent
18956 This AI confirms that an incomplete type from a limited view does not have
18957 discriminants. This has always been the case in GNAT.
18958
18959 @noindent
18960 RM References: 10.01.01 (12.3/2)
18961
18962 @item
18963 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
18964 @cindex AI-0129 (Ada 2012 feature)
18965
18966 @noindent
18967 This AI clarifies the description of limited views: a limited view of a
18968 package includes only one view of a type that has an incomplete declaration
18969 and a full declaration (there is no possible ambiguity in a client package).
18970 This AI also fixes an omission: a nested package in the private part has no
18971 limited view. GNAT always implemented this correctly.
18972
18973 @noindent
18974 RM References: 10.01.01 (12.2/2) 10.01.01 (12.3/2)
18975
18976
18977
18978 @item
18979 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
18980 @cindex AI-0077 (Ada 2012 feature)
18981
18982 @noindent
18983 This AI clarifies that a declaration does not include a context clause,
18984 and confirms that it is illegal to have a context in which both a limited
18985 and a nonlimited view of a package are accessible. Such double visibility
18986 was always rejected by GNAT.
18987
18988 @noindent
18989 RM References: 10.01.02 (12/2) 10.01.02 (21/2) 10.01.02 (22/2)
18990
18991 @item
18992 @emph{AI-0122 Private with and children of generics (0000-00-00)}
18993 @cindex AI-0122 (Ada 2012 feature)
18994
18995 @noindent
18996 This AI clarifies the visibility of private children of generic units within
18997 instantiations of a parent. GNAT has always handled this correctly.
18998
18999 @noindent
19000 RM References: 10.01.02 (12/2)
19001
19002
19003
19004 @item
19005 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
19006 @cindex AI-0040 (Ada 2012 feature)
19007
19008 @noindent
19009 This AI confirms that a limited with clause in a child unit cannot name
19010 an ancestor of the unit. This has always been checked in GNAT.
19011
19012 @noindent
19013 RM References: 10.01.02 (20/2)
19014
19015 @item
19016 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
19017 @cindex AI-0132 (Ada 2012 feature)
19018
19019 @noindent
19020 This AI fills a gap in the description of library unit pragmas. The pragma
19021 clearly must apply to a library unit, even if it does not carry the name
19022 of the enclosing unit. GNAT has always enforced the required check.
19023
19024 @noindent
19025 RM References: 10.01.05 (7)
19026
19027
19028 @item
19029 @emph{AI-0034 Categorization of limited views (0000-00-00)}
19030 @cindex AI-0034 (Ada 2012 feature)
19031
19032 @noindent
19033 The RM makes certain limited with clauses illegal because of categorization
19034 considerations, when the corresponding normal with would be legal. This is
19035 not intended, and GNAT has always implemented the recommended behavior.
19036
19037 @noindent
19038 RM References: 10.02.01 (11/1) 10.02.01 (17/2)
19039
19040
19041 @item
19042 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
19043 @cindex AI-0035 (Ada 2012 feature)
19044
19045 @noindent
19046 This AI remedies some inconsistencies in the legality rules for Pure units.
19047 Derived access types are legal in a pure unit (on the assumption that the
19048 rule for a zero storage pool size has been enforced on the ancestor type).
19049 The rules are enforced in generic instances and in subunits. GNAT has always
19050 implemented the recommended behavior.
19051
19052 @noindent
19053 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)
19054
19055
19056 @item
19057 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
19058 @cindex AI-0219 (Ada 2012 feature)
19059
19060 @noindent
19061 This AI refines the rules for the cases with limited parameters which do not
19062 allow the implementations to omit ``redundant''. GNAT now properly conforms
19063 to the requirements of this binding interpretation.
19064
19065 @noindent
19066 RM References: 10.02.01 (18/2)
19067
19068 @item
19069 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
19070 @cindex AI-0043 (Ada 2012 feature)
19071
19072 @noindent
19073 This AI covers various omissions in the RM regarding the raising of
19074 exceptions. GNAT has always implemented the intended semantics.
19075
19076 @noindent
19077 RM References: 11.04.01 (10.1/2) 11 (2)
19078
19079
19080 @item
19081 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
19082 @cindex AI-0200 (Ada 2012 feature)
19083
19084 @noindent
19085 This AI plugs a gap in the RM which appeared to allow some obviously intended
19086 illegal instantiations. GNAT has never allowed these instantiations.
19087
19088 @noindent
19089 RM References: 12.07 (16)
19090
19091
19092 @item
19093 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
19094 @cindex AI-0112 (Ada 2012 feature)
19095
19096 @noindent
19097 This AI concerns giving names to various representation aspects, but the
19098 practical effect is simply to make the use of duplicate
19099 @code{Atomic}[@code{_Components}],
19100 @code{Volatile}[@code{_Components}] and
19101 @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
19102 now performs this required check.
19103
19104 @noindent
19105 RM References: 13.01 (8)
19106
19107 @item
19108 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
19109 @cindex AI-0106 (Ada 2012 feature)
19110
19111 @noindent
19112 The RM appeared to allow representation pragmas on generic formal parameters,
19113 but this was not intended, and GNAT has never permitted this usage.
19114
19115 @noindent
19116 RM References: 13.01 (9.1/1)
19117
19118
19119 @item
19120 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
19121 @cindex AI-0012 (Ada 2012 feature)
19122
19123 @noindent
19124 It is now illegal to give an inappropriate component size or a pragma
19125 @code{Pack} that attempts to change the component size in the case of atomic
19126 or aliased components. Previously GNAT ignored such an attempt with a
19127 warning.
19128
19129 @noindent
19130 RM References: 13.02 (6.1/2) 13.02 (7) C.06 (10) C.06 (11) C.06 (21)
19131
19132
19133 @item
19134 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
19135 @cindex AI-0039 (Ada 2012 feature)
19136
19137 @noindent
19138 The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
19139 for stream attributes, but these were never useful and are now illegal. GNAT
19140 has always regarded such expressions as illegal.
19141
19142 @noindent
19143 RM References: 13.03 (4) 13.03 (6) 13.13.02 (38/2)
19144
19145
19146 @item
19147 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
19148 @cindex AI-0095 (Ada 2012 feature)
19149
19150 @noindent
19151 The prefix of @code{'Address} cannot statically denote a subprogram with
19152 convention @code{Intrinsic}. The use of the @code{Address} attribute raises
19153 @code{Program_Error} if the prefix denotes a subprogram with convention
19154 @code{Intrinsic}.
19155
19156 @noindent
19157 RM References: 13.03 (11/1)
19158
19159
19160 @item
19161 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
19162 @cindex AI-0116 (Ada 2012 feature)
19163
19164 @noindent
19165 This AI requires that the alignment of a class-wide object be no greater
19166 than the alignment of any type in the class. GNAT has always followed this
19167 recommendation.
19168
19169 @noindent
19170 RM References: 13.03 (29) 13.11 (16)
19171
19172
19173 @item
19174 @emph{AI-0146 Type invariants (2009-09-21)}
19175 @cindex AI-0146 (Ada 2012 feature)
19176
19177 @noindent
19178 Type invariants may be specified for private types using the aspect notation.
19179 Aspect @code{Type_Invariant} may be specified for any private type,
19180 @code{Type_Invariant'Class} can
19181 only be specified for tagged types, and is inherited by any descendent of the
19182 tagged types. The invariant is a boolean expression that is tested for being
19183 true in the following situations: conversions to the private type, object
19184 declarations for the private type that are default initialized, and
19185 [@b{in}] @b{out}
19186 parameters and returned result on return from any primitive operation for
19187 the type that is visible to a client.
19188 GNAT defines the synonyms @code{Invariant} for @code{Type_Invariant} and
19189 @code{Invariant'Class} for @code{Type_Invariant'Class}.
19190
19191 @noindent
19192 RM References: 13.03.03 (00)
19193
19194 @item
19195 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
19196 @cindex AI-0078 (Ada 2012 feature)
19197
19198 @noindent
19199 In Ada 2012, compilers are required to support unchecked conversion where the
19200 target alignment is a multiple of the source alignment. GNAT always supported
19201 this case (and indeed all cases of differing alignments, doing copies where
19202 required if the alignment was reduced).
19203
19204 @noindent
19205 RM References: 13.09 (7)
19206
19207
19208 @item
19209 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
19210 @cindex AI-0195 (Ada 2012 feature)
19211
19212 @noindent
19213 The handling of invalid values is now designated to be implementation
19214 defined. This is a documentation change only, requiring Annex M in the GNAT
19215 Reference Manual to document this handling.
19216 In GNAT, checks for invalid values are made
19217 only when necessary to avoid erroneous behavior. Operations like assignments
19218 which cannot cause erroneous behavior ignore the possibility of invalid
19219 values and do not do a check. The date given above applies only to the
19220 documentation change, this behavior has always been implemented by GNAT.
19221
19222 @noindent
19223 RM References: 13.09.01 (10)
19224
19225 @item
19226 @emph{AI-0193 Alignment of allocators (2010-09-16)}
19227 @cindex AI-0193 (Ada 2012 feature)
19228
19229 @noindent
19230 This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
19231 analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
19232 of size.
19233
19234 @noindent
19235 RM References: 13.11 (16) 13.11 (21) 13.11.01 (0) 13.11.01 (1)
19236 13.11.01 (2) 13.11.01 (3)
19237
19238
19239 @item
19240 @emph{AI-0177 Parameterized expressions (2010-07-10)}
19241 @cindex AI-0177 (Ada 2012 feature)
19242
19243 @noindent
19244 The new Ada 2012 notion of parameterized expressions is implemented. The form
19245 is:
19246 @smallexample
19247 @i{function specification} @b{is} (@i{expression})
19248 @end smallexample
19249
19250 @noindent
19251 This is exactly equivalent to the
19252 corresponding function body that returns the expression, but it can appear
19253 in a package spec. Note that the expression must be parenthesized.
19254
19255 @noindent
19256 RM References: 13.11.01 (3/2)
19257
19258 @item
19259 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
19260 @cindex AI-0033 (Ada 2012 feature)
19261
19262 @noindent
19263 Neither of these two pragmas may appear within a generic template, because
19264 the generic might be instantiated at other than the library level.
19265
19266 @noindent
19267 RM References: 13.11.02 (16) C.03.01 (7/2) C.03.01 (8/2)
19268
19269
19270 @item
19271 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
19272 @cindex AI-0161 (Ada 2012 feature)
19273
19274 @noindent
19275 A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
19276 of the default stream attributes for elementary types. If this restriction is
19277 in force, then it is necessary to provide explicit subprograms for any
19278 stream attributes used.
19279
19280 @noindent
19281 RM References: 13.12.01 (4/2) 13.13.02 (40/2) 13.13.02 (52/2)
19282
19283 @item
19284 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
19285 @cindex AI-0194 (Ada 2012 feature)
19286
19287 @noindent
19288 The @code{Stream_Size} attribute returns the default number of bits in the
19289 stream representation of the given type.
19290 This value is not affected by the presence
19291 of stream subprogram attributes for the type. GNAT has always implemented
19292 this interpretation.
19293
19294 @noindent
19295 RM References: 13.13.02 (1.2/2)
19296
19297 @item
19298 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
19299 @cindex AI-0109 (Ada 2012 feature)
19300
19301 @noindent
19302 This AI is an editorial change only. It removes the need for a tag check
19303 that can never fail.
19304
19305 @noindent
19306 RM References: 13.13.02 (34/2)
19307
19308 @item
19309 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
19310 @cindex AI-0007 (Ada 2012 feature)
19311
19312 @noindent
19313 The RM as written appeared to limit the possibilities of declaring read
19314 attribute procedures for private scalar types. This limitation was not
19315 intended, and has never been enforced by GNAT.
19316
19317 @noindent
19318 RM References: 13.13.02 (50/2) 13.13.02 (51/2)
19319
19320
19321 @item
19322 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
19323 @cindex AI-0065 (Ada 2012 feature)
19324
19325 @noindent
19326 This AI clarifies the fact that all remote access types support external
19327 streaming. This fixes an obvious oversight in the definition of the
19328 language, and GNAT always implemented the intended correct rules.
19329
19330 @noindent
19331 RM References: 13.13.02 (52/2)
19332
19333 @item
19334 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
19335 @cindex AI-0019 (Ada 2012 feature)
19336
19337 @noindent
19338 The RM suggests that primitive subprograms of a specific tagged type are
19339 frozen when the tagged type is frozen. This would be an incompatible change
19340 and is not intended. GNAT has never attempted this kind of freezing and its
19341 behavior is consistent with the recommendation of this AI.
19342
19343 @noindent
19344 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)
19345
19346 @item
19347 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
19348 @cindex AI-0017 (Ada 2012 feature)
19349
19350 @noindent
19351 So-called ``Taft-amendment types'' (i.e., types that are completed in package
19352 bodies) are not frozen by the occurrence of bodies in the
19353 enclosing declarative part. GNAT always implemented this properly.
19354
19355 @noindent
19356 RM References: 13.14 (3/1)
19357
19358
19359 @item
19360 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
19361 @cindex AI-0060 (Ada 2012 feature)
19362
19363 @noindent
19364 This AI extends the definition of remote access types to include access
19365 to limited, synchronized, protected or task class-wide interface types.
19366 GNAT already implemented this extension.
19367
19368 @noindent
19369 RM References: A (4) E.02.02 (9/1) E.02.02 (9.2/1) E.02.02 (14/2) E.02.02 (18)
19370
19371 @item
19372 @emph{AI-0114 Classification of letters (0000-00-00)}
19373 @cindex AI-0114 (Ada 2012 feature)
19374
19375 @noindent
19376 The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
19377 181 (@code{MICRO SIGN}), and
19378 186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
19379 lower case letters by Unicode.
19380 However, they are not allowed in identifiers, and they
19381 return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
19382 This behavior is consistent with that defined in Ada 95.
19383
19384 @noindent
19385 RM References: A.03.02 (59) A.04.06 (7)
19386
19387
19388 @item
19389 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
19390 @cindex AI-0185 (Ada 2012 feature)
19391
19392 @noindent
19393 Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
19394 classification functions for @code{Wide_Character} and
19395 @code{Wide_Wide_Character}, as well as providing
19396 case folding routines for @code{Wide_[Wide_]Character} and
19397 @code{Wide_[Wide_]String}.
19398
19399 @noindent
19400 RM References: A.03.05 (0) A.03.06 (0)
19401
19402
19403 @item
19404 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
19405 @cindex AI-0031 (Ada 2012 feature)
19406
19407 @noindent
19408 A new version of @code{Find_Token} is added to all relevant string packages,
19409 with an extra parameter @code{From}. Instead of starting at the first
19410 character of the string, the search for a matching Token starts at the
19411 character indexed by the value of @code{From}.
19412 These procedures are available in all versions of Ada
19413 but if used in versions earlier than Ada 2012 they will generate a warning
19414 that an Ada 2012 subprogram is being used.
19415
19416 @noindent
19417 RM References: A.04.03 (16) A.04.03 (67) A.04.03 (68/1) A.04.04 (51)
19418 A.04.05 (46)
19419
19420
19421 @item
19422 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
19423 @cindex AI-0056 (Ada 2012 feature)
19424
19425 @noindent
19426 The wording in the Ada 2005 RM implied an incompatible handling of the
19427 @code{Index} functions, resulting in raising an exception instead of
19428 returning zero in some situations.
19429 This was not intended and has been corrected.
19430 GNAT always returned zero, and is thus consistent with this AI.
19431
19432 @noindent
19433 RM References: A.04.03 (56.2/2) A.04.03 (58.5/2)
19434
19435
19436 @item
19437 @emph{AI-0137 String encoding package (2010-03-25)}
19438 @cindex AI-0137 (Ada 2012 feature)
19439
19440 @noindent
19441 The packages @code{Ada.Strings.UTF_Encoding}, together with its child
19442 packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
19443 and @code{Wide_Wide_Strings} have been
19444 implemented. These packages (whose documentation can be found in the spec
19445 files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
19446 @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
19447 @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
19448 values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
19449 UTF-16), as well as conversions between the different UTF encodings. With
19450 the exception of @code{Wide_Wide_Strings}, these packages are available in
19451 Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
19452 The @code{Wide_Wide_Strings package}
19453 is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
19454 mode since it uses @code{Wide_Wide_Character}).
19455
19456 @noindent
19457 RM References: A.04.11
19458
19459 @item
19460 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
19461 @cindex AI-0038 (Ada 2012 feature)
19462
19463 @noindent
19464 These are minor errors in the description on three points. The intent on
19465 all these points has always been clear, and GNAT has always implemented the
19466 correct intended semantics.
19467
19468 @noindent
19469 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)
19470
19471 @item
19472 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
19473 @cindex AI-0044 (Ada 2012 feature)
19474
19475 @noindent
19476 This AI places restrictions on allowed instantiations of generic containers.
19477 These restrictions are not checked by the compiler, so there is nothing to
19478 change in the implementation. This affects only the RM documentation.
19479
19480 @noindent
19481 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)
19482
19483 @item
19484 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
19485 @cindex AI-0127 (Ada 2012 feature)
19486
19487 @noindent
19488 This package provides an interface for identifying the current locale.
19489
19490 @noindent
19491 RM References: A.19 A.19.01 A.19.02 A.19.03 A.19.05 A.19.06
19492 A.19.07 A.19.08 A.19.09 A.19.10 A.19.11 A.19.12 A.19.13
19493
19494
19495
19496 @item
19497 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
19498 @cindex AI-0002 (Ada 2012 feature)
19499
19500 @noindent
19501 The compiler is not required to support exporting an Ada subprogram with
19502 convention C if there are parameters or a return type of an unconstrained
19503 array type (such as @code{String}). GNAT allows such declarations but
19504 generates warnings. It is possible, but complicated, to write the
19505 corresponding C code and certainly such code would be specific to GNAT and
19506 non-portable.
19507
19508 @noindent
19509 RM References: B.01 (17) B.03 (62) B.03 (71.1/2)
19510
19511
19512 @item
19513 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
19514 @cindex AI05-0216 (Ada 2012 feature)
19515
19516 @noindent
19517 It is clearly the intention that @code{No_Task_Hierarchy} is intended to
19518 forbid tasks declared locally within subprograms, or functions returning task
19519 objects, and that is the implementation that GNAT has always provided.
19520 However the language in the RM was not sufficiently clear on this point.
19521 Thus this is a documentation change in the RM only.
19522
19523 @noindent
19524 RM References: D.07 (3/3)
19525
19526 @item
19527 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
19528 @cindex AI-0211 (Ada 2012 feature)
19529
19530 @noindent
19531 The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
19532 @code{Ada.Real_Time.Timing_Events.Set_Handler}.
19533
19534 @noindent
19535 RM References: D.07 (5) D.07 (10/2) D.07 (10.4/2) D.07 (10.7/2)
19536
19537 @item
19538 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
19539 @cindex AI-0190 (Ada 2012 feature)
19540
19541 @noindent
19542 This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
19543 used to control storage pools globally.
19544 In particular, you can force every access
19545 type that is used for allocation (@b{new}) to have an explicit storage pool,
19546 or you can declare a pool globally to be used for all access types that lack
19547 an explicit one.
19548
19549 @noindent
19550 RM References: D.07 (8)
19551
19552 @item
19553 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
19554 @cindex AI-0189 (Ada 2012 feature)
19555
19556 @noindent
19557 This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
19558 which says that no dynamic allocation will occur once elaboration is
19559 completed.
19560 In general this requires a run-time check, which is not required, and which
19561 GNAT does not attempt. But the static cases of allocators in a task body or
19562 in the body of the main program are detected and flagged at compile or bind
19563 time.
19564
19565 @noindent
19566 RM References: D.07 (19.1/2) H.04 (23.3/2)
19567
19568 @item
19569 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
19570 @cindex AI-0171 (Ada 2012 feature)
19571
19572 @noindent
19573 A new package @code{System.Multiprocessors} is added, together with the
19574 definition of pragma @code{CPU} for controlling task affinity. A new no
19575 dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
19576 is added to the Ravenscar profile.
19577
19578 @noindent
19579 RM References: D.13.01 (4/2) D.16
19580
19581
19582 @item
19583 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
19584 @cindex AI-0210 (Ada 2012 feature)
19585
19586 @noindent
19587 This is a documentation only issue regarding wording of metric requirements,
19588 that does not affect the implementation of the compiler.
19589
19590 @noindent
19591 RM References: D.15 (24/2)
19592
19593
19594 @item
19595 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
19596 @cindex AI-0206 (Ada 2012 feature)
19597
19598 @noindent
19599 Remote types packages are now allowed to depend on preelaborated packages.
19600 This was formerly considered illegal.
19601
19602 @noindent
19603 RM References: E.02.02 (6)
19604
19605
19606
19607 @item
19608 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
19609 @cindex AI-0152 (Ada 2012 feature)
19610
19611 @noindent
19612 Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
19613 where the type of the returned value is an anonymous access type.
19614
19615 @noindent
19616 RM References: H.04 (8/1)
19617 @end itemize
19618
19619
19620 @node Obsolescent Features
19621 @chapter Obsolescent Features
19622
19623 @noindent
19624 This chapter describes features that are provided by GNAT, but are
19625 considered obsolescent since there are preferred ways of achieving
19626 the same effect. These features are provided solely for historical
19627 compatibility purposes.
19628
19629 @menu
19630 * pragma No_Run_Time::
19631 * pragma Ravenscar::
19632 * pragma Restricted_Run_Time::
19633 @end menu
19634
19635 @node pragma No_Run_Time
19636 @section pragma No_Run_Time
19637
19638 The pragma @code{No_Run_Time} is used to achieve an affect similar
19639 to the use of the "Zero Foot Print" configurable run time, but without
19640 requiring a specially configured run time. The result of using this
19641 pragma, which must be used for all units in a partition, is to restrict
19642 the use of any language features requiring run-time support code. The
19643 preferred usage is to use an appropriately configured run-time that
19644 includes just those features that are to be made accessible.
19645
19646 @node pragma Ravenscar
19647 @section pragma Ravenscar
19648
19649 The pragma @code{Ravenscar} has exactly the same effect as pragma
19650 @code{Profile (Ravenscar)}. The latter usage is preferred since it
19651 is part of the new Ada 2005 standard.
19652
19653 @node pragma Restricted_Run_Time
19654 @section pragma Restricted_Run_Time
19655
19656 The pragma @code{Restricted_Run_Time} has exactly the same effect as
19657 pragma @code{Profile (Restricted)}. The latter usage is
19658 preferred since the Ada 2005 pragma @code{Profile} is intended for
19659 this kind of implementation dependent addition.
19660
19661 @include fdl.texi
19662 @c GNU Free Documentation License
19663
19664 @node Index,,GNU Free Documentation License, Top
19665 @unnumbered Index
19666
19667 @printindex cp
19668
19669 @contents
19670
19671 @bye